69 lines
1.5 KiB
JavaScript
69 lines
1.5 KiB
JavaScript
/*
|
|
Language: Bash
|
|
Author: vah <vahtenberg@gmail.com>
|
|
Contributrors: Benjamin Pannell <contact@sierrasoftworks.com>
|
|
*/
|
|
|
|
function(hljs) {
|
|
var VAR = {
|
|
className: 'variable',
|
|
variants: [
|
|
{begin: /\$[\w\d#@][\w\d_]*/},
|
|
{begin: /\$\{(.*?)\}/}
|
|
]
|
|
};
|
|
var QUOTE_STRING = {
|
|
className: 'string',
|
|
begin: /"/, end: /"/,
|
|
contains: [
|
|
hljs.BACKSLASH_ESCAPE,
|
|
VAR,
|
|
{
|
|
className: 'variable',
|
|
begin: /\$\(/, end: /\)/,
|
|
contains: [hljs.BACKSLASH_ESCAPE]
|
|
}
|
|
]
|
|
};
|
|
var APOS_STRING = {
|
|
className: 'string',
|
|
begin: /'/, end: /'/
|
|
};
|
|
|
|
return {
|
|
aliases: ['sh', 'zsh'],
|
|
lexemes: /-?[a-z\.]+/,
|
|
keywords: {
|
|
keyword:
|
|
'if then else elif fi for break continue while in do done exit return set '+
|
|
'declare case esac export exec',
|
|
literal:
|
|
'true false',
|
|
built_in:
|
|
'printf echo read cd pwd pushd popd dirs let eval unset typeset readonly '+
|
|
'getopts source shopt caller type hash bind help sudo',
|
|
operator:
|
|
'-ne -eq -lt -gt -f -d -e -s -l -a' // relevance booster
|
|
},
|
|
contains: [
|
|
{
|
|
className: 'shebang',
|
|
begin: /^#![^\n]+sh\s*$/,
|
|
relevance: 10
|
|
},
|
|
{
|
|
className: 'function',
|
|
begin: /\w[\w\d_]*\s*\(\s*\)\s*\{/,
|
|
returnBegin: true,
|
|
contains: [hljs.inherit(hljs.TITLE_MODE, {begin: /\w[\w\d_]*/})],
|
|
relevance: 0
|
|
},
|
|
hljs.HASH_COMMENT_MODE,
|
|
hljs.NUMBER_MODE,
|
|
QUOTE_STRING,
|
|
APOS_STRING,
|
|
VAR
|
|
]
|
|
};
|
|
}
|