{ "displayName": "Shell", "name": "shellscript", "patterns": [ { "include": "#initial_context" } ], "repository": { "alias_statement": { "begin": "[\\t ]*+(alias)[\\t ]*+((?:((?\\\\`|]+(?!>))" }, { "include": "#normal_context" } ] }, "arithmetic_double": { "patterns": [ { "begin": "\\(\\(", "beginCaptures": { "0": { "name": "punctuation.section.arithmetic.double.shell" } }, "end": "\\)\\s*\\)", "endCaptures": { "0": { "name": "punctuation.section.arithmetic.double.shell" } }, "name": "meta.arithmetic.shell", "patterns": [ { "include": "#math" }, { "include": "#string" } ] } ] }, "arithmetic_no_dollar": { "patterns": [ { "begin": "\\(", "beginCaptures": { "0": { "name": "punctuation.section.arithmetic.single.shell" } }, "end": "\\)", "endCaptures": { "0": { "name": "punctuation.section.arithmetic.single.shell" } }, "name": "meta.arithmetic.shell", "patterns": [ { "include": "#math" }, { "include": "#string" } ] } ] }, "array_access_inline": { "captures": { "1": { "name": "punctuation.section.array.shell" }, "2": { "patterns": [ { "include": "#special_expansion" }, { "include": "#string" }, { "include": "#variable" } ] }, "3": { "name": "punctuation.section.array.shell" } }, "match": "(\\[)([^]\\[]+)(])" }, "array_value": { "begin": "[\\t ]*+((?\\[{|]|$|[\\t ;])(?!nocorrect |nocorrect\\t|nocorrect$|readonly |readonly\\t|readonly$|function |function\\t|function$|foreach |foreach\\t|foreach$|coproc |coproc\\t|coproc$|logout |logout\\t|logout$|export |export\\t|export$|select |select\\t|select$|repeat |repeat\\t|repeat$|pushd |pushd\\t|pushd$|until |until\\t|until$|while |while\\t|while$|local |local\\t|local$|case |case\\t|case$|done |done\\t|done$|elif |elif\\t|elif$|else |else\\t|else$|esac |esac\\t|esac$|popd |popd\\t|popd$|then |then\\t|then$|time |time\\t|time$|for |for\\t|for$|end |end\\t|end$|fi |fi\\t|fi$|do |do\\t|do$|in |in\\t|in$|if |if\\t|if$)(?:((?<=^|[\\t \\&;])(?:readonly|declare|typeset|export|local)(?=[\\t \\&;]|$))|((?![\"']|\\\\\\n?$)[^\\t\\n\\r !\"'<>]+?))(?:(?=[\\t ])|(?=[\\n\\&);`{|}]|[\\t ]*#|])(?`{|]+)" }, { "begin": "(?:\\G|(?\\[{|]|$|[\\t ;])(?!nocorrect |nocorrect\\t|nocorrect$|readonly |readonly\\t|readonly$|function |function\\t|function$|foreach |foreach\\t|foreach$|coproc |coproc\\t|coproc$|logout |logout\\t|logout$|export |export\\t|export$|select |select\\t|select$|repeat |repeat\\t|repeat$|pushd |pushd\\t|pushd$|until |until\\t|until$|while |while\\t|while$|local |local\\t|local$|case |case\\t|case$|done |done\\t|done$|elif |elif\\t|elif$|else |else\\t|else$|esac |esac\\t|esac$|popd |popd\\t|popd$|then |then\\t|then$|time |time\\t|time$|for |for\\t|for$|end |end\\t|end$|fi |fi\\t|fi$|do |do\\t|do$|in |in\\t|in$|if |if\\t|if$)(?!\\\\\\n?$)", "beginCaptures": { }, "end": "(?=[\\n\\&);`{|}]|[\\t ]*#|])(?]|&&|\\|\\|", "name": "keyword.operator.logical.shell" }, { "match": "(?[=>]?|==|!=|^|\\|{1,2}|&{1,2}|[,:=?]|[-%\\&*+/^|]=|<<=|>>=", "name": "keyword.operator.arithmetic.shell" }, { "match": "0[Xx]\\h+", "name": "constant.numeric.hex.shell" }, { "match": ";", "name": "punctuation.separator.semicolon.range" }, { "match": "0\\d+", "name": "constant.numeric.octal.shell" }, { "match": "\\d{1,2}#[0-9@-Z_a-z]+", "name": "constant.numeric.other.shell" }, { "match": "\\d+", "name": "constant.numeric.integer.shell" }, { "match": "(?[=>]?|==|!=|^|\\|{1,2}|&{1,2}|[,:=?]|[-%\\&*+/^|]=|<<=|>>=", "name": "keyword.operator.arithmetic.shell" }, { "match": "0[Xx]\\h+", "name": "constant.numeric.hex.shell" }, { "match": "0\\d+", "name": "constant.numeric.octal.shell" }, { "match": "\\d{1,2}#[0-9@-Z_a-z]+", "name": "constant.numeric.other.shell" }, { "match": "\\d+", "name": "constant.numeric.integer.shell" } ] }, "misc_ranges": { "patterns": [ { "include": "#logical_expression_single" }, { "include": "#logical_expression_double" }, { "include": "#subshell_dollar" }, { "begin": "(?\\[{|]|$|[\\t ;]))", "beginCaptures": { "1": { "name": "string.unquoted.argument.shell constant.other.option.dash.shell" }, "2": { "name": "string.unquoted.argument.shell constant.other.option.shell" } }, "contentName": "string.unquoted.argument constant.other.option", "end": "(?=[\\t ])|(?=[\\n\\&);`{|}]|[\\t ]*#|])(?>?)[\\t ]*+([^\\t\\n \"$\\&-);<>\\\\`|]+)" }, "redirect_number": { "captures": { "1": { "name": "keyword.operator.redirect.stdout.shell" }, "2": { "name": "keyword.operator.redirect.stderr.shell" }, "3": { "name": "keyword.operator.redirect.$3.shell" } }, "match": "(?<=[\\t ])(?:(1)|(2)|(\\d+))(?=>)" }, "redirection": { "patterns": [ { "begin": "[<>]\\(", "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.shell" } }, "end": "\\)", "endCaptures": { "0": { "name": "punctuation.definition.string.end.shell" } }, "name": "string.interpolated.process-substitution.shell", "patterns": [ { "include": "#initial_context" } ] }, { "match": "(?])(&>|\\d*>&\\d*|\\d*(>>|[<>])|\\d*<&|\\d*<>)(?![<>])", "name": "keyword.operator.redirect.shell" } ] }, "regex_comparison": { "match": "=~", "name": "keyword.operator.logical.regex.shell" }, "regexp": { "patterns": [ { "match": ".+" } ] }, "simple_options": { "captures": { "0": { "patterns": [ { "captures": { "1": { "name": "string.unquoted.argument.shell constant.other.option.dash.shell" }, "2": { "name": "string.unquoted.argument.shell constant.other.option.shell" } }, "match": "[\\t ]++(-)(\\w+)" } ] } }, "match": "(?:[\\t ]++-\\w+)*" }, "simple_unquoted": { "match": "[^\\t\\n \"$\\&-);<>\\\\`|]", "name": "string.unquoted.shell" }, "special_expansion": { "match": "!|:[-=?]?|[*@]|##?|%%|[%/]", "name": "keyword.operator.expansion.shell" }, "start_of_command": { "match": "[\\t ]*+(?![\\n!#\\&()<>\\[{|]|$|[\\t ;])(?!nocorrect |nocorrect\\t|nocorrect$|readonly |readonly\\t|readonly$|function |function\\t|function$|foreach |foreach\\t|foreach$|coproc |coproc\\t|coproc$|logout |logout\\t|logout$|export |export\\t|export$|select |select\\t|select$|repeat |repeat\\t|repeat$|pushd |pushd\\t|pushd$|until |until\\t|until$|while |while\\t|while$|local |local\\t|local$|case |case\\t|case$|done |done\\t|done$|elif |elif\\t|elif$|else |else\\t|else$|esac |esac\\t|esac$|popd |popd\\t|popd$|then |then\\t|then$|time |time\\t|time$|for |for\\t|for$|end |end\\t|end$|fi |fi\\t|fi$|do |do\\t|do$|in |in\\t|in$|if |if\\t|if$)(?!\\\\\\n?$)" }, "string": { "patterns": [ { "match": "\\\\.", "name": "constant.character.escape.shell" }, { "begin": "'", "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.shell" } }, "end": "'", "endCaptures": { "0": { "name": "punctuation.definition.string.end.shell" } }, "name": "string.quoted.single.shell" }, { "begin": "\\$?\"", "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.shell" } }, "end": "\"", "endCaptures": { "0": { "name": "punctuation.definition.string.end.shell" } }, "name": "string.quoted.double.shell", "patterns": [ { "match": "\\\\[\\n\"$\\\\`]", "name": "constant.character.escape.shell" }, { "include": "#variable" }, { "include": "#interpolation" } ] }, { "begin": "\\$'", "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.shell" } }, "end": "'", "endCaptures": { "0": { "name": "punctuation.definition.string.end.shell" } }, "name": "string.quoted.single.dollar.shell", "patterns": [ { "match": "\\\\['\\\\abefnrtv]", "name": "constant.character.escape.ansi-c.shell" }, { "match": "\\\\[0-9]{3}\"", "name": "constant.character.escape.octal.shell" }, { "match": "\\\\x\\h{2}\"", "name": "constant.character.escape.hex.shell" }, { "match": "\\\\c.\"", "name": "constant.character.escape.control-char.shell" } ] } ] }, "subshell_dollar": { "patterns": [ { "begin": "\\$\\(", "beginCaptures": { "0": { "name": "punctuation.definition.subshell.single.shell" } }, "end": "\\)", "endCaptures": { "0": { "name": "punctuation.definition.subshell.single.shell" } }, "name": "meta.scope.subshell", "patterns": [ { "include": "#parenthese" }, { "include": "#initial_context" } ] } ] }, "support": { "patterns": [ { "match": "(?<=^|[\\&;\\s])[.:](?=[\\&;\\s]|$)", "name": "support.function.builtin.shell" } ] }, "typical_statements": { "patterns": [ { "include": "#assignment_statement" }, { "include": "#case_statement" }, { "include": "#for_statement" }, { "include": "#while_statement" }, { "include": "#function_definition" }, { "include": "#command_statement" }, { "include": "#line_continuation" }, { "include": "#arithmetic_double" }, { "include": "#normal_context" } ] }, "variable": { "patterns": [ { "captures": { "1": { "name": "punctuation.definition.variable.shell variable.parameter.positional.all.shell" }, "2": { "name": "variable.parameter.positional.all.shell" } }, "match": "(\\$)(@(?!\\w))" }, { "captures": { "1": { "name": "punctuation.definition.variable.shell variable.parameter.positional.shell" }, "2": { "name": "variable.parameter.positional.shell" } }, "match": "(\\$)([0-9](?!\\w))" }, { "captures": { "1": { "name": "punctuation.definition.variable.shell variable.language.special.shell" }, "2": { "name": "variable.language.special.shell" } }, "match": "(\\$)([-!#$*0?_](?!\\w))" }, { "begin": "(\\$)(\\{)[\\t ]*+(?=\\d)", "beginCaptures": { "1": { "name": "punctuation.definition.variable.shell variable.parameter.positional.shell" }, "2": { "name": "punctuation.section.bracket.curly.variable.begin.shell punctuation.definition.variable.shell variable.parameter.positional.shell" } }, "contentName": "meta.parameter-expansion", "end": "}", "endCaptures": { "0": { "name": "punctuation.section.bracket.curly.variable.end.shell punctuation.definition.variable.shell variable.parameter.positional.shell" } }, "patterns": [ { "include": "#special_expansion" }, { "include": "#array_access_inline" }, { "match": "[0-9]+", "name": "variable.parameter.positional.shell" }, { "match": "(?