1/* 2Language: Bash 3Author: vah <vahtenberg@gmail.com> 4*/ 5 6hljs.LANGUAGES.bash = function(){ 7 var BASH_LITERAL = {'true' : 1, 'false' : 1} 8 return { 9 defaultMode: { 10 lexems: [hljs.IDENT_RE], 11 contains: ['string', 'shebang', 'comment', 'number', 'test_condition', 'string', 'variable'], 12 keywords: { 13 'keyword': {'if' : 1, 'then' : 1, 'else' : 1, 'fi' : 1, 'for' : 1, 'break' : 1, 'continue' : 1, 'while' : 1, 'in' : 1, 'do' : 1, 'done' : 1, 'echo' : 1, 'exit' : 1, 'return' : 1, 'set' : 1, 'declare' : 1}, 14 'literal': BASH_LITERAL 15 } 16 }, 17 case_insensitive: false, 18 modes: [ 19 { 20 className: 'shebang', 21 begin: '(#!\\/bin\\/bash)|(#!\\/bin\\/sh)', 22 end: '^', 23 relevance: 10 24 }, 25 hljs.HASH_COMMENT_MODE, 26 { 27 className: 'test_condition', 28 begin: '\\[ ', 29 end: ' \\]', 30 contains: ['string', 'variable', 'number'], 31 lexems: [hljs.IDENT_RE], 32 keywords: { 33 'literal': BASH_LITERAL 34 }, 35 relevance: 0 36 }, 37 { 38 className: 'test_condition', 39 begin: '\\[\\[ ', 40 end: ' \\]\\]', 41 contains: ['string', 'variable', 'number'], 42 lexems: [hljs.IDENT_RE], 43 keywords: { 44 'literal': BASH_LITERAL 45 } 46 }, 47 { 48 className: 'variable', 49 begin: '\\$([a-zA-Z0-9_]+)\\b', 50 end: '^' 51 }, 52 { 53 className: 'variable', 54 begin: '\\$\\{(([^}])|(\\\\}))+\\}', 55 end: '^', 56 contains: ['number'] 57 }, 58 { 59 className: 'string', 60 begin: '"', end: '"', 61 illegal: '\\n', 62 contains: ['escape', 'variable'], 63 relevance: 0 64 }, 65 { 66 className: 'string', 67 begin: '"', end: '"', 68 illegal: '\\n', 69 contains: ['escape', 'variable'], 70 relevance: 0 71 }, 72 hljs.BACKSLASH_ESCAPE, 73 hljs.C_NUMBER_MODE, 74 { 75 className: 'comment', 76 begin: '\\/\\/', end: '$', 77 illegal: '.' 78 } 79 ] 80 }; 81}(); 82