From 990153d422c0976d681d0bd655a3ff4a977efd42 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Mon, 13 May 2024 18:37:30 +0200 Subject: [PATCH 001/113] [ShellScript] Fix job built-ins This commit... 1. adds missing -f and -p options for wait built-in 2. adds dedicated tests for job built-in commands 3. refactors job variable tests by replacing `fg` command by `:` dummy to align them with majority of other variable tests --- ...commands-builtin-shell-bash.sublime-syntax | 4 +- ShellScript/commands-builtin-shell-bash.yml | 4 +- ShellScript/test/syntax_test_bash.sh | 106 +++++++++++++----- 3 files changed, 85 insertions(+), 29 deletions(-) diff --git a/ShellScript/commands-builtin-shell-bash.sublime-syntax b/ShellScript/commands-builtin-shell-bash.sublime-syntax index 0aed11c9c6..4b1823f0a9 100644 --- a/ShellScript/commands-builtin-shell-bash.sublime-syntax +++ b/ShellScript/commands-builtin-shell-bash.sublime-syntax @@ -338,7 +338,7 @@ contexts: cmd-kill-args: - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-boilerplate-with-end-of-options - - match: ([-+])[snlL] + - match: ([-+])[snlL]+ scope: meta.parameter.option.shell variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell @@ -346,7 +346,7 @@ contexts: cmd-wait-args: - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-boilerplate-with-end-of-options - - match: ([-+])[n] + - match: ([-+])[fnp]+ scope: meta.parameter.option.shell variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell diff --git a/ShellScript/commands-builtin-shell-bash.yml b/ShellScript/commands-builtin-shell-bash.yml index 150a2867cf..3d5dbe0dc4 100644 --- a/ShellScript/commands-builtin-shell-bash.yml +++ b/ShellScript/commands-builtin-shell-bash.yml @@ -134,11 +134,11 @@ jobs: short-options: x kill: - short-options: snlL + short-options-compact: snlL # TODO: -sigspec wait: - short-options: "n" + short-options-compact: "fnp" disown: short-options-compact: ar diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index ecceadfebf..81ab64b1c1 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -6865,35 +6865,91 @@ let "two=5+5"; if [[ "$X" == "1" ]]; then X="one"; fi # https://www.gnu.org/software/bash/manual/bash.html#Job-Control-Basics # ############################################################################### -fg % -# ^ meta.interpolation.job.shell variable.other.readwrite.shell punctuation.definition.variable.shell -fg %% -# ^^ meta.interpolation.job.shell variable.language.job.shell -# ^ punctuation.definition.variable.shell -fg %+ -# ^^ meta.interpolation.job.shell variable.language.job.shell -# ^ punctuation.definition.variable.shell -fg %- -# ^^ meta.interpolation.job.shell variable.language.job.shell -# ^ punctuation.definition.variable.shell -fg %1 %2 %3 -# ^^ meta.interpolation.job.shell variable.language.job.shell -# ^ punctuation.definition.variable.shell -# ^^ meta.interpolation.job.shell variable.language.job.shell -# ^ punctuation.definition.variable.shell -# ^^ meta.interpolation.job.shell variable.language.job.shell -# ^ punctuation.definition.variable.shell -fg %ce -# ^^^ meta.interpolation.job.shell variable.other.readwrite.shell -# ^ punctuation.definition.variable.shell -fg %?ce -# ^^^^ meta.interpolation.job.shell variable.other.readwrite.shell -# ^ punctuation.definition.variable.shell -# ^ keyword.operator.match.shell +: % +# ^ meta.interpolation.job.shell variable.other.readwrite.shell punctuation.definition.variable.shell +: %% +# ^^ meta.interpolation.job.shell variable.language.job.shell +# ^ punctuation.definition.variable.shell +# ^ - meta.interpolation - variable +: %+ +# ^^ meta.interpolation.job.shell variable.language.job.shell +# ^ punctuation.definition.variable.shell +# ^ - meta.interpolation - variable +: %- +# ^^ meta.interpolation.job.shell variable.language.job.shell +# ^ punctuation.definition.variable.shell +# ^ - meta.interpolation - variable +: %1 %2 %3 +# ^^ meta.interpolation.job.shell variable.language.job.shell +# ^ punctuation.definition.variable.shell +# ^ - meta.interpolation - variable +# ^^ meta.interpolation.job.shell variable.language.job.shell +# ^ punctuation.definition.variable.shell +# ^ - meta.interpolation - variable +# ^^ meta.interpolation.job.shell variable.language.job.shell +# ^ punctuation.definition.variable.shell +# ^ - meta.interpolation - variable +: %ce +# ^^^ meta.interpolation.job.shell variable.other.readwrite.shell +# ^ punctuation.definition.variable.shell +# ^ - meta.interpolation - variable +: %?ce +# ^^^^ meta.interpolation.job.shell variable.other.readwrite.shell +# ^ punctuation.definition.variable.shell +# ^ keyword.operator.match.shell +# ^ - meta.interpolation - variable %1 # <- meta.interpolation.job.shell variable.language.job.shell punctuation.definition.variable.shell #^ meta.interpolation.job.shell variable.language.job.shell +# ^ - meta.interpolation - variable + + +############################################################################### +# 7.2 Job Control Builtins # +# https://www.gnu.org/software/bash/manual/bash.html#Job-Control-Builtins # +############################################################################### + +fg fg +# <- meta.function-call.identifier.shell support.function.fg.shell +#^ meta.function-call.identifier.shell support.function.fg.shell +# ^^^ meta.function-call.arguments.shell - support + +bg bg +# <- meta.function-call.identifier.shell support.function.bg.shell +#^ meta.function-call.identifier.shell support.function.bg.shell +# ^^^ meta.function-call.arguments.shell - support + +jobs jobs +# <- meta.function-call.identifier.shell support.function.jobs.shell +#^^^ meta.function-call.identifier.shell support.function.jobs.shell +# ^^^^^ meta.function-call.arguments.shell - support + +kill -s +# <- meta.function-call.identifier.shell support.function.kill.shell +#^^^ meta.function-call.identifier.shell support.function.kill.shell +# ^^^ meta.function-call.arguments.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell + +wait -fn -p varname +# <- meta.function-call.identifier.shell support.function.wait.shell +#^^^ meta.function-call.identifier.shell support.function.wait.shell +# ^^^^^^^^^^^^^^^ meta.function-call.arguments.shell +# ^^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^^^^^^ meta.string.shell string.unquoted.shell + +disown -ar +# <- meta.function-call.identifier.shell support.function.disown.shell +#^^^^^ meta.function-call.identifier.shell support.function.disown.shell +# ^^^^ meta.function-call.arguments.shell +# ^^^ meta.parameter.option.shell variable.parameter.option.shell + +suspend -f +# <- meta.function-call.identifier.shell support.function.suspend.shell +#^^^^^^ meta.function-call.identifier.shell support.function.suspend.shell +# ^^^ meta.function-call.arguments.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell ############################################################################### From dc641e5a069a188064043ce669bbdfaae45a2824 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Mon, 13 May 2024 20:10:19 +0200 Subject: [PATCH 002/113] [ShellScript] Fix brace expansions This commit fixes support for brace expansions according to bash syntax specs. Former `number-range` was just a special case for what brace expansions can do. --- ShellScript/Bash.sublime-syntax | 252 ++++++++++++---- ShellScript/test/syntax_test_bash.sh | 419 +++++++++++++++++++++++++-- 2 files changed, 602 insertions(+), 69 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 29b75e45d5..5a378819ec 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -73,7 +73,7 @@ variables: # Command options are identifiers, which may start with interpolation. opt_punctuation: '{{wspace}}(--|[-+]){{nonposix_begin}}' - opt_literal_char: '[^{{metachar}}=%$\\""''`]' + opt_literal_char: '[^{{metachar}}=%$\\""''`{}]' opt_break: '{{nonposix_break}}' # Variables are posix identifiers, which may start with interpolation. @@ -1153,7 +1153,8 @@ contexts: - include: cmd-args-boilerplate for-args: - - include: loop-end + - meta_include_prototype: false + - include: line-continuations - match: \(\( scope: punctuation.section.arithmetic.begin.shell set: cmd-arithmetic-body @@ -1163,26 +1164,16 @@ contexts: loop-iterator-var: - match: in{{cmd_break}} scope: keyword.control.in.shell - set: loop-iterator-range - - include: loop-end - - include: variables - - loop-iterator-range: - - include: loop-end - - include: number-range - - match: (?=\S) set: loop-iterator-wordlist + - include: redirections + - include: eoc-pop + - include: variables loop-iterator-wordlist: - - include: loop-end - - include: booleans - - include: strings-unquoted - - loop-end: - - match: (?=(?:do|done){{cmd_break}}) - pop: 1 + - meta_include_prototype: false - include: redirections - include: eoc-pop + - include: strings-unquoted ###[ REDIRECTIONS AND HEREDOCS ]############################################### @@ -1379,6 +1370,7 @@ contexts: # sequence \newline is ignored, and ‘\’ must be used to quote the # characters ‘\’, ‘$’, and ‘`’. - include: string-escapes + - include: brace-interpolations - include: string-interpolations heredocs-body-no-expansion: @@ -1559,22 +1551,6 @@ contexts: 2: meta.number.integer.decimal.shell constant.numeric.value.shell pop: 1 - number-range: - - match: ({)(([-+]?)\d+)(..)(([-+]?)\d+)(?:(..)(([-+]?)\d+))?(}) - scope: meta.sequence.range.shell - captures: - 1: punctuation.section.sequence.begin.shell - 2: meta.number.integer.decimal.shell constant.numeric.value.shell - 3: keyword.operator.arithmetic.shell - 4: keyword.operator.range.shell - 5: meta.number.integer.decimal.shell constant.numeric.value.shell - 6: keyword.operator.arithmetic.shell - 7: keyword.operator.range.shell - 8: meta.number.integer.decimal.shell constant.numeric.value.shell - 9: keyword.operator.arithmetic.shell - 10: punctuation.section.sequence.end.shell - pop: 1 - ###[ OPERATORS ]############################################################### line-continuations: @@ -1711,16 +1687,183 @@ contexts: - include: expressions expansions-brace: + # use branching as valid brace expansions must not exceed word boundaries + - match: (?={) + branch_point: brace-expansion + branch: + - expansion-brace-sequence + - expansion-brace-series + - expansion-brace-fallback + + expansion-brace-sequence: + # sequence expression + - meta_include_prototype: false - match: \{ - scope: punctuation.section.interpolation.begin.shell + scope: + meta.interpolation.brace.shell + punctuation.section.interpolation.begin.shell push: - - meta_scope: meta.interpolation.brace.shell - - match: \} - scope: punctuation.section.interpolation.end.shell - pop: 1 - - match: \, - scope: punctuation.separator.sequence.shell - - include: expansions-and-strings + - expansion-brace-sequence-body + - expansion-brace-sequence-begin + + expansion-brace-sequence-begin: + - match: \.\. + scope: keyword.operator.range.shell + pop: 1 + - include: line-continuations + - include: expansion-brace-sequence-content + - match: '' + fail: brace-expansion + + expansion-brace-sequence-body: + - meta_content_scope: meta.interpolation.brace.shell + - match: \.\. + scope: keyword.operator.range.shell + - include: expansion-brace-end + - include: expansion-brace-sequence-content + - match: '' + fail: brace-expansion + + expansion-brace-sequence-content: + - include: expansions-arithmetic + - include: expansions-command + - include: expansions-parameter + - match: ([-+]?)(\d+) + scope: meta.number.integer.decimal.shell + captures: + 1: keyword.operator.arithmetic.shell + 2: constant.numeric.value.shell + - match: '[[:alpha:]]' + scope: constant.character.shell + + expansion-brace-series: + # series of comma-separated strings + - meta_include_prototype: false + - match: \{ + scope: + meta.interpolation.brace.shell + punctuation.section.interpolation.begin.shell + push: expansion-brace-series-begin + + expansion-brace-series-begin: + - meta_include_prototype: false + - meta_content_scope: + meta.interpolation.brace.shell + meta.string.shell string.unquoted.shell + - match: (?=\}) + fail: brace-expansion + - include: line-continuations + - include: expansion-brace-series-content + + expansion-brace-series-body: + - meta_include_prototype: false + - meta_content_scope: + meta.interpolation.brace.shell + meta.string.shell string.unquoted.shell + - include: expansion-brace-end + - include: expansion-brace-series-content + + expansion-brace-series-content: + - match: \, + scope: + meta.interpolation.brace.shell + punctuation.separator.sequence.shell + set: expansion-brace-series-body + - include: string-unquoted-content + - include: expansions-patterns + - match: (?={{metachar}}) + fail: brace-expansion + + expansion-brace-end: + - match: \} + scope: + meta.interpolation.brace.shell + punctuation.section.interpolation.end.shell + pop: 2 + - include: line-continuations + + expansion-brace-fallback: + - meta_include_prototype: false + - match: \{ + pop: 1 + + brace-interpolations: + # use branching as valid brace expansions must not exceed word boundaries + - match: (?={) + branch_point: brace-interpolation + branch: + - brace-interpolation-sequence + - brace-interpolation-series + - expansion-brace-fallback + + brace-interpolation-sequence: + # sequence expression + - clear_scopes: 1 + - meta_include_prototype: false + - match: \{ + scope: + meta.interpolation.brace.shell + punctuation.section.interpolation.begin.shell + push: + - brace-interpolation-sequence-body + - brace-interpolation-sequence-begin + + brace-interpolation-sequence-begin: + - match: \.\. + scope: keyword.operator.range.shell + pop: 1 + - include: line-continuations + - include: expansion-brace-sequence-content + - match: '' + fail: brace-interpolation + + brace-interpolation-sequence-body: + - meta_content_scope: meta.interpolation.brace.shell + - match: \.\. + scope: keyword.operator.range.shell + - include: expansion-brace-end + - include: expansion-brace-sequence-content + - match: '' + fail: brace-interpolation + + brace-interpolation-series: + # series of comma-separated strings + - clear_scopes: 1 + - meta_include_prototype: false + - match: \{ + scope: + meta.interpolation.brace.shell + punctuation.section.interpolation.begin.shell + push: brace-interpolation-series-begin + + brace-interpolation-series-begin: + - meta_include_prototype: false + - meta_content_scope: + meta.interpolation.brace.shell + meta.string.shell string.unquoted.shell + - match: (?=\}) + fail: brace-interpolation + - include: line-continuations + - include: brace-interpolation-series-content + + brace-interpolation-series-body: + - meta_include_prototype: false + - meta_content_scope: + meta.interpolation.brace.shell + meta.string.shell string.unquoted.shell + - include: expansion-brace-end + - include: brace-interpolation-series-content + + brace-interpolation-series-content: + - match: \, + scope: + meta.interpolation.brace.shell + punctuation.separator.sequence.shell + set: brace-interpolation-series-body + - include: string-unquoted-content + - include: expansions-patterns + - match: (?={{metachar}}) + fail: brace-interpolation expansions-command: - match: (\$)(\() @@ -2302,9 +2445,16 @@ contexts: string-unquoted-body: - meta_include_prototype: false - meta_scope: meta.string.shell string.unquoted.shell + - include: string-unquoted-content + - include: string-path-separators + - match: (?!{{cmd_literal_char}}) + pop: 1 + + string-unquoted-content: - include: string-prototype - include: line-continuations - include: any-escapes + - include: brace-interpolations - include: string-interpolations - match: \' scope: punctuation.definition.string.begin.shell @@ -2334,9 +2484,6 @@ contexts: - meta_include_prototype: false - meta_scope: string.quoted.double.locale.shell - include: string-quoted-double-body - - include: string-path-separators - - match: (?!{{cmd_literal_char}}) - pop: 1 strings: - include: any-escapes @@ -2373,8 +2520,8 @@ contexts: - match: \" scope: punctuation.definition.string.end.shell pop: 1 - - include: string-prototype - include: line-continuations + - include: string-prototype - include: string-escapes - include: string-interpolations - include: string-path-separators @@ -2383,8 +2530,8 @@ contexts: - match: \' scope: punctuation.definition.string.end.shell pop: 1 - - include: string-prototype - include: line-continuations + - include: string-prototype - include: string-escapes-ansi-c string-quoted-single-body: @@ -2414,10 +2561,15 @@ contexts: string-interpolations: - match: '{{is_interpolation}}' - push: - - clear_scopes: 1 - - include: expansions-variables - - include: immediately-pop + push: string-interpolation-body + + string-interpolation-body: + - clear_scopes: 1 + - meta_include_prototype: false + - include: expansions-arithmetic + - include: expansions-command + - include: expansions-parameter + - include: immediately-pop # for use by inheriting syntaxes to easily inject string interpolation # in any kind of quoted or unquoted string diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index 81ab64b1c1..ffb6d04613 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -431,13 +431,13 @@ set +Eou pipefail # ^ variable.parameter.option.shell punctuation.definition.parameter.shell # ^^ variable.parameter.option.shell - punctuation # ^ - variable.parameter.option - punctuation -set -e -- -o {string} +set -e -- -o {str,ing} # ^^ variable.parameter.option.shell # ^ - variable - keyword # ^^ keyword.operator.end-of-options.shell # ^ - variable - keyword # ^^ - variable.parameter.option -# ^^^^^^^^ meta.interpolation.brace.shell +# ^^^^^^^^^ meta.interpolation.brace.shell read -d '' -sn 1 -t1 -- -t1 10 #^^^ meta.function-call.identifier.shell @@ -819,13 +819,13 @@ do$var for done # <- keyword.control.loop.for.shell #^^ keyword.control.loop.for.shell -# ^^^^ keyword.control.loop.end.shell +# ^^^^ variable.other.readwrite.shell - keyword for do done # <- keyword.control.loop.for.shell #^^ keyword.control.loop.for.shell -# ^^ keyword.control.loop.do.shell -# ^^^^ keyword.control.loop.end.shell +# ^^ variable.other.readwrite.shell - keyword +# ^^^^ variable.other.readwrite.shell - keyword for x; do #<- keyword.control.loop.for.shell @@ -881,6 +881,17 @@ do done # <- keyword.control.loop.end.shell +for \ + (( i = 0; i < 10; i++ )) do echo $i; done; +# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.arithmetic.shell +# ^^ keyword.control.loop.do.shell +# ^^^^^^^ meta.function-call +# ^^^^ support.function.echo.shell +# ^^ variable.other.readwrite.shell +# ^ punctuation.terminator.statement.shell +# ^^^^ keyword.control.loop.end.shell +# ^ punctuation.terminator.statement.shell + for i in str1 $str2 "str3" 'str4' st$r5; do echo $i; done; # <- keyword.control.loop.for.shell # ^ variable.other.readwrite.shell @@ -899,6 +910,46 @@ for i in str1 $str2 "str3" 'str4' st$r5; do echo $i; done; # ^^^^ keyword.control.loop.end.shell # ^ punctuation.terminator.statement.shell +for i in for in do echo done; do echo $i; done; +# <- keyword.control.loop.for.shell +# ^^ keyword.control.in.shell +# ^ - meta.string +# ^^^ meta.string.shell string.unquoted.shell +# ^ - meta.string +# ^^ meta.string.shell string.unquoted.shell +# ^ - meta.string +# ^^ meta.string.shell string.unquoted.shell +# ^ - meta.string +# ^^^^ meta.string.shell string.unquoted.shell +# ^ - meta.string +# ^^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.terminator.statement.shell +# ^^ keyword.control.loop.do.shell +# ^^^^ support.function.echo.shell +# ^^ variable.other.readwrite.shell +# ^ punctuation.terminator.statement.shell +# ^^^^ keyword.control.loop.end.shell +# ^ punctuation.terminator.statement.shell + +for i in { [ \( ; do echo $i; done; +# <- keyword.control.loop.for.shell +# ^ variable.other.readwrite.shell +# ^^ keyword.control.in.shell +# ^ - meta.string +# ^ meta.string.shell string.unquoted.shell +# ^ - meta.string +# ^ meta.string.shell string.unquoted.shell +# ^ - meta.string +# ^^ meta.string.shell string.unquoted.shell constant.character.escape.shell +# ^ - meta.string +# ^ punctuation.terminator.statement.shell +# ^^ keyword.control.loop.do.shell +# ^^^^ support.function.echo.shell +# ^^ variable.other.readwrite.shell +# ^ punctuation.terminator.statement.shell +# ^^^^ keyword.control.loop.end.shell +# ^ punctuation.terminator.statement.shell + for i in } {(..)} {a..)} +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.interpolation + +: {a..z\ + ..2} +#^^^^^ - meta.interpolation + +: {foo\ + bar,baz} +#^^^^^^^^^^ - meta.interpolation + +: '{foo,bar,baz}' '{1..10}' +# ^^^^^^^^^^^^^^^ meta.string.shell string.quoted.single.shell - meta.interpolation +# ^^^^^^^^^ meta.string.shell string.quoted.single.shell - meta.interpolation + +: "{foo,bar,baz}" "{1..10}" +# ^^^^^^^^^^^^^^^ meta.string.shell string.quoted.double.shell - meta.interpolation +# ^^^^^^^^^ meta.string.shell string.quoted.double.shell - meta.interpolation + + ############################################################################### # 3.5.3 Shell Parameter Expansion # # https://www.gnu.org/software/bash/manual/bash.html#Shell-Parameter-Expansion# From e4400fe5f365bb64991d5f117934b45e0a0b4add Mon Sep 17 00:00:00 2001 From: deathaxe Date: Thu, 6 Jun 2024 20:04:48 +0200 Subject: [PATCH 003/113] [ShellScript] Fix tilde expansions --- ShellScript/Bash.sublime-syntax | 69 ++++++++++++-- ShellScript/test/syntax_test_bash.sh | 131 +++++++++++++++++++++++++++ 2 files changed, 191 insertions(+), 9 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 5a378819ec..830313c925 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -928,7 +928,7 @@ contexts: cmd-basic: # basic user defined or external commands - match: '{{cmd_begin}}' - push: [cmd-args, cmd-basic-name] + push: [cmd-args, cmd-basic-name, maybe-tilde-expansion] cmd-basic-name: - clear_scopes: 1 @@ -1665,6 +1665,7 @@ contexts: expansions: - include: expansions-patterns - include: expansions-brace + - include: expansions-tilde - include: expansions-variables - include: expansions-job @@ -1672,7 +1673,6 @@ contexts: - include: expansions-parameter - include: expansions-arithmetic - include: expansions-command - - include: expansions-tilde expansions-arithmetic: - match: (\$)(\(\() @@ -2106,9 +2106,56 @@ contexts: - include: pattern-charsets - include: pattern-wildcards + maybe-tilde-interpolation: + - meta_include_prototype: false + # https://www.gnu.org/software/bash/manual/bash.html#Tilde-Expansion + - include: tilde-interpolation + - include: line-continuations + - include: immediately-pop + + tilde-interpolation: + - match: \~ + scope: variable.language.tilde.shell + set: tilde-interpolation-modifier + + tilde-interpolation-modifier: + - clear_scopes: 1 + - meta_include_prototype: false + - meta_scope: meta.interpolation.tilde.shell + - include: tilde-expansion-modifier + + maybe-tilde-expansion: + - include: tilde-expansion + - include: line-continuations + - include: immediately-pop + + tilde-expansion: + - match: \~ + scope: variable.language.tilde.shell + set: tilde-expansion-modifier + expansions-tilde: - - match: '~' - scope: meta.interpolation.tilde.shell variable.language.tilde.shell + # https://www.gnu.org/software/bash/manual/bash.html#Tilde-Expansion + - match: \~ + scope: variable.language.tilde.shell + push: tilde-expansion-modifier + + tilde-expansion-modifier: + - meta_include_prototype: false + - meta_scope: meta.interpolation.tilde.shell + - match: (?:[-+]?\d+|[-+](?![^/{{metachar}}])) + scope: variable.language.tilde.shell + pop: 1 + - match: '' + push: tilde-expansion-username + + tilde-expansion-username: + - meta_include_prototype: false + - meta_content_scope: meta.string.shell string.unquoted.username.shell + - include: line-continuations + - include: string-interpolations + - match: (?=[/{{metachar}}]) + pop: 2 ###[ SHELL PATTERN MATCHING ]################################################## @@ -2435,19 +2482,23 @@ contexts: ###[ STRINGS ]################################################################# strings-unquoted: - - match: (?=[^{{metachar}}]) - push: string-unquoted-body + - match: '{{nonposix_begin}}' + push: + - string-unquoted-body + - maybe-tilde-interpolation string-unquoted: - - match: (?=[^{{metachar}}]) - set: string-unquoted-body + - match: '{{nonposix_begin}}' + set: + - string-unquoted-body + - maybe-tilde-interpolation string-unquoted-body: - meta_include_prototype: false - meta_scope: meta.string.shell string.unquoted.shell - include: string-unquoted-content - include: string-path-separators - - match: (?!{{cmd_literal_char}}) + - match: '{{cmd_break}}' pop: 1 string-unquoted-content: diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index ffb6d04613..78a7da6462 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -3525,6 +3525,137 @@ any --arg{1,2,3}={1,2,3} # ^^^^^^^^^ meta.string.shell string.quoted.double.shell - meta.interpolation +############################################################################### +# 3.5.2 Tilde Expansion # +# https://www.gnu.org/software/bash/manual/bash.html#Tilde-Expansion # +############################################################################### + +: ~ # expand to $HOME +# ^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ - meta.interpolation + +: ~/ # expand to $HOME +# ^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ - meta.interpolation + +: ~+ # expand to current working dir +# ^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ - meta.interpolation + +: ~+/ # expand to current working dir +# ^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ - meta.interpolation + +: ~- # expand to previous working dir +# ^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ - meta.interpolation + +: ~-/ # expand to previous working dir +# ^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ - meta.interpolation + +: ~0 # expand to current working dir +# ^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ - meta.interpolation + +: ~0/ # expand to current working dir +# ^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ - meta.interpolation + +: ~1 # expand to previous working dir +# ^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ - meta.interpolation + +: ~1/ # expand to previous working dir +# ^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ - meta.interpolation + +: ~+0 # equivalent to ~+ +# ^^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ - meta.interpolation + +: ~+0/ # equivalent to ~+ +# ^^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ - meta.interpolation + +: ~+1 # top of directory stack +# ^^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ - meta.interpolation + +: ~+1/ # top of directory stack +# ^^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ - meta.interpolation + +: ~fred/foo* # The subdirectory foo of the home directory of the user fred +# ^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^^^^ meta.interpolation.tilde.shell meta.string.shell string.unquoted.username.shell - variable +# ^^^^^ - meta.interpolation +# ^ constant.other.wildcard.asterisk.shell + +: ~fr\ +ed/foo* # The subdirectory foo of the home directory of the user fred +# <- meta.interpolation.tilde.shell meta.string.shell string.unquoted.username.shell - variable +#^ meta.interpolation.tilde.shell meta.string.shell string.unquoted.username.shell - variable +# ^^^^^ - meta.interpolation +# ^ constant.other.wildcard.asterisk.shell + +: ~${fred}/foo?bar +# ^ meta.interpolation.tilde.shell variable.language.tilde.shell - variable meta.interpolation +# ^^^^^^^ meta.interpolation.tilde.shell meta.string.shell meta.interpolation.parameter.shell +# ^^^^^^^^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell +# ^ constant.other.wildcard.questionmark.shell + +: ~f${re}d/foo?bar +# ^ meta.interpolation.tilde.shell variable.language.tilde.shell - meta.interpolation meta.interpolation - string +# ^ meta.interpolation.tilde.shell meta.string.shell string.unquoted.username.shell - meta.interpolation meta.interpolation +# ^^^^^ meta.interpolation.tilde.shell meta.string.shell meta.interpolation.parameter.shell - string +# ^ meta.interpolation.tilde.shell meta.string.shell string.unquoted.username.shell - meta.interpolation meta.interpolation +# ^^^^^^^^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +foo=~/~ +# ^ variable.language.tilde.shell +# ^ - variable + +foo=~/~${bar} +# ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell +# ^^ meta.string.shell string.unquoted.shell - meta.interpolation +# ^^^^^^ meta.string.shell meta.interpolation.parameter.shell +# ^ - meta.string - meta.interpolation +# ^ variable.language.tilde.shell +# ^^ string.unquoted.shell +# ^ - variable +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +foo=(~/~foo ~/~bar) +# ^^^^^^^^^^^^^^^ meta.sequence.shell +# ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell +# ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation - variable +# ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell +# ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation - variable + +cmd --foo=~/~bar +# ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell +# ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation - variable + +test $me -eq ~/~foo +# ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell +# ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation - variable + +~/.config/app +# <- meta.function-call.identifier.shell meta.interpolation.tilde.shell variable.language.tilde.shell +#^^^^^^^^^^^^ meta.function-call.identifier.shell variable.function.shell + ############################################################################### # 3.5.3 Shell Parameter Expansion # # https://www.gnu.org/software/bash/manual/bash.html#Shell-Parameter-Expansion# From 2425757e720cc4ee767c9aa97416fedc43b6365e Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 11 May 2024 10:04:29 +0200 Subject: [PATCH 004/113] [ShellScript] Refactor parameter expansions This commit ... 1. applies structural changes, required for ZSH. 2. fixes various parameter expansion bugs related with special parameters e.g. `${$}`, `${?}`, ... 3. fixes advanced tilde expansions such as `~name/` or `~+/` In general it means to introduce contexts and rules to scope expansions more precisely and detailed. --- ShellScript/Bash.sublime-syntax | 322 ++- ShellScript/test/syntax_test_bash.sh | 3832 +++++++++++++++++++++----- 2 files changed, 3373 insertions(+), 781 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 830313c925..ea415a7a41 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -47,7 +47,7 @@ first_line_match: |- ############################################################################### variables: - is_interpolation: (?=\$([\d({]|[$#@!~*?_-](?!\w)|{{identifier}})|`) + is_interpolation: (?=\$[({{{identifier_char}}{{builtin_variable}}]|`) is_variable: (?={{variable_first_char}}{{nbc}}(?:[({]{{nbc}}[)}])?{{nbc}}=) # posix identifiers (alpha-numeric) @@ -80,6 +80,10 @@ variables: variable_begin: (?={{variable_first_char}}|\$) variable_first_char: '{{identifier_first_char}}' + # Shell Parameter Expansions + builtin_variable: '[$#@!*?_-]' + parameter_switch: '[AEKLPQUaku]' + # posix regexp quantifiers character_quantifier: '[?*+]' lazy_or_possessive: '[?+]?' @@ -1428,15 +1432,16 @@ contexts: array-item-access-begin: - match: '[*@]' - scope: variable.language.array.shell + scope: variable.language.shell pop: 1 - match: '' set: array-key-body array-key-body: - - meta_scope: meta.string.shell string.unquoted.shell - - match: (?=\]) - pop: 1 + - meta_content_scope: meta.string.shell string.unquoted.shell + - match: \] + scope: punctuation.section.item-access.end.shell + pop: 2 - include: string-unquoted-body expressions: @@ -1663,16 +1668,23 @@ contexts: - include: expansions expansions: - - include: expansions-patterns - include: expansions-brace + - include: expansions-job + - include: expansions-patterns - include: expansions-tilde - include: expansions-variables - - include: expansions-job + + expansions-patterns: + - include: pattern-groups + - include: pattern-charsets + - include: pattern-wildcards expansions-variables: - - include: expansions-parameter - include: expansions-arithmetic - include: expansions-command + - include: expansions-parameter + +###[ ARITHMETIC EXPANSIONS ]################################################### expansions-arithmetic: - match: (\$)(\(\() @@ -1686,6 +1698,8 @@ contexts: pop: 1 - include: expressions +###[ BRACE EXPANSIONS ]######################################################## + expansions-brace: # use branching as valid brace expansions must not exceed word boundaries - match: (?={) @@ -1725,9 +1739,7 @@ contexts: fail: brace-expansion expansion-brace-sequence-content: - - include: expansions-arithmetic - - include: expansions-command - - include: expansions-parameter + - include: expansions-variables - match: ([-+]?)(\d+) scope: meta.number.integer.decimal.shell captures: @@ -1865,18 +1877,14 @@ contexts: - match: (?={{metachar}}) fail: brace-interpolation +###[ COMMAND EXPANSIONS ]###################################################### + expansions-command: - match: (\$)(\() captures: 1: punctuation.definition.variable.shell 2: punctuation.section.interpolation.begin.shell - push: - - meta_scope: meta.interpolation.command.shell - - match: \s*(\)) - captures: - 1: punctuation.section.interpolation.end.shell - pop: 1 - - include: statements + push: expansion-command-body - match: \` scope: meta.interpolation.command.shell @@ -1888,6 +1896,16 @@ contexts: 0: meta.interpolation.command.shell punctuation.section.interpolation.end.shell + expansion-command-body: + - meta_scope: meta.interpolation.command.shell + - match: \s*(\)) + captures: + 1: punctuation.section.interpolation.end.shell + pop: 1 + - include: statements + +###[ JOB EXPANSIONS ]########################################################## + expansions-job: # There are a number of ways to refer to a job in the shell. # The symbols ‘%%’ and ‘%+’ refer to the shell’s notion of the current job, @@ -1915,196 +1933,234 @@ contexts: 1: punctuation.definition.variable.shell 2: keyword.operator.match.shell +###[ PARAMETER EXPANSIONS ]#################################################### + expansions-parameter: - - match: (\$)(\{)(#)(\}) - captures: - 0: meta.interpolation.parameter.shell - 1: punctuation.definition.variable.shell - 2: punctuation.section.interpolation.begin.shell - 3: variable.language.shell - 4: punctuation.section.interpolation.end.shell - match: (\$)(\{) captures: 1: punctuation.definition.variable.shell 2: punctuation.section.interpolation.begin.shell push: - - expansions-parameter-meta - - expansions-parameter-chars - - expansions-parameter-first-char - - match: (\$)[$#@!~*?_-](?!\w) - scope: - meta.interpolation.parameter.shell - variable.language.shell + - expansion-parameter-meta + - expansion-parameter-modifier + - expansion-parameter-name + - expansion-parameter-operator + # https://www.gnu.org/software/bash/manual/bash.html#Positional-Parameters + - match: (\$)\d + scope: meta.interpolation.parameter.shell variable.language.positional.shell captures: 1: punctuation.definition.variable.shell - - match: (\$)(?:\d|{{identifier}}) - scope: - meta.interpolation.parameter.shell - variable.other.readwrite.shell + # https://www.gnu.org/software/bash/manual/bash.html#Special-Parameters + - match: (\$){{builtin_variable}}(?!\w) + scope: meta.interpolation.parameter.shell variable.language.shell + captures: + 1: punctuation.definition.variable.shell + - match: (\$){{identifier}} + scope: meta.interpolation.parameter.shell variable.other.readwrite.shell captures: 1: punctuation.definition.variable.shell - expansions-parameter-meta: + expansion-parameter-meta: - meta_include_prototype: false - meta_scope: meta.interpolation.parameter.shell - include: immediately-pop - expansions-parameter-first-char: - - match: \! - scope: keyword.operator.logical.shell + expansion-parameter-operator: + # Both ! and # are operators and special parameters at the same time. + # First char is operator only if not followed by } or operator + # Note: Matches may be wrong if line continuation follows, but it seems + # unlikely enough to accept it, instead of overcomplicating with branching. + - meta_include_prototype: false + # Expansion result is used as new parameter name to expand + # Adds a level of indirection to name resolution + - match: \!(?![/%,:=^}]|[-+?@][^}]) + scope: keyword.operator.expansion.indirection.shell pop: 1 - - match: \# - scope: keyword.operator.arithmetic.shell + # Length of var in words (array) or bytes + - match: \#(?![/%,:=^}]|[-+?@#][^}]) + scope: keyword.operator.expansion.length.shell pop: 1 - include: line-continuations - include: immediately-pop - expansions-parameter-chars: - - include: expressions-parameter-variable - - include: arrays-item-access - - match: ([@*])?(/) - captures: - 1: variable.language.shell - 2: keyword.operator.substitution.shell - set: - - expansions-parameter-substitution - - expansions-parameter-switch - - match: \:?[-+=?] - scope: keyword.operator.assignment.shell - set: expressions-parameter-variable - - match: (@)?(:) - captures: - 1: variable.language.shell - 2: keyword.operator.substring.begin.shell - set: - - match: ":" - scope: keyword.operator.substring.end.shell - set: expansions-parameter-expression - - include: expansions-parameter-expression - - match: \#(?=}) - - match: ([@*])?(\#\#?|%%?|\^\^?|,,?) - captures: - 1: variable.language.shell - 2: keyword.operator.expansion.shell - set: expansions-parameter-pattern - - match: ([@*])?(@)([QEPAa])(?=}) - captures: - 1: variable.language.shell - 2: keyword.operator.expansion.shell - 3: variable.parameter.switch.shell - - match: '[@*](?=})' + expansion-parameter-name: + - meta_include_prototype: false + - match: \d+ + scope: variable.language.positional.shell + pop: 1 + - match: '{{builtin_variable}}(?=[-+*/%?,:=#^@}\[])' scope: variable.language.shell + pop: 1 + - match: '' + set: expansion-parameter-name-chars - expansions-parameter-common: - - match: \} - scope: punctuation.section.interpolation.end.shell + expansion-parameter-name-chars: + # note: no quoted name parts allowed within parameter expansions + - match: '[@*](?!\w)' + scope: variable.language.shell pop: 1 - match: '{{identifier_char}}+' scope: variable.other.readwrite.shell + - include: any-escapes + - include: pattern-literals + - include: expansions-variables - include: line-continuations - - include: strings + - include: immediately-pop - expansions-parameter-expression: + expansion-parameter-modifier: + # ${parameter@operator} + - match: (?:(@)({{parameter_switch}}))?(}) + captures: + 1: keyword.operator.expansion.shell + 2: variable.parameter.switch.shell + 3: punctuation.section.interpolation.end.shell + pop: 1 + # ${parameter:=word} + - match: :?[-+=?] + scope: keyword.operator.assignment.shell + set: + - expansion-parameter-value + - maybe-tilde-interpolation + # ${parameter:offset:length} + - match: ':' + scope: keyword.operator.substring.begin.shell + set: expansion-parameter-substr-start + # ${parameter/pattern/word} + - match: /[/#%]? + scope: keyword.operator.substitution.shell + set: + - expansion-parameter-substitution-pattern + - maybe-tilde-expansion + # ${parameter#pattern} + # ${parameter##pattern} + # ${parameter%pattern} + # ${parameter%%pattern} + # ${parameter^pattern} + # ${parameter^^pattern} + # ${parameter,pattern} + # ${parameter,,pattern} + - match: (?:##?|%%?|\^\^?|,,?) + scope: keyword.operator.expansion.shell + set: + - expansion-parameter-pattern + - maybe-tilde-expansion + - include: arrays-item-access + + expansion-parameter-substr-start: + - match: ':' + scope: keyword.operator.substring.end.shell + set: expansion-parameter-expression + - include: expansion-parameter-expression + + expansion-parameter-expression: + - include: expansion-parameter-end - include: expressions - - include: expansions-parameter-common - expansions-parameter-pattern: + expansion-parameter-pattern: # [3.5.8.1] Pattern Matching in parameter expansions - meta_content_scope: meta.string.regexp.shell - - include: expansions-parameter-common + - include: expansion-parameter-end + - include: line-continuations + - include: any-escapes + - include: pattern-literals - include: expansions-variables - - include: expansions-parameter-pattern-charsets - - include: expansions-parameter-pattern-groups + - include: expansion-parameter-pattern-charsets + - include: expansion-parameter-pattern-groups - include: pattern-wildcards - expansions-parameter-pattern-charsets: + expansion-parameter-pattern-charsets: - match: (?=\[) - branch_point: expansions-parameter-pattern-charset + branch_point: expansion-parameter-pattern-charset branch: - - expansions-parameter-pattern-charset + - expansion-parameter-pattern-charset - pattern-charset-fallback - expansions-parameter-pattern-charset: + expansion-parameter-pattern-charset: - match: (\[)([!^]?) captures: 1: punctuation.definition.set.begin.regexp.shell 2: keyword.operator.logical.regexp.shell set: - - expansions-parameter-pattern-charset-body + - expansion-parameter-pattern-charset-body - pattern-charset-begin - expansions-parameter-pattern-charset-body: + expansion-parameter-pattern-charset-body: - meta_scope: meta.set.regexp.shell - match: $|(?=\}) # bailout at end parameter - fail: expansions-parameter-pattern-charset + fail: expansion-parameter-pattern-charset - include: pattern-charset-end - include: pattern-charset-content - expansions-parameter-pattern-groups: + expansion-parameter-pattern-groups: - match: ([?*+@!])(\() captures: 1: keyword.operator.quantifier.regexp.shell 2: meta.group.regexp.shell punctuation.definition.group.begin.regexp.shell - push: expansions-parameter-pattern-group-body + push: expansion-parameter-pattern-group-body - expansions-parameter-pattern-group-body: + expansion-parameter-pattern-group-body: - meta_content_scope: meta.group.regexp.shell - include: pattern-group-end - include: line-continuations - - include: strings + - include: any-escapes - include: expansions-variables - - include: expansions-parameter-pattern-groups - - include: expansions-parameter-pattern-group-charsets - - include: pattern-wildcards + - include: expansion-parameter-pattern-groups + - include: expansion-parameter-pattern-group-charsets + - include: pattern-literals - include: pattern-operators + - include: pattern-wildcards - include: brace-pop - expansions-parameter-pattern-group-charsets: + expansion-parameter-pattern-group-charsets: - match: (?=\[) - branch_point: expansions-parameter-pattern-group-charset + branch_point: expansion-parameter-pattern-group-charset branch: - - expansions-parameter-pattern-group-charset + - expansion-parameter-pattern-group-charset - pattern-charset-fallback - expansions-parameter-pattern-group-charset: + expansion-parameter-pattern-group-charset: - match: (\[)([!^]?) captures: 1: punctuation.definition.set.begin.regexp.shell 2: keyword.operator.logical.regexp.shell set: - - expansions-parameter-pattern-group-charset-body + - expansion-parameter-pattern-group-charset-body - pattern-charset-begin - expansions-parameter-pattern-group-charset-body: + expansion-parameter-pattern-group-charset-body: - meta_scope: meta.set.regexp.shell - match: $|(?=[)}]) # bailout at end of group or parameter - fail: expansions-parameter-pattern-group-charset + fail: expansion-parameter-pattern-group-charset - include: pattern-charset-end - include: pattern-charset-content - expansions-parameter-substitution: + expansion-parameter-substitution-pattern: # [3.5.8.1] Pattern Matching in parameter expansions' substitutions - meta_content_scope: meta.string.regexp.shell - match: / scope: keyword.operator.substitution.shell - set: expressions-parameter-variable - - include: expansions-parameter-pattern + set: expansion-parameter-substitution-value + - include: expansion-parameter-pattern - expansions-parameter-switch: - - match: '[/#%]' - scope: variable.parameter.switch.shell - pop: 1 - - include: line-continuations - - include: immediately-pop + expansion-parameter-substitution-value: + - meta_include_prototype: false + - meta_content_scope: meta.string.shell string.unquoted.shell + - include: expansion-parameter-end + - include: string-unquoted-content - expressions-parameter-variable: - - include: expansions-parameter-common - - include: expansions-variables + expansion-parameter-value: + - meta_include_prototype: false + - meta_content_scope: meta.string.shell string.unquoted.shell + - include: expansion-parameter-end + - include: string-unquoted-content + - include: expansions-patterns - expansions-patterns: - - include: pattern-groups - - include: pattern-charsets - - include: pattern-wildcards + expansion-parameter-end: + - match: \} + scope: punctuation.section.interpolation.end.shell + pop: 1 + +###[ TILDE EXPANSIONS ]######################################################## maybe-tilde-interpolation: - meta_include_prototype: false @@ -2290,12 +2346,12 @@ contexts: pattern-group-content: - include: line-continuations - include: any-escapes - - include: pattern-literals - include: expansions-variables - include: pattern-groups - include: pattern-group-charsets - - include: pattern-wildcards + - include: pattern-literals - include: pattern-operators + - include: pattern-wildcards pattern-group-end: - match: \) @@ -2327,16 +2383,16 @@ contexts: pattern-literals: - match: \" - scope: punctuation.definition.literal.begin.shell + scope: punctuation.definition.quoted.begin.shell push: pattern-double-quoted-literal-body - match: \' - scope: punctuation.definition.literal.begin.shell + scope: punctuation.definition.quoted.begin.shell push: pattern-single-quoted-literal-body pattern-double-quoted-literal-body: - meta_include_prototype: false - match: \" - scope: punctuation.definition.literal.end.shell + scope: punctuation.definition.quoted.end.shell pop: 1 - include: string-prototype - include: string-escapes @@ -2346,7 +2402,7 @@ contexts: pattern-single-quoted-literal-body: - meta_include_prototype: false - match: \' - scope: punctuation.definition.literal.end.shell + scope: punctuation.definition.quoted.end.shell pop: 1 - include: string-prototype @@ -2597,13 +2653,13 @@ contexts: scope: constant.character.escape.shell string-escapes: - - match: '\\(?:e|033)\[\d{1,3}(?:;\d{1,3}){0,4}m' + - match: \\(?:e|033)\[\d{1,3}(?:;\d{1,3}){0,4}m scope: constant.character.escape.color.shell - match: \\[$`"\\] scope: constant.character.escape.shell string-path-separators: - - match: ':(?=\$|(?:~|\.?\.)?/(?!/))' + - match: :(?=\$|(?:~|\.?\.)?/(?!/)) scope: punctuation.separator.sequence.shell string-escapes-ansi-c: @@ -2617,9 +2673,7 @@ contexts: string-interpolation-body: - clear_scopes: 1 - meta_include_prototype: false - - include: expansions-arithmetic - - include: expansions-command - - include: expansions-parameter + - include: expansions-variables - include: immediately-pop # for use by inheriting syntaxes to easily inject string interpolation diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index 78a7da6462..58ef6f454f 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -1655,9 +1655,10 @@ if [ "$1" != "" -a "$2" != "" ]; then #^ keyword.control.conditional.if.shell # <- keyword.control.conditional.if.shell # ^ support.function.test.begin.shell +# ^^ variable.language.positional.shell # ^^ keyword.operator.comparison.shell # ^^ meta.conditional.shell variable.parameter.option.shell -# ^^ variable.other.readwrite.shell +# ^^ variable.language.positional.shell # ^^ keyword.operator.comparison.shell # ^ support.function.test.end.shell # ^ punctuation.terminator.statement.shell @@ -1666,12 +1667,12 @@ if [ "$1" != "" -a "$2" != "" ]; then # <- keyword.declaration.variable.shell # ^^^ variable.other.readwrite.shell # ^ keyword.operator.assignment.shell - # ^^ variable.other.readwrite.shell + # ^^ variable.language.positional.shell local TARGET=$2 # <- keyword.declaration.variable.shell # ^^^^^^ variable.other.readwrite.shell # ^ keyword.operator.assignment.shell - # ^^ variable.other.readwrite.shell + # ^^ variable.language.positional.shell elif [ "$1" ]; then # <- keyword.control.conditional.elseif.shell # ^^^^^^^^ meta.conditional.shell @@ -1686,7 +1687,7 @@ elif [ "$1" ]; then # <- keyword.declaration.variable.shell # ^^^^^^ variable.other.readwrite.shell # ^ keyword.operator.assignment.shell - # ^^ variable.other.readwrite.shell + # ^^ variable.language.positional.shell fi # <- keyword.control.conditional.end.shell @@ -1805,8 +1806,8 @@ case "$1" in # <- keyword.control.conditional.case.shell #^^^ keyword.control.conditional.case.shell # ^ meta.string.shell string.quoted.double.shell punctuation.definition.string.begin.shell -# ^ meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell punctuation.definition.variable.shell -# ^ meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^ meta.string.shell meta.interpolation.parameter.shell variable.language.positional.shell punctuation.definition.variable.shell +# ^ meta.string.shell meta.interpolation.parameter.shell variable.language.positional.shell # ^ meta.string.shell string.quoted.double.shell punctuation.definition.string.end.shell # ^^ keyword.control.in.shell setup ) @@ -2294,7 +2295,7 @@ logExit ( ) { #^ meta.conditional.shell support.function.test.begin.shell # ^^ meta.conditional.shell support.function.test.end.shell # ^^ keyword.operator.logical.shell - # ^^^^ keyword.control.flow.exit.shell + # ^^^^ keyword.control.flow.exit.shell # ^ keyword.operator.arithmetic.shell # ^ meta.number.integer.decimal.shell constant.numeric.value.shell } @@ -2921,8 +2922,8 @@ array=($one "two" ${three} 'four' $5) # ^ string.quoted.single punctuation.definition.string.begin.shell # ^^^^ string.quoted.single.shell # ^ string.quoted.single punctuation.definition.string.end.shell +# ^^ variable.language.positional.shell # ^ punctuation.definition.variable.shell -# ^ variable.other.readwrite.shell # ^ punctuation.section.sequence.end.shell array=([one]== ["two"]='what' [4+5]=qux [five]=0 [six]=0s) @@ -2971,7 +2972,7 @@ echo ${array[@]} # ^^^^^ variable.other.readwrite.shell # ^^^ meta.item-access.shell - variable.other # ^ punctuation.section.item-access.begin.shell -# ^ variable.language.array.shell +# ^ variable.language.shell # ^ punctuation.section.item-access.end.shell array["foo"]=bar @@ -3121,15 +3122,15 @@ commits=($(git rev-list --reverse --$abbrev-commit "$latest".. -- "$prefix")) ############################################################################### : $1 $2 $3 $45 $678 -# ^^ meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^^ meta.interpolation.parameter.shell variable.language.positional.shell # ^ - meta.interpolation - variable -# ^^ meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^^ meta.interpolation.parameter.shell variable.language.positional.shell # ^ - meta.interpolation - variable -# ^^ meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^^ meta.interpolation.parameter.shell variable.language.positional.shell # ^ - meta.interpolation - variable -# ^^ meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^^ meta.interpolation.parameter.shell variable.language.positional.shell # ^^ - meta.interpolation - variable -# ^^ meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^^ meta.interpolation.parameter.shell variable.language.positional.shell # ^^^ - meta.interpolation - variable # When a positional parameter consisting of more than a single digit is expanded, @@ -3138,12 +3139,12 @@ commits=($(git rev-list --reverse --$abbrev-commit "$latest".. -- "$prefix")) # ^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^^ variable.other.readwrite.shell +# ^^ variable.language.positional.shell # ^ punctuation.section.interpolation.end.shell # ^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^^^ variable.other.readwrite.shell +# ^^^ variable.language.positional.shell # ^ punctuation.section.interpolation.end.shell @@ -3161,9 +3162,26 @@ commits=($(git rev-list --reverse --$abbrev-commit "$latest".. -- "$prefix")) # equivalent to "$1c$2c…", where c is the first character of the value of the # IFS variable. If IFS is unset, the parameters are separated by spaces. If IFS # is null, the parameters are joined without intervening separators. -: $* +: $* ${*} ${!*} ${#*} # ^^ meta.interpolation.parameter.shell variable.language.shell # ^ punctuation.definition.variable.shell +# ^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ punctuation.section.interpolation.end.shell +# ^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.indirection.shell +# ^ variable.language.shell +# ^ punctuation.section.interpolation.end.shell +# ^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.length.shell +# ^ variable.language.shell +# ^ punctuation.section.interpolation.end.shell # Expands to the positional parameters, starting from one. When the expansion # occurs within double quotes, each parameter expands to a separate word. That @@ -3172,37 +3190,139 @@ commits=($(git rev-list --reverse --$abbrev-commit "$latest".. -- "$prefix")) # beginning part of the original word, and the expansion of the last parameter # is joined with the last part of the original word. When there are no # positional parameters, "$@" and $@ expand to nothing (i.e., they are removed). -: $@ +: $@ ${@} ${!@} ${#@} # ^^ meta.interpolation.parameter.shell variable.language.shell # ^ punctuation.definition.variable.shell +# ^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ punctuation.section.interpolation.end.shell +# ^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.indirection.shell +# ^ variable.language.shell +# ^ punctuation.section.interpolation.end.shell +# ^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.length.shell +# ^ variable.language.shell +# ^ punctuation.section.interpolation.end.shell # Expands to the number of positional parameters in decimal. -: $# +: $# ${#} ${!#} ${##} # ^^ meta.interpolation.parameter.shell variable.language.shell # ^ punctuation.definition.variable.shell +# ^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ punctuation.section.interpolation.end.shell +# ^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.indirection.shell +# ^ variable.language.shell +# ^ punctuation.section.interpolation.end.shell +# ^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.length.shell +# ^ variable.language.shell +# ^ punctuation.section.interpolation.end.shell # Expands to the exit status of the most recently executed foreground pipeline. -: $? +: $? ${?} ${!?} ${#?} # ^^ meta.interpolation.parameter.shell variable.language.shell # ^ punctuation.definition.variable.shell +# ^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ punctuation.section.interpolation.end.shell +# ^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.indirection.shell +# ^ variable.language.shell +# ^ punctuation.section.interpolation.end.shell +# ^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.length.shell +# ^ variable.language.shell +# ^ punctuation.section.interpolation.end.shell # Expands to the current option flags as specified upon invocation, by the set # builtin command, or those set by the shell itself (such as the -i option). -: $- +: $- ${-} ${!-} ${#-} # ^^ meta.interpolation.parameter.shell variable.language.shell # ^ punctuation.definition.variable.shell +# ^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ punctuation.section.interpolation.end.shell +# ^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.indirection.shell +# ^ variable.language.shell +# ^ punctuation.section.interpolation.end.shell +# ^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.length.shell +# ^ variable.language.shell +# ^ punctuation.section.interpolation.end.shell # Expands to the process ID of the shell. In a () subshell, it expands to the # process ID of the invoking shell, not the subshell. -: $$ +: $$ ${$} ${!$} ${#$} # ^^ meta.interpolation.parameter.shell variable.language.shell # ^ punctuation.definition.variable.shell +# ^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ punctuation.section.interpolation.end.shell +# ^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.indirection.shell +# ^ variable.language.shell +# ^ punctuation.section.interpolation.end.shell +# ^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.length.shell +# ^ variable.language.shell +# ^ punctuation.section.interpolation.end.shell # Expands to the process ID of the job most recently placed into the background, # whether executed as an asynchronous command or using the bg builtin -: $! +: $! ${!} ${!!} ${#!} # ^^ meta.interpolation.parameter.shell variable.language.shell # ^ punctuation.definition.variable.shell +# ^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ punctuation.section.interpolation.end.shell +# ^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.indirection.shell +# ^ variable.language.shell +# ^ punctuation.section.interpolation.end.shell +# ^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.length.shell +# ^ variable.language.shell +# ^ punctuation.section.interpolation.end.shell # Expands to the name of the shell or shell script. This is set at shell # initialization. If Bash is invoked with a file of commands (see Shell @@ -3210,9 +3330,26 @@ commits=($(git rev-list --reverse --$abbrev-commit "$latest".. -- "$prefix")) # option (see Invoking Bash), then $0 is set to the first argument after the # string to be executed, if one is present. Otherwise, it is set to the filename # used to invoke Bash, as given by argument zero. -: $0 -# ^^ meta.interpolation.parameter.shell variable.other.readwrite.shell +: $0 ${0} ${!0} ${#0} +# ^^ meta.interpolation.parameter.shell variable.language.positional.shell # ^ punctuation.definition.variable.shell +# ^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.positional.shell +# ^ punctuation.section.interpolation.end.shell +# ^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.indirection.shell +# ^ variable.language.positional.shell +# ^ punctuation.section.interpolation.end.shell +# ^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.length.shell +# ^ variable.language.positional.shell +# ^ punctuation.section.interpolation.end.shell # At shell startup, set to the absolute pathname used to invoke the shell or # shell script being executed as passed in the environment or argument list. @@ -3220,9 +3357,26 @@ commits=($(git rev-list --reverse --$abbrev-commit "$latest".. -- "$prefix")) # expansion. Also set to the full pathname used to invoke each command executed # and placed in the environment exported to that command. When checking mail, # this parameter holds the name of the mail file. -: $_ +: $_ ${_} ${!_} ${#_} # ^^ meta.interpolation.parameter.shell variable.language.shell # ^ punctuation.definition.variable.shell +# ^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ punctuation.section.interpolation.end.shell +# ^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.indirection.shell +# ^ variable.language.shell +# ^ punctuation.section.interpolation.end.shell +# ^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.length.shell +# ^ variable.language.shell +# ^ punctuation.section.interpolation.end.shell ############################################################################### @@ -3681,732 +3835,3126 @@ test $me -eq ~/~foo # ^ punctuation.definition.variable.shell # ^ - meta.interpolation - variable -${foo:=bar} -# <- meta.function-call.identifier.shell meta.interpolation.parameter.shell punctuation.definition.variable.shell -#^^^^^^^^^^ meta.function-call.identifier.shell meta.interpolation.parameter.shell -#^ punctuation.section.interpolation.begin.shell -# <- - variable.other.readwrite -# ^^^ variable.other.readwrite.shell -# ^^ keyword.operator.assignment.shell -# ^^^^ - string.unquoted -# ^ punctuation.section.interpolation.end.shell +################################ -: ${foo:-bar} -# ^^^^^^^^^^^ meta.interpolation.parameter.shell +# When braces are used, the matching ending brace is the first ‘}’ +: ${} +# ^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^^^ variable.other.readwrite.shell -# ^^ keyword.operator.assignment.shell -# ^ punctuation.section.interpolation.end.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta -: ${foo:0:8} -# ^^^^^^^^^^ meta.interpolation.parameter.shell +# ...not escaped by a backslash, +: ${\}} # bad substitution +# ^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^^^ variable.other.readwrite.shell -# ^ keyword.operator.substring.begin.shell -# ^ meta.number.integer.decimal.shell constant.numeric.value.shell - variable -# ^ keyword.operator.substring.end.shell -# ^ meta.number.integer.decimal.shell constant.numeric.value.shell - variable -# ^ punctuation.section.interpolation.end.shell +# ^^ constant.character.escape.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta -: ${@:0:1} -# ^^^^^^^^ meta.interpolation.parameter.shell +# ... not within a quoted string, +: ${"}"} # bad substitution +# ^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell -# ^ keyword.operator.substring.begin.shell -# ^ meta.number.integer.decimal.shell constant.numeric.value.shell -# ^ keyword.operator.substring.end.shell -# ^ meta.number.integer.decimal.shell constant.numeric.value.shell -# ^ punctuation.section.interpolation.end.shell +# ^ punctuation.definition.quoted.begin.shell +# ^ punctuation.definition.quoted.end.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta -: ${*:0:1} -# ^^^^^^^^ meta.interpolation.parameter.shell +# ... not within and command substitution, +: ${$( } )} +# ^^ meta.interpolation.parameter.shell - meta.interpolation.command +# ^^^^^^ meta.interpolation.parameter.shell meta.interpolation.command.shell +# ^ meta.interpolation.parameter.shell - meta.interpolation.command # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ - variable.language -# ^ keyword.operator.substring.begin.shell -# ^ meta.number.integer.decimal.shell constant.numeric.value.shell -# ^ keyword.operator.substring.end.shell -# ^ meta.number.integer.decimal.shell constant.numeric.value.shell -# ^ punctuation.section.interpolation.end.shell - -: ${foo:='bar'} -# ^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.function.shell +# ^^ punctuation.section.interpolation.end.shell +# ^ - meta + +# ...not within an embedded arithmetic expansion, +: ${$(( } ))} +# ^^ meta.interpolation.parameter.shell - meta.interpolation.arithmetic +# ^^^^^^^^ meta.interpolation.parameter.shell meta.interpolation.arithmetic.shell +# ^ meta.interpolation.parameter.shell - meta.interpolation.arithmetic # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^^ keyword.operator.assignment.shell -# ^ punctuation.definition.string.begin.shell -# ^^^^^ meta.string.shell string.quoted.single.shell -# ^ punctuation.definition.string.end.shell -# ^ punctuation.section.interpolation.end.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ - punctuation +# ^^^ punctuation.section.interpolation.end.shell +# ^ - meta -: ${foo/#bar/baz} -# ^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +################################ + +: ${foo} +# ^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^^^ variable.other.readwrite.shell -# ^ keyword.operator.substitution.shell -# ^ variable.parameter.switch.shell -# ^ keyword.operator.substitution.shell -# ^ punctuation.section.interpolation.end.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta.interpolation - punctuation - variable -: ${foo/%bar/baz} -# ^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +: ${foo}@ +# ^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^^^ variable.other.readwrite.shell -# ^ keyword.operator.substitution.shell -# ^ variable.parameter.switch.shell -# ^ keyword.operator.substitution.shell -# ^ punctuation.section.interpolation.end.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta.interpolation - punctuation - variable -: ${foo//bar/baz} -# ^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +: ${foo}# +# ^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^^^ variable.other.readwrite.shell -# ^ keyword.operator.substitution.shell -# ^ variable.parameter.switch.shell -# ^ keyword.operator.substitution.shell -# ^ punctuation.section.interpolation.end.shell - +# ^ punctuation.section.interpolation.end.shell +# ^ - meta.interpolation - punctuation - variable -: ${#} # is the same as $# -# ^^^^ meta.interpolation.parameter.shell -# ^ punctuation.definition.variable.shell -# ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell -# ^ punctuation.section.interpolation.end.shell -: ${#*} -# ^^^^^ meta.interpolation.parameter.shell +: ${foo}? +# ^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ keyword.operator.arithmetic.shell -# ^ variable.language.shell -# ^ punctuation.section.interpolation.end.shell -: ${#@} -# ^^^^^ meta.interpolation.parameter.shell +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta.interpolation - punctuation - variable + +: ${foo}! +# ^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ keyword.operator.arithmetic.shell -# ^ variable.language.shell -# ^ punctuation.section.interpolation.end.shell -: ${@/bar/baz} -# ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell -: ${*/bar/baz} -# ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell -: ${@#pattern} -# ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell -: ${*#pattern} -# ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell -: ${@##pattern} -# ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell -: ${*##pattern} -# ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell -: ${@%pattern} -# ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell -: ${*%%pattern} -# ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell -: ${@,pattern} -# ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell -: ${*,,pattern} -# ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell -: ${@^pattern} -# ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell -: ${*^^pattern} -# ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell -: ${foo@Q} -# ^ keyword.operator.expansion.shell -# ^ variable.parameter.switch.shell -: ${foo@E} -# ^ keyword.operator.expansion.shell -# ^ variable.parameter.switch.shell -: ${foo@P} -# ^ keyword.operator.expansion.shell -# ^ variable.parameter.switch.shell -: ${foo@A} -# ^ keyword.operator.expansion.shell -# ^ variable.parameter.switch.shell -: ${foo@a} -# ^ keyword.operator.expansion.shell -# ^ variable.parameter.switch.shell -: ${foo@t} -# ^ - keyword.operator -# ^ - variable.parameter.switch +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta.interpolation - punctuation - variable -: ${foo:=`bar`} -# ^^^^^^^ meta.interpolation.parameter.shell - meta.interpolation meta.interpolation -# ^^^^^ meta.interpolation.parameter.shell meta.interpolation.command.shell -# ^ meta.interpolation.parameter.shell - meta.interpolation meta.interpolation +: ${foo}* +# ^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^^ keyword.operator.assignment.shell -# ^ punctuation.section.interpolation.begin.shell -# ^^ punctuation.section.interpolation.end.shell +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta.interpolation - punctuation - variable -: ${foo:=$( bar )} -# ^^^^^^^ meta.interpolation.parameter.shell - meta.interpolation meta.interpolation -# ^^^^^^^^ meta.interpolation.parameter.shell meta.interpolation.command.shell -# ^ meta.interpolation.parameter.shell - meta.interpolation meta.interpolation +: ${foo}- +# ^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^^ keyword.operator.assignment.shell -# ^ punctuation.definition.variable.shell -# ^ punctuation.section.interpolation.begin.shell -# ^^ punctuation.section.interpolation.end.shell +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta.interpolation - punctuation - variable -: ${foo:=$(( 1 + 1 ))} -# ^^^^^^^ meta.interpolation.parameter.shell - meta.interpolation meta.interpolation -# ^^^^^^^^^^^^ meta.interpolation.parameter.shell meta.interpolation.arithmetic.shell -# ^ meta.interpolation.parameter.shell - meta.interpolation meta.interpolation +: ${foo}_ +# ^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^^ keyword.operator.assignment.shell -# ^ punctuation.definition.variable.shell -# ^^ punctuation.section.interpolation.begin.shell -# ^ meta.number.integer.decimal.shell constant.numeric.value.shell -# ^ keyword.operator.arithmetic.shell -# ^ meta.number.integer.decimal.shell constant.numeric.value.shell -# ^^^ punctuation.section.interpolation.end.shell +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta.interpolation - punctuation - variable -: ${foo:=$bar} -# ^^^^^^^ meta.interpolation.parameter.shell - meta.interpolation meta.interpolation -# ^^^^ meta.interpolation.parameter.shell meta.interpolation.parameter.shell variable.other.readwrite.shell -# ^ meta.interpolation.parameter.shell - meta.interpolation meta.interpolation +################################ + +# If the first character of parameter is an exclamation point (!), and +# parameter is not a nameref, it introduces a level of indirection. Bash uses +# the value formed by expanding the rest of parameter as the new parameter; +# this is then expanded and that value is used in the rest of the expansion, +# rather than the expansion of the original parameter. This is known as +# indirect expansion. + +: ${!foo} +# ^ keyword.operator.expansion.indirection.shell + +: ${\ +!foo} +# <- keyword.operator.expansion.indirection.shell + +: ${\ +!\ +foo} +# <- meta.interpolation.parameter.shell variable.other.readwrite.shell + +: ${foo!} +# ^ - keyword + +# Expands to the names of variables whose names begin with prefix, separated +# by the first character of the IFS special variable. When ‘@’ is used and the +# expansion appears within double quotes, each variable name expands to a +# separate word. + +: ${!prefix*} +# ^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.indirection.shell +# ^ variable.language.shell +# ^ punctuation.section.interpolation.end.shell + +: ${!prefix@} +# ^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.indirection.shell +# ^ variable.language.shell +# ^ punctuation.section.interpolation.end.shell + +: ${!${prefix}@} +# ^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.indirection.shell +# ^ variable.language.shell +# ^ punctuation.section.interpolation.end.shell + +# If name is an array variable, expands to the list of array indices (keys) +# assigned in name. If name is not an array, expands to 0 if name is set and +# null otherwise. When ‘@’ is used and the expansion appears within double +# quotes, each key expands to a separate word. + +: ${!prefix[*]} +# ^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.indirection.shell +# ^ variable.language.shell +# ^ punctuation.section.interpolation.end.shell + +: ${!prefix[@]} +# ^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.indirection.shell +# ^ variable.language.shell +# ^ punctuation.section.interpolation.end.shell + +################################ + +: ${#foo} +# ^ keyword.operator.expansion.length.shell + +: ${\ +#foo} +# <- keyword.operator.expansion.length.shell + +: ${\ +#\ +foo} +# <- meta.interpolation.parameter.shell variable.other.readwrite.shell + +################################ + +# If parameter is unset or null, the expansion of word is substituted. +# Otherwise, the value of parameter is substituted. + +: ${@-bar} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${*-bar} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${?-bar} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${#-bar} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${$-bar} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${--bar} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${!-bar} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${_-bar} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo-bar} +# ^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo-~+/*bar} +# ^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ keyword.operator.assignment.shell +# ^^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string +# ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation.tilde +# ^ constant.other.wildcard.asterisk.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo-m~+/*bar} +# ^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ keyword.operator.assignment.shell +# ^^^^^^^^ meta.string.shell string.unquoted.shell +# ^^ - constant - variable +# ^ constant.other.wildcard.asterisk.shell + +: ${foo-~u${se}r/*bar} +# ^^^^^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ keyword.operator.assignment.shell +# ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string +# ^ meta.string.shell meta.interpolation.tilde.shell meta.string.shell string.unquoted.username.shell - string string +# ^^^^^ meta.string.shell meta.interpolation.tilde.shell meta.string.shell meta.interpolation.parameter.shell - string +# ^ meta.string.shell meta.interpolation.tilde.shell meta.string.shell string.unquoted.username.shell - string string +# ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation.tilde +# ^ constant.other.wildcard.asterisk.shell +# ^ punctuation.section.interpolation.end.shell + +################################ + +: ${@:-bar} +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${*:-bar} +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${?:-bar} +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${#:-bar} +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${$:-bar} +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${-:-bar} +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${!:-bar} +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${_:-bar} +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo:-bar} +# ^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell # ^^ keyword.operator.assignment.shell -# ^ punctuation.definition.variable.shell -# ^^^ variable.other -# ^ punctuation.section.interpolation.end.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell -: ${foo:="$bar"} -# ^^^^^^^^ meta.interpolation.parameter.shell - meta.interpolation meta.interpolation -# ^^^^ meta.interpolation.parameter.shell meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell -# ^^ meta.interpolation.parameter.shell - meta.interpolation meta.interpolation +: ${foo:-~+/*bar} +# ^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell # ^^ keyword.operator.assignment.shell -# ^ punctuation.definition.string.begin.shell -# ^ punctuation.definition.variable.shell -# ^^^^ variable.other.readwrite.shell -# ^ punctuation.definition.string.end.shell -# ^ punctuation.section.interpolation.end.shell +# ^^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string +# ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation.tilde +# ^ constant.other.wildcard.asterisk.shell +# ^ punctuation.section.interpolation.end.shell -: ${foo//}/foo} +: ${foo:-m~+/*bar} +# ^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^^ keyword.operator.assignment.shell +# ^^^^^^^^ meta.string.shell string.unquoted.shell +# ^^ - constant - variable +# ^ constant.other.wildcard.asterisk.shell + +: ${foo:-~u${se}r/*bar} +# ^^^^^^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^^ keyword.operator.assignment.shell +# ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string +# ^ meta.string.shell meta.interpolation.tilde.shell meta.string.shell string.unquoted.username.shell - string string +# ^^^^^ meta.string.shell meta.interpolation.tilde.shell meta.string.shell meta.interpolation.parameter.shell - string +# ^ meta.string.shell meta.interpolation.tilde.shell meta.string.shell string.unquoted.username.shell - string string +# ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation.tilde +# ^ constant.other.wildcard.asterisk.shell +# ^ punctuation.section.interpolation.end.shell + +################################ + +# If parameter is unset or null, the expansion of word is assigned to +# parameter. The value of parameter is then substituted. Positional parameters +# and special parameters may not be assigned to in this way. + +: ${@=bar} # ^^^^^^^^ meta.interpolation.parameter.shell -# ^^^^^ - meta.interpolation +# ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ keyword.operator.substitution.shell -# ^ variable.parameter.switch.shell +# ^ variable.language.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell -: ${foo//\}/foo} -# ^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +: ${*=bar} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ keyword.operator.substitution.shell -# ^ variable.parameter.switch.shell -# ^^ constant.character.escape.shell +# ^ variable.language.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${#=bar} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${?=bar} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${$=bar} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${-=bar} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${!=bar} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${_=bar} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo=bar} +# ^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo=~+/*bar} +# ^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ keyword.operator.assignment.shell +# ^^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string +# ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation.tilde +# ^ constant.other.wildcard.asterisk.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo=m~+/*bar} +# ^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ keyword.operator.assignment.shell +# ^^^^^^^^ meta.string.shell string.unquoted.shell +# ^^ - constant - variable +# ^ constant.other.wildcard.asterisk.shell + +################################ + +: ${@:=bar} +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${*:=bar} +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${#:=bar} +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${?:=bar} +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${$:=bar} +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${-:=bar} +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${!:=bar} +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${_:=bar} +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo:=bar} +# ^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo:=~+/*bar} +# ^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^^ keyword.operator.assignment.shell +# ^^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string +# ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation.tilde +# ^ constant.other.wildcard.asterisk.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo:=m~+/*bar} +# ^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^^ keyword.operator.assignment.shell +# ^^^^^^^^ meta.string.shell string.unquoted.shell +# ^^ - constant - variable +# ^ constant.other.wildcard.asterisk.shell + +################################ + +# If parameter is null or unset, the expansion of word (or a message to that +# effect if word is not present) is written to the standard error and the +# shell, if it is not interactive, exits. Otherwise, the value of parameter is +# substituted. + +: ${@?bar} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${*?bar} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${#?bar} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${??bar} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${$?bar} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${-?bar} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${!?bar} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${_?bar} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo?bar} +# ^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo?~+/?bar} +# ^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ keyword.operator.assignment.shell +# ^^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string +# ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation.tilde +# ^ constant.other.wildcard.questionmark.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo?m~+/?bar} +# ^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ keyword.operator.assignment.shell +# ^^^^^^^^ meta.string.shell string.unquoted.shell +# ^^ - constant - variable +# ^ constant.other.wildcard.questionmark.shell + +################################ + +: ${@:?bar} +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${*:?bar} +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${#:?bar} +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${?:?bar} +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${$:?bar} +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${-:?bar} +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${!:?bar} +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${_:?bar} +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo:?bar} +# ^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo:?~+/*bar} +# ^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^^ keyword.operator.assignment.shell +# ^^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string +# ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation.tilde +# ^ constant.other.wildcard.asterisk.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo:?m~+/*bar} +# ^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^^ keyword.operator.assignment.shell +# ^^^^^^^^ meta.string.shell string.unquoted.shell +# ^^ - constant - variable +# ^ constant.other.wildcard.asterisk.shell + +################################ + +# If parameter is null or unset, nothing is substituted, otherwise the +# expansion of word is substituted. + +: ${@+bar} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${*+bar} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${#+bar} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${?+bar} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${$+bar} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${-+bar} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${!+bar} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${_+bar} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo+bar} +# ^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo+~+/*bar} +# ^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ keyword.operator.assignment.shell +# ^^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string +# ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation.tilde +# ^ constant.other.wildcard.asterisk.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo+m~+/*bar} +# ^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ keyword.operator.assignment.shell +# ^^^^^^^^ meta.string.shell string.unquoted.shell +# ^^ - constant - variable +# ^ constant.other.wildcard.asterisk.shell + +################################ + +: ${@:+bar} +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${*:+bar} +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${#:+bar} +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${?:+bar} +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${$:+bar} +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${-:+bar} +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${!:+bar} +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${_:+bar} +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo:+bar} +# ^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo:+~+/*bar} +# ^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^^ keyword.operator.assignment.shell +# ^^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string +# ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation.tilde +# ^ constant.other.wildcard.asterisk.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo:+m~+/*bar} +# ^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^^ keyword.operator.assignment.shell +# ^^^^^^^^ meta.string.shell string.unquoted.shell +# ^^ - constant - variable +# ^ constant.other.wildcard.asterisk.shell + +################################ +# ${parameter:offset:length} + +: ${@:0:1} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.substring.begin.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ keyword.operator.substring.end.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.section.interpolation.end.shell + +: ${*:0:1} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.substring.begin.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ keyword.operator.substring.end.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.section.interpolation.end.shell + +: ${#:0:1} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.substring.begin.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ keyword.operator.substring.end.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.section.interpolation.end.shell + +: ${?:0:1} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.substring.begin.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ keyword.operator.substring.end.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.section.interpolation.end.shell + +: ${$:0:1} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.substring.begin.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ keyword.operator.substring.end.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.section.interpolation.end.shell + +: ${-:0:1} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.substring.begin.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ keyword.operator.substring.end.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.section.interpolation.end.shell + +: ${!:0:1} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.substring.begin.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ keyword.operator.substring.end.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.section.interpolation.end.shell + +: ${_:0:1} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.substring.begin.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ keyword.operator.substring.end.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo:0:8} +# ^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ keyword.operator.substring.begin.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell - variable +# ^ keyword.operator.substring.end.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell - variable +# ^ punctuation.section.interpolation.end.shell + +: ${var:pos:len} +# ^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.substring.begin.shell +# ^ keyword.operator.substring.end.shell +# ^ punctuation.section.interpolation.end.shell + +: ${var:pos + 2:len * 4} +# ^^^^^^^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.substring.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ keyword.operator.arithmetic.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ keyword.operator.substring.end.shell +# ^^^ variable.other.readwrite.shell +# ^ keyword.operator.arithmetic.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.section.interpolation.end.shell + +: ${${var}:${pos}:${len}} +# ^^ meta.interpolation.parameter.shell - meta.interpolation meta.interpolation +# ^^^^^^ meta.interpolation.parameter.shell meta.interpolation.parameter.shell +# ^ meta.interpolation.parameter.shell - meta.interpolation meta.interpolation +# ^^^^^^ meta.interpolation.parameter.shell meta.interpolation.parameter.shell +# ^ meta.interpolation.parameter.shell - meta.interpolation meta.interpolation +# ^^^^^^ meta.interpolation.parameter.shell meta.interpolation.parameter.shell +# ^ meta.interpolation.parameter.shell - meta.interpolation meta.interpolation +# ^ - meta.interpolation + +################################ +# ${parameter/pattern/word} + +: ${@/bar/baz} +# ^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.regexp.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta + +: ${*/bar/baz} +# ^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.regexp.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta + +: ${#/bar/baz} +# ^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.regexp.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta + +: ${?/bar/baz} +# ^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.regexp.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta + +: ${$/bar/baz} +# ^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.regexp.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta + +: ${-/bar/baz} +# ^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.regexp.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta + +: ${!/bar/baz} +# ^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.regexp.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta + +: ${_/bar/baz} +# ^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.regexp.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta + +: ${foo/bar/baz} +# ^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.regexp.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta + +: ${foo@/bar/baz} +# ^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ variable.language.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.regexp.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta + +: ${foo*/bar/baz} +# ^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ variable.language.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.regexp.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta + +: ${foo[@]/bar/baz} +# ^^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.item-access.begin.shell +# ^ variable.language.shell +# ^ punctuation.section.item-access.end.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.regexp.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta + +: ${foo[*]/bar/baz} +# ^^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.item-access.begin.shell +# ^ variable.language.shell +# ^ punctuation.section.item-access.end.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.regexp.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta + +# pattern switches + +: ${foo/#bar/baz} +# ^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^^ keyword.operator.substitution.shell +# ^ keyword.operator.substitution.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo/%bar/baz} +# ^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^^ keyword.operator.substitution.shell +# ^ keyword.operator.substitution.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//bar/baz} +# ^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^^ keyword.operator.substitution.shell +# ^ keyword.operator.substitution.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//@/} +# ^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ - meta.interpolation +# ^^ keyword.operator.substitution.shell +# ^ - keyword - variable +# ^ keyword.operator.substitution.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//*/} +# ^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ - meta.interpolation +# ^^ keyword.operator.substitution.shell +# ^ constant.other.wildcard.asterisk.shell +# ^ keyword.operator.substitution.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//#/} +# ^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ - meta.interpolation +# ^^ keyword.operator.substitution.shell +# ^ - keyword - variable +# ^ keyword.operator.substitution.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//?/} +# ^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ - meta.interpolation +# ^^ keyword.operator.substitution.shell +# ^ constant.other.wildcard.questionmark.shell +# ^ keyword.operator.substitution.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//-/} +# ^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ - meta.interpolation +# ^^ keyword.operator.substitution.shell +# ^ - keyword - variable +# ^ keyword.operator.substitution.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//!/} +# ^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ - meta.interpolation +# ^^ keyword.operator.substitution.shell +# ^ - keyword - variable +# ^ keyword.operator.substitution.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//_/} +# ^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ - meta.interpolation +# ^^ keyword.operator.substitution.shell +# ^ - keyword - variable +# ^ keyword.operator.substitution.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//%/} +# ^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ - meta.interpolation +# ^^ keyword.operator.substitution.shell +# ^ - keyword - variable +# ^ keyword.operator.substitution.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//:/} +# ^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ - meta.interpolation +# ^^ keyword.operator.substitution.shell +# ^ - keyword +# ^ keyword.operator.substitution.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//a\/b/c/d} +# ^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ - meta.interpolation +# ^^ keyword.operator.substitution.shell +# ^^ constant.character.escape +# ^ keyword.operator.substitution.shell +# ^ - keyword.operator +# ^ punctuation.section.interpolation.end.shell + +: ${foo//\ +a\/b/c/d} +# <- meta.interpolation.parameter.shell meta.string.regexp.shell +#^^^ meta.interpolation.parameter.shell meta.string.regexp.shell +# ^ meta.interpolation.parameter.shell - meta.interpolation.parameter.shell meta.string +# ^^^ meta.interpolation.parameter.shell meta.string.shell +# ^ meta.interpolation.parameter.shell - meta.interpolation.parameter.shell meta.string +#^^ constant.character.escape.shell +# ^ keyword.operator.substitution.shell +# ^ - keyword +# ^ punctuation.section.interpolation.end.shell + +# expansion termination within patterns or words + +: ${foo//}/foo} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^^^^^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^ keyword.operator.substitution.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//\}/foo} +# ^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^ keyword.operator.substitution.shell +# ^^ constant.character.escape.shell # ^ keyword.operator.substitution.shell # ^ punctuation.section.interpolation.end.shell -: ${foo//:/[}] -# ^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^^^ - meta.string.regexp - meta.set -# ^ - meta.interpolation +: ${foo//:/[}] +# ^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^^^ - meta.string.regexp - meta.set +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^^ keyword.operator.substitution.shell +# ^ keyword.operator.substitution.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//:/[\}]} +# ^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^^ keyword.operator.substitution.shell +# ^ keyword.operator.substitution.shell +# ^^^^ - meta.string.regexp - meta.set - punctuation +# ^^ constant.character.escape.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//[a-/\}} # incomplete charset +# ^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^^ keyword.operator.substitution.shell +# ^^^ - meta.set - punctuation +# ^ keyword.operator.substitution.shell +# ^^ constant.character.escape.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//+([a-:/\}} # incomplete charset in incomplete group +# ^^^^^^^^ meta.interpolation.parameter.shell - meta.group +# ^^^^^^^^ meta.interpolation.parameter.shell meta.group.regexp.shell +# ^ meta.interpolation.parameter.shell - meta.group +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^^ keyword.operator.substitution.shell +# ^ keyword.operator.quantifier.regexp.shell +# ^ punctuation.definition.group.begin.regexp.shell +# ^^^^^ - constant - punctuation +# ^^ constant.character.escape.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//+([a|&)/\}} # incomplete charset in group +# ^^^^^^^^ meta.interpolation.parameter.shell - meta.group +# ^^^^^^ meta.interpolation.parameter.shell meta.group.regexp.shell +# ^^^^ meta.interpolation.parameter.shell - meta.group +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^^ keyword.operator.substitution.shell +# ^ keyword.operator.quantifier.regexp.shell +# ^ punctuation.definition.group.begin.regexp.shell +# ^^^^ - constant - punctuation +# ^ keyword.operator.logical.regexp.shell +# ^ punctuation.definition.group.end.regexp.shell +# ^ keyword.operator.substitution.shell +# ^^ constant.character.escape.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//[abc[]/x} # `[` has no meaing within charsets +# ^^^^^^^ meta.interpolation.parameter.shell - meta.string meta.set +# ^^^^^^ meta.interpolation.parameter.shell meta.string.regexp.shell meta.set.regexp.shell +# ^^^ meta.interpolation.parameter.shell - meta.string meta.set +# ^^ keyword.operator.substitution.shell +# ^ punctuation.definition.set.begin.regexp.shell +# ^ - keyword - punctuation +# ^ punctuation.definition.set.end.regexp.shell +# ^ keyword.operator.substitution.shell +# ^ punctuation.section.interpolation.end.shell + +: ${var//f|o/b|ar} # `|` has no meaing in patterns or replacement strings +# ^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^^ keyword.operator.substitution.shell +# ^^^ meta.string.regexp.shell - keyword - punctuation +# ^ keyword.operator.substitution.shell +# ^^^^ meta.string.shell string.unquoted.shell - keyword - punctuation +# ^ punctuation.section.interpolation.end.shell + +: ${var//f&o/b&ar} # `&` has no meaing in patterns or replacement strings +# ^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^^ keyword.operator.substitution.shell +# ^^^ meta.string.regexp.shell - keyword - punctuation +# ^ keyword.operator.substitution.shell +# ^^^^ meta.string.shell string.unquoted.shell - keyword - punctuation +# ^ punctuation.section.interpolation.end.shell + +: ${var//f>o/b>ar} # `>` has no meaing in patterns or replacement strings +# ^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^^ keyword.operator.substitution.shell +# ^^^ meta.string.regexp.shell - keyword - punctuation +# ^ keyword.operator.substitution.shell +# ^^^^ meta.string.shell string.unquoted.shell - keyword - punctuation +# ^ punctuation.section.interpolation.end.shell + +: ${var//f Date: Wed, 12 Jun 2024 21:30:33 +0200 Subject: [PATCH 005/113] [ShellScript] Refactor redirections --- ShellScript/Bash.sublime-syntax | 63 +++++---- ShellScript/test/syntax_test_bash.sh | 195 ++++++++++++++++++++++----- 2 files changed, 194 insertions(+), 64 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index ea415a7a41..3f5d2bfe6e 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -114,8 +114,8 @@ contexts: statements: - include: comments - include: line-continuations - - include: operators - include: redirections + - include: operators - include: def-anonymous - include: cmd-alias - include: cmd-arithmetic @@ -1195,26 +1195,29 @@ contexts: 1: meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell - 2: keyword.operator.assignment.redirection.process.shell + 2: keyword.operator.assignment.redirection.shell 3: meta.compound.shell punctuation.section.compound.begin.shell - push: - - meta_content_scope: meta.compound.shell - - match: \) - scope: - meta.compound.shell - punctuation.section.compound.end.shell - pop: 1 - - include: statements + push: redirections-process-body + + redirections-process-body: + - meta_scope: meta.redirection.shell + - meta_content_scope: meta.compound.shell + - match: \) + scope: + meta.compound.shell + punctuation.section.compound.end.shell + pop: 1 + - include: statements redirections-output: - - match: (\d*)(>>!?|>&?|&>|&?>[|>]) + - match: (\d*)(&>>?[|!]?|>>?&?[|!]?) captures: 1: meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell 2: keyword.operator.assignment.redirection.shell - push: redirections-post + push: redirection-descriptor redirections-input: - match: (\d*)(<&?) @@ -1223,31 +1226,37 @@ contexts: meta.number.integer.decimal.shell constant.numeric.value.shell 2: keyword.operator.assignment.redirection.shell - push: redirections-post + push: redirection-descriptor - redirections-post: - - match: \s*(?:(\d+)|(-)) + redirections-inout: + - match: (\d*)(<>) captures: 1: meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell - 2: punctuation.terminator.file-descriptor.shell - pop: 1 - - match: \s*(?=\S) - set: - - match: '{{cmd_break}}' - pop: 1 - - include: expansions-and-strings - - match: \s* - pop: 1 + 2: keyword.operator.assignment.redirection.shell + push: redirection-descriptor - redirections-inout: - - match: (\d*)(<>) + redirection-descriptor: + - meta_include_prototype: false + - meta_scope: meta.redirection.shell + - include: eoc-pop + - match: (?:(\d+)(-?)|(-)){{cmd_break}} captures: 1: meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell - 2: keyword.operator.assignment.redirection.shell + 2: punctuation.terminator.file-descriptor.shell + 3: punctuation.terminator.file-descriptor.shell + pop: 1 + - match: (?=\S) + set: + - redirection-path + - maybe-tilde-interpolation + + redirection-path: + - meta_scope: meta.redirection.shell meta.path.shell meta.string.shell string.unquoted.shell + - include: string-unquoted-body redirections-here-string: - match: (\d*)(<<<)\s*{{nonposix_begin}} diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index 58ef6f454f..74c25c3d70 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -8032,76 +8032,197 @@ echo '([^.[:space:]]+) Class::method()' # colon not scoped as path separator # https://www.gnu.org/software/bash/manual/bash.html#Redirections # ############################################################################### -function show_help() { - echo "Usage: imgcat [-p] filename ..." 1>& 2 - # ^ meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell - echo " or: cat filename | imgcat" 1>& 2 - # ^ meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell -} + > +# ^ meta.redirection.shell keyword.operator.assignment.redirection.shell +# ^ - meta.redirection + + >- +# ^^ meta.redirection.shell +# ^ keyword.operator.assignment.redirection.shell +# ^ punctuation.terminator.file-descriptor.shell +# ^ - meta.redirection + + >2 +# ^^ meta.redirection.shell +# ^ keyword.operator.assignment.redirection.shell +# ^ constant.numeric.value.shell +# ^ - meta.redirection + + > out~put- +# ^^ meta.redirection.shell - meta.path +# ^^^^^^^^ meta.redirection.shell meta.path.shell +# ^ keyword.operator.assignment.redirection.shell +# ^ - variable +# ^ - punctuation + + > ~/.local/file +# ^^ meta.redirection.shell - meta.path +# ^ meta.redirection.shell meta.path.shell meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell +# ^^^^^^^^^^^^ meta.redirection.shell meta.path.shell meta.string.shell string.unquoted.shell - meta.interpolation +# ^ keyword.operator.assignment.redirection.shell +# ^ variable.language.tilde.shell + + > "~/.local/file" +# ^^ meta.redirection.shell - meta.path +# ^^^^^^^^^^^^^^^ meta.redirection.shell meta.string.shell string.quoted.double.shell +# ^ keyword.operator.assignment.redirection.shell +# ^ punctuation.definition.string.begin.shell +# ^ - variable.language +# ^ punctuation.definition.string.end.shell + +# Open file word for writing as standard output. If the file does not exist +# then it is created. +: > word >| word >! word +# ^^^^^^ meta.redirection.shell +# ^ keyword.operator.assignment.redirection.shell +# ^^^^^^^ meta.redirection.shell +# ^^ keyword.operator.assignment.redirection.shell +# ^^^^^^^ meta.redirection.shell +# ^^ keyword.operator.assignment.redirection.shell + +# Open file word for writing in append mode as standard output. If the file +# does not exist, and the CLOBBER and APPEND_CREATE options are both unset, +# this causes an error; otherwise, the file is created. +: >> word >>| word >>! word +# ^^^^^^^ meta.redirection.shell +# ^^ keyword.operator.assignment.redirection.shell +# ^^^^^^^^ meta.redirection.shell +# ^^^ keyword.operator.assignment.redirection.shell +# ^^^^^^^^ meta.redirection.shell +# ^^^ keyword.operator.assignment.redirection.shell + +# Redirects both standard output and standard error (file descriptor 2) in the +# manner of ‘>| word’. +: >&| word >&! word &>| word &>! word +# ^^^^^^^^ meta.redirection.shell +# ^^^ keyword.operator.assignment.redirection.shell +# ^^^^^^^^ meta.redirection.shell +# ^^^ keyword.operator.assignment.redirection.shell +# ^^^^^^^^ meta.redirection.shell +# ^^^ keyword.operator.assignment.redirection.shell +# ^^^^^^^^ meta.redirection.shell +# ^^^ keyword.operator.assignment.redirection.shell + +# Redirects both standard output and standard error (file descriptor 2) in the +# manner of ‘>> word’. +: >>& word &>> word +# ^^^^^^^^ meta.redirection.shell +# ^^^ keyword.operator.assignment.redirection.shell +# ^^^^^^^^ meta.redirection.shell +# ^^^ keyword.operator.assignment.redirection.shell + +# Redirects both standard output and standard error (file descriptor 2) in the +# manner of ‘>>| word’. +: >>&| word >>&! word &>>| word &>>! word +# ^^^^^^^^^ meta.redirection.shell +# ^^^^ keyword.operator.assignment.redirection.shell +# ^^^^^^^^^ meta.redirection.shell +# ^^^^ keyword.operator.assignment.redirection.shell +# ^^^^^^^^^ meta.redirection.shell +# ^^^^ keyword.operator.assignment.redirection.shell +# ^^^^^^^^^ meta.redirection.shell +# ^^^^ keyword.operator.assignment.redirection.shell foo 2>&1 +# ^^^^ meta.redirection.shell # ^ meta.function-call.arguments meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell # ^^ meta.function-call.arguments keyword.operator.assignment.redirection # ^ meta.function-call.arguments meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell + foo 2>&- -# ^ punctuation.terminator +# ^^^^ meta.redirection.shell +# ^ punctuation.terminator.file-descriptor.shell + foo | bar 2>&1 +# ^^^^ meta.redirection.shell # ^ meta.function-call.arguments meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell # ^^ meta.function-call.arguments keyword.operator.assignment.redirection # ^ meta.function-call.arguments meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell + foo | bar --opt1 arg1 < file.txt -# ^ meta.function-call.arguments keyword.operator.assignment.redirection +# ^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell +# ^^ meta.redirection.shell - meta.path +# ^ keyword.operator.assignment.redirection.shell +# ^^^^^^^^ meta.redirection.shell meta.path.shell + foo | bar --opt1 arg1 > file.txt -# ^ meta.function-call.arguments keyword.operator.assignment.redirection +# ^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell +# ^^ meta.redirection.shell - meta.path +# ^ keyword.operator.assignment.redirection.shell +# ^^^^^^^^ meta.redirection.shell meta.path.shell + foo -x arg1 &>/dev/null -# ^^ meta.function-call.arguments keyword.operator.assignment.redirection +# ^^^^^^^^^ meta.function-call.arguments.shell - meta.redirection +# ^^ meta.function-call.arguments.shell meta.redirection.shell - meta.path +# ^^ keyword.operator.assignment.redirection.shell +# ^^^^^^^^^ meta.function-call.arguments.shell meta.redirection.shell meta.path.shell + foo -x arg1 &> /dev/null -# ^^ meta.function-call.arguments keyword.operator.assignment.redirection +# ^^^^^^^^^ meta.function-call.arguments.shell - meta.redirection +# ^^^ meta.function-call.arguments.shell meta.redirection.shell - meta.path +# ^^ keyword.operator.assignment.redirection.shell +# ^^^^^^^^^ meta.function-call.arguments.shell meta.redirection.shell meta.path.shell +# ^ - meta.function + tr "o" "a" < <(echo "Foo") -# ^ keyword.operator.assignment.redirection - keyword.operator.assignment.redirection.process -# ^ keyword.operator.assignment.redirection.process -# ^ punctuation -# ^ support.function -# ^ punctuation +# ^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell +# ^ keyword.operator.assignment.redirection.shell +# ^ keyword.operator.assignment.redirection.shell +# ^ punctuation.section.compound.begin.shell +# ^ punctuation.section.compound.end.shell + wc <(cat /usr/share/dict/linux.words) -# ^ keyword.operator.assignment.redirection.process -# ^ punctuation -# ^ variable.function -# ^ meta.function-call.arguments meta.function-call.arguments -# ^ meta.function-call.arguments meta.function-call.arguments -# ^ punctuation +# ^ meta.function-call.arguments.shell - meta.redirection +# ^ meta.function-call.arguments.shell meta.redirection.shell - meta.compound +# ^ meta.function-call.arguments.shell meta.redirection.shell meta.compound.shell - meta.function-call meta.function-call +# ^^^ meta.function-call.arguments.shell meta.redirection.shell meta.compound.shell meta.function-call.identifier.shell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.redirection.shell meta.compound.shell meta.function-call.arguments.shell +# ^ meta.function-call.arguments.shell meta.redirection.shell meta.compound.shell - meta.function-call meta.function-call +# ^ keyword.operator.assignment.redirection.shell +# ^ punctuation.section.compound.begin.shell +# ^^^ variable.function.shell +# ^ punctuation.section.compound.end.shell + comm <(ls -l) <(ls -al) -# ^^^^^^^ meta.compound.shell -# ^^ - meta.compound -# ^^^^^^^^ meta.compound.shell -# ^ - meta.compound -# ^ keyword.operator.assignment.redirection.process.shell +# ^ meta.redirection.shell - meta.compound +# ^^^^^^^ meta.redirection.shell meta.compound.shell +# ^ - meta.redirection - meta.compound +# ^ meta.redirection.shell - meta.compound +# ^^^^^^^^ meta.redirection.shell meta.compound.shell +# ^ - meta.redirection - meta.compound +# ^ keyword.operator.assignment.redirection.shell # ^ punctuation.section.compound.begin.shell -# ^^ variable.parameter +# ^^ variable.function.shell +# ^^ variable.parameter.option.shell # ^ punctuation.section.compound.end.shell -# ^ keyword.operator.assignment.redirection.process.shell +# ^ keyword.operator.assignment.redirection.shell # ^ punctuation.section.compound.begin.shell -# ^ variable.function -# ^^^ variable.parameter +# ^^ variable.function.shell +# ^^^ variable.parameter.option.shell # ^ punctuation.section.compound.end.shell + gzip | tee >(md5sum - | sed 's/-$/mydata.lz2/'>mydata-gz.md5) > mydata.gz # ^ keyword.operator.assignment.pipe.shell -# ^ keyword.operator.assignment.redirection.process -# ^ punctuation +# ^ keyword.operator.assignment.redirection.shell +# ^ punctuation.section.compound.begin.shell # ^ keyword.operator.assignment.pipe.shell -# ^ keyword.operator.assignment.redirection -# ^ punctuation -# ^ keyword.operator.assignment.redirection +# ^ keyword.operator.assignment.redirection.shell +# ^ punctuation.section.compound.end.shell +# ^ keyword.operator.assignment.redirection.shell + LC_ALL=C 2> /dev/null +# ^^^ meta.redirection.shell - meta.path # ^ meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell # ^ keyword.operator.assignment.redirection -# ^ - variable.function +# ^^^^^^^^^ meta.redirection.shell meta.path.shell - variable + 2>&1 echo foo # <- meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell #^^ keyword.operator.assignment.redirection # ^ meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell # ^^^^ meta.function-call support.function.echo # ^^^^ meta.function-call.arguments + touch file.txt foo=x Date: Sun, 16 Jun 2024 19:24:02 +0200 Subject: [PATCH 006/113] [ShellScript] Refactor subscriptions --- ShellScript/Bash.sublime-syntax | 113 ++++++++++++++----------- ShellScript/test/syntax_test_bash.sh | 119 +++++++++++++++++++-------- 2 files changed, 148 insertions(+), 84 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 3f5d2bfe6e..16953656f6 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -307,12 +307,12 @@ contexts: - match: '{{is_variable}}' push: - variable-value-assignment - - variable-item-access + - variable-subscription - variable-other-chars variables: - match: (?={{identifier_first_char}}) - push: [variable-item-access, variable-other-chars] + push: [variable-subscription, variable-other-chars] variable-other-chars: - match: '{{identifier_char}}+' @@ -320,12 +320,33 @@ contexts: - include: variable-other-expansions - include: immediately-pop - variable-item-access: + variable-subscription: - meta_scope: meta.variable.shell - - include: arrays-item-access + - include: variable-subscriptions - include: line-continuations - include: immediately-pop + variable-subscriptions: + - match: (\[)([*@])(\]) + scope: meta.item-access.shell + captures: + 1: punctuation.section.item-access.begin.shell + 2: variable.language.shell + 3: punctuation.section.item-access.end.shell + - match: \[ + scope: punctuation.section.item-access.begin.shell + push: variable-subscription-body + + variable-subscription-body: + - meta_include_prototype: false + - meta_scope: meta.item-access.shell + - meta_content_scope: meta.string.shell string.unquoted.shell + - match: \] + scope: punctuation.section.item-access.end.shell + pop: 1 + - include: eoc-pop + - include: string-unquoted-content + variable-value-assignment: - match: '{{varassign}}' scope: keyword.operator.assignment.shell @@ -336,29 +357,50 @@ contexts: variable-value: - match: \( scope: punctuation.section.sequence.begin.shell - set: - - meta_scope: meta.sequence.shell - - match: \) - scope: punctuation.section.sequence.end.shell - pop: 1 - - match: \[ - scope: punctuation.section.brackets.begin.shell - push: - - meta_scope: meta.brackets.shell - - match: \] - scope: punctuation.section.brackets.end.shell - set: variable-value-assignment - - include: expansions-and-strings - - include: comments - - include: comments - - match: (?=\S) - push: variable-value + set: variable-value-list-body - include: line-continuations - include: boolean - include: number - include: string-unquoted - include: immediately-pop + variable-value-list-body: + - meta_scope: meta.sequence.shell + - match: \) + scope: punctuation.section.sequence.end.shell + pop: 1 + - match: \[ + scope: punctuation.definition.key.begin.shell + push: variable-mapping-key-body + - include: comments + - match: (?=\S) + push: variable-value + + variable-mapping-key-body: + - meta_scope: meta.mapping.key.shell + - meta_content_scope: entity.name.key.shell + - match: \] + scope: punctuation.definition.key.end.shell + set: variable-mapping-value-assignment + - include: eoc-pop + - include: expansions-variables + - include: pattern-literals + + variable-mapping-value-assignment: + - meta_content_scope: meta.mapping.shell + - match: '{{varassign}}' + scope: meta.mapping.shell keyword.operator.assignment.shell + set: + - variable-mapping-meta + - variable-value + - include: line-continuations + - include: immediately-pop + + variable-mapping-meta: + - meta_include_prototype: false + - meta_content_scope: meta.mapping.value.shell + - include: immediately-pop + ###[ ALIAS BUILTINS ]########################################################## cmd-alias: @@ -1426,33 +1468,6 @@ contexts: ###[ EXPRESSIONS ]############################################################# - arrays-item-access: - - match: \[ - scope: punctuation.section.item-access.begin.shell - push: - - array-item-access-end - - array-item-access-begin - - array-item-access-end: - - meta_scope: meta.item-access.shell - - match: \] - scope: punctuation.section.item-access.end.shell - pop: 1 - - array-item-access-begin: - - match: '[*@]' - scope: variable.language.shell - pop: 1 - - match: '' - set: array-key-body - - array-key-body: - - meta_content_scope: meta.string.shell string.unquoted.shell - - match: \] - scope: punctuation.section.item-access.end.shell - pop: 2 - - include: string-unquoted-body - expressions: - match: \( scope: punctuation.section.group.begin.shell @@ -2053,7 +2068,7 @@ contexts: set: - expansion-parameter-pattern - maybe-tilde-expansion - - include: arrays-item-access + - include: variable-subscriptions expansion-parameter-substr-start: - match: ':' diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index 74c25c3d70..1ce4a7e806 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -2930,32 +2930,50 @@ array=([one]== ["two"]='what' [4+5]=qux [five]=0 [six]=0s) #^^^^^ - meta.sequence # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.sequence.shell # ^ - meta.sequence +# ^^^^^ meta.mapping.key.shell +# ^ meta.mapping.shell +# ^ meta.mapping.value.shell +# ^^^^^^^ meta.mapping.key.shell +# ^ meta.mapping.shell +# ^^^^^^ meta.mapping.value.shell +# ^^^^^ meta.mapping.key.shell +# ^ meta.mapping.shell +# ^^^ meta.mapping.value.shell +# ^^^^^^ meta.mapping.key.shell +# ^ meta.mapping.shell +# ^ meta.mapping.value.shell +# ^^^^^ meta.mapping.key.shell +# ^ meta.mapping.shell +# ^^ meta.mapping.value.shell # ^ keyword.operator.assignment.shell # ^ punctuation.section.sequence.begin.shell -# ^ punctuation.section.brackets.begin.shell -# ^ punctuation.section.brackets.end.shell +# ^ punctuation.definition.key.begin.shell +# ^^^ entity.name.key.shell +# ^ punctuation.definition.key.end.shell # ^ keyword.operator.assignment.shell -# ^ string.unquoted.shell - keyword -# ^ punctuation.section.brackets.begin.shell -# ^^^^^ string.quoted.double.shell -# ^ punctuation.section.brackets.end.shell +# ^ meta.string.shell string.unquoted.shell - keyword +# ^ punctuation.definition.key.begin.shell +# ^^^^^ entity.name.key.shell +# ^ punctuation.definition.quoted.begin.shell +# ^ punctuation.definition.quoted.end.shell +# ^ punctuation.definition.key.end.shell # ^ keyword.operator.assignment.shell # ^^^^^^ string.quoted.single.shell -# ^ punctuation.section.brackets.begin.shell -# ^ - constant -# ^ - keyword -# ^ - constant -# ^ punctuation.section.brackets.end.shell +# ^ punctuation.definition.key.begin.shell +# ^^^ entity.name.key.shell - constant - keyword +# ^ punctuation.definition.key.end.shell # ^ keyword.operator.assignment.shell -# ^^^ string.unquoted.shell -# ^ punctuation.section.brackets.begin.shell -# ^ punctuation.section.brackets.end.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.definition.key.begin.shell +# ^^^^ entity.name.key.shell +# ^ punctuation.definition.key.end.shell # ^ keyword.operator.assignment.shell # ^ meta.number.integer.decimal.shell constant.numeric.value.shell -# ^ punctuation.section.brackets.begin.shell -# ^ punctuation.section.brackets.end.shell +# ^ punctuation.definition.key.begin.shell +# ^^^ entity.name.key.shell +# ^ punctuation.definition.key.end.shell # ^ keyword.operator.assignment.shell -# ^^ string.unquoted.shell +# ^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.sequence.end.shell declare -a array @@ -2967,13 +2985,6 @@ array[500]=value # ^ punctuation.section.item-access.end.shell # ^ keyword.operator.assignment # ^^^^^ meta.string.shell string.unquoted.shell -echo ${array[@]} -# ^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^^^^^ variable.other.readwrite.shell -# ^^^ meta.item-access.shell - variable.other -# ^ punctuation.section.item-access.begin.shell -# ^ variable.language.shell -# ^ punctuation.section.item-access.end.shell array["foo"]=bar #^^^^ meta.variable.shell variable.other.readwrite.shell @@ -4011,19 +4022,59 @@ foo} # null otherwise. When ‘@’ is used and the expansion appears within double # quotes, each key expands to a separate word. -: ${!prefix[*]} +: ${!prefix[*]} ${!array[ *]} ${!array[* ]} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.section.interpolation.begin.shell # ^ keyword.operator.expansion.indirection.shell # ^ variable.language.shell # ^ punctuation.section.interpolation.end.shell - -: ${!prefix[@]} +# ^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.indirection.shell +# ^^^^^ variable.other.readwrite.shell +# ^^^^ meta.item-access.shell - variable.other +# ^ punctuation.section.item-access.begin.shell +# ^ - variable.language +# ^ punctuation.section.item-access.end.shell +# ^ punctuation.section.interpolation.end.shell +# ^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.indirection.shell +# ^^^^^ variable.other.readwrite.shell +# ^^^^ meta.item-access.shell - variable.other +# ^ punctuation.section.item-access.begin.shell +# ^ - variable.language +# ^ punctuation.section.item-access.end.shell +# ^ punctuation.section.interpolation.end.shell + +: ${!prefix[@]} ${!array[ @]} ${!array[@ ]} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.section.interpolation.begin.shell # ^ keyword.operator.expansion.indirection.shell # ^ variable.language.shell # ^ punctuation.section.interpolation.end.shell +# ^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.indirection.shell +# ^^^^^ variable.other.readwrite.shell +# ^^^^ meta.item-access.shell - variable.other +# ^ punctuation.section.item-access.begin.shell +# ^ - variable.language +# ^ punctuation.section.item-access.end.shell +# ^ punctuation.section.interpolation.end.shell +# ^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.indirection.shell +# ^^^^^ variable.other.readwrite.shell +# ^^^^ meta.item-access.shell - variable.other +# ^ punctuation.section.item-access.begin.shell +# ^ - variable.language +# ^ punctuation.section.item-access.end.shell +# ^ punctuation.section.interpolation.end.shell ################################ @@ -8693,17 +8744,15 @@ declare -a owners=( # dogs # ^^^^^^^ meta.declaration.variable.arguments.shell meta.sequence.shell comment.line.number-sign.shell [susan]=labrador -# ^^^^^^^^^^^^^^^^ meta.declaration.variable.arguments.shell meta.sequence.shell -# ^^^^^^^ meta.brackets.shell -# ^ keyword.operator.assignment.shell -# ^^^^^^^^ meta.string.shell string.unquoted.shell +# ^^^^^^^ meta.declaration.variable.arguments.shell meta.sequence.shell meta.mapping.key.shell +# ^ meta.declaration.variable.arguments.shell meta.sequence.shell keyword.operator.assignment.shell - meta.mapping.key +# ^^^^^^^^ meta.declaration.variable.arguments.shell meta.sequence.shell meta.string.shell string.unquoted.shell # cats # ^^^^^^^ meta.declaration.variable.arguments.shell meta.sequence.shell comment.line.number-sign.shell [terry]=tabby -# ^^^^^^^^^^^^^^ meta.declaration.variable.arguments.shell meta.sequence.shell -# ^^^^^^^ meta.brackets.shell -# ^ keyword.operator.assignment.shell -# ^^^^^ meta.string.shell string.unquoted.shell +# ^^^^^^^ meta.declaration.variable.arguments.shell meta.sequence.shell meta.mapping.key.shell +# ^ meta.declaration.variable.arguments.shell meta.sequence.shell keyword.operator.assignment.shell - meta.mapping.key +# ^^^^^ meta.declaration.variable.arguments.shell meta.sequence.shell meta.string.shell string.unquoted.shell ) declare -f _init_completion > /dev/null && complete -F _upto upto From ac63597bb86a7fd93e604dfadbba83a74f1a9100 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 15 Jun 2024 09:54:28 +0200 Subject: [PATCH 007/113] [ShellScript] Fix function identifiers This commit removes quote-removal from function and alias identifiers as it is not supported by Bash. Function identifiers must be unquoted literals. --- ShellScript/Bash.sublime-syntax | 35 ++++----------------------- ShellScript/test/syntax_test_bash.sh | 36 ++++------------------------ 2 files changed, 9 insertions(+), 62 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 16953656f6..927b6f7b45 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -252,7 +252,8 @@ contexts: def-functions-name-chars: - match: '{{cmd_literal_char}}+' scope: entity.name.function.shell - - include: entity-function-expansions + - include: expansions-variables + - include: line-continuations - include: immediately-pop def-functions-params: @@ -445,7 +446,8 @@ contexts: - meta_scope: meta.variable.shell - match: '{{opt_literal_char}}+' scope: entity.name.function.shell - - include: entity-function-expansions + - include: expansions-variables + - include: line-continuations - include: immediately-pop ###[ ARITHMETIC BUILTINS ]##################################################### @@ -1602,35 +1604,6 @@ contexts: ###[ IDENTIFIER EXPANSIONS AND QUOTES ]######################################## - entity-function-expansions: - - include: line-continuations - - include: any-escapes - - match: \' - scope: punctuation.definition.string.begin.shell - push: - - meta_include_prototype: false - - meta_scope: meta.string.shell entity.name.function.shell - - include: string-quoted-single-body - - match: \" - scope: punctuation.definition.string.begin.shell - push: - - meta_include_prototype: false - - meta_scope: meta.string.shell entity.name.function.shell - - include: string-quoted-double-body - - match: \$' - scope: punctuation.definition.string.begin.shell - push: - - meta_include_prototype: false - - meta_scope: meta.string.shell entity.name.function.shell - - include: string-ansi-c-body - - match: \$" - scope: punctuation.definition.string.begin.shell - push: - - meta_include_prototype: false - - meta_scope: meta.string.shell entity.name.function.shell - - include: string-quoted-double-body - - include: expansions-variables - variable-function-expansions: - include: line-continuations - include: any-escapes diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index 1ce4a7e806..0ff8c7180f 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -2596,15 +2596,15 @@ function =foo () { # <- meta.function-call.identifier.shell variable.function.shell #^^^ meta.function-call.identifier.shell variable.function.shell -function fo${bar}'baz' () {} +function fo${bar}baz () {} # ^^^ meta.function.identifier.shell - meta.interpolation - meta.string # ^^^^^^ meta.function.identifier.shell meta.interpolation.parameter.shell - meta.string -# ^^^^^ meta.function.identifier.shell meta.string.shell - meta.interpolation -# ^^ meta.function.parameters.shell -# ^^^ meta.function.shell +# ^^^ meta.function.identifier.shell - meta.interpolation +# ^^ meta.function.parameters.shell +# ^^^ meta.function.shell # ^^ entity.name.function.shell # ^^^^^^ - entity.name -# ^^^^^ entity.name.function.shell +# ^^^ entity.name.function.shell # Functions may replace booleans. Won't respect that in function calls though. function true () {} ; function false () {} @@ -8581,17 +8581,6 @@ alias foo=bar # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell -alias f'o'o=bar -# <- meta.declaration.alias.shell keyword.declaration.alias.shell -#^^^^ meta.declaration.alias.shell -# ^^^^^^^^^^ meta.declaration.alias.arguments.shell -# ^ - meta.declaration.alias -# ^^^^^ meta.variable.shell entity.name.function.shell -# ^ punctuation.definition.string.begin.shell -# ^ punctuation.definition.string.end.shell -# ^ keyword.operator.assignment.shell -# ^^^ meta.string.shell string.unquoted.shell - alias -p foo=bar 7za=qux # <- meta.declaration.alias.shell keyword.declaration.alias.shell #^^^^ meta.declaration.alias.shell @@ -9519,21 +9508,6 @@ unalias foo # comment # ^ - meta.variable - variable # ^^^^^^^^^^ comment.line.number-sign.shell -unalias foo b"a"r b'a'z 7za -# <- meta.function-call.identifier.shell support.function.unalias.shell -#^^^^^^ meta.function-call.identifier.shell support.function.unalias.shell -# ^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell -# ^ - meta.function -# ^ - meta.variable - variable -# ^^^ entity.name.function.shell -# ^ - meta.variable - variable -# ^^^^^ entity.name.function.shell -# ^ - meta.variable - variable -# ^^^^^ entity.name.function.shell -# ^ - meta.variable - variable -# ^^^ entity.name.function.shell -# ^ - meta.variable - variable - ############################################################################### # 4.2 Bash Builtin Commands (unset) # From 94ca368bb7feb9e0a558511623230d8aef406983 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 23 Jun 2024 10:56:15 +0200 Subject: [PATCH 008/113] [ShellScript] Exclude linefeed from continuation punctuation --- ShellScript/Bash.sublime-syntax | 14 +++++++++----- ShellScript/test/syntax_test_bash.sh | 28 +++++++++++++++++++--------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 927b6f7b45..52380360c4 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -1585,15 +1585,19 @@ contexts: ###[ OPERATORS ]############################################################### line-continuations: - - match: \\\n - scope: punctuation.separator.continuation.line.shell - push: - - match: ^ - pop: 1 + - match: (\\)\n + captures: + 1: punctuation.separator.continuation.line.shell + push: line-continuation-body - match: \\(\s+)\n captures: 1: invalid.illegal.unexpected-whitespace.shell + line-continuation-body: + - meta_include_prototype: false + - match: ^ + pop: 1 + operators: - match: \|\||\&\&|\!(?!\S) scope: keyword.operator.logical.shell diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index 0ff8c7180f..009a8e1361 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -48,7 +48,8 @@ foo | `# get quarks ` \ # ^ punctuation.section.interpolation.begin.shell # ^^^^^^^^^^^^^ comment.line.number-sign.shell # ^ punctuation.section.interpolation.end.shell - comment -# ^^ punctuation.separator.continuation.line.shell - comment +# ^ punctuation.separator.continuation.line.shell - comment +# ^ - punctuation - comment foo | ` # get quarks ` \ bar ` # important; this and that ` "${USELESS_TEXT}" | ` # match text` \ @@ -68,7 +69,8 @@ bar ` # important; this and that ` "${USELESS_TEXT}" | ` # match text` \ # ^ meta.string.shell string.quoted.double.shell punctuation.definition.string.end.shell # ^ keyword.operator.assignment.pipe.shell # ^ punctuation.section.interpolation.begin.shell -# ^^ punctuation.separator.continuation.line.shell +# ^ punctuation.separator.continuation.line.shell +# ^ - punctuation - comment # https://github.com/sublimehq/Packages/issues/3661 @@ -112,7 +114,9 @@ echo hello, \ # <- meta.function-call.identifier.shell support.function.echo.shell #^^^ meta.function-call.identifier.shell support.function.echo.shell # ^^^^^^^^^^ meta.function-call.arguments.shell -# ^^ punctuation.separator.continuation.line.shell +# ^ punctuation.separator.continuation.line.shell +# ^ - punctuation + world! # <- meta.function-call.identifier.shell variable.function.shell #^^^^^ meta.function-call.identifier.shell variable.function.shell @@ -231,7 +235,8 @@ echo $"Hello echo $"Hello \ # ^^^^^^^^^^ meta.string.shell string.quoted.double.locale.shell # ^^ punctuation.definition.string.begin.shell -# ^^ punctuation.separator.continuation.line.shell +# ^ punctuation.separator.continuation.line.shell +# ^ - punctuation World\\" #^^^^^^^^^ meta.string.shell string.quoted.double.locale.shell # ^^ constant.character.escape.shell @@ -8879,13 +8884,15 @@ exec "$cmd" \ # ^ meta.function-call.arguments.shell # ^^^^^^ meta.function-call.identifier.shell meta.string.shell # ^^^ meta.function-call.arguments.shell -# ^^ punctuation.separator.continuation.line.shell +# ^ punctuation.separator.continuation.line.shell +# ^ - punctuation exec "$cmd" \ $opts \ #^^^^^^^^^ meta.function-call.arguments.shell # ^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell -# ^^ punctuation.separator.continuation.line.shell +# ^ punctuation.separator.continuation.line.shell +# ^ - punctuation exec "$cmd" \ $opts \ @@ -8898,7 +8905,8 @@ exec \ #^^^^^^^^^^^^ meta.function-call.arguments.shell # ^^^ meta.parameter.option.shell variable.parameter.option.shell # ^^^^ meta.string.shell string.unquoted.shell -# ^^ punctuation.separator.continuation.line.shell +# ^ punctuation.separator.continuation.line.shell +# ^ - punctuation exec \ -la name \ @@ -8906,7 +8914,8 @@ exec \ #^ meta.function-call.arguments.shell # ^^^^^^ meta.function-call.identifier.shell meta.string.shell # ^^^ meta.function-call.arguments.shell -# ^^ punctuation.separator.continuation.line.shell +# ^ punctuation.separator.continuation.line.shell +# ^ - punctuation exec \ -la name \ @@ -8914,7 +8923,8 @@ exec \ $opts \ #^^^^^^^^^ meta.function-call.arguments.shell # ^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell -# ^^ punctuation.separator.continuation.line.shell +# ^ punctuation.separator.continuation.line.shell +# ^ - punctuation exec \ -la name \ From cb84818e1f435afc27d70de93302af5356bae9f7 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Wed, 8 May 2024 19:19:59 +0200 Subject: [PATCH 009/113] [ShellScript] Replace various anonymous contexts in Bash This commit makes it easier to extend contexts in inherited syntax definitions. --- ShellScript/Bash.sublime-syntax | 92 +++++++++++++++++++-------------- 1 file changed, 54 insertions(+), 38 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 52380360c4..4cc8014165 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -220,6 +220,7 @@ contexts: - def-functions-params def-anonymous-body: + - meta_include_prototype: false - include: def-function-body-braces - include: line-continuations - include: comments @@ -244,6 +245,7 @@ contexts: - def-functions-name def-functions-name: + - meta_include_prototype: false - match: '{{cmd_begin}}' set: def-functions-name-chars - include: else-pop @@ -258,6 +260,7 @@ contexts: def-functions-params: - clear_scopes: 1 + - meta_include_prototype: false - meta_content_scope: meta.function.identifier.shell - match: (\()\s*(\)) scope: meta.function.parameters.shell @@ -270,6 +273,7 @@ contexts: - include: else-pop def-functions-body: + - meta_include_prototype: false - include: def-function-body-braces - include: def-function-body-parens - include: line-continuations @@ -279,22 +283,26 @@ contexts: def-function-body-braces: - match: \{ # Bash expects `{{cmd_break}}` but we don't care. scope: punctuation.section.compound.begin.shell - set: - - meta_scope: meta.compound.shell - - match: \} - scope: punctuation.section.compound.end.shell - pop: 1 - - include: statements + set: def-function-body-braces-body + + def-function-body-braces-body: + - meta_scope: meta.compound.shell + - match: \} + scope: punctuation.section.compound.end.shell + pop: 1 + - include: statements def-function-body-parens: - match: \( scope: punctuation.section.compound.begin.shell - set: - - meta_scope: meta.compound.shell - - match: \) - scope: punctuation.section.compound.end.shell - pop: 1 - - include: statements + set: def-function-body-parens-body + + def-function-body-parens-body: + - meta_scope: meta.compound.shell + - match: \) + scope: punctuation.section.compound.end.shell + pop: 1 + - include: statements def-functions-redirection: - meta_scope: meta.function.shell @@ -944,22 +952,26 @@ contexts: ###[ COMMANDS ]################################################################ cmd-compound: - - match: \( - scope: punctuation.section.compound.begin.shell - push: - - meta_scope: meta.compound.shell - - match: \) - scope: punctuation.section.compound.end.shell - set: cmd-compound-args - - include: statements - match: \{{{cmd_break}} scope: punctuation.section.compound.begin.shell - push: - - meta_scope: meta.compound.shell - - match: \} - scope: punctuation.section.compound.end.shell - set: cmd-compound-args - - include: statements + push: cmd-compound-braces-body + - match: \( + scope: punctuation.section.compound.begin.shell + push: cmd-compound-parens-body + + cmd-compound-braces-body: + - meta_scope: meta.compound.shell + - match: \} + scope: punctuation.section.compound.end.shell + set: cmd-compound-args + - include: statements + + cmd-compound-parens-body: + - meta_scope: meta.compound.shell + - match: \) + scope: punctuation.section.compound.end.shell + set: cmd-compound-args + - include: statements cmd-compound-args: - meta_content_scope: meta.compound.arguments.shell @@ -1473,12 +1485,7 @@ contexts: expressions: - match: \( scope: punctuation.section.group.begin.shell - push: - - meta_scope: meta.group.shell - - match: \) - scope: punctuation.section.group.end.shell - pop: 1 - - include: expressions + push: expression-group-body # multi char operators - match: '[-+*/%&|^]=|<<=|>>=' scope: keyword.operator.assignment.augmented.shell @@ -1512,6 +1519,13 @@ contexts: - include: variables - include: line-continuations + expression-group-body: + - meta_scope: meta.group.shell + - match: \) + scope: punctuation.section.group.end.shell + pop: 1 + - include: expressions + ###[ CONSTANTS ]############################################################### booleans: @@ -1692,12 +1706,14 @@ contexts: captures: 1: punctuation.definition.variable.shell 2: punctuation.section.interpolation.begin.shell - push: - - meta_scope: meta.interpolation.arithmetic.shell - - match: \)\) - scope: punctuation.section.interpolation.end.shell - pop: 1 - - include: expressions + push: arithmetic-expansion-parens-body + + arithmetic-expansion-parens-body: + - meta_scope: meta.interpolation.arithmetic.shell + - match: \)\) + scope: punctuation.section.interpolation.end.shell + pop: 1 + - include: expressions ###[ BRACE EXPANSIONS ]######################################################## From 0b44a93ed273ddc0269a998400295375ccf127fa Mon Sep 17 00:00:00 2001 From: deathaxe Date: Wed, 8 May 2024 19:46:03 +0200 Subject: [PATCH 010/113] [ShellScript] Scope function body meta.block This commit scopes function bodies with a commonly used meta scope in favor of Bash's "compound" command as preparation for other shells, which follow closer to other programming languages. It removes redirections from context stack as those are handled globally. --- ShellScript/Bash.sublime-syntax | 27 ++++---- ShellScript/test/syntax_test_bash.sh | 94 ++++++++++++++-------------- 2 files changed, 59 insertions(+), 62 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 4cc8014165..e922151a29 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -215,12 +215,12 @@ contexts: def-anonymous: - match: (?=\(\s*\)) push: - - def-functions-redirection - def-anonymous-body - def-functions-params def-anonymous-body: - meta_include_prototype: false + - meta_scope: meta.function.shell - include: def-function-body-braces - include: line-continuations - include: comments @@ -230,7 +230,6 @@ contexts: # [Bash] 3.3 Shell Functions - match: (?={{cmd_literal}}\s*\(\s*\)) push: - - def-functions-redirection - def-functions-body - def-functions-params - def-functions-name @@ -239,7 +238,6 @@ contexts: meta.function.shell keyword.declaration.function.shell push: - - def-functions-redirection - def-functions-body - def-functions-params - def-functions-name @@ -274,6 +272,7 @@ contexts: def-functions-body: - meta_include_prototype: false + - meta_scope: meta.function.shell - include: def-function-body-braces - include: def-function-body-parens - include: line-continuations @@ -282,34 +281,32 @@ contexts: def-function-body-braces: - match: \{ # Bash expects `{{cmd_break}}` but we don't care. - scope: punctuation.section.compound.begin.shell + scope: meta.block.shell punctuation.section.block.begin.shell set: def-function-body-braces-body def-function-body-braces-body: - - meta_scope: meta.compound.shell + - meta_content_scope: meta.function.shell meta.block.shell - match: \} - scope: punctuation.section.compound.end.shell + scope: + meta.function.shell meta.block.shell + punctuation.section.block.end.shell pop: 1 - include: statements def-function-body-parens: - match: \( - scope: punctuation.section.compound.begin.shell + scope: meta.block.shell punctuation.section.block.begin.shell set: def-function-body-parens-body def-function-body-parens-body: - - meta_scope: meta.compound.shell + - meta_content_scope: meta.function.shell meta.block.shell - match: \) - scope: punctuation.section.compound.end.shell + scope: + meta.function.shell meta.block.shell + punctuation.section.block.end.shell pop: 1 - include: statements - def-functions-redirection: - - meta_scope: meta.function.shell - - include: redirections - - include: else-pop - - include: eol-pop - ###[ VARIABLE DEFINITIONS ]#################################################### def-variables: diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index 009a8e1361..0d14d59fa7 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -1902,7 +1902,7 @@ case $TERM in sun-cmd) # ^ keyword.control.conditional.patterns.end.shell update_terminal_cwd() { print -Pn "\e]l%~\e\\" };; - # ^ meta.function punctuation.section.compound.end.shell + # ^ meta.function punctuation.section.block.end.shell # ^^ punctuation.terminator.case.clause.shell *xterm*|rxvt|(dt|k|E)term) # ^ constant.other.wildcard.asterisk.shell @@ -1914,13 +1914,13 @@ case $TERM in # ^ punctuation.definition.group.end.regexp.shell # ^ keyword.control.conditional.patterns.end.shell update_terminal_cwd() { print -Pn "\e]2;%~\a" };; - # ^ meta.function punctuation.section.compound.end.shell + # ^ meta.function punctuation.section.block.end.shell # ^^ punctuation.terminator.case.clause.shell *) # <- constant.other.wildcard.asterisk.shell #^ keyword.control.conditional.patterns.end.shell update_terminal_cwd() {};; - # ^ meta.function punctuation.section.compound.end.shell + # ^ meta.function punctuation.section.block.end.shell # ^^ punctuation.terminator.case.clause.shell esac # <- keyword.control.conditional.end.shell @@ -2214,19 +2214,19 @@ coproc foobar { () {} -# ^ meta.function.shell - meta.compound -# ^^ meta.function.shell meta.compound.shell +# ^ meta.function.shell - meta.block +# ^^ meta.function.shell meta.block.shell # ^ - meta.function -# ^ punctuation.section.compound.begin.shell -# ^ punctuation.section.compound.end.shell +# ^ punctuation.section.block.begin.shell +# ^ punctuation.section.block.end.shell () \ {} -# ^ meta.function.shell - meta.compound -# ^^ meta.function.shell meta.compound.shell +# ^ meta.function.shell - meta.block +# ^^ meta.function.shell meta.block.shell # ^ - meta.function -# ^ punctuation.section.compound.begin.shell -# ^ punctuation.section.compound.end.shell +# ^ punctuation.section.block.begin.shell +# ^ punctuation.section.block.end.shell () { [[ $# == 2 ]] && tput setaf $2 || tput setaf 3; echo -e "$1"; tput setaf 15; } #^^ source.shell - meta.function @@ -2234,11 +2234,11 @@ coproc foobar { # ^ meta.function.parameters.shell # ^ meta.function.parameters.shell # ^ meta.function.shell - meta.function.identifier - meta.compound -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.shell meta.compound.shell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.shell meta.block.shell # ^ punctuation.section.parameters.begin.shell # ^ punctuation.section.parameters.end.shell # ^ - punctuation -# ^ punctuation.section.compound.begin.shell +# ^ punctuation.section.block.begin.shell # ^^ support.function.test.begin # ^ punctuation.definition.variable # ^ variable.language @@ -2254,14 +2254,14 @@ coproc foobar { # ^ meta.function.parameters.shell # ^ meta.function.parameters.shell # ^ meta.function.shell - meta.function.identifier - meta.compound -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.shell meta.compound.shell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.shell meta.block.shell #^^ - entity # ^^^^ entity.name.function.shell # ^ - entity - punctuation # ^ punctuation.section.parameters.begin.shell # ^ punctuation.section.parameters.end.shell # ^ - punctuation -# ^ punctuation.section.compound.begin.shell +# ^ punctuation.section.block.begin.shell # ^^ support.function.test.begin.shell # ^ punctuation.definition.variable.shell # ^^ variable.language.shell @@ -2275,13 +2275,13 @@ logExit ( ) { #^^^^^^ meta.function.identifier.shell entity.name.function.shell # ^ meta.function.identifier.shell # ^^^ meta.function.parameters.shell -# ^ meta.function.shell - meta.compound -# ^^ meta.function.shell meta.compound.shell +# ^ meta.function.shell - meta.block +# ^^ meta.function.shell meta.block.shell #^^^^^^ entity.name.function.shell # ^ - entity - punctuation # ^ punctuation.section.parameters.begin.shell # ^ punctuation.section.parameters.end.shell -# ^ punctuation.section.compound.begin.shell +# ^ punctuation.section.block.begin.shell [[ $1 == '0' ]] && tput setaf 2 || tput setaf 1; #<- meta.conditional.shell support.function.test.begin.shell #^ meta.conditional.shell support.function.test.begin.shell @@ -2304,7 +2304,7 @@ logExit ( ) { # ^ keyword.operator.arithmetic.shell # ^ meta.number.integer.decimal.shell constant.numeric.value.shell } -# <- meta.function.shell meta.compound.shell punctuation.section.compound.end.shell +# <- meta.function.shell meta.block.shell punctuation.section.block.end.shell #^ - meta.function logExit $? $WEIRD @@ -2327,9 +2327,9 @@ function foo # ^^^ entity.name.function.shell # ^ - entity { -# <- meta.function.shell meta.compound.shell punctuation.section.compound.begin.shell +# <- meta.function.shell meta.block.shell punctuation.section.block.begin.shell foo bar - # <- meta.function.shell meta.compound.shell meta.function-call.identifier.shell + # <- meta.function.shell meta.block.shell meta.function-call.identifier.shell # <- variable.function.shell return 0 @@ -2337,7 +2337,7 @@ function foo #^^^^^ keyword.control.flow.return.shell # ^ meta.number.integer.decimal.shell constant.numeric.value.shell } -# <- meta.function.shell meta.compound.shell punctuation.section.compound.end.shell +# <- meta.function.shell meta.block.shell punctuation.section.block.end.shell #^ - meta.function # <- - meta.function @@ -2358,12 +2358,12 @@ function foo ( ) { # ^ - entity.name.function # ^ punctuation.section.parameters.begin.shell # ^ punctuation.section.parameters.end.shell -# ^ punctuation.section.compound.begin.shell +# ^ punctuation.section.block.begin.shell echo 'hello from foo' - # <- meta.function.shell meta.compound.shell meta.function-call.identifier.shell + # <- meta.function.shell meta.block.shell meta.function-call.identifier.shell # <- support.function.echo.shell } -# <- meta.function.shell meta.compound.shell punctuation.section.compound.end.shell +# <- meta.function.shell meta.block.shell punctuation.section.block.end.shell #^ - meta.function # <- - meta.function @@ -2372,27 +2372,27 @@ f () ( # <- meta.function.identifier.shell entity.name.function.shell #^ meta.function.identifier.shell - entity - punctuation # ^^ meta.function.parameters.shell -# ^ meta.function.shell - meta.compound -# ^ meta.function.shell meta.compound.shell punctuation.section.compound.begin.shell +# ^ meta.function.shell - meta.block +# ^ meta.function.shell meta.block.shell punctuation.section.block.begin.shell echo hello - # <- meta.function.shell meta.compound.shell meta.function-call.identifier.shell + # <- meta.function.shell meta.block.shell meta.function-call.identifier.shell # <- support.function.echo.shell ) -# <- meta.function.shell meta.compound.shell punctuation.section.compound.end.shell +# <- meta.function.shell meta.block.shell punctuation.section.block.end.shell #^ - meta.function function f ( # <- meta.function.shell keyword.declaration.function.shell #^^^^^^^ meta.function.shell # ^^^ meta.function.identifier.shell -# ^^ meta.function.shell meta.compound.shell +# ^^ meta.function.shell meta.block.shell #^^^^^^^ keyword.declaration.function.shell # ^ entity.name.function.shell -# ^ punctuation.section.compound.begin.shell +# ^ punctuation.section.block.begin.shell echo hello # <- meta.function meta.function-call support.function.echo ) -# <- meta.function.shell meta.compound.shell punctuation.section.compound.end.shell +# <- meta.function.shell meta.block.shell punctuation.section.block.end.shell #^ - meta.function function foo { @@ -2476,7 +2476,7 @@ function 7zip { # ^^^^^^ meta.function.identifier.shell # ^^^^ entity.name.function.shell } -# <- meta.function.shell meta.compound.shell punctuation.section.compound.end.shell +# <- meta.function.shell meta.block.shell punctuation.section.block.end.shell 7zip # <- meta.function-call.identifier.shell variable.function.shell #^^^ meta.function-call.identifier.shell variable.function.shell @@ -2491,10 +2491,10 @@ function [] () { # ^^ entity.name.function.shell # ^ punctuation.section.parameters.begin.shell # ^ punctuation.section.parameters.end.shell -# ^ meta.compound.shell punctuation.section.compound.begin.shell +# ^ meta.block.shell punctuation.section.block.begin.shell echo "Hello from []" } -# <- meta.function.shell meta.compound.shell punctuation.section.compound.end.shell +# <- meta.function.shell meta.block.shell punctuation.section.block.end.shell [] # <- meta.function-call.identifier.shell variable.function.shell #^ meta.function-call.identifier.shell variable.function.shell @@ -2509,7 +2509,7 @@ function [[]] () { # ^^^^ entity.name.function.shell # ^ punctuation.section.parameters.begin.shell # ^ punctuation.section.parameters.end.shell -# ^ meta.compound.shell punctuation.section.compound.begin.shell +# ^ meta.block.shell punctuation.section.block.begin.shell echo "Hello from [[]]" } [[]] @@ -2526,7 +2526,7 @@ function {} () { # ^^ entity.name.function.shell # ^ punctuation.section.parameters.begin.shell # ^ punctuation.section.parameters.end.shell -# ^ meta.compound.shell punctuation.section.compound.begin.shell +# ^ meta.block.shell punctuation.section.block.begin.shell echo "Hello from {}" } {} @@ -2543,7 +2543,7 @@ function {{}} () { # ^^^^ entity.name.function.shell # ^ punctuation.section.parameters.begin.shell # ^ punctuation.section.parameters.end.shell -# ^ meta.compound.shell punctuation.section.compound.begin.shell +# ^ meta.block.shell punctuation.section.block.begin.shell echo "Hello from {{}}" } {{}} @@ -2560,7 +2560,7 @@ function -foo () { # ^^^^ entity.name.function.shell # ^ punctuation.section.parameters.begin.shell # ^ punctuation.section.parameters.end.shell -# ^ meta.compound.shell punctuation.section.compound.begin.shell +# ^ meta.block.shell punctuation.section.block.begin.shell echo "Hello from -foo" } -foo @@ -2577,7 +2577,7 @@ function +foo () { # ^^^^ entity.name.function.shell # ^ punctuation.section.parameters.begin.shell # ^ punctuation.section.parameters.end.shell -# ^ meta.compound.shell punctuation.section.compound.begin.shell +# ^ meta.block.shell punctuation.section.block.begin.shell echo "Hello from +foo" } +foo @@ -2594,7 +2594,7 @@ function =foo () { # ^^^^ entity.name.function.shell # ^ punctuation.section.parameters.begin.shell # ^ punctuation.section.parameters.end.shell -# ^ meta.compound.shell punctuation.section.compound.begin.shell +# ^ meta.block.shell punctuation.section.block.begin.shell echo "Hello from =foo" } =foo @@ -2617,7 +2617,7 @@ function true () {} ; function false () {} # ^^^^^^ meta.function.identifier.shell # ^^ meta.function.parameters.shell # ^^^ meta.function.shell -# ^^ - meta.function +# ^^^ - meta.function # ^^^^^^^^ meta.function.shell # ^^^^^^^ meta.function.identifier.shell # ^^ meta.function.parameters.shell @@ -2641,7 +2641,7 @@ __git_aliased_command () esac done } -# <- meta.function.shell meta.compound.shell punctuation.section.compound.end.shell +# <- meta.function.shell meta.block.shell punctuation.section.block.end.shell #^ - meta.function # <- - meta.function @@ -9167,7 +9167,7 @@ f() { local "$x"'+=(4)' # <- keyword.declaration.variable.shell esac - # <- meta.function.shell meta.compound.shell meta.conditional.case.shell + # <- meta.function.shell meta.block.shell meta.conditional.case.shell # <- keyword.control.conditional.end.shell IFS=, local -a "$x"'=("${x}: ${'"$x"'[*]}")' @@ -9176,10 +9176,10 @@ f() { # ^ meta.string.shell string.unquoted.shell # ^ keyword.declaration.variable.shell done - # <- meta.function.shell meta.compound.shell + # <- meta.function.shell meta.block.shell # <- keyword.control.loop.end.shell } -# <- meta.function.shell meta.compound.shell punctuation.section.compound.end.shell +# <- meta.function.shell meta.block.shell punctuation.section.block.end.shell ############################################################################### @@ -10181,7 +10181,7 @@ function clk { esac # <- meta.function keyword.control.conditional.end.shell } -# <- punctuation.section.compound.end.shell +# <- punctuation.section.block.end.shell if [ "$*" = '*' ] then remotefilter="cat" From fabf29212797fa1f026110d396976da5450fed24 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 11 May 2024 10:01:27 +0200 Subject: [PATCH 011/113] [ShellScript] Refactor case statement contexts This commit applies required changes to support ZSH case statements, which may use curly braced code blocks as in C, which didn't work well with previous meta scope structure. --- ShellScript/Bash.sublime-syntax | 28 ++++++++------- ShellScript/test/syntax_test_bash.sh | 51 ++++++++++++++-------------- 2 files changed, 40 insertions(+), 39 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index e922151a29..eca7a88526 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -1113,7 +1113,7 @@ contexts: scope: keyword.control.conditional.else.shell - match: case{{cmd_break}} scope: keyword.control.conditional.case.shell - push: [case-body, case-word] + push: [case-meta, case-word] - match: esac{{cmd_break}} scope: keyword.control.conditional.end.shell # loops @@ -1145,20 +1145,27 @@ contexts: scope: keyword.control.flow.return.shell push: flow-args + case-meta: + - meta_include_prototype: false + - meta_scope: meta.conditional.case.shell + - include: immediately-pop + + case-end: + - match: esac{{cmd_break}} + scope: keyword.control.conditional.end.shell + pop: 1 + case-word: - match: in{{cmd_break}} scope: keyword.control.in.shell - pop: 1 + set: case-body + - include: case-end - include: comments - - include: case-end-ahead - include: expansions-and-strings case-body: - - meta_scope: meta.conditional.case.shell + - include: case-end - include: comments - - match: esac{{cmd_break}} - scope: keyword.control.conditional.end.shell - pop: 1 - match: \(|(?=\S) scope: keyword.control.conditional.patterns.begin.shell push: @@ -1166,10 +1173,7 @@ contexts: - case-clause-patterns case-clause-patterns: - - clear_scopes: 1 # remove meta.conditional.case.shell - - meta_scope: - meta.conditional.case.clause.patterns.shell - meta.string.regexp.shell + - meta_scope: meta.patterns.shell meta.string.regexp.shell - match: \) scope: keyword.control.conditional.patterns.end.shell pop: 1 @@ -1193,8 +1197,6 @@ contexts: - include: case-clause-pattern-content case-clause-commands: - - clear_scopes: 1 # remove meta.conditional.case.shell - - meta_scope: meta.conditional.case.clause.commands.shell - match: ;;&?|;& scope: punctuation.terminator.case.clause.shell pop: 1 diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index 0d14d59fa7..a55f21a467 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -1777,8 +1777,8 @@ esac case var in ( patt ( esac #^ meta.conditional.case.shell -# ^^^^^^^ meta.conditional.case.clause.patterns.shell - meta.group -# ^^ meta.conditional.case.clause.patterns.shell meta.group.regexp.shell +# ^^^^^^^ meta.patterns.shell - meta.group +# ^^ meta.patterns.shell meta.group.regexp.shell # ^^^^ meta.conditional.case.shell # ^ keyword.control.conditional.patterns.begin.shell # ^ punctuation.definition.group.begin.regexp.shell @@ -1799,8 +1799,8 @@ case # comment # ^^^^^^^^^^ comment.line.number-sign.shell pattern) # comment #^ meta.conditional.case.shell -# ^^^^^^^^ meta.conditional.case.clause.patterns.shell -# ^^^^^^^^^^^ meta.conditional.case.clause.commands.shell +# ^^^^^^^^ meta.conditional.case.shell meta.patterns.shell +# ^^^^^^^^^^^ meta.conditional.case.shell - meta.patterns # ^^^^^^^^^^ comment.line.number-sign.shell esac # <- meta.conditional.case.shell keyword.control.conditional.end.shell @@ -1868,35 +1868,34 @@ case "${foo}" in- in_ in=10 in # ^^ - keyword.control.in # ^^ keyword.control.in ( help | h ) bar ;; -#^^^ meta.conditional.case.shell - meta.conditional.case.clause.patterns - meta.conditional.case.clause.commands -# ^^^^^^^^^^^^ meta.conditional.case.clause.patterns.shell - meta.conditional.case.clause.commands - meta.conditional.case.shell -# ^^^^^^^ meta.conditional.case.clause.commands.shell - meta.conditional.case.clause.patterns - meta.conditional.case.shell -# ^ meta.conditional.case.shell - meta.conditional.case.clause.patterns - meta.conditional.case.clause.commands +#^^^ meta.conditional.case.shell - meta.patterns +# ^^^^^^^^^^^^ meta.conditional.case.shell meta.patterns.shell +# ^^^^^^^^ meta.conditional.case.shell - meta.patterns # <- keyword.control.conditional.patterns.begin.shell # ^ keyword.control.conditional.patterns.end.shell # ^^ punctuation.terminator.case.clause.shell do1 ) foo1 ;& -#^^^ meta.conditional.case.shell - meta.conditional.case.clause.patterns - meta.conditional.case.clause.commands -# ^^^^^ meta.conditional.case.clause.patterns.shell - meta.conditional.case.clause.commands - meta.conditional.case.shell -# ^^^^^^^^ meta.conditional.case.clause.commands.shell - meta.conditional.case.clause.patterns - meta.conditional.case.shell -# ^ meta.conditional.case.shell - meta.conditional.case.clause.patterns - meta.conditional.case.clause.commands +#^^^ meta.conditional.case.shell - meta.patterns +# ^^^^^ meta.conditional.case.shell meta.patterns.shell +# ^^^^^^^^^ meta.conditional.case.shell - meta.patterns # ^ keyword.control.conditional.patterns.end.shell # ^^ punctuation.terminator.case.clause.shell (do2 ) foo2 ;;& -#^^^ meta.conditional.case.shell - meta.conditional.case.clause.patterns - meta.conditional.case.clause.commands -# ^^^^^^ meta.conditional.case.clause.patterns.shell - meta.conditional.case.clause.commands - meta.conditional.case.shell -# ^^^^^^^^^ meta.conditional.case.clause.commands.shell - meta.conditional.case.clause.patterns - meta.conditional.case.shell -# ^ meta.conditional.case.shell - meta.conditional.case.clause.patterns - meta.conditional.case.clause.commands +#^^^ meta.conditional.case.shell - meta.patterns +# ^^^^^^ meta.conditional.case.shell meta.patterns.shell +# ^^^^^^^^^^ meta.conditional.case.shell - meta.patterns # <- keyword.control.conditional.patterns.begin.shell # ^ keyword.control.conditional.patterns.end.shell # ^^^ punctuation.terminator.case.clause.shell *) bar -#^^^ meta.conditional.case.shell - meta.conditional.case.clause.patterns - meta.conditional.case.clause.commands -# ^^ meta.conditional.case.clause.patterns.shell - meta.conditional.case.clause.commands - meta.conditional.case.shell -# ^^^^^ meta.conditional.case.clause.commands.shell - meta.conditional.case.clause.patterns - meta.conditional.case.shell +#^^^ meta.conditional.case.shell - meta.patterns +# ^^ meta.conditional.case.shell meta.patterns.shell +# ^^^^^ meta.conditional.case.shell - meta.patterns #^ keyword.control.conditional.patterns.end.shell esac -# <- keyword.control.conditional.end.shell +# <- meta.conditional.case.shell keyword.control.conditional.end.shell +#^^^ meta.conditional.case.shell keyword.control.conditional.end.shell +# ^ - meta.conditional - keyword case $TERM in sun-cmd) @@ -1928,9 +1927,9 @@ esac case $SERVER in # <- keyword.control.conditional.case.shell ws-+([0-9]).host.com) echo "Web Server" -#^^^ meta.conditional.case.clause.patterns.shell meta.string.regexp.shell - meta.group -# ^^^^^^^ meta.conditional.case.clause.patterns.shell meta.string.regexp.shell meta.group.regexp.shell -# ^^^^^^^^^^ meta.conditional.case.clause.patterns.shell meta.string.regexp.shell - meta.group +#^^^ meta.patterns.shell meta.string.regexp.shell - meta.group +# ^^^^^^^ meta.patterns.shell meta.string.regexp.shell meta.group.regexp.shell +# ^^^^^^^^^^ meta.patterns.shell meta.string.regexp.shell - meta.group # ^ keyword.operator.quantifier.regexp.shell # ^ punctuation.definition.group.begin.regexp.shell # ^ punctuation.definition.set.begin.regexp.shell @@ -1943,9 +1942,9 @@ ws-+([0-9]).host.com) echo "Web Server" # <- punctuation.terminator.case.clause.shell #^ punctuation.terminator.case.clause.shell db-+([0-9])\.host\.com) echo "DB server" -#^^^ meta.conditional.case.clause.patterns.shell meta.string.regexp.shell - meta.group -# ^^^^^^^ meta.conditional.case.clause.patterns.shell meta.string.regexp.shell meta.group.regexp.shell -# ^^^^^^^^^^^ meta.conditional.case.clause.patterns.shell meta.string.regexp.shell - meta.group +#^^^ meta.patterns.shell meta.string.regexp.shell - meta.group +# ^^^^^^^ meta.patterns.shell meta.string.regexp.shell meta.group.regexp.shell +# ^^^^^^^^^^^ meta.patterns.shell meta.string.regexp.shell - meta.group # ^ keyword.operator.quantifier.regexp.shell # ^ punctuation.definition.group.begin.regexp.shell # ^ punctuation.definition.set.begin.regexp.shell From 055a76b8882b3683e330d53bdc169a092f1b70ff Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 14 Jul 2024 18:27:32 +0200 Subject: [PATCH 012/113] [ShellScript] Add paths patterns --- ShellScript/Bash.sublime-syntax | 212 ++++++++++++++++++++++++--- ShellScript/test/syntax_test_bash.sh | 165 +++++++++++++++------ 2 files changed, 311 insertions(+), 66 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index eca7a88526..15d50b197d 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -361,13 +361,14 @@ contexts: - include: immediately-pop variable-value: + - meta_include_prototype: false - match: \( scope: punctuation.section.sequence.begin.shell set: variable-value-list-body - include: line-continuations - include: boolean - include: number - - include: string-unquoted + - include: string-path-pattern - include: immediately-pop variable-value-list-body: @@ -983,18 +984,41 @@ contexts: scope: punctuation.definition.history.shell cmd-basic: - # basic user defined or external commands + - match: \$?\" + scope: punctuation.definition.quoted.begin.shell + push: + - cmd-name + - path-pattern-double-quoted-body + - path-pattern-quoted-begin + - match: \$\' + scope: punctuation.definition.quoted.begin.shell + push: + - cmd-name + - path-pattern-ansi-c-body + - path-pattern-quoted-begin + - match: \' + scope: punctuation.definition.quoted.begin.shell + push: + - cmd-name + - path-pattern-single-quoted-body + - path-pattern-quoted-begin - match: '{{cmd_begin}}' - push: [cmd-args, cmd-basic-name, maybe-tilde-expansion] + push: + - cmd-name + - path-pattern-unquoted-begin - cmd-basic-name: - - clear_scopes: 1 - - meta_scope: meta.function-call.identifier.shell - - match: '{{cmd_literal_char}}+' - scope: variable.function.shell - - include: variable-function-expansions + cmd-name: + - meta_scope: meta.function-call.identifier.shell meta.path.shell variable.function.shell + - match: '{{cmd_break}}' + set: cmd-args + - include: line-continuations + - include: any-escapes + - include: brace-interpolations + - include: string-interpolations - include: expansions-job - - include: immediately-pop + - include: expansions-patterns + - include: path-pattern-quotes + - include: path-pattern-separators cmd-args: - meta_content_scope: meta.function-call.arguments.shell @@ -1272,7 +1296,9 @@ contexts: meta.number.integer.decimal.shell constant.numeric.value.shell 2: keyword.operator.assignment.redirection.shell - push: redirection-descriptor + push: + - redirection-meta + - redirection-descriptor redirections-input: - match: (\d*)(<&?) @@ -1281,7 +1307,9 @@ contexts: meta.number.integer.decimal.shell constant.numeric.value.shell 2: keyword.operator.assignment.redirection.shell - push: redirection-descriptor + push: + - redirection-meta + - redirection-descriptor redirections-inout: - match: (\d*)(<>) @@ -1290,12 +1318,17 @@ contexts: meta.number.integer.decimal.shell constant.numeric.value.shell 2: keyword.operator.assignment.redirection.shell - push: redirection-descriptor + push: + - redirection-meta + - redirection-descriptor - redirection-descriptor: + redirection-meta: - meta_include_prototype: false - meta_scope: meta.redirection.shell - - include: eoc-pop + - include: immediately-pop + + redirection-descriptor: + - meta_include_prototype: false - match: (?:(\d+)(-?)|(-)){{cmd_break}} captures: 1: meta.file-descriptor.shell @@ -1304,14 +1337,8 @@ contexts: 2: punctuation.terminator.file-descriptor.shell 3: punctuation.terminator.file-descriptor.shell pop: 1 - - match: (?=\S) - set: - - redirection-path - - maybe-tilde-interpolation - - redirection-path: - - meta_scope: meta.redirection.shell meta.path.shell meta.string.shell string.unquoted.shell - - include: string-unquoted-body + - include: eoc-pop + - include: string-path-pattern redirections-here-string: - match: (\d*)(<<<)\s*{{nonposix_begin}} @@ -2229,6 +2256,145 @@ contexts: - match: (?=[/{{metachar}}]) pop: 2 +###[ PATH PATTERN MATCHING ]################################################### + + string-path-patterns: + - match: '{{nonposix_begin}}' + push: string-path-pattern + + string-path-pattern: + - meta_include_prototype: false + - match: \$?\" + scope: punctuation.definition.string.begin.shell + set: + - string-path-pattern-body + - string-path-pattern-double-quoted-body + - path-pattern-quoted-begin + - match: \$\' + scope: punctuation.definition.string.begin.shell + set: + - string-path-pattern-body + - string-path-pattern-ansi-c-body + - path-pattern-quoted-begin + - match: \' + scope: punctuation.definition.string.begin.shell + set: + - string-path-pattern-body + - string-path-pattern-single-quoted-body + - path-pattern-quoted-begin + - match: (?=\S) + set: + - string-path-pattern-body + - string-path-pattern-begin + + string-path-pattern-begin: + - meta_include_prototype: false + - include: tilde-interpolation + - include: path-pattern-quoted-begin + + string-path-pattern-body: + - meta_scope: meta.path.shell meta.string.shell string.unquoted.shell + - match: '{{cmd_break}}' + pop: 1 + - include: line-continuations + - include: string-prototype + - include: any-escapes + - include: brace-interpolations + - include: string-interpolations + - include: expansions-patterns + - include: string-path-pattern-quotes + - include: string-path-separators + - include: path-pattern-separators + + string-path-pattern-quotes: + - match: \" + scope: punctuation.definition.string.begin.shell + push: string-path-pattern-double-quoted-body + - match: \$' + scope: punctuation.definition.string.begin.shell + push: string-path-pattern-ansi-c-body + - match: \' + scope: punctuation.definition.string.begin.shell + push: string-path-pattern-single-quoted-body + + string-path-pattern-ansi-c-body: + - clear_scopes: 1 + - meta_scope: string.quoted.single.shell + - include: string-ansi-c-body + - include: string-path-separators + - include: path-pattern-separators + + string-path-pattern-double-quoted-body: + - clear_scopes: 1 + - meta_scope: string.quoted.double.shell + - include: string-quoted-double-body + - include: string-path-separators + - include: path-pattern-separators + + string-path-pattern-single-quoted-body: + - clear_scopes: 1 + - meta_scope: string.quoted.single.shell + - include: string-quoted-single-body + - include: string-path-separators + - include: path-pattern-separators + + path-pattern-quoted-begin: + - meta_include_prototype: false + - match: \.\.(?=/) + scope: constant.other.path.parent.shell + pop: 1 + - match: \.(?=/) + scope: constant.other.path.self.shell + pop: 1 + - include: line-continuations + - include: immediately-pop + + path-pattern-unquoted-begin: + - meta_include_prototype: false + - include: tilde-expansion + - include: path-pattern-quoted-begin + + path-pattern-quotes: + - match: \$?\" + scope: punctuation.definition.quoted.begin.shell + push: path-pattern-double-quoted-body + - match: \$' + scope: punctuation.definition.quoted.begin.shell + push: path-pattern-ansi-c-body + - match: \' + scope: punctuation.definition.quoted.begin.shell + push: path-pattern-single-quoted-body + + path-pattern-ansi-c-body: + - match: \' + scope: punctuation.definition.quoted.end.shell + pop: 1 + - include: line-continuations + - include: string-escapes-ansi-c + - include: path-pattern-separators + + path-pattern-double-quoted-body: + - match: \" + scope: punctuation.definition.quoted.end.shell + pop: 1 + - include: line-continuations + - include: string-escapes + - include: string-interpolations + - include: path-pattern-separators + + path-pattern-single-quoted-body: + - match: \' + scope: punctuation.definition.quoted.end.shell + pop: 1 + - include: path-pattern-separators + + path-pattern-separators: + - match: (/)(?:(?:(\.\.)|(\.))(?=/))? + captures: + 1: punctuation.separator.path.shell + 2: constant.other.path.parent.shell + 3: constant.other.path.self.shell + ###[ SHELL PATTERN MATCHING ]################################################## pattern-main-content: diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index a55f21a467..c40b313988 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -327,35 +327,35 @@ echo git rev-list "$(echo --all)" | grep -P 'c354a80' # ^^^^^^^^^ meta.string.shell string.quoted.single.shell ' echo ' -# <- meta.function-call.identifier.shell meta.string.shell -#^^^^^^^ meta.function-call.identifier.shell meta.string.shell -# <- variable.function.shell punctuation.definition.string.begin.shell +# <- meta.function-call.identifier.shell meta.path.shell +#^^^^^^^ meta.function-call.identifier.shell meta.path.shell +# <- variable.function.shell punctuation.definition.quoted.begin.shell #^^^^^^^ variable.function.shell -# ^ punctuation.definition.string.end.shell +# ^ punctuation.definition.quoted.end.shell # ^ - meta - variable e'cho'o -# <- meta.function-call.identifier.shell - meta.string -#^^^^^ meta.function-call.identifier.shell meta.string.shell -# ^ meta.function-call.identifier.shell - meta.string +# <- meta.function-call.identifier.shell +#^^^^^ meta.function-call.identifier.shell +# ^ meta.function-call.identifier.shell # <- variable.function.shell #^^^^^^ variable.function.shell # ^ - meta - variable e' cho'o -# <- meta.function-call.identifier.shell - meta.string -#^^^^^^ meta.function-call.identifier.shell meta.string.shell -# ^ meta.function-call.identifier.shell - meta.string +# <- meta.function-call.identifier.shell +#^^^^^^ meta.function-call.identifier.shell +# ^ meta.function-call.identifier.shell # <- variable.function.shell #^^^^^^^ variable.function.shell # ^ - meta - variable e"\" \t ${ch} "o -# <- meta.function-call.identifier.shell - meta.string - meta.interpolation -#^^^^^^^ meta.function-call.identifier.shell meta.string.shell - meta.interpolation -# ^^^^^ meta.function-call.identifier.shell meta.string.shell meta.interpolation.parameter.shell -# ^^ meta.function-call.identifier.shell meta.string.shell - meta.interpolation -# ^ meta.function-call.identifier.shell - meta.string - meta.interpolation +# <- meta.function-call.identifier.shell - meta.interpolation +#^^^^^^^ meta.function-call.identifier.shell - meta.interpolation +# ^^^^^ meta.function-call.identifier.shell meta.interpolation.parameter.shell +# ^^ meta.function-call.identifier.shell - meta.interpolation +# ^ meta.function-call.identifier.shell - meta.interpolation # <- variable.function.shell #^^^^^^^ variable.function.shell # ^^^^^ - variable.function @@ -368,7 +368,7 @@ ch=ch e${ch}"o" hello, world! # <- meta.function-call.identifier.shell variable.function.shell #^^^^^ meta.function-call.identifier.shell meta.interpolation.parameter.shell -# ^^^ meta.function-call.identifier.shell meta.string.shell - meta.interpolation +# ^^^ meta.function-call.identifier.shell - meta.interpolation # ^^^^^^^^^^^^^^ meta.function-call.arguments.shell #^^^^^ - variable.function # ^^^ variable.function.shell @@ -376,8 +376,8 @@ e${ch}"o" hello, world! # ^ punctuation.section.interpolation.begin.shell # ^^ variable.other.readwrite # ^ punctuation.section.interpolation.end.shell -# ^ punctuation.definition.string.begin.shell -# ^ punctuation.definition.string.end.shell +# ^ punctuation.definition.quoted.begin.shell +# ^ punctuation.definition.quoted.end.shell e=e ${e}'ch'o hello, world! # <- meta.function-call.identifier.shell - variable.function @@ -389,21 +389,82 @@ ${e}'ch'o hello, world! #^ punctuation.section.interpolation.begin.shell # ^ variable.other.readwrite.shell # ^ punctuation.section.interpolation.end.shell -# ^ punctuation.definition.string.begin.shell -# ^ punctuation.definition.string.end.shell +# ^ punctuation.definition.quoted.begin.shell +# ^ punctuation.definition.quoted.end.shell e=e $e'ch'o Hello, world! # <- meta.function-call.identifier.shell meta.interpolation.parameter.shell #^ meta.function-call.identifier.shell meta.interpolation.parameter.shell -# ^^^^ meta.function-call.identifier.shell meta.string.shell +# ^^^^ meta.function-call.identifier.shell # ^ meta.function-call.identifier.shell # ^^^^^^^^^^^^^^ meta.function-call.arguments.shell # <- variable.other.readwrite.shell punctuation.definition.variable.shell #^ variable.other.readwrite.shell # ^^^^^ variable.function.shell -# ^ punctuation.definition.string.begin.shell -# ^ punctuation.definition.string.end.shell +# ^ punctuation.definition.quoted.begin.shell +# ^ punctuation.definition.quoted.end.shell + +./~foo/../bar../baz.sh +# <- meta.function-call.identifier.shell meta.path.shell variable.function.shell constant.other.path.self.shell +#^^^^^^^^^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +#^ punctuation.separator.path.shell +# ^ - variable.language +# ^ punctuation.separator.path.shell +# ^^ constant.other.path.parent.shell +# ^ punctuation.separator.path.shell +# ^^ - constant.other.path - punctuation +# ^ punctuation.separator.path.shell + +"./~foo/../bar../baz.sh" +# <- meta.function-call.identifier.shell meta.path.shell variable.function.shell punctuation.definition.quoted.begin.shell +#^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +#^ constant.other.path.self.shell +# ^ punctuation.separator.path.shell +# ^ - variable.language +# ^ punctuation.separator.path.shell +# ^^ constant.other.path.parent.shell +# ^ punctuation.separator.path.shell +# ^^ - constant.other.path - punctuation +# ^ punctuation.separator.path.shell +# ^ punctuation.definition.quoted.end.shell + +"./"~foo"/../"bar"../"baz.sh +# <- meta.function-call.identifier.shell meta.path.shell variable.function.shell punctuation.definition.quoted.begin.shell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +#^ constant.other.path.self.shell +# ^ punctuation.separator.path.shell +# ^ punctuation.definition.quoted.end.shell +# ^ - variable.language +# ^ punctuation.definition.quoted.begin.shell +# ^ punctuation.separator.path.shell +# ^^ constant.other.path.parent.shell +# ^ punctuation.separator.path.shell +# ^ punctuation.definition.quoted.end.shell +# ^ punctuation.definition.quoted.begin.shell +# ^ punctuation.separator.path.shell +# ^ punctuation.definition.quoted.end.shell +../my?script[1-9].* +# <- meta.function-call.identifier.shell meta.path.shell variable.function.shell constant.other.path.parent.shell +#^^^^^^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +#^ constant.other.path.parent.shell +# ^ punctuation.separator.path.shell +# ^ constant.other.wildcard.questionmark.shell +# ^^^^^ meta.set.regexp.shell +# ^ punctuation.definition.set.begin.regexp.shell +# ^^^ constant.other.range.regexp.shell +# ^ punctuation.definition.set.end.regexp.shell +# ^ constant.other.wildcard.asterisk.shell + +"../my?script[1-9].*" # no pattern matching within quotes +# <- meta.function-call.identifier.shell meta.path.shell variable.function.shell punctuation.definition.quoted.begin.shell +#^^^^^^^^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +#^^ constant.other.path.parent.shell +# ^ punctuation.separator.path.shell +# ^ - constant +# ^^^^^ - meta.set.regexp - punctuation +# ^ - constant +# ^ punctuation.definition.quoted.end.shell ############################################################################### # 3.2 Shell Commands (Basic Command Arguments) # @@ -649,20 +710,12 @@ sleep 2 & jobs # ^ keyword.operator # ^^^^ meta.function-call.identifier.shell support.function.jobs.shell -subdir/./myscript.sh --option arg1 arg2 -x -# <- meta.function-call.identifier.shell variable.function.shell -#^^^^^^^^^^^^^^^^^^^ meta.function-call.identifier.shell variable.function.shell -# ^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell -# ^^^^^^^^ meta.parameter.option.shell variable.parameter.option.shell -# ^^^^^^^^^^^ - string -# ^^ meta.parameter.option.shell variable.parameter.option.shell -# ^ - meta.function-call - {foo} -o --option -- -o -# <- meta.function-call.identifier.shell variable.function.shell -#^^^^ meta.function-call.identifier.shell variable.function.shell +# <- meta.function-call.identifier.shell variable.function.shell - meta.interpolation +#^^^^ meta.function-call.identifier.shell - meta.interpolation # ^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell # ^ - meta.function-call +#^^^^ variable.function.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell # ^ - variable # ^^^^^^^^ meta.parameter.option.shell variable.parameter.option.shell @@ -672,8 +725,9 @@ subdir/./myscript.sh --option arg1 arg2 -x # ^^ - variable [foo] -o -# <- meta.function-call.identifier.shell variable.function.shell -#^^^^ meta.function-call.identifier.shell variable.function.shell +# <- meta.function-call.identifier.shell meta.path.shell variable.function.shell meta.set.regexp.shell punctuation.definition.set.begin.regexp.shell +#^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell meta.set.regexp.shell - punctuation +# ^ meta.function-call.identifier.shell meta.path.shell variable.function.shell meta.set.regexp.shell punctuation.definition.set.end.regexp.shell # ^^^ meta.function-call.arguments.shell $foo -o @@ -2449,8 +2503,9 @@ foo:foo () { echo "this is ~" } "~" -# <- meta.function-call.identifier.shell meta.string.shell variable.function.shell punctuation.definition.string.begin.shell -#^^ meta.function-call.identifier.shell meta.string.shell variable.function.shell +# <- meta.function-call.identifier.shell variable.function.shell punctuation.definition.quoted.begin.shell +#^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^ punctuation.definition.quoted.end.shell ^ () { # <- meta.function entity.name.function echo "this is ^" @@ -3821,9 +3876,21 @@ test $me -eq ~/~foo # ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell # ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation - variable -~/.config/app +~/.bin/~app # <- meta.function-call.identifier.shell meta.interpolation.tilde.shell variable.language.tilde.shell -#^^^^^^^^^^^^ meta.function-call.identifier.shell variable.function.shell +#^^^^^^^^^^ meta.function-call.identifier.shell variable.function.shell +#^ punctuation.separator.path.shell +# ^ punctuation.separator.path.shell +# ^ - variable.language.tilde + +"~/.bin/~app" +# <- meta.function-call.identifier.shell meta.path.shell variable.function.shell punctuation.definition.quoted.begin.shell +#^^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +#^ - variable.language.tilde +# ^ punctuation.separator.path.shell +# ^ punctuation.separator.path.shell +# ^ - variable.language.tilde +# ^ punctuation.definition.quoted.end.shell ############################################################################### # 3.5.3 Shell Parameter Expansion # @@ -8112,10 +8179,22 @@ echo '([^.[:space:]]+) Class::method()' # colon not scoped as path separator > ~/.local/file # ^^ meta.redirection.shell - meta.path -# ^ meta.redirection.shell meta.path.shell meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ meta.redirection.shell meta.path.shell meta.string.shell meta.interpolation.tilde.shell # ^^^^^^^^^^^^ meta.redirection.shell meta.path.shell meta.string.shell string.unquoted.shell - meta.interpolation # ^ keyword.operator.assignment.redirection.shell # ^ variable.language.tilde.shell +# ^ punctuation.separator.path.shell +# ^ punctuation.separator.path.shell + + > "~/.local/file" +# ^^ meta.redirection.shell - meta.path +# ^^^^^^^^^^^^^^^ meta.redirection.shell meta.path.shell meta.string.shell string.quoted.double.shell +# ^ keyword.operator.assignment.redirection.shell +# ^ punctuation.definition.string.begin.shell +# ^ - variable.language +# ^ punctuation.separator.path.shell +# ^ punctuation.separator.path.shell +# ^ punctuation.definition.string.end.shell > "~/.local/file" # ^^ meta.redirection.shell - meta.path @@ -8881,7 +8960,7 @@ exec git diff-index --check --cached $against -- exec "$cmd" \ #^^^ meta.function-call.identifier.shell # ^ meta.function-call.arguments.shell -# ^^^^^^ meta.function-call.identifier.shell meta.string.shell +# ^^^^^^ meta.function-call.identifier.shell meta.path.shell # ^^^ meta.function-call.arguments.shell # ^ punctuation.separator.continuation.line.shell # ^ - punctuation @@ -8911,7 +8990,7 @@ exec \ -la name \ "$cmd" \ #^ meta.function-call.arguments.shell -# ^^^^^^ meta.function-call.identifier.shell meta.string.shell +# ^^^^^^ meta.function-call.identifier.shell meta.path.shell # ^^^ meta.function-call.arguments.shell # ^ punctuation.separator.continuation.line.shell # ^ - punctuation From 559aa33b5a1d59fd7d08388dfad8794708ba43dd Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 6 Jul 2024 11:33:04 +0200 Subject: [PATCH 013/113] [ShellScript] Refactor command arguments' word boundaries This commit... 1. refactors how word boundaries and quotes are treated. Motivation: A reliably distinction between tilde-expansions and logic operators is required in ZSH pattern matching to support the following: cmd ~/path/*~*.com ^ operator ^ tilde expansion 2. assigns `string` scope to all suitable strings and patterns to enable color schemes to more clearly distinguish them from variables. Note: Aligns Bash with "Batch File" syntax. 3. refactors command argument list termination Replace clunky and messy "boilerplate" contexts with proper "cmd-args-end". Note: Aligns Bash with "Batch File" syntax. --- ShellScript/Bash.sublime-syntax | 844 ++++++++---------- ...commands-builtin-shell-bash.sublime-syntax | 141 ++- ShellScript/test/syntax_test_bash.sh | 694 ++++++++------ ShellScript/tools/update-commands.py | 10 +- 4 files changed, 888 insertions(+), 801 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 15d50b197d..026884a65e 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -48,23 +48,16 @@ first_line_match: |- variables: is_interpolation: (?=\$[({{{identifier_char}}{{builtin_variable}}]|`) - is_variable: (?={{variable_first_char}}{{nbc}}(?:[({]{{nbc}}[)}])?{{nbc}}=) # posix identifiers (alpha-numeric) identifier: '{{identifier_first_char}}{{identifier_char}}*' identifier_first_char: '[[:alpha:]_]' identifier_char: '[[:alnum:]_]' - - # non-posix identifiers - nonposix: '{{nonposix_first_char}}{{nonposix_char}}*{{nonposix_break}}' - nonposix_first_char: '[^{{metachar}}]' - nonposix_char: '[^{{metachar}}=]' - nonposix_begin: (?={{nonposix_first_char}}) - nonposix_break: (?={{metachar}}|{{varassign}}|$) + identifier_break: (?!{{identifier_char}}) # Commands literals are command names without interpolation or quotation. cmd_literal: '{{cmd_literal_char}}+{{cmd_break}}' - cmd_literal_char: '[^{{metachar}}%$\\""''`]' + cmd_literal_char: '[^{{metachar}}%$\\"''`]' # Command names are non-posix identifiers, which may include assignment operators. cmd_begin: (?={{cmd_char}}) @@ -72,13 +65,12 @@ variables: cmd_char: '[^{{metachar}}]' # Command options are identifiers, which may start with interpolation. - opt_punctuation: '{{wspace}}(--|[-+]){{nonposix_begin}}' - opt_literal_char: '[^{{metachar}}=%$\\""''`{}]' - opt_break: '{{nonposix_break}}' + opt_punctuation: '(--|[-+]){{word_begin}}' + opt_break: (?![^={{metachar}}]) - # Variables are posix identifiers, which may start with interpolation. - variable_begin: (?={{variable_first_char}}|\$) - variable_first_char: '{{identifier_first_char}}' + word_begin: (?=\S) + word_break: (?!{{word_char}}) + word_char: '[^{{metachar}}]' # Shell Parameter Expansions builtin_variable: '[$#@!*?_-]' @@ -104,10 +96,13 @@ variables: no_escape_behind: (?))) + - match: (?=\s*(?:[)}|;]|&(?!>))) pop: 1 - include: eol-pop + eoc-pop2: + - match: (?=\s*(?:[)}|;]|&(?!>))) + pop: 2 + - include: eol-pop2 + eol-pop: - - match: $|(?=\s+#) + - match: (?=\s*$|\s+#) pop: 1 - include: line-continuations eol-pop2: - - match: $|(?=\s+#) + - match: (?=\s*$|\s+#) pop: 2 - include: line-continuations @@ -170,10 +172,6 @@ contexts: - match: '' pop: 1 - immediately-pop2: - - match: '' - pop: 2 - ###[ COMMENTS ]################################################################ comments: @@ -216,7 +214,7 @@ contexts: - match: (?=\(\s*\)) push: - def-anonymous-body - - def-functions-params + - def-function-params def-anonymous-body: - meta_include_prototype: false @@ -230,33 +228,33 @@ contexts: # [Bash] 3.3 Shell Functions - match: (?={{cmd_literal}}\s*\(\s*\)) push: - - def-functions-body - - def-functions-params - - def-functions-name + - def-function-body + - def-function-params + - def-function-name - match: function{{cmd_break}} scope: meta.function.shell keyword.declaration.function.shell push: - - def-functions-body - - def-functions-params - - def-functions-name + - def-function-body + - def-function-params + - def-function-name - def-functions-name: + def-function-name: - meta_include_prototype: false - match: '{{cmd_begin}}' - set: def-functions-name-chars + set: def-function-name-chars - include: else-pop - include: eol-pop - def-functions-name-chars: - - match: '{{cmd_literal_char}}+' - scope: entity.name.function.shell - - include: expansions-variables + def-function-name-chars: + - meta_scope: entity.name.function.shell - include: line-continuations - - include: immediately-pop + - include: literal-unquoted-content + - match: '{{cmd_break}}' + pop: 1 - def-functions-params: + def-function-params: - clear_scopes: 1 - meta_include_prototype: false - meta_content_scope: meta.function.identifier.shell @@ -270,7 +268,7 @@ contexts: - include: comments - include: else-pop - def-functions-body: + def-function-body: - meta_include_prototype: false - meta_scope: meta.function.shell - include: def-function-body-braces @@ -310,21 +308,11 @@ contexts: ###[ VARIABLE DEFINITIONS ]#################################################### def-variables: - - match: '{{is_variable}}' + - match: '{{identifier}}(?=(?:\[[^\]]*\])*{{varassign}})' + scope: variable.other.readwrite.shell push: - variable-value-assignment - variable-subscription - - variable-other-chars - - variables: - - match: (?={{identifier_first_char}}) - push: [variable-subscription, variable-other-chars] - - variable-other-chars: - - match: '{{identifier_char}}+' - scope: variable.other.readwrite.shell - - include: variable-other-expansions - - include: immediately-pop variable-subscription: - meta_scope: meta.variable.shell @@ -390,8 +378,7 @@ contexts: scope: punctuation.definition.key.end.shell set: variable-mapping-value-assignment - include: eoc-pop - - include: expansions-variables - - include: pattern-literals + - include: literal-unquoted-content variable-mapping-value-assignment: - meta_content_scope: meta.mapping.shell @@ -431,30 +418,26 @@ contexts: variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell - - include: cmd-alias-args-end-of-options - - cmd-alias-args-end-of-options: - include: cmd-args-illegal-options - - match: --{{cmd_break}}|(?=\S) + - match: --{{word_break}} scope: keyword.operator.end-of-options.shell - set: cmd-alias-args-name - - include: eoc-pop + set: cmd-alias-args-definitions + - include: cmd-alias-args-definitions - cmd-alias-args-name: - - include: cmd-args-boilerplate + cmd-alias-args-definitions: + - include: cmd-args-end - match: = scope: keyword.operator.assignment.shell - push: string-unquoted - - match: (?=\S) - push: cmd-alias-args-name-chars + push: variable-value + - match: '{{word_begin}}' + push: alias-name-chars - cmd-alias-args-name-chars: - - meta_scope: meta.variable.shell - - match: '{{opt_literal_char}}+' - scope: entity.name.function.shell - - include: expansions-variables + alias-name-chars: + - meta_scope: meta.variable.shell entity.name.function.shell - include: line-continuations - - include: immediately-pop + - include: literal-unquoted-content + - match: '{{opt_break}}' + pop: 1 ###[ ARITHMETIC BUILTINS ]##################################################### @@ -497,8 +480,7 @@ contexts: escape_captures: 0: meta.string.shell string.quoted.single.shell punctuation.definition.string.end.shell - - include: redirections - - include: eoc-pop + - include: cmd-args-end - include: cmd-test - include: expressions @@ -575,7 +557,7 @@ contexts: cmd-declare-options-then-functions: - include: cmd-declare-options - - include: cmd-args-end-of-options-then-functions + - include: cmd-args-end-of-options-then-function-declarations cmd-declare-options-then-variables: - include: cmd-declare-options @@ -600,23 +582,26 @@ contexts: cmd-exec-args: - meta_content_scope: meta.function-call.arguments.shell + - include: cmd-args-end - match: ([-+])[cl]*[a]{{opt_break}} - scope: meta.parameter.option.shell variable.parameter.option.shell + scope: + meta.parameter.option.shell + variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell push: cmd-args-option-maybe-value - match: ([-+])[cl]+{{opt_break}} - scope: meta.parameter.option.shell variable.parameter.option.shell + scope: + meta.parameter.option.shell + variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell - - match: '{{wspace}}(--){{cmd_break}}' - captures: - 0: meta.function-call.arguments.shell - 1: keyword.operator.end-of-options.shell + - match: --{{word_break}} + scope: + meta.function-call.arguments.shell + keyword.operator.end-of-options.shell pop: 1 - include: cmd-args-illegal-options - - include: redirections - - include: eoc-pop - include: else-pop ###[ EXPORT BUILTINS ]######################################################### @@ -647,7 +632,7 @@ contexts: cmd-export-options-then-functions: - include: cmd-export-options - - include: cmd-args-end-of-options-then-functions + - include: cmd-args-end-of-options-then-function-declarations cmd-export-options-then-variables: - include: cmd-export-options @@ -715,6 +700,7 @@ contexts: cmd-sudo-args: - meta_content_scope: meta.function-call.arguments.shell + - include: cmd-args-end - match: (--)(?x:askpass|auth-type|background|close-from|login-class| preserve-env|edit|group|set-home|help|host|login|remove-timestamp| reset-timestamp|list|non-interactive|preserve-groups|prompt|role| @@ -738,16 +724,13 @@ contexts: variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell - - match: --{{cmd_break}} + - match: --{{word_break}} scope: meta.function-call.arguments.shell keyword.operator.end-of-options.shell pop: 1 - - match: (--|[-+]){{identifier}} - scope: invalid.illegal.parameter.shell - - include: redirections + - include: cmd-args-illegal-options - include: else-pop - - include: eol-pop ###[ TEST BUILTINS ]########################################################### @@ -770,9 +753,8 @@ contexts: scope: invalid.illegal.operator.shell - match: '!=|==?' scope: keyword.operator.comparison.shell - - include: redirections + - include: cmd-args-end - include: test-expression-common - - include: eoc-pop builtin-test-body: - meta_scope: meta.conditional.shell @@ -784,6 +766,7 @@ contexts: scope: invalid.illegal.operator.shell - match: '!=|==?' scope: keyword.operator.comparison.shell + - include: line-continuations - include: test-expression-common compound-test-body: @@ -805,18 +788,21 @@ contexts: captures: 1: keyword.operator.comparison.shell push: compound-test-pattern + - include: line-continuations - include: test-expression-common compound-test-eregexp: - - meta_content_scope: meta.string.regexp.shell + - meta_content_scope: meta.string.regexp.shell string.unquoted.shell - match: (?=\s) pop: 1 + - include: line-continuations - include: eregexp-main-content compound-test-pattern: - - meta_content_scope: meta.string.regexp.shell + - meta_content_scope: meta.string.regexp.shell string.unquoted.shell - match: (?=\s) pop: 1 + - include: line-continuations - include: pattern-main-content compound-test-group-body: @@ -834,17 +820,18 @@ contexts: captures: 1: keyword.operator.comparison.shell push: compound-test-group-pattern + - include: line-continuations - include: test-expression-common compound-test-group-eregexp: - - meta_content_scope: meta.string.regexp.shell + - meta_content_scope: meta.string.regexp.shell string.unquoted.shell - include: compound-test-group-pattern-end - include: eregexp-group-content compound-test-group-pattern: - - meta_content_scope: meta.string.regexp.shell + - meta_content_scope: meta.string.regexp.shell string.unquoted.shell - include: compound-test-group-pattern-end - - include: pattern-main-content + - include: pattern-group-content compound-test-group-pattern-end: - match: \) @@ -859,6 +846,7 @@ contexts: pop: 3 - match: (?=&&|\|\|) pop: 1 + - include: line-continuations test-expression-common: - match: ([-+])[aobcdefghknoprstuvwxzGLNORS]{{opt_break}}(?!\s*(=~|!=|==?)) @@ -874,11 +862,7 @@ contexts: - match: '&&|\|\||!' scope: keyword.operator.logical.shell - include: comments - - include: booleans - - include: numbers - - include: expansions-variables - - include: strings-unquoted - - include: line-continuations + - include: cmd-args-values ###[ UNALIAS BUILTINS ]######################################################## @@ -903,7 +887,7 @@ contexts: variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell - - include: cmd-alias-args-end-of-options + - include: cmd-args-end-of-options-then-functions ###[ UNSET BUILTINS ]########################################################## @@ -987,43 +971,44 @@ contexts: - match: \$?\" scope: punctuation.definition.quoted.begin.shell push: - - cmd-name + - cmd-name-body - path-pattern-double-quoted-body - path-pattern-quoted-begin - match: \$\' scope: punctuation.definition.quoted.begin.shell push: - - cmd-name + - cmd-name-body - path-pattern-ansi-c-body - path-pattern-quoted-begin - match: \' scope: punctuation.definition.quoted.begin.shell push: - - cmd-name + - cmd-name-body - path-pattern-single-quoted-body - path-pattern-quoted-begin - match: '{{cmd_begin}}' push: - - cmd-name - - path-pattern-unquoted-begin + - cmd-name-body + - path-pattern-begin - cmd-name: + cmd-name-body: - meta_scope: meta.function-call.identifier.shell meta.path.shell variable.function.shell + - include: line-continuations + - include: path-pattern-content - match: '{{cmd_break}}' set: cmd-args - - include: line-continuations - - include: any-escapes - - include: brace-interpolations - - include: string-interpolations - - include: expansions-job - - include: expansions-patterns - - include: path-pattern-quotes - - include: path-pattern-separators cmd-args: + - meta_include_prototype: false - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end + - include: cmd-args-end-of-options-then-ambigious - include: cmd-args-options + - include: cmd-args-values + + cmd-args-end: + - include: redirections + - include: eoc-pop cmd-args-illegal-options: - match: (--|[-+]){{identifier}} @@ -1031,21 +1016,21 @@ contexts: cmd-args-options: - match: '{{opt_punctuation}}' - captures: - 1: meta.parameter.option.shell - variable.parameter.option.shell - punctuation.definition.parameter.shell - push: cmd-args-option-name + scope: punctuation.definition.parameter.shell + push: + - cmd-args-option-maybe-assignment + - cmd-args-option-name cmd-args-option-name: - - meta_content_scope: meta.parameter.option.shell - - match: '{{opt_literal_char}}+' - scope: variable.parameter.option.shell - - include: expansions-and-strings - - include: cmd-args-option-maybe-assignment + - meta_scope: meta.parameter.option.shell variable.parameter.option.shell + - include: line-continuations + - include: literal-unquoted-content + - match: '{{opt_break}}' + pop: 1 cmd-args-option-maybe-assignment: # NOTE: this context is used in commands-builtin-shell-bash.sublime-syntax + - meta_include_prototype: false - match: = scope: keyword.operator.assignment.shell set: variable-value @@ -1054,73 +1039,83 @@ contexts: cmd-args-option-maybe-value: # NOTE: this context is used in commands-builtin-shell-bash.sublime-syntax - - match: '{{wspace}}(?=[^-\]}{{metachar}}]|\\\n)' + - meta_include_prototype: false + - match: '{{wspace}}(?![-\]}{{metachar}}])' set: variable-value - include: number - include: line-continuations - include: immediately-pop - cmd-args-boilerplate: - # NOTE: this context is used in commands-builtin-shell-bash.sublime-syntax - - include: expansions-and-strings - - include: redirections - - include: booleans - - include: eoc-pop - - cmd-args-boilerplate-with-end-of-options: - # NOTE: this context is used in commands-builtin-shell-bash.sublime-syntax - - include: cmd-args-boilerplate - - include: cmd-args-end-of-options-then-ambigious - cmd-args-end-of-options-then-ambigious: - - match: '{{wspace}}(--){{cmd_break}}' - captures: - 1: keyword.operator.end-of-options.shell + - match: --{{word_break}} + scope: keyword.operator.end-of-options.shell push: cmd-args-ambigious cmd-args-ambigious: - - include: expansions-and-strings + - meta_include_prototype: false - include: redirections + - include: eoc-pop2 + - include: cmd-args-values + + cmd-args-end-of-options-then-function-declarations: + - include: cmd-args-illegal-options + - match: --{{word_break}} + scope: keyword.operator.end-of-options.shell + set: cmd-args-function-declarations + - include: cmd-args-function-declarations + + cmd-args-function-declarations: + - meta_include_prototype: false + - include: cmd-args-end + - match: '{{word_begin}}' + push: function-declaration-name-chars + + function-declaration-name-chars: + - meta_scope: meta.variable.shell entity.name.function.shell - include: line-continuations - - match: $|(?=\s*[#)};&|]) - pop: 2 + - include: literal-unquoted-content + - match: '{{word_break}}' + pop: 1 cmd-args-end-of-options-then-functions: - include: cmd-args-illegal-options - - match: --{{cmd_break}}|(?=\S) + - match: --{{word_break}} scope: keyword.operator.end-of-options.shell set: cmd-args-functions - - include: eoc-pop + - include: cmd-args-functions cmd-args-functions: - - include: cmd-args-boilerplate - - match: '{{varassign}}' - scope: keyword.operator.assignment.shell - push: string-unquoted - - match: '{{cmd_begin}}' - push: cmd-args-functions-chars + - include: cmd-args-end + - match: '{{word_begin}}' + push: function-reference-name-chars - cmd-args-functions-chars: - - meta_scope: meta.variable.shell - - match: '{{identifier_char}}+' - scope: variable.function.shell - - include: variable-function-expansions - - include: immediately-pop + function-reference-name-chars: + - meta_scope: meta.variable.shell variable.function.shell + - include: line-continuations + - include: literal-unquoted-content + - match: '{{word_break}}' + pop: 1 cmd-args-end-of-options-then-variables: - include: cmd-args-illegal-options - - match: --{{cmd_break}}|(?=\S) + - match: --{{word_break}} scope: keyword.operator.end-of-options.shell set: cmd-args-variables - - include: eoc-pop + - include: cmd-args-variables cmd-args-variables: - - include: cmd-args-boilerplate + - include: cmd-args-end - match: '{{varassign}}' scope: keyword.operator.assignment.shell push: variable-value - include: variables + cmd-args-values: + - meta_include_prototype: false + - include: booleans + - include: numbers + - include: string-path-patterns + ###[ CONTROL STATEMENTS ]###################################################### cmd-control: @@ -1185,7 +1180,8 @@ contexts: set: case-body - include: case-end - include: comments - - include: expansions-and-strings + - include: redirections + - include: cmd-args-values case-body: - include: case-end @@ -1197,26 +1193,29 @@ contexts: - case-clause-patterns case-clause-patterns: - - meta_scope: meta.patterns.shell meta.string.regexp.shell + - meta_scope: meta.patterns.shell + - meta_content_scope: meta.string.regexp.shell string.unquoted.shell - match: \) scope: keyword.control.conditional.patterns.end.shell pop: 1 # emergency bail outs if ')' is missing - match: (?=;;&?|;&) pop: 1 + - include: line-continuations - include: case-clause-pattern-content case-clause-pattern-content: # [Bash] 3.2.4.2: Each pattern undergoes tilde expansion, parameter # expansion, command substitution, and arithmetic expansion. - match: \( # Note: exists to support ZSH - scope: meta.group.regexp.shell punctuation.definition.group.begin.regexp.shell + scope: meta.group.regexp.shell string.unquoted.shell punctuation.definition.group.begin.regexp.shell push: case-clause-pattern-group-body - include: case-end-ahead - include: pattern-group-content case-clause-pattern-group-body: - - meta_content_scope: meta.group.regexp.shell + - clear_scopes: 1 # clear `string.unquoted` + - meta_content_scope: meta.group.regexp.shell string.unquoted.shell - include: pattern-group-end - include: case-clause-pattern-content @@ -1232,8 +1231,9 @@ contexts: pop: 1 flow-args: + - include: cmd-args-end - include: number - - include: cmd-args-boilerplate + - include: string-path-pattern for-args: - meta_include_prototype: false @@ -1248,15 +1248,13 @@ contexts: - match: in{{cmd_break}} scope: keyword.control.in.shell set: loop-iterator-wordlist - - include: redirections - - include: eoc-pop + - include: cmd-args-end - include: variables loop-iterator-wordlist: - meta_include_prototype: false - - include: redirections - - include: eoc-pop - - include: strings-unquoted + - include: cmd-args-end + - include: string-path-patterns ###[ REDIRECTIONS AND HEREDOCS ]############################################### @@ -1329,7 +1327,7 @@ contexts: redirection-descriptor: - meta_include_prototype: false - - match: (?:(\d+)(-?)|(-)){{cmd_break}} + - match: (?:(\d+)(-?)|(-)){{word_break}} captures: 1: meta.file-descriptor.shell meta.number.integer.decimal.shell @@ -1341,7 +1339,7 @@ contexts: - include: string-path-pattern redirections-here-string: - - match: (\d*)(<<<)\s*{{nonposix_begin}} + - match: (\d*)(<<<)\s*{{word_begin}} captures: 1: meta.file-descriptor.shell meta.number.integer.decimal.shell @@ -1540,10 +1538,7 @@ contexts: # syntax. - include: booleans - include: numbers - - include: strings - - include: expansions-variables - include: variables - - include: line-continuations expression-group-body: - meta_scope: meta.group.shell @@ -1598,28 +1593,32 @@ contexts: number: # Note: Leading sign is scoped as operator for consistent highlighting as # we can't distinguish operators from sign for sure everywhere. - - match: ([-+]?)(0[xX])(\h*)\w* + - match: ([-+]?)(0[xX])(\h*){{word_break}} + scope: meta.number.integer.hexadecimal.shell captures: 1: keyword.operator.arithmetic.shell - 2: meta.number.integer.hexadecimal.shell constant.numeric.base.shell - 3: meta.number.integer.hexadecimal.shell constant.numeric.value.shell + 2: constant.numeric.base.shell + 3: constant.numeric.value.shell pop: 1 - - match: ([-+]?)(0)([0-7]+)\w* + - match: ([-+]?)(0)([0-7]+){{word_break}} + scope: meta.number.integer.octal.shell captures: 1: keyword.operator.arithmetic.shell - 2: meta.number.integer.octal.shell constant.numeric.base.shell - 3: meta.number.integer.octal.shell constant.numeric.value.shell + 2: constant.numeric.base.shell + 3: constant.numeric.value.shell pop: 1 - - match: ([-+]?)(\d+#)([a-zA-Z0-9@_]+) + - match: ([-+]?)(\d+#)([a-zA-Z0-9@_]+){{word_break}} + scope: meta.number.integer.other.she captures: 1: keyword.operator.arithmetic.shell - 2: meta.number.integer.other.shell constant.numeric.base.shell - 3: meta.number.integer.other.shell constant.numeric.value.shell + 2: constant.numeric.base.shell + 3: constant.numeric.value.shell # If base# is omitted, then base 10 is used. - - match: ([-+]?)(\d+)(?![.\w]) + - match: ([-+]?)(\d+){{word_break}} + scope: meta.number.integer.decimal.shell captures: 1: keyword.operator.arithmetic.shell - 2: meta.number.integer.decimal.shell constant.numeric.value.shell + 2: constant.numeric.value.shell pop: 1 ###[ OPERATORS ]############################################################### @@ -1646,75 +1645,8 @@ contexts: - match: ; scope: punctuation.terminator.statement.shell -###[ IDENTIFIER EXPANSIONS AND QUOTES ]######################################## - - variable-function-expansions: - - include: line-continuations - - include: any-escapes - - match: \' - scope: punctuation.definition.string.begin.shell - push: - - meta_include_prototype: false - - meta_scope: meta.string.shell variable.function.shell - - include: string-quoted-single-body - - match: \" - scope: punctuation.definition.string.begin.shell - push: - - meta_include_prototype: false - - meta_scope: meta.string.shell variable.function.shell - - include: string-quoted-double-body - - match: \$' - scope: punctuation.definition.string.begin.shell - push: - - meta_include_prototype: false - - meta_scope: meta.string.shell variable.function.shell - - include: string-ansi-c-body - - match: \$" - scope: punctuation.definition.string.begin.shell - push: - - meta_include_prototype: false - - meta_scope: meta.string.shell variable.function.shell - - include: string-quoted-double-body - - include: expansions-variables - - variable-other-expansions: - - include: line-continuations - - include: any-escapes - - match: \' - scope: punctuation.definition.string.begin.shell - push: - - meta_scope: meta.string.shell variable.other.readwrite.shell - - include: string-quoted-single-body - - match: \" - scope: punctuation.definition.string.begin.shell - push: - - meta_scope: meta.string.shell variable.other.readwrite.shell - - include: string-quoted-double-body - - match: \$' - scope: punctuation.definition.string.begin.shell - push: - - meta_scope: meta.string.shell variable.other.readwrite.shell - - include: string-ansi-c-body - - match: \$" - scope: punctuation.definition.string.begin.shell - push: - - meta_scope: meta.string.shell variable.other.readwrite.shell - - include: string-quoted-double-body - - include: expansions-variables - ###[ EXPANSIONS ]############################################################## - expansions-and-strings: - - include: strings - - include: expansions - - expansions: - - include: expansions-brace - - include: expansions-job - - include: expansions-patterns - - include: expansions-tilde - - include: expansions-variables - expansions-patterns: - include: pattern-groups - include: pattern-charsets @@ -1824,9 +1756,9 @@ contexts: meta.interpolation.brace.shell punctuation.separator.sequence.shell set: expansion-brace-series-body - - include: string-unquoted-content - - include: expansions-patterns - - match: (?={{metachar}}) + - include: line-continuations + - include: pattern-main-content + - match: '{{word_break}}' fail: brace-expansion expansion-brace-end: @@ -1915,9 +1847,9 @@ contexts: meta.interpolation.brace.shell punctuation.separator.sequence.shell set: brace-interpolation-series-body - - include: string-unquoted-content - - include: expansions-patterns - - match: (?={{metachar}}) + - include: line-continuations + - include: pattern-main-content + - match: '{{word_break}}' fail: brace-interpolation ###[ COMMAND EXPANSIONS ]###################################################### @@ -2038,17 +1970,12 @@ contexts: set: expansion-parameter-name-chars expansion-parameter-name-chars: + - meta_content_scope: variable.other.readwrite.shell # note: no quoted name parts allowed within parameter expansions - match: '[@*](?!\w)' scope: variable.language.shell pop: 1 - - match: '{{identifier_char}}+' - scope: variable.other.readwrite.shell - - include: any-escapes - - include: pattern-literals - - include: expansions-variables - - include: line-continuations - - include: immediately-pop + - include: variable-name-chars expansion-parameter-modifier: # ${parameter@operator} @@ -2073,7 +2000,7 @@ contexts: scope: keyword.operator.substitution.shell set: - expansion-parameter-substitution-pattern - - maybe-tilde-expansion + - maybe-tilde-interpolation # ${parameter#pattern} # ${parameter##pattern} # ${parameter%pattern} @@ -2086,7 +2013,7 @@ contexts: scope: keyword.operator.expansion.shell set: - expansion-parameter-pattern - - maybe-tilde-expansion + - maybe-tilde-interpolation - include: variable-subscriptions expansion-parameter-substr-start: @@ -2101,12 +2028,9 @@ contexts: expansion-parameter-pattern: # [3.5.8.1] Pattern Matching in parameter expansions - - meta_content_scope: meta.string.regexp.shell + - meta_content_scope: meta.string.regexp.shell string.unquoted.shell - include: expansion-parameter-end - - include: line-continuations - - include: any-escapes - - include: pattern-literals - - include: expansions-variables + - include: string-unquoted-content - include: expansion-parameter-pattern-charsets - include: expansion-parameter-pattern-groups - include: pattern-wildcards @@ -2137,19 +2061,17 @@ contexts: expansion-parameter-pattern-groups: - match: ([?*+@!])(\() captures: - 1: keyword.operator.quantifier.regexp.shell - 2: meta.group.regexp.shell punctuation.definition.group.begin.regexp.shell + 1: string.unquoted.shell keyword.operator.quantifier.regexp.shell + 2: meta.group.regexp.shell string.unquoted.shell punctuation.definition.group.begin.regexp.shell push: expansion-parameter-pattern-group-body expansion-parameter-pattern-group-body: - - meta_content_scope: meta.group.regexp.shell + - clear_scopes: 1 # clear `string.unquoted` + - meta_content_scope: meta.group.regexp.shell string.unquoted.shell - include: pattern-group-end - - include: line-continuations - - include: any-escapes - - include: expansions-variables + - include: string-unquoted-content - include: expansion-parameter-pattern-groups - include: expansion-parameter-pattern-group-charsets - - include: pattern-literals - include: pattern-operators - include: pattern-wildcards - include: brace-pop @@ -2179,7 +2101,7 @@ contexts: expansion-parameter-substitution-pattern: # [3.5.8.1] Pattern Matching in parameter expansions' substitutions - - meta_content_scope: meta.string.regexp.shell + - meta_content_scope: meta.string.regexp.shell string.unquoted.shell - match: / scope: keyword.operator.substitution.shell set: expansion-parameter-substitution-value @@ -2195,13 +2117,13 @@ contexts: - meta_include_prototype: false - meta_content_scope: meta.string.shell string.unquoted.shell - include: expansion-parameter-end - - include: string-unquoted-content - - include: expansions-patterns + - include: pattern-main-content expansion-parameter-end: - match: \} scope: punctuation.section.interpolation.end.shell pop: 1 + - include: line-continuations ###[ TILDE EXPANSIONS ]######################################################## @@ -2233,12 +2155,6 @@ contexts: scope: variable.language.tilde.shell set: tilde-expansion-modifier - expansions-tilde: - # https://www.gnu.org/software/bash/manual/bash.html#Tilde-Expansion - - match: \~ - scope: variable.language.tilde.shell - push: tilde-expansion-modifier - tilde-expansion-modifier: - meta_include_prototype: false - meta_scope: meta.interpolation.tilde.shell @@ -2259,55 +2175,26 @@ contexts: ###[ PATH PATTERN MATCHING ]################################################### string-path-patterns: - - match: '{{nonposix_begin}}' - push: string-path-pattern + - match: '{{word_begin}}' + push: + - string-path-pattern-body + - maybe-tilde-interpolation string-path-pattern: - - meta_include_prototype: false - - match: \$?\" - scope: punctuation.definition.string.begin.shell + - match: '{{word_begin}}' set: - string-path-pattern-body - - string-path-pattern-double-quoted-body - - path-pattern-quoted-begin - - match: \$\' - scope: punctuation.definition.string.begin.shell - set: - - string-path-pattern-body - - string-path-pattern-ansi-c-body - - path-pattern-quoted-begin - - match: \' - scope: punctuation.definition.string.begin.shell - set: - - string-path-pattern-body - - string-path-pattern-single-quoted-body - - path-pattern-quoted-begin - - match: (?=\S) - set: - - string-path-pattern-body - - string-path-pattern-begin - - string-path-pattern-begin: - - meta_include_prototype: false - - include: tilde-interpolation - - include: path-pattern-quoted-begin + - maybe-tilde-interpolation string-path-pattern-body: - - meta_scope: meta.path.shell meta.string.shell string.unquoted.shell - - match: '{{cmd_break}}' - pop: 1 + - meta_scope: meta.string.shell string.unquoted.shell - include: line-continuations - - include: string-prototype - - include: any-escapes - - include: brace-interpolations - - include: string-interpolations - - include: expansions-patterns - - include: string-path-pattern-quotes - - include: string-path-separators - - include: path-pattern-separators + - include: string-path-pattern-content + - match: '{{word_break}}' + pop: 1 - string-path-pattern-quotes: - - match: \" + string-path-pattern-content: + - match: \$?\" scope: punctuation.definition.string.begin.shell push: string-path-pattern-double-quoted-body - match: \$' @@ -2316,27 +2203,44 @@ contexts: - match: \' scope: punctuation.definition.string.begin.shell push: string-path-pattern-single-quoted-body + - include: string-prototype + - include: any-escapes + - include: brace-interpolations + - include: string-interpolations + - include: expansions-job + - include: expansions-patterns + - include: string-pathlist-separators string-path-pattern-ansi-c-body: - - clear_scopes: 1 + - clear_scopes: 1 # clear `string.unquoted` - meta_scope: string.quoted.single.shell - include: string-ansi-c-body - - include: string-path-separators - - include: path-pattern-separators + - include: string-quoted-pathlist-separators string-path-pattern-double-quoted-body: - - clear_scopes: 1 + - clear_scopes: 1 # clear `string.unquoted` - meta_scope: string.quoted.double.shell - - include: string-quoted-double-body - - include: string-path-separators - - include: path-pattern-separators + - include: string-double-quoted-body + - include: string-quoted-pathlist-separators string-path-pattern-single-quoted-body: - - clear_scopes: 1 + - clear_scopes: 1 # clear `string.unquoted` - meta_scope: string.quoted.single.shell - - include: string-quoted-single-body - - include: string-path-separators - - include: path-pattern-separators + - include: string-single-quoted-body + - include: string-quoted-pathlist-separators + + string-pathlist-separators: + - match: '{{pathlist_separator}}' + scope: punctuation.separator.sequence.shell + push: path-pattern-begin + + string-quoted-pathlist-separators: + - match: '{{pathlist_separator}}' + scope: punctuation.separator.sequence.shell + + path-pattern-begin: + - include: tilde-expansion + - include: path-pattern-quoted-begin path-pattern-quoted-begin: - meta_include_prototype: false @@ -2349,12 +2253,7 @@ contexts: - include: line-continuations - include: immediately-pop - path-pattern-unquoted-begin: - - meta_include_prototype: false - - include: tilde-expansion - - include: path-pattern-quoted-begin - - path-pattern-quotes: + path-pattern-content: - match: \$?\" scope: punctuation.definition.quoted.begin.shell push: path-pattern-double-quoted-body @@ -2364,28 +2263,24 @@ contexts: - match: \' scope: punctuation.definition.quoted.begin.shell push: path-pattern-single-quoted-body + - include: string-prototype + - include: any-escapes + - include: brace-interpolations + - include: string-interpolations + - include: expansions-job + - include: expansions-patterns + - include: path-pattern-separators path-pattern-ansi-c-body: - - match: \' - scope: punctuation.definition.quoted.end.shell - pop: 1 - - include: line-continuations - - include: string-escapes-ansi-c + - include: literal-ansi-c-body - include: path-pattern-separators path-pattern-double-quoted-body: - - match: \" - scope: punctuation.definition.quoted.end.shell - pop: 1 - - include: line-continuations - - include: string-escapes - - include: string-interpolations + - include: literal-double-quoted-body - include: path-pattern-separators path-pattern-single-quoted-body: - - match: \' - scope: punctuation.definition.quoted.end.shell - pop: 1 + - include: literal-single-quoted-body - include: path-pattern-separators path-pattern-separators: @@ -2399,10 +2294,7 @@ contexts: pattern-main-content: # [3.5.8.1] Pattern Matching in arbitrary expressions - - include: line-continuations - - include: any-escapes - - include: pattern-literals - - include: expansions-variables + - include: string-unquoted-content - include: expansions-patterns pattern-charsets: @@ -2489,6 +2381,7 @@ contexts: pop: 1 - include: any-escapes - include: expansions-variables + - include: eol-pop pattern-charset-equivalence-body: - meta_scope: meta.set.regexp.shell @@ -2500,6 +2393,7 @@ contexts: pop: 1 - include: any-escapes - include: expansions-variables + - include: eol-pop pattern-charset-posix-body: - meta_scope: meta.set.regexp.shell @@ -2512,33 +2406,33 @@ contexts: pop: 1 - include: any-escapes - include: expansions-variables + - include: eol-pop pattern-groups: - match: ([?*+@!])(\() captures: - 1: keyword.operator.quantifier.regexp.shell - 2: meta.group.regexp.shell punctuation.definition.group.begin.regexp.shell + 1: string.unquoted.shell keyword.operator.quantifier.regexp.shell + 2: meta.group.regexp.shell string.unquoted.shell punctuation.definition.group.begin.regexp.shell push: pattern-group-body pattern-group-body: - - meta_content_scope: meta.group.regexp.shell + - clear_scopes: 1 # clear `string.unquoted` + - meta_content_scope: meta.group.regexp.shell string.unquoted.shell - include: pattern-group-end - include: pattern-group-content pattern-group-content: - - include: line-continuations - - include: any-escapes - - include: expansions-variables + - include: string-unquoted-content - include: pattern-groups - include: pattern-group-charsets - - include: pattern-literals - include: pattern-operators - include: pattern-wildcards pattern-group-end: - match: \) - scope: meta.group.regexp.shell punctuation.definition.group.end.regexp.shell + scope: meta.group.regexp.shell string.unquoted.shell punctuation.definition.group.end.regexp.shell pop: 1 + - include: line-continuations pattern-group-charsets: - match: (?=\[) @@ -2563,31 +2457,6 @@ contexts: - include: pattern-charset-end - include: pattern-charset-content - pattern-literals: - - match: \" - scope: punctuation.definition.quoted.begin.shell - push: pattern-double-quoted-literal-body - - match: \' - scope: punctuation.definition.quoted.begin.shell - push: pattern-single-quoted-literal-body - - pattern-double-quoted-literal-body: - - meta_include_prototype: false - - match: \" - scope: punctuation.definition.quoted.end.shell - pop: 1 - - include: string-prototype - - include: string-escapes - - include: line-continuations - - include: expansions-variables - - pattern-single-quoted-literal-body: - - meta_include_prototype: false - - match: \' - scope: punctuation.definition.quoted.end.shell - pop: 1 - - include: string-prototype - pattern-operators: - match: \| scope: keyword.operator.logical.regexp.shell @@ -2601,15 +2470,12 @@ contexts: ###[ POSIX EXTENDED REGULAR EXPRESSIONS ]###################################### eregexp-main-content: - - include: line-continuations - - include: any-escapes - - include: pattern-literals - - include: expansions-variables + - include: eregexp-quantifiers + - include: string-unquoted-content - include: eregexp-charsets - include: eregexp-groups - include: eregexp-anchors - include: eregexp-operators - - include: eregexp-quantifiers - include: eregexp-literals eregexp-groups: @@ -2618,22 +2484,21 @@ contexts: push: [eregexp-group-body, eregexp-unexpected-quantifier] eregexp-group-body: - - meta_scope: meta.group.regexp.shell + - clear_scopes: 1 # clear `string.unquoted` + - meta_scope: meta.group.regexp.shell string.unquoted.shell - match: \) scope: punctuation.section.group.end.regexp.shell pop: 1 + - include: line-continuations - include: eregexp-group-content eregexp-group-content: - - include: line-continuations - - include: any-escapes - - include: pattern-literals - - include: expansions-variables + - include: eregexp-quantifiers + - include: string-unquoted-content - include: eregexp-group-charsets - include: eregexp-groups - include: eregexp-anchors - include: eregexp-operators - - include: eregexp-quantifiers - include: eregexp-literals eregexp-charsets: @@ -2717,105 +2582,69 @@ contexts: - match: \) scope: invalid.illegal.stray.regexp.shell -###[ STRINGS ]################################################################# - - strings-unquoted: - - match: '{{nonposix_begin}}' - push: - - string-unquoted-body - - maybe-tilde-interpolation +###[ LITERALS ]################################################################ - string-unquoted: - - match: '{{nonposix_begin}}' - set: - - string-unquoted-body - - maybe-tilde-interpolation - - string-unquoted-body: - - meta_include_prototype: false - - meta_scope: meta.string.shell string.unquoted.shell - - include: string-unquoted-content - - include: string-path-separators - - match: '{{cmd_break}}' - pop: 1 - - string-unquoted-content: + literal-unquoted-content: + - match: \$?\" + scope: punctuation.definition.quoted.begin.shell + push: literal-double-quoted-body + - match: \$' + scope: punctuation.definition.quoted.begin.shell + push: literal-ansi-c-body + - match: \' + scope: punctuation.definition.quoted.begin.shell + push: literal-single-quoted-body - include: string-prototype - - include: line-continuations - include: any-escapes - include: brace-interpolations - include: string-interpolations + + literal-ansi-c-body: - match: \' - scope: punctuation.definition.string.begin.shell - push: - - clear_scopes: 1 - - meta_include_prototype: false - - meta_scope: string.quoted.single.shell - - include: string-quoted-single-body + scope: punctuation.definition.quoted.end.shell + pop: 1 + - include: line-continuations + - include: string-prototype + - include: string-escapes-ansi-c + + literal-double-quoted-body: - match: \" - scope: punctuation.definition.string.begin.shell - push: - - clear_scopes: 1 - - meta_include_prototype: false - - meta_scope: string.quoted.double.shell - - include: string-quoted-double-body - - match: \$' - scope: punctuation.definition.string.begin.shell - push: - - clear_scopes: 1 - - meta_include_prototype: false - - meta_scope: string.quoted.single.ansi-c.shell - - include: string-ansi-c-body - - match: \$" - scope: punctuation.definition.string.begin.shell - push: - - clear_scopes: 1 - - meta_include_prototype: false - - meta_scope: string.quoted.double.locale.shell - - include: string-quoted-double-body + scope: punctuation.definition.quoted.end.shell + pop: 1 + - include: line-continuations + - include: string-prototype + - include: string-escapes + - include: string-interpolations - strings: - - include: any-escapes - # nothing is escaped in a singly-quoted string! + literal-single-quoted-body: - match: \' + scope: punctuation.definition.quoted.end.shell + pop: 1 + - include: string-prototype + +###[ STRINGS ]################################################################# + + string-unquoted-content: + # [Bash] 3.1.2.5 + - match: \$?\" scope: punctuation.definition.string.begin.shell - push: - - meta_include_prototype: false - - meta_scope: meta.string.shell string.quoted.single.shell - - include: string-quoted-single-body - - match: \" - scope: punctuation.definition.string.begin.shell - push: - - meta_include_prototype: false - - meta_scope: meta.string.shell string.quoted.double.shell - - include: string-quoted-double-body + push: string-double-quoted-body # [Bash] 3.1.2.4 - match: \$' scope: punctuation.definition.string.begin.shell - push: - - meta_include_prototype: false - - meta_scope: meta.string.shell string.quoted.single.ansi-c.shell - - include: string-ansi-c-body - # [Bash] 3.1.2.5 - # If the string is translated and replaced, the replacement is double-quoted. - - match: \$" + push: string-ansi-c-body + - match: \' scope: punctuation.definition.string.begin.shell - push: - - meta_include_prototype: false - - meta_scope: meta.string.shell string.quoted.double.locale.shell - - include: string-quoted-double-body - - string-quoted-double-body: - - match: \" - scope: punctuation.definition.string.end.shell - pop: 1 - - include: line-continuations + push: string-single-quoted-body - include: string-prototype - - include: string-escapes + - include: any-escapes + - include: brace-interpolations - include: string-interpolations - - include: string-path-separators string-ansi-c-body: + - clear_scopes: 1 # clear `string.unquoted` + - meta_include_prototype: false + - meta_scope: string.quoted.single.shell - match: \' scope: punctuation.definition.string.end.shell pop: 1 @@ -2823,12 +2652,26 @@ contexts: - include: string-prototype - include: string-escapes-ansi-c - string-quoted-single-body: + string-double-quoted-body: + - clear_scopes: 1 # clear `string.unquoted` + - meta_include_prototype: false + - meta_scope: string.quoted.double.shell + - match: \" + scope: punctuation.definition.string.end.shell + pop: 1 + - include: line-continuations + - include: string-prototype + - include: string-escapes + - include: string-interpolations + + string-single-quoted-body: + - clear_scopes: 1 # clear `string.unquoted` + - meta_include_prototype: false + - meta_scope: string.quoted.single.shell - match: \' scope: punctuation.definition.string.end.shell pop: 1 - include: string-prototype - - include: string-path-separators any-escapes: - match: \\. @@ -2840,10 +2683,6 @@ contexts: - match: \\[$`"\\] scope: constant.character.escape.shell - string-path-separators: - - match: :(?=\$|(?:~|\.?\.)?/(?!/)) - scope: punctuation.separator.sequence.shell - string-escapes-ansi-c: - match: \\([abfnrtv'"?$`\\]|[0-8]{1,3}|x\h{1,8}|c[a-z]) scope: constant.character.escape.shell @@ -2861,3 +2700,16 @@ contexts: # for use by inheriting syntaxes to easily inject string interpolation # in any kind of quoted or unquoted string string-prototype: [] + +###[ VARIABLES ]############################################################### + + variables: + - match: '{{word_begin}}' + push: [variable-subscription, variable-name-chars] + + variable-name-chars: + - meta_scope: variable.other.readwrite.shell + - include: line-continuations + - include: literal-unquoted-content + - match: '{{identifier_break}}' + pop: 1 diff --git a/ShellScript/commands-builtin-shell-bash.sublime-syntax b/ShellScript/commands-builtin-shell-bash.sublime-syntax index 4b1823f0a9..306dec7338 100644 --- a/ShellScript/commands-builtin-shell-bash.sublime-syntax +++ b/ShellScript/commands-builtin-shell-bash.sublime-syntax @@ -122,7 +122,8 @@ contexts: push: cmd-su-args cmd-bind-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end + - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[lpsvPSVX]*[mqurfx] scope: meta.parameter.option.shell variable.parameter.option.shell captures: @@ -132,36 +133,48 @@ contexts: scope: meta.parameter.option.shell variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell + - include: cmd-args-values cmd-builtin-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end + - include: cmd-args-end-of-options-then-ambigious + - include: cmd-args-values cmd-caller-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end + - include: cmd-args-end-of-options-then-ambigious + - include: cmd-args-values cmd-colon-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate + - include: cmd-args-end + - include: cmd-args-values cmd-command-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end + - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[pVv]+ scope: meta.parameter.option.shell variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell + - include: cmd-args-values cmd-cd-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end + - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[LPe@] scope: meta.parameter.option.shell variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell push: cmd-args-option-maybe-value + - include: cmd-args-values cmd-dot-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate + - include: cmd-args-end + - include: cmd-args-values cmd-enable-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end + - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[dnps]*[af] scope: meta.parameter.option.shell variable.parameter.option.shell captures: @@ -171,35 +184,45 @@ contexts: scope: meta.parameter.option.shell variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell + - include: cmd-args-values cmd-help-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end + - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[dms]+ scope: meta.parameter.option.shell variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell + - include: cmd-args-values cmd-logout-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end + - include: cmd-args-end-of-options-then-ambigious + - include: cmd-args-values cmd-mapfile-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end + - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[dnOstuCc] scope: meta.parameter.option.shell variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell push: cmd-args-option-maybe-value + - include: cmd-args-values cmd-printf-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end + - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[v] scope: meta.parameter.option.shell variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell push: cmd-args-option-maybe-value + - include: cmd-args-values cmd-read-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end + - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[ers]*[adeinNprstu] scope: meta.parameter.option.shell variable.parameter.option.shell captures: @@ -209,9 +232,11 @@ contexts: scope: meta.parameter.option.shell variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell + - include: cmd-args-values cmd-readarray-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end + - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[ers]*[adeinNprstu] scope: meta.parameter.option.shell variable.parameter.option.shell captures: @@ -221,32 +246,43 @@ contexts: scope: meta.parameter.option.shell variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell + - include: cmd-args-values cmd-source-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end + - include: cmd-args-end-of-options-then-ambigious + - include: cmd-args-values cmd-type-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end + - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[afptP]+ scope: meta.parameter.option.shell variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell + - include: cmd-args-values cmd-ulimit-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end + - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[HSabcdefiklmnpqrstuvxPT]+ scope: meta.parameter.option.shell variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell + - include: cmd-args-values cmd-eval-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate + - include: cmd-args-end + - include: cmd-args-values cmd-getopts-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end + - include: cmd-args-end-of-options-then-ambigious + - include: cmd-args-values cmd-hash-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end + - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[dt]*[rpl] scope: meta.parameter.option.shell variable.parameter.option.shell captures: @@ -256,46 +292,56 @@ contexts: scope: meta.parameter.option.shell variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell + - include: cmd-args-values cmd-pwd-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end + - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[LP]+ scope: meta.parameter.option.shell variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell + - include: cmd-args-values cmd-shift-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate - - include: numbers + - include: cmd-args-end + - include: cmd-args-values cmd-times-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end + - include: cmd-args-end-of-options-then-ambigious + - include: cmd-args-values cmd-trap-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end + - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[lp]+ scope: meta.parameter.option.shell variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell + - include: cmd-args-values cmd-umask-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end + - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[pS] scope: meta.parameter.option.shell variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell push: cmd-args-option-maybe-value - - include: numbers + - include: cmd-args-values cmd-echo-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end - match: ([-+])[neE]+ scope: meta.parameter.option.shell variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell + - include: cmd-args-values cmd-set-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end + - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[abefhkmnptuvxBCEHPT]*[o] scope: meta.parameter.option.shell variable.parameter.option.shell captures: @@ -305,9 +351,11 @@ contexts: scope: meta.parameter.option.shell variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell + - include: cmd-args-values cmd-shopt-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end + - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[pqsu]*[o] scope: meta.parameter.option.shell variable.parameter.option.shell captures: @@ -317,15 +365,21 @@ contexts: scope: meta.parameter.option.shell variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell + - include: cmd-args-values cmd-bg-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end + - include: cmd-args-end-of-options-then-ambigious + - include: cmd-args-values cmd-fg-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end + - include: cmd-args-end-of-options-then-ambigious + - include: cmd-args-values cmd-jobs-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end + - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[lnprs]*[x] scope: meta.parameter.option.shell variable.parameter.option.shell captures: @@ -335,25 +389,31 @@ contexts: scope: meta.parameter.option.shell variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell + - include: cmd-args-values cmd-kill-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end + - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[snlL]+ scope: meta.parameter.option.shell variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell push: cmd-args-option-maybe-value + - include: cmd-args-values cmd-wait-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end + - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[fnp]+ scope: meta.parameter.option.shell variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell push: cmd-args-option-maybe-value + - include: cmd-args-values cmd-disown-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end + - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[ar]*[h] scope: meta.parameter.option.shell variable.parameter.option.shell captures: @@ -363,17 +423,21 @@ contexts: scope: meta.parameter.option.shell variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell + - include: cmd-args-values cmd-suspend-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end + - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[f] scope: meta.parameter.option.shell variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell push: cmd-args-option-maybe-value + - include: cmd-args-values cmd-su-args: - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-boilerplate-with-end-of-options + - include: cmd-args-end + - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[mp]*[-cls] scope: meta.parameter.option.shell variable.parameter.option.shell captures: @@ -383,3 +447,4 @@ contexts: scope: meta.parameter.option.shell variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell + - include: cmd-args-values diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index c40b313988..923ec7b3e3 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -185,7 +185,7 @@ echo 'singe\' \\'' # ^ - meta.string - string echo $'\a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z\'' -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell string.quoted.single.ansi-c.shell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell string.quoted.single.shell # ^^ punctuation.definition.string.begin.shell # ^^^^ constant.character.escape.shell # ^^^^^^ - constant.character.escape @@ -207,7 +207,7 @@ echo -e "\e[33mcolored text\e[0m uncolored" # ^^^^^ constant.character.escape.color.shell echo $'Hello\' World\\' -# ^^^^^^^^^^^^^^^^^^ meta.string.shell string.quoted.single.ansi-c.shell +# ^^^^^^^^^^^^^^^^^^ meta.string.shell string.quoted.single.shell # ^^ punctuation.definition.string.begin.shell # ^^ constant.character.escape.shell # ^^ constant.character.escape.shell @@ -215,7 +215,7 @@ echo $'Hello\' World\\' # ^ - meta.string - string echo $"Hello\" World\\" -# ^^^^^^^^^^^^^^^^^^ meta.string.shell string.quoted.double.locale.shell +# ^^^^^^^^^^^^^^^^^^ meta.string.shell string.quoted.double.shell # ^^ punctuation.definition.string.begin.shell # ^^ constant.character.escape.shell # ^^ constant.character.escape.shell @@ -223,30 +223,30 @@ echo $"Hello\" World\\" # ^ - meta.string - string echo $"Hello -# ^^^^^^^^ meta.string.shell string.quoted.double.locale.shell +# ^^^^^^^^ meta.string.shell string.quoted.double.shell # ^^ punctuation.definition.string.begin.shell World\\" -#^^^^^^^^^ meta.string.shell string.quoted.double.locale.shell +#^^^^^^^^^ meta.string.shell string.quoted.double.shell # ^^ constant.character.escape.shell # ^ punctuation.definition.string.end.shell # ^ - meta.string - string # Note: Line continuation causes the linefeed to be removed from the output string. echo $"Hello \ -# ^^^^^^^^^^ meta.string.shell string.quoted.double.locale.shell +# ^^^^^^^^^^ meta.string.shell string.quoted.double.shell # ^^ punctuation.definition.string.begin.shell # ^ punctuation.separator.continuation.line.shell # ^ - punctuation World\\" -#^^^^^^^^^ meta.string.shell string.quoted.double.locale.shell +#^^^^^^^^^ meta.string.shell string.quoted.double.shell # ^^ constant.character.escape.shell # ^ punctuation.definition.string.end.shell # ^ - meta.string - string echo $"Hello \\\"$world\"" -# ^^^^^^^^^^^^ meta.string.shell string.quoted.double.locale.shell - meta.interpolation - variable +# ^^^^^^^^^^^^ meta.string.shell string.quoted.double.shell - meta.interpolation - variable # ^^^^^^ meta.string.shell meta.interpolation.parameter.shell -# ^^^ meta.string.shell string.quoted.double.locale.shell - meta.interpolation - variable +# ^^^ meta.string.shell string.quoted.double.shell - meta.interpolation - variable # ^^ punctuation.definition.string.begin.shell # ^^^^ constant.character.escape.shell # ^ punctuation.definition.variable.shell @@ -255,9 +255,9 @@ echo $"Hello \\\"$world\"" # ^ punctuation.definition.string.end.shell echo $"Hello \\\"`echo World`\"" -# ^^^^^^^^^^^^ meta.string.shell string.quoted.double.locale.shell - meta.interpolation - variable +# ^^^^^^^^^^^^ meta.string.shell string.quoted.double.shell - meta.interpolation - variable # ^^^^^^^^^^^^ meta.string.shell meta.interpolation.command.shell -# ^^^ meta.string.shell string.quoted.double.locale.shell - meta.interpolation - variable +# ^^^ meta.string.shell string.quoted.double.shell - meta.interpolation - variable # ^^ punctuation.definition.string.begin.shell # ^^^^ constant.character.escape.shell # ^ punctuation.section.interpolation.begin.shell @@ -441,6 +441,7 @@ $e'ch'o Hello, world! # ^ punctuation.separator.path.shell # ^ punctuation.definition.quoted.end.shell # ^ punctuation.definition.quoted.begin.shell +# ^^ - constant.other.path - punctuation # ^ punctuation.separator.path.shell # ^ punctuation.definition.quoted.end.shell @@ -466,6 +467,25 @@ $e'ch'o Hello, world! # ^ - constant # ^ punctuation.definition.quoted.end.shell +# QUOTING VARIABLES IN ARITHMETIC EXPRESSIONS +# note: quotes with whitespace is not supported, but bash parses variables too +# different, depending on context, to find a perfact solution + +(( foo "bar" 'baz' "foo "bar' baz' )) +# ^^^ variable.other.readwrite.shell +# ^^^^^ variable.other.readwrite.shell +# ^ punctuation.definition.quoted.begin.shell +# ^ punctuation.definition.quoted.end.shell +# ^^^^^ variable.other.readwrite.shell +# ^ punctuation.definition.quoted.begin.shell +# ^ punctuation.definition.quoted.end.shell +# ^^^^^^^^^^^^^^^ variable.other.readwrite.shell +# ^ punctuation.definition.quoted.begin.shell +# ^ punctuation.definition.quoted.end.shell +# ^ punctuation.definition.quoted.begin.shell +# ^ punctuation.definition.quoted.end.shell + + ############################################################################### # 3.2 Shell Commands (Basic Command Arguments) # # https://www.gnu.org/software/bash/manual/bash.html#Simple-Commands # @@ -524,11 +544,12 @@ read -d '' -sn 1 -t1 -- -t1 10 # ^^ variable.parameter.option.shell # ^ meta.number.integer.decimal.shell constant.numeric.value.shell # ^^ keyword.operator.end-of-options.shell -# ^^^^^^ - constant - variable +# ^^^^ - constant - variable +# ^^ constant.numeric.value.shell shift 2 -- #^^^^ meta.function-call.identifier.shell support.function.shift.shell -# ^^^^^^ meta.function-call.arguments.shell +# ^^^^^ meta.function-call.arguments.shell # ^ meta.number.integer.decimal.shell constant.numeric.value.shell # ^^ - keyword @@ -565,13 +586,14 @@ foo\ -e Hello # <- - punctuation #^ - variable.parameter -# ^^^^^ - string +# ^^^^^ meta.string.shell string.unquoted.shell foo -e =Hello #^^ meta.function-call.identifier.shell variable.function.shell # ^^^^^^^^^^ meta.function-call.arguments.shell # ^ punctuation.definition.parameter.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^^^^^ meta.string.shell string.unquoted.shell # ^ - keyword.operator foo -e=Hello @@ -581,7 +603,7 @@ foo -e=Hello # ^ meta.parameter.option.shell variable.parameter.option.shell punctuation.definition.parameter.shell # ^ meta.parameter.option.shell variable.parameter.option.shell - punctuation # ^ keyword.operator.assignment.shell -# ^^^^^ string.unquoted.shell +# ^^^^^ meta.string.shell string.unquoted.shell foo -$e=Hello #^^ meta.function-call.identifier.shell variable.function.shell @@ -589,7 +611,17 @@ foo -$e=Hello # ^ meta.parameter.option.shell variable.parameter.option.shell punctuation.definition.parameter.shell # ^^ meta.parameter.option.shell meta.interpolation.parameter.shell variable.other.readwrite.shell - variable variable # ^ keyword.operator.assignment.shell -# ^^^^^ string.unquoted.shell +# ^^^^^ meta.string.shell string.unquoted.shell + +any --h\elp +# ^^^^^^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^ constant.character.escape.shell + +any --"h\elp" +# ^^^^^^^^^ meta.parameter.option.shell variable.parameter.option.shell +# ^ punctuation.definition.quoted.begin.shell +# ^^ - constant.character.escape +# ^ punctuation.definition.quoted.end.shell foo -n - # ^ - meta.parameter @@ -1254,12 +1286,20 @@ while true; do # ^^^^^ keyword.control.flow.break.shell # ^ meta.number.integer.decimal.shell constant.numeric.value.shell # ^ punctuation.terminator.statement.shell + break ${levels}; +# ^^^^^ keyword.control.flow.break.shell +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.terminator.statement.shell continue # ^^^^^^^^ keyword.control.flow.continue.shell continue 2; # ^^^^^^^^ keyword.control.flow.continue.shell # ^ meta.number.integer.decimal.shell constant.numeric.value.shell # ^ punctuation.terminator.statement.shell + continue ${levels}; +# ^^^^^^^^ keyword.control.flow.continue.shell +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.terminator.statement.shell done # <- keyword.control.loop.end @@ -1518,12 +1558,12 @@ if !cmd [[ '-e' == -e ]] # -e undergoes pattern matching on the right # ^^^^ meta.string.shell string.quoted.single.shell # ^^ keyword.operator.comparison.shell -# ^^ meta.conditional.shell meta.string.regexp.shell - variable +# ^^ meta.conditional.shell meta.string.regexp.shell string.unquoted.shell - variable [[ -e == -e ]] # a syntax error in bash but allowed in zsh -# ^^ - variable.parameter.option +# ^^ meta.string.shell string.unquoted.shell - variable # ^^ keyword.operator.comparison.shell -# ^^ meta.conditional.shell meta.string.regexp.shell - variable +# ^^ meta.conditional.shell meta.string.regexp.shell string.unquoted.shell - variable [[ $foo == 'bar' || $foo == "baz" && $bar == baz ]] # <- meta.conditional.shell support.function.test.begin.shell @@ -1831,8 +1871,9 @@ esac case var in ( patt ( esac #^ meta.conditional.case.shell -# ^^^^^^^ meta.patterns.shell - meta.group -# ^^ meta.patterns.shell meta.group.regexp.shell +# ^ meta.patterns.shell - meta.string - meta.group - string +# ^^^^^^ meta.patterns.shell meta.string.regexp.shell string.unquoted.shell - meta.group +# ^^ meta.patterns.shell meta.string.regexp.shell meta.group.regexp.shell string.unquoted.shell # ^^^^ meta.conditional.case.shell # ^ keyword.control.conditional.patterns.begin.shell # ^ punctuation.definition.group.begin.regexp.shell @@ -1853,7 +1894,8 @@ case # comment # ^^^^^^^^^^ comment.line.number-sign.shell pattern) # comment #^ meta.conditional.case.shell -# ^^^^^^^^ meta.conditional.case.shell meta.patterns.shell +# ^^^^^^^ meta.conditional.case.shell meta.patterns.shell meta.string.regexp.shell string.unquoted.shell - meta.group +# ^ meta.patterns.shell - meta.string - meta.group - string # ^^^^^^^^^^^ meta.conditional.case.shell - meta.patterns # ^^^^^^^^^^ comment.line.number-sign.shell esac @@ -1923,27 +1965,33 @@ case "${foo}" in- in_ in=10 in # ^^ keyword.control.in ( help | h ) bar ;; #^^^ meta.conditional.case.shell - meta.patterns -# ^^^^^^^^^^^^ meta.conditional.case.shell meta.patterns.shell +# ^ meta.patterns.shell - meta.string - meta.group - string +# ^^^^^^^^^^ meta.conditional.case.shell meta.patterns.shell meta.string.regexp.shell string.unquoted.shell - meta.group +# ^ meta.patterns.shell - meta.string - meta.group - string # ^^^^^^^^ meta.conditional.case.shell - meta.patterns # <- keyword.control.conditional.patterns.begin.shell # ^ keyword.control.conditional.patterns.end.shell # ^^ punctuation.terminator.case.clause.shell do1 ) foo1 ;& #^^^ meta.conditional.case.shell - meta.patterns -# ^^^^^ meta.conditional.case.shell meta.patterns.shell +# ^^^^ meta.conditional.case.shell meta.patterns.shell meta.string.regexp.shell string.unquoted.shell - meta.group +# ^ meta.patterns.shell - meta.string - meta.group - string # ^^^^^^^^^ meta.conditional.case.shell - meta.patterns # ^ keyword.control.conditional.patterns.end.shell # ^^ punctuation.terminator.case.clause.shell (do2 ) foo2 ;;& #^^^ meta.conditional.case.shell - meta.patterns -# ^^^^^^ meta.conditional.case.shell meta.patterns.shell +# ^ meta.patterns.shell - meta.string - meta.group - string +# ^^^^ meta.conditional.case.shell meta.patterns.shell meta.string.regexp.shell string.unquoted.shell - meta.group +# ^ meta.patterns.shell - meta.string - meta.group - string # ^^^^^^^^^^ meta.conditional.case.shell - meta.patterns # <- keyword.control.conditional.patterns.begin.shell # ^ keyword.control.conditional.patterns.end.shell # ^^^ punctuation.terminator.case.clause.shell *) bar #^^^ meta.conditional.case.shell - meta.patterns -# ^^ meta.conditional.case.shell meta.patterns.shell +# ^ meta.conditional.case.shell meta.patterns.shell meta.string.regexp.shell string.unquoted.shell - meta.group +# ^ meta.patterns.shell - meta.string - meta.group - string # ^^^^^ meta.conditional.case.shell - meta.patterns #^ keyword.control.conditional.patterns.end.shell esac @@ -1958,6 +2006,10 @@ case $TERM in # ^ meta.function punctuation.section.block.end.shell # ^^ punctuation.terminator.case.clause.shell *xterm*|rxvt|(dt|k|E)term) + #^^^^^^^^ meta.patterns.shell meta.string.regexp.shell string.unquoted.shell + # ^^^^^^^^ meta.patterns.shell meta.string.regexp.shell meta.group.regexp.shell string.unquoted.shell + # ^^^^ meta.patterns.shell meta.string.regexp.shell string.unquoted.shell + # ^ meta.patterns.shell - meta.string - meta.group - string # ^ constant.other.wildcard.asterisk.shell # ^ keyword.operator.logical.regexp.shell # ^ keyword.operator.logical.regexp.shell @@ -1970,7 +2022,7 @@ case $TERM in # ^ meta.function punctuation.section.block.end.shell # ^^ punctuation.terminator.case.clause.shell *) - # <- constant.other.wildcard.asterisk.shell + # <- meta.patterns.shell meta.string.regexp.shell string.unquoted.shell constant.other.wildcard.asterisk.shell #^ keyword.control.conditional.patterns.end.shell update_terminal_cwd() {};; # ^ meta.function punctuation.section.block.end.shell @@ -1983,7 +2035,9 @@ case $SERVER in ws-+([0-9]).host.com) echo "Web Server" #^^^ meta.patterns.shell meta.string.regexp.shell - meta.group # ^^^^^^^ meta.patterns.shell meta.string.regexp.shell meta.group.regexp.shell -# ^^^^^^^^^^ meta.patterns.shell meta.string.regexp.shell - meta.group +# ^^^^^^^^^ meta.patterns.shell meta.string.regexp.shell - meta.group +# ^ meta.patterns.shell - meta.string - meta.group - string +#^^^^^^^^^^^^^^^^^^^ string.unquoted.shell # ^ keyword.operator.quantifier.regexp.shell # ^ punctuation.definition.group.begin.regexp.shell # ^ punctuation.definition.set.begin.regexp.shell @@ -2073,7 +2127,8 @@ esac # <- meta.compound.shell punctuation.section.compound.begin.shell #^^^^^^^^^ meta.compound.shell - meta.compound meta.compound # ^^^ meta.function-call.identifier.shell -# ^^^^ meta.function-call.arguments.shell +# ^^^ meta.function-call.arguments.shell +# ^^ - meta.function-call # ^^^^^^^^^^^^^^^^^^^^^ meta.compound.arguments.shell - meta.compound meta.compound # ^ - meta.compound # ^^^ variable.function.shell @@ -2169,7 +2224,7 @@ coproc awk '{print "foo" $0;fflush()}' # ^ - meta.coproc - meta.function-call #^^^^^ keyword.declaration.coproc.shell # ^^^ variable.function.shell -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell string.quoted.single.shell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell string.quoted.single.shell - meta.interpolation # ^ punctuation.definition.string.begin.shell # ^ punctuation.definition.string.end.shell @@ -2389,6 +2444,11 @@ function foo # <- keyword.control.flow.return.shell #^^^^^ keyword.control.flow.return.shell # ^ meta.number.integer.decimal.shell constant.numeric.value.shell + + return ${RETURN_CODE} + # <- keyword.control.flow.return.shell + #^^^^^ keyword.control.flow.return.shell + # ^^^^^^^^^^^^^^ meta.interpolation.parameter.shell } # <- meta.function.shell meta.block.shell punctuation.section.block.end.shell #^ - meta.function @@ -2805,32 +2865,6 @@ x="$(( foo++ ))" # ^^ keyword # ^^ punctuation.section.interpolation.end.shell -B$(cat)OWL=$(($(cat food.txt | wc -l) + 5)) -# <- meta.variable.shell variable.other.readwrite.shell - meta.interpolation -#^^^^^^ meta.variable.shell meta.interpolation.command.shell -# ^^^ meta.variable.shell variable.other.readwrite.shell -# ^ - meta.interpolation -# ^^^ meta.string.shell meta.interpolation.arithmetic.shell - meta.interpolation meta.interpolation -# ^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell meta.interpolation.arithmetic.shell meta.interpolation.command.shell -# ^^^^^^ meta.string.shell meta.interpolation.arithmetic.shell - meta.interpolation meta.interpolation -# ^ - meta.interpolation -# ^ keyword.operator.assignment -# ^^^^^ - punctuation punctuation -# ^ punctuation.definition.variable.shell -# ^^ punctuation.section.interpolation.begin.shell -# ^ punctuation.definition.variable.shell -# ^ punctuation.section.interpolation.begin.shell -# ^^^ variable.function -# ^^^^^^^^ - variable.function -# ^ - meta.function-call -# ^ keyword.operator -# ^ - meta.function-call -# ^^ meta.function-call.identifier.shell variable.function.shell -# ^ punctuation.section.interpolation.end.shell -# ^ keyword.operator -# ^ constant.numeric -# ^^ punctuation.section.interpolation.end.shell - # These are all legal identifiers for variables. alias=hello # <- - storage - keyword @@ -2885,16 +2919,6 @@ charclass=\}ower # ^^^^^^ meta.string.shell # ^^ constant.character.escape.shell -# `-` is not a valid variable identifier char -my-var=20 -# <- variable.other.readwrite.shell -#^ variable.other.readwrite.shell -# ^^^^^^^ - variable.other - -5var=20 -# <- - variable.other -#^^^^^^ - variable.other - (foo=bar) # <- meta.compound.shell punctuation.section.compound.begin.shell #^^^^^^^^ meta.compound.shell @@ -3185,6 +3209,25 @@ commits=($(git rev-list --reverse --$abbrev-commit "$latest".. -- "$prefix")) # <- - variable.other.readwrite +# `=` must immediately follow without whitespace +novar =20 +# <- - meta.variable - variable.other +#^^^^^^^^ - meta.variable - variable.other + +# `-` is not a valid variable identifier char +my-var=20 +# <- - meta.variable - variable.other +#^^^^^^^^ - meta.variable - variable.other + +5var=20 +# <- - meta.variable - variable.other +#^^^^^^ - meta.variable - variable.other + +# not a variable due to command interpolation in name +B$(cat)OWL=$(($(cat food.txt | wc -l) + 5)) +# <- meta.function-call.identifier.shell meta.path.shell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell + ############################################################################### # 3.4.1 Positional Parameters # @@ -3459,13 +3502,19 @@ commits=($(git rev-list --reverse --$abbrev-commit "$latest".. -- "$prefix")) # followed by an optional postscript. : prefix{a,b,c}suffix -# ^^^^^^ - meta.interpolation -# ^^^^^^^ meta.interpolation.brace.shell -# ^^^^^^ - meta.interpolation +# ^^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation +# ^ meta.string.shell meta.interpolation.brace.shell punctuation.section.interpolation.begin.shell +# ^ meta.string.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell +# ^ meta.string.shell meta.interpolation.brace.shell punctuation.separator.sequence.shell +# ^ meta.string.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell +# ^ meta.string.shell meta.interpolation.brace.shell punctuation.separator.sequence.shell +# ^ meta.string.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell +# ^ meta.string.shell meta.interpolation.brace.shell punctuation.section.interpolation.end.shell +# ^^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation : {a,b,~,%,!,.,\,,\{,\},*,?,-1,+2,0," ",' '} #^ - meta.interpolation -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interpolation.brace.shell - meta.interpolation.brace meta.interpolation.brace +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell meta.interpolation.brace.shell - meta.interpolation.brace meta.interpolation.brace # ^ punctuation.section.interpolation.begin.shell # ^ meta.string.shell string.unquoted.shell # ^ punctuation.separator.sequence.shell @@ -3502,19 +3551,19 @@ commits=($(git rev-list --reverse --$abbrev-commit "$latest".. -- "$prefix")) # ^ - meta.interpolation : {${foo},${bar},$(ls ~),foo${bar}buz,a{a,b,c}d} -# ^ meta.interpolation.brace.shell - meta.interpolation meta.interpolation -# ^^^^^^ meta.interpolation.brace.shell meta.interpolation.parameter.shell -# ^ meta.interpolation.brace.shell - meta.interpolation meta.interpolation -# ^^^^^^ meta.interpolation.brace.shell meta.interpolation.parameter.shell -# ^ meta.interpolation.brace.shell - meta.interpolation meta.interpolation -# ^^^^^^^ meta.interpolation.brace.shell meta.interpolation.command.shell -# ^ meta.interpolation.brace.shell punctuation.separator.sequence.shell -# ^^^ meta.interpolation.brace.shell meta.string.shell string.unquoted.shell -# ^^^^^^ meta.interpolation.brace.shell meta.string.shell meta.interpolation.parameter.shell -# ^^^ meta.interpolation.brace.shell meta.string.shell string.unquoted.shell -# ^ meta.interpolation.brace.shell punctuation.separator.sequence.shell -# ^ meta.interpolation.brace.shell meta.string.shell string.unquoted.shell -# ^^^^^^^ meta.interpolation.brace.shell meta.string.shell meta.interpolation.brace.shell +# ^ meta.string.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation +# ^^^^^^ meta.string.shell meta.interpolation.brace.shell meta.interpolation.parameter.shell +# ^ meta.string.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation +# ^^^^^^ meta.string.shell meta.interpolation.brace.shell meta.interpolation.parameter.shell +# ^ meta.string.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation +# ^^^^^^^ meta.string.shell meta.interpolation.brace.shell meta.interpolation.command.shell +# ^ meta.string.shell meta.interpolation.brace.shell punctuation.separator.sequence.shell +# ^^^ meta.string.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell +# ^^^^^^ meta.string.shell meta.interpolation.brace.shell meta.string.shell meta.interpolation.parameter.shell +# ^^^ meta.string.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell +# ^ meta.string.shell meta.interpolation.brace.shell punctuation.separator.sequence.shell +# ^ meta.string.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell +# ^^^^^^^ meta.string.shell meta.interpolation.brace.shell meta.string.shell meta.interpolation.brace.shell # ^ punctuation.section.interpolation.begin.shell # ^ meta.string.shell string.unquoted.shell # ^ punctuation.separator.sequence.shell @@ -3541,13 +3590,13 @@ bar,baz} # ^ punctuation.section.interpolation.end.shell : {{foo,{bar,baz},foo},bar,{1..10}} -# ^ meta.interpolation.brace.shell - meta.interpolation meta.interpolation -# ^^^^^ meta.interpolation.brace.shell meta.string.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation meta.interpolation -# ^^^^^^^^^ meta.interpolation.brace.shell meta.string.shell meta.interpolation.brace.shell meta.string.shell meta.interpolation.brace.shell -# ^^^^^ meta.interpolation.brace.shell meta.string.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation meta.interpolation -# ^^^^^ meta.interpolation.brace.shell - meta.interpolation meta.interpolation -# ^^^^^^^ meta.interpolation.brace.shell meta.string.shell meta.interpolation.brace.shell -# ^ meta.interpolation.brace.shell - meta.interpolation meta.interpolation +# ^ meta.string.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation +# ^^^^^ meta.string.shell meta.interpolation.brace.shell meta.string.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation meta.interpolation +# ^^^^^^^^^ meta.string.shell meta.interpolation.brace.shell meta.string.shell meta.interpolation.brace.shell meta.string.shell meta.interpolation.brace.shell +# ^^^^^ meta.string.shell meta.interpolation.brace.shell meta.string.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation meta.interpolation +# ^^^^^ meta.string.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation +# ^^^^^^^ meta.string.shell meta.interpolation.brace.shell meta.string.shell meta.interpolation.brace.shell +# ^ meta.string.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation # ^ - meta.string - meta.interpolation # ^^ punctuation.section.interpolation.begin.shell # ^^^ string.unquoted.shell @@ -3715,12 +3764,24 @@ any --arg{1..4}={1..4} # ^ keyword.operator.assignment.shell # ^^^^^^ meta.string.shell meta.interpolation.brace.shell +any --arg{1..4} ={1..4} +# ^^^^^ meta.parameter.option.shell variable.parameter.option.shell - meta.interpolation +# ^^^^^^ meta.function-call.arguments.shell meta.parameter.option.shell meta.interpolation.brace.shell - variable.parameter +# ^ meta.string.shell string.unquoted.shell - meta.interpolation +# ^^^^^^ meta.string.shell meta.interpolation.brace.shell + any --arg{1,2,3}={1,2,3} # ^^^^^ meta.parameter.option.shell variable.parameter.option.shell - meta.interpolation # ^^^^^^^ meta.function-call.arguments.shell meta.parameter.option.shell meta.interpolation.brace.shell - variable.parameter # ^ keyword.operator.assignment.shell # ^^^^^^^ meta.string.shell meta.interpolation.brace.shell +any --arg{1,2,3} ={1,2,3} +# ^^^^^ meta.parameter.option.shell variable.parameter.option.shell - meta.interpolation +# ^^^^^^^ meta.function-call.arguments.shell meta.parameter.option.shell meta.interpolation.brace.shell - variable.parameter +# ^ meta.string.shell string.unquoted.shell - meta.interpolation +# ^^^^^^^ meta.string.shell meta.interpolation.brace.shell + # invalid brace expansions due to whitespace : {} {*} {1} {a} {foo} {'bar'} {"baz"} @@ -3755,59 +3816,59 @@ any --arg{1,2,3}={1,2,3} ############################################################################### : ~ # expand to $HOME -# ^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ meta.interpolation.tilde.shell variable.language.tilde.shell - string # ^ - meta.interpolation : ~/ # expand to $HOME -# ^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ meta.interpolation.tilde.shell variable.language.tilde.shell - string # ^ - meta.interpolation : ~+ # expand to current working dir -# ^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^^ meta.interpolation.tilde.shell variable.language.tilde.shell - string # ^ - meta.interpolation : ~+/ # expand to current working dir -# ^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^^ meta.interpolation.tilde.shell variable.language.tilde.shell - string # ^ - meta.interpolation : ~- # expand to previous working dir -# ^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^^ meta.interpolation.tilde.shell variable.language.tilde.shell - string # ^ - meta.interpolation : ~-/ # expand to previous working dir -# ^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^^ meta.interpolation.tilde.shell variable.language.tilde.shell - string # ^ - meta.interpolation : ~0 # expand to current working dir -# ^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^^ meta.interpolation.tilde.shell variable.language.tilde.shell - string # ^ - meta.interpolation : ~0/ # expand to current working dir -# ^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^^ meta.interpolation.tilde.shell variable.language.tilde.shell - string # ^ - meta.interpolation : ~1 # expand to previous working dir -# ^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^^ meta.interpolation.tilde.shell variable.language.tilde.shell - string # ^ - meta.interpolation : ~1/ # expand to previous working dir -# ^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^^ meta.interpolation.tilde.shell variable.language.tilde.shell - string # ^ - meta.interpolation : ~+0 # equivalent to ~+ -# ^^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^^^ meta.interpolation.tilde.shell variable.language.tilde.shell - string # ^ - meta.interpolation : ~+0/ # equivalent to ~+ -# ^^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^^^ meta.interpolation.tilde.shell variable.language.tilde.shell - string # ^ - meta.interpolation : ~+1 # top of directory stack -# ^^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^^^ meta.interpolation.tilde.shell variable.language.tilde.shell - string # ^ - meta.interpolation : ~+1/ # top of directory stack -# ^^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^^^ meta.interpolation.tilde.shell variable.language.tilde.shell - string # ^ - meta.interpolation : ~fred/foo* # The subdirectory foo of the home directory of the user fred @@ -3845,13 +3906,13 @@ ed/foo* # The subdirectory foo of the home directory of the user fred # ^ punctuation.section.interpolation.end.shell foo=~/~ -# ^ variable.language.tilde.shell -# ^ - variable +# ^ variable.language.tilde.shell - string +# ^^ string.unquoted.shell - variable foo=~/~${bar} -# ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string # ^^ meta.string.shell string.unquoted.shell - meta.interpolation -# ^^^^^^ meta.string.shell meta.interpolation.parameter.shell +# ^^^^^^ meta.string.shell meta.interpolation.parameter.shell - string # ^ - meta.string - meta.interpolation # ^ variable.language.tilde.shell # ^^ string.unquoted.shell @@ -3863,14 +3924,34 @@ foo=~/~${bar} foo=(~/~foo ~/~bar) # ^^^^^^^^^^^^^^^ meta.sequence.shell -# ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string # ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation - variable -# ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string # ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation - variable -cmd --foo=~/~bar -# ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell +cmd --foo=~/~bar --baz =~/~buz +# ^ keyword.operator.assignment.shell +# ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string # ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation - variable +# ^^^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation - keyword - variable + +cmd ~/f~oo b~ar -- ~/f~oo b~ar +# ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string +# ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation - variable +# ^^^^ meta.string.shell string.unquoted.shell - meta.interpolation - variable +# ^^ keyword.operator.end-of-options.shell +# ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string +# ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation - variable +# ^^^^ meta.string.shell string.unquoted.shell - meta.interpolation - variable + +echo ~/~foo ~/~foo # tilde expansions, but no path pattern support +# ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string +# ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation - variable +# ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string +# ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation - variable + +echo "~/~foo" # literal quoted string +# ^^^^^^^^ meta.function-call.arguments.shell meta.string.shell string.quoted.double.shell - meta.interpolation - variable test $me -eq ~/~foo # ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell @@ -3897,25 +3978,37 @@ test $me -eq ~/~foo # https://www.gnu.org/software/bash/manual/bash.html#Shell-Parameter-Expansion# ############################################################################### -: $__ -# ^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell -# ^ punctuation.definition.variable.shell -# ^ - meta.interpolation - variable +$__ $__ +# <- meta.function-call.identifier.shell meta.path.shell meta.interpolation.parameter.shell variable.other.readwrite.shell punctuation.definition.variable.shell +#^^ meta.function-call.identifier.shell meta.path.shell meta.interpolation.parameter.shell variable.other.readwrite.shell - variable variable +# ^ meta.function-call.arguments.shell - meta.string - meta.interpolation - variable +# ^^^ meta.function-call.arguments.shell meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^ punctuation.definition.variable.shell +# ^ - meta.function-call - meta.string - meta.interpolation - variable -: $var_0 -# ^^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell -# ^ punctuation.definition.variable.shell -# ^ - meta.interpolation - variable +$var_0 $var_0 +# <- meta.function-call.identifier.shell meta.path.shell meta.interpolation.parameter.shell variable.other.readwrite.shell punctuation.definition.variable.shell +#^^^^^ meta.function-call.identifier.shell meta.path.shell meta.interpolation.parameter.shell variable.other.readwrite.shell - variable variable +# ^ meta.function-call.arguments.shell - meta.string - meta.interpolation - variable +# ^^^^^^ meta.function-call.arguments.shell meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^ punctuation.definition.variable.shell +# ^ - meta.function-call - meta.string - meta.interpolation - variable -: $_var0 -# ^^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell -# ^ punctuation.definition.variable.shell -# ^ - meta.interpolation - variable +$_var0 $_var0 +# <- meta.function-call.identifier.shell meta.path.shell meta.interpolation.parameter.shell variable.other.readwrite.shell punctuation.definition.variable.shell +#^^^^^ meta.function-call.identifier.shell meta.path.shell meta.interpolation.parameter.shell variable.other.readwrite.shell - variable variable +# ^ meta.function-call.arguments.shell - meta.string - meta.interpolation - variable +# ^^^^^^ meta.function-call.arguments.shell meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^ punctuation.definition.variable.shell +# ^ - meta.function-call - meta.string - meta.interpolation - variable -: $_0var_ -# ^^^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell -# ^ punctuation.definition.variable.shell -# ^ - meta.interpolation - variable +$_0var_ $_0var_ +# <- meta.function-call.identifier.shell meta.path.shell meta.interpolation.parameter.shell variable.other.readwrite.shell punctuation.definition.variable.shell +#^^^^^^ meta.function-call.identifier.shell meta.path.shell meta.interpolation.parameter.shell variable.other.readwrite.shell - variable variable +# ^ meta.function-call.arguments.shell - meta.string - meta.interpolation - variable +# ^^^^^^^ meta.function-call.arguments.shell meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^ punctuation.definition.variable.shell +# ^ - meta.function-call - meta.string - meta.interpolation - variable ################################ @@ -5600,7 +5693,7 @@ a\/b/c/d} : ${var//f|o/b|ar} # `|` has no meaing in patterns or replacement strings # ^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell # ^^ keyword.operator.substitution.shell -# ^^^ meta.string.regexp.shell - keyword - punctuation +# ^^^ meta.string.regexp.shell string.unquoted.shell - keyword - punctuation # ^ keyword.operator.substitution.shell # ^^^^ meta.string.shell string.unquoted.shell - keyword - punctuation # ^ punctuation.section.interpolation.end.shell @@ -5608,7 +5701,7 @@ a\/b/c/d} : ${var//f&o/b&ar} # `&` has no meaing in patterns or replacement strings # ^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell # ^^ keyword.operator.substitution.shell -# ^^^ meta.string.regexp.shell - keyword - punctuation +# ^^^ meta.string.regexp.shell string.unquoted.shell - keyword - punctuation # ^ keyword.operator.substitution.shell # ^^^^ meta.string.shell string.unquoted.shell - keyword - punctuation # ^ punctuation.section.interpolation.end.shell @@ -5616,7 +5709,7 @@ a\/b/c/d} : ${var//f>o/b>ar} # `>` has no meaing in patterns or replacement strings # ^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell # ^^ keyword.operator.substitution.shell -# ^^^ meta.string.regexp.shell - keyword - punctuation +# ^^^ meta.string.regexp.shell string.unquoted.shell - keyword - punctuation # ^ keyword.operator.substitution.shell # ^^^^ meta.string.shell string.unquoted.shell - keyword - punctuation # ^ punctuation.section.interpolation.end.shell @@ -5624,7 +5717,7 @@ a\/b/c/d} : ${var//f out~put- # ^^ meta.redirection.shell - meta.path -# ^^^^^^^^ meta.redirection.shell meta.path.shell +# ^^^^^^^^ meta.redirection.shell # ^ keyword.operator.assignment.redirection.shell # ^ - variable # ^ - punctuation > ~/.local/file # ^^ meta.redirection.shell - meta.path -# ^ meta.redirection.shell meta.path.shell meta.string.shell meta.interpolation.tilde.shell -# ^^^^^^^^^^^^ meta.redirection.shell meta.path.shell meta.string.shell string.unquoted.shell - meta.interpolation +# ^ meta.redirection.shell meta.string.shell meta.interpolation.tilde.shell +# ^^^^^^^^^^^^ meta.redirection.shell meta.string.shell string.unquoted.shell - meta.interpolation # ^ keyword.operator.assignment.redirection.shell # ^ variable.language.tilde.shell -# ^ punctuation.separator.path.shell -# ^ punctuation.separator.path.shell > "~/.local/file" # ^^ meta.redirection.shell - meta.path -# ^^^^^^^^^^^^^^^ meta.redirection.shell meta.path.shell meta.string.shell string.quoted.double.shell +# ^^^^^^^^^^^^^^^ meta.redirection.shell meta.string.shell string.quoted.double.shell # ^ keyword.operator.assignment.redirection.shell # ^ punctuation.definition.string.begin.shell # ^ - variable.language -# ^ punctuation.separator.path.shell -# ^ punctuation.separator.path.shell # ^ punctuation.definition.string.end.shell > "~/.local/file" @@ -8277,25 +8385,25 @@ foo | bar --opt1 arg1 < file.txt # ^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell # ^^ meta.redirection.shell - meta.path # ^ keyword.operator.assignment.redirection.shell -# ^^^^^^^^ meta.redirection.shell meta.path.shell +# ^^^^^^^^ meta.redirection.shell foo | bar --opt1 arg1 > file.txt # ^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell # ^^ meta.redirection.shell - meta.path # ^ keyword.operator.assignment.redirection.shell -# ^^^^^^^^ meta.redirection.shell meta.path.shell +# ^^^^^^^^ meta.redirection.shell foo -x arg1 &>/dev/null # ^^^^^^^^^ meta.function-call.arguments.shell - meta.redirection # ^^ meta.function-call.arguments.shell meta.redirection.shell - meta.path # ^^ keyword.operator.assignment.redirection.shell -# ^^^^^^^^^ meta.function-call.arguments.shell meta.redirection.shell meta.path.shell +# ^^^^^^^^^ meta.function-call.arguments.shell meta.redirection.shell foo -x arg1 &> /dev/null # ^^^^^^^^^ meta.function-call.arguments.shell - meta.redirection # ^^^ meta.function-call.arguments.shell meta.redirection.shell - meta.path # ^^ keyword.operator.assignment.redirection.shell -# ^^^^^^^^^ meta.function-call.arguments.shell meta.redirection.shell meta.path.shell +# ^^^^^^^^^ meta.function-call.arguments.shell meta.redirection.shell # ^ - meta.function tr "o" "a" < <(echo "Foo") @@ -8348,7 +8456,7 @@ LC_ALL=C 2> /dev/null # ^^^ meta.redirection.shell - meta.path # ^ meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell # ^ keyword.operator.assignment.redirection -# ^^^^^^^^^ meta.redirection.shell meta.path.shell - variable +# ^^^^^^^^^ meta.redirection.shell - variable 2>&1 echo foo # <- meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell @@ -8664,6 +8772,19 @@ alias foo=bar # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell +alias foo=bar -p 7za=qux +# <- meta.declaration.alias.shell keyword.declaration.alias.shell +#^^^^ meta.declaration.alias.shell +# ^^^^^^^^^^^^^^^^^^^ meta.declaration.alias.arguments.shell +# ^ - meta.declaration.alias +# ^^^ meta.variable.shell entity.name.function.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^^ meta.variable.shell entity.name.function.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell + alias -p foo=bar 7za=qux # <- meta.declaration.alias.shell keyword.declaration.alias.shell #^^^^ meta.declaration.alias.shell @@ -8827,6 +8948,20 @@ declare -a owners=( # ^^^^^ meta.declaration.variable.arguments.shell meta.sequence.shell meta.string.shell string.unquoted.shell ) +declare -f = +# <- meta.declaration.variable.shell keyword.declaration.variable.shell +#^^^^^^ meta.declaration.variable.shell keyword.declaration.variable.shell +# ^^^^^ meta.declaration.variable.arguments.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^ entity.name.function.shell + +declare -f ==cmd +# <- meta.declaration.variable.shell keyword.declaration.variable.shell +#^^^^^^ meta.declaration.variable.shell keyword.declaration.variable.shell +# ^^^^^^^^^ meta.declaration.variable.arguments.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^^^^ entity.name.function.shell + declare -f _init_completion > /dev/null && complete -F _upto upto # <- meta.declaration.variable.shell keyword.declaration.variable.shell #^^^^^^ meta.declaration.variable.shell @@ -8837,7 +8972,7 @@ declare -f _init_completion > /dev/null && complete -F _upto upto # ^ - meta.function-call #^^^^^^ keyword.declaration.variable.shell # ^^ variable.parameter.option.shell -# ^^^^^^^^^^^^^^^^ meta.variable.shell variable.function.shell +# ^^^^^^^^^^^^^^^^ meta.variable.shell entity.name.function.shell # ^ keyword.operator.assignment.redirection.shell # ^^ keyword.operator.logical.shell # ^^^^^^^^ variable.function.shell @@ -8960,7 +9095,7 @@ exec git diff-index --check --cached $against -- exec "$cmd" \ #^^^ meta.function-call.identifier.shell # ^ meta.function-call.arguments.shell -# ^^^^^^ meta.function-call.identifier.shell meta.path.shell +# ^^^^^^ meta.function-call.identifier.shell # ^^^ meta.function-call.arguments.shell # ^ punctuation.separator.continuation.line.shell # ^ - punctuation @@ -8990,7 +9125,7 @@ exec \ -la name \ "$cmd" \ #^ meta.function-call.arguments.shell -# ^^^^^^ meta.function-call.identifier.shell meta.path.shell +# ^^^^^^ meta.function-call.identifier.shell # ^^^ meta.function-call.arguments.shell # ^ punctuation.separator.continuation.line.shell # ^ - punctuation @@ -9070,7 +9205,21 @@ export -f foo #^^^^^ meta.function-call.identifier.shell support.function.export.shell # ^^^^^^^ meta.function-call.arguments.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell -# ^^^ meta.variable.shell variable.function.shell +# ^^^ meta.variable.shell entity.name.function.shell + +export -f = +# <- meta.function-call.identifier.shell support.function.export.shell +#^^^^^ meta.function-call.identifier.shell support.function.export.shell +# ^^^^^ meta.function-call.arguments.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^ meta.variable.shell entity.name.function.shell + +export -f ==cmd +# <- meta.function-call.identifier.shell support.function.export.shell +#^^^^^ meta.function-call.identifier.shell support.function.export.shell +# ^^^^^^^^^ meta.function-call.arguments.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^^^^ meta.variable.shell entity.name.function.shell export PATH="$PATH:$HOME/.local/bin" # ^^^^ meta.function-call.identifier.shell support.function.export.shell @@ -9087,15 +9236,28 @@ export PATH="$PATH:$HOME/.local/bin" # ^^^^^^^^^^^^ string.quoted.double # ^ punctuation.definition.string.end +# tilde expansion in unquoted strings +export PATH=$PATH:~/.local/bin +# ^^^^ meta.function-call.identifier.shell support.function.export.shell +# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell +# ^^^^ meta.variable variable.other.readwrite +# ^ keyword.operator.assignment +# ^^^^^^^^^^^^^^^^^^ meta.string.shell +# ^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^ meta.interpolation.tilde.shell variable.language.tilde.shell + +# no tilde expansion in quoted strings export PATH="$PATH:~/.local/bin" # ^^^^ meta.function-call.identifier.shell support.function.export.shell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell # ^^^^ meta.variable variable.other.readwrite # ^ keyword.operator.assignment -# ^ string.quoted.double punctuation.definition.string.begin -# ^^^^^ meta.interpolation.parameter variable.other.readwrite -# ^ punctuation.definition.variable -# ^ string.quoted.double punctuation.separator.sequence -# ^ punctuation.definition.string.end +# ^^^^^^^^^^^^^^^^^^^^ meta.string.shell +# ^ punctuation.definition.string.begin.shell +# ^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^ punctuation.separator.sequence.shell +# ^ - variable +# ^ punctuation.definition.string.end.shell export SOMETHING='/etc/test:/var/test:../foo:./foo' # ^^^^ meta.function-call.identifier.shell support.function.export.shell @@ -9214,14 +9376,18 @@ local -fn foo #^^^^ meta.declaration.variable.shell keyword.declaration.variable.shell # ^^^^^^^^ meta.declaration.variable.arguments.shell # ^^^ meta.parameter.option.shell variable.parameter.option.shell -# ^^^ meta.variable.shell variable.function.shell +# ^^^ meta.variable.shell entity.name.function.shell f() { local -a "$@" + #^^^^ meta.declaration.variable.shell keyword.declaration.variable.shell + # ^^^^^^^^ meta.declaration.variable.arguments.shell # <- keyword.declaration.variable.shell #^^^^ keyword.declaration.variable.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell - # ^^^^ meta.string.shell + # ^ meta.variable.shell variable.other.readwrite.shell punctuation.definition.quoted.begin.shell + # ^^ meta.variable.shell meta.interpolation.parameter.shell variable.language.shell + # ^ meta.variable.shell variable.other.readwrite.shell punctuation.definition.quoted.end.shell local x # <- keyword.declaration.variable.shell #^^^^ keyword.declaration.variable.shell @@ -9323,7 +9489,7 @@ typeset -f _init_completion > /dev/null && complete -F _upto upto # ^ - meta.function-call #^^^^^^ keyword.declaration.variable.shell # ^^ variable.parameter.option.shell -# ^^^^^^^^^^^^^^^^ meta.variable.shell variable.function.shell +# ^^^^^^^^^^^^^^^^ meta.variable.shell entity.name.function.shell # ^ keyword.operator.assignment.redirection.shell # ^^ keyword.operator.logical.shell # ^^^^^^^^ variable.function.shell @@ -9400,6 +9566,7 @@ test var[0] != var[^0-9]*$ #^^^ meta.function-call.identifier.shell support.function.test.shell # ^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell # ^^^^^^ meta.string.shell string.unquoted.shell +# ^^^ meta.set.regexp.shell # ^^ keyword.operator.comparison.shell # ^^^^^^^^^^^ meta.string.shell string.unquoted.shell - meta.string.regexp @@ -9408,7 +9575,7 @@ test $var[0] != var[^0-9]*$ #^^^ meta.function-call.identifier.shell support.function.test.shell # ^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell # ^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell -# ^^^ - meta.interpolation - meta.item-access - punctuation +# ^^^ meta.set.regexp.shell # ^^ keyword.operator.comparison.shell # ^^^^^^^^^^^ meta.string.shell string.unquoted.shell - meta.string.regexp @@ -9557,7 +9724,7 @@ let "$var != test -z '$5' && cmd" # ^^ keyword.operator.comparison.shell # ^^^^ support.function.test.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell -# ^^^^ string.quoted.single.shell +# ^^^^ meta.string.shell string.quoted.single.shell - variable # ^^ keyword.operator.logical.shell # ^^^ - variable.function # ^ string.quoted.double.shell punctuation.definition.string.end.shell @@ -9583,7 +9750,7 @@ unalias foo # ^^^^ meta.function-call.arguments.shell # ^ - meta.function # ^ - meta.variable - variable -# ^^^ entity.name.function.shell +# ^^^ variable.function.shell # ^ - meta.variable - variable unalias foo # comment @@ -9592,7 +9759,7 @@ unalias foo # comment # ^^^^ meta.function-call.arguments.shell # ^^^^^^^^^^ - meta.function # ^ - meta.variable - variable -# ^^^ entity.name.function.shell +# ^^^ variable.function.shell # ^ - meta.variable - variable # ^^^^^^^^^^ comment.line.number-sign.shell @@ -9608,16 +9775,14 @@ unset foo b'a'r ba${z} # 'foo' and 'bar' are variable names #^^^^ meta.function-call.identifier.shell # ^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell # ^ - meta.function-call -# ^ meta.variable.shell - meta.string -# ^^^ meta.variable.shell meta.string.shell -# ^ meta.variable.shell - meta.string +# ^^^^^ meta.variable.shell #^^^^ support.function.unset.shell # ^ - meta.variable - support - variable # ^^^ meta.variable.shell variable.other.readwrite.shell # ^ - meta.variable - variable # ^^^^^ variable.other.readwrite.shell -# ^ punctuation.definition.string.begin.shell -# ^ punctuation.definition.string.end.shell +# ^ punctuation.definition.quoted.begin.shell +# ^ punctuation.definition.quoted.end.shell # ^ - meta.variable - variable # ^^ meta.variable.shell - meta.interpolation # ^^^^ meta.variable.shell meta.interpolation.parameter.shell @@ -9625,16 +9790,24 @@ unset foo b'a'r ba${z} # 'foo' and 'bar' are variable names # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell unset -n -unset -nfv foo +unset -nfv foo = == ==cmd cmd=name # <- meta.function-call.identifier.shell support.function.unset.shell #^^^^ meta.function-call.identifier.shell -# ^^^^^^^^^ meta.function-call.arguments.shell -# ^ - meta.function-call +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell +# ^ - meta.function-call #^^^^ support.function.unset.shell # ^^^^ meta.parameter.option.shell variable.parameter.option.shell # ^ - variable # ^^^ variable.function.shell # ^ - variable +# ^ variable.function.shell +# ^ - variable +# ^^ variable.function.shell +# ^ - variable +# ^^^^^ variable.function.shell +# ^ - variable +# ^^^^^^^^ variable.function.shell +# ^ - variable unset -f -n -v foo b'a'r; unset -vn foo 2>& /dev/null # <- meta.function-call.identifier.shell support.function.unset.shell @@ -9644,9 +9817,6 @@ unset -f -n -v foo b'a'r; unset -vn foo 2>& /dev/null # ^^^^^ meta.function-call.identifier.shell # ^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell # ^ - meta.function-call -# ^ - meta.string -# ^^^ meta.string.shell -# ^ - meta.string # ^^ meta.parameter.option.shell variable.parameter.option.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell @@ -9654,6 +9824,8 @@ unset -f -n -v foo b'a'r; unset -vn foo 2>& /dev/null # ^^^ variable.function.shell # ^ - variable # ^^^^^ variable.function.shell +# ^ punctuation.definition.quoted.begin.shell +# ^ punctuation.definition.quoted.end.shell # ^ punctuation.terminator.statement.shell # ^^^^^ support.function.unset.shell # ^ - support - variable @@ -10290,4 +10462,4 @@ fi # <- keyword.control.conditional.end.shell curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | POETRY_PREVIEW=1 python -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments - punctuation.separator +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell string.unquoted.shell diff --git a/ShellScript/tools/update-commands.py b/ShellScript/tools/update-commands.py index e7c356f6db..ab6d49496f 100644 --- a/ShellScript/tools/update-commands.py +++ b/ShellScript/tools/update-commands.py @@ -19,11 +19,11 @@ def main(): cmd_args = [{"meta_content_scope": "meta.function-call.arguments.shell"}] + cmd_args.append({"include": "cmd-args-end"}) + allow_eoo = value.get("allow-end-of-options-token", True) if allow_eoo: - cmd_args.append({"include": "cmd-args-boilerplate-with-end-of-options"}) - else: - cmd_args.append({"include": "cmd-args-boilerplate"}) + cmd_args.append({"include": "cmd-args-end-of-options-then-ambigious"}) long_options = value.get("long-options") if long_options: @@ -63,9 +63,7 @@ def main(): } }) - allow_numeric_args = value.get("allow-numeric-args") - if allow_numeric_args: - cmd_args.append({"include": "numbers"}) + cmd_args.append({"include": "cmd-args-values"}) contexts[f"cmd-{command}-args"] = cmd_args From 7d69e14b384a79e156d3b0a0651c8afc0fb88897 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 21 Jul 2024 15:40:41 +0200 Subject: [PATCH 014/113] [ShellScript] Reorganize literals --- ShellScript/Bash.sublime-syntax | 146 ++++++++++++++++---------------- 1 file changed, 72 insertions(+), 74 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 026884a65e..05608f1af0 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -1547,80 +1547,6 @@ contexts: pop: 1 - include: expressions -###[ CONSTANTS ]############################################################### - - booleans: - - match: false\b - scope: constant.language.boolean.false.shell - - match: true\b - scope: constant.language.boolean.true.shell - - boolean: - - match: false\b - scope: constant.language.boolean.false.shell - pop: 1 - - match: true\b - scope: constant.language.boolean.true.shell - pop: 1 - - numbers: - # A leading ‘0x’ or ‘0X’ denotes hexadecimal. - - match: \b(0[xX])(\h*) - scope: meta.number.integer.hexadecimal.shell - captures: - 1: constant.numeric.base.shell - 2: constant.numeric.value.shell - # Constants with a leading 0 are interpreted as octal numbers. - - match: \b(0)([0-7]+) - scope: meta.number.integer.octal.shell - captures: - 1: constant.numeric.base.shell - 2: constant.numeric.value.shell - # Otherwise, numbers take the form [base#]n, where the optional base is a - # decimal number between 2 and 64 representing the arithmetic base, and n is - # a number in that base. When specifying n, the digits greater than 9 are - # represented by the lowercase letters, the uppercase letters, ‘@’, and ‘_’, - # in that order. - - match: \b(\d+#)([a-zA-Z0-9@_]+) - scope: meta.number.integer.other.shell - captures: - 1: constant.numeric.base.shell - 2: constant.numeric.value.shell - # If base# is omitted, then base 10 is used. - - match: \b\d+(?![.\w]) - scope: meta.number.integer.decimal.shell constant.numeric.value.shell - - number: - # Note: Leading sign is scoped as operator for consistent highlighting as - # we can't distinguish operators from sign for sure everywhere. - - match: ([-+]?)(0[xX])(\h*){{word_break}} - scope: meta.number.integer.hexadecimal.shell - captures: - 1: keyword.operator.arithmetic.shell - 2: constant.numeric.base.shell - 3: constant.numeric.value.shell - pop: 1 - - match: ([-+]?)(0)([0-7]+){{word_break}} - scope: meta.number.integer.octal.shell - captures: - 1: keyword.operator.arithmetic.shell - 2: constant.numeric.base.shell - 3: constant.numeric.value.shell - pop: 1 - - match: ([-+]?)(\d+#)([a-zA-Z0-9@_]+){{word_break}} - scope: meta.number.integer.other.she - captures: - 1: keyword.operator.arithmetic.shell - 2: constant.numeric.base.shell - 3: constant.numeric.value.shell - # If base# is omitted, then base 10 is used. - - match: ([-+]?)(\d+){{word_break}} - scope: meta.number.integer.decimal.shell - captures: - 1: keyword.operator.arithmetic.shell - 2: constant.numeric.value.shell - pop: 1 - ###[ OPERATORS ]############################################################### line-continuations: @@ -2584,6 +2510,78 @@ contexts: ###[ LITERALS ]################################################################ + booleans: + - match: false\b + scope: constant.language.boolean.false.shell + - match: true\b + scope: constant.language.boolean.true.shell + + boolean: + - match: false\b + scope: constant.language.boolean.false.shell + pop: 1 + - match: true\b + scope: constant.language.boolean.true.shell + pop: 1 + + numbers: + # A leading ‘0x’ or ‘0X’ denotes hexadecimal. + - match: \b(0[xX])(\h*) + scope: meta.number.integer.hexadecimal.shell + captures: + 1: constant.numeric.base.shell + 2: constant.numeric.value.shell + # Constants with a leading 0 are interpreted as octal numbers. + - match: \b(0)([0-7]+) + scope: meta.number.integer.octal.shell + captures: + 1: constant.numeric.base.shell + 2: constant.numeric.value.shell + # Otherwise, numbers take the form [base#]n, where the optional base is a + # decimal number between 2 and 64 representing the arithmetic base, and n is + # a number in that base. When specifying n, the digits greater than 9 are + # represented by the lowercase letters, the uppercase letters, ‘@’, and ‘_’, + # in that order. + - match: \b(\d+#)([a-zA-Z0-9@_]+) + scope: meta.number.integer.other.shell + captures: + 1: constant.numeric.base.shell + 2: constant.numeric.value.shell + # If base# is omitted, then base 10 is used. + - match: \b\d+(?![.\w]) + scope: meta.number.integer.decimal.shell constant.numeric.value.shell + + number: + # Note: Leading sign is scoped as operator for consistent highlighting as + # we can't distinguish operators from sign for sure everywhere. + - match: ([-+]?)(0[xX])(\h*){{word_break}} + scope: meta.number.integer.hexadecimal.shell + captures: + 1: keyword.operator.arithmetic.shell + 2: constant.numeric.base.shell + 3: constant.numeric.value.shell + pop: 1 + - match: ([-+]?)(0)([0-7]+){{word_break}} + scope: meta.number.integer.octal.shell + captures: + 1: keyword.operator.arithmetic.shell + 2: constant.numeric.base.shell + 3: constant.numeric.value.shell + pop: 1 + - match: ([-+]?)(\d+#)([a-zA-Z0-9@_]+){{word_break}} + scope: meta.number.integer.other.she + captures: + 1: keyword.operator.arithmetic.shell + 2: constant.numeric.base.shell + 3: constant.numeric.value.shell + # If base# is omitted, then base 10 is used. + - match: ([-+]?)(\d+){{word_break}} + scope: meta.number.integer.decimal.shell + captures: + 1: keyword.operator.arithmetic.shell + 2: constant.numeric.value.shell + pop: 1 + literal-unquoted-content: - match: \$?\" scope: punctuation.definition.quoted.begin.shell From 5e244330d9544bc8559e52ece70219d0fb97aee4 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Fri, 10 May 2024 18:14:38 +0200 Subject: [PATCH 015/113] [ShellScript] Special echo treatment Everything between options and end of command is a string, regardless quotation. This commit therefore introduces special contexts for `echo` builtin. --- ShellScript/Bash.sublime-syntax | 25 +++++++++++++++++++ ...commands-builtin-shell-bash.sublime-syntax | 11 -------- ShellScript/commands-builtin-shell-bash.yml | 3 +-- ShellScript/test/syntax_test_bash.sh | 17 +++++++++++-- 4 files changed, 41 insertions(+), 15 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 05608f1af0..c8c114c42b 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -115,6 +115,7 @@ contexts: - include: cmd-alias - include: cmd-arithmetic - include: cmd-compound + - include: cmd-echo - include: cmd-historic - include: cmd-sudo - include: cmd-test @@ -571,6 +572,30 @@ contexts: captures: 1: punctuation.definition.parameter.shell +###[ ECHO BUILTINS ]########################################################### + + cmd-echo: + - match: echo{{cmd_break}} + scope: + meta.function-call.identifier.shell + support.function.echo.shell + push: cmd-echo-args + + cmd-echo-args: + - meta_content_scope: meta.function-call.arguments.shell + - include: eoc-pop + - match: ([-+])[neE]+{{opt_break}} + scope: meta.parameter.option.shell variable.parameter.option.shell + captures: + 1: punctuation.definition.parameter.shell + - match: (?=\S) + set: cmd-echo-string + + cmd-echo-string: + - meta_content_scope: meta.function-call.arguments.shell + - include: cmd-args-end + - include: string-path-patterns + ###[ EXEC BUILTINS ]########################################################### cmd-exec: diff --git a/ShellScript/commands-builtin-shell-bash.sublime-syntax b/ShellScript/commands-builtin-shell-bash.sublime-syntax index 306dec7338..b2f7e01871 100644 --- a/ShellScript/commands-builtin-shell-bash.sublime-syntax +++ b/ShellScript/commands-builtin-shell-bash.sublime-syntax @@ -87,9 +87,6 @@ contexts: - match: umask{{cmd_break}} scope: meta.function-call.identifier.shell support.function.umask.shell push: cmd-umask-args - - match: echo{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.echo.shell - push: cmd-echo-args - match: set{{cmd_break}} scope: meta.function-call.identifier.shell support.function.set.shell push: cmd-set-args @@ -330,14 +327,6 @@ contexts: 1: punctuation.definition.parameter.shell push: cmd-args-option-maybe-value - include: cmd-args-values - cmd-echo-args: - - meta_content_scope: meta.function-call.arguments.shell - - include: cmd-args-end - - match: ([-+])[neE]+ - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - - include: cmd-args-values cmd-set-args: - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end diff --git a/ShellScript/commands-builtin-shell-bash.yml b/ShellScript/commands-builtin-shell-bash.yml index 3d5dbe0dc4..a545af921e 100644 --- a/ShellScript/commands-builtin-shell-bash.yml +++ b/ShellScript/commands-builtin-shell-bash.yml @@ -104,8 +104,7 @@ umask: # "unset" is handled in the syntax def, don't put it here! -echo: - short-options-compact: neE +# "echo" is handled in the syntax def, don't put it here! set: short-options-compact: abefhkmnptuvxBCEHPT diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index 923ec7b3e3..247730f6c5 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -179,8 +179,8 @@ echo 'singe\' \\'' # ^^^^^^^^ meta.string.shell string.quoted.single.shell - string.unquoted # ^ punctuation.definition.string.begin.shell # ^^ - constant -# ^ - string -# ^^ constant.character.escape.shell - string.quoted +# ^^ meta.string.shell string.unquoted.shell - string.quoted +# ^^ constant.character.escape.shell # ^^ meta.string.shell string.quoted.single.shell - string.unquoted # ^ - meta.string - string @@ -206,6 +206,19 @@ echo -e "\e[33mcolored text\e[0m uncolored" # ^^^^^^ constant.character.escape.color.shell # ^^^^^ constant.character.escape.color.shell +echo -e -a -n <1 ! # unknown options start printed text +#^^^ meta.function-call.identifier.shell support.function.echo.shell +# ^^^^^^^^^ meta.function-call.arguments.shell +# ^^ variable.parameter.option.shell +# ^^ meta.string.shell string.unquoted.shell +# ^^ meta.string.shell string.unquoted.shell +# ^^ meta.redirection.shell +# ^ keyword.operator.assignment.redirection.shell +# ^ meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ meta.string.shell string.unquoted.shell +# ^ - meta.function-call - comment +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell + echo $'Hello\' World\\' # ^^^^^^^^^^^^^^^^^^ meta.string.shell string.quoted.single.shell # ^^ punctuation.definition.string.begin.shell From 5cfa0238c79dbdd768830662689dc772c99ccb77 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 14 Jul 2024 10:38:03 +0200 Subject: [PATCH 016/113] [ShellScript] Tweak builtin test command arguments This commit... 1. fixes [ command termination behavior - terminate at \n ; && or || as normal `test` builtin 2. prefers scoping < > as comparison operator as it is more likely to be valid than redirections. Note: May need further refinements 3. highlight unquoted ; illegal in [[ ... ]] compound test expressions 4. fixes word boundaries of strings withing test expressions --- ShellScript/Bash.sublime-syntax | 38 ++--- ShellScript/test/syntax_test_bash.sh | 245 +++++++++++++++++++++++---- 2 files changed, 232 insertions(+), 51 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index c8c114c42b..2b475d4141 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -772,26 +772,23 @@ contexts: support.function.test.shell push: cmd-test-args - cmd-test-args: - - meta_content_scope: meta.function-call.arguments.shell - - match: =~ - scope: invalid.illegal.operator.shell - - match: '!=|==?' - scope: keyword.operator.comparison.shell - - include: cmd-args-end - - include: test-expression-common - builtin-test-body: - meta_scope: meta.conditional.shell - match: '{{wspace}}(\])' captures: 1: support.function.test.end.shell pop: 1 - - match: =~ + - include: cmd-test-args + + cmd-test-args: + - meta_content_scope: meta.function-call.arguments.shell + - match: =~|[<>]= scope: invalid.illegal.operator.shell - match: '!=|==?' scope: keyword.operator.comparison.shell - - include: line-continuations + - match: '<(?!<)|>(?!>)' + scope: keyword.operator.comparison.shell + - include: cmd-args-end - include: test-expression-common compound-test-body: @@ -813,19 +810,23 @@ contexts: captures: 1: keyword.operator.comparison.shell push: compound-test-pattern + - match: '[<>]=?' + scope: keyword.operator.comparison.shell + - match: ; + scope: invalid.illegal.unexpected.shell - include: line-continuations - include: test-expression-common compound-test-eregexp: - meta_content_scope: meta.string.regexp.shell string.unquoted.shell - - match: (?=\s) + - match: (?=[\s;]) pop: 1 - include: line-continuations - include: eregexp-main-content compound-test-pattern: - meta_content_scope: meta.string.regexp.shell string.unquoted.shell - - match: (?=\s) + - match: (?=[\s;]) pop: 1 - include: line-continuations - include: pattern-main-content @@ -845,6 +846,10 @@ contexts: captures: 1: keyword.operator.comparison.shell push: compound-test-group-pattern + - match: '[<>]=?' + scope: keyword.operator.comparison.shell + - match: ; + scope: invalid.illegal.unexpected.shell - include: line-continuations - include: test-expression-common @@ -859,9 +864,6 @@ contexts: - include: pattern-group-content compound-test-group-pattern-end: - - match: \) - scope: punctuation.section.group.end.shell - pop: 2 - match: '{{wspace}}(\]\])' captures: 1: invalid.illegal.unexpected-token.shell @@ -869,7 +871,7 @@ contexts: - match: $\n? scope: invalid.illegal.unexpected-token.shell pop: 3 - - match: (?=&&|\|\|) + - match: (?=\s*(?:&&|\|\||;|\))) pop: 1 - include: line-continuations @@ -882,8 +884,6 @@ contexts: 1: punctuation.definition.parameter.shell - match: ([-+])(?:ef|nt|ot|eq|ne|lt|le|gt|ge){{opt_break}}(?!\s*(=~|!=|==?)) scope: keyword.operator.comparison.shell - - match: '[<>]=?' - scope: keyword.operator.comparison.shell - match: '&&|\|\||!' scope: keyword.operator.logical.shell - include: comments diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index 247730f6c5..4a861c4583 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -1511,24 +1511,6 @@ if !cmd # <- variable.language.history.shell punctuation.definition.history.shell #^^ variable.language.history.shell -[ ] -# <- support.function.test.begin.shell -# ^ support.function.test.end.shell - -[ -] -# <- meta.conditional.shell support.function.test.end.shell - -! [ ] -# <- keyword.operator.logical.shell -# ^ support.function.test.begin.shell -# ^ support.function.test.end.shell - -![ ] -# <- punctuation.definition.history.shell -#^ support.function.test.begin.shell -# ^ support.function.test.end.shell - [[ ]] # <- support.function.test.begin.shell #^ support.function.test.begin.shell @@ -1672,7 +1654,8 @@ if [[ "$ERL_TOP" != ";"; ]];then;fi #^ keyword.control.conditional.if.shell # ^^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell # ^^^^^^^^^^^^^^^^^ - meta.string.regexp -# ^^^^ meta.string.regexp.shell +# ^^^ meta.string.regexp.shell +# ^ invalid.illegal.unexpected.shell - meta.string # ^^^ - meta.string.regexp # ^ punctuation.terminator.statement.shell # ^^^^ keyword.control.conditional.then.shell @@ -7569,8 +7552,8 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # <- meta.conditional.shell meta.group.shell meta.string.regexp.shell #^^ meta.conditional.shell meta.group.shell meta.string.regexp.shell - meta.set # ^^^^^^ meta.conditional.shell meta.group.shell meta.string.regexp.shell meta.set.regexp.shell -# ^^ meta.conditional.shell meta.group.shell meta.string.regexp.shell - meta.set -# ^ meta.conditional.shell meta.group.shell - meta.string.regexp +# ^ meta.conditional.shell meta.group.shell meta.string.regexp.shell - meta.set +# ^^ meta.conditional.shell meta.group.shell - meta.string.regexp # ^^^ meta.conditional.shell - meta.group # ^^ support.function.test.end.shell @@ -8067,8 +8050,8 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} [[ ( $foo =~ ^\ [^0-9]+ ) ]] # <- meta.conditional.shell meta.group.shell meta.string.regexp.shell -#^^^^^^^^^^ meta.conditional.shell meta.group.shell meta.string.regexp.shell -# ^ meta.conditional.shell meta.group.shell - meta.string.regexp +#^^^^^^^^^ meta.conditional.shell meta.group.shell meta.string.regexp.shell +# ^^ meta.conditional.shell meta.group.shell - meta.string.regexp # ^^^ meta.conditional.shell - meta.group # ^^ support.function.test.end.shell @@ -8126,8 +8109,8 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} [[ ( $foo =~ [\\\] ) ]] #^^ meta.conditional.shell - meta.group # ^^^^^^^^^^ meta.conditional.shell meta.group.shell - meta.string.regexp -# ^^^^^^ meta.conditional.shell meta.group.shell meta.string.regexp.shell -# ^ meta.conditional.shell meta.group.shell - meta.string.regexp +# ^^^^^ meta.conditional.shell meta.group.shell meta.string.regexp.shell +# ^^ meta.conditional.shell meta.group.shell - meta.string.regexp # ^^^ meta.conditional.shell - meta.group - meta.string.regexp # ^ - meta.conditional @@ -8240,17 +8223,23 @@ echo '([^.[:space:]]+) Class::method()' # colon not scoped as path separator [[ $foo =~ 'bar' || $foo =~ "baz" && $bar =~ baz ]] # <- meta.conditional.shell support.function.test.begin.shell #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell -# ^^^^ variable.other.readwrite.shell +# ^^^^ meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^^^^ - meta.string # ^^ keyword.operator.comparison.shell # ^^^^^ meta.string.regexp.shell +# ^^^^ - meta.string # ^^ keyword.operator.logical.shell -# ^^^^ variable.other.readwrite.shell +# ^^^^ meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^^^^ - meta.string # ^^ keyword.operator.comparison.shell # ^^^^^ meta.string.regexp.shell +# ^^^^ - meta.string # ^^ keyword.operator.logical.shell -# ^^^^ variable.other.readwrite.shell +# ^^^^ meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^^^^ - meta.string # ^^ keyword.operator.comparison.shell # ^^^ meta.string.regexp.shell +# ^^^^ - meta.string # ^^ support.function.test.end.shell [[ ( $foo =~ 'bar' || $foo =~ "baz" ) && $bar =~ baz ]] @@ -8258,21 +8247,111 @@ echo '([^.[:space:]]+) Class::method()' # colon not scoped as path separator #^^ meta.conditional.shell - meta.group # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell meta.group.shell # ^^^^^^^^^^^^^^^^^^ meta.conditional.shell - meta.group +#^^^^ - meta.string # ^ punctuation.section.group.begin.shell -# ^^^^ variable.other.readwrite.shell +# ^^^^ meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^^^^ - meta.string # ^^ keyword.operator.comparison.shell # ^^^^^ meta.string.regexp.shell +# ^^^^ - meta.string # ^^ keyword.operator.logical.shell -# ^^^^ variable.other.readwrite.shell +# ^^^^ meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^^^^ - meta.string # ^^ keyword.operator.comparison.shell # ^^^^^ meta.string.regexp.shell +# ^^^^^^ - meta.string # ^ punctuation.section.group.end.shell # ^^ keyword.operator.logical.shell -# ^^^^ variable.other.readwrite.shell +# ^^^^ meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^^^^ - meta.string # ^^ keyword.operator.comparison.shell # ^^^ meta.string.regexp.shell +# ^^^^ - meta.string # ^^ support.function.test.end.shell +[[ $foo =~ ; ]] # unquoted semicolons are illegal +# <- meta.conditional.shell support.function.test.begin.shell +#^^^^^^^^^^^^^^ meta.conditional.shell +# ^ - meta.conditional +# ^^ keyword.operator.comparison.shell +# ^ invalid.illegal.unexpected.shell +# ^^ support.function.test.end.shell + +[[ ( $foo =~ ; ) ]] # unquoted semicolons are illegal +# <- meta.conditional.shell support.function.test.begin.shell +#^^ meta.conditional.shell - meta.group +# ^^^^^^^^^^^^^ meta.conditional.shell meta.group.shell +# ^^^ meta.conditional.shell - meta.group +# ^ - meta.conditional +# ^^ keyword.operator.comparison.shell +# ^ invalid.illegal.unexpected.shell +# ^ punctuation.section.group.end.shell +# ^^ support.function.test.end.shell + +[[ $foo =~ (;) ]] # unquoted semicolons allowed in pattern groups +# <- meta.conditional.shell support.function.test.begin.shell +#^^^^^^^^^^ meta.conditional.shell - meta.group +# ^^^ meta.conditional.shell meta.string.regexp.shell meta.group.regexp.shell string.unquoted.shell +# ^^^ meta.conditional.shell - meta.group +# ^ - meta.conditional +# ^^ keyword.operator.comparison.shell +# ^ punctuation.section.group.begin.regexp.shell +# ^ punctuation.section.group.end.regexp.shell +# ^^ support.function.test.end.shell + +[[ ( $foo =~ (;) ) ]] # unquoted semicolons allowed in pattern groups +# <- meta.conditional.shell support.function.test.begin.shell +#^^ meta.conditional.shell - meta.group +# ^^^^^^^^^^ meta.conditional.shell meta.group.shell - meta.group meta.group +# ^^^ meta.conditional.shell meta.group.shell meta.string.regexp.shell meta.group.regexp.shell string.unquoted.shell +# ^ meta.conditional.shell meta.group.shell - meta.group meta.group +# ^^^ meta.conditional.shell - meta.group +# ^ - meta.conditional +# ^^ keyword.operator.comparison.shell +# ^ punctuation.section.group.begin.regexp.shell +# ^ punctuation.section.group.end.regexp.shell +# ^ punctuation.section.group.end.shell +# ^^ support.function.test.end.shell + +[[ $foo =~ \; ]] # escaped semicolons are allowed +# <- meta.conditional.shell support.function.test.begin.shell +#^^^^^^^^^^^^^^^ meta.conditional.shell +# ^ - meta.conditional +# ^^ keyword.operator.comparison.shell +# ^^ constant.character.escape.shell +# ^^ support.function.test.end.shell + +[[ ( $foo =~ \; ) ]] # escaped semicolons are allowed +# <- meta.conditional.shell support.function.test.begin.shell +#^^ meta.conditional.shell - meta.group +# ^^^^^^^^^^^^^^ meta.conditional.shell meta.group.shell +# ^^^ meta.conditional.shell - meta.group +# ^ - meta.conditional +# ^^ keyword.operator.comparison.shell +# ^^ constant.character.escape.shell +# ^ punctuation.section.group.end.shell +# ^^ support.function.test.end.shell + +[[ $foo =~ ";" ]] +# <- meta.conditional.shell support.function.test.begin.shell +#^^^^^^^^^^^^^^^^ meta.conditional.shell +# ^ - meta.conditional +# ^^ keyword.operator.comparison.shell +# ^^^ string +# ^^ support.function.test.end.shell + +[[ ( $foo =~ ";" ) ]] +# <- meta.conditional.shell support.function.test.begin.shell +#^^ meta.conditional.shell - meta.group +# ^^^^^^^^^^ meta.conditional.shell meta.group.shell - meta.string.regexp +# ^^^ meta.conditional.shell meta.group.shell meta.string.regexp.shell +# ^^ meta.conditional.shell meta.group.shell - meta.string +# ^^^ meta.conditional.shell - meta.group +# ^ - meta.conditional +# ^^ keyword.operator.comparison.shell +# ^ punctuation.section.group.end.shell +# ^^ support.function.test.end.shell + ############################################################################### # 3.6 Redirections # @@ -9572,7 +9651,33 @@ test str == "str" # ^^^^^^^^^^^^^ meta.function-call.arguments.shell # ^^^ meta.string.shell string.unquoted.shell # ^^ keyword.operator.comparison.shell -# ^^^^^ string.quoted.double.shell +# ^^^^^ meta.string.shell string.quoted.double.shell + +test str != "str" +#<- meta.function-call.identifier.shell support.function.test.shell +#^^^ meta.function-call.identifier.shell support.function.test.shell +# ^^^^^^^^^^^^^ meta.function-call.arguments.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^^ keyword.operator.comparison.shell +# ^^^^^ meta.string.shell string.quoted.double.shell + +test str < 'str' +# <- meta.function-call.identifier.shell support.function.test.shell +#^^^ meta.function-call.identifier.shell support.function.test.shell +# ^^^^^^^^^^^^ meta.function-call.arguments.shell +# ^ - meta.function-call +# ^^^ meta.string.shell string.unquoted.shell +# ^ keyword.operator.comparison.shell +# ^^^^^ meta.string.shell string.quoted.single.shell + +test str > str +# <- meta.function-call.identifier.shell support.function.test.shell +#^^^ meta.function-call.identifier.shell support.function.test.shell +# ^^^^^^^^^^ meta.function-call.arguments.shell +# ^ - meta.function-call +# ^^^ meta.string.shell string.unquoted.shell +# ^ keyword.operator.comparison.shell +# ^^^ meta.string.shell string.unquoted.shell test var[0] != var[^0-9]*$ #<- meta.function-call.identifier.shell support.function.test.shell @@ -9943,13 +10048,73 @@ sudo --reset-timestamp -n -f -- rm -rf ############################################################################### # 6.4 Bash Conditional Expressions # +# https://www.gnu.org/software/bash/manual/bash.html#Bash-Conditional-Expressions ############################################################################### +![ ] +# <- punctuation.definition.history.shell +#^ support.function.test.begin.shell +# ^ support.function.test.end.shell + +! [ ] +# <- keyword.operator.logical.shell +# ^ support.function.test.begin.shell +# ^ support.function.test.end.shell + [ ] # <- meta.conditional.shell support.function.test.begin.shell #^^^ meta.conditional.shell # ^ support.function.test.end.shell +[ +] +# <- - meta.conditional - support.function.test + +[ \ +] +# <- meta.conditional.shell support.function.test.end.shell + +[ # comment ] +# <- meta.conditional.shell support.function.test.begin.shell +#^ - meta.conditional - comment +# ^^^^^^^^^^^^ comment.line.number-sign.shell - meta.conditional + +[ ; cmd ] +# <- meta.conditional.shell support.function.test.begin.shell +#^^^^^^^^^ - meta.conditional +# ^ punctuation.terminator.statement.shell +# ^^^ variable.function.shell +# ^ string.unquoted.shell + +[ && cmd ] +# <- meta.conditional.shell support.function.test.begin.shell +#^^^^^^^^^^ - meta.conditional +# ^^ keyword.operator.logical.shell +# ^^^ variable.function.shell +# ^ string.unquoted.shell + +[ || cmd ] +# <- meta.conditional.shell support.function.test.begin.shell +#^^^^^^^^^^ - meta.conditional +# ^^ keyword.operator.logical.shell +# ^^^ variable.function.shell +# ^ string.unquoted.shell + +[ >>cmd ] +# <- meta.conditional.shell support.function.test.begin.shell +#^^^^^^^^ meta.conditional.shell +# ^^^^^ meta.redirection.shell +# ^^ keyword.operator.assignment.redirection.shell +# ^^^ string.unquoted.shell +# ^ support.function.test.end.shell + +[ <= str ] +# <- meta.conditional.shell support.function.test.begin.shell +#^^^^^^^^^^^^^ meta.conditional.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^^ invalid.illegal.operator.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ support.function.test.end.shell + +[ str <= str ] +# <- meta.conditional.shell support.function.test.begin.shell +#^^^^^^^^^^^^^ meta.conditional.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^^ invalid.illegal.operator.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ support.function.test.end.shell + [ str = str ] # <- meta.conditional.shell support.function.test.begin.shell #^^^^^^^^^^^^ meta.conditional.shell From 7b2fc8fa45b076ff236912a4aeb74283056d590a Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 14 Jul 2024 17:42:31 +0200 Subject: [PATCH 017/113] [ShellScript] Remove obsolete brace expansion contexts --- ShellScript/Bash.sublime-syntax | 134 +++++++------------------------- 1 file changed, 28 insertions(+), 106 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 2b475d4141..dd8d04b1ab 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -1626,105 +1626,6 @@ contexts: ###[ BRACE EXPANSIONS ]######################################################## - expansions-brace: - # use branching as valid brace expansions must not exceed word boundaries - - match: (?={) - branch_point: brace-expansion - branch: - - expansion-brace-sequence - - expansion-brace-series - - expansion-brace-fallback - - expansion-brace-sequence: - # sequence expression - - meta_include_prototype: false - - match: \{ - scope: - meta.interpolation.brace.shell - punctuation.section.interpolation.begin.shell - push: - - expansion-brace-sequence-body - - expansion-brace-sequence-begin - - expansion-brace-sequence-begin: - - match: \.\. - scope: keyword.operator.range.shell - pop: 1 - - include: line-continuations - - include: expansion-brace-sequence-content - - match: '' - fail: brace-expansion - - expansion-brace-sequence-body: - - meta_content_scope: meta.interpolation.brace.shell - - match: \.\. - scope: keyword.operator.range.shell - - include: expansion-brace-end - - include: expansion-brace-sequence-content - - match: '' - fail: brace-expansion - - expansion-brace-sequence-content: - - include: expansions-variables - - match: ([-+]?)(\d+) - scope: meta.number.integer.decimal.shell - captures: - 1: keyword.operator.arithmetic.shell - 2: constant.numeric.value.shell - - match: '[[:alpha:]]' - scope: constant.character.shell - - expansion-brace-series: - # series of comma-separated strings - - meta_include_prototype: false - - match: \{ - scope: - meta.interpolation.brace.shell - punctuation.section.interpolation.begin.shell - push: expansion-brace-series-begin - - expansion-brace-series-begin: - - meta_include_prototype: false - - meta_content_scope: - meta.interpolation.brace.shell - meta.string.shell string.unquoted.shell - - match: (?=\}) - fail: brace-expansion - - include: line-continuations - - include: expansion-brace-series-content - - expansion-brace-series-body: - - meta_include_prototype: false - - meta_content_scope: - meta.interpolation.brace.shell - meta.string.shell string.unquoted.shell - - include: expansion-brace-end - - include: expansion-brace-series-content - - expansion-brace-series-content: - - match: \, - scope: - meta.interpolation.brace.shell - punctuation.separator.sequence.shell - set: expansion-brace-series-body - - include: line-continuations - - include: pattern-main-content - - match: '{{word_break}}' - fail: brace-expansion - - expansion-brace-end: - - match: \} - scope: - meta.interpolation.brace.shell - punctuation.section.interpolation.end.shell - pop: 2 - - include: line-continuations - - expansion-brace-fallback: - - meta_include_prototype: false - - match: \{ - pop: 1 - brace-interpolations: # use branching as valid brace expansions must not exceed word boundaries - match: (?={) @@ -1732,7 +1633,7 @@ contexts: branch: - brace-interpolation-sequence - brace-interpolation-series - - expansion-brace-fallback + - brace-interpolation-fallback brace-interpolation-sequence: # sequence expression @@ -1751,16 +1652,24 @@ contexts: scope: keyword.operator.range.shell pop: 1 - include: line-continuations - - include: expansion-brace-sequence-content - - match: '' - fail: brace-interpolation + - include: brace-interpolation-sequence-content brace-interpolation-sequence-body: - meta_content_scope: meta.interpolation.brace.shell - match: \.\. scope: keyword.operator.range.shell - - include: expansion-brace-end - - include: expansion-brace-sequence-content + - include: brace-interpolation-end + - include: brace-interpolation-sequence-content + + brace-interpolation-sequence-content: + - include: expansions-variables + - match: ([-+]?)(\d+) + scope: meta.number.integer.decimal.shell + captures: + 1: keyword.operator.arithmetic.shell + 2: constant.numeric.value.shell + - match: '[[:alpha:]]' + scope: constant.character.shell - match: '' fail: brace-interpolation @@ -1789,7 +1698,7 @@ contexts: - meta_content_scope: meta.interpolation.brace.shell meta.string.shell string.unquoted.shell - - include: expansion-brace-end + - include: brace-interpolation-end - include: brace-interpolation-series-content brace-interpolation-series-content: @@ -1803,6 +1712,19 @@ contexts: - match: '{{word_break}}' fail: brace-interpolation + brace-interpolation-end: + - match: \} + scope: + meta.interpolation.brace.shell + punctuation.section.interpolation.end.shell + pop: 2 + - include: line-continuations + + brace-interpolation-fallback: + - meta_include_prototype: false + - match: \{ + pop: 1 + ###[ COMMAND EXPANSIONS ]###################################################### expansions-command: From 904edb6545ce26f3953c82b96568d1c8c6ee197e Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 20 Jul 2024 11:42:19 +0200 Subject: [PATCH 018/113] [ShellScript] Scope built-in variables This commit scopes all pre-defined built-in variables and distinguishes them from special variables such as `$0` or `$*`. Fixes an issue with `$_` vs. `$$_` highlighting. see: https://www.gnu.org/software/bash/manual/bash.html#Shell-Variables --- Makefile/syntax_test_makefile.mak | 2 +- ShellScript/Bash.sublime-syntax | 160 +++- ShellScript/test/syntax_test_bash.sh | 1012 +++++++++++++++++++------- 3 files changed, 886 insertions(+), 288 deletions(-) diff --git a/Makefile/syntax_test_makefile.mak b/Makefile/syntax_test_makefile.mak index 9077a36c2c..3a71cd77a8 100644 --- a/Makefile/syntax_test_makefile.mak +++ b/Makefile/syntax_test_makefile.mak @@ -1062,7 +1062,7 @@ foo: # ^^^^ support.function.echo.shell # ^ constant.character.escape.makefile # ^ punctuation.definition.variable.shell - # ^^^^^ variable.other.readwrite.shell + # ^^^^^ variable.language.builtin.shell test "$$abc" = "$$def" # ^ support.function.test.shell diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index dd8d04b1ab..9ef9af9e5a 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -47,7 +47,7 @@ first_line_match: |- ############################################################################### variables: - is_interpolation: (?=\$[({{{identifier_char}}{{builtin_variable}}]|`) + is_interpolation: (?=\$[({{{identifier_char}}{{special_variable}}]|`) # posix identifiers (alpha-numeric) identifier: '{{identifier_first_char}}{{identifier_char}}*' @@ -73,7 +73,131 @@ variables: word_char: '[^{{metachar}}]' # Shell Parameter Expansions - builtin_variable: '[$#@!*?_-]' + # https://www.gnu.org/software/bash/manual/bash.html#Shell-Variables + # Note: do not sort! order required to fully scope all variables + builtin_variable: |- + (?x: + _\b + | {{shell_variables}} + | CDPATH + | CHILD_MAX + | COLUMNS + | COMP_CWORD + | COMP_KEY + | COMP_LINE + | COMP_POINT + | COMP_TYPE + | COMP_WORDBREAKS + | COMP_WORDS + | COMPREPLY + | COPROC + | DIRSTACK + | EMACS + | ENV + | EPOCHREALTIME + | EPOCHSECONDS + | EUID + | EXECIGNORE + | FCEDIT + | FIGNORE + | FUNCNAME + | FUNCNEST + | GLOBIGNORE + | GROUPS + | histchars + | HISTCMD + | HISTCONTROL + | HISTFILESIZE + | HISTFILE + | HISTIGNORE + | HISTSIZE + | HISTTIMEFORMAT + | HOME + | HOSTFILE + | HOSTNAME + | HOSTTYPE + | IFS + | IGNOREEOF + | INPUTRC + | INSIDE_EMACS + | LANG + | LC_ALL + | LC_COLLATE + | LC_CTYPE + | LC_MESSAGES + | LC_NUMERIC + | LC_TIME + | LINENO + | LINES + | MACHTYPE + | MAILCHECK + | MAILPATH + | MAIL + | MAPFILE + | OLDPWD + | OPTARG + | OPTERR + | OPTIND + | OSTYPE + | PATH + | PIPESTATUS + | POSIXLY_CORRECT + | PPID + | PROMPT_COMMAND + | PROMPT_DIRTRIM + | PS0 + | PS1 + | PS2 + | PS3 + | PS4 + | PWD + | RANDOM + | READLINE_ARGUMENT + | READLINE_LINE + | READLINE_MARK + | READLINE_POINT + | REPLY + | SECONDS + | SHELLOPTS + | SHELL + | SHLVL + | SRANDOM + | TIMEFORMAT + | TMOUT + | TMPDIR + | UID + ) + + # Shell specific built-in variable + shell_variables: |- + (?x: + BASH + (?: + _(?: + ALIASES + | ARGC + | ARGV0 + | ARGV + | CMDS + | COMMAND + | COMPAT + | ENV + | EXECUTION_STRING + | LINENO + | LOADABLES_PATH + | REMATCH + | SOURCE + | SUBSHELL + | VERSINFO + | VERSION + | XTRACEFD + ) + | OPTS + | PID + )? + ) + + special_variable: '[$#@!*?-]' parameter_switch: '[AEKLPQUaku]' # posix regexp quantifiers @@ -309,11 +433,11 @@ contexts: ###[ VARIABLE DEFINITIONS ]#################################################### def-variables: - - match: '{{identifier}}(?=(?:\[[^\]]*\])*{{varassign}})' - scope: variable.other.readwrite.shell + - match: (?={{identifier}}(?:\[[^\]]*\])*{{varassign}}) push: - variable-value-assignment - variable-subscription + - variable-name-begin variable-subscription: - meta_scope: meta.variable.shell @@ -326,7 +450,7 @@ contexts: scope: meta.item-access.shell captures: 1: punctuation.section.item-access.begin.shell - 2: variable.language.shell + 2: variable.language.array.shell 3: punctuation.section.item-access.end.shell - match: \[ scope: punctuation.section.item-access.begin.shell @@ -1798,9 +1922,14 @@ contexts: scope: meta.interpolation.parameter.shell variable.language.positional.shell captures: 1: punctuation.definition.variable.shell + # https://www.gnu.org/software/bash/manual/bash.html#Shell-Variables + - match: (\$){{builtin_variable}} + scope: meta.interpolation.parameter.shell variable.language.builtin.shell + captures: + 1: punctuation.definition.variable.shell # https://www.gnu.org/software/bash/manual/bash.html#Special-Parameters - - match: (\$){{builtin_variable}}(?!\w) - scope: meta.interpolation.parameter.shell variable.language.shell + - match: (\$){{special_variable}} + scope: meta.interpolation.parameter.shell variable.language.special.shell captures: 1: punctuation.definition.variable.shell - match: (\$){{identifier}} @@ -1837,7 +1966,10 @@ contexts: scope: variable.language.positional.shell pop: 1 - match: '{{builtin_variable}}(?=[-+*/%?,:=#^@}\[])' - scope: variable.language.shell + scope: variable.language.builtin.shell + pop: 1 + - match: '{{special_variable}}(?=[-+*/%?,:=#^@}\[])' + scope: variable.language.special.shell pop: 1 - match: '' set: expansion-parameter-name-chars @@ -1846,7 +1978,7 @@ contexts: - meta_content_scope: variable.other.readwrite.shell # note: no quoted name parts allowed within parameter expansions - match: '[@*](?!\w)' - scope: variable.language.shell + scope: variable.language.special.shell pop: 1 - include: variable-name-chars @@ -2650,7 +2782,15 @@ contexts: variables: - match: '{{word_begin}}' - push: [variable-subscription, variable-name-chars] + push: [variable-subscription, variable-name-begin] + + variable-name-begin: + - meta_include_prototype: false + - match: '{{builtin_variable}}' + scope: variable.language.builtin.shell + pop: 1 + - match: '' + set: variable-name-chars variable-name-chars: - meta_scope: variable.other.readwrite.shell diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index 4a861c4583..28f2b34648 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -1164,7 +1164,7 @@ for i in {-10..+20..-4}; do echo $i; done; # ^ punctuation.terminator.statement.shell for i in $*; do echo $i; done; -# ^^ meta.interpolation.parameter.shell variable.language.shell +# ^^ meta.interpolation.parameter.shell variable.language.special.shell for i in $(seq 100); do # <- keyword.control.loop.for.shell @@ -1375,7 +1375,7 @@ done while IFS= read -r -d '' f; do # <- keyword.control.loop.while.shell -# ^^^ variable.other.readwrite.shell +# ^^^ variable.language.builtin.shell # ^ keyword.operator.assignment.shell # ^^^^ support.function.read.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell @@ -1638,7 +1638,7 @@ if [[ $- =~ *i* ]] ; then echo shell is not interactive; fi # ^^^^ meta.function-call.identifier.shell # ^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell # ^^ support.function.test.begin.shell -# ^^ meta.interpolation.parameter.shell variable.language.shell +# ^^ meta.interpolation.parameter.shell variable.language.special.shell # ^ punctuation.definition.variable.shell # ^^ keyword.operator.comparison.shell # ^ invalid.illegal.unexpected-quantifier.regexp.shell @@ -1777,7 +1777,7 @@ elif [ "$1" ]; then # <- keyword.declaration.variable.shell # ^^^ variable.other.readwrite.shell # ^ keyword.operator.assignment.shell - # ^^^^ variable.other.readwrite.shell + # ^^^^ variable.language.builtin.shell local TARGET=$1 # <- keyword.declaration.variable.shell # ^^^^^^ variable.other.readwrite.shell @@ -1839,7 +1839,7 @@ asdf foo && FOO=some-value pwd # ^^ keyword.operator.logical.shell # ^^^ meta.function-call.identifier.shell variable.function.shell # ^^^ meta.function-call.arguments.shell -# ^^ variable.language.shell +# ^^ variable.language.special.shell ############################################################################### @@ -2368,7 +2368,7 @@ coproc foobar { # ^ punctuation.section.block.begin.shell # ^^ support.function.test.begin.shell # ^ punctuation.definition.variable.shell -# ^^ variable.language.shell +# ^^ variable.language.special.shell # ^^ keyword.operator.comparison.shell # ^^ support.function.test.end.shell # ^^ keyword.operator.logical.shell @@ -2416,7 +2416,7 @@ logExit $? $WEIRD #^^^^^^ meta.function-call.identifier.shell variable.function.shell # ^^^^^^^^^^ meta.function-call.arguments.shell # ^ - meta.interpolation - variable -# ^^ meta.interpolation.parameter.shell variable.language.shell +# ^^ meta.interpolation.parameter.shell variable.language.special.shell # ^ - meta.interpolation - variable # ^^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell # ^ - meta.function-call - meta.interpolation - variable @@ -3271,26 +3271,29 @@ B$(cat)OWL=$(($(cat food.txt | wc -l) + 5)) # equivalent to "$1c$2c…", where c is the first character of the value of the # IFS variable. If IFS is unset, the parameters are separated by spaces. If IFS # is null, the parameters are joined without intervening separators. -: $* ${*} ${!*} ${#*} -# ^^ meta.interpolation.parameter.shell variable.language.shell +: $* ${*} ${!*} ${#*} _$*_ +# ^^ meta.interpolation.parameter.shell variable.language.special.shell # ^ punctuation.definition.variable.shell # ^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ punctuation.section.interpolation.end.shell # ^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ keyword.operator.expansion.indirection.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ punctuation.section.interpolation.end.shell # ^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ keyword.operator.expansion.length.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ punctuation.section.interpolation.end.shell +# ^ meta.string.shell string.unquoted.shell +# ^^ meta.string.shell meta.interpolation.parameter.shell variable.language.special.shell +# ^ meta.string.shell string.unquoted.shell # Expands to the positional parameters, starting from one. When the expansion # occurs within double quotes, each parameter expands to a separate word. That @@ -3299,139 +3302,157 @@ B$(cat)OWL=$(($(cat food.txt | wc -l) + 5)) # beginning part of the original word, and the expansion of the last parameter # is joined with the last part of the original word. When there are no # positional parameters, "$@" and $@ expand to nothing (i.e., they are removed). -: $@ ${@} ${!@} ${#@} -# ^^ meta.interpolation.parameter.shell variable.language.shell +: $@ ${@} ${!@} ${#@} _$@_ +# ^^ meta.interpolation.parameter.shell variable.language.special.shell # ^ punctuation.definition.variable.shell # ^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ punctuation.section.interpolation.end.shell # ^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ keyword.operator.expansion.indirection.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ punctuation.section.interpolation.end.shell # ^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ keyword.operator.expansion.length.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ punctuation.section.interpolation.end.shell +# ^ meta.string.shell string.unquoted.shell +# ^^ meta.string.shell meta.interpolation.parameter.shell variable.language.special.shell +# ^ meta.string.shell string.unquoted.shell # Expands to the number of positional parameters in decimal. -: $# ${#} ${!#} ${##} -# ^^ meta.interpolation.parameter.shell variable.language.shell +: $# ${#} ${!#} ${##} _$#_ +# ^^ meta.interpolation.parameter.shell variable.language.special.shell # ^ punctuation.definition.variable.shell # ^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ punctuation.section.interpolation.end.shell # ^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ keyword.operator.expansion.indirection.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ punctuation.section.interpolation.end.shell # ^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ keyword.operator.expansion.length.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ punctuation.section.interpolation.end.shell +# ^ meta.string.shell string.unquoted.shell +# ^^ meta.string.shell meta.interpolation.parameter.shell variable.language.special.shell +# ^ meta.string.shell string.unquoted.shell # Expands to the exit status of the most recently executed foreground pipeline. -: $? ${?} ${!?} ${#?} -# ^^ meta.interpolation.parameter.shell variable.language.shell +: $? ${?} ${!?} ${#?} _$?_ +# ^^ meta.interpolation.parameter.shell variable.language.special.shell # ^ punctuation.definition.variable.shell # ^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ punctuation.section.interpolation.end.shell # ^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ keyword.operator.expansion.indirection.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ punctuation.section.interpolation.end.shell # ^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ keyword.operator.expansion.length.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ punctuation.section.interpolation.end.shell +# ^ meta.string.shell string.unquoted.shell +# ^^ meta.string.shell meta.interpolation.parameter.shell variable.language.special.shell +# ^ meta.string.shell string.unquoted.shell # Expands to the current option flags as specified upon invocation, by the set # builtin command, or those set by the shell itself (such as the -i option). -: $- ${-} ${!-} ${#-} -# ^^ meta.interpolation.parameter.shell variable.language.shell +: $- ${-} ${!-} ${#-} _$-_ +# ^^ meta.interpolation.parameter.shell variable.language.special.shell # ^ punctuation.definition.variable.shell # ^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ punctuation.section.interpolation.end.shell # ^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ keyword.operator.expansion.indirection.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ punctuation.section.interpolation.end.shell # ^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ keyword.operator.expansion.length.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ punctuation.section.interpolation.end.shell +# ^ meta.string.shell string.unquoted.shell +# ^^ meta.string.shell meta.interpolation.parameter.shell variable.language.special.shell +# ^ meta.string.shell string.unquoted.shell # Expands to the process ID of the shell. In a () subshell, it expands to the # process ID of the invoking shell, not the subshell. -: $$ ${$} ${!$} ${#$} -# ^^ meta.interpolation.parameter.shell variable.language.shell +: $$ ${$} ${!$} ${#$} _$$_ +# ^^ meta.interpolation.parameter.shell variable.language.special.shell # ^ punctuation.definition.variable.shell # ^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ punctuation.section.interpolation.end.shell # ^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ keyword.operator.expansion.indirection.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ punctuation.section.interpolation.end.shell # ^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ keyword.operator.expansion.length.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ punctuation.section.interpolation.end.shell +# ^ meta.string.shell string.unquoted.shell +# ^^ meta.string.shell meta.interpolation.parameter.shell variable.language.special.shell +# ^ meta.string.shell string.unquoted.shell # Expands to the process ID of the job most recently placed into the background, # whether executed as an asynchronous command or using the bg builtin -: $! ${!} ${!!} ${#!} -# ^^ meta.interpolation.parameter.shell variable.language.shell +: $! ${!} ${!!} ${#!} _$!_ +# ^^ meta.interpolation.parameter.shell variable.language.special.shell # ^ punctuation.definition.variable.shell # ^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ punctuation.section.interpolation.end.shell # ^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ keyword.operator.expansion.indirection.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ punctuation.section.interpolation.end.shell # ^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ keyword.operator.expansion.length.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ punctuation.section.interpolation.end.shell +# ^ meta.string.shell string.unquoted.shell +# ^^ meta.string.shell meta.interpolation.parameter.shell variable.language.special.shell +# ^ meta.string.shell string.unquoted.shell # Expands to the name of the shell or shell script. This is set at shell # initialization. If Bash is invoked with a file of commands (see Shell @@ -3439,7 +3460,7 @@ B$(cat)OWL=$(($(cat food.txt | wc -l) + 5)) # option (see Invoking Bash), then $0 is set to the first argument after the # string to be executed, if one is present. Otherwise, it is set to the filename # used to invoke Bash, as given by argument zero. -: $0 ${0} ${!0} ${#0} +: $0 ${0} ${!0} ${#0} _$0_ # ^^ meta.interpolation.parameter.shell variable.language.positional.shell # ^ punctuation.definition.variable.shell # ^^^^ meta.interpolation.parameter.shell @@ -3459,33 +3480,9 @@ B$(cat)OWL=$(($(cat food.txt | wc -l) + 5)) # ^ keyword.operator.expansion.length.shell # ^ variable.language.positional.shell # ^ punctuation.section.interpolation.end.shell - -# At shell startup, set to the absolute pathname used to invoke the shell or -# shell script being executed as passed in the environment or argument list. -# Subsequently, expands to the last argument to the previous command, after -# expansion. Also set to the full pathname used to invoke each command executed -# and placed in the environment exported to that command. When checking mail, -# this parameter holds the name of the mail file. -: $_ ${_} ${!_} ${#_} -# ^^ meta.interpolation.parameter.shell variable.language.shell -# ^ punctuation.definition.variable.shell -# ^^^^ meta.interpolation.parameter.shell -# ^ punctuation.definition.variable.shell -# ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell -# ^ punctuation.section.interpolation.end.shell -# ^^^^^ meta.interpolation.parameter.shell -# ^ punctuation.definition.variable.shell -# ^ punctuation.section.interpolation.begin.shell -# ^ keyword.operator.expansion.indirection.shell -# ^ variable.language.shell -# ^ punctuation.section.interpolation.end.shell -# ^^^^^ meta.interpolation.parameter.shell -# ^ punctuation.definition.variable.shell -# ^ punctuation.section.interpolation.begin.shell -# ^ keyword.operator.expansion.length.shell -# ^ variable.language.shell -# ^ punctuation.section.interpolation.end.shell +# ^ meta.string.shell string.unquoted.shell +# ^^ meta.string.shell meta.interpolation.parameter.shell variable.language.positional.shell +# ^ meta.string.shell string.unquoted.shell ############################################################################### @@ -4160,21 +4157,21 @@ foo} # ^^^^^^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.section.interpolation.begin.shell # ^ keyword.operator.expansion.indirection.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ punctuation.section.interpolation.end.shell : ${!prefix@} # ^^^^^^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.section.interpolation.begin.shell # ^ keyword.operator.expansion.indirection.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ punctuation.section.interpolation.end.shell : ${!${prefix}@} # ^^^^^^^^^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.section.interpolation.begin.shell # ^ keyword.operator.expansion.indirection.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ punctuation.section.interpolation.end.shell # If name is an array variable, expands to the list of array indices (keys) @@ -4186,7 +4183,7 @@ foo} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.section.interpolation.begin.shell # ^ keyword.operator.expansion.indirection.shell -# ^ variable.language.shell +# ^ variable.language.array.shell # ^ punctuation.section.interpolation.end.shell # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell @@ -4213,7 +4210,7 @@ foo} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.section.interpolation.begin.shell # ^ keyword.operator.expansion.indirection.shell -# ^ variable.language.shell +# ^ variable.language.array.shell # ^ punctuation.section.interpolation.end.shell # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell @@ -4260,7 +4257,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4270,7 +4267,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4280,7 +4277,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4290,7 +4287,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4300,7 +4297,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4310,7 +4307,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4320,7 +4317,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4330,7 +4327,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.builtin.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4378,7 +4375,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4388,7 +4385,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4398,7 +4395,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4408,7 +4405,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4418,7 +4415,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4428,7 +4425,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4438,7 +4435,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4448,7 +4445,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.builtin.shell # ^^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4500,7 +4497,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4510,7 +4507,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4520,7 +4517,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4530,7 +4527,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4540,7 +4537,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4550,7 +4547,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4560,7 +4557,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4570,7 +4567,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.builtin.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4607,7 +4604,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4617,7 +4614,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4627,7 +4624,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4637,7 +4634,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4647,7 +4644,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4657,7 +4654,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4667,7 +4664,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4677,7 +4674,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.builtin.shell # ^^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4719,7 +4716,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4729,7 +4726,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4739,7 +4736,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4749,7 +4746,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4759,7 +4756,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4769,7 +4766,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4779,7 +4776,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4789,7 +4786,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.builtin.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4826,7 +4823,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4836,7 +4833,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4846,7 +4843,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4856,7 +4853,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4866,7 +4863,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4876,7 +4873,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4886,7 +4883,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4896,7 +4893,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.builtin.shell # ^^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4936,7 +4933,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4946,7 +4943,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4956,7 +4953,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4966,7 +4963,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4976,7 +4973,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4986,7 +4983,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -4996,7 +4993,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -5006,7 +5003,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.builtin.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -5043,7 +5040,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -5053,7 +5050,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -5063,7 +5060,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -5073,7 +5070,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -5083,7 +5080,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -5093,7 +5090,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -5103,7 +5100,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -5113,7 +5110,7 @@ foo} # ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.builtin.shell # ^^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.interpolation.end.shell @@ -5150,7 +5147,7 @@ foo} # ^^^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.substring.begin.shell # ^ meta.number.integer.decimal.shell constant.numeric.value.shell # ^ keyword.operator.substring.end.shell @@ -5161,7 +5158,7 @@ foo} # ^^^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.substring.begin.shell # ^ meta.number.integer.decimal.shell constant.numeric.value.shell # ^ keyword.operator.substring.end.shell @@ -5172,7 +5169,7 @@ foo} # ^^^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.substring.begin.shell # ^ meta.number.integer.decimal.shell constant.numeric.value.shell # ^ keyword.operator.substring.end.shell @@ -5183,7 +5180,7 @@ foo} # ^^^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.substring.begin.shell # ^ meta.number.integer.decimal.shell constant.numeric.value.shell # ^ keyword.operator.substring.end.shell @@ -5194,7 +5191,7 @@ foo} # ^^^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.substring.begin.shell # ^ meta.number.integer.decimal.shell constant.numeric.value.shell # ^ keyword.operator.substring.end.shell @@ -5205,7 +5202,7 @@ foo} # ^^^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.substring.begin.shell # ^ meta.number.integer.decimal.shell constant.numeric.value.shell # ^ keyword.operator.substring.end.shell @@ -5216,7 +5213,7 @@ foo} # ^^^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.substring.begin.shell # ^ meta.number.integer.decimal.shell constant.numeric.value.shell # ^ keyword.operator.substring.end.shell @@ -5227,7 +5224,7 @@ foo} # ^^^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.builtin.shell # ^ keyword.operator.substring.begin.shell # ^ meta.number.integer.decimal.shell constant.numeric.value.shell # ^ keyword.operator.substring.end.shell @@ -5286,7 +5283,7 @@ foo} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.substitution.shell # ^^^ meta.string.regexp.shell # ^ keyword.operator.substitution.shell @@ -5298,7 +5295,7 @@ foo} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.substitution.shell # ^^^ meta.string.regexp.shell # ^ keyword.operator.substitution.shell @@ -5310,7 +5307,7 @@ foo} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.substitution.shell # ^^^ meta.string.regexp.shell # ^ keyword.operator.substitution.shell @@ -5322,7 +5319,7 @@ foo} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.substitution.shell # ^^^ meta.string.regexp.shell # ^ keyword.operator.substitution.shell @@ -5334,7 +5331,7 @@ foo} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.substitution.shell # ^^^ meta.string.regexp.shell # ^ keyword.operator.substitution.shell @@ -5346,7 +5343,7 @@ foo} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.substitution.shell # ^^^ meta.string.regexp.shell # ^ keyword.operator.substitution.shell @@ -5358,7 +5355,7 @@ foo} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.substitution.shell # ^^^ meta.string.regexp.shell # ^ keyword.operator.substitution.shell @@ -5370,7 +5367,7 @@ foo} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^ variable.language.shell +# ^ variable.language.builtin.shell # ^ keyword.operator.substitution.shell # ^^^ meta.string.regexp.shell # ^ keyword.operator.substitution.shell @@ -5395,7 +5392,7 @@ foo} # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^^^ variable.other.readwrite.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.substitution.shell # ^^^ meta.string.regexp.shell # ^ keyword.operator.substitution.shell @@ -5408,7 +5405,7 @@ foo} # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^^^ variable.other.readwrite.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.substitution.shell # ^^^ meta.string.regexp.shell # ^ keyword.operator.substitution.shell @@ -5422,7 +5419,7 @@ foo} # ^ punctuation.section.interpolation.begin.shell # ^^^ variable.other.readwrite.shell # ^ punctuation.section.item-access.begin.shell -# ^ variable.language.shell +# ^ variable.language.array.shell # ^ punctuation.section.item-access.end.shell # ^ keyword.operator.substitution.shell # ^^^ meta.string.regexp.shell @@ -5437,7 +5434,7 @@ foo} # ^ punctuation.section.interpolation.begin.shell # ^^^ variable.other.readwrite.shell # ^ punctuation.section.item-access.begin.shell -# ^ variable.language.shell +# ^ variable.language.array.shell # ^ punctuation.section.item-access.end.shell # ^ keyword.operator.substitution.shell # ^^^ meta.string.regexp.shell @@ -5778,37 +5775,37 @@ a\/b/c/d} : ${@#pattern} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${*#pattern} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${##pattern} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${?#pattern} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${$#pattern} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${-#pattern} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell @@ -5820,7 +5817,7 @@ a\/b/c/d} : ${_#pattern} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.builtin.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell @@ -5845,7 +5842,7 @@ a\/b/c/d} # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^^^ variable.other.readwrite.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell # ^ punctuation.section.interpolation.end.shell @@ -5855,7 +5852,7 @@ a\/b/c/d} # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^^^ variable.other.readwrite.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell # ^ punctuation.section.interpolation.end.shell @@ -5867,7 +5864,7 @@ a\/b/c/d} # ^^^ variable.other.readwrite.shell # ^^^ meta.item-access.shell # ^ punctuation.section.item-access.begin.shell -# ^ variable.language.shell +# ^ variable.language.array.shell # ^ punctuation.section.item-access.end.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell @@ -5880,7 +5877,7 @@ a\/b/c/d} # ^^^ variable.other.readwrite.shell # ^^^ meta.item-access.shell # ^ punctuation.section.item-access.begin.shell -# ^ variable.language.shell +# ^ variable.language.array.shell # ^ punctuation.section.item-access.end.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell @@ -5935,66 +5932,66 @@ a\/b/c/d} : ${@##pattern} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${*##pattern} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${###pattern} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${?##pattern} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${$##pattern} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${-##pattern} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${!##pattern} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell # ^ keyword.operator.expansion.indirection.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${!###pattern} # ^^^^^^^^^^^^^^ meta.interpolation.parameter.shell # ^ keyword.operator.expansion.indirection.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${!####pattern} # ^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell # ^ keyword.operator.expansion.indirection.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^^ meta.string.regexp.shell # ^ - keyword : ${_##pattern} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.builtin.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell @@ -6029,7 +6026,7 @@ a\/b/c/d} # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^^^ variable.other.readwrite.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell # ^ punctuation.section.interpolation.end.shell @@ -6039,7 +6036,7 @@ a\/b/c/d} # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^^^ variable.other.readwrite.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell # ^ punctuation.section.interpolation.end.shell @@ -6051,7 +6048,7 @@ a\/b/c/d} # ^^^ variable.other.readwrite.shell # ^^^ meta.item-access.shell # ^ punctuation.section.item-access.begin.shell -# ^ variable.language.shell +# ^ variable.language.array.shell # ^ punctuation.section.item-access.end.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell @@ -6064,7 +6061,7 @@ a\/b/c/d} # ^^^ variable.other.readwrite.shell # ^^^ meta.item-access.shell # ^ punctuation.section.item-access.begin.shell -# ^ variable.language.shell +# ^ variable.language.array.shell # ^ punctuation.section.item-access.end.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell @@ -6100,42 +6097,42 @@ a\/b/c/d} : ${@%pattern} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell : ${*%pattern} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell : ${#%pattern} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell : ${?%pattern} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell : ${$%pattern} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell : ${-%pattern} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell : ${!%pattern} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell : ${_%pattern} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.builtin.shell # ^ keyword.operator.expansion.shell : ${foo%} @@ -6158,7 +6155,7 @@ a\/b/c/d} # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^^^ variable.other.readwrite.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell # ^ punctuation.section.interpolation.end.shell @@ -6168,7 +6165,7 @@ a\/b/c/d} # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^^^ variable.other.readwrite.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell # ^ punctuation.section.interpolation.end.shell @@ -6180,7 +6177,7 @@ a\/b/c/d} # ^^^ variable.other.readwrite.shell # ^^^ meta.item-access.shell # ^ punctuation.section.item-access.begin.shell -# ^ variable.language.shell +# ^ variable.language.array.shell # ^ punctuation.section.item-access.end.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell @@ -6193,7 +6190,7 @@ a\/b/c/d} # ^^^ variable.other.readwrite.shell # ^^^ meta.item-access.shell # ^ punctuation.section.item-access.begin.shell -# ^ variable.language.shell +# ^ variable.language.array.shell # ^ punctuation.section.item-access.end.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell @@ -6241,49 +6238,49 @@ a\/b/c/d} : ${@%%pattern} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${*%%pattern} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${#%%pattern} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${?%%pattern} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${$%%pattern} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${-%%pattern} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${!%%pattern} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${_%%pattern} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.builtin.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell @@ -6316,7 +6313,7 @@ a\/b/c/d} # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^^^ variable.other.readwrite.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell # ^ punctuation.section.interpolation.end.shell @@ -6326,7 +6323,7 @@ a\/b/c/d} # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^^^ variable.other.readwrite.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell # ^ punctuation.section.interpolation.end.shell @@ -6338,7 +6335,7 @@ a\/b/c/d} # ^^^ variable.other.readwrite.shell # ^^^ meta.item-access.shell # ^ punctuation.section.item-access.begin.shell -# ^ variable.language.shell +# ^ variable.language.array.shell # ^ punctuation.section.item-access.end.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell @@ -6351,7 +6348,7 @@ a\/b/c/d} # ^^^ variable.other.readwrite.shell # ^^^ meta.item-access.shell # ^ punctuation.section.item-access.begin.shell -# ^ variable.language.shell +# ^ variable.language.array.shell # ^ punctuation.section.item-access.end.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell @@ -6377,49 +6374,49 @@ a\/b/c/d} : ${@,pattern} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${*,pattern} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${#,pattern} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${?,pattern} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${$,pattern} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${-,pattern} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${!,pattern} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${_,pattern} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.builtin.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell @@ -6443,7 +6440,7 @@ a\/b/c/d} # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^^^ variable.other.readwrite.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell # ^ punctuation.section.interpolation.end.shell @@ -6453,7 +6450,7 @@ a\/b/c/d} # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^^^ variable.other.readwrite.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell # ^ punctuation.section.interpolation.end.shell @@ -6465,7 +6462,7 @@ a\/b/c/d} # ^^^ variable.other.readwrite.shell # ^^^ meta.item-access.shell # ^ punctuation.section.item-access.begin.shell -# ^ variable.language.shell +# ^ variable.language.array.shell # ^ punctuation.section.item-access.end.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell @@ -6478,7 +6475,7 @@ a\/b/c/d} # ^^^ variable.other.readwrite.shell # ^^^ meta.item-access.shell # ^ punctuation.section.item-access.begin.shell -# ^ variable.language.shell +# ^ variable.language.array.shell # ^ punctuation.section.item-access.end.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell @@ -6528,49 +6525,49 @@ a\/b/c/d} : ${@,,pattern} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${*,,pattern} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${#,,pattern} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${?,,pattern} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${$,,pattern} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${-,,pattern} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${!,,pattern} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${_,,pattern} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.builtin.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell @@ -6603,7 +6600,7 @@ a\/b/c/d} # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^^^ variable.other.readwrite.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell # ^ punctuation.section.interpolation.end.shell @@ -6613,7 +6610,7 @@ a\/b/c/d} # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^^^ variable.other.readwrite.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell # ^ punctuation.section.interpolation.end.shell @@ -6625,7 +6622,7 @@ a\/b/c/d} # ^^^ variable.other.readwrite.shell # ^^^ meta.item-access.shell # ^ punctuation.section.item-access.begin.shell -# ^ variable.language.shell +# ^ variable.language.array.shell # ^ punctuation.section.item-access.end.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell @@ -6638,7 +6635,7 @@ a\/b/c/d} # ^^^ variable.other.readwrite.shell # ^^^ meta.item-access.shell # ^ punctuation.section.item-access.begin.shell -# ^ variable.language.shell +# ^ variable.language.array.shell # ^ punctuation.section.item-access.end.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell @@ -6664,49 +6661,49 @@ a\/b/c/d} : ${@^pattern} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${*^pattern} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${#^pattern} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${?^pattern} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${$^pattern} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${-^pattern} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${!^pattern} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${_^pattern} # ^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.builtin.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell @@ -6730,7 +6727,7 @@ a\/b/c/d} # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^^^ variable.other.readwrite.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell # ^ punctuation.section.interpolation.end.shell @@ -6740,7 +6737,7 @@ a\/b/c/d} # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^^^ variable.other.readwrite.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell # ^ punctuation.section.interpolation.end.shell @@ -6752,7 +6749,7 @@ a\/b/c/d} # ^^^ variable.other.readwrite.shell # ^^^ meta.item-access.shell # ^ punctuation.section.item-access.begin.shell -# ^ variable.language.shell +# ^ variable.language.array.shell # ^ punctuation.section.item-access.end.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell @@ -6765,7 +6762,7 @@ a\/b/c/d} # ^^^ variable.other.readwrite.shell # ^^^ meta.item-access.shell # ^ punctuation.section.item-access.begin.shell -# ^ variable.language.shell +# ^ variable.language.array.shell # ^ punctuation.section.item-access.end.shell # ^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell @@ -6815,49 +6812,49 @@ a\/b/c/d} : ${@^^pattern} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${*^^pattern} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${#^^pattern} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${?^^pattern} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${$^^pattern} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${-^^pattern} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${!^^pattern} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell : ${_^^pattern} # ^^^^^^^^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.builtin.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell string.unquoted.shell @@ -6890,7 +6887,7 @@ a\/b/c/d} # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^^^ variable.other.readwrite.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell # ^ punctuation.section.interpolation.end.shell @@ -6900,7 +6897,7 @@ a\/b/c/d} # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^^^ variable.other.readwrite.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell # ^ punctuation.section.interpolation.end.shell @@ -6912,7 +6909,7 @@ a\/b/c/d} # ^^^ variable.other.readwrite.shell # ^^^ meta.item-access.shell # ^ punctuation.section.item-access.begin.shell -# ^ variable.language.shell +# ^ variable.language.array.shell # ^ punctuation.section.item-access.end.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell @@ -6925,7 +6922,7 @@ a\/b/c/d} # ^^^ variable.other.readwrite.shell # ^^^ meta.item-access.shell # ^ punctuation.section.item-access.begin.shell -# ^ variable.language.shell +# ^ variable.language.array.shell # ^ punctuation.section.item-access.end.shell # ^^ keyword.operator.expansion.shell # ^^^^^^^ meta.string.regexp.shell @@ -6951,49 +6948,49 @@ a\/b/c/d} ${@@A} # ^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^ variable.parameter.switch.shell ${*@A} # ^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^ variable.parameter.switch.shell ${?@A} # ^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^ variable.parameter.switch.shell ${$@A} # ^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^ variable.parameter.switch.shell ${-@A} # ^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^ variable.parameter.switch.shell ${!@A} # ^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^ variable.parameter.switch.shell ${-@A} # ^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^ variable.parameter.switch.shell ${_@A} # ^^^^^^ meta.interpolation.parameter.shell -# ^ variable.language.shell +# ^ variable.language.builtin.shell # ^ keyword.operator.expansion.shell # ^ variable.parameter.switch.shell @@ -7064,22 +7061,22 @@ a\/b/c/d} # ^ - variable.parameter.switch : ${foo@@u} -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^ variable.parameter.switch.shell : ${foo*@u} -# ^ variable.language.shell +# ^ variable.language.special.shell # ^ keyword.operator.expansion.shell # ^ variable.parameter.switch.shell : ${foo[@]@u} -# ^ variable.language.shell +# ^ variable.language.array.shell # ^ keyword.operator.expansion.shell # ^ variable.parameter.switch.shell : ${foo[*]@u} -# ^ variable.language.shell +# ^ variable.language.array.shell # ^ keyword.operator.expansion.shell # ^ variable.parameter.switch.shell @@ -9316,14 +9313,14 @@ export -f ==cmd export PATH="$PATH:$HOME/.local/bin" # ^^^^ meta.function-call.identifier.shell support.function.export.shell # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments -# ^^^^ meta.variable variable.other.readwrite +# ^^^^ variable.language.builtin.shell # ^ keyword.operator.assignment # ^^^^^^^^^^^^^^^^^^^^^^^^ meta.string # ^ string.quoted.double punctuation.definition.string.begin -# ^^^^^ meta.interpolation.parameter variable.other.readwrite +# ^^^^^ meta.interpolation.parameter variable.language.builtin.shell # ^ punctuation.definition.variable # ^ string.quoted.double punctuation.separator.sequence -# ^^^^^ meta.interpolation.parameter variable.other.readwrite +# ^^^^^ meta.interpolation.parameter variable.language.builtin.shell # ^ punctuation.definition.variable # ^^^^^^^^^^^^ string.quoted.double # ^ punctuation.definition.string.end @@ -9332,21 +9329,21 @@ export PATH="$PATH:$HOME/.local/bin" export PATH=$PATH:~/.local/bin # ^^^^ meta.function-call.identifier.shell support.function.export.shell # ^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell -# ^^^^ meta.variable variable.other.readwrite +# ^^^^ variable.language.builtin.shell # ^ keyword.operator.assignment # ^^^^^^^^^^^^^^^^^^ meta.string.shell -# ^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^^^^^ meta.interpolation.parameter.shell variable.language.builtin.shell # ^ meta.interpolation.tilde.shell variable.language.tilde.shell # no tilde expansion in quoted strings export PATH="$PATH:~/.local/bin" # ^^^^ meta.function-call.identifier.shell support.function.export.shell # ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell -# ^^^^ meta.variable variable.other.readwrite +# ^^^^ variable.language.builtin.shell # ^ keyword.operator.assignment # ^^^^^^^^^^^^^^^^^^^^ meta.string.shell # ^ punctuation.definition.string.begin.shell -# ^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^^^^^ meta.interpolation.parameter.shell variable.language.builtin.shell # ^ punctuation.separator.sequence.shell # ^ - variable # ^ punctuation.definition.string.end.shell @@ -9478,7 +9475,7 @@ f() { #^^^^ keyword.declaration.variable.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell # ^ meta.variable.shell variable.other.readwrite.shell punctuation.definition.quoted.begin.shell - # ^^ meta.variable.shell meta.interpolation.parameter.shell variable.language.shell + # ^^ meta.variable.shell meta.interpolation.parameter.shell variable.language.special.shell # ^ meta.variable.shell variable.other.readwrite.shell punctuation.definition.quoted.end.shell local x # <- keyword.declaration.variable.shell @@ -9507,7 +9504,7 @@ f() { # <- keyword.control.conditional.end.shell IFS=, local -a "$x"'=("${x}: ${'"$x"'[*]}")' - # ^ variable.other.readwrite.shell + # ^ variable.language.builtin.shell # ^ keyword.operator.assignment.shell # ^ meta.string.shell string.unquoted.shell # ^ keyword.declaration.variable.shell @@ -10046,6 +10043,467 @@ sudo --reset-timestamp -n -f -- rm -rf # ^ punctuation.definition.parameter.shell +############################################################################### +# 5.2 Bash Variables # +# https://www.gnu.org/software/bash/manual/bash.html#Shell-Variables # +############################################################################### + +# At shell startup, set to the absolute pathname used to invoke the shell or +# shell script being executed as passed in the environment or argument list. +# Subsequently, expands to the last argument to the previous command, after +# expansion. Also set to the full pathname used to invoke each command executed +# and placed in the environment exported to that command. When checking mail, +# this parameter holds the name of the mail file. +: $_ ${_} ${!_} ${#_} +# ^^ meta.interpolation.parameter.shell variable.language.builtin.shell +# ^ punctuation.definition.variable.shell +# ^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.builtin.shell +# ^ punctuation.section.interpolation.end.shell +# ^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.indirection.shell +# ^ variable.language.builtin.shell +# ^ punctuation.section.interpolation.end.shell +# ^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.length.shell +# ^ variable.language.builtin.shell +# ^ punctuation.section.interpolation.end.shell + +: $BASH_ALIASES +# ^^^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $BASH_ARGC +# ^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $BASH_ARGV +# ^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $BASH_ARGV0 +# ^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $BASH_CMDS +# ^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $BASH_COMMAND +# ^^^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $BASH_COMPAT +# ^^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $BASH_ENV +# ^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $BASH_EXECUTION_STRING +# ^^^^^^^^^^^^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $BASH_LINENO +# ^^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $BASH_LOADABLES_PATH +# ^^^^^^^^^^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $BASH_REMATCH +# ^^^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $BASH_SOURCE +# ^^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $BASH_SUBSHELL +# ^^^^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $BASH_VERSINFO +# ^^^^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $BASH_VERSION +# ^^^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $BASH_XTRACEFD +# ^^^^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $BASH +# ^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $BASHOPTS +# ^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $BASHPID +# ^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $CDPATH +# ^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $CHILD_MAX +# ^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $COLUMNS +# ^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $COMP_CWORD +# ^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $COMP_KEY +# ^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $COMP_LINE +# ^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $COMP_POINT +# ^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $COMP_TYPE +# ^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $COMP_WORDBREAKS +# ^^^^^^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $COMP_WORDS +# ^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $COMPREPLY +# ^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $COPROC +# ^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $DIRSTACK +# ^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $EMACS +# ^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $ENV +# ^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $EPOCHREALTIME +# ^^^^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $EPOCHSECONDS +# ^^^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $EUID +# ^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $EXECIGNORE +# ^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $FCEDIT +# ^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $FIGNORE +# ^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $FUNCNAME +# ^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $FUNCNEST +# ^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $GLOBIGNORE +# ^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $GROUPS +# ^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $histchars +# ^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $HISTCMD +# ^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $HISTCONTROL +# ^^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $HISTFILE +# ^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $HISTFILESIZE +# ^^^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $HISTIGNORE +# ^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $HISTSIZE +# ^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $HISTTIMEFORMAT +# ^^^^^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $HOME +# ^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $HOSTFILE +# ^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $HOSTNAME +# ^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $HOSTTYPE +# ^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $IFS +# ^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $IGNOREEOF +# ^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $INPUTRC +# ^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $INSIDE_EMACS +# ^^^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $LANG +# ^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $LC_ALL +# ^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $LC_COLLATE +# ^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $LC_CTYPE +# ^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $LC_MESSAGES +# ^^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $LC_NUMERIC +# ^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $LC_TIME +# ^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $LINENO +# ^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $LINES +# ^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $MACHTYPE +# ^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $MAIL +# ^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $MAILCHECK +# ^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $MAILPATH +# ^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $MAPFILE +# ^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $OLDPWD +# ^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $OPTARG +# ^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $OPTERR +# ^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $OPTIND +# ^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $OSTYPE +# ^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $PATH +# ^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $PIPESTATUS +# ^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $POSIXLY_CORRECT +# ^^^^^^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $PPID +# ^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $PROMPT_COMMAND +# ^^^^^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $PROMPT_DIRTRIM +# ^^^^^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $PS0 +# ^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $PS1 +# ^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $PS2 +# ^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $PS3 +# ^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $PS4 +# ^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $PWD +# ^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $RANDOM +# ^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $READLINE_ARGUMENT +# ^^^^^^^^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $READLINE_LINE +# ^^^^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $READLINE_MARK +# ^^^^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $READLINE_POINT +# ^^^^^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $REPLY +# ^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $SECONDS +# ^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $SHELL +# ^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $SHELLOPTS +# ^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $SHLVL +# ^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $SRANDOM +# ^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $TIMEFORMAT +# ^^^^^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $TMOUT +# ^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $TMPDIR +# ^^^^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + +: $UID +# ^^^^ variable.language.builtin.shell +# ^ punctuation.definition.variable.shell + + ############################################################################### # 6.4 Bash Conditional Expressions # # https://www.gnu.org/software/bash/manual/bash.html#Bash-Conditional-Expressions From 02f0bb7663d4bc416c13725dfd615b6bad095126 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 21 Jul 2024 15:54:01 +0200 Subject: [PATCH 019/113] [ShellScript] Reorganize expressions Move up expressions and operators contexts. --- ShellScript/Bash.sublime-syntax | 137 ++++++++++++++++---------------- 1 file changed, 70 insertions(+), 67 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 9ef9af9e5a..f885dc8209 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -1405,6 +1405,76 @@ contexts: - include: cmd-args-end - include: string-path-patterns +###[ EXPRESSIONS ]############################################################# + + expressions: + - match: \( + scope: punctuation.section.group.begin.shell + push: expression-group-body + # multi char operators + - match: '[-+*/%&|^]=|<<=|>>=' + scope: keyword.operator.assignment.augmented.shell + - match: '<<|>>' + scope: keyword.operator.bitwise.shell + - match: '<=?|>=?|[=!]=' + scope: keyword.operator.comparison.shell + - match: '&&|\|\||!' + scope: keyword.operator.logical.shell + # single char operators + - match: '=' + scope: keyword.operator.assignment.shell + - match: '[&|^~]' + scope: keyword.operator.bitwise.shell + - match: ; + scope: punctuation.terminator.statement.shell + - match: \, + scope: punctuation.separator.sequence.shell + - match: \:|\? + scope: keyword.operator.ternary.shell + - include: arithmetic-operators + # Shell variables are allowed as operands; parameter expansion is performed + # before the expression is evaluated. Within an expression, shell variables + # may also be referenced by name without using the parameter expansion + # syntax. + - include: booleans + - include: numbers + - include: variables + + expression-group-body: + - meta_scope: meta.group.shell + - match: \) + scope: punctuation.section.group.end.shell + pop: 1 + - include: expressions + +###[ OPERATORS ]############################################################### + + line-continuations: + - match: (\\)\n + captures: + 1: punctuation.separator.continuation.line.shell + push: line-continuation-body + - match: \\(\s+)\n + captures: + 1: invalid.illegal.unexpected-whitespace.shell + + line-continuation-body: + - meta_include_prototype: false + - match: ^ + pop: 1 + + arithmetic-operators: + - match: '[-+*/%]' + scope: keyword.operator.arithmetic.shell + + operators: + - match: \|\||\&\&|\!(?!\S) + scope: keyword.operator.logical.shell + - match: \||\& + scope: keyword.operator.assignment.pipe.shell + - match: ; + scope: punctuation.terminator.statement.shell + ###[ REDIRECTIONS AND HEREDOCS ]############################################### redirections: @@ -1653,73 +1723,6 @@ contexts: - match: (?=\S) push: [statement, cmd-args] -###[ EXPRESSIONS ]############################################################# - - expressions: - - match: \( - scope: punctuation.section.group.begin.shell - push: expression-group-body - # multi char operators - - match: '[-+*/%&|^]=|<<=|>>=' - scope: keyword.operator.assignment.augmented.shell - - match: '<<|>>' - scope: keyword.operator.bitwise.shell - - match: '<=?|>=?|[=!]=' - scope: keyword.operator.comparison.shell - - match: '&&|\|\||!' - scope: keyword.operator.logical.shell - # single char operators - - match: '[-+*/%]' - scope: keyword.operator.arithmetic.shell - - match: '=' - scope: keyword.operator.assignment.shell - - match: '[&|^~]' - scope: keyword.operator.bitwise.shell - - match: ; - scope: punctuation.terminator.statement.shell - - match: \, - scope: punctuation.separator.sequence.shell - - match: \:|\? - scope: keyword.operator.ternary.shell - # Shell variables are allowed as operands; parameter expansion is performed - # before the expression is evaluated. Within an expression, shell variables - # may also be referenced by name without using the parameter expansion - # syntax. - - include: booleans - - include: numbers - - include: variables - - expression-group-body: - - meta_scope: meta.group.shell - - match: \) - scope: punctuation.section.group.end.shell - pop: 1 - - include: expressions - -###[ OPERATORS ]############################################################### - - line-continuations: - - match: (\\)\n - captures: - 1: punctuation.separator.continuation.line.shell - push: line-continuation-body - - match: \\(\s+)\n - captures: - 1: invalid.illegal.unexpected-whitespace.shell - - line-continuation-body: - - meta_include_prototype: false - - match: ^ - pop: 1 - - operators: - - match: \|\||\&\&|\!(?!\S) - scope: keyword.operator.logical.shell - - match: \||\& - scope: keyword.operator.assignment.pipe.shell - - match: ; - scope: punctuation.terminator.statement.shell - ###[ EXPANSIONS ]############################################################## expansions-patterns: From c032c5ff476f2166a304cc11e29cfb341ff0a4e8 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 21 Jul 2024 16:10:29 +0200 Subject: [PATCH 020/113] [ShellScript] Reorganize literals This commit moves literals, strings and pattern matching contexts up, right after heredocs. --- ShellScript/Bash.sublime-syntax | 1280 ++++++++++++++++--------------- 1 file changed, 641 insertions(+), 639 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index f885dc8209..832f4a0746 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -1723,464 +1723,198 @@ contexts: - match: (?=\S) push: [statement, cmd-args] -###[ EXPANSIONS ]############################################################## - - expansions-patterns: - - include: pattern-groups - - include: pattern-charsets - - include: pattern-wildcards +###[ LITERALS ]################################################################ - expansions-variables: - - include: expansions-arithmetic - - include: expansions-command - - include: expansions-parameter + booleans: + - match: false\b + scope: constant.language.boolean.false.shell + - match: true\b + scope: constant.language.boolean.true.shell -###[ ARITHMETIC EXPANSIONS ]################################################### + boolean: + - match: false\b + scope: constant.language.boolean.false.shell + pop: 1 + - match: true\b + scope: constant.language.boolean.true.shell + pop: 1 - expansions-arithmetic: - - match: (\$)(\(\() + numbers: + # A leading ‘0x’ or ‘0X’ denotes hexadecimal. + - match: \b(0[xX])(\h*) + scope: meta.number.integer.hexadecimal.shell captures: - 1: punctuation.definition.variable.shell - 2: punctuation.section.interpolation.begin.shell - push: arithmetic-expansion-parens-body + 1: constant.numeric.base.shell + 2: constant.numeric.value.shell + # Constants with a leading 0 are interpreted as octal numbers. + - match: \b(0)([0-7]+) + scope: meta.number.integer.octal.shell + captures: + 1: constant.numeric.base.shell + 2: constant.numeric.value.shell + # Otherwise, numbers take the form [base#]n, where the optional base is a + # decimal number between 2 and 64 representing the arithmetic base, and n is + # a number in that base. When specifying n, the digits greater than 9 are + # represented by the lowercase letters, the uppercase letters, ‘@’, and ‘_’, + # in that order. + - match: \b(\d+#)([a-zA-Z0-9@_]+) + scope: meta.number.integer.other.shell + captures: + 1: constant.numeric.base.shell + 2: constant.numeric.value.shell + # If base# is omitted, then base 10 is used. + - match: \b\d+(?![.\w]) + scope: meta.number.integer.decimal.shell constant.numeric.value.shell - arithmetic-expansion-parens-body: - - meta_scope: meta.interpolation.arithmetic.shell - - match: \)\) - scope: punctuation.section.interpolation.end.shell + number: + # Note: Leading sign is scoped as operator for consistent highlighting as + # we can't distinguish operators from sign for sure everywhere. + - match: ([-+]?)(0[xX])(\h*){{word_break}} + scope: meta.number.integer.hexadecimal.shell + captures: + 1: keyword.operator.arithmetic.shell + 2: constant.numeric.base.shell + 3: constant.numeric.value.shell + pop: 1 + - match: ([-+]?)(0)([0-7]+){{word_break}} + scope: meta.number.integer.octal.shell + captures: + 1: keyword.operator.arithmetic.shell + 2: constant.numeric.base.shell + 3: constant.numeric.value.shell + pop: 1 + - match: ([-+]?)(\d+#)([a-zA-Z0-9@_]+){{word_break}} + scope: meta.number.integer.other.she + captures: + 1: keyword.operator.arithmetic.shell + 2: constant.numeric.base.shell + 3: constant.numeric.value.shell + # If base# is omitted, then base 10 is used. + - match: ([-+]?)(\d+){{word_break}} + scope: meta.number.integer.decimal.shell + captures: + 1: keyword.operator.arithmetic.shell + 2: constant.numeric.value.shell pop: 1 - - include: expressions - -###[ BRACE EXPANSIONS ]######################################################## - brace-interpolations: - # use branching as valid brace expansions must not exceed word boundaries - - match: (?={) - branch_point: brace-interpolation - branch: - - brace-interpolation-sequence - - brace-interpolation-series - - brace-interpolation-fallback + literal-unquoted-content: + - match: \$?\" + scope: punctuation.definition.quoted.begin.shell + push: literal-double-quoted-body + - match: \$' + scope: punctuation.definition.quoted.begin.shell + push: literal-ansi-c-body + - match: \' + scope: punctuation.definition.quoted.begin.shell + push: literal-single-quoted-body + - include: string-prototype + - include: any-escapes + - include: brace-interpolations + - include: string-interpolations - brace-interpolation-sequence: - # sequence expression - - clear_scopes: 1 - - meta_include_prototype: false - - match: \{ - scope: - meta.interpolation.brace.shell - punctuation.section.interpolation.begin.shell - push: - - brace-interpolation-sequence-body - - brace-interpolation-sequence-begin + literal-ansi-c-body: + - match: \' + scope: punctuation.definition.quoted.end.shell + pop: 1 + - include: line-continuations + - include: string-prototype + - include: string-escapes-ansi-c - brace-interpolation-sequence-begin: - - match: \.\. - scope: keyword.operator.range.shell + literal-double-quoted-body: + - match: \" + scope: punctuation.definition.quoted.end.shell pop: 1 - include: line-continuations - - include: brace-interpolation-sequence-content + - include: string-prototype + - include: string-escapes + - include: string-interpolations - brace-interpolation-sequence-body: - - meta_content_scope: meta.interpolation.brace.shell - - match: \.\. - scope: keyword.operator.range.shell - - include: brace-interpolation-end - - include: brace-interpolation-sequence-content + literal-single-quoted-body: + - match: \' + scope: punctuation.definition.quoted.end.shell + pop: 1 + - include: string-prototype - brace-interpolation-sequence-content: - - include: expansions-variables - - match: ([-+]?)(\d+) - scope: meta.number.integer.decimal.shell - captures: - 1: keyword.operator.arithmetic.shell - 2: constant.numeric.value.shell - - match: '[[:alpha:]]' - scope: constant.character.shell - - match: '' - fail: brace-interpolation +###[ STRINGS ]################################################################# - brace-interpolation-series: - # series of comma-separated strings - - clear_scopes: 1 - - meta_include_prototype: false - - match: \{ - scope: - meta.interpolation.brace.shell - punctuation.section.interpolation.begin.shell - push: brace-interpolation-series-begin + string-unquoted-content: + # [Bash] 3.1.2.5 + - match: \$?\" + scope: punctuation.definition.string.begin.shell + push: string-double-quoted-body + # [Bash] 3.1.2.4 + - match: \$' + scope: punctuation.definition.string.begin.shell + push: string-ansi-c-body + - match: \' + scope: punctuation.definition.string.begin.shell + push: string-single-quoted-body + - include: string-prototype + - include: any-escapes + - include: brace-interpolations + - include: string-interpolations - brace-interpolation-series-begin: + string-ansi-c-body: + - clear_scopes: 1 # clear `string.unquoted` - meta_include_prototype: false - - meta_content_scope: - meta.interpolation.brace.shell - meta.string.shell string.unquoted.shell - - match: (?=\}) - fail: brace-interpolation + - meta_scope: string.quoted.single.shell + - match: \' + scope: punctuation.definition.string.end.shell + pop: 1 - include: line-continuations - - include: brace-interpolation-series-content + - include: string-prototype + - include: string-escapes-ansi-c - brace-interpolation-series-body: + string-double-quoted-body: + - clear_scopes: 1 # clear `string.unquoted` - meta_include_prototype: false - - meta_content_scope: - meta.interpolation.brace.shell - meta.string.shell string.unquoted.shell - - include: brace-interpolation-end - - include: brace-interpolation-series-content - - brace-interpolation-series-content: - - match: \, - scope: - meta.interpolation.brace.shell - punctuation.separator.sequence.shell - set: brace-interpolation-series-body - - include: line-continuations - - include: pattern-main-content - - match: '{{word_break}}' - fail: brace-interpolation - - brace-interpolation-end: - - match: \} - scope: - meta.interpolation.brace.shell - punctuation.section.interpolation.end.shell - pop: 2 + - meta_scope: string.quoted.double.shell + - match: \" + scope: punctuation.definition.string.end.shell + pop: 1 - include: line-continuations + - include: string-prototype + - include: string-escapes + - include: string-interpolations - brace-interpolation-fallback: + string-single-quoted-body: + - clear_scopes: 1 # clear `string.unquoted` - meta_include_prototype: false - - match: \{ + - meta_scope: string.quoted.single.shell + - match: \' + scope: punctuation.definition.string.end.shell pop: 1 + - include: string-prototype -###[ COMMAND EXPANSIONS ]###################################################### + any-escapes: + - match: \\. + scope: constant.character.escape.shell - expansions-command: - - match: (\$)(\() - captures: - 1: punctuation.definition.variable.shell - 2: punctuation.section.interpolation.begin.shell - push: expansion-command-body - - match: \` - scope: - meta.interpolation.command.shell - punctuation.section.interpolation.begin.shell - embed: statements - embed_scope: meta.interpolation.command.shell - escape: '{{no_escape_behind}}\`' - escape_captures: - 0: meta.interpolation.command.shell - punctuation.section.interpolation.end.shell - - expansion-command-body: - - meta_scope: meta.interpolation.command.shell - - match: \s*(\)) - captures: - 1: punctuation.section.interpolation.end.shell - pop: 1 - - include: statements - -###[ JOB EXPANSIONS ]########################################################## - - expansions-job: - # There are a number of ways to refer to a job in the shell. - # The symbols ‘%%’ and ‘%+’ refer to the shell’s notion of the current job, - # which is the last job stopped while it was in the foreground or started in - # the background. The previous job may be referenced using ‘%-’. - # Job number n may be referred to as ‘%n’. - - match: (%)([-+%]|\d+) - scope: - meta.interpolation.job.shell - variable.language.job.shell - captures: - 1: punctuation.definition.variable.shell - # A job may also be referred to using a prefix of the name used to start it, - # or using a substring that appears in its command line. For example, ‘%ce’ - # refers to a stopped ce job. Using ‘%?ce’, on the other hand, refers to any - # job containing the string ‘ce’ in its command line. If the prefix or - # substring matches more than one job, Bash reports an error. - # A single ‘%’ (with no accompanying job specification) also refers to the - # current job. - - match: (%)(?:(\??)\w+)? - scope: - meta.interpolation.job.shell - variable.other.readwrite.shell - captures: - 1: punctuation.definition.variable.shell - 2: keyword.operator.match.shell - -###[ PARAMETER EXPANSIONS ]#################################################### - - expansions-parameter: - - match: (\$)(\{) - captures: - 1: punctuation.definition.variable.shell - 2: punctuation.section.interpolation.begin.shell - push: - - expansion-parameter-meta - - expansion-parameter-modifier - - expansion-parameter-name - - expansion-parameter-operator - # https://www.gnu.org/software/bash/manual/bash.html#Positional-Parameters - - match: (\$)\d - scope: meta.interpolation.parameter.shell variable.language.positional.shell - captures: - 1: punctuation.definition.variable.shell - # https://www.gnu.org/software/bash/manual/bash.html#Shell-Variables - - match: (\$){{builtin_variable}} - scope: meta.interpolation.parameter.shell variable.language.builtin.shell - captures: - 1: punctuation.definition.variable.shell - # https://www.gnu.org/software/bash/manual/bash.html#Special-Parameters - - match: (\$){{special_variable}} - scope: meta.interpolation.parameter.shell variable.language.special.shell - captures: - 1: punctuation.definition.variable.shell - - match: (\$){{identifier}} - scope: meta.interpolation.parameter.shell variable.other.readwrite.shell - captures: - 1: punctuation.definition.variable.shell - - expansion-parameter-meta: - - meta_include_prototype: false - - meta_scope: meta.interpolation.parameter.shell - - include: immediately-pop - - expansion-parameter-operator: - # Both ! and # are operators and special parameters at the same time. - # First char is operator only if not followed by } or operator - # Note: Matches may be wrong if line continuation follows, but it seems - # unlikely enough to accept it, instead of overcomplicating with branching. - - meta_include_prototype: false - # Expansion result is used as new parameter name to expand - # Adds a level of indirection to name resolution - - match: \!(?![/%,:=^}]|[-+?@][^}]) - scope: keyword.operator.expansion.indirection.shell - pop: 1 - # Length of var in words (array) or bytes - - match: \#(?![/%,:=^}]|[-+?@#][^}]) - scope: keyword.operator.expansion.length.shell - pop: 1 - - include: line-continuations - - include: immediately-pop - - expansion-parameter-name: - - meta_include_prototype: false - - match: \d+ - scope: variable.language.positional.shell - pop: 1 - - match: '{{builtin_variable}}(?=[-+*/%?,:=#^@}\[])' - scope: variable.language.builtin.shell - pop: 1 - - match: '{{special_variable}}(?=[-+*/%?,:=#^@}\[])' - scope: variable.language.special.shell - pop: 1 - - match: '' - set: expansion-parameter-name-chars - - expansion-parameter-name-chars: - - meta_content_scope: variable.other.readwrite.shell - # note: no quoted name parts allowed within parameter expansions - - match: '[@*](?!\w)' - scope: variable.language.special.shell - pop: 1 - - include: variable-name-chars - - expansion-parameter-modifier: - # ${parameter@operator} - - match: (?:(@)({{parameter_switch}}))?(}) - captures: - 1: keyword.operator.expansion.shell - 2: variable.parameter.switch.shell - 3: punctuation.section.interpolation.end.shell - pop: 1 - # ${parameter:=word} - - match: :?[-+=?] - scope: keyword.operator.assignment.shell - set: - - expansion-parameter-value - - maybe-tilde-interpolation - # ${parameter:offset:length} - - match: ':' - scope: keyword.operator.substring.begin.shell - set: expansion-parameter-substr-start - # ${parameter/pattern/word} - - match: /[/#%]? - scope: keyword.operator.substitution.shell - set: - - expansion-parameter-substitution-pattern - - maybe-tilde-interpolation - # ${parameter#pattern} - # ${parameter##pattern} - # ${parameter%pattern} - # ${parameter%%pattern} - # ${parameter^pattern} - # ${parameter^^pattern} - # ${parameter,pattern} - # ${parameter,,pattern} - - match: (?:##?|%%?|\^\^?|,,?) - scope: keyword.operator.expansion.shell - set: - - expansion-parameter-pattern - - maybe-tilde-interpolation - - include: variable-subscriptions - - expansion-parameter-substr-start: - - match: ':' - scope: keyword.operator.substring.end.shell - set: expansion-parameter-expression - - include: expansion-parameter-expression - - expansion-parameter-expression: - - include: expansion-parameter-end - - include: expressions - - expansion-parameter-pattern: - # [3.5.8.1] Pattern Matching in parameter expansions - - meta_content_scope: meta.string.regexp.shell string.unquoted.shell - - include: expansion-parameter-end - - include: string-unquoted-content - - include: expansion-parameter-pattern-charsets - - include: expansion-parameter-pattern-groups - - include: pattern-wildcards - - expansion-parameter-pattern-charsets: - - match: (?=\[) - branch_point: expansion-parameter-pattern-charset - branch: - - expansion-parameter-pattern-charset - - pattern-charset-fallback - - expansion-parameter-pattern-charset: - - match: (\[)([!^]?) - captures: - 1: punctuation.definition.set.begin.regexp.shell - 2: keyword.operator.logical.regexp.shell - set: - - expansion-parameter-pattern-charset-body - - pattern-charset-begin - - expansion-parameter-pattern-charset-body: - - meta_scope: meta.set.regexp.shell - - match: $|(?=\}) # bailout at end parameter - fail: expansion-parameter-pattern-charset - - include: pattern-charset-end - - include: pattern-charset-content - - expansion-parameter-pattern-groups: - - match: ([?*+@!])(\() - captures: - 1: string.unquoted.shell keyword.operator.quantifier.regexp.shell - 2: meta.group.regexp.shell string.unquoted.shell punctuation.definition.group.begin.regexp.shell - push: expansion-parameter-pattern-group-body - - expansion-parameter-pattern-group-body: - - clear_scopes: 1 # clear `string.unquoted` - - meta_content_scope: meta.group.regexp.shell string.unquoted.shell - - include: pattern-group-end - - include: string-unquoted-content - - include: expansion-parameter-pattern-groups - - include: expansion-parameter-pattern-group-charsets - - include: pattern-operators - - include: pattern-wildcards - - include: brace-pop - - expansion-parameter-pattern-group-charsets: - - match: (?=\[) - branch_point: expansion-parameter-pattern-group-charset - branch: - - expansion-parameter-pattern-group-charset - - pattern-charset-fallback - - expansion-parameter-pattern-group-charset: - - match: (\[)([!^]?) - captures: - 1: punctuation.definition.set.begin.regexp.shell - 2: keyword.operator.logical.regexp.shell - set: - - expansion-parameter-pattern-group-charset-body - - pattern-charset-begin - - expansion-parameter-pattern-group-charset-body: - - meta_scope: meta.set.regexp.shell - - match: $|(?=[)}]) # bailout at end of group or parameter - fail: expansion-parameter-pattern-group-charset - - include: pattern-charset-end - - include: pattern-charset-content - - expansion-parameter-substitution-pattern: - # [3.5.8.1] Pattern Matching in parameter expansions' substitutions - - meta_content_scope: meta.string.regexp.shell string.unquoted.shell - - match: / - scope: keyword.operator.substitution.shell - set: expansion-parameter-substitution-value - - include: expansion-parameter-pattern - - expansion-parameter-substitution-value: - - meta_include_prototype: false - - meta_content_scope: meta.string.shell string.unquoted.shell - - include: expansion-parameter-end - - include: string-unquoted-content - - expansion-parameter-value: - - meta_include_prototype: false - - meta_content_scope: meta.string.shell string.unquoted.shell - - include: expansion-parameter-end - - include: pattern-main-content - - expansion-parameter-end: - - match: \} - scope: punctuation.section.interpolation.end.shell - pop: 1 - - include: line-continuations - -###[ TILDE EXPANSIONS ]######################################################## + string-escapes: + - match: \\(?:e|033)\[\d{1,3}(?:;\d{1,3}){0,4}m + scope: constant.character.escape.color.shell + - match: \\[$`"\\] + scope: constant.character.escape.shell - maybe-tilde-interpolation: - - meta_include_prototype: false - # https://www.gnu.org/software/bash/manual/bash.html#Tilde-Expansion - - include: tilde-interpolation - - include: line-continuations - - include: immediately-pop + string-escapes-ansi-c: + - match: \\([abfnrtv'"?$`\\]|[0-8]{1,3}|x\h{1,8}|c[a-z]) + scope: constant.character.escape.shell - tilde-interpolation: - - match: \~ - scope: variable.language.tilde.shell - set: tilde-interpolation-modifier + string-interpolations: + - match: '{{is_interpolation}}' + push: string-interpolation-body - tilde-interpolation-modifier: + string-interpolation-body: - clear_scopes: 1 - meta_include_prototype: false - - meta_scope: meta.interpolation.tilde.shell - - include: tilde-expansion-modifier - - maybe-tilde-expansion: - - include: tilde-expansion - - include: line-continuations + - include: expansions-variables - include: immediately-pop - tilde-expansion: - - match: \~ - scope: variable.language.tilde.shell - set: tilde-expansion-modifier - - tilde-expansion-modifier: - - meta_include_prototype: false - - meta_scope: meta.interpolation.tilde.shell - - match: (?:[-+]?\d+|[-+](?![^/{{metachar}}])) - scope: variable.language.tilde.shell - pop: 1 - - match: '' - push: tilde-expansion-username - - tilde-expansion-username: - - meta_include_prototype: false - - meta_content_scope: meta.string.shell string.unquoted.username.shell - - include: line-continuations - - include: string-interpolations - - match: (?=[/{{metachar}}]) - pop: 2 + # for use by inheriting syntaxes to easily inject string interpolation + # in any kind of quoted or unquoted string + string-prototype: [] -###[ PATH PATTERN MATCHING ]################################################### +###[ STRING PATH PATTERN MATCHING ]############################################ string-path-patterns: - match: '{{word_begin}}' @@ -2246,6 +1980,8 @@ contexts: - match: '{{pathlist_separator}}' scope: punctuation.separator.sequence.shell +###[ PATH PATTERN MATCHING ]################################################### + path-pattern-begin: - include: tilde-expansion - include: path-pattern-quoted-begin @@ -2526,260 +2262,526 @@ contexts: - eregexp-charset-body - pattern-charset-begin - eregexp-charset-body: + eregexp-charset-body: + - meta_include_prototype: false + - meta_scope: meta.set.regexp.shell + - match: (?!\S) # also fail at eof + fail: eregexp-charset + - include: pattern-charset-end + - include: pattern-charset-content + + eregexp-group-charsets: + - match: (?=\[) + branch_point: eregexp-group-charset + branch: + - eregexp-group-charset + - pattern-charset-fallback + + eregexp-group-charset: + - match: (\[)(\^?) + captures: + 1: punctuation.definition.set.begin.regexp.shell + 2: keyword.operator.logical.regexp.shell + set: + - eregexp-group-charset-body + - pattern-charset-begin + + eregexp-group-charset-body: + - meta_include_prototype: false + - meta_scope: meta.set.regexp.shell + - match: (?=\)) + fail: eregexp-group-charset + - include: pattern-charset-end + - include: pattern-charset-content + + eregexp-anchors: + - match: '[$^]' + scope: keyword.control.anchor.regexp.shell + push: eregexp-unexpected-quantifier + + eregexp-operators: + - match: \| + scope: keyword.operator.alternation.regexp.shell + push: eregexp-unexpected-quantifier + + eregexp-quantifiers: + - match: '{{ranged_quantifier}}{{lazy_or_possessive}}' + scope: keyword.operator.quantifier.regexp.shell + push: eregexp-unexpected-quantifier + - match: '{{character_quantifier}}{{lazy_or_possessive}}' + scope: keyword.operator.quantifier.regexp.shell + push: eregexp-unexpected-quantifier + + eregexp-unexpected-quantifier: + - meta_include_prototype: false + - match: '{{ranged_quantifier}}{{lazy_or_possessive}}' + scope: invalid.illegal.unexpected-quantifier.regexp.shell + - match: '{{character_quantifier}}{{lazy_or_possessive}}' + scope: invalid.illegal.unexpected-quantifier.regexp.shell + - include: immediately-pop + + eregexp-literals: + - match: \. + scope: keyword.other.any.regexp.shell + - match: \) + scope: invalid.illegal.stray.regexp.shell + +###[ EXPANSIONS ]############################################################## + + expansions-patterns: + - include: pattern-groups + - include: pattern-charsets + - include: pattern-wildcards + + expansions-variables: + - include: expansions-arithmetic + - include: expansions-command + - include: expansions-parameter + +###[ ARITHMETIC EXPANSIONS ]################################################### + + expansions-arithmetic: + - match: (\$)(\(\() + captures: + 1: punctuation.definition.variable.shell + 2: punctuation.section.interpolation.begin.shell + push: arithmetic-expansion-parens-body + + arithmetic-expansion-parens-body: + - meta_scope: meta.interpolation.arithmetic.shell + - match: \)\) + scope: punctuation.section.interpolation.end.shell + pop: 1 + - include: expressions + +###[ BRACE EXPANSIONS ]######################################################## + + brace-interpolations: + # use branching as valid brace expansions must not exceed word boundaries + - match: (?={) + branch_point: brace-interpolation + branch: + - brace-interpolation-sequence + - brace-interpolation-series + - brace-interpolation-fallback + + brace-interpolation-sequence: + # sequence expression + - clear_scopes: 1 + - meta_include_prototype: false + - match: \{ + scope: + meta.interpolation.brace.shell + punctuation.section.interpolation.begin.shell + push: + - brace-interpolation-sequence-body + - brace-interpolation-sequence-begin + + brace-interpolation-sequence-begin: + - match: \.\. + scope: keyword.operator.range.shell + pop: 1 + - include: line-continuations + - include: brace-interpolation-sequence-content + + brace-interpolation-sequence-body: + - meta_content_scope: meta.interpolation.brace.shell + - match: \.\. + scope: keyword.operator.range.shell + - include: brace-interpolation-end + - include: brace-interpolation-sequence-content + + brace-interpolation-sequence-content: + - include: expansions-variables + - match: ([-+]?)(\d+) + scope: meta.number.integer.decimal.shell + captures: + 1: keyword.operator.arithmetic.shell + 2: constant.numeric.value.shell + - match: '[[:alpha:]]' + scope: constant.character.shell + - match: '' + fail: brace-interpolation + + brace-interpolation-series: + # series of comma-separated strings + - clear_scopes: 1 + - meta_include_prototype: false + - match: \{ + scope: + meta.interpolation.brace.shell + punctuation.section.interpolation.begin.shell + push: brace-interpolation-series-begin + + brace-interpolation-series-begin: + - meta_include_prototype: false + - meta_content_scope: + meta.interpolation.brace.shell + meta.string.shell string.unquoted.shell + - match: (?=\}) + fail: brace-interpolation + - include: line-continuations + - include: brace-interpolation-series-content + + brace-interpolation-series-body: + - meta_include_prototype: false + - meta_content_scope: + meta.interpolation.brace.shell + meta.string.shell string.unquoted.shell + - include: brace-interpolation-end + - include: brace-interpolation-series-content + + brace-interpolation-series-content: + - match: \, + scope: + meta.interpolation.brace.shell + punctuation.separator.sequence.shell + set: brace-interpolation-series-body + - include: line-continuations + - include: pattern-main-content + - match: '{{word_break}}' + fail: brace-interpolation + + brace-interpolation-end: + - match: \} + scope: + meta.interpolation.brace.shell + punctuation.section.interpolation.end.shell + pop: 2 + - include: line-continuations + + brace-interpolation-fallback: - meta_include_prototype: false - - meta_scope: meta.set.regexp.shell - - match: (?!\S) # also fail at eof - fail: eregexp-charset - - include: pattern-charset-end - - include: pattern-charset-content + - match: \{ + pop: 1 - eregexp-group-charsets: - - match: (?=\[) - branch_point: eregexp-group-charset - branch: - - eregexp-group-charset - - pattern-charset-fallback +###[ COMMAND EXPANSIONS ]###################################################### - eregexp-group-charset: - - match: (\[)(\^?) + expansions-command: + - match: (\$)(\() captures: - 1: punctuation.definition.set.begin.regexp.shell - 2: keyword.operator.logical.regexp.shell - set: - - eregexp-group-charset-body - - pattern-charset-begin + 1: punctuation.definition.variable.shell + 2: punctuation.section.interpolation.begin.shell + push: expansion-command-body + - match: \` + scope: + meta.interpolation.command.shell + punctuation.section.interpolation.begin.shell + embed: statements + embed_scope: meta.interpolation.command.shell + escape: '{{no_escape_behind}}\`' + escape_captures: + 0: meta.interpolation.command.shell + punctuation.section.interpolation.end.shell - eregexp-group-charset-body: - - meta_include_prototype: false - - meta_scope: meta.set.regexp.shell - - match: (?=\)) - fail: eregexp-group-charset - - include: pattern-charset-end - - include: pattern-charset-content + expansion-command-body: + - meta_scope: meta.interpolation.command.shell + - match: \s*(\)) + captures: + 1: punctuation.section.interpolation.end.shell + pop: 1 + - include: statements - eregexp-anchors: - - match: '[$^]' - scope: keyword.control.anchor.regexp.shell - push: eregexp-unexpected-quantifier +###[ JOB EXPANSIONS ]########################################################## - eregexp-operators: - - match: \| - scope: keyword.operator.alternation.regexp.shell - push: eregexp-unexpected-quantifier + expansions-job: + # There are a number of ways to refer to a job in the shell. + # The symbols ‘%%’ and ‘%+’ refer to the shell’s notion of the current job, + # which is the last job stopped while it was in the foreground or started in + # the background. The previous job may be referenced using ‘%-’. + # Job number n may be referred to as ‘%n’. + - match: (%)([-+%]|\d+) + scope: + meta.interpolation.job.shell + variable.language.job.shell + captures: + 1: punctuation.definition.variable.shell + # A job may also be referred to using a prefix of the name used to start it, + # or using a substring that appears in its command line. For example, ‘%ce’ + # refers to a stopped ce job. Using ‘%?ce’, on the other hand, refers to any + # job containing the string ‘ce’ in its command line. If the prefix or + # substring matches more than one job, Bash reports an error. + # A single ‘%’ (with no accompanying job specification) also refers to the + # current job. + - match: (%)(?:(\??)\w+)? + scope: + meta.interpolation.job.shell + variable.other.readwrite.shell + captures: + 1: punctuation.definition.variable.shell + 2: keyword.operator.match.shell - eregexp-quantifiers: - - match: '{{ranged_quantifier}}{{lazy_or_possessive}}' - scope: keyword.operator.quantifier.regexp.shell - push: eregexp-unexpected-quantifier - - match: '{{character_quantifier}}{{lazy_or_possessive}}' - scope: keyword.operator.quantifier.regexp.shell - push: eregexp-unexpected-quantifier +###[ PARAMETER EXPANSIONS ]#################################################### - eregexp-unexpected-quantifier: + expansions-parameter: + - match: (\$)(\{) + captures: + 1: punctuation.definition.variable.shell + 2: punctuation.section.interpolation.begin.shell + push: + - expansion-parameter-meta + - expansion-parameter-modifier + - expansion-parameter-name + - expansion-parameter-operator + # https://www.gnu.org/software/bash/manual/bash.html#Positional-Parameters + - match: (\$)\d + scope: meta.interpolation.parameter.shell variable.language.positional.shell + captures: + 1: punctuation.definition.variable.shell + # https://www.gnu.org/software/bash/manual/bash.html#Shell-Variables + - match: (\$){{builtin_variable}} + scope: meta.interpolation.parameter.shell variable.language.builtin.shell + captures: + 1: punctuation.definition.variable.shell + # https://www.gnu.org/software/bash/manual/bash.html#Special-Parameters + - match: (\$){{special_variable}} + scope: meta.interpolation.parameter.shell variable.language.special.shell + captures: + 1: punctuation.definition.variable.shell + - match: (\$){{identifier}} + scope: meta.interpolation.parameter.shell variable.other.readwrite.shell + captures: + 1: punctuation.definition.variable.shell + + expansion-parameter-meta: - meta_include_prototype: false - - match: '{{ranged_quantifier}}{{lazy_or_possessive}}' - scope: invalid.illegal.unexpected-quantifier.regexp.shell - - match: '{{character_quantifier}}{{lazy_or_possessive}}' - scope: invalid.illegal.unexpected-quantifier.regexp.shell + - meta_scope: meta.interpolation.parameter.shell - include: immediately-pop - eregexp-literals: - - match: \. - scope: keyword.other.any.regexp.shell - - match: \) - scope: invalid.illegal.stray.regexp.shell - -###[ LITERALS ]################################################################ - - booleans: - - match: false\b - scope: constant.language.boolean.false.shell - - match: true\b - scope: constant.language.boolean.true.shell + expansion-parameter-operator: + # Both ! and # are operators and special parameters at the same time. + # First char is operator only if not followed by } or operator + # Note: Matches may be wrong if line continuation follows, but it seems + # unlikely enough to accept it, instead of overcomplicating with branching. + - meta_include_prototype: false + # Expansion result is used as new parameter name to expand + # Adds a level of indirection to name resolution + - match: \!(?![/%,:=^}]|[-+?@][^}]) + scope: keyword.operator.expansion.indirection.shell + pop: 1 + # Length of var in words (array) or bytes + - match: \#(?![/%,:=^}]|[-+?@#][^}]) + scope: keyword.operator.expansion.length.shell + pop: 1 + - include: line-continuations + - include: immediately-pop - boolean: - - match: false\b - scope: constant.language.boolean.false.shell + expansion-parameter-name: + - meta_include_prototype: false + - match: \d+ + scope: variable.language.positional.shell pop: 1 - - match: true\b - scope: constant.language.boolean.true.shell + - match: '{{builtin_variable}}(?=[-+*/%?,:=#^@}\[])' + scope: variable.language.builtin.shell + pop: 1 + - match: '{{special_variable}}(?=[-+*/%?,:=#^@}\[])' + scope: variable.language.special.shell pop: 1 + - match: '' + set: expansion-parameter-name-chars - numbers: - # A leading ‘0x’ or ‘0X’ denotes hexadecimal. - - match: \b(0[xX])(\h*) - scope: meta.number.integer.hexadecimal.shell - captures: - 1: constant.numeric.base.shell - 2: constant.numeric.value.shell - # Constants with a leading 0 are interpreted as octal numbers. - - match: \b(0)([0-7]+) - scope: meta.number.integer.octal.shell - captures: - 1: constant.numeric.base.shell - 2: constant.numeric.value.shell - # Otherwise, numbers take the form [base#]n, where the optional base is a - # decimal number between 2 and 64 representing the arithmetic base, and n is - # a number in that base. When specifying n, the digits greater than 9 are - # represented by the lowercase letters, the uppercase letters, ‘@’, and ‘_’, - # in that order. - - match: \b(\d+#)([a-zA-Z0-9@_]+) - scope: meta.number.integer.other.shell + expansion-parameter-name-chars: + - meta_content_scope: variable.other.readwrite.shell + # note: no quoted name parts allowed within parameter expansions + - match: '[@*](?!\w)' + scope: variable.language.special.shell + pop: 1 + - include: variable-name-chars + + expansion-parameter-modifier: + # ${parameter@operator} + - match: (?:(@)({{parameter_switch}}))?(}) captures: - 1: constant.numeric.base.shell - 2: constant.numeric.value.shell - # If base# is omitted, then base 10 is used. - - match: \b\d+(?![.\w]) - scope: meta.number.integer.decimal.shell constant.numeric.value.shell + 1: keyword.operator.expansion.shell + 2: variable.parameter.switch.shell + 3: punctuation.section.interpolation.end.shell + pop: 1 + # ${parameter:=word} + - match: :?[-+=?] + scope: keyword.operator.assignment.shell + set: + - expansion-parameter-value + - maybe-tilde-interpolation + # ${parameter:offset:length} + - match: ':' + scope: keyword.operator.substring.begin.shell + set: expansion-parameter-substr-start + # ${parameter/pattern/word} + - match: /[/#%]? + scope: keyword.operator.substitution.shell + set: + - expansion-parameter-substitution-pattern + - maybe-tilde-interpolation + # ${parameter#pattern} + # ${parameter##pattern} + # ${parameter%pattern} + # ${parameter%%pattern} + # ${parameter^pattern} + # ${parameter^^pattern} + # ${parameter,pattern} + # ${parameter,,pattern} + - match: (?:##?|%%?|\^\^?|,,?) + scope: keyword.operator.expansion.shell + set: + - expansion-parameter-pattern + - maybe-tilde-interpolation + - include: variable-subscriptions + + expansion-parameter-substr-start: + - match: ':' + scope: keyword.operator.substring.end.shell + set: expansion-parameter-expression + - include: expansion-parameter-expression - number: - # Note: Leading sign is scoped as operator for consistent highlighting as - # we can't distinguish operators from sign for sure everywhere. - - match: ([-+]?)(0[xX])(\h*){{word_break}} - scope: meta.number.integer.hexadecimal.shell - captures: - 1: keyword.operator.arithmetic.shell - 2: constant.numeric.base.shell - 3: constant.numeric.value.shell - pop: 1 - - match: ([-+]?)(0)([0-7]+){{word_break}} - scope: meta.number.integer.octal.shell - captures: - 1: keyword.operator.arithmetic.shell - 2: constant.numeric.base.shell - 3: constant.numeric.value.shell - pop: 1 - - match: ([-+]?)(\d+#)([a-zA-Z0-9@_]+){{word_break}} - scope: meta.number.integer.other.she - captures: - 1: keyword.operator.arithmetic.shell - 2: constant.numeric.base.shell - 3: constant.numeric.value.shell - # If base# is omitted, then base 10 is used. - - match: ([-+]?)(\d+){{word_break}} - scope: meta.number.integer.decimal.shell + expansion-parameter-expression: + - include: expansion-parameter-end + - include: expressions + + expansion-parameter-pattern: + # [3.5.8.1] Pattern Matching in parameter expansions + - meta_content_scope: meta.string.regexp.shell string.unquoted.shell + - include: expansion-parameter-end + - include: string-unquoted-content + - include: expansion-parameter-pattern-charsets + - include: expansion-parameter-pattern-groups + - include: pattern-wildcards + + expansion-parameter-pattern-charsets: + - match: (?=\[) + branch_point: expansion-parameter-pattern-charset + branch: + - expansion-parameter-pattern-charset + - pattern-charset-fallback + + expansion-parameter-pattern-charset: + - match: (\[)([!^]?) captures: - 1: keyword.operator.arithmetic.shell - 2: constant.numeric.value.shell - pop: 1 + 1: punctuation.definition.set.begin.regexp.shell + 2: keyword.operator.logical.regexp.shell + set: + - expansion-parameter-pattern-charset-body + - pattern-charset-begin - literal-unquoted-content: - - match: \$?\" - scope: punctuation.definition.quoted.begin.shell - push: literal-double-quoted-body - - match: \$' - scope: punctuation.definition.quoted.begin.shell - push: literal-ansi-c-body - - match: \' - scope: punctuation.definition.quoted.begin.shell - push: literal-single-quoted-body - - include: string-prototype - - include: any-escapes - - include: brace-interpolations - - include: string-interpolations + expansion-parameter-pattern-charset-body: + - meta_scope: meta.set.regexp.shell + - match: $|(?=\}) # bailout at end parameter + fail: expansion-parameter-pattern-charset + - include: pattern-charset-end + - include: pattern-charset-content - literal-ansi-c-body: - - match: \' - scope: punctuation.definition.quoted.end.shell - pop: 1 - - include: line-continuations - - include: string-prototype - - include: string-escapes-ansi-c + expansion-parameter-pattern-groups: + - match: ([?*+@!])(\() + captures: + 1: string.unquoted.shell keyword.operator.quantifier.regexp.shell + 2: meta.group.regexp.shell string.unquoted.shell punctuation.definition.group.begin.regexp.shell + push: expansion-parameter-pattern-group-body - literal-double-quoted-body: - - match: \" - scope: punctuation.definition.quoted.end.shell - pop: 1 - - include: line-continuations - - include: string-prototype - - include: string-escapes - - include: string-interpolations + expansion-parameter-pattern-group-body: + - clear_scopes: 1 # clear `string.unquoted` + - meta_content_scope: meta.group.regexp.shell string.unquoted.shell + - include: pattern-group-end + - include: string-unquoted-content + - include: expansion-parameter-pattern-groups + - include: expansion-parameter-pattern-group-charsets + - include: pattern-operators + - include: pattern-wildcards + - include: brace-pop - literal-single-quoted-body: - - match: \' - scope: punctuation.definition.quoted.end.shell - pop: 1 - - include: string-prototype + expansion-parameter-pattern-group-charsets: + - match: (?=\[) + branch_point: expansion-parameter-pattern-group-charset + branch: + - expansion-parameter-pattern-group-charset + - pattern-charset-fallback -###[ STRINGS ]################################################################# + expansion-parameter-pattern-group-charset: + - match: (\[)([!^]?) + captures: + 1: punctuation.definition.set.begin.regexp.shell + 2: keyword.operator.logical.regexp.shell + set: + - expansion-parameter-pattern-group-charset-body + - pattern-charset-begin - string-unquoted-content: - # [Bash] 3.1.2.5 - - match: \$?\" - scope: punctuation.definition.string.begin.shell - push: string-double-quoted-body - # [Bash] 3.1.2.4 - - match: \$' - scope: punctuation.definition.string.begin.shell - push: string-ansi-c-body - - match: \' - scope: punctuation.definition.string.begin.shell - push: string-single-quoted-body - - include: string-prototype - - include: any-escapes - - include: brace-interpolations - - include: string-interpolations + expansion-parameter-pattern-group-charset-body: + - meta_scope: meta.set.regexp.shell + - match: $|(?=[)}]) # bailout at end of group or parameter + fail: expansion-parameter-pattern-group-charset + - include: pattern-charset-end + - include: pattern-charset-content - string-ansi-c-body: - - clear_scopes: 1 # clear `string.unquoted` + expansion-parameter-substitution-pattern: + # [3.5.8.1] Pattern Matching in parameter expansions' substitutions + - meta_content_scope: meta.string.regexp.shell string.unquoted.shell + - match: / + scope: keyword.operator.substitution.shell + set: expansion-parameter-substitution-value + - include: expansion-parameter-pattern + + expansion-parameter-substitution-value: - meta_include_prototype: false - - meta_scope: string.quoted.single.shell - - match: \' - scope: punctuation.definition.string.end.shell - pop: 1 - - include: line-continuations - - include: string-prototype - - include: string-escapes-ansi-c + - meta_content_scope: meta.string.shell string.unquoted.shell + - include: expansion-parameter-end + - include: string-unquoted-content - string-double-quoted-body: - - clear_scopes: 1 # clear `string.unquoted` + expansion-parameter-value: - meta_include_prototype: false - - meta_scope: string.quoted.double.shell - - match: \" - scope: punctuation.definition.string.end.shell + - meta_content_scope: meta.string.shell string.unquoted.shell + - include: expansion-parameter-end + - include: pattern-main-content + + expansion-parameter-end: + - match: \} + scope: punctuation.section.interpolation.end.shell pop: 1 - include: line-continuations - - include: string-prototype - - include: string-escapes - - include: string-interpolations - string-single-quoted-body: - - clear_scopes: 1 # clear `string.unquoted` +###[ TILDE EXPANSIONS ]######################################################## + + maybe-tilde-interpolation: - meta_include_prototype: false - - meta_scope: string.quoted.single.shell - - match: \' - scope: punctuation.definition.string.end.shell - pop: 1 - - include: string-prototype + # https://www.gnu.org/software/bash/manual/bash.html#Tilde-Expansion + - include: tilde-interpolation + - include: line-continuations + - include: immediately-pop - any-escapes: - - match: \\. - scope: constant.character.escape.shell + tilde-interpolation: + - match: \~ + scope: variable.language.tilde.shell + set: tilde-interpolation-modifier - string-escapes: - - match: \\(?:e|033)\[\d{1,3}(?:;\d{1,3}){0,4}m - scope: constant.character.escape.color.shell - - match: \\[$`"\\] - scope: constant.character.escape.shell + tilde-interpolation-modifier: + - clear_scopes: 1 + - meta_include_prototype: false + - meta_scope: meta.interpolation.tilde.shell + - include: tilde-expansion-modifier - string-escapes-ansi-c: - - match: \\([abfnrtv'"?$`\\]|[0-8]{1,3}|x\h{1,8}|c[a-z]) - scope: constant.character.escape.shell + maybe-tilde-expansion: + - include: tilde-expansion + - include: line-continuations + - include: immediately-pop - string-interpolations: - - match: '{{is_interpolation}}' - push: string-interpolation-body + tilde-expansion: + - match: \~ + scope: variable.language.tilde.shell + set: tilde-expansion-modifier - string-interpolation-body: - - clear_scopes: 1 + tilde-expansion-modifier: - meta_include_prototype: false - - include: expansions-variables - - include: immediately-pop + - meta_scope: meta.interpolation.tilde.shell + - match: (?:[-+]?\d+|[-+](?![^/{{metachar}}])) + scope: variable.language.tilde.shell + pop: 1 + - match: '' + push: tilde-expansion-username - # for use by inheriting syntaxes to easily inject string interpolation - # in any kind of quoted or unquoted string - string-prototype: [] + tilde-expansion-username: + - meta_include_prototype: false + - meta_content_scope: meta.string.shell string.unquoted.username.shell + - include: line-continuations + - include: string-interpolations + - match: (?=[/{{metachar}}]) + pop: 2 ###[ VARIABLES ]############################################################### From ef210ad1989ca3476cc035dfcfc7e33da6391a1b Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 20 Jul 2024 21:33:27 +0200 Subject: [PATCH 021/113] [ShellScript] Add arithmetic highlighting in assignment values This commit... 1. enables support for correctly scoping literal and arithmetic assignment values in `declare` commands and its friends. 2. fixes unsupported nested `(...)` in value sequences. The following is illegal `var=(foo (bar baz))`. 3. distinguishes option assignment values and variable assignment values. Only the latter supports value sequences wrapped in parens. --- ShellScript/Bash.sublime-syntax | 484 ++++++++++++++---- ShellScript/test/syntax_test_bash.sh | 728 +++++++++++++++++++++++---- 2 files changed, 1007 insertions(+), 205 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 832f4a0746..01e073ee38 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -68,6 +68,9 @@ variables: opt_punctuation: '(--|[-+]){{word_begin}}' opt_break: (?![^={{metachar}}]) + variable_begin: (?={{variable_first_char}}) + variable_first_char: '[[:alpha:]_''"$%]' + word_begin: (?=\S) word_break: (?!{{word_char}}) word_char: '[^{{metachar}}]' @@ -256,8 +259,7 @@ contexts: - include: def-functions - include: booleans - include: cmd-basic - - match: '[)}\]]' - scope: invalid.illegal.stray.shell + - include: illegal-stray statement: - include: statements @@ -435,8 +437,7 @@ contexts: def-variables: - match: (?={{identifier}}(?:\[[^\]]*\])*{{varassign}}) push: - - variable-value-assignment - - variable-subscription + - literal-array-value-assignment - variable-name-begin variable-subscription: @@ -466,60 +467,6 @@ contexts: - include: eoc-pop - include: string-unquoted-content - variable-value-assignment: - - match: '{{varassign}}' - scope: keyword.operator.assignment.shell - set: variable-value - - include: line-continuations - - include: immediately-pop - - variable-value: - - meta_include_prototype: false - - match: \( - scope: punctuation.section.sequence.begin.shell - set: variable-value-list-body - - include: line-continuations - - include: boolean - - include: number - - include: string-path-pattern - - include: immediately-pop - - variable-value-list-body: - - meta_scope: meta.sequence.shell - - match: \) - scope: punctuation.section.sequence.end.shell - pop: 1 - - match: \[ - scope: punctuation.definition.key.begin.shell - push: variable-mapping-key-body - - include: comments - - match: (?=\S) - push: variable-value - - variable-mapping-key-body: - - meta_scope: meta.mapping.key.shell - - meta_content_scope: entity.name.key.shell - - match: \] - scope: punctuation.definition.key.end.shell - set: variable-mapping-value-assignment - - include: eoc-pop - - include: literal-unquoted-content - - variable-mapping-value-assignment: - - meta_content_scope: meta.mapping.shell - - match: '{{varassign}}' - scope: meta.mapping.shell keyword.operator.assignment.shell - set: - - variable-mapping-meta - - variable-value - - include: line-continuations - - include: immediately-pop - - variable-mapping-meta: - - meta_include_prototype: false - - meta_content_scope: meta.mapping.value.shell - - include: immediately-pop - ###[ ALIAS BUILTINS ]########################################################## cmd-alias: @@ -553,7 +500,7 @@ contexts: - include: cmd-args-end - match: = scope: keyword.operator.assignment.shell - push: variable-value + push: literal-array-value - match: '{{word_begin}}' push: alias-name-chars @@ -671,25 +618,74 @@ contexts: - include: immediately-pop cmd-declare-args: - - match: ([-+])(?:[aAgiIlnrtux]*[Ff][aAgiIlnrtux]*) + # option contains -f or -F + - match: ([-+])[aAgiIlnrtux]*[Ff][aAgiIlnrtux]*{{opt_break}} + scope: + meta.parameter.option.shell + variable.parameter.option.shell + captures: + 1: punctuation.definition.parameter.shell + set: cmd-declare-functions + # option contains any mix of iA or Ai + - match: ([-+])(?:[agIlnrtux]*?i[iagIlnrtux]*?A|[agIlnrtux]*?A[aAgIlnrtux]*?i)[aAgiIlnrtux]*?{{opt_break}} + scope: + meta.parameter.option.shell + variable.parameter.option.shell + captures: + 1: punctuation.definition.parameter.shell + set: cmd-declare-variables-with-arithmetic-mappings + # option contains any mix of ia or ai or i + - match: ([-+])[aAgiIlnrtux]*?i[aAgiIlnrtux]*?{{opt_break}} + scope: + meta.parameter.option.shell + variable.parameter.option.shell + captures: + 1: punctuation.definition.parameter.shell + set: cmd-declare-variables-with-arithmetic-values + # option contains contains A + - match: ([-+])[aAgIlnrtux]*?A[aAgIlnrtux]*?{{opt_break}} scope: meta.parameter.option.shell variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell - set: cmd-declare-options-then-functions - - include: cmd-declare-options-then-variables + set: cmd-declare-variables-with-literal-mappings + # anything else is a variable with any value + - include: cmd-declare-options + - include: cmd-args-end-of-options-then-variables-literal-values - cmd-declare-options-then-functions: + cmd-declare-functions: - include: cmd-declare-options - include: cmd-args-end-of-options-then-function-declarations - cmd-declare-options-then-variables: + cmd-declare-variables-with-arithmetic-mappings: + - include: cmd-declare-options + - include: cmd-args-end-of-options-then-variables-arithmetic-mappings + + cmd-declare-variables-with-arithmetic-values: + - match: ([-+])[aAgiIlnrtux]*?A[aAgiIlnrtux]*?{{opt_break}} + scope: + meta.parameter.option.shell + variable.parameter.option.shell + captures: + 1: punctuation.definition.parameter.shell + set: cmd-declare-variables-with-arithmetic-mappings + - include: cmd-declare-options + - include: cmd-args-end-of-options-then-variables-arithmetic-values + + cmd-declare-variables-with-literal-mappings: + - match: ([-+])[aAgiIlnrtux]*?i[aAgiIlnrtux]*?{{opt_break}} + scope: + meta.parameter.option.shell + variable.parameter.option.shell + captures: + 1: punctuation.definition.parameter.shell + set: cmd-declare-variables-with-arithmetic-mappings - include: cmd-declare-options - - include: cmd-args-end-of-options-then-variables + - include: cmd-args-end-of-options-then-variables-literal-mappings cmd-declare-options: - - match: ([-+])(?:[aAgiIlnrtux]+|p) + - match: ([-+])(?:[aAgiIlnrtux]+|p){{opt_break}} scope: meta.parameter.option.shell variable.parameter.option.shell @@ -770,7 +766,7 @@ contexts: - include: immediately-pop cmd-export-args: - - match: ([-+])n?fn? + - match: ([-+])n?fn?{{opt_break}} scope: meta.parameter.option.shell variable.parameter.option.shell @@ -785,10 +781,10 @@ contexts: cmd-export-options-then-variables: - include: cmd-export-options - - include: cmd-args-end-of-options-then-variables + - include: cmd-args-end-of-options-then-variables-literal-values cmd-export-options: - - match: ([-+])[np] + - match: ([-+])[np]{{opt_break}} scope: meta.parameter.option.shell variable.parameter.option.shell @@ -812,25 +808,45 @@ contexts: - include: immediately-pop cmd-readonly-args: - - match: ([-+])[aA]*f[aA]* + # options contain -f => function declarations (wins over -A) + - match: ([-+])[aA]*f[aA]*{{opt_break}} scope: meta.parameter.option.shell variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell set: cmd-readonly-options-then-functions + # options contain -A => associative array (wins over -a) + - match: ([-+])a?Aa?{{opt_break}} + scope: + meta.parameter.option.shell + variable.parameter.option.shell + captures: + 1: punctuation.definition.parameter.shell + set: cmd-readonly-options-then-mappings - include: cmd-readonly-options-then-variables cmd-readonly-options-then-functions: - include: cmd-readonly-options - - include: cmd-args-end-of-options-then-functions + - include: cmd-args-end-of-options-then-function-declarations + + cmd-readonly-options-then-mappings: + - match: ([-+])[aA]*f[aA]*{{opt_break}} + scope: + meta.parameter.option.shell + variable.parameter.option.shell + captures: + 1: punctuation.definition.parameter.shell + set: cmd-readonly-options-then-functions + - include: cmd-readonly-options + - include: cmd-args-end-of-options-then-variables-literal-mappings cmd-readonly-options-then-variables: - include: cmd-readonly-options - - include: cmd-args-end-of-options-then-variables + - include: cmd-args-end-of-options-then-variables-literal-values cmd-readonly-options: - - match: ([-+])(?:[aAf]+|p) + - match: ([-+])(?:[aAf]+|p){{opt_break}} scope: meta.parameter.option.shell variable.parameter.option.shell @@ -1022,21 +1038,21 @@ contexts: support.function.unalias.shell push: - cmd-unalias-args-meta - - cmd-unalias-options + - cmd-unalias-args cmd-unalias-args-meta: - meta_include_prototype: false - meta_content_scope: meta.function-call.arguments.shell - include: immediately-pop - cmd-unalias-options: - - match: ([-+])a + cmd-unalias-args: + - match: ([-+])a{{opt_break}} scope: meta.parameter.option.shell variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell - - include: cmd-args-end-of-options-then-functions + - include: cmd-args-end-of-options-then-function-references ###[ UNSET BUILTINS ]########################################################## @@ -1055,7 +1071,7 @@ contexts: - include: immediately-pop cmd-unset-args: - - match: ([-+])[nv]?f[nv]? + - match: ([-+])[nv]?f[nv]?{{opt_break}} scope: meta.parameter.option.shell variable.parameter.option.shell @@ -1066,14 +1082,14 @@ contexts: cmd-unset-options-then-functions: - include: cmd-unset-options - - include: cmd-args-end-of-options-then-functions + - include: cmd-args-end-of-options-then-function-references cmd-unset-options-then-variables: - include: cmd-unset-options - - include: cmd-args-end-of-options-then-variables + - include: cmd-args-end-of-options-then-variables-literal-values cmd-unset-options: - - match: ([-+])[nv]+ + - match: ([-+])[nv]+{{opt_break}} scope: meta.parameter.option.shell variable.parameter.option.shell @@ -1182,19 +1198,27 @@ contexts: - meta_include_prototype: false - match: = scope: keyword.operator.assignment.shell - set: variable-value + set: cmd-args-option-value - include: line-continuations - include: immediately-pop cmd-args-option-maybe-value: # NOTE: this context is used in commands-builtin-shell-bash.sublime-syntax - meta_include_prototype: false - - match: '{{wspace}}(?![-\]}{{metachar}}])' - set: variable-value + - match: '{{wspace}}(?![-+\]}{{metachar}}])' + set: cmd-args-option-value - include: number - include: line-continuations - include: immediately-pop + cmd-args-option-value: + - meta_include_prototype: false + - include: line-continuations + - include: boolean + - include: number + - include: string-path-pattern + - include: immediately-pop + cmd-args-end-of-options-then-ambigious: - match: --{{word_break}} scope: keyword.operator.end-of-options.shell @@ -1226,14 +1250,14 @@ contexts: - match: '{{word_break}}' pop: 1 - cmd-args-end-of-options-then-functions: + cmd-args-end-of-options-then-function-references: - include: cmd-args-illegal-options - match: --{{word_break}} scope: keyword.operator.end-of-options.shell - set: cmd-args-functions - - include: cmd-args-functions + set: cmd-args-function-references + - include: cmd-args-function-references - cmd-args-functions: + cmd-args-function-references: - include: cmd-args-end - match: '{{word_begin}}' push: function-reference-name-chars @@ -1245,19 +1269,65 @@ contexts: - match: '{{word_break}}' pop: 1 - cmd-args-end-of-options-then-variables: + cmd-args-end-of-options-then-variables-arithmetic-mappings: - include: cmd-args-illegal-options - match: --{{word_break}} scope: keyword.operator.end-of-options.shell - set: cmd-args-variables - - include: cmd-args-variables + set: cmd-args-variables-arithmetic-mappings + - include: cmd-args-variables-arithmetic-mappings - cmd-args-variables: + cmd-args-variables-arithmetic-mappings: - include: cmd-args-end - - match: '{{varassign}}' - scope: keyword.operator.assignment.shell - push: variable-value - - include: variables + - match: '{{variable_begin}}' + push: + - arithmetic-mapping-value-assignment + - variable-name-begin + - include: illegal-words + + cmd-args-end-of-options-then-variables-arithmetic-values: + - include: cmd-args-illegal-options + - match: --{{word_break}} + scope: keyword.operator.end-of-options.shell + set: cmd-args-variables-arithmetic-values + - include: cmd-args-variables-arithmetic-values + + cmd-args-variables-arithmetic-values: + - include: cmd-args-end + - match: '{{variable_begin}}' + push: + - arithmetic-array-value-assignment + - variable-name-begin + - include: illegal-words + + cmd-args-end-of-options-then-variables-literal-mappings: + - include: cmd-args-illegal-options + - match: --{{word_break}} + scope: keyword.operator.end-of-options.shell + set: cmd-args-variables-literal-mappings + - include: cmd-args-variables-literal-mappings + + cmd-args-variables-literal-mappings: + - include: cmd-args-end + - match: '{{variable_begin}}' + push: + - literal-mapping-value-assignment + - variable-name-begin + - include: illegal-words + + cmd-args-end-of-options-then-variables-literal-values: + - include: cmd-args-illegal-options + - match: --{{word_break}} + scope: keyword.operator.end-of-options.shell + set: cmd-args-variables-literal-values + - include: cmd-args-variables-literal-values + + cmd-args-variables-literal-values: + - include: cmd-args-end + - match: '{{variable_begin}}' + push: + - literal-array-value-assignment + - variable-name-begin + - include: illegal-words cmd-args-values: - meta_include_prototype: false @@ -1405,6 +1475,208 @@ contexts: - include: cmd-args-end - include: string-path-patterns +###[ ARITHMETIC VALUE ASSIGNMENTS ]############################################ + + arithmetic-array-value-assignment: + # maybe variable subscripts followed by value assignment + - meta_content_scope: meta.variable.shell + - match: '{{varassign}}' + scope: keyword.operator.assignment.shell + set: arithmetic-array-value + - include: variable-subscriptions + - include: line-continuations + - include: immediately-pop + + arithmetic-array-value: + # maybe indexed array of or single arithmetic expression value + - meta_include_prototype: false + - include: line-continuations + - match: \( + scope: punctuation.section.sequence.begin.shell + set: arithmetic-explicit-mapping-body + - match: '' + set: arithmetic-value-body + + arithmetic-mapping-value-assignment: + # maybe variable subscripts followed by value assignment + - meta_content_scope: meta.variable.shell + - match: '{{varassign}}' + scope: keyword.operator.assignment.shell + set: arithmetic-mapping-value + - include: variable-subscriptions + - include: line-continuations + - include: immediately-pop + + arithmetic-mapping-value: + # maybe associative of or single arithmetic expression value + - meta_include_prototype: false + - include: line-continuations + - match: \( + scope: punctuation.section.sequence.begin.shell + set: arithmetic-mapping-begin + - match: '' + set: arithmetic-value-body + + arithmetic-mapping-begin: + - meta_scope: meta.sequence.list.shell + - include: list-end + - include: line-continuations + - include: comments + - match: (?=\[) + set: arithmetic-explicit-mapping-body + - match: (?=\S) + set: arithmetic-implicit-mapping-body + + arithmetic-explicit-mapping-body: + - meta_scope: meta.sequence.list.shell + - include: list-end + - include: comments + - include: explicit-mapping-keys + - include: arithmetic-operators + - include: numbers + - include: variables + - include: illegal-words + + arithmetic-implicit-mapping-body: + - meta_scope: meta.sequence.list.shell + - include: list-end + - include: comments + - match: '{{word_begin}}' + push: arithmetic-implicit-mapping-key-body + + arithmetic-implicit-mapping-key-body: + - meta_scope: meta.item-access.shell entity.name.key.shell + - include: line-continuations + - include: literal-unquoted-content + - match: '{{word_break}}' + set: arithmetic-implicit-mapping-value + + arithmetic-implicit-mapping-value: + - include: line-continuations + - include: comments + - match: '{{word_begin}}' + set: arithmetic-value-body + + arithmetic-value-body: + - match: '{{word_break}}' + pop: 1 + - include: line-continuations + - include: arithmetic-operators + - include: numbers + - include: variables + +###[ LITERAL VALUE ASSIGNMENTS ]############################################### + + literal-array-value-assignment: + # maybe variable subscripts followed by value assignment + - meta_content_scope: meta.variable.shell + - match: '{{varassign}}' + scope: keyword.operator.assignment.shell + set: literal-array-value + - include: variable-subscriptions + - include: line-continuations + - include: immediately-pop + + literal-array-value: + # maybe indexed array of or single literal/string value + - meta_include_prototype: false + - match: \( + scope: punctuation.section.sequence.begin.shell + set: literal-explicit-mapping-body + - include: line-continuations + - include: boolean + - include: string-path-pattern + - include: immediately-pop + + literal-mapping-value-assignment: + # maybe variable subscripts followed by value assignment + - meta_content_scope: meta.variable.shell + - match: '{{varassign}}' + scope: keyword.operator.assignment.shell + set: literal-mapping-value + - include: variable-subscriptions + - include: line-continuations + - include: immediately-pop + + literal-mapping-value: + # maybe associative array of or single literal/string value + - meta_include_prototype: false + - match: \( + scope: punctuation.section.sequence.begin.shell + set: literal-mapping-begin + - include: line-continuations + - include: boolean + - include: string-path-pattern + - include: immediately-pop + + literal-mapping-begin: + - meta_scope: meta.sequence.list.shell + - include: list-end + - include: line-continuations + - include: comments + - match: (?=\[) + set: literal-explicit-mapping-body + - match: (?=\S) + set: literal-implicit-mapping-body + + literal-explicit-mapping-body: + - meta_scope: meta.sequence.list.shell + - include: list-end + - include: comments + - include: explicit-mapping-keys + - include: booleans + - include: string-path-patterns + + literal-implicit-mapping-body: + - meta_scope: meta.sequence.list.shell + - include: list-end + - include: comments + - match: '{{word_begin}}' + push: literal-implicit-mapping-key-body + + literal-implicit-mapping-key-body: + - meta_scope: meta.item-access.shell entity.name.key.shell + - include: line-continuations + - include: literal-unquoted-content + - match: '{{word_break}}' + set: literal-implicit-mapping-value + + literal-implicit-mapping-value: + - include: line-continuations + - include: comments + - include: boolean + - include: string-path-pattern + +###[ ARRAY VALUE PROTOTYPES ]################################################## + + explicit-mapping-keys: + - match: \[ + scope: punctuation.section.item-access.begin.shell + push: explicit-mapping-key-body + + explicit-mapping-key-body: + - meta_scope: meta.item-access.shell + - meta_content_scope: entity.name.key.shell + - match: \] + scope: punctuation.section.item-access.end.shell + set: explicit-mapping-value-assignment + - include: literal-unquoted-content + + explicit-mapping-value-assignment: + - match: '{{varassign}}' + scope: keyword.operator.assignment.shell + pop: 1 + - include: line-continuations + - include: immediately-pop + + list-end: + - match: \) + scope: punctuation.section.sequence.end.shell + pop: 1 + - match: '[(<>]+' + scope: invalid.illegal.unexpected.shell + - include: line-continuations + ###[ EXPRESSIONS ]############################################################# expressions: @@ -2786,7 +3058,7 @@ contexts: ###[ VARIABLES ]############################################################### variables: - - match: '{{word_begin}}' + - match: '{{variable_begin}}' push: [variable-subscription, variable-name-begin] variable-name-begin: @@ -2803,3 +3075,21 @@ contexts: - include: literal-unquoted-content - match: '{{identifier_break}}' pop: 1 + +###[ ILLEGALS ]################################################################ + + illegal-stray: + - match: '[)}\]]' + scope: invalid.illegal.stray.shell + + illegal-words: + - match: '{{word_begin}}' + push: illegal-word-chars + + illegal-word-chars: + - meta_include_prototype: false + - meta_scope: invalid.illegal.unexpected.shell + - include: line-continuations + - include: literal-unquoted-content + - match: '{{word_break}}' + pop: 1 diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index 28f2b34648..fbc4dd8f65 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -2803,7 +2803,7 @@ x=0.19.8.1 x=10 # <- variable.other.readwrite.shell #^ keyword.operator.assignment.shell -# ^^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^^ meta.string.shell string.unquoted.shell # Spaces following an assignment token means an empty string value! x= pwd @@ -2950,41 +2950,38 @@ array=() # an empty array # ^ punctuation.section.sequence.begin # ^ punctuation.section.sequence.end -array=(one two three four -5 (foo bar baz) (5 6 7)) +array=(one two three four -5 (foo bar baz) #<- meta.variable.shell variable.other.readwrite.shell #^^^^ meta.variable.shell - meta.sequence # ^ - meta.variable - meta.sequence -# ^^^^^^^^^^^^^^^^^^^^^^^ meta.sequence.shell - meta.sequence meta.sequence -# ^^^^^^^^^^^^^ meta.sequence.shell meta.sequence.shell -# ^ meta.sequence.shell - meta.sequence meta.sequence -# ^^^^^^^ meta.sequence.shell meta.sequence.shell -# ^ meta.sequence.shell - meta.sequence meta.sequence -# ^ - meta +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.sequence.list.shell - meta.sequence meta.sequence +# ^ - meta #^^^^ variable.other.readwrite.shell # ^ keyword.operator.assignment.shell # ^ punctuation.section.sequence.begin.shell -# ^^^ string.unquoted.shell -# ^^^ string.unquoted.shell -# ^^^^^ string.unquoted.shell -# ^^^^ string.unquoted.shell -# ^ keyword.operator.arithmetic.shell -# ^ meta.number.integer.decimal.shell constant.numeric.value.shell -# ^ punctuation.section.sequence.begin.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ - meta.string - string +# ^^^ meta.string.shell string.unquoted.shell +# ^ - meta.string - string +# ^^^^^ meta.string.shell string.unquoted.shell +# ^ - meta.string - string +# ^^^^ meta.string.shell string.unquoted.shell +# ^ - meta.string - string +# ^^ meta.string.shell string.unquoted.shell +# ^^ - meta.string - string +# ^ invalid.illegal.unexpected.shell # ^^^ meta.string.shell string.unquoted.shell -# ^^^ string.unquoted.shell -# ^^^ string.unquoted.shell +# ^ - meta.string - string +# ^^^ meta.string.shell string.unquoted.shell +# ^ - meta.string - string +# ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.sequence.end.shell -# ^ punctuation.section.sequence.begin.shell -# ^ meta.number.integer.decimal.shell constant.numeric.value.shell -# ^ meta.number.integer.decimal.shell constant.numeric.value.shell -# ^ meta.number.integer.decimal.shell constant.numeric.value.shell -# ^^ punctuation.section.sequence.end.shell array=($one "two" ${three} 'four' $5) #<- meta.variable.shell variable.other.readwrite.shell #^^^^ meta.variable.shell #^^^^^ - meta.sequence -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.sequence.shell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.sequence.list.shell # ^ - meta.sequence # <- variable.other.readwrite.shell # ^ keyword.operator.assignment.shell @@ -3007,50 +3004,40 @@ array=($one "two" ${three} 'four' $5) array=([one]== ["two"]='what' [4+5]=qux [five]=0 [six]=0s) #^^^^^ - meta.sequence -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.sequence.shell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.sequence.list.shell # ^ - meta.sequence -# ^^^^^ meta.mapping.key.shell -# ^ meta.mapping.shell -# ^ meta.mapping.value.shell -# ^^^^^^^ meta.mapping.key.shell -# ^ meta.mapping.shell -# ^^^^^^ meta.mapping.value.shell -# ^^^^^ meta.mapping.key.shell -# ^ meta.mapping.shell -# ^^^ meta.mapping.value.shell -# ^^^^^^ meta.mapping.key.shell -# ^ meta.mapping.shell -# ^ meta.mapping.value.shell -# ^^^^^ meta.mapping.key.shell -# ^ meta.mapping.shell -# ^^ meta.mapping.value.shell +# ^^^^^ meta.item-access.shell +# ^^^^^^^ meta.item-access.shell +# ^^^^^ meta.item-access.shell +# ^^^^^^ meta.item-access.shell +# ^^^^^ meta.item-access.shell # ^ keyword.operator.assignment.shell # ^ punctuation.section.sequence.begin.shell -# ^ punctuation.definition.key.begin.shell +# ^ punctuation.section.item-access.begin.shell # ^^^ entity.name.key.shell -# ^ punctuation.definition.key.end.shell +# ^ punctuation.section.item-access.end.shell # ^ keyword.operator.assignment.shell # ^ meta.string.shell string.unquoted.shell - keyword -# ^ punctuation.definition.key.begin.shell +# ^ punctuation.section.item-access.begin.shell # ^^^^^ entity.name.key.shell # ^ punctuation.definition.quoted.begin.shell # ^ punctuation.definition.quoted.end.shell -# ^ punctuation.definition.key.end.shell +# ^ punctuation.section.item-access.end.shell # ^ keyword.operator.assignment.shell # ^^^^^^ string.quoted.single.shell -# ^ punctuation.definition.key.begin.shell +# ^ punctuation.section.item-access.begin.shell # ^^^ entity.name.key.shell - constant - keyword -# ^ punctuation.definition.key.end.shell +# ^ punctuation.section.item-access.end.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell -# ^ punctuation.definition.key.begin.shell +# ^ punctuation.section.item-access.begin.shell # ^^^^ entity.name.key.shell -# ^ punctuation.definition.key.end.shell +# ^ punctuation.section.item-access.end.shell # ^ keyword.operator.assignment.shell -# ^ meta.number.integer.decimal.shell constant.numeric.value.shell -# ^ punctuation.definition.key.begin.shell +# ^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.item-access.begin.shell # ^^^ entity.name.key.shell -# ^ punctuation.definition.key.end.shell +# ^ punctuation.section.item-access.end.shell # ^ keyword.operator.assignment.shell # ^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.sequence.end.shell @@ -3178,17 +3165,17 @@ foo=`(uname -r) 2>/dev/null` || foo=unknown # ^^^^^^^ meta.string.shell string.unquoted.shell commits=($(git rev-list --reverse --$abbrev-commit "$latest".. -- "$prefix")) -# ^ meta.sequence.shell - meta.interpolation -# ^^ meta.sequence.shell meta.string.shell meta.interpolation.command.shell - meta.function -# ^^^ meta.sequence.shell meta.string.shell meta.interpolation.command.shell meta.function-call.identifier.shell - meta.function meta.function -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.sequence.shell meta.string.shell meta.interpolation.command.shell meta.function-call.arguments.shell - meta.function meta.function +# ^ meta.sequence.list.shell - meta.interpolation +# ^^ meta.sequence.list.shell meta.string.shell meta.interpolation.command.shell - meta.function +# ^^^ meta.sequence.list.shell meta.string.shell meta.interpolation.command.shell meta.function-call.identifier.shell - meta.function meta.function +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.sequence.list.shell meta.string.shell meta.interpolation.command.shell meta.function-call.arguments.shell - meta.function meta.function # ^^ meta.parameter.option.shell - meta.parameter.option.shell meta.interpolation # ^^^^^^^ meta.parameter.option.shell meta.interpolation.parameter.shell # ^^^^^^^ meta.parameter.option.shell - meta.parameter.option.shell meta.interpolation # ^^^^^^^^^ meta.string.shell # ^^^^^^^^^ meta.string.shell -# ^ meta.sequence.shell meta.string.shell meta.interpolation.command.shell - meta.function -# ^ meta.sequence.shell - meta.interpolation +# ^ meta.sequence.list.shell meta.string.shell meta.interpolation.command.shell - meta.function +# ^ meta.sequence.list.shell - meta.interpolation # ^ punctuation.section.sequence.begin.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -3916,7 +3903,7 @@ foo=~/~${bar} # ^ punctuation.section.interpolation.end.shell foo=(~/~foo ~/~bar) -# ^^^^^^^^^^^^^^^ meta.sequence.shell +# ^^^^^^^^^^^^^^^ meta.sequence.list.shell # ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string # ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation - variable # ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string @@ -8952,91 +8939,492 @@ declare # comment declare foo # 'foo' is a variable name #^^^^^^ meta.declaration.variable.shell # ^^^^ meta.declaration.variable.arguments.shell -# ^ - meta.declaration.variable +# ^ - meta.declaration # <- keyword.declaration.variable.shell # ^ - variable.other.readwrite # ^ - meta.declaration.variable -declare +A # this is a comment +declare foo| # '|' terminates statement #^^^^^^ meta.declaration.variable.shell -# ^^^ meta.declaration.variable.arguments.shell -# ^ - meta.declaration.variable -# ^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell +# ^^^^ meta.declaration.variable.arguments.shell +# ^ - meta.declaration +# <- keyword.declaration.variable.shell +# ^ keyword.operator -declare -A foo bar # 'foo' and 'bar' are variable names +declare foo | # '|' terminates statement #^^^^^^ meta.declaration.variable.shell -# ^^^^^^^^^^^ meta.declaration.variable.arguments.shell -# ^ - meta.declaration.variable -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell +# ^^^^ meta.declaration.variable.arguments.shell +# ^ - meta.declaration +# <- keyword.declaration.variable.shell +# ^ keyword.operator -declare -I foo +declare foo& # '&' terminates statement #^^^^^^ meta.declaration.variable.shell -# ^^^^^^^ meta.declaration.variable.arguments.shell -# ^^ variable.parameter.option.shell -# ^^^ variable.other.readwrite.shell +# ^^^^ meta.declaration.variable.arguments.shell +# ^ - meta.declaration +# <- keyword.declaration.variable.shell +# ^ keyword.operator -declare ret; bar=foo # comment +declare foo & # '&' terminates statement #^^^^^^ meta.declaration.variable.shell # ^^^^ meta.declaration.variable.arguments.shell -# ^ - meta.declaration.variable +# ^ - meta.declaration # <- keyword.declaration.variable.shell -# ^ punctuation.terminator.statement.shell -# ^ keyword.operator.assignment.shell -# ^^^ meta.string.shell string.unquoted.shell -# ^ - meta.string - string - comment -# ^^^^^^^^^^ comment.line.number-sign.shell +# ^ keyword.operator -declare ret ; +declare foo ; # ';' terminates statement #^^^^^^ meta.declaration.variable.shell # ^^^^ meta.declaration.variable.arguments.shell -# ^ - meta.declaration.variable +# ^ - meta.declaration # <- keyword.declaration.variable.shell # ^ punctuation.terminator.statement.shell -declare ret& +declare foo; bar=baz # 2nd statement after ';' #^^^^^^ meta.declaration.variable.shell # ^^^^ meta.declaration.variable.arguments.shell -# ^ - meta.declaration.variable +# ^^ - meta.declaration # <- keyword.declaration.variable.shell -# ^ keyword.operator +#^^^^^^ keyword.declaration.variable.shell +# ^^^ variable.other.readwrite.shell +# ^ punctuation.terminator.statement.shell +# ^^^ variable.other.readwrite.shell +# ^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ - meta.string - string - comment +# ^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell -declare ret & +declare foo==bar baz =buz # assignment must immediately follow a variable #^^^^^^ meta.declaration.variable.shell -# ^^^^ meta.declaration.variable.arguments.shell -# ^ - meta.declaration.variable +# ^^^^^^^^^^^^^^^^^^ meta.declaration.variable.arguments.shell +# ^ - meta.declaration # <- keyword.declaration.variable.shell -# ^ keyword.operator +# ^ - variable +# ^^^ variable.other.readwrite.shell +# ^ keyword.operator.assignment.shell +# ^^^^ meta.string.shell string.unquoted.shell +# ^ - variable +# ^^^ variable.other.readwrite.shell +# ^ - variable +# ^^^^ invalid.illegal.unexpected.shell +# ^ - variable +declare foo= /dev/null && complete -F _upto upto # ^^^^^^^^ variable.function.shell # ^^ variable.parameter.option.shell +# declare called in command substituations + printFunction "$variableString1" "$(declare -p variableArray)" # ^ meta.string.shell string.quoted.double.shell punctuation.definition.string.begin.shell # ^^^^^^^^^^^^^^^^ meta.string.shell meta.interpolation.parameter.shell - string @@ -9447,7 +9837,7 @@ local foo+=10 bar-=true # ^^^^^^^^^^^^^^^^^^ meta.declaration.variable.arguments.shell # ^^^ meta.variable.shell variable.other.readwrite.shell # ^^ keyword.operator.assignment.shell -# ^^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^^ meta.string.shell string.unquoted.shell # ^^^ meta.variable.shell variable.other.readwrite.shell # ^^ keyword.operator.assignment.shell # ^^^^ constant.language.boolean.true.shell @@ -9530,7 +9920,128 @@ readonly foo # 'foo' is a variable name # ^^^ variable.other.readwrite # ^ - variable -readonly -f foo # 'foo' is a variable name +# indexed array with string values +readonly bar=\ +(foo b*$r b-20 'b?r' "b*z" [100]=val >=b, a&=b, a^=b, a|=b )) From cbce5848c603c602218459f2c2849e1468a9a84c Mon Sep 17 00:00:00 2001 From: deathaxe Date: Mon, 22 Jul 2024 11:07:27 +0200 Subject: [PATCH 022/113] [ShellScript] Reorganize variables --- ShellScript/Bash.sublime-syntax | 40 ++++++++++++++++----------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 01e073ee38..a106bc2b18 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -440,6 +440,25 @@ contexts: - literal-array-value-assignment - variable-name-begin + variables: + - match: '{{variable_begin}}' + push: [variable-subscription, variable-name-begin] + + variable-name-begin: + - meta_include_prototype: false + - match: '{{builtin_variable}}' + scope: variable.language.builtin.shell + pop: 1 + - match: '' + set: variable-name-chars + + variable-name-chars: + - meta_scope: variable.other.readwrite.shell + - include: line-continuations + - include: literal-unquoted-content + - match: '{{identifier_break}}' + pop: 1 + variable-subscription: - meta_scope: meta.variable.shell - include: variable-subscriptions @@ -3055,27 +3074,6 @@ contexts: - match: (?=[/{{metachar}}]) pop: 2 -###[ VARIABLES ]############################################################### - - variables: - - match: '{{variable_begin}}' - push: [variable-subscription, variable-name-begin] - - variable-name-begin: - - meta_include_prototype: false - - match: '{{builtin_variable}}' - scope: variable.language.builtin.shell - pop: 1 - - match: '' - set: variable-name-chars - - variable-name-chars: - - meta_scope: variable.other.readwrite.shell - - include: line-continuations - - include: literal-unquoted-content - - match: '{{identifier_break}}' - pop: 1 - ###[ ILLEGALS ]################################################################ illegal-stray: From 7e541271ecbbedd718ae1058446aed12a67a7184 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Wed, 24 Jul 2024 12:58:49 +0200 Subject: [PATCH 023/113] [ShellScript] Tweak number word breaks This commit... 1. drops leading `\b` from `numbers`'s patterns as proper global word boundary checks are available. 2. treat numbers as words, consuming everything until word boundary and scope it illegal if not valid part of a number. --- ShellScript/Bash.sublime-syntax | 13 ++++++++----- ShellScript/test/syntax_test_bash.sh | 5 +++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index a106bc2b18..311e9721a6 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -2032,29 +2032,32 @@ contexts: numbers: # A leading ‘0x’ or ‘0X’ denotes hexadecimal. - - match: \b(0[xX])(\h*) + - match: (0[xX])(\h*)({{word_char}}*) scope: meta.number.integer.hexadecimal.shell captures: 1: constant.numeric.base.shell 2: constant.numeric.value.shell + 3: invalid.illegal.shell # Constants with a leading 0 are interpreted as octal numbers. - - match: \b(0)([0-7]+) + - match: (0)([0-7]+)({{word_char}}*) scope: meta.number.integer.octal.shell captures: 1: constant.numeric.base.shell 2: constant.numeric.value.shell + 3: invalid.illegal.shell # Otherwise, numbers take the form [base#]n, where the optional base is a # decimal number between 2 and 64 representing the arithmetic base, and n is # a number in that base. When specifying n, the digits greater than 9 are # represented by the lowercase letters, the uppercase letters, ‘@’, and ‘_’, # in that order. - - match: \b(\d+#)([a-zA-Z0-9@_]+) + - match: (\d+#)([[:alnum:]@_]+)({{word_char}}*) scope: meta.number.integer.other.shell captures: 1: constant.numeric.base.shell 2: constant.numeric.value.shell + 3: invalid.illegal.shell # If base# is omitted, then base 10 is used. - - match: \b\d+(?![.\w]) + - match: \d+(?![.\w]) scope: meta.number.integer.decimal.shell constant.numeric.value.shell number: @@ -2074,7 +2077,7 @@ contexts: 2: constant.numeric.base.shell 3: constant.numeric.value.shell pop: 1 - - match: ([-+]?)(\d+#)([a-zA-Z0-9@_]+){{word_break}} + - match: ([-+]?)(\d+#)([[:alnum:]@_]+){{word_break}} scope: meta.number.integer.other.she captures: 1: keyword.operator.arithmetic.shell diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index fbc4dd8f65..454b45659d 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -11266,7 +11266,7 @@ true false #^^^^^^^^^^^^^^^^^ meta.arithmetic.shell # ^ meta.number.integer.octal.shell constant.numeric.base.shell # ^^^^^^^^ meta.number.integer.octal.shell constant.numeric.value.shell -# ^^^ - meta.number - constant +# ^^^ meta.number.integer.octal.shell invalid.illegal.shell (( 0x )) # ^ - meta.number - constant @@ -11283,7 +11283,8 @@ true false # ^ - meta.number - constant # ^^ meta.number.integer.hexadecimal.shell constant.numeric.base.shell # ^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.shell constant.numeric.value.shell -# ^^^^ - meta.number - constant +# ^ meta.number.integer.hexadecimal.shell invalid.illegal.shell +# ^^^ - meta.number - constant (( 64#123@_ )) # ^^^ meta.number.integer.other.shell constant.numeric.base.shell From 361743166cd107f6526aeffb9f928e77892d154c Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 21 Jul 2024 16:29:37 +0200 Subject: [PATCH 024/113] [ShellScript] Avoid duplicate patterns in statement 1. `comments` is not required 2. `line-continuations` is already provided by `eol-pop` --- ShellScript/Bash.sublime-syntax | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 311e9721a6..0da5b683ad 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -262,7 +262,30 @@ contexts: - include: illegal-stray statement: - - include: statements + - include: redirections + - include: operators + - include: def-anonymous + - include: cmd-alias + - include: cmd-arithmetic + - include: cmd-compound + - include: cmd-echo + - include: cmd-historic + - include: cmd-sudo + - include: cmd-test + - include: cmd-control + - include: cmd-coproc + - include: cmd-exec + - include: cmd-unalias + - include: cmd-unset + - include: cmd-builtins + - include: cmd-declare + - include: cmd-export + - include: cmd-readonly + - include: def-variables + - include: def-functions + - include: booleans + - include: cmd-basic + - include: illegal-stray - include: eol-pop ###[ PROTOTYPES ]############################################################## From 14db3386de7a80c0adf6cd03d0248b29cf9edcf2 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 21 Jul 2024 22:01:46 +0200 Subject: [PATCH 025/113] [ShellScript] Fix comments after heredoc tags --- ShellScript/Bash.sublime-syntax | 19 +++++++++---------- ShellScript/test/syntax_test_bash.sh | 5 +++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 0da5b683ad..9ae565ce16 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -1891,7 +1891,7 @@ contexts: 4: punctuation.definition.tag.begin.shell 5: entity.name.tag.heredoc.shell 6: punctuation.definition.tag.end.shell - push: [heredocs-body-allow-tabs-no-expansion, heredocs-preamble] + push: [heredocs-body-allow-tabs-no-expansion, heredocs-preamble, cmd-args] - match: (\d*)(<<-)\s*((")({{identifier}})(")) captures: 1: meta.file-descriptor.shell @@ -1902,7 +1902,7 @@ contexts: 4: punctuation.definition.tag.begin.shell 5: entity.name.tag.heredoc.shell 6: punctuation.definition.tag.end.shell - push: [heredocs-body-allow-tabs-no-expansion, heredocs-preamble] + push: [heredocs-body-allow-tabs-no-expansion, heredocs-preamble, cmd-args] - match: (\d*)(<<-)\s*((\\)({{identifier}})) captures: 1: meta.file-descriptor.shell @@ -1912,7 +1912,7 @@ contexts: 3: meta.string.heredoc.shell meta.tag.heredoc.shell 4: punctuation.definition.tag.shell 5: entity.name.tag.heredoc.shell - push: [heredocs-body-allow-tabs-no-expansion, heredocs-preamble] + push: [heredocs-body-allow-tabs-no-expansion, heredocs-preamble, cmd-args] - match: (\d*)(<<-)\s*({{identifier}}) captures: 1: meta.file-descriptor.shell @@ -1920,7 +1920,7 @@ contexts: constant.numeric.value.shell 2: keyword.operator.assignment.redirection.shell 3: meta.string.heredoc.shell meta.tag.heredoc.shell entity.name.tag.heredoc.shell - push: [heredocs-body-allow-tabs, heredocs-preamble] + push: [heredocs-body-allow-tabs, heredocs-preamble, cmd-args] # These are the variants that DON'T allow tabs before the end token - match: (\d*)(<<)\s*((')({{identifier}})(')) captures: @@ -1932,7 +1932,7 @@ contexts: 4: punctuation.definition.tag.begin.shell 5: entity.name.tag.heredoc.shell 6: punctuation.definition.tag.end.shell - push: [heredocs-body-no-expansion, heredocs-preamble] + push: [heredocs-body-no-expansion, heredocs-preamble, cmd-args] - match: (\d*)(<<)\s*((")({{identifier}})(")) captures: 1: meta.file-descriptor.shell @@ -1943,7 +1943,7 @@ contexts: 4: punctuation.definition.tag.begin.shell 5: entity.name.tag.heredoc.shell 6: punctuation.definition.tag.end.shell - push: [heredocs-body-no-expansion, heredocs-preamble] + push: [heredocs-body-no-expansion, heredocs-preamble, cmd-args] - match: (\d*)(<<)\s*((\\)({{identifier}})) captures: 1: meta.file-descriptor.shell @@ -1953,7 +1953,7 @@ contexts: 3: meta.string.heredoc.shell meta.tag.heredoc.shell 4: punctuation.definition.tag.shell 5: entity.name.tag.heredoc.shell - push: [heredocs-body-no-expansion, heredocs-preamble] + push: [heredocs-body-no-expansion, heredocs-preamble, cmd-args] - match: (\d*)(<<)\s*({{identifier}}) captures: 1: meta.file-descriptor.shell @@ -1961,7 +1961,7 @@ contexts: constant.numeric.value.shell 2: keyword.operator.assignment.redirection.shell 3: meta.string.heredoc.shell meta.tag.heredoc.shell entity.name.tag.heredoc.shell - push: [heredocs-body, heredocs-preamble] + push: [heredocs-body, heredocs-preamble, cmd-args] heredocs-body: - meta_scope: meta.string.heredoc.shell @@ -2034,8 +2034,7 @@ contexts: - clear_scopes: 1 - match: ^ pop: 1 - - match: (?=\S) - push: [statement, cmd-args] + - include: statements ###[ LITERALS ]################################################################ diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index 454b45659d..e14f6ed362 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -1929,15 +1929,16 @@ echo Deploying... * ) # <- constant.other.wildcard.asterisk.shell # ^ keyword.control.conditional.patterns.end.shell -cat <<'ENDCAT' +cat <<'ENDCAT' # comment # <- meta.function-call.identifier.shell variable.function.shell # ^^ meta.function-call.arguments.shell - meta.string - meta.tag # ^^^^^^^^ meta.function-call.arguments.shell meta.string.heredoc.shell meta.tag.heredoc.shell - string.unquoted.heredoc -# ^ meta.function-call.arguments.shell meta.string.heredoc.shell - meta.tag - string.unquoted.heredoc +# ^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.heredoc.shell - meta.tag - string.unquoted.heredoc # ^^ keyword.operator.assignment.redirection.shell # ^ punctuation.definition.tag.begin.shell - entity # ^^^^^^ entity.name.tag.heredoc.shell # ^ punctuation.definition.tag.end.shell - entity +# ^^^^^^^^^^ comment.line.number-sign.shell foo # <- meta.function-call.arguments.shell meta.string.heredoc.shell string.unquoted.heredoc.shell From 814edf288d93d960c5565a5da226ce7430099e80 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Wed, 24 Jul 2024 14:56:49 +0200 Subject: [PATCH 026/113] [ShellScript] Reorganize prototypes at the bottom --- ShellScript/Bash.sublime-syntax | 68 ++++++++++++++++----------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 9ae565ce16..efb4d72a3b 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -288,40 +288,6 @@ contexts: - include: illegal-stray - include: eol-pop -###[ PROTOTYPES ]############################################################## - - brace-pop: - - match: (?=\}) - pop: 1 - - else-pop: - - match: (?=\S) - pop: 1 - - eoc-pop: - - match: (?=\s*(?:[)}|;]|&(?!>))) - pop: 1 - - include: eol-pop - - eoc-pop2: - - match: (?=\s*(?:[)}|;]|&(?!>))) - pop: 2 - - include: eol-pop2 - - eol-pop: - - match: (?=\s*$|\s+#) - pop: 1 - - include: line-continuations - - eol-pop2: - - match: (?=\s*$|\s+#) - pop: 2 - - include: line-continuations - - immediately-pop: - - match: '' - pop: 1 - ###[ COMMENTS ]################################################################ comments: @@ -3116,3 +3082,37 @@ contexts: - include: literal-unquoted-content - match: '{{word_break}}' pop: 1 + +###[ PROTOTYPES ]############################################################## + + brace-pop: + - match: (?=\}) + pop: 1 + + else-pop: + - match: (?=\S) + pop: 1 + + eoc-pop: + - match: (?=\s*(?:[)}|;]|&(?!>))) + pop: 1 + - include: eol-pop + + eoc-pop2: + - match: (?=\s*(?:[)}|;]|&(?!>))) + pop: 2 + - include: eol-pop2 + + eol-pop: + - match: (?=\s*$|\s+#) + pop: 1 + - include: line-continuations + + eol-pop2: + - match: (?=\s*$|\s+#) + pop: 2 + - include: line-continuations + + immediately-pop: + - match: '' + pop: 1 From c24ac9fc1a5105d03ad23b0a6247e16ec185f0f0 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Fri, 26 Jul 2024 19:11:55 +0200 Subject: [PATCH 027/113] [ShellScript] Remove obsolete compound args contexts Only redirections are allowed after compound commands, which is already satisfied/handled via global statements context. --- ShellScript/Bash.sublime-syntax | 10 +++----- ShellScript/test/syntax_test_bash.sh | 34 +++++++++++++--------------- 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index efb4d72a3b..4dabdf9cd0 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -606,7 +606,7 @@ contexts: scope: meta.compound.shell punctuation.section.compound.end.shell - set: cmd-compound-args + pop: 1 - include: statements ###[ DECLARE BUILTINS ]######################################################## @@ -1118,20 +1118,16 @@ contexts: - meta_scope: meta.compound.shell - match: \} scope: punctuation.section.compound.end.shell - set: cmd-compound-args + pop: 1 - include: statements cmd-compound-parens-body: - meta_scope: meta.compound.shell - match: \) scope: punctuation.section.compound.end.shell - set: cmd-compound-args + pop: 1 - include: statements - cmd-compound-args: - - meta_content_scope: meta.compound.arguments.shell - - include: cmd-args - cmd-historic: - match: (\!)(-?\d+|!) scope: variable.language.history.shell diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index e14f6ed362..4726888646 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -2114,28 +2114,23 @@ esac # https://www.gnu.org/software/bash/manual/bash.html#Command-Grouping # ############################################################################### -(foo) -o +(foo) # <- meta.compound.shell punctuation.section.compound.begin.shell #^^^ meta.compound.shell meta.function-call.identifier.shell variable.function.shell # ^ meta.compound.shell punctuation.section.compound.end.shell -# ^^^ meta.compound.arguments.shell +# ^ - meta -{ foo -o } --opt -- --no-option +{ foo -o } # <- meta.compound.shell punctuation.section.compound.begin.shell #^^^^^^^^^ meta.compound.shell - meta.compound meta.compound # ^^^ meta.function-call.identifier.shell # ^^^ meta.function-call.arguments.shell # ^^ - meta.function-call -# ^^^^^^^^^^^^^^^^^^^^^ meta.compound.arguments.shell - meta.compound meta.compound -# ^ - meta.compound +# ^ - meta.compound # ^^^ variable.function.shell # ^ meta.parameter.option.shell variable.parameter.option.shell punctuation.definition.parameter.shell # ^ meta.parameter.option.shell variable.parameter.option.shell - punctuation # ^ punctuation.section.compound.end.shell -# ^^ meta.parameter.option.shell variable.parameter.option.shell punctuation.definition.parameter.shell -# ^^^ meta.parameter.option.shell variable.parameter.option.shell - punctuation -# ^^ keyword.operator.end-of-options.shell -# ^^^^^^^^^^^ - variable - punctuation { # <- meta.compound.shell punctuation.section.compound.begin.shell @@ -2150,16 +2145,14 @@ esac # ^^^^^ meta.function-call.arguments.shell } 2>> "$stderr_log" #^^ meta.compound.shell meta.compound.shell -# ^^^^^^^^^^^^^^^^^^ meta.compound.shell meta.compound.arguments.shell -# ^ meta.compound.shell - meta.compound meta.compound +# ^ meta.compound.shell - meta.compound meta.compound +# ^^^^^^^^^^^^^^^^^ meta.compound.shell meta.redirection.shell # ^ punctuation.section.compound.end.shell - # ^ meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell - variable.function } 1>> "$stdout_log" # <- meta.compound.shell - meta.compound meta.compound -#^^^^^^^^^^^^^^^^^^ meta.compound.arguments.shell -# ^ - meta +#^ - meta +# ^^^^^^^^^^^^^^^^^ meta.redirection.shell # <- punctuation.section.compound.end.shell -# ^ meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell - variable.function ############################################################################### @@ -2275,16 +2268,21 @@ coproc myls { ls thisfiledoesntexist; read; 2>&1 } | foo # ^^^^^^ meta.compound.shell meta.coproc.shell # ^^^^^ meta.compound.shell meta.coproc.identifier.shell # ^^^^^^^^^^^^^^^^ meta.compound.shell meta.coproc.command.shell meta.compound.shell -# ^^^^ meta.compound.shell meta.coproc.command.shell meta.compound.arguments.shell -# ^^^ meta.compound.shell - meta.coproc -# ^^^^^ meta.compound.arguments.shell - meta.coproc - meta.function-call +# ^ meta.compound.shell - meta.redirection - meta.coproc +# ^^^ meta.compound.shell meta.redirection.shell - meta.coproc +# ^^^ meta.compound.shell - meta.redirection - meta.coproc +# ^ - meta +# ^^^^ meta.redirection.shell # ^^^^^^ keyword.declaration.coproc.shell # ^^^ entity.name.function.shell # ^ punctuation.section.compound.begin.shell # ^^^ variable.function.shell +# ^^^^^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.terminator.statement.shell # ^ punctuation.section.compound.end.shell # ^^ keyword.operator.assignment.redirection # ^ meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.terminator.statement.shell # ^ punctuation.section.compound.end.shell # ^ meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell # ^^ keyword.operator.assignment.redirection From d989c708d93b2122ea3b7ea11793204d84103b17 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Fri, 26 Jul 2024 19:15:33 +0200 Subject: [PATCH 028/113] [ShellScript] Simplify coproc --- ShellScript/Bash.sublime-syntax | 22 ++++++++-------------- ShellScript/test/syntax_test_bash.sh | 18 +++++++++--------- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 4dabdf9cd0..3ceb200c79 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -579,15 +579,14 @@ contexts: push: cmd-coproc-identifier cmd-coproc-identifier: - - match: (\s*({{cmd_literal}})\s*)(\{) + - match: (\s*)(({{cmd_literal}})\s*)?(\{) captures: - 1: meta.coproc.identifier.shell - 2: entity.name.function.shell - 3: meta.coproc.command.shell meta.compound.shell + 1: meta.coproc.shell + 2: meta.coproc.identifier.shell + 3: entity.name.function.shell + 4: meta.coproc.command.shell meta.compound.shell punctuation.section.compound.begin.shell - set: - - cmd-coproc-compound-meta - - cmd-coproc-compound-command + set: cmd-coproc-compound-command - match: '' set: cmd-coproc-basic-command @@ -595,16 +594,11 @@ contexts: - meta_scope: meta.coproc.command.shell - include: statement - cmd-coproc-compound-meta: - - meta_include_prototype: false - - meta_scope: meta.coproc.command.shell - - include: immediately-pop - cmd-coproc-compound-command: - - meta_content_scope: meta.compound.shell + - meta_content_scope: meta.coproc.command.shell meta.compound.shell - match: \} scope: - meta.compound.shell + meta.coproc.command.shell meta.compound.shell punctuation.section.compound.end.shell pop: 1 - include: statements diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index 4726888646..5f1184380a 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -2220,10 +2220,10 @@ coproc awk '{print "foo" $0;fflush()}' coproc { ls thisfiledoesntexist; read; 2>&1 } | foo # <- meta.coproc.shell keyword.declaration.coproc.shell -#^^^^^ meta.coproc.shell -# ^ meta.coproc.command.shell +#^^^^^^ meta.coproc.shell # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.coproc.command.shell meta.compound.shell -# ^^^^^^ meta.coproc.command.shell - meta.compound +# ^^^ - meta.coproc - meta.compound - meta.function-call +# ^^^ meta.function-call.identifier.shell # ^ - meta.function-call - meta.function.coproc # ^^ meta.function-call.identifier.shell # ^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell @@ -2245,8 +2245,8 @@ coproc { ls thisfiledoesntexist; read; 2>&1 } | foo coproc myls { ls thisfiledoesntexist; read; 2>&1 } | foo # <- meta.coproc.shell keyword.declaration.coproc.shell -#^^^^^ meta.coproc.shell -# ^^^^^^ meta.coproc.identifier.shell - meta.compound +#^^^^^^ meta.coproc.shell +# ^^^^^ meta.coproc.identifier.shell - meta.compound # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.coproc.command.shell meta.compound.shell # ^^^ - meta.function-call # ^^^ meta.function-call.identifier.shell @@ -2265,8 +2265,8 @@ coproc myls { ls thisfiledoesntexist; read; 2>&1 } | foo { coproc tee { tee logfile ;} >&3 ;} 3>&1 # <- meta.compound.shell punctuation.section.compound.begin.shell -# ^^^^^^ meta.compound.shell meta.coproc.shell -# ^^^^^ meta.compound.shell meta.coproc.identifier.shell +# ^^^^^^^ meta.compound.shell meta.coproc.shell +# ^^^^ meta.compound.shell meta.coproc.identifier.shell # ^^^^^^^^^^^^^^^^ meta.compound.shell meta.coproc.command.shell meta.compound.shell # ^ meta.compound.shell - meta.redirection - meta.coproc # ^^^ meta.compound.shell meta.redirection.shell - meta.coproc @@ -2290,8 +2290,8 @@ coproc myls { ls thisfiledoesntexist; read; 2>&1 } | foo coproc foobar { # <- meta.coproc.shell keyword.declaration.coproc.shell -#^^^^^ meta.coproc.shell -# ^^^^^^^^ meta.coproc.identifier.shell +#^^^^^^ meta.coproc.shell +# ^^^^^^^ meta.coproc.identifier.shell # ^^ meta.coproc.command.shell meta.compound.shell #^^^^^ keyword.declaration.coproc.shell # ^^^^^^ entity.name.function.shell From 87e4a5b7c2d8b938ac4d0c2209ee6009632e992f Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 27 Jul 2024 18:14:59 +0200 Subject: [PATCH 029/113] [ShellScript] Refactor tilde interpolation scopes 1. always clear parent scope 2. scope username `constant.other` --- ShellScript/Bash.sublime-syntax | 30 +++++++------------------- ShellScript/test/syntax_test_bash.sh | 32 ++++++++++++++-------------- 2 files changed, 24 insertions(+), 38 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 3ceb200c79..7dff255c0c 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -2255,7 +2255,7 @@ contexts: ###[ PATH PATTERN MATCHING ]################################################### path-pattern-begin: - - include: tilde-expansion + - include: tilde-interpolation - include: path-pattern-quoted-begin path-pattern-quoted-begin: @@ -3020,40 +3020,26 @@ contexts: tilde-interpolation: - match: \~ scope: variable.language.tilde.shell - set: tilde-interpolation-modifier + set: tilde-modifier - tilde-interpolation-modifier: + tilde-modifier: - clear_scopes: 1 - - meta_include_prototype: false - - meta_scope: meta.interpolation.tilde.shell - - include: tilde-expansion-modifier - - maybe-tilde-expansion: - - include: tilde-expansion - - include: line-continuations - - include: immediately-pop - - tilde-expansion: - - match: \~ - scope: variable.language.tilde.shell - set: tilde-expansion-modifier - - tilde-expansion-modifier: - meta_include_prototype: false - meta_scope: meta.interpolation.tilde.shell - match: (?:[-+]?\d+|[-+](?![^/{{metachar}}])) scope: variable.language.tilde.shell pop: 1 - match: '' - push: tilde-expansion-username + set: tilde-modifier-username - tilde-expansion-username: + tilde-modifier-username: + - clear_scopes: 1 - meta_include_prototype: false - - meta_content_scope: meta.string.shell string.unquoted.username.shell + - meta_content_scope: meta.interpolation.tilde.shell constant.other.username.shell - include: line-continuations - include: string-interpolations - match: (?=[/{{metachar}}]) - pop: 2 + pop: 1 ###[ ILLEGALS ]################################################################ diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index 5f1184380a..9b8827a177 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -3852,20 +3852,20 @@ any --arg{1,2,3} ={1,2,3} : ~fred/foo* # The subdirectory foo of the home directory of the user fred # ^ meta.interpolation.tilde.shell variable.language.tilde.shell -# ^^^^ meta.interpolation.tilde.shell meta.string.shell string.unquoted.username.shell - variable +# ^^^^ meta.interpolation.tilde.shell constant.other.username.shell - variable # ^^^^^ - meta.interpolation # ^ constant.other.wildcard.asterisk.shell : ~fr\ ed/foo* # The subdirectory foo of the home directory of the user fred -# <- meta.interpolation.tilde.shell meta.string.shell string.unquoted.username.shell - variable -#^ meta.interpolation.tilde.shell meta.string.shell string.unquoted.username.shell - variable +# <- meta.interpolation.tilde.shell constant.other.username.shell - variable +#^ meta.interpolation.tilde.shell constant.other.username.shell - variable # ^^^^^ - meta.interpolation # ^ constant.other.wildcard.asterisk.shell : ~${fred}/foo?bar # ^ meta.interpolation.tilde.shell variable.language.tilde.shell - variable meta.interpolation -# ^^^^^^^ meta.interpolation.tilde.shell meta.string.shell meta.interpolation.parameter.shell +# ^^^^^^^ meta.interpolation.tilde.shell meta.interpolation.parameter.shell # ^^^^^^^^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -3875,9 +3875,9 @@ ed/foo* # The subdirectory foo of the home directory of the user fred : ~f${re}d/foo?bar # ^ meta.interpolation.tilde.shell variable.language.tilde.shell - meta.interpolation meta.interpolation - string -# ^ meta.interpolation.tilde.shell meta.string.shell string.unquoted.username.shell - meta.interpolation meta.interpolation -# ^^^^^ meta.interpolation.tilde.shell meta.string.shell meta.interpolation.parameter.shell - string -# ^ meta.interpolation.tilde.shell meta.string.shell string.unquoted.username.shell - meta.interpolation meta.interpolation +# ^ meta.interpolation.tilde.shell constant.other.username.shell - meta.interpolation meta.interpolation +# ^^^^^ meta.interpolation.tilde.shell meta.interpolation.parameter.shell - string +# ^ meta.interpolation.tilde.shell constant.other.username.shell - meta.interpolation meta.interpolation # ^^^^^^^^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -3937,7 +3937,7 @@ test $me -eq ~/~foo # ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation - variable ~/.bin/~app -# <- meta.function-call.identifier.shell meta.interpolation.tilde.shell variable.language.tilde.shell +# <- meta.function-call.identifier.shell meta.interpolation.tilde.shell variable.language.tilde.shell - variable.function #^^^^^^^^^^ meta.function-call.identifier.shell variable.function.shell #^ punctuation.separator.path.shell # ^ punctuation.separator.path.shell @@ -4347,9 +4347,9 @@ foo} # ^^^^^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell # ^ keyword.operator.assignment.shell # ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string -# ^ meta.string.shell meta.interpolation.tilde.shell meta.string.shell string.unquoted.username.shell - string string -# ^^^^^ meta.string.shell meta.interpolation.tilde.shell meta.string.shell meta.interpolation.parameter.shell - string -# ^ meta.string.shell meta.interpolation.tilde.shell meta.string.shell string.unquoted.username.shell - string string +# ^ meta.string.shell meta.interpolation.tilde.shell constant.other.username.shell - string string +# ^^^^^ meta.string.shell meta.interpolation.tilde.shell meta.interpolation.parameter.shell - string +# ^ meta.string.shell meta.interpolation.tilde.shell constant.other.username.shell - string string # ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation.tilde # ^ constant.other.wildcard.asterisk.shell # ^ punctuation.section.interpolation.end.shell @@ -4465,9 +4465,9 @@ foo} # ^^^^^^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell # ^^ keyword.operator.assignment.shell # ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string -# ^ meta.string.shell meta.interpolation.tilde.shell meta.string.shell string.unquoted.username.shell - string string -# ^^^^^ meta.string.shell meta.interpolation.tilde.shell meta.string.shell meta.interpolation.parameter.shell - string -# ^ meta.string.shell meta.interpolation.tilde.shell meta.string.shell string.unquoted.username.shell - string string +# ^ meta.string.shell meta.interpolation.tilde.shell constant.other.username.shell - string string +# ^^^^^ meta.string.shell meta.interpolation.tilde.shell meta.interpolation.parameter.shell - string +# ^ meta.string.shell meta.interpolation.tilde.shell constant.other.username.shell - string string # ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation.tilde # ^ constant.other.wildcard.asterisk.shell # ^ punctuation.section.interpolation.end.shell @@ -5729,7 +5729,7 @@ a\/b/c/d} # ^ keyword.operator.substitution.shell # ^^ meta.string.regexp.shell # ^ variable.language.tilde.shell -# ^ string.unquoted.username.shell +# ^ constant.other.username.shell # ^ keyword.operator.substitution.shell # ^ punctuation.section.interpolation.end.shell @@ -5751,7 +5751,7 @@ a\/b/c/d} # ^ keyword.operator.substitution.shell # ^^^^^ meta.string.regexp.shell meta.interpolation.tilde.shell # ^ variable.language.tilde.shell -# ^^^^ meta.string.shell string.unquoted.username.shell +# ^^^^ meta.string.shell constant.other.username.shell # ^ keyword.operator.substitution.shell # ^^^^^^ meta.string.shell string.unquoted.shell - variable # ^ punctuation.section.interpolation.end.shell From d3f71edd17d822e1dea6b821b0b25345de2bc7a5 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 27 Jul 2024 18:27:44 +0200 Subject: [PATCH 030/113] [ShellScript] Align illegal token scopes Use already existing `invalid.illegal.unexpected-token.shell` --- ShellScript/Bash.sublime-syntax | 8 ++--- ShellScript/test/syntax_test_bash.sh | 46 ++++++++++++++-------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 7dff255c0c..6c9f686e24 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -955,7 +955,7 @@ contexts: - match: '[<>]=?' scope: keyword.operator.comparison.shell - match: ; - scope: invalid.illegal.unexpected.shell + scope: invalid.illegal.unexpected-token.shell - include: line-continuations - include: test-expression-common @@ -991,7 +991,7 @@ contexts: - match: '[<>]=?' scope: keyword.operator.comparison.shell - match: ; - scope: invalid.illegal.unexpected.shell + scope: invalid.illegal.unexpected-token.shell - include: line-continuations - include: test-expression-common @@ -1672,7 +1672,7 @@ contexts: scope: punctuation.section.sequence.end.shell pop: 1 - match: '[(<>]+' - scope: invalid.illegal.unexpected.shell + scope: invalid.illegal.unexpected-token.shell - include: line-continuations ###[ EXPRESSIONS ]############################################################# @@ -3053,7 +3053,7 @@ contexts: illegal-word-chars: - meta_include_prototype: false - - meta_scope: invalid.illegal.unexpected.shell + - meta_scope: invalid.illegal.unexpected-token.shell - include: line-continuations - include: literal-unquoted-content - match: '{{word_break}}' diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index 9b8827a177..90cc59d2c9 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -1655,7 +1655,7 @@ if [[ "$ERL_TOP" != ";"; ]];then;fi # ^^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell # ^^^^^^^^^^^^^^^^^ - meta.string.regexp # ^^^ meta.string.regexp.shell -# ^ invalid.illegal.unexpected.shell - meta.string +# ^ invalid.illegal.unexpected-token.shell - meta.string # ^^^ - meta.string.regexp # ^ punctuation.terminator.statement.shell # ^^^^ keyword.control.conditional.then.shell @@ -2968,7 +2968,7 @@ array=(one two three four -5 (foo bar baz) # ^ - meta.string - string # ^^ meta.string.shell string.unquoted.shell # ^^ - meta.string - string -# ^ invalid.illegal.unexpected.shell +# ^ invalid.illegal.unexpected-token.shell # ^^^ meta.string.shell string.unquoted.shell # ^ - meta.string - string # ^^^ meta.string.shell string.unquoted.shell @@ -8257,7 +8257,7 @@ echo '([^.[:space:]]+) Class::method()' # colon not scoped as path separator #^^^^^^^^^^^^^^ meta.conditional.shell # ^ - meta.conditional # ^^ keyword.operator.comparison.shell -# ^ invalid.illegal.unexpected.shell +# ^ invalid.illegal.unexpected-token.shell # ^^ support.function.test.end.shell [[ ( $foo =~ ; ) ]] # unquoted semicolons are illegal @@ -8267,7 +8267,7 @@ echo '([^.[:space:]]+) Class::method()' # colon not scoped as path separator # ^^^ meta.conditional.shell - meta.group # ^ - meta.conditional # ^^ keyword.operator.comparison.shell -# ^ invalid.illegal.unexpected.shell +# ^ invalid.illegal.unexpected-token.shell # ^ punctuation.section.group.end.shell # ^^ support.function.test.end.shell @@ -9004,7 +9004,7 @@ declare foo==bar baz =buz # assignment must immediately follow a variable # ^ - variable # ^^^ variable.other.readwrite.shell # ^ - variable -# ^^^^ invalid.illegal.unexpected.shell +# ^^^^ invalid.illegal.unexpected-token.shell # ^ - variable declare foo= Date: Mon, 29 Jul 2024 20:53:56 +0200 Subject: [PATCH 031/113] [ShellScript] Simplify alias meta scope --- ShellScript/Bash.sublime-syntax | 6 ++---- ShellScript/test/syntax_test_bash.sh | 27 +++++++++++---------------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 6c9f686e24..329de60470 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -479,16 +479,14 @@ contexts: cmd-alias: - match: alias{{cmd_break}} - scope: - meta.declaration.alias.shell - keyword.declaration.alias.shell + scope: keyword.declaration.alias.shell push: - cmd-alias-args-meta - cmd-alias-args cmd-alias-args-meta: - meta_include_prototype: false - - meta_content_scope: meta.declaration.alias.arguments.shell + - meta_scope: meta.declaration.alias.shell - include: immediately-pop cmd-alias-args: diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index 90cc59d2c9..4bc465acce 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -8840,8 +8840,7 @@ alias alias foo=bar # <- meta.declaration.alias.shell keyword.declaration.alias.shell -#^^^^ meta.declaration.alias.shell -# ^^^^^^^^ meta.declaration.alias.arguments.shell +#^^^^^^^^^^^^ meta.declaration.alias.shell # ^ - meta.declaration.alias # ^^^ meta.variable.shell entity.name.function.shell # ^ keyword.operator.assignment.shell @@ -8849,8 +8848,7 @@ alias foo=bar alias foo=bar -p 7za=qux # <- meta.declaration.alias.shell keyword.declaration.alias.shell -#^^^^ meta.declaration.alias.shell -# ^^^^^^^^^^^^^^^^^^^ meta.declaration.alias.arguments.shell +#^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.alias.shell # ^ - meta.declaration.alias # ^^^ meta.variable.shell entity.name.function.shell # ^ keyword.operator.assignment.shell @@ -8862,8 +8860,7 @@ alias foo=bar -p 7za=qux alias -p foo=bar 7za=qux # <- meta.declaration.alias.shell keyword.declaration.alias.shell -#^^^^ meta.declaration.alias.shell -# ^^^^^^^^^^^^^^^^^^^ meta.declaration.alias.arguments.shell +#^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.alias.shell # ^ - meta.declaration.alias # ^^ meta.parameter.option.shell variable.parameter.option.shell # ^^^ meta.variable.shell entity.name.function.shell @@ -8875,8 +8872,7 @@ alias -p foo=bar 7za=qux alias -a -p -- foo=bar baz=qux # <- meta.declaration.alias.shell keyword.declaration.alias.shell -#^^^^ meta.declaration.alias.shell -# ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.alias.arguments.shell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.alias.shell # ^ - meta.declaration.alias # ^^ invalid.illegal.parameter.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell @@ -8890,8 +8886,7 @@ alias -a -p -- foo=bar baz=qux alias $foo=bar # <- meta.declaration.alias.shell keyword.declaration.alias.shell -#^^^^ meta.declaration.alias.shell -# ^^^^^^^^^ meta.declaration.alias.arguments.shell +#^^^^^^^^^^^^^ meta.declaration.alias.shell # ^ - meta.declaration.alias # ^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell # ^ keyword.operator.assignment.shell @@ -8899,16 +8894,16 @@ alias $foo=bar alias ..='cd ..' # <- meta.declaration.alias.shell keyword.declaration.alias.shell -#^^^^ meta.declaration.alias.shell keyword.declaration.alias.shell -# ^^^^^^^^^^^ meta.declaration.alias.arguments.shell +#^^^^^^^^^^^^^^^ meta.declaration.alias.shell +#^^^^ keyword.declaration.alias.shell # ^^ meta.variable.shell entity.name.function.shell # ^ keyword.operator.assignment.shell # ^^^^^^^ meta.string.shell string.quoted.single.shell alias -p ..='cd ..' # <- meta.declaration.alias.shell keyword.declaration.alias.shell -#^^^^ meta.declaration.alias.shell keyword.declaration.alias.shell -# ^^^^^^^^^^^^^^ meta.declaration.alias.arguments.shell +#^^^^^^^^^^^^^^^^^^ meta.declaration.alias.shell +#^^^^ keyword.declaration.alias.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell # ^^ meta.variable.shell entity.name.function.shell # ^ keyword.operator.assignment.shell @@ -8916,8 +8911,8 @@ alias -p ..='cd ..' alias -- -='cd -' # <- meta.declaration.alias.shell keyword.declaration.alias.shell -#^^^^ meta.declaration.alias.shell keyword.declaration.alias.shell -# ^^^^^^^^^^^^ meta.declaration.alias.arguments.shell +#^^^^^^^^^^^^^^^^ meta.declaration.alias.shell +#^^^^ keyword.declaration.alias.shell # ^^ keyword.operator.end-of-options.shell # ^ meta.variable.shell entity.name.function.shell # ^ keyword.operator.assignment.shell From 8d5d4655d7d33adf7bc6955c0e1f16645b9e60ca Mon Sep 17 00:00:00 2001 From: deathaxe Date: Mon, 29 Jul 2024 21:05:39 +0200 Subject: [PATCH 032/113] [ShellScript] Simplify declaration meta scope --- ShellScript/Bash.sublime-syntax | 17 +-- ShellScript/test/syntax_test_bash.sh | 196 ++++++++++++--------------- 2 files changed, 87 insertions(+), 126 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 329de60470..de554a4259 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -605,16 +605,14 @@ contexts: cmd-declare: - match: (declare|local|typeset){{cmd_break}} - scope: - meta.declaration.variable.shell - keyword.declaration.variable.shell + scope: keyword.declaration.variable.shell push: - cmd-declare-args-meta - cmd-declare-args cmd-declare-args-meta: - meta_include_prototype: false - - meta_content_scope: meta.declaration.variable.arguments.shell + - meta_scope: meta.declaration.variable.shell - include: immediately-pop cmd-declare-args: @@ -795,18 +793,11 @@ contexts: cmd-readonly: - match: readonly{{cmd_break}} - scope: - meta.declaration.variable.shell - keyword.declaration.variable.shell + scope: keyword.declaration.variable.shell push: - - cmd-readonly-args-meta + - cmd-declare-args-meta - cmd-readonly-args - cmd-readonly-args-meta: - - meta_include_prototype: false - - meta_content_scope: meta.declaration.variable.arguments.shell - - include: immediately-pop - cmd-readonly-args: # options contain -f => function declarations (wins over -A) - match: ([-+])[aA]*f[aA]*{{opt_break}} diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index 4bc465acce..d9bd0e2864 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -8931,51 +8931,44 @@ declare # comment # ^^^^^^^^^^ comment.line.number-sign.shell declare foo # 'foo' is a variable name -#^^^^^^ meta.declaration.variable.shell -# ^^^^ meta.declaration.variable.arguments.shell +#^^^^^^^^^^ meta.declaration.variable.shell # ^ - meta.declaration # <- keyword.declaration.variable.shell # ^ - variable.other.readwrite # ^ - meta.declaration.variable declare foo| # '|' terminates statement -#^^^^^^ meta.declaration.variable.shell -# ^^^^ meta.declaration.variable.arguments.shell +#^^^^^^^^^^ meta.declaration.variable.shell # ^ - meta.declaration # <- keyword.declaration.variable.shell # ^ keyword.operator declare foo | # '|' terminates statement -#^^^^^^ meta.declaration.variable.shell -# ^^^^ meta.declaration.variable.arguments.shell +#^^^^^^^^^^ meta.declaration.variable.shell # ^ - meta.declaration # <- keyword.declaration.variable.shell # ^ keyword.operator declare foo& # '&' terminates statement -#^^^^^^ meta.declaration.variable.shell -# ^^^^ meta.declaration.variable.arguments.shell +#^^^^^^^^^^ meta.declaration.variable.shell # ^ - meta.declaration # <- keyword.declaration.variable.shell # ^ keyword.operator declare foo & # '&' terminates statement -#^^^^^^ meta.declaration.variable.shell -# ^^^^ meta.declaration.variable.arguments.shell +#^^^^^^^^^^ meta.declaration.variable.shell # ^ - meta.declaration # <- keyword.declaration.variable.shell # ^ keyword.operator declare foo ; # ';' terminates statement -#^^^^^^ meta.declaration.variable.shell -# ^^^^ meta.declaration.variable.arguments.shell +#^^^^^^^^^^ meta.declaration.variable.shell # ^ - meta.declaration # <- keyword.declaration.variable.shell # ^ punctuation.terminator.statement.shell declare foo; bar=baz # 2nd statement after ';' -#^^^^^^ meta.declaration.variable.shell -# ^^^^ meta.declaration.variable.arguments.shell +#^^^^^^^^^^ meta.declaration.variable.shell # ^^ - meta.declaration # <- keyword.declaration.variable.shell #^^^^^^ keyword.declaration.variable.shell @@ -8988,8 +8981,7 @@ declare foo; bar=baz # 2nd statement after ';' # ^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell declare foo==bar baz =buz # assignment must immediately follow a variable -#^^^^^^ meta.declaration.variable.shell -# ^^^^^^^^^^^^^^^^^^ meta.declaration.variable.arguments.shell +#^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.variable.shell # ^ - meta.declaration # <- keyword.declaration.variable.shell # ^ - variable @@ -9003,9 +8995,8 @@ declare foo==bar baz =buz # assignment must immediately follow a variable # ^ - variable declare foo= /dev/null && complete -F _upto upto # <- meta.declaration.variable.shell keyword.declaration.variable.shell -#^^^^^^ meta.declaration.variable.shell -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.variable.arguments.shell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.variable.shell # ^^^^ - meta.declaration - meta.function-call # ^^^^^^^^ meta.function-call.identifier.shell # ^^^^^^^^^^^^^^ meta.function-call.arguments.shell @@ -9802,9 +9782,9 @@ local+= local foo bar # 'foo' and 'bar' are variable names # <- meta.declaration.variable.shell keyword.declaration.variable.shell -#^^^^ meta.declaration.variable.shell keyword.declaration.variable.shell -# ^^^^^^^^ meta.declaration.variable.arguments.shell +#^^^^^^^^^^^^ meta.declaration.variable.shell # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.declaration.variable +#^^^^ keyword.declaration.variable.shell # ^ - variable # ^^^ meta.variable.shell variable.other.readwrite.shell # ^ - variable @@ -9813,8 +9793,8 @@ local foo bar # 'foo' and 'bar' are variable names local foo bar='baz' # 'foo' and 'bar' are variable names # <- meta.declaration.variable.shell keyword.declaration.variable.shell -#^^^^ meta.declaration.variable.shell keyword.declaration.variable.shell -# ^^^^^^^^^^^^^^ meta.declaration.variable.arguments.shell +#^^^^^^^^^^^^^^^^^^ meta.declaration.variable.shell +#^^^^ keyword.declaration.variable.shell # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.declaration.variable # ^ - variable # ^^^ meta.variable.shell variable.other.readwrite.shell @@ -9827,8 +9807,8 @@ local foo bar='baz' # 'foo' and 'bar' are variable names local foo+=10 bar-=true # <- meta.declaration.variable.shell keyword.declaration.variable.shell -#^^^^ meta.declaration.variable.shell keyword.declaration.variable.shell -# ^^^^^^^^^^^^^^^^^^ meta.declaration.variable.arguments.shell +#^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.variable.shell +#^^^^ keyword.declaration.variable.shell # ^^^ meta.variable.shell variable.other.readwrite.shell # ^^ keyword.operator.assignment.shell # ^^ meta.string.shell string.unquoted.shell @@ -9838,23 +9818,22 @@ local foo+=10 bar-=true local pid="$(cat "$PIDFILE" 2>/dev/null)" # <- meta.declaration.variable.shell keyword.declaration.variable.shell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.variable.shell #^^^^ meta.declaration.variable.shell keyword.declaration.variable.shell -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.variable.arguments.shell # ^^^ meta.variable.shell variable.other.readwrite.shell # ^ keyword.operator.assignment.shell # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell local -fn foo # <- meta.declaration.variable.shell keyword.declaration.variable.shell -#^^^^ meta.declaration.variable.shell keyword.declaration.variable.shell -# ^^^^^^^^ meta.declaration.variable.arguments.shell +#^^^^^^^^^^^^ meta.declaration.variable.shell +#^^^^ keyword.declaration.variable.shell # ^^^ meta.parameter.option.shell variable.parameter.option.shell # ^^^ meta.variable.shell entity.name.function.shell f() { local -a "$@" - #^^^^ meta.declaration.variable.shell keyword.declaration.variable.shell - # ^^^^^^^^ meta.declaration.variable.arguments.shell + #^^^^^^^^^^^^ meta.declaration.variable.shell # <- keyword.declaration.variable.shell #^^^^ keyword.declaration.variable.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell @@ -9906,8 +9885,7 @@ f() { readonly foo # 'foo' is a variable name # <- meta.declaration.variable.shell keyword.declaration.variable.shell -#^^^^^^^ meta.declaration.variable.shell -# ^^^^ meta.declaration.variable.arguments.shell +#^^^^^^^^^^^ meta.declaration.variable.shell # ^ - meta.declaration.variable #^^^^^^^ keyword.declaration.variable.shell # ^ - storage - variable @@ -9917,7 +9895,7 @@ readonly foo # 'foo' is a variable name # indexed array with string values readonly bar=\ (foo b*$r b-20 'b?r' "b*z" [100]=val /dev/null && complete -F _upto upto # <- meta.declaration.variable.shell keyword.declaration.variable.shell -#^^^^^^ meta.declaration.variable.shell -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.variable.arguments.shell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.variable.shell # ^^^^ - meta.declaration - meta.function-call # ^^^^^^^^ meta.function-call.identifier.shell # ^^^^^^^^^^^^^^ meta.function-call.arguments.shell From d2d7e86897854f7da4643f078d4b3f1e72b43a66 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 30 Jul 2024 17:54:26 +0200 Subject: [PATCH 033/113] [ShellScript] Refactor anonymous function definitions This commit... 1. scopes anonymous functions `meta.function-call meta.function.anonymous` as those are immediately called. 2. allows arguments after function body --- ShellScript/Bash.sublime-syntax | 88 ++++++--- ShellScript/test/syntax_test_bash.sh | 266 +++++++++++++++++++-------- 2 files changed, 256 insertions(+), 98 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index de554a4259..63bac8af84 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -238,6 +238,7 @@ contexts: - include: line-continuations - include: redirections - include: operators + - include: terminators - include: def-anonymous - include: cmd-alias - include: cmd-arithmetic @@ -264,6 +265,7 @@ contexts: statement: - include: redirections - include: operators + - include: terminators - include: def-anonymous - include: cmd-alias - include: cmd-arithmetic @@ -324,34 +326,65 @@ contexts: - match: \n pop: 1 -###[ FUNCTION DEFINITIONS ]#################################################### +###[ ANONYMOUS FUNCTION DEFINITIONS ]########################################## def-anonymous: - - match: (?=\(\s*\)) - push: - - def-anonymous-body - - def-function-params + # anonymous functions are immediatelly called + # hence scoping as meta.function-call meta.function + - match: (\()\s*(\)) + scope: meta.function-call.shell meta.function.anonymous.parameters.shell + captures: + 1: punctuation.section.parameters.begin.shell + 2: punctuation.section.parameters.end.shell + push: def-anonymous-body + + def-anonymous-begin: + # anonymous functions are immediatelly called + # hence scoping as meta.function-call meta.function + - meta_include_prototype: false + - meta_scope: meta.function-call.shell meta.function.anonymous.shell + - match: '' + set: def-anonymous-body def-anonymous-body: - meta_include_prototype: false - - meta_scope: meta.function.shell - - include: def-function-body-braces + - meta_content_scope: meta.function-call.shell meta.function.anonymous.shell + - match: \{ # Bash expects `{{cmd_break}}` but we don't care. + scope: punctuation.section.block.begin.shell + set: def-anonymous-block-body + - include: cmd-args-illegal-options - include: line-continuations - include: comments - include: else-pop + def-anonymous-block-body: + - meta_scope: meta.function-call.shell meta.function.anonymous.body.shell meta.block.shell + - match: \} + scope: punctuation.section.block.end.shell + set: cmd-args + - include: statements + +###[ FUNCTION DEFINITIONS ]#################################################### + def-functions: # [Bash] 3.3 Shell Functions + - match: function{{cmd_break}} + scope: keyword.declaration.function.shell + branch_point: function + branch: + - def-function-begin + - def-anonymous-begin - match: (?={{cmd_literal}}\s*\(\s*\)) push: - def-function-body - def-function-params - def-function-name - - match: function{{cmd_break}} - scope: - meta.function.shell - keyword.declaration.function.shell - push: + + def-function-begin: + - meta_include_prototype: false + - meta_scope: meta.function.shell + - match: '' + set: - def-function-body - def-function-params - def-function-name @@ -360,8 +393,8 @@ contexts: - meta_include_prototype: false - match: '{{cmd_begin}}' set: def-function-name-chars - - include: else-pop - - include: eol-pop + - match: (?=\S) + fail: function def-function-name-chars: - meta_scope: entity.name.function.shell @@ -383,10 +416,11 @@ contexts: - include: line-continuations - include: comments - include: else-pop + - include: eol-pop def-function-body: - meta_include_prototype: false - - meta_scope: meta.function.shell + - meta_content_scope: meta.function.shell - include: def-function-body-braces - include: def-function-body-parens - include: line-continuations @@ -395,16 +429,14 @@ contexts: def-function-body-braces: - match: \{ # Bash expects `{{cmd_break}}` but we don't care. - scope: meta.block.shell punctuation.section.block.begin.shell + scope: punctuation.section.block.begin.shell set: def-function-body-braces-body def-function-body-braces-body: - - meta_content_scope: meta.function.shell meta.block.shell + - meta_scope: meta.function.body.shell meta.block.shell - match: \} - scope: - meta.function.shell meta.block.shell - punctuation.section.block.end.shell - pop: 1 + scope: punctuation.section.block.end.shell + set: def-function-end - include: statements def-function-body-parens: @@ -413,14 +445,16 @@ contexts: set: def-function-body-parens-body def-function-body-parens-body: - - meta_content_scope: meta.function.shell meta.block.shell + - meta_scope: meta.function.body.shell meta.block.shell - match: \) - scope: - meta.function.shell meta.block.shell - punctuation.section.block.end.shell - pop: 1 + scope: punctuation.section.block.end.shell + set: def-function-end - include: statements + def-function-end: + - include: eoc-pop + - include: illegal-words + ###[ VARIABLE DEFINITIONS ]#################################################### def-variables: @@ -1731,6 +1765,8 @@ contexts: scope: keyword.operator.logical.shell - match: \||\& scope: keyword.operator.assignment.pipe.shell + + terminators: - match: ; scope: punctuation.terminator.statement.shell diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index d9bd0e2864..694ba57a2d 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -2309,35 +2309,41 @@ coproc foobar { # https://www.gnu.org/software/bash/manual/bash.html#Shell-Functions # ############################################################################### +# Anonymous Functions + () -#^^ - meta.function -# ^ meta.function.parameters.shell -# ^ meta.function.parameters.shell -# ^ meta.function.shell +#^^ - meta.function-call - meta.function +# ^^^ meta.function-call.shell +# ^^ meta.function.anonymous.parameters.shell +# ^ punctuation.section.parameters.begin.shell +# ^ punctuation.section.parameters.end.shell +# ^ meta.function.anonymous.shell () {} -# ^ meta.function.shell - meta.block -# ^^ meta.function.shell meta.block.shell +# ^^^ meta.function-call.shell +# ^ meta.function.anonymous.shell - meta.block +# ^^ meta.function.anonymous.body.shell meta.block.shell # ^ - meta.function # ^ punctuation.section.block.begin.shell # ^ punctuation.section.block.end.shell () \ {} -# ^ meta.function.shell - meta.block -# ^^ meta.function.shell meta.block.shell +# ^^^ meta.function-call.shell +# ^ meta.function.anonymous.shell - meta.block +# ^^ meta.function.anonymous.body.shell meta.block.shell # ^ - meta.function # ^ punctuation.section.block.begin.shell # ^ punctuation.section.block.end.shell - () { [[ $# == 2 ]] && tput setaf $2 || tput setaf 3; echo -e "$1"; tput setaf 15; } -#^^ source.shell - meta.function -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.shell - meta.function meta.function -# ^ meta.function.parameters.shell -# ^ meta.function.parameters.shell -# ^ meta.function.shell - meta.function.identifier - meta.compound -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.shell meta.block.shell + () { [[ $# == 2 ]] && tput setaf $2 || tput setaf 3; echo -e "$1"; tput setaf 15; } arg1 arg2 +#^^ source.shell - meta.function-call - meta.function +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.shell meta.function-call.shell - meta.function meta.function +# ^^ meta.function.anonymous.parameters.shell +# ^ meta.function.anonymous.shell - meta.compound +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.anonymous.body.shell meta.block.shell +# ^^^^^^^^^^ meta.function-call.arguments.shell # ^ punctuation.section.parameters.begin.shell # ^ punctuation.section.parameters.end.shell # ^ - punctuation @@ -2348,29 +2354,132 @@ coproc foobar { # ^^ keyword.operator.comparison # ^^ support.function.test.end # ^^ keyword.operator.logical +# ^ punctuation.section.block.end.shell +# ^^^^ meta.string.shell string.unquoted.shell +# ^^^^ meta.string.shell string.unquoted.shell + +function ; {} arg +# <- meta.function-call.shell meta.function.anonymous.shell keyword.declaration.function.shell +#^^^^^^^^ meta.function-call.shell meta.function.anonymous.shell +# ^^^^^^^^^ - meta.function.anonymous +# ^^ meta.function-call.identifier.shell meta.path.shell +# ^^^^ meta.function-call.arguments.shell +#^^^^^^^ keyword.declaration.function.shell +# ^ punctuation.terminator.statement.shell +# ^^ variable.function.shell +# ^^^ meta.string.shell string.unquoted.shell + +function () {} arg +# <- meta.function-call.shell meta.function.anonymous.shell keyword.declaration.function.shell +#^^^^^^^^^^^^^ meta.function-call.shell +#^^^^^^^^ meta.function.anonymous.shell +# ^^ meta.function.anonymous.parameters.shell +# ^ meta.function.anonymous.shell +# ^^ meta.function.anonymous.body.shell meta.block.shell +# ^^^^ meta.function-call.arguments.shell +#^^^^^^^ keyword.declaration.function.shell +# ^ punctuation.section.parameters.begin.shell +# ^ punctuation.section.parameters.end.shell +# ^ punctuation.section.block.begin.shell +# ^ punctuation.section.block.end.shell +# ^^^ meta.string.shell string.unquoted.shell - logC () { [[ $# == 2 ]] && tput setaf $2 || tput setaf 3; echo -e "$1"; tput setaf 15; } -#^^ source.shell - meta.function -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.shell - meta.function meta.function -# ^^^^ meta.function.identifier.shell -# ^ meta.function.identifier.shell -# ^ meta.function.parameters.shell -# ^ meta.function.parameters.shell -# ^ meta.function.shell - meta.function.identifier - meta.compound -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.shell meta.block.shell -#^^ - entity -# ^^^^ entity.name.function.shell -# ^ - entity - punctuation -# ^ punctuation.section.parameters.begin.shell -# ^ punctuation.section.parameters.end.shell -# ^ - punctuation -# ^ punctuation.section.block.begin.shell -# ^^ support.function.test.begin.shell -# ^ punctuation.definition.variable.shell -# ^^ variable.language.special.shell -# ^^ keyword.operator.comparison.shell -# ^^ support.function.test.end.shell -# ^^ keyword.operator.logical.shell +function () ; {} arg +# <- meta.function-call.shell meta.function.anonymous.shell keyword.declaration.function.shell +#^^^^^^^^^^^ meta.function-call.shell +#^^^^^^^^ meta.function.anonymous.shell +# ^^ meta.function.anonymous.parameters.shell +# ^ meta.function.anonymous.shell +# ^^^^^^^^ - meta.function.anonymous +# ^^ meta.function-call.identifier.shell +# ^^^^ meta.function-call.arguments.shell +#^^^^^^^ keyword.declaration.function.shell +# ^ punctuation.section.parameters.begin.shell +# ^ punctuation.section.parameters.end.shell +# ^ punctuation.terminator.statement.shell +# ^^ variable.function.shell +# ^^^ meta.string.shell string.unquoted.shell + +# Posix Functions + + func() ; +#^ source.shell - meta.function +# ^^^^ meta.function.identifier.shell +# ^^ meta.function.parameters.shell +# ^ meta.function.shell + + func () ; +#^ source.shell - meta.function +# ^^^^^ meta.function.identifier.shell +# ^^ meta.function.parameters.shell +# ^ meta.function.shell + + func () () +#^ source.shell - meta.function +# ^^^^^ meta.function.identifier.shell +# ^^ meta.function.parameters.shell +# ^ meta.function.shell +# ^^ meta.function.body.shell meta.block.shell + + func () {} +#^ source.shell - meta.function +# ^^^^^ meta.function.identifier.shell +# ^^ meta.function.parameters.shell +# ^ meta.function.shell +# ^^ meta.function.body.shell meta.block.shell + + func () {} rest # comment +#^ source.shell - meta.function +# ^^^^^ meta.function.identifier.shell +# ^^ meta.function.parameters.shell +# ^ meta.function.shell +# ^^ meta.function.body.shell meta.block.shell +# ^^^^ invalid.illegal.unexpected-token.shell +# ^^^^^^^^^^ comment.line.number-sign.shell + + func () {} rest ; echo done +#^ source.shell - meta.function +# ^^^^^ meta.function.identifier.shell +# ^^ meta.function.parameters.shell +# ^ meta.function.shell +# ^^ meta.function.body.shell meta.block.shell +# ^^^^ invalid.illegal.unexpected-token.shell +# ^ punctuation.terminator.statement.shell +# ^^^^ support.function.echo.shell +# ^^^^ meta.string.shell string.unquoted.shell + + func () {} rest && echo done +#^ source.shell - meta.function +# ^^^^^ meta.function.identifier.shell +# ^^ meta.function.parameters.shell +# ^ meta.function.shell +# ^^ meta.function.body.shell meta.block.shell +# ^^^^ invalid.illegal.unexpected-token.shell +# ^^ keyword.operator.logical.shell +# ^^^^ support.function.echo.shell +# ^^^^ meta.string.shell string.unquoted.shell + + logC () { [[ $# == 2 ]] && tput setaf $2 || tput setaf 3; echo -e "$1"; tput setaf 15; } +#^ source.shell - meta.function +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.shell - meta.function meta.function +# ^^^^ meta.function.identifier.shell +# ^ meta.function.identifier.shell +# ^^ meta.function.parameters.shell +# ^ meta.function.shell - meta.function.identifier - meta.compound +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.body.shell meta.block.shell +#^ - entity +# ^^^^ entity.name.function.shell +# ^ - entity - punctuation +# ^ punctuation.section.parameters.begin.shell +# ^ punctuation.section.parameters.end.shell +# ^ - punctuation +# ^ punctuation.section.block.begin.shell +# ^^ support.function.test.begin.shell +# ^ punctuation.definition.variable.shell +# ^^ variable.language.special.shell +# ^^ keyword.operator.comparison.shell +# ^^ support.function.test.end.shell +# ^^ keyword.operator.logical.shell logExit ( ) { # <- source.shell meta.function.identifier.shell entity.name.function.shell @@ -2379,7 +2488,7 @@ logExit ( ) { # ^ meta.function.identifier.shell # ^^^ meta.function.parameters.shell # ^ meta.function.shell - meta.block -# ^^ meta.function.shell meta.block.shell +# ^^ meta.function.body.shell meta.block.shell #^^^^^^ entity.name.function.shell # ^ - entity - punctuation # ^ punctuation.section.parameters.begin.shell @@ -2407,7 +2516,7 @@ logExit ( ) { # ^ keyword.operator.arithmetic.shell # ^ meta.number.integer.decimal.shell constant.numeric.value.shell } -# <- meta.function.shell meta.block.shell punctuation.section.block.end.shell +# <- meta.function.body.shell meta.block.shell punctuation.section.block.end.shell #^ - meta.function logExit $? $WEIRD @@ -2424,15 +2533,16 @@ function foo #^^^^^^^^^^^^ source.shell - meta.function meta.function # <- source.shell meta.function.shell keyword.declaration.function.shell #^^^^^^^ meta.function.shell -# ^^^^^ meta.function.identifier.shell +# ^^^^ meta.function.identifier.shell +# ^ meta.function.shell #^^^^^^^ keyword.declaration.function.shell # ^ - entity - keyword - storage # ^^^ entity.name.function.shell # ^ - entity { -# <- meta.function.shell meta.block.shell punctuation.section.block.begin.shell +# <- meta.function.body.shell meta.block.shell punctuation.section.block.begin.shell foo bar - # <- meta.function.shell meta.block.shell meta.function-call.identifier.shell + # <- meta.function.body.shell meta.block.shell meta.function-call.identifier.shell # <- variable.function.shell return 0 @@ -2445,7 +2555,7 @@ function foo #^^^^^ keyword.control.flow.return.shell # ^^^^^^^^^^^^^^ meta.interpolation.parameter.shell } -# <- meta.function.shell meta.block.shell punctuation.section.block.end.shell +# <- meta.function.body.shell meta.block.shell punctuation.section.block.end.shell #^ - meta.function # <- - meta.function @@ -2454,13 +2564,19 @@ function func\ name # <- source.shell meta.function.identifier.shell entity.name.function.shell +function \ +func\ +name +# <- source.shell meta.function.identifier.shell entity.name.function.shell + function foo ( ) { #^^^^^^^^^^^^^^^^^^^^^^ source.shell - meta.function meta.function # <- source.shell meta.function.shell keyword.declaration.function.shell #^^^^^^^ meta.function.shell # ^^^^^ meta.function.identifier.shell # ^^^^^^^ meta.function.parameters.shell -# ^^^ meta.function.shell +# ^ meta.function.shell +# ^^ meta.function.body.shell meta.block.shell # ^ - entity.name.function # ^^^ entity.name.function.shell # ^ - entity.name.function @@ -2468,10 +2584,10 @@ function foo ( ) { # ^ punctuation.section.parameters.end.shell # ^ punctuation.section.block.begin.shell echo 'hello from foo' - # <- meta.function.shell meta.block.shell meta.function-call.identifier.shell + # <- meta.function.body.shell meta.block.shell meta.function-call.identifier.shell # <- support.function.echo.shell } -# <- meta.function.shell meta.block.shell punctuation.section.block.end.shell +# <- meta.function.body.shell meta.block.shell punctuation.section.block.end.shell #^ - meta.function # <- - meta.function @@ -2481,26 +2597,26 @@ f () ( #^ meta.function.identifier.shell - entity - punctuation # ^^ meta.function.parameters.shell # ^ meta.function.shell - meta.block -# ^ meta.function.shell meta.block.shell punctuation.section.block.begin.shell +# ^ meta.function.body.shell meta.block.shell punctuation.section.block.begin.shell echo hello - # <- meta.function.shell meta.block.shell meta.function-call.identifier.shell + # <- meta.function.body.shell meta.block.shell meta.function-call.identifier.shell # <- support.function.echo.shell ) -# <- meta.function.shell meta.block.shell punctuation.section.block.end.shell +# <- meta.function.body.shell meta.block.shell punctuation.section.block.end.shell #^ - meta.function function f ( # <- meta.function.shell keyword.declaration.function.shell #^^^^^^^ meta.function.shell # ^^^ meta.function.identifier.shell -# ^^ meta.function.shell meta.block.shell +# ^^ meta.function.body.shell meta.block.shell #^^^^^^^ keyword.declaration.function.shell # ^ entity.name.function.shell # ^ punctuation.section.block.begin.shell echo hello # <- meta.function meta.function-call support.function.echo ) -# <- meta.function.shell meta.block.shell punctuation.section.block.end.shell +# <- meta.function.body.shell meta.block.shell punctuation.section.block.end.shell #^ - meta.function function foo { @@ -2574,18 +2690,13 @@ foo:foo () { @ # <- meta.function-call.identifier.shell variable.function.shell -function () () -# <- meta.function.identifier.shell entity.name.function.shell -function () {} -# <- meta.function.identifier.shell entity.name.function.shell - function 7zip { # <- meta.function.shell keyword.declaration.function.shell #^^^^^^^ meta.function.shell keyword.declaration.function.shell # ^^^^^^ meta.function.identifier.shell # ^^^^ entity.name.function.shell } -# <- meta.function.shell meta.block.shell punctuation.section.block.end.shell +# <- meta.function.body.shell meta.block.shell punctuation.section.block.end.shell 7zip # <- meta.function-call.identifier.shell variable.function.shell #^^^ meta.function-call.identifier.shell variable.function.shell @@ -2595,7 +2706,8 @@ function [] () { #^^^^^^^ meta.function.shell # ^^^^ meta.function.identifier.shell # ^^ meta.function.parameters.shell -# ^^^ meta.function.shell +# ^ meta.function.shell +# ^^ meta.function.body.shell meta.block.shell #^^^^^^^ keyword.declaration.function.shell # ^^ entity.name.function.shell # ^ punctuation.section.parameters.begin.shell @@ -2603,7 +2715,7 @@ function [] () { # ^ meta.block.shell punctuation.section.block.begin.shell echo "Hello from []" } -# <- meta.function.shell meta.block.shell punctuation.section.block.end.shell +# <- meta.function.body.shell meta.block.shell punctuation.section.block.end.shell [] # <- meta.function-call.identifier.shell variable.function.shell #^ meta.function-call.identifier.shell variable.function.shell @@ -2613,7 +2725,8 @@ function [[]] () { #^^^^^^^ meta.function.shell # ^^^^^^ meta.function.identifier.shell # ^^ meta.function.parameters.shell -# ^^^ meta.function.shell +# ^ meta.function.shell +# ^^ meta.function.body.shell meta.block.shell #^^^^^^^ keyword.declaration.function.shell # ^^^^ entity.name.function.shell # ^ punctuation.section.parameters.begin.shell @@ -2630,7 +2743,8 @@ function {} () { #^^^^^^^ meta.function.shell # ^^^^ meta.function.identifier.shell # ^^ meta.function.parameters.shell -# ^^^ meta.function.shell +# ^ meta.function.shell +# ^^ meta.function.body.shell meta.block.shell #^^^^^^^ keyword.declaration.function.shell # ^^ entity.name.function.shell # ^ punctuation.section.parameters.begin.shell @@ -2647,7 +2761,8 @@ function {{}} () { #^^^^^^^ meta.function.shell # ^^^^^^ meta.function.identifier.shell # ^^ meta.function.parameters.shell -# ^^^ meta.function.shell +# ^ meta.function.shell +# ^^ meta.function.body.shell meta.block.shell #^^^^^^^ keyword.declaration.function.shell # ^^^^ entity.name.function.shell # ^ punctuation.section.parameters.begin.shell @@ -2664,7 +2779,8 @@ function -foo () { #^^^^^^^ meta.function.shell # ^^^^^^ meta.function.identifier.shell # ^^ meta.function.parameters.shell -# ^^^ meta.function.shell +# ^ meta.function.shell +# ^^ meta.function.body.shell meta.block.shell #^^^^^^^ keyword.declaration.function.shell # ^^^^ entity.name.function.shell # ^ punctuation.section.parameters.begin.shell @@ -2681,7 +2797,8 @@ function +foo () { #^^^^^^^ meta.function.shell # ^^^^^^ meta.function.identifier.shell # ^^ meta.function.parameters.shell -# ^^^ meta.function.shell +# ^ meta.function.shell +# ^^ meta.function.body.shell meta.block.shell #^^^^^^^ keyword.declaration.function.shell # ^^^^ entity.name.function.shell # ^ punctuation.section.parameters.begin.shell @@ -2698,7 +2815,8 @@ function =foo () { #^^^^^^^ meta.function.shell # ^^^^^^ meta.function.identifier.shell # ^^ meta.function.parameters.shell -# ^^^ meta.function.shell +# ^ meta.function.shell +# ^^ meta.function.body.shell meta.block.shell #^^^^^^^ keyword.declaration.function.shell # ^^^^ entity.name.function.shell # ^ punctuation.section.parameters.begin.shell @@ -2715,7 +2833,8 @@ function fo${bar}baz () {} # ^^^^^^ meta.function.identifier.shell meta.interpolation.parameter.shell - meta.string # ^^^ meta.function.identifier.shell - meta.interpolation # ^^ meta.function.parameters.shell -# ^^^ meta.function.shell +# ^ meta.function.shell +# ^^ meta.function.body.shell meta.block.shell # ^^ entity.name.function.shell # ^^^^^^ - entity.name # ^^^ entity.name.function.shell @@ -2725,12 +2844,15 @@ function true () {} ; function false () {} #^^^^^^^ meta.function.shell # ^^^^^^ meta.function.identifier.shell # ^^ meta.function.parameters.shell -# ^^^ meta.function.shell +# ^ meta.function.shell +# ^^ meta.function.body.shell meta.block.shell # ^^^ - meta.function # ^^^^^^^^ meta.function.shell # ^^^^^^^ meta.function.identifier.shell # ^^ meta.function.parameters.shell -# ^^^ meta.function.shell +# ^ meta.function.shell +# ^^ meta.function.body.shell meta.block.shell +# ^ - meta.function # ^^^^ entity.name.function.shell # ^^^^^ entity.name.function.shell # ^ punctuation.terminator.statement.shell @@ -2750,7 +2872,7 @@ __git_aliased_command () esac done } -# <- meta.function.shell meta.block.shell punctuation.section.block.end.shell +# <- meta.function.body.shell meta.block.shell punctuation.section.block.end.shell #^ - meta.function # <- - meta.function @@ -9863,7 +9985,7 @@ f() { local "$x"'+=(4)' # <- keyword.declaration.variable.shell esac - # <- meta.function.shell meta.block.shell meta.conditional.case.shell + # <- meta.function.body.shell meta.block.shell meta.conditional.case.shell # <- keyword.control.conditional.end.shell IFS=, local -a "$x"'=("${x}: ${'"$x"'[*]}")' @@ -9872,10 +9994,10 @@ f() { # ^ meta.string.shell string.unquoted.shell # ^ keyword.declaration.variable.shell done - # <- meta.function.shell meta.block.shell + # <- meta.function.body.shell meta.block.shell # <- keyword.control.loop.end.shell } -# <- meta.function.shell meta.block.shell punctuation.section.block.end.shell +# <- meta.function.body.shell meta.block.shell punctuation.section.block.end.shell ############################################################################### From 3c09b5eba67df9dff45e12dbe1a7aa72e8e82cf9 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 30 Jul 2024 18:55:23 +0200 Subject: [PATCH 034/113] [ShellScript] Refactor command arguments This commit adjusts builtin commands' argument contexts so they follow the same context structure, used by cmd-basic - means: dedicated cmd-args-meta context is used to apply meta.function-call.arguments scope. Hence eoc-pop2 and eol-pop2 become obsolete as all commands share same structure. --- ShellScript/Bash.sublime-syntax | 49 ++--- ...commands-builtin-shell-bash.sublime-syntax | 180 +++++++++++------- ShellScript/tools/update-commands.py | 8 +- 3 files changed, 125 insertions(+), 112 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 63bac8af84..c882e4aec1 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -361,7 +361,9 @@ contexts: - meta_scope: meta.function-call.shell meta.function.anonymous.body.shell meta.block.shell - match: \} scope: punctuation.section.block.end.shell - set: cmd-args + set: + - cmd-args-meta + - cmd-args - include: statements ###[ FUNCTION DEFINITIONS ]#################################################### @@ -789,14 +791,9 @@ contexts: meta.function-call.identifier.shell support.function.export.shell push: - - cmd-export-args-meta + - cmd-args-meta - cmd-export-args - cmd-export-args-meta: - - meta_include_prototype: false - - meta_content_scope: meta.function-call.arguments.shell - - include: immediately-pop - cmd-export-args: - match: ([-+])n?fn?{{opt_break}} scope: @@ -1062,14 +1059,9 @@ contexts: meta.function-call.identifier.shell support.function.unalias.shell push: - - cmd-unalias-args-meta + - cmd-args-meta - cmd-unalias-args - cmd-unalias-args-meta: - - meta_include_prototype: false - - meta_content_scope: meta.function-call.arguments.shell - - include: immediately-pop - cmd-unalias-args: - match: ([-+])a{{opt_break}} scope: @@ -1087,14 +1079,9 @@ contexts: meta.function-call.identifier.shell support.function.unset.shell push: - - cmd-unset-args-meta + - cmd-args-meta - cmd-unset-args - cmd-unset-args-meta: - - meta_include_prototype: false - - meta_content_scope: meta.function-call.arguments.shell - - include: immediately-pop - cmd-unset-args: - match: ([-+])[nv]?f[nv]?{{opt_break}} scope: @@ -1182,16 +1169,22 @@ contexts: - include: line-continuations - include: path-pattern-content - match: '{{cmd_break}}' - set: cmd-args + set: + - cmd-args-meta + - cmd-args cmd-args: - meta_include_prototype: false - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-end-of-options-then-ambigious - include: cmd-args-options - include: cmd-args-values + cmd-args-meta: + - meta_include_prototype: false + - meta_content_scope: meta.function-call.arguments.shell + - include: immediately-pop + cmd-args-end: - include: redirections - include: eoc-pop @@ -1243,12 +1236,12 @@ contexts: cmd-args-end-of-options-then-ambigious: - match: --{{word_break}} scope: keyword.operator.end-of-options.shell - push: cmd-args-ambigious + set: cmd-args-ambigious cmd-args-ambigious: - meta_include_prototype: false - include: redirections - - include: eoc-pop2 + - include: eoc-pop - include: cmd-args-values cmd-args-end-of-options-then-function-declarations: @@ -3099,21 +3092,11 @@ contexts: pop: 1 - include: eol-pop - eoc-pop2: - - match: (?=\s*(?:[)}|;]|&(?!>))) - pop: 2 - - include: eol-pop2 - eol-pop: - match: (?=\s*$|\s+#) pop: 1 - include: line-continuations - eol-pop2: - - match: (?=\s*$|\s+#) - pop: 2 - - include: line-continuations - immediately-pop: - match: '' pop: 1 diff --git a/ShellScript/commands-builtin-shell-bash.sublime-syntax b/ShellScript/commands-builtin-shell-bash.sublime-syntax index b2f7e01871..a8b33948f4 100644 --- a/ShellScript/commands-builtin-shell-bash.sublime-syntax +++ b/ShellScript/commands-builtin-shell-bash.sublime-syntax @@ -9,116 +9,184 @@ scope: commands.builtin.shell.bash version: 2 hidden: true contexts: - main: - - match: '' + main: [] cmd-builtins: - match: bind{{cmd_break}} scope: meta.function-call.identifier.shell support.function.bind.shell - push: cmd-bind-args + push: + - cmd-args-meta + - cmd-bind-args - match: builtin{{cmd_break}} scope: meta.function-call.identifier.shell support.function.builtin.shell - push: cmd-builtin-args + push: + - cmd-args-meta + - cmd-builtin-args - match: caller{{cmd_break}} scope: meta.function-call.identifier.shell support.function.caller.shell - push: cmd-caller-args + push: + - cmd-args-meta + - cmd-caller-args - match: :{{cmd_break}} scope: meta.function-call.identifier.shell support.function.colon.shell - push: cmd-colon-args + push: + - cmd-args-meta + - cmd-colon-args - match: command{{cmd_break}} scope: meta.function-call.identifier.shell support.function.command.shell - push: cmd-command-args + push: + - cmd-args-meta + - cmd-command-args - match: cd{{cmd_break}} scope: meta.function-call.identifier.shell support.function.cd.shell - push: cmd-cd-args + push: + - cmd-args-meta + - cmd-cd-args - match: \.{{cmd_break}} scope: meta.function-call.identifier.shell support.function.dot.shell - push: cmd-dot-args + push: + - cmd-args-meta + - cmd-dot-args - match: enable{{cmd_break}} scope: meta.function-call.identifier.shell support.function.enable.shell - push: cmd-enable-args + push: + - cmd-args-meta + - cmd-enable-args - match: help{{cmd_break}} scope: meta.function-call.identifier.shell support.function.help.shell - push: cmd-help-args + push: + - cmd-args-meta + - cmd-help-args - match: logout{{cmd_break}} scope: meta.function-call.identifier.shell support.function.logout.shell - push: cmd-logout-args + push: + - cmd-args-meta + - cmd-logout-args - match: mapfile{{cmd_break}} scope: meta.function-call.identifier.shell support.function.mapfile.shell - push: cmd-mapfile-args + push: + - cmd-args-meta + - cmd-mapfile-args - match: printf{{cmd_break}} scope: meta.function-call.identifier.shell support.function.printf.shell - push: cmd-printf-args + push: + - cmd-args-meta + - cmd-printf-args - match: read{{cmd_break}} scope: meta.function-call.identifier.shell support.function.read.shell - push: cmd-read-args + push: + - cmd-args-meta + - cmd-read-args - match: readarray{{cmd_break}} scope: meta.function-call.identifier.shell support.function.readarray.shell - push: cmd-readarray-args + push: + - cmd-args-meta + - cmd-readarray-args - match: source{{cmd_break}} scope: meta.function-call.identifier.shell support.function.source.shell - push: cmd-source-args + push: + - cmd-args-meta + - cmd-source-args - match: type{{cmd_break}} scope: meta.function-call.identifier.shell support.function.type.shell - push: cmd-type-args + push: + - cmd-args-meta + - cmd-type-args - match: ulimit{{cmd_break}} scope: meta.function-call.identifier.shell support.function.ulimit.shell - push: cmd-ulimit-args + push: + - cmd-args-meta + - cmd-ulimit-args - match: eval{{cmd_break}} scope: meta.function-call.identifier.shell support.function.eval.shell - push: cmd-eval-args + push: + - cmd-args-meta + - cmd-eval-args - match: getopts{{cmd_break}} scope: meta.function-call.identifier.shell support.function.getopts.shell - push: cmd-getopts-args + push: + - cmd-args-meta + - cmd-getopts-args - match: hash{{cmd_break}} scope: meta.function-call.identifier.shell support.function.hash.shell - push: cmd-hash-args + push: + - cmd-args-meta + - cmd-hash-args - match: pwd{{cmd_break}} scope: meta.function-call.identifier.shell support.function.pwd.shell - push: cmd-pwd-args + push: + - cmd-args-meta + - cmd-pwd-args - match: shift{{cmd_break}} scope: meta.function-call.identifier.shell support.function.shift.shell - push: cmd-shift-args + push: + - cmd-args-meta + - cmd-shift-args - match: times{{cmd_break}} scope: meta.function-call.identifier.shell support.function.times.shell - push: cmd-times-args + push: + - cmd-args-meta + - cmd-times-args - match: trap{{cmd_break}} scope: meta.function-call.identifier.shell support.function.trap.shell - push: cmd-trap-args + push: + - cmd-args-meta + - cmd-trap-args - match: umask{{cmd_break}} scope: meta.function-call.identifier.shell support.function.umask.shell - push: cmd-umask-args + push: + - cmd-args-meta + - cmd-umask-args - match: set{{cmd_break}} scope: meta.function-call.identifier.shell support.function.set.shell - push: cmd-set-args + push: + - cmd-args-meta + - cmd-set-args - match: shopt{{cmd_break}} scope: meta.function-call.identifier.shell support.function.shopt.shell - push: cmd-shopt-args + push: + - cmd-args-meta + - cmd-shopt-args - match: bg{{cmd_break}} scope: meta.function-call.identifier.shell support.function.bg.shell - push: cmd-bg-args + push: + - cmd-args-meta + - cmd-bg-args - match: fg{{cmd_break}} scope: meta.function-call.identifier.shell support.function.fg.shell - push: cmd-fg-args + push: + - cmd-args-meta + - cmd-fg-args - match: jobs{{cmd_break}} scope: meta.function-call.identifier.shell support.function.jobs.shell - push: cmd-jobs-args + push: + - cmd-args-meta + - cmd-jobs-args - match: kill{{cmd_break}} scope: meta.function-call.identifier.shell support.function.kill.shell - push: cmd-kill-args + push: + - cmd-args-meta + - cmd-kill-args - match: wait{{cmd_break}} scope: meta.function-call.identifier.shell support.function.wait.shell - push: cmd-wait-args + push: + - cmd-args-meta + - cmd-wait-args - match: disown{{cmd_break}} scope: meta.function-call.identifier.shell support.function.disown.shell - push: cmd-disown-args + push: + - cmd-args-meta + - cmd-disown-args - match: suspend{{cmd_break}} scope: meta.function-call.identifier.shell support.function.suspend.shell - push: cmd-suspend-args + push: + - cmd-args-meta + - cmd-suspend-args - match: su{{cmd_break}} scope: meta.function-call.identifier.shell support.function.su.shell - push: cmd-su-args + push: + - cmd-args-meta + - cmd-su-args cmd-bind-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[lpsvPSVX]*[mqurfx] @@ -132,21 +200,17 @@ contexts: 1: punctuation.definition.parameter.shell - include: cmd-args-values cmd-builtin-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-end-of-options-then-ambigious - include: cmd-args-values cmd-caller-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-end-of-options-then-ambigious - include: cmd-args-values cmd-colon-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-values cmd-command-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[pVv]+ @@ -155,7 +219,6 @@ contexts: 1: punctuation.definition.parameter.shell - include: cmd-args-values cmd-cd-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[LPe@] @@ -165,11 +228,9 @@ contexts: push: cmd-args-option-maybe-value - include: cmd-args-values cmd-dot-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-values cmd-enable-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[dnps]*[af] @@ -183,7 +244,6 @@ contexts: 1: punctuation.definition.parameter.shell - include: cmd-args-values cmd-help-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[dms]+ @@ -192,12 +252,10 @@ contexts: 1: punctuation.definition.parameter.shell - include: cmd-args-values cmd-logout-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-end-of-options-then-ambigious - include: cmd-args-values cmd-mapfile-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[dnOstuCc] @@ -207,7 +265,6 @@ contexts: push: cmd-args-option-maybe-value - include: cmd-args-values cmd-printf-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[v] @@ -217,7 +274,6 @@ contexts: push: cmd-args-option-maybe-value - include: cmd-args-values cmd-read-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[ers]*[adeinNprstu] @@ -231,7 +287,6 @@ contexts: 1: punctuation.definition.parameter.shell - include: cmd-args-values cmd-readarray-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[ers]*[adeinNprstu] @@ -245,12 +300,10 @@ contexts: 1: punctuation.definition.parameter.shell - include: cmd-args-values cmd-source-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-end-of-options-then-ambigious - include: cmd-args-values cmd-type-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[afptP]+ @@ -259,7 +312,6 @@ contexts: 1: punctuation.definition.parameter.shell - include: cmd-args-values cmd-ulimit-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[HSabcdefiklmnpqrstuvxPT]+ @@ -268,16 +320,13 @@ contexts: 1: punctuation.definition.parameter.shell - include: cmd-args-values cmd-eval-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-values cmd-getopts-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-end-of-options-then-ambigious - include: cmd-args-values cmd-hash-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[dt]*[rpl] @@ -291,7 +340,6 @@ contexts: 1: punctuation.definition.parameter.shell - include: cmd-args-values cmd-pwd-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[LP]+ @@ -300,16 +348,13 @@ contexts: 1: punctuation.definition.parameter.shell - include: cmd-args-values cmd-shift-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-values cmd-times-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-end-of-options-then-ambigious - include: cmd-args-values cmd-trap-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[lp]+ @@ -318,7 +363,6 @@ contexts: 1: punctuation.definition.parameter.shell - include: cmd-args-values cmd-umask-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[pS] @@ -328,7 +372,6 @@ contexts: push: cmd-args-option-maybe-value - include: cmd-args-values cmd-set-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[abefhkmnptuvxBCEHPT]*[o] @@ -342,7 +385,6 @@ contexts: 1: punctuation.definition.parameter.shell - include: cmd-args-values cmd-shopt-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[pqsu]*[o] @@ -356,17 +398,14 @@ contexts: 1: punctuation.definition.parameter.shell - include: cmd-args-values cmd-bg-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-end-of-options-then-ambigious - include: cmd-args-values cmd-fg-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-end-of-options-then-ambigious - include: cmd-args-values cmd-jobs-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[lnprs]*[x] @@ -380,27 +419,22 @@ contexts: 1: punctuation.definition.parameter.shell - include: cmd-args-values cmd-kill-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[snlL]+ scope: meta.parameter.option.shell variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell - push: cmd-args-option-maybe-value - include: cmd-args-values cmd-wait-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[fnp]+ scope: meta.parameter.option.shell variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell - push: cmd-args-option-maybe-value - include: cmd-args-values cmd-disown-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[ar]*[h] @@ -414,7 +448,6 @@ contexts: 1: punctuation.definition.parameter.shell - include: cmd-args-values cmd-suspend-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[f] @@ -424,7 +457,6 @@ contexts: push: cmd-args-option-maybe-value - include: cmd-args-values cmd-su-args: - - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - include: cmd-args-end-of-options-then-ambigious - match: ([-+])[mp]*[-cls] diff --git a/ShellScript/tools/update-commands.py b/ShellScript/tools/update-commands.py index ab6d49496f..c1c97f6a33 100644 --- a/ShellScript/tools/update-commands.py +++ b/ShellScript/tools/update-commands.py @@ -9,7 +9,7 @@ def main(): main = [] contexts = { - "main": [{"match": ''}], + "main": [], "cmd-builtins": main } @@ -17,9 +17,7 @@ def main(): if not value: value = {} - cmd_args = [{"meta_content_scope": "meta.function-call.arguments.shell"}] - - cmd_args.append({"include": "cmd-args-end"}) + cmd_args = [{"include": "cmd-args-end"}] allow_eoo = value.get("allow-end-of-options-token", True) if allow_eoo: @@ -72,7 +70,7 @@ def main(): main.append({ "match": match, "scope": scope, - "push": f"cmd-{command}-args" + "push": ["cmd-args-meta", f"cmd-{command}-args"] }) commands_output = { From fa33e93f28ddc5389be5414921f0e210463c2566 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 30 Jul 2024 22:04:35 +0200 Subject: [PATCH 035/113] [ShellScript] Add missing option word boundaries --- ShellScript/Bash.sublime-syntax | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index c882e4aec1..fed7b091b1 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -526,7 +526,7 @@ contexts: - include: immediately-pop cmd-alias-args: - - match: ([-+])p + - match: ([-+])p{{opt_break}} scope: meta.parameter.option.shell variable.parameter.option.shell @@ -898,14 +898,14 @@ contexts: captures: 1: punctuation.definition.parameter.shell push: cmd-args-option-maybe-assignment - - match: ([-+])[AbEeHiKklnPSsUuVv]*[aCcghprt] + - match: ([-+])[AbEeHiKklnPSsUuVv]*[aCcghprt]{{opt_break}} scope: meta.parameter.option.shell variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell push: cmd-args-option-maybe-value - - match: ([-+])[AbEeHiKklnPSsUuVv]+ + - match: ([-+])[AbEeHiKklnPSsUuVv]+{{opt_break}} scope: meta.parameter.option.shell variable.parameter.option.shell From 84eebb1559f1729fe2a35abba4cde76161eee6cb Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 30 Jul 2024 23:34:52 +0200 Subject: [PATCH 036/113] [ShellScript] Fix for arguments --- ShellScript/Bash.sublime-syntax | 2 +- ShellScript/test/syntax_test_bash.sh | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index fed7b091b1..8ade7c8fc0 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -1470,7 +1470,7 @@ contexts: for-args: - meta_include_prototype: false - - include: line-continuations + - include: eoc-pop - match: \(\( scope: punctuation.section.arithmetic.begin.shell set: cmd-arithmetic-body diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index 694ba57a2d..99cb4dc5e1 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -920,6 +920,20 @@ do$var do+= #^^^^ - keyword.control +for +var in $vars; +# <- - variable.other +#^^ - variable.other +#^^^^^^^^^^^ meta.function-call + +for \ +var in $vars; +#<- variable.other.readwrite.shell +#^^ variable.other.readwrite.shell +# ^^ keyword.control.in.shell +# ^^^^^ meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^ punctuation.terminator.statement.shell + for done # <- keyword.control.loop.for.shell #^^ keyword.control.loop.for.shell From fe77936ee42cf43246ca2503134b4b3cd3aabba3 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Wed, 31 Jul 2024 21:39:07 +0200 Subject: [PATCH 037/113] [ShellScript] Simplify arithmetic command We have enough context to no longer need to rely on lookahead for closing )). --- ShellScript/Bash.sublime-syntax | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 8ade7c8fc0..3ed1855117 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -556,7 +556,7 @@ contexts: ###[ ARITHMETIC BUILTINS ]##################################################### cmd-arithmetic: - - match: \(\((?=.+\)\)) + - match: \(\( scope: punctuation.section.arithmetic.begin.shell push: cmd-arithmetic-body - match: let{{cmd_break}} From a7325860fdd569d5367a22f5a7ba58a46932f8d6 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 30 Jul 2024 21:56:04 +0200 Subject: [PATCH 038/113] [ShellScript] Refactor arithmetic expressions This commit... 1. treats `let ...` statement as arithmetic variable declaration as this is what it is most likely used for. 2. drops `cmd-test` and treats arguments as plain arithmetic expressions. Actually let args are equal to content of (( ... )) compound commands according to Bash Manual. 3. refactors quoted vs. unquoted expressions --- ShellScript/Bash.sublime-syntax | 198 +++++--- ShellScript/test/syntax_test_bash.sh | 662 ++++++++++++++++----------- 2 files changed, 521 insertions(+), 339 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 3ed1855117..cc95c0a25b 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -557,51 +557,24 @@ contexts: cmd-arithmetic: - match: \(\( - scope: punctuation.section.arithmetic.begin.shell + scope: punctuation.section.compound.begin.shell push: cmd-arithmetic-body - match: let{{cmd_break}} - scope: - meta.function-call.identifier.shell - support.function.let.shell + scope: meta.function-call.identifier.shell support.function.let.shell push: cmd-arithmetic-args cmd-arithmetic-body: - - meta_scope: meta.arithmetic.shell + - meta_scope: meta.compound.arithmetic.shell + - meta_content_scope: meta.arithmetic.shell - match: \)\) - scope: punctuation.section.arithmetic.end.shell + scope: punctuation.section.compound.end.shell pop: 1 - - include: expressions + - include: expression-content cmd-arithmetic-args: - - meta_content_scope: meta.function-call.arguments.shell - - match: \" - scope: - meta.string.shell string.quoted.double.shell - punctuation.definition.string.begin.shell - embed: cmd-arithmetic-args-quoted-commen - embed_scope: meta.string.shell meta.interpolation.shell - escape: '{{no_escape_behind}}"' - escape_captures: - 0: meta.string.shell string.quoted.double.shell - punctuation.definition.string.end.shell - - match: \' - scope: - meta.string.shell string.quoted.single.shell - punctuation.definition.string.begin.shell - embed: cmd-arithmetic-args-quoted-commen - embed_scope: meta.string.shell meta.interpolation.shell - escape: '{{no_escape_behind}}''' - escape_captures: - 0: meta.string.shell string.quoted.single.shell - punctuation.definition.string.end.shell + - meta_content_scope: meta.function-call.arguments.shell meta.arithmetic.shell - include: cmd-args-end - - include: cmd-test - - include: expressions - - cmd-arithmetic-args-quoted-commen: - - include: line-continuations - - include: cmd-test - - include: expressions + - include: expression-content ###[ COPROC BUILTINS ]######################################################### @@ -1472,7 +1445,7 @@ contexts: - meta_include_prototype: false - include: eoc-pop - match: \(\( - scope: punctuation.section.arithmetic.begin.shell + scope: punctuation.section.compound.begin.shell set: cmd-arithmetic-body - match: (?=\S) set: loop-iterator-var @@ -1504,12 +1477,12 @@ contexts: arithmetic-array-value: # maybe indexed array of or single arithmetic expression value - meta_include_prototype: false - - include: line-continuations - match: \( scope: punctuation.section.sequence.begin.shell set: arithmetic-explicit-mapping-body - - match: '' - set: arithmetic-value-body + - include: line-continuations + - include: arithmetic-word + - include: immediately-pop arithmetic-mapping-value-assignment: # maybe variable subscripts followed by value assignment @@ -1524,12 +1497,12 @@ contexts: arithmetic-mapping-value: # maybe associative of or single arithmetic expression value - meta_include_prototype: false - - include: line-continuations - match: \( scope: punctuation.section.sequence.begin.shell set: arithmetic-mapping-begin - - match: '' - set: arithmetic-value-body + - include: line-continuations + - include: arithmetic-word + - include: immediately-pop arithmetic-mapping-begin: - meta_scope: meta.sequence.list.shell @@ -1546,9 +1519,8 @@ contexts: - include: list-end - include: comments - include: explicit-mapping-keys - - include: arithmetic-operators - - include: numbers - - include: variables + - match: (?=[[:alnum:]_'"]) + push: arithmetic-word - include: illegal-words arithmetic-implicit-mapping-body: @@ -1568,16 +1540,7 @@ contexts: arithmetic-implicit-mapping-value: - include: line-continuations - include: comments - - match: '{{word_begin}}' - set: arithmetic-value-body - - arithmetic-value-body: - - match: '{{word_break}}' - pop: 1 - - include: line-continuations - - include: arithmetic-operators - - include: numbers - - include: variables + - include: arithmetic-word ###[ LITERAL VALUE ASSIGNMENTS ]############################################### @@ -1691,12 +1654,93 @@ contexts: scope: invalid.illegal.unexpected-token.shell - include: line-continuations -###[ EXPRESSIONS ]############################################################# +###[ ARITHMETIC EXPRESSIONS ]################################################## - expressions: + arithmetic-word: + # A `word` which is interpreted as arithmetic expression + - match: \" + scope: punctuation.definition.quoted.begin.shell + set: arithmetic-word-double-quoted-body + - match: \' + scope: punctuation.definition.quoted.begin.shell + set: arithmetic-word-single-quoted-body + - match: '{{word_begin}}' + set: arithmetic-word-unquoted-body + + arithmetic-word-double-quoted-body: + - meta_scope: meta.arithmetic.shell + - include: expression-double-quoted-body + + arithmetic-word-single-quoted-body: + - meta_scope: meta.arithmetic.shell + - include: expression-single-quoted-body + + arithmetic-word-unquoted-body: + - meta_scope: meta.arithmetic.shell - match: \( scope: punctuation.section.group.begin.shell push: expression-group-body + - include: expression-common + - match: '{{word_break}}' + pop: 1 + + expression-content: + # arithmetic expression content without word boundary checks + - match: \" + scope: punctuation.definition.quoted.begin.shell + push: expression-double-quoted-body + - match: \' + scope: punctuation.definition.quoted.begin.shell + push: expression-single-quoted-body + - match: \( + scope: punctuation.section.group.begin.shell + push: expression-group-body + - include: expression-common + + expression-double-quoted-body: + - match: \" + scope: punctuation.definition.quoted.end.shell + pop: 1 + - match: \( + scope: punctuation.section.group.begin.shell + push: expression-double-quoted-group-body + - include: expression-common + + expression-double-quoted-group-body: + - meta_scope: meta.group.shell + - match: \) + scope: punctuation.section.group.end.shell + pop: 1 + - match: (?=") + pop: 1 + - include: expression-common + + expression-single-quoted-body: + - match: \' + scope: punctuation.definition.quoted.end.shell + pop: 1 + - match: \( + scope: punctuation.section.group.begin.shell + push: expression-single-quoted-group-body + - include: expression-common + + expression-single-quoted-group-body: + - meta_scope: meta.group.shell + - match: \) + scope: punctuation.section.group.end.shell + pop: 1 + - match: (?=') + pop: 1 + - include: expression-common + + expression-group-body: + - meta_scope: meta.group.shell + - match: \) + scope: punctuation.section.group.end.shell + pop: 1 + - include: expression-common + + expression-common: # multi char operators - match: '[-+*/%&|^]=|<<=|>>=' scope: keyword.operator.assignment.augmented.shell @@ -1707,31 +1751,43 @@ contexts: - match: '&&|\|\||!' scope: keyword.operator.logical.shell # single char operators + - match: '[-+*/%]' + scope: keyword.operator.arithmetic.shell - match: '=' scope: keyword.operator.assignment.shell - match: '[&|^~]' scope: keyword.operator.bitwise.shell - - match: ; - scope: punctuation.terminator.statement.shell - match: \, scope: punctuation.separator.sequence.shell - match: \:|\? scope: keyword.operator.ternary.shell - - include: arithmetic-operators + - include: terminators # Shell variables are allowed as operands; parameter expansion is performed # before the expression is evaluated. Within an expression, shell variables # may also be referenced by name without using the parameter expansion # syntax. - include: booleans - include: numbers - - include: variables + - include: expression-variables + - include: expression-illegals - expression-group-body: - - meta_scope: meta.group.shell - - match: \) - scope: punctuation.section.group.end.shell + expression-illegals: + - match: '{{word_char}}' + scope: invalid.illegal.unexpected-token.shell + + expression-variables: + # variables within arithmetic expressions must not contain quotes + - match: (?=[{{identifier_first_char}}$%]) + push: + - variable-subscription + - expression-variable-chars + + expression-variable-chars: + - meta_scope: variable.other.readwrite.shell + - include: line-continuations + - include: string-interpolations + - match: '{{identifier_break}}' pop: 1 - - include: expressions ###[ OPERATORS ]############################################################### @@ -1749,10 +1805,6 @@ contexts: - match: ^ pop: 1 - arithmetic-operators: - - match: '[-+*/%]' - scope: keyword.operator.arithmetic.shell - operators: - match: \|\||\&\&|\!(?!\S) scope: keyword.operator.logical.shell @@ -2642,7 +2694,7 @@ contexts: - match: \)\) scope: punctuation.section.interpolation.end.shell pop: 1 - - include: expressions + - include: expression-content ###[ BRACE EXPANSIONS ]######################################################## @@ -2918,14 +2970,16 @@ contexts: - include: variable-subscriptions expansion-parameter-substr-start: + - meta_content_scope: meta.arithmetic.shell - match: ':' scope: keyword.operator.substring.end.shell set: expansion-parameter-expression - include: expansion-parameter-expression expansion-parameter-expression: + - meta_content_scope: meta.arithmetic.shell - include: expansion-parameter-end - - include: expressions + - include: expression-content expansion-parameter-pattern: # [3.5.8.1] Pattern Matching in parameter expansions diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index 99cb4dc5e1..1fa81304ad 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -480,24 +480,6 @@ $e'ch'o Hello, world! # ^ - constant # ^ punctuation.definition.quoted.end.shell -# QUOTING VARIABLES IN ARITHMETIC EXPRESSIONS -# note: quotes with whitespace is not supported, but bash parses variables too -# different, depending on context, to find a perfact solution - -(( foo "bar" 'baz' "foo "bar' baz' )) -# ^^^ variable.other.readwrite.shell -# ^^^^^ variable.other.readwrite.shell -# ^ punctuation.definition.quoted.begin.shell -# ^ punctuation.definition.quoted.end.shell -# ^^^^^ variable.other.readwrite.shell -# ^ punctuation.definition.quoted.begin.shell -# ^ punctuation.definition.quoted.end.shell -# ^^^^^^^^^^^^^^^ variable.other.readwrite.shell -# ^ punctuation.definition.quoted.begin.shell -# ^ punctuation.definition.quoted.end.shell -# ^ punctuation.definition.quoted.begin.shell -# ^ punctuation.definition.quoted.end.shell - ############################################################################### # 3.2 Shell Commands (Basic Command Arguments) # @@ -957,9 +939,9 @@ done #<- keyword.control.loop.end.shell for (( i = 0; i < 10; i++ )); do -# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.arithmetic.shell +# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.arithmetic.shell # <- keyword.control.loop.for.shell -# ^^ punctuation.section.arithmetic.begin.shell +# ^^ punctuation.section.compound.begin.shell # ^ keyword.operator.assignment.shell # ^ meta.number.integer.decimal.shell constant.numeric.value.shell - punctuation # ^ punctuation.terminator.statement.shell @@ -967,7 +949,7 @@ for (( i = 0; i < 10; i++ )); do # ^^ meta.number.integer.decimal.shell constant.numeric.value.shell # ^ punctuation.terminator.statement.shell # ^^ keyword.operator.arithmetic.shell -# ^^ punctuation.section.arithmetic.end.shell +# ^^ punctuation.section.compound.end.shell # ^ punctuation.terminator.statement.shell # ^^ keyword.control.loop.do.shell echo $i @@ -978,9 +960,9 @@ done # <- keyword.control.loop.end.shell for (( i = 0; i < 10; i++ )) #; do -# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.arithmetic.shell +# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.arithmetic.shell # <- keyword.control.loop.for.shell -# ^^ punctuation.section.arithmetic.begin.shell +# ^^ punctuation.section.compound.begin.shell # ^ keyword.operator.assignment.shell # ^ meta.number.integer.decimal.shell constant.numeric.value.shell - punctuation # ^ punctuation.terminator.statement.shell @@ -988,7 +970,7 @@ for (( i = 0; i < 10; i++ )) #; do # ^^ meta.number.integer.decimal.shell constant.numeric.value.shell # ^ punctuation.terminator.statement.shell # ^^ keyword.operator.arithmetic.shell -# ^^ punctuation.section.arithmetic.end.shell +# ^^ punctuation.section.compound.end.shell # ^^^^^^ comment.line.number-sign.shell do #<- keyword.control.loop.do.shell @@ -1001,7 +983,7 @@ done for \ (( i = 0; i < 10; i++ )) do echo $i; done; -# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.arithmetic.shell +# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.arithmetic.shell # ^^ keyword.control.loop.do.shell # ^^^^^^^ meta.function-call # ^^^^ support.function.echo.shell @@ -3243,7 +3225,7 @@ foo=`echo -e` foo=`let 5+5` # ^ meta.string.shell meta.interpolation.command.shell # ^^^ meta.string.shell meta.interpolation.command.shell meta.function-call.identifier.shell -# ^^^^ meta.string.shell meta.interpolation.command.shell meta.function-call.arguments.shell +# ^^^^ meta.string.shell meta.interpolation.command.shell meta.function-call.arguments.shell meta.arithmetic.shell # ^ meta.string.shell meta.interpolation.command.shell # ^ punctuation.section.interpolation.begin.shell # ^^^ support.function.let.shell @@ -5388,6 +5370,25 @@ foo} # ^ meta.number.integer.decimal.shell constant.numeric.value.shell # ^ punctuation.section.interpolation.end.shell +: ${var:"pos + 2":'len * 4'} +# ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.substring.begin.shell +# ^ punctuation.definition.quoted.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ keyword.operator.arithmetic.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.definition.quoted.end.shell +# ^ keyword.operator.substring.end.shell +# ^ punctuation.definition.quoted.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ keyword.operator.arithmetic.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.definition.quoted.end.shell +# ^ punctuation.section.interpolation.end.shell + : ${${var}:${pos}:${len}} # ^^ meta.interpolation.parameter.shell - meta.interpolation meta.interpolation # ^^^^^^ meta.interpolation.parameter.shell meta.interpolation.parameter.shell @@ -9238,8 +9239,16 @@ declare -ai bar=(foo b*$r b-20 'b?r' "b*z" [100]=val [100] =val /dev/null +#^^ support.function.let.shell +let - +#^^ support.function.let.shell +let() +#^^ support.function.let.shell +let[] +#^^^^ - storage - keyword.declaration +let{} +#^^^^ - storage - keyword.declaration +let- +#^^^ - storage - keyword.declaration +-let +#^^^ - storage - keyword.declaration +let+ +#^^^ - storage - keyword.declaration +let$ +#^^^ - storage - keyword.declaration +let$var +#^^^^^^ - storage - keyword.declaration +let= +#^^^ - storage - keyword.declaration +let-= +#^^^^ - storage - keyword.declaration +let+= +#^^^^ - storage - keyword.declaration + +let expr 'expr' "expr" +# <- meta.function-call.identifier.shell support.function.let.shell +#^^ meta.function-call.identifier.shell +# ^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.arithmetic.shell +#^^ support.function.let.shell +# ^^^^ variable.other.readwrite.shell +# ^ punctuation.definition.quoted.begin.shell +# ^^^^ variable.other.readwrite.shell +# ^ punctuation.definition.quoted.end.shell +# ^ punctuation.definition.quoted.begin.shell +# ^^^^ variable.other.readwrite.shell +# ^ punctuation.definition.quoted.end.shell + +let 5 \ + + 5 +# <- meta.function-call.arguments.shell meta.arithmetic.shell +#^^^^^^ meta.function-call.arguments.shell meta.arithmetic.shell +# ^ - meta.arithmetic +# ^ keyword.operator.arithmetic.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell + +let 5+5 # comment +#^^ meta.function-call.identifier.shell +# ^^^^ meta.function-call.arguments.shell meta.arithmetic.shell +# ^ - meta.arithmetic +#^^ support.function.let.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ keyword.operator.arithmetic.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell + +let var[10]=5*(20+$idx) +# <- meta.function-call.identifier.shell support.function.let.shell +#^^ meta.function-call.identifier.shell +# ^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.arithmetic.shell +# ^^^ meta.variable.shell variable.other.readwrite.shell +# ^^^^ meta.variable.shell meta.item-access.shell +# ^ punctuation.section.item-access.begin.shell +# ^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.item-access.end.shell +# ^ keyword.operator.assignment.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ keyword.operator.arithmetic.shell +# ^ punctuation.section.group.begin.shell +# ^^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ keyword.operator.arithmetic.shell +# ^^^^ variable.other.readwrite.shell +# ^ punctuation.section.group.end.shell + +let "two=5+5"; if [[ "$X" == "1" ]]; then X="one"; fi +# <- meta.function-call.identifier.shell support.function.let.shell +#^^ meta.function-call.identifier.shell +# ^^^^^^^^^^ meta.function-call.arguments.shell meta.arithmetic.shell +# ^ - meta.function-call - meta.arithmetic +#^^ support.function.let.shell +# ^ punctuation.definition.quoted.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ keyword.operator.assignment.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ keyword.operator.arithmetic.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.definition.quoted.end.shell +# ^ punctuation.terminator.statement.shell +# ^^ keyword.control.conditional.if.shell +# ^^^^^^^^^^^^^^^^^ meta.conditional.shell +# ^ punctuation.terminator.statement.shell +# ^^^^ keyword.control.conditional.then.shell +# ^ variable.other.readwrite.shell +# ^ keyword.operator.assignment.shell +# ^^^^^ string.quoted.double.shell +# ^ punctuation.terminator.statement.shell +# ^^ keyword.control.conditional.end.shell + +let test -z $2 && { } +#^^ meta.function-call.identifier.shell support.function.let.shell +# ^^^^^^^^^^^ meta.function-call.arguments.shell meta.arithmetic.shell +# ^^^^ - meta.arithmetic - meta.compound +# ^^^ meta.compound.shell +#^^ support.function.let.shell +# ^^^^ variable.other.readwrite.shell +# ^ keyword.operator.arithmetic.shell +# ^ variable.other.readwrite.shell +# ^^ variable.language.positional.shell +# ^^ keyword.operator.logical.shell +# ^ punctuation.section.compound.begin.shell +# ^ punctuation.section.compound.end.shell + +let $var == test -z $5 && cmd +#^^ meta.function-call.identifier.shell support.function.let.shell +# ^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.arithmetic.shell +# ^^^^^^^^ - meta.arithmetic +# ^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^^ keyword.operator.comparison.shell +# ^^^^ variable.other.readwrite.shell +# ^ keyword.operator.arithmetic.shell +# ^ variable.other.readwrite.shell +# ^^ variable.language.positional.shell +# ^^ keyword.operator.logical.shell +# ^^^ variable.function.shell + +let 'test -z $2 && { }' +#^^ meta.function-call.identifier.shell support.function.let.shell +# ^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.arithmetic.shell +# ^ punctuation.definition.quoted.begin.shell +# ^^^^ variable.other.readwrite.shell +# ^ keyword.operator.arithmetic.shell +# ^ variable.other.readwrite.shell +# ^^ variable.language.positional.shell +# ^^ keyword.operator.logical.shell +# ^ invalid.illegal.unexpected-token.shell +# ^ invalid.illegal.unexpected-token.shell +# ^ punctuation.definition.quoted.end.shell + + ############################################################################### -# 4.2 Bash Builtin Commands (locsl) # +# 4.2 Bash Builtin Commands (local) # # https://www.gnu.org/software/bash/manual/bash.html#index-local # ############################################################################### @@ -10375,86 +10596,6 @@ if test "$VAR" != ";";then;fi # ^ punctuation.terminator.statement.shell # ^^ keyword.control.conditional.end.shell -let test -z $2 && { } -#^^ meta.function-call.identifier.shell support.function.let.shell -# ^ meta.function-call.arguments.shell - meta.function-call mete.function-call -# ^^^^ meta.function-call.arguments.shell meta.function-call.identifier.shell -# ^^^^^^ meta.function-call.arguments.shell meta.function-call.arguments.shell -# ^^^^ - meta.function-call - meta.compound -# ^^^ meta.compound.shell - meta.function-call -# ^^^^ support.function.test.shell -# ^^ meta.parameter.option.shell variable.parameter.option.shell -# ^^ meta.interpolation.parameter.shell variable.language.positional.shell -# ^^ keyword.operator.logical.shell -# ^ punctuation.section.compound.begin.shell -# ^ punctuation.section.compound.end.shell - -let $var == test -z $5 && cmd -#^^ meta.function-call.identifier.shell support.function.let.shell -# ^^^^^^^^^ meta.function-call.arguments.shell - meta.function-call mete.function-call -# ^^^^ meta.function-call.arguments.shell meta.function-call.identifier.shell -# ^^^^^^ meta.function-call.arguments.shell meta.function-call.arguments.shell -# ^^^^ - meta.function-call -# ^^^ meta.function-call.identifier.shell -# ^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell -# ^^ keyword.operator.comparison.shell -# ^^^^ support.function.test.shell -# ^^ meta.parameter.option.shell variable.parameter.option.shell -# ^^ meta.interpolation.parameter.shell variable.language.positional.shell -# ^^ keyword.operator.logical.shell -# ^^^ variable.function.shell - -let 'test -z $2 && { }' -#^^ meta.function-call.identifier.shell support.function.let.shell -# ^^ meta.function-call.arguments.shell - meta.function-call mete.function-call -# ^^^^ meta.function-call.arguments.shell meta.function-call.identifier.shell -# ^^^^^^ meta.function-call.arguments.shell meta.function-call.arguments.shell -# ^^^^^^^^ meta.function-call.arguments.shell - meta.function-call mete.function-call -# ^^^ - meta.compound -# ^ - meta.function-call -# ^ string.quoted.single.shell punctuation.definition.string.begin.shell -# ^^^^ support.function.test.shell -# ^^ meta.parameter.option.shell variable.parameter.option.shell -# ^^ meta.interpolation.parameter.shell variable.language.positional.shell -# ^^ keyword.operator.logical.shell -# ^ string.quoted.single.shell punctuation.definition.string.end.shell - -let '$var == test -z \'$5\' && cmd' -#^^ meta.function-call.identifier.shell support.function.let.shell -# ^^^^^^^^^^^ meta.function-call.arguments.shell - meta.function-call mete.function-call -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell -# ^^^^ meta.function-call.arguments.shell meta.function-call.identifier.shell -# ^^^^^^^^^^ meta.function-call.arguments.shell meta.function-call.arguments.shell -# ^^^^^^^^ meta.function-call.arguments.shell - meta.function-call mete.function-call -# ^ string.quoted.single.shell punctuation.definition.string.begin.shell -# ^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell -# ^^ keyword.operator.comparison.shell -# ^^^^ support.function.test.shell -# ^^ meta.parameter.option.shell variable.parameter.option.shell -# ^^ constant.character.escape.shell -# ^^ meta.interpolation.parameter.shell variable.language.positional.shell -# ^^ constant.character.escape.shell -# ^^ keyword.operator.logical.shell -# ^^^ - variable.function -# ^ string.quoted.single.shell punctuation.definition.string.end.shell - -let "$var != test -z '$5' && cmd" -#^^ meta.function-call.identifier.shell support.function.let.shell -# ^^^^^^^^^^^ meta.function-call.arguments.shell - meta.function-call mete.function-call -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell -# ^^^^ meta.function-call.arguments.shell meta.function-call.identifier.shell -# ^^^^^^^^ meta.function-call.arguments.shell meta.function-call.arguments.shell -# ^^^^^^^^ meta.function-call.arguments.shell - meta.function-call mete.function-call -# ^ string.quoted.double.shell punctuation.definition.string.begin.shell -# ^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell -# ^^ keyword.operator.comparison.shell -# ^^^^ support.function.test.shell -# ^^ meta.parameter.option.shell variable.parameter.option.shell -# ^^^^ meta.string.shell string.quoted.single.shell - variable -# ^^ keyword.operator.logical.shell -# ^^^ - variable.function -# ^ string.quoted.double.shell punctuation.definition.string.end.shell - ############################################################################### # 4.2 Bash Builtin Commands (unalias) # @@ -11315,7 +11456,7 @@ true false # ^ - meta.number - constant (( 0 1 2 3 4 5 6 7 8 9)) -#^^^^^^^^^^^^^^^^^^^^^^^ meta.arithmetic.shell +#^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.arithmetic.shell # ^ - meta.number - constant # ^ meta.number.integer.decimal.shell constant.numeric.value.shell # ^ - meta.number - constant @@ -11339,7 +11480,7 @@ true false # ^ - meta.number - constant (( -0 -1 -2 -3 -4 -5 -6 -7 -8 -9)) -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.arithmetic.shell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.arithmetic.shell # ^^ - meta.number - constant # ^ meta.number.integer.decimal.shell constant.numeric.value.shell # ^^ - meta.number - constant @@ -11363,7 +11504,7 @@ true false # ^ - meta.number - constant (( 012345670802 )) -#^^^^^^^^^^^^^^^^^ meta.arithmetic.shell +#^^^^^^^^^^^^^^^^^ meta.compound.arithmetic.shell # ^ meta.number.integer.octal.shell constant.numeric.base.shell # ^^^^^^^^ meta.number.integer.octal.shell constant.numeric.value.shell # ^^^ meta.number.integer.octal.shell invalid.illegal.shell @@ -11396,27 +11537,69 @@ true false # https://www.gnu.org/software/bash/manual/bash.html#Shell-Arithmetic # ############################################################################### +# QUOTING ARITHMETIC EXPRESSIONS +# arithmetic expressions can be unquoted or quoted words, variables within however are not. + +(( foo "bar" 'baz' "foo "bar' baz' )) +# ^^^ variable.other.readwrite.shell +# ^ punctuation.definition.quoted.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ punctuation.definition.quoted.end.shell +# ^ punctuation.definition.quoted.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ punctuation.definition.quoted.end.shell +# ^ punctuation.definition.quoted.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ punctuation.definition.quoted.end.shell +# ^^^ variable.other.readwrite.shell +# ^ punctuation.definition.quoted.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ punctuation.definition.quoted.end.shell + (( a=b, a*=b, a/=b, a%=b, a+=b, a-=b, a<<=b, a>>=b, a&=b, a^=b, a|=b )) # ^ variable.other.readwrite.shell # ^ keyword.operator.assignment.shell # ^ variable.other.readwrite.shell -# ^ meta.arithmetic punctuation.separator +# ^ punctuation.separator.sequence.shell # ^ variable.other.readwrite.shell # ^^ keyword.operator.assignment.augmented.shell # ^ variable.other.readwrite.shell -# ^ meta.arithmetic punctuation.separator +# ^ punctuation.separator.sequence.shell +# ^ variable.other.readwrite.shell # ^^ keyword.operator.assignment.augmented.shell -# ^ meta.arithmetic +# ^ variable.other.readwrite.shell +# ^ punctuation.separator.sequence.shell +# ^ variable.other.readwrite.shell # ^^ keyword.operator.assignment.augmented.shell -# ^ meta.arithmetic +# ^ variable.other.readwrite.shell +# ^ punctuation.separator.sequence.shell +# ^ variable.other.readwrite.shell # ^^ keyword.operator.assignment.augmented.shell -# ^ meta.arithmetic punctuation.separator +# ^ variable.other.readwrite.shell +# ^ punctuation.separator.sequence.shell +# ^ variable.other.readwrite.shell # ^^ keyword.operator.assignment.augmented.shell +# ^ variable.other.readwrite.shell +# ^ punctuation.separator.sequence.shell +# ^ variable.other.readwrite.shell # ^^^ keyword.operator.assignment.augmented.shell +# ^ variable.other.readwrite.shell +# ^ punctuation.separator.sequence.shell +# ^ variable.other.readwrite.shell # ^^^ keyword.operator.assignment.augmented.shell +# ^ variable.other.readwrite.shell +# ^ punctuation.separator.sequence.shell +# ^ variable.other.readwrite.shell # ^^ keyword.operator.assignment.augmented.shell +# ^ variable.other.readwrite.shell +# ^ punctuation.separator.sequence.shell +# ^ variable.other.readwrite.shell # ^^ keyword.operator.assignment.augmented.shell +# ^ variable.other.readwrite.shell +# ^ punctuation.separator.sequence.shell +# ^ variable.other.readwrite.shell # ^^ keyword.operator.assignment.augmented.shell +# ^ variable.other.readwrite.shell (( a++ a ++ )) # ^^ keyword.operator.arithmetic.shell # ^^ keyword.operator.arithmetic.shell @@ -11494,15 +11677,15 @@ true false # ^ keyword.operator.ternary.shell # ^ keyword.operator.ternary.shell (((a>b) ? (a>c?a:c) : (b>c?b:c))) -# <- meta.arithmetic.shell punctuation.section.arithmetic.begin.shell - meta.group -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.arithmetic.shell +# <- meta.compound.arithmetic.shell punctuation.section.compound.begin.shell - meta.group +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.arithmetic.shell # ^^^^^ meta.group.shell # ^^^ - meta.group.shell # ^^^^^^^^^ meta.group.shell # ^^^ - meta.group.shell # ^^^^^^^^^ meta.group.shell # ^^ - meta.group.shell -#^ punctuation.section.arithmetic.begin.shell +#^ punctuation.section.compound.begin.shell # ^ punctuation.section.group.begin.shell # ^ keyword.operator.comparison.shell # ^ punctuation.section.group.end.shell @@ -11518,66 +11701,11 @@ true false # ^ keyword.operator.ternary.shell # ^ keyword.operator.ternary.shell # ^ punctuation.section.group.end.shell -# ^^ punctuation.section.arithmetic.end.shell +# ^^ punctuation.section.compound.end.shell ((a+=b)) # ^ - string.unquoted -let 5 \ - + 5 -#^^^^^^ meta.function-call.arguments.shell -# ^ - meta.function-call -# ^ keyword.operator.arithmetic.shell -# ^ meta.number.integer.decimal.shell constant.numeric.value.shell - -let 5+5 # comment -#^^ meta.function-call.identifier.shell -# ^^^^ meta.function-call.arguments.shell -# ^ - meta.function-call -#^^ support.function.let.shell -# ^ meta.number.integer.decimal.shell constant.numeric.value.shell -# ^ keyword.operator.arithmetic.shell -# ^ meta.number.integer.decimal.shell constant.numeric.value.shell - -let var[10]=5*(20+$idx) -#^^ meta.function-call.identifier.shell support.function.let.shell -# ^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell -# ^^^^ meta.item-access.shell -# ^ punctuation.section.item-access.begin.shell -# ^^ meta.string.shell string.unquoted.shell -# ^ punctuation.section.item-access.end.shell -# ^ keyword.operator.assignment.shell -# ^ meta.number.integer.decimal.shell constant.numeric.value.shell -# ^ keyword.operator.arithmetic.shell -# ^ punctuation.section.group.begin.shell -# ^^ meta.number.integer.decimal.shell constant.numeric.value.shell -# ^ keyword.operator.arithmetic.shell -# ^^^^ variable.other.readwrite.shell -# ^ punctuation.section.group.end.shell - -let "two=5+5"; if [[ "$X" == "1" ]]; then X="one"; fi -#^^ meta.function-call.identifier.shell -# ^^^^^^^^^^ meta.function-call.arguments.shell -# ^ - meta.function-call -#^^ support.function.let.shell -# ^ meta.string.shell string.quoted.double.shell punctuation.definition.string.begin.shell -# ^^^^^^^ meta.string.shell meta.interpolation.shell - string -# ^ keyword.operator.assignment.shell -# ^ meta.number.integer.decimal.shell constant.numeric.value.shell -# ^ keyword.operator.arithmetic.shell -# ^ meta.number.integer.decimal.shell constant.numeric.value.shell -# ^ meta.string.shell string.quoted.double.shell punctuation.definition.string.end.shell -# ^ punctuation.terminator.statement.shell -# ^^ keyword.control.conditional.if.shell -# ^^^^^^^^^^^^^^^^^ meta.conditional.shell -# ^ punctuation.terminator.statement.shell -# ^^^^ keyword.control.conditional.then.shell -# ^ variable.other.readwrite.shell -# ^ keyword.operator.assignment.shell -# ^^^^^ string.quoted.double.shell -# ^ punctuation.terminator.statement.shell -# ^^ keyword.control.conditional.end.shell - ############################################################################### # 7.1 Job Control Basics # From 416660c3fa79227acec8a364628aeb42e3e21494 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Thu, 1 Aug 2024 20:10:57 +0200 Subject: [PATCH 039/113] [ShellScript] Refactor conditional compound commands This commit... 1. applies `meta.compound.conditional` to `[ .. ]` and `[[ .. ]]` expressions 2. scopes brackets `punctuation.section.compound`. --- ShellScript/Bash.sublime-syntax | 16 +- ShellScript/test/syntax_test_bash.sh | 718 +++++++++++++-------------- 2 files changed, 366 insertions(+), 368 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index cc95c0a25b..7a25f37674 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -896,22 +896,20 @@ contexts: cmd-test: - match: \[\[(?=\s) - scope: support.function.test.begin.shell + scope: punctuation.section.compound.begin.shell push: compound-test-body - match: \[(?=\s) - scope: support.function.test.begin.shell + scope: punctuation.section.compound.begin.shell push: builtin-test-body - match: test{{cmd_break}} - scope: - meta.function-call.identifier.shell - support.function.test.shell + scope: meta.function-call.identifier.shell support.function.test.shell push: cmd-test-args builtin-test-body: - - meta_scope: meta.conditional.shell + - meta_scope: meta.compound.conditional.shell - match: '{{wspace}}(\])' captures: - 1: support.function.test.end.shell + 1: punctuation.section.compound.end.shell pop: 1 - include: cmd-test-args @@ -927,10 +925,10 @@ contexts: - include: test-expression-common compound-test-body: - - meta_scope: meta.conditional.shell + - meta_scope: meta.compound.conditional.shell - match: '{{wspace}}(\]\])' captures: - 1: support.function.test.end.shell + 1: punctuation.section.compound.end.shell pop: 1 - match: \( scope: punctuation.section.group.begin.shell diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index 1fa81304ad..12b0c3ae3e 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -75,11 +75,11 @@ bar ` # important; this and that ` "${USELESS_TEXT}" | ` # match text` \ # https://github.com/sublimehq/Packages/issues/3661 [[ # ' ]] -# <- meta.conditional.shell - comment -#^^ meta.conditional.shell - comment -# ^^^^^^^ meta.conditional.shell comment.line.number-sign.shell +# <- meta.compound.conditional.shell - comment +#^^ meta.compound.conditional.shell - comment +# ^^^^^^^ meta.compound.conditional.shell comment.line.number-sign.shell ]] -# <- meta.conditional.shell support.function.test.end.shell +# <- meta.compound.conditional.shell punctuation.section.compound.end.shell [[ # ' @@ -1269,9 +1269,9 @@ do echo bar; until ! { [[ true ]]; } # ^^^^^ keyword.control.loop.until.shell # ^ keyword.operator.logical.shell # ^ punctuation.section.compound.begin.shell -# ^^ support.function.test.begin.shell +# ^^ punctuation.section.compound.begin.shell # ^^^^ constant.language.boolean.true.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell # ^ punctuation.terminator.statement.shell # ^ punctuation.section.compound.end.shell @@ -1337,9 +1337,9 @@ while ! { [[ true ]]; }; do echo bar; done # <- keyword.control.loop.while.shell # ^ keyword.operator.logical.shell # ^ punctuation.section.compound.begin.shell -# ^^ support.function.test.begin.shell +# ^^ punctuation.section.compound.begin.shell # ^^^^ constant.language.boolean.true.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell # ^ punctuation.terminator.statement.shell # ^ punctuation.section.compound.end.shell # ^ punctuation.terminator.statement.shell @@ -1350,9 +1350,9 @@ while ! ( [[ true ]] ); do echo bar; done # <- keyword.control.loop.while.shell # ^ keyword.operator.logical.shell # ^ punctuation.section.compound.begin.shell -# ^^ support.function.test.begin.shell +# ^^ punctuation.section.compound.begin.shell # ^^^^ constant.language.boolean.true.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell # ^ punctuation.section.compound.end.shell # ^ punctuation.terminator.statement.shell # ^^ keyword.control.loop.do.shell @@ -1508,57 +1508,57 @@ if !cmd #^^ variable.language.history.shell [[ ]] -# <- support.function.test.begin.shell -#^ support.function.test.begin.shell -# ^^ support.function.test.end.shell +# <- punctuation.section.compound.begin.shell +#^ punctuation.section.compound.begin.shell +# ^^ punctuation.section.compound.end.shell [[ ]] -# <- meta.conditional.shell support.function.test.end.shell -#^ meta.conditional.shell support.function.test.end.shell +# <- meta.compound.conditional.shell punctuation.section.compound.end.shell +#^ meta.compound.conditional.shell punctuation.section.compound.end.shell ! [[ ]] # <- keyword.operator.logical.shell -# ^^ support.function.test.begin.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.begin.shell +# ^^ punctuation.section.compound.end.shell ![[ ]] # <- punctuation.definition.history.shell -#^^^^^ meta.conditional.shell -#^^ support.function.test.begin.shell -# ^^ support.function.test.end.shell +#^^^^^ meta.compound.conditional.shell +#^^ punctuation.section.compound.begin.shell +# ^^ punctuation.section.compound.end.shell [[ ! ($line == ^0[1-9]$) ]] -# <- meta.conditional.shell - meta.group -#^^^^ meta.conditional.shell - meta.group -# ^^^^^^^^^^ meta.conditional.shell meta.group.shell - meta.string.regexp -# ^^^^^^^^ meta.conditional.shell meta.group.shell meta.string.regexp.shell -# ^ meta.conditional.shell meta.group.shell - meta.string -# ^^^ meta.conditional.shell - meta.group +# <- meta.compound.conditional.shell - meta.group +#^^^^ meta.compound.conditional.shell - meta.group +# ^^^^^^^^^^ meta.compound.conditional.shell meta.group.shell - meta.string.regexp +# ^^^^^^^^ meta.compound.conditional.shell meta.group.shell meta.string.regexp.shell +# ^ meta.compound.conditional.shell meta.group.shell - meta.string +# ^^^ meta.compound.conditional.shell - meta.group # [[ ! ($line != \() ]] -# <- meta.conditional.shell - meta.group -#^^^^ meta.conditional.shell - meta.group -# ^^^^^^^^^^ meta.conditional.shell meta.group.shell - meta.string.regexp -# ^^ meta.conditional.shell meta.group.shell meta.string.regexp.shell constant.character.escape.shell -# ^ meta.conditional.shell meta.group.shell - meta.string -# ^^^ meta.conditional.shell - meta.group +# <- meta.compound.conditional.shell - meta.group +#^^^^ meta.compound.conditional.shell - meta.group +# ^^^^^^^^^^ meta.compound.conditional.shell meta.group.shell - meta.string.regexp +# ^^ meta.compound.conditional.shell meta.group.shell meta.string.regexp.shell constant.character.escape.shell +# ^ meta.compound.conditional.shell meta.group.shell - meta.string +# ^^^ meta.compound.conditional.shell - meta.group # [[ '-e' == -e ]] # -e undergoes pattern matching on the right # ^^^^ meta.string.shell string.quoted.single.shell # ^^ keyword.operator.comparison.shell -# ^^ meta.conditional.shell meta.string.regexp.shell string.unquoted.shell - variable +# ^^ meta.compound.conditional.shell meta.string.regexp.shell string.unquoted.shell - variable [[ -e == -e ]] # a syntax error in bash but allowed in zsh # ^^ meta.string.shell string.unquoted.shell - variable # ^^ keyword.operator.comparison.shell -# ^^ meta.conditional.shell meta.string.regexp.shell string.unquoted.shell - variable +# ^^ meta.compound.conditional.shell meta.string.regexp.shell string.unquoted.shell - variable [[ $foo == 'bar' || $foo == "baz" && $bar == baz ]] -# <- meta.conditional.shell support.function.test.begin.shell -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell # ^^^^ variable.other.readwrite.shell # ^^ keyword.operator.comparison.shell # ^^^^^ meta.string.regexp.shell @@ -1570,13 +1570,13 @@ if !cmd # ^^^^ variable.other.readwrite.shell # ^^ keyword.operator.comparison.shell # ^^^ meta.string.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ ( $foo == 'bar' || $foo == "baz" ) && $bar == baz ]] -# <- meta.conditional.shell support.function.test.begin.shell -#^^ meta.conditional.shell - meta.group -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell meta.group.shell -# ^^^^^^^^^^^^^^^^^^ meta.conditional.shell - meta.group +# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell +#^^ meta.compound.conditional.shell - meta.group +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell meta.group.shell +# ^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell - meta.group # ^ punctuation.section.group.begin.shell # ^^^^ variable.other.readwrite.shell # ^^ keyword.operator.comparison.shell @@ -1590,56 +1590,56 @@ if !cmd # ^^^^ variable.other.readwrite.shell # ^^ keyword.operator.comparison.shell # ^^^ meta.string.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell if [[ expr ]] && [[ expr ]] || [[ expr ]] ; then cmd ; fi -# ^^^^^^^^^^ meta.conditional.shell -# ^^ support.function.test.begin.shell -# ^^ support.function.test.end.shell +# ^^^^^^^^^^ meta.compound.conditional.shell +# ^^ punctuation.section.compound.begin.shell +# ^^ punctuation.section.compound.end.shell # ^^ keyword.operator.logical.shell -# ^^^^^^^^^^ meta.conditional.shell -# ^^ support.function.test.begin.shell -# ^^ support.function.test.end.shell +# ^^^^^^^^^^ meta.compound.conditional.shell +# ^^ punctuation.section.compound.begin.shell +# ^^ punctuation.section.compound.end.shell # ^^ keyword.operator.logical.shell -# ^^^^^^^^^^ meta.conditional.shell -# ^^ support.function.test.begin.shell -# ^^ support.function.test.end.shell +# ^^^^^^^^^^ meta.compound.conditional.shell +# ^^ punctuation.section.compound.begin.shell +# ^^ punctuation.section.compound.end.shell # ^ punctuation.terminator.statement.shell if [[ expr && expr || expr ]] ; then cmd ; fi -# ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell -# ^^ support.function.test.begin.shell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell +# ^^ punctuation.section.compound.begin.shell # ^^ keyword.operator.logical.shell # ^^ keyword.operator.logical.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell # ^ punctuation.terminator.statement.shell if [[ expr && ( expr || expr ) ]] ; then cmd ; fi -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell # ^^^^^^^^^^^^^^^^ meta.group.shell -# ^^ support.function.test.begin.shell +# ^^ punctuation.section.compound.begin.shell # ^^ keyword.operator.logical.shell # ^ punctuation.section.group.begin.shell # ^^ keyword.operator.logical.shell # ^ punctuation.section.group.end.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell # ^ punctuation.terminator.statement.shell if [[ $- =~ *i* ]] ; then echo shell is not interactive; fi #^ keyword.control.conditional.if.shell -# ^^^^^^^^^^^^^^^ meta.conditional.shell +# ^^^^^^^^^^^^^^^ meta.compound.conditional.shell # ^^^^^^^^^ - meta.string.regexp # ^^^ meta.string.regexp.shell # ^^^ - meta.string.regexp # ^^^^ meta.function-call.identifier.shell # ^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell -# ^^ support.function.test.begin.shell +# ^^ punctuation.section.compound.begin.shell # ^^ meta.interpolation.parameter.shell variable.language.special.shell # ^ punctuation.definition.variable.shell # ^^ keyword.operator.comparison.shell # ^ invalid.illegal.unexpected-quantifier.regexp.shell # ^ keyword.operator.quantifier.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell # ^ punctuation.terminator.statement.shell # ^^^^ keyword.control.conditional.then.shell # ^^^^ support.function.echo.shell @@ -1648,7 +1648,7 @@ if [[ $- =~ *i* ]] ; then echo shell is not interactive; fi if [[ "$ERL_TOP" != ";"; ]];then;fi #^ keyword.control.conditional.if.shell -# ^^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +# ^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell # ^^^^^^^^^^^^^^^^^ - meta.string.regexp # ^^^ meta.string.regexp.shell # ^ invalid.illegal.unexpected-token.shell - meta.string @@ -1708,13 +1708,13 @@ if ( [[ ! -z "$PLATFORM" ]] && ! cmd || ! cmd2 ); then PLATFORM=docker; fi # ^ meta.string string.unquoted.shell if [ ! -f q4m-$Q4MVER.tar.gz ]; then -# ^ support.function.test.begin.shell +# ^ punctuation.section.compound.begin.shell # ^ keyword.operator.logical.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell # ^ punctuation.definition.parameter.shell # ^ - keyword.operator # ^^^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell -# ^ support.function.test.end.shell +# ^ punctuation.section.compound.end.shell # ^ punctuation.terminator.statement.shell # ^^^^ keyword.control.conditional.then.shell : @@ -1742,16 +1742,16 @@ if (ruby extconf.rb && fi if [ "$1" != "" -a "$2" != "" ]; then -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell #^ keyword.control.conditional.if.shell # <- keyword.control.conditional.if.shell -# ^ support.function.test.begin.shell +# ^ punctuation.section.compound.begin.shell # ^^ variable.language.positional.shell # ^^ keyword.operator.comparison.shell -# ^^ meta.conditional.shell variable.parameter.option.shell +# ^^ meta.compound.conditional.shell variable.parameter.option.shell # ^^ variable.language.positional.shell # ^^ keyword.operator.comparison.shell -# ^ support.function.test.end.shell +# ^ punctuation.section.compound.end.shell # ^ punctuation.terminator.statement.shell # ^^^^ keyword.control.conditional.then.shell local DIR=$1 @@ -1766,7 +1766,7 @@ if [ "$1" != "" -a "$2" != "" ]; then # ^^ variable.language.positional.shell elif [ "$1" ]; then # <- keyword.control.conditional.elseif.shell -# ^^^^^^^^ meta.conditional.shell +# ^^^^^^^^ meta.compound.conditional.shell # ^ punctuation.terminator.statement.shell # ^^^^ keyword.control.conditional.then.shell local DIR=$PWD @@ -2344,11 +2344,11 @@ coproc foobar { # ^ punctuation.section.parameters.end.shell # ^ - punctuation # ^ punctuation.section.block.begin.shell -# ^^ support.function.test.begin +# ^^ punctuation.section.compound.begin # ^ punctuation.definition.variable # ^ variable.language # ^^ keyword.operator.comparison -# ^^ support.function.test.end +# ^^ punctuation.section.compound.end # ^^ keyword.operator.logical # ^ punctuation.section.block.end.shell # ^^^^ meta.string.shell string.unquoted.shell @@ -2470,11 +2470,11 @@ function () ; {} arg # ^ punctuation.section.parameters.end.shell # ^ - punctuation # ^ punctuation.section.block.begin.shell -# ^^ support.function.test.begin.shell +# ^^ punctuation.section.compound.begin.shell # ^ punctuation.definition.variable.shell # ^^ variable.language.special.shell # ^^ keyword.operator.comparison.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell # ^^ keyword.operator.logical.shell logExit ( ) { @@ -2491,22 +2491,22 @@ logExit ( ) { # ^ punctuation.section.parameters.end.shell # ^ punctuation.section.block.begin.shell [[ $1 == '0' ]] && tput setaf 2 || tput setaf 1; - #<- meta.conditional.shell support.function.test.begin.shell - #^ meta.conditional.shell support.function.test.begin.shell - # ^^ meta.conditional.shell support.function.test.end.shell + #<- meta.compound.conditional.shell punctuation.section.compound.begin.shell + #^ meta.compound.conditional.shell punctuation.section.compound.begin.shell + # ^^ meta.compound.conditional.shell punctuation.section.compound.end.shell [[ $1 == '0' ]] && echo -e "$2 PASSED" || echo -e "$2 FAILED"; - #<- meta.conditional.shell support.function.test.begin.shell - #^ meta.conditional.shell support.function.test.begin.shell - # ^^ meta.conditional.shell support.function.test.end.shell + #<- meta.compound.conditional.shell punctuation.section.compound.begin.shell + #^ meta.compound.conditional.shell punctuation.section.compound.begin.shell + # ^^ meta.compound.conditional.shell punctuation.section.compound.end.shell # ^^ keyword.operator.logical.shell # ^^^^ meta.function-call.identifier.shell support.function.echo.shell tput setaf 15; # <- meta.function meta.function-call variable.function # ^ meta.function punctuation.terminator.statement [[ $1 == '0' ]] || exit -1 - #<- meta.conditional.shell support.function.test.begin.shell - #^ meta.conditional.shell support.function.test.begin.shell - # ^^ meta.conditional.shell support.function.test.end.shell + #<- meta.compound.conditional.shell punctuation.section.compound.begin.shell + #^ meta.compound.conditional.shell punctuation.section.compound.begin.shell + # ^^ meta.compound.conditional.shell punctuation.section.compound.end.shell # ^^ keyword.operator.logical.shell # ^^^^ keyword.control.flow.exit.shell # ^ keyword.operator.arithmetic.shell @@ -7620,12 +7620,12 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^ constant.other.wildcard.questionmark.shell [[ abc == ^abc|bca$ ]] -#^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell # ^^^^^^^^^ meta.string.regexp.shell - keyword -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ a\$b*c == a'$b*'? ]] -#^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell # ^^^^^^^ meta.string.regexp.shell # ^ punctuation.definition.string.begin.shell # ^^^ - constant - keyword - variable @@ -7633,7 +7633,7 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^ constant.other.wildcard.questionmark.shell [[ a"$bc*"c == *"$bc*"c ]] -#^^^^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell # ^^^^^^^^ meta.string.regexp.shell # ^ constant.other.wildcard.asterisk.shell # ^ punctuation.definition.string.begin.shell @@ -7642,7 +7642,7 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^ punctuation.definition.string.end.shell [[ $foo == !(foo|bar|???|*|'?'|'*') ]] -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell # ^ meta.string.regexp.shell # ^^^^^^^^^^^^^^^^^^^^^^^ meta.string.regexp.shell meta.group.regexp.shell # ^ keyword.operator.quantifier.regexp.shell @@ -7659,29 +7659,29 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^ punctuation.definition.string.begin.shell # ^ punctuation.definition.string.end.shell # ^ punctuation.definition.group.end.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ ( $foo == * -#^^ meta.conditional.shell - meta.group -# ^^^^^^^^^^ meta.conditional.shell meta.group.shell - meta.string.regexp -# ^ meta.conditional.shell meta.group.shell meta.string.regexp.shell -# ^ meta.conditional.shell meta.group.shell - meta.string.regexp invalid.illegal.unexpected-token.shell +#^^ meta.compound.conditional.shell - meta.group +# ^^^^^^^^^^ meta.compound.conditional.shell meta.group.shell - meta.string.regexp +# ^ meta.compound.conditional.shell meta.group.shell meta.string.regexp.shell +# ^ meta.compound.conditional.shell meta.group.shell - meta.string.regexp invalid.illegal.unexpected-token.shell [[ ( $foo == *\ [^0-9]? ) ]] # note: line continuation is only valid without leading whitespace, but we ignore it -# <- meta.conditional.shell meta.group.shell meta.string.regexp.shell -#^^ meta.conditional.shell meta.group.shell meta.string.regexp.shell - meta.set -# ^^^^^^ meta.conditional.shell meta.group.shell meta.string.regexp.shell meta.set.regexp.shell -# ^ meta.conditional.shell meta.group.shell meta.string.regexp.shell - meta.set -# ^^ meta.conditional.shell meta.group.shell - meta.string.regexp -# ^^^ meta.conditional.shell - meta.group -# ^^ support.function.test.end.shell +# <- meta.compound.conditional.shell meta.group.shell meta.string.regexp.shell +#^^ meta.compound.conditional.shell meta.group.shell meta.string.regexp.shell - meta.set +# ^^^^^^ meta.compound.conditional.shell meta.group.shell meta.string.regexp.shell meta.set.regexp.shell +# ^ meta.compound.conditional.shell meta.group.shell meta.string.regexp.shell - meta.set +# ^^ meta.compound.conditional.shell meta.group.shell - meta.string.regexp +# ^^^ meta.compound.conditional.shell - meta.group +# ^^ punctuation.section.compound.end.shell [[ ( $foo == ? ]] -#^^ meta.conditional.shell - meta.group -# ^^^^^^^^^^ meta.conditional.shell meta.group.shell - meta.string.regexp -# ^ meta.conditional.shell meta.group.shell meta.string.regexp.shell -# ^^^ meta.conditional.shell meta.group.shell - meta.string.regexp +#^^ meta.compound.conditional.shell - meta.group +# ^^^^^^^^^^ meta.compound.conditional.shell meta.group.shell - meta.string.regexp +# ^ meta.compound.conditional.shell meta.group.shell meta.string.regexp.shell +# ^^^ meta.compound.conditional.shell meta.group.shell - meta.string.regexp # ^^ invalid.illegal.unexpected-token.shell [[ ( $foo == ? ]] @@ -7690,17 +7690,17 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} #^^^^^^^^^^^^^^ - meta.conditional [[ $foo == +( ]] -#^^^^^^^^^^ meta.conditional.shell - meta.string.regexp - meta.group -# ^ meta.conditional.shell meta.string.regexp.shell - meta.group -# ^^^^^ meta.conditional.shell meta.string.regexp.shell meta.group.regexp.shell +#^^^^^^^^^^ meta.compound.conditional.shell - meta.string.regexp - meta.group +# ^ meta.compound.conditional.shell meta.string.regexp.shell - meta.group +# ^^^^^ meta.compound.conditional.shell meta.string.regexp.shell meta.group.regexp.shell # ^ keyword.operator.quantifier.regexp.shell # ^ punctuation.definition.group.begin.regexp.shell # ^^ - punctuation [!0-9]+ ) ]] -# <- meta.conditional.shell meta.string.regexp.shell meta.group.regexp.shell -#^^ meta.conditional.shell meta.string.regexp.shell meta.group.regexp.shell - meta.set -# ^^^^^^ meta.conditional.shell meta.string.regexp.shell meta.group.regexp.shell meta.set.regexp.shell -# ^^^ meta.conditional.shell meta.string.regexp.shell meta.group.regexp.shell - meta.set +# <- meta.compound.conditional.shell meta.string.regexp.shell meta.group.regexp.shell +#^^ meta.compound.conditional.shell meta.string.regexp.shell meta.group.regexp.shell - meta.set +# ^^^^^^ meta.compound.conditional.shell meta.string.regexp.shell meta.group.regexp.shell meta.set.regexp.shell +# ^^^ meta.compound.conditional.shell meta.string.regexp.shell meta.group.regexp.shell - meta.set # ^^^ - meta.string.regexp # ^ punctuation.definition.set.begin.regexp.shell # ^ keyword.operator.logical.regexp.shell @@ -7708,7 +7708,7 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^ punctuation.definition.set.end.regexp.shell # ^ - constant - keyword # ^ punctuation.definition.group.end.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell ############################################################################### @@ -7718,28 +7718,28 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} ############################################################################### [[ a =~ [ ]] -#^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^ meta.string.regexp.shell - meta.set # ^^^ - meta.string.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ a =~ ] ]] -#^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^ meta.string.regexp.shell - meta.set # ^^^ - meta.string.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ a =~ [[] ]] -#^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^^^ meta.string.regexp.shell meta.set.regexp.shell # ^^^ - meta.string.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ a =~ [^[] ]] -#^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^^^^ meta.string.regexp.shell meta.set.regexp.shell # ^^^ - meta.string.regexp.shell @@ -7747,58 +7747,58 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^ keyword.operator.logical.regexp.shell # ^ - punctuation # ^ punctuation.definition.set.end.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ a =~ [![] ]] # ! is not an operator in ERE -#^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^^^^ meta.string.regexp.shell meta.set.regexp.shell # ^^^ - meta.string.regexp.shell # ^ punctuation.definition.set.begin.regexp.shell # ^^ - keyword - punctuation # ^ punctuation.definition.set.end.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ a =~ [\[] ]] -#^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^^^^ meta.string.regexp.shell meta.set.regexp.shell # ^^^ - meta.string.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ a =~ [^\[] ]] -#^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^^^^^ meta.string.regexp.shell meta.set.regexp.shell # ^^^ - meta.string.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ a =~ []] ]] -#^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^^^ meta.string.regexp.shell meta.set.regexp.shell # ^^^ - meta.string.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ a =~ []-[] ]] -#^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^^^^^ meta.string.regexp.shell meta.set.regexp.shell # ^^^ - meta.string.regexp.shell # ^ punctuation.definition.set.begin.regexp.shell # ^^^ constant.other.range.regexp.shell # ^ punctuation.definition.set.end.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ a =~ [^]] ]] -#^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^^^^ meta.string.regexp.shell meta.set.regexp.shell # ^^^ - meta.string.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ a =~ [!]] ]] # ! is not an operator in ERE -#^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^^^ meta.string.regexp.shell meta.set.regexp.shell # ^ meta.string.regexp.shell - meta.set @@ -7807,53 +7807,53 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^ - keyword - punctuation # ^ punctuation.definition.set.end.regexp.shell # ^ - punctuation -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ a =~ [\]] ]] -#^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^^^^ meta.string.regexp.shell meta.set.regexp.shell # ^^^ - meta.string.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ a =~ [^\]] ]] -#^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^^^^^ meta.string.regexp.shell meta.set.regexp.shell # ^^^ - meta.string.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ a =~ [\\\]] ]] -#^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^^^^^^ meta.string.regexp.shell meta.set.regexp.shell # ^^^ - meta.string.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ a =~ [\\\] ]] -#^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^^^^^ meta.string.regexp.shell - meta.set # ^^^ - meta.string.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ a =~ [[:alpha: ]] -#^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^^^^^^^^^ meta.string.regexp.shell - meta.set # ^^^ - meta.string.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ a =~ [[:alpha:] ]] -#^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^ meta.string.regexp.shell - meta.set # ^^^^^^^^^ meta.string.regexp.shell meta.set.regexp.shell # ^^^ - meta.string.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ a =~ [[:alpha:]][^[:alpha:]][[^:alpha:]] ]] -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.regexp.shell meta.set.regexp.shell # ^ meta.string.regexp.shell - meta.set @@ -7872,10 +7872,10 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^^^^^^^^^ - constant.other.posix-class # ^ punctuation.definition.set.end.regexp.shell # ^ - punctuation -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ a =~ [[:${posix}:]][[:$foo:]] ]] -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^^^ meta.string.regexp.shell meta.set.regexp.shell - meta.interpolation # ^^^^^^^^ meta.string.regexp.shell meta.set.regexp.shell meta.set.regexp.shell meta.interpolation.parameter.shell @@ -7883,7 +7883,7 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^^^^ meta.string.regexp.shell meta.set.regexp.shell meta.set.regexp.shell meta.interpolation.parameter.shell # ^^^ meta.string.regexp.shell meta.set.regexp.shell - meta.interpolation # ^^^ - meta.string.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell # ^^ punctuation.definition.set.begin.regexp.shell # ^ constant.other.posix-class.regexp.shell punctuation.definition.class.begin.regexp.shell # ^ punctuation.definition.variable.shell @@ -7897,10 +7897,10 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^^^^ variable.other.readwrite.shell # ^ punctuation.definition.class.end.regexp.shell # ^^ punctuation.definition.set.end.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ a =~ [[=a=]] ]] -#^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^^^^^^^ meta.string.regexp.shell meta.set.regexp.shell # ^^^ - meta.string.regexp.shell @@ -7909,10 +7909,10 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^^^ constant.character.equivalence-class.regexp.shell # ^ punctuation.definition.class.end.regexp.shell # ^^ punctuation.definition.set.end.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ a =~ [[=$a=]] ]] -#^^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^^^^^^^^ meta.string.regexp.shell meta.set.regexp.shell # ^^^ - meta.string.regexp.shell @@ -7922,10 +7922,10 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^^ meta.interpolation.parameter.shell variable.other.readwrite.shell # ^ punctuation.definition.class.end.regexp.shell # ^^ punctuation.definition.set.end.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ a =~ [[.ch.]] ]] -#^^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^^^^^^^^ meta.string.regexp.shell meta.set.regexp.shell # ^^^ - meta.string.regexp.shell @@ -7934,10 +7934,10 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^^^^ constant.character.collate.regexp.shell # ^ punctuation.definition.collate.end.regexp.shell # ^^ punctuation.definition.set.end.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ a =~ [[.dollar-sign.]] ]] -#^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^^^^^^^^^^^^^^^^^ meta.string.regexp.shell meta.set.regexp.shell # ^^^ - meta.string.regexp.shell @@ -7946,10 +7946,10 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^^^^^^^^^^^^^ constant.character.collate.regexp.shell # ^ punctuation.definition.collate.end.regexp.shell # ^^ punctuation.definition.set.end.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ a =~ [[.${equiv}.]] ]] -#^^^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^^^^^^^^^^^^^^ meta.string.regexp.shell meta.set.regexp.shell # ^^^ - meta.string.regexp.shell @@ -7959,18 +7959,18 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^^^^^^^^ meta.interpolation.parameter.shell # ^ punctuation.definition.collate.end.regexp.shell # ^^ punctuation.definition.set.end.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ a =~ [[.alpha=]] ]] -#^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^^^^^^^^^^ meta.string.regexp.shell meta.set.regexp.shell - constant # ^ meta.string.regexp.shell - meta.set # ^^^ - meta.string.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ a =~ [-9][0-][$0-9][0-$9] ]] -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^^^^^^^^^^^^^^^^^^^^ meta.string.regexp.shell meta.set.regexp.shell # ^^ - constant - operator @@ -7979,33 +7979,33 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^^ constant.other.range.regexp.shell # ^^ meta.interpolation.parameter.shell variable.language.positional.shell # ^^^ - meta.string.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ a =~ [${ bar }] ]] -#^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^^^^^^^^^^ meta.string.regexp.shell meta.set.regexp.shell # ^^^^^^^^ meta.interpolation.parameter.shell # ^^^ - meta.string.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ a =~ { ]] -#^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^ meta.string.regexp.shell - meta.interpolation # ^^^ - meta.string.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ a =~ } ]] -#^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^ meta.string.regexp.shell - meta.interpolation # ^^^ - meta.string.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ a =~ \${* ]] -#^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^^^^ meta.string.regexp.shell - meta.interpolation # ^^^ - meta.string.regexp.shell @@ -8013,7 +8013,7 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^ keyword.operator.quantifier.regexp.shell [[ a =~ ${* ]]} ]] -#^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^^^^^^^ meta.string.regexp.shell meta.interpolation.parameter.shell # ^^^ - meta.string.regexp.shell @@ -8021,17 +8021,17 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^ punctuation.section.interpolation.begin.shell # ^^ - support.function # ^ punctuation.section.interpolation.end.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ a =~ %1* ]] -#^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^^^ meta.string.regexp.shell - meta.interpolation # ^ keyword.operator.quantifier.regexp.shell # ^^^ - meta.string.regexp.shell [[ a =~ [abc[]* ]] -#^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^ - meta.string.regexp.shell # ^^^^^^^ meta.string.regexp.shell - meta.interpolation # ^^^ - meta.string.regexp.shell @@ -8041,7 +8041,7 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^ keyword.operator.quantifier.regexp.shell [[ "${foo}" =~ bar*baz ]] -#^^^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^^^^^^^^ - meta.string.regexp.shell # ^^^^^^^ meta.string.regexp.shell - meta.interpolation # ^^^ - meta.string.regexp.shell @@ -8049,7 +8049,7 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^ keyword.operator.quantifier.regexp.shell [[ "${foo}" =~ bar|baz ]] -#^^^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^^^^^^^^ - meta.string.regexp.shell # ^^^^^^^ meta.string.regexp.shell - meta.interpolation # ^^^ - meta.string.regexp.shell @@ -8057,7 +8057,7 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^ keyword.operator.alternation.regexp.shell [[ $foo =~ ^$'\t' ]] -#^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell # ^ - meta.conditional #^^^^^^^^^^ - meta.string.regexp.shell # ^^^^^^ meta.string.regexp.shell - meta.interpolation @@ -8066,7 +8066,7 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^^ keyword.operator.comparison.shell [[ $foo =~ ^abc$var$ ]] -#^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell # ^ - meta.conditional #^^^^^^^^^^ - meta.string.regexp.shell # ^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell @@ -8077,7 +8077,7 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^^^ - meta.string.regexp.shell [[ $foo =~ [[:space:]]*?(a)b ]] -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell # ^ - meta.conditional #^^^^^^^^^^ - meta.string.regexp.shell # ^^^^^^^^^^^^^^^^^ meta.string.regexp.shell @@ -8094,7 +8094,7 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^ punctuation.section.group.end.regexp.shell [[ $foo =~ ^0[1-9]$ ]] -#^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell # ^ - meta.conditional #^^^^^^^^^^ - meta.string.regexp.shell # ^^^^^^^^ meta.string.regexp.shell @@ -8103,7 +8103,7 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^^^ - meta.string.regexp.shell [[ $foo =~ ^0[1-9]{2,3}$ ]] -#^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell # ^ - meta.conditional #^^^^^^^^^^ - meta.string.regexp.shell # ^^^^^^^^^^^^^ meta.string.regexp.shell @@ -8113,7 +8113,7 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^^^ - meta.string.regexp.shell [[ $foo =~ ^0[1-9]{a,b}$ ]] -#^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell # ^ - meta.conditional #^^^^^^^^^^ - meta.string.regexp.shell # ^^^^^^^^^^^^^ meta.string.regexp.shell @@ -8128,24 +8128,24 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^^^ - meta.string.regexp.shell [[ ! ($foo =~ ^0[1-9]$) ]] -# <- meta.conditional.shell - meta.group -#^^^^ meta.conditional.shell - meta.group -# ^^^^^^^^^ meta.conditional.shell meta.group.shell - meta.string.regexp -# ^^^^^^^^ meta.conditional.shell meta.group.shell meta.string.regexp.shell -# ^ meta.conditional.shell meta.group.shell - meta.string.regexp -# ^^^ meta.conditional.shell - meta.group +# <- meta.compound.conditional.shell - meta.group +#^^^^ meta.compound.conditional.shell - meta.group +# ^^^^^^^^^ meta.compound.conditional.shell meta.group.shell - meta.string.regexp +# ^^^^^^^^ meta.compound.conditional.shell meta.group.shell meta.string.regexp.shell +# ^ meta.compound.conditional.shell meta.group.shell - meta.string.regexp +# ^^^ meta.compound.conditional.shell - meta.group # ^ - meta.conditional - meta.group [[ ! ($foo =~ ^(\([0-9]+)$) ]] -# <- meta.conditional.shell - meta.group -#^^^^ meta.conditional.shell - meta.group -# ^^^^^^^^^ meta.conditional.shell meta.group.shell - meta.string.regexp -# ^^^^^^^^^^^^ meta.conditional.shell meta.group.shell meta.string.regexp.shell -# ^ meta.conditional.shell meta.group.shell - meta.string.regexp -# ^^^ meta.conditional.shell - meta.group +# <- meta.compound.conditional.shell - meta.group +#^^^^ meta.compound.conditional.shell - meta.group +# ^^^^^^^^^ meta.compound.conditional.shell meta.group.shell - meta.string.regexp +# ^^^^^^^^^^^^ meta.compound.conditional.shell meta.group.shell meta.string.regexp.shell +# ^ meta.compound.conditional.shell meta.group.shell - meta.string.regexp +# ^^^ meta.compound.conditional.shell - meta.group # ^ - meta.conditional - meta.group -# <- support.function.test.begin.shell -#^ support.function.test.begin.shell +# <- punctuation.section.compound.begin.shell +#^ punctuation.section.compound.begin.shell # ^ keyword.operator.logical.shell # ^ punctuation.section.group.begin.shell # ^^^^ variable.other.readwrite.shell @@ -8159,27 +8159,27 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^ keyword.operator.quantifier.regexp.shell # ^ punctuation.section.group.end.regexp.shell # ^ punctuation.section.group.end.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ ( $foo =~ ^ -#^^ meta.conditional.shell - meta.group -# ^^^^^^^^^^ meta.conditional.shell meta.group.shell - meta.string.regexp -# ^ meta.conditional.shell meta.group.shell meta.string.regexp.shell -# ^ meta.conditional.shell meta.group.shell - meta.string.regexp invalid.illegal.unexpected-token.shell +#^^ meta.compound.conditional.shell - meta.group +# ^^^^^^^^^^ meta.compound.conditional.shell meta.group.shell - meta.string.regexp +# ^ meta.compound.conditional.shell meta.group.shell meta.string.regexp.shell +# ^ meta.compound.conditional.shell meta.group.shell - meta.string.regexp invalid.illegal.unexpected-token.shell [[ ( $foo =~ ^\ [^0-9]+ ) ]] -# <- meta.conditional.shell meta.group.shell meta.string.regexp.shell -#^^^^^^^^^ meta.conditional.shell meta.group.shell meta.string.regexp.shell -# ^^ meta.conditional.shell meta.group.shell - meta.string.regexp -# ^^^ meta.conditional.shell - meta.group -# ^^ support.function.test.end.shell +# <- meta.compound.conditional.shell meta.group.shell meta.string.regexp.shell +#^^^^^^^^^ meta.compound.conditional.shell meta.group.shell meta.string.regexp.shell +# ^^ meta.compound.conditional.shell meta.group.shell - meta.string.regexp +# ^^^ meta.compound.conditional.shell - meta.group +# ^^ punctuation.section.compound.end.shell [[ ( $foo =~ ^ ]] -#^^ meta.conditional.shell - meta.group -# ^^^^^^^^^^ meta.conditional.shell meta.group.shell - meta.string.regexp -# ^ meta.conditional.shell meta.group.shell meta.string.regexp.shell -# ^^^ meta.conditional.shell meta.group.shell - meta.string.regexp +#^^ meta.compound.conditional.shell - meta.group +# ^^^^^^^^^^ meta.compound.conditional.shell meta.group.shell - meta.string.regexp +# ^ meta.compound.conditional.shell meta.group.shell meta.string.regexp.shell +# ^^^ meta.compound.conditional.shell meta.group.shell - meta.string.regexp # ^^ invalid.illegal.unexpected-token.shell [[ ( $foo =~ ^ ]] @@ -8188,92 +8188,92 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} #^^^^^^^^^^^^^^ - meta.conditional [[ $foo =~ ( ]] -#^^^^^^^^^^ meta.conditional.shell - meta.string.regexp - meta.group -# ^^^^^ meta.conditional.shell meta.string.regexp.shell meta.group.regexp.shell +#^^^^^^^^^^ meta.compound.conditional.shell - meta.string.regexp - meta.group +# ^^^^^ meta.compound.conditional.shell meta.string.regexp.shell meta.group.regexp.shell # ^ punctuation.section.group.begin.regexp.shell # ^^ - punctuation [^0-9]+ ) ]] -# <- meta.conditional.shell meta.string.regexp.shell meta.group.regexp.shell -#^^^^^^^^^^^ meta.conditional.shell meta.string.regexp.shell meta.group.regexp.shell +# <- meta.compound.conditional.shell meta.string.regexp.shell meta.group.regexp.shell +#^^^^^^^^^^^ meta.compound.conditional.shell meta.string.regexp.shell meta.group.regexp.shell # ^^^ - meta.string.regexp -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ $foo =~ ) ]] -#^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^ meta.compound.conditional.shell # ^ meta.string.regexp.shell invalid.illegal.stray.regexp.shell [[ $foo =~ ( ) ]] -#^^^^^^^^^^ meta.conditional.shell - meta.string.regexp - meta.group -# ^^^ meta.conditional.shell meta.string.regexp.shell meta.group.regexp.shell -# ^^^ meta.conditional.shell - meta.string.regexp - meta.group +#^^^^^^^^^^ meta.compound.conditional.shell - meta.string.regexp - meta.group +# ^^^ meta.compound.conditional.shell meta.string.regexp.shell meta.group.regexp.shell +# ^^^ meta.compound.conditional.shell - meta.string.regexp - meta.group # ^ - meta.conditional [[ $foo =~ ( [ ) ]] -#^^^^^^^^^^ meta.conditional.shell - meta.string.regexp - meta.group -# ^^^^^ meta.conditional.shell meta.string.regexp.shell meta.group.regexp.shell -# ^^^ meta.conditional.shell - meta.string.regexp - meta.group +#^^^^^^^^^^ meta.compound.conditional.shell - meta.string.regexp - meta.group +# ^^^^^ meta.compound.conditional.shell meta.string.regexp.shell meta.group.regexp.shell +# ^^^ meta.compound.conditional.shell - meta.string.regexp - meta.group # ^ - meta.conditional [[ $foo =~ ( ] ) ]] -#^^^^^^^^^^ meta.conditional.shell - meta.string.regexp - meta.group -# ^^^^^ meta.conditional.shell meta.string.regexp.shell meta.group.regexp.shell -# ^^^ meta.conditional.shell - meta.string.regexp - meta.group +#^^^^^^^^^^ meta.compound.conditional.shell - meta.string.regexp - meta.group +# ^^^^^ meta.compound.conditional.shell meta.string.regexp.shell meta.group.regexp.shell +# ^^^ meta.compound.conditional.shell - meta.string.regexp - meta.group # ^ - meta.conditional [[ $foo =~ ( [\\\] ) ]] -#^^^^^^^^^^ meta.conditional.shell - meta.string.regexp - meta.group -# ^^^^^^^^^ meta.conditional.shell meta.string.regexp.shell meta.group.regexp.shell -# ^^^ meta.conditional.shell - meta.string.regexp - meta.group +#^^^^^^^^^^ meta.compound.conditional.shell - meta.string.regexp - meta.group +# ^^^^^^^^^ meta.compound.conditional.shell meta.string.regexp.shell meta.group.regexp.shell +# ^^^ meta.compound.conditional.shell - meta.string.regexp - meta.group # ^ - meta.conditional [[ ( $foo =~ [\\\] ) ]] -#^^ meta.conditional.shell - meta.group -# ^^^^^^^^^^ meta.conditional.shell meta.group.shell - meta.string.regexp -# ^^^^^ meta.conditional.shell meta.group.shell meta.string.regexp.shell -# ^^ meta.conditional.shell meta.group.shell - meta.string.regexp -# ^^^ meta.conditional.shell - meta.group - meta.string.regexp +#^^ meta.compound.conditional.shell - meta.group +# ^^^^^^^^^^ meta.compound.conditional.shell meta.group.shell - meta.string.regexp +# ^^^^^ meta.compound.conditional.shell meta.group.shell meta.string.regexp.shell +# ^^ meta.compound.conditional.shell meta.group.shell - meta.string.regexp +# ^^^ meta.compound.conditional.shell - meta.group - meta.string.regexp # ^ - meta.conditional [[ ( $foo =~ ([\\\])) ]] -#^^ meta.conditional.shell - meta.group -# ^^^^^^^^^^ meta.conditional.shell meta.group.shell - meta.string.regexp -# ^^^^^^^ meta.conditional.shell meta.group.shell meta.string.regexp.shell meta.group.regexp.shell -# ^ meta.conditional.shell meta.group.shell - meta.string.regexp -# ^^^ meta.conditional.shell - meta.group - meta.string.regexp +#^^ meta.compound.conditional.shell - meta.group +# ^^^^^^^^^^ meta.compound.conditional.shell meta.group.shell - meta.string.regexp +# ^^^^^^^ meta.compound.conditional.shell meta.group.shell meta.string.regexp.shell meta.group.regexp.shell +# ^ meta.compound.conditional.shell meta.group.shell - meta.string.regexp +# ^^^ meta.compound.conditional.shell - meta.group - meta.string.regexp # ^ - meta.conditional [[ $foo =~ (?x) ]] -#^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell # ^^^^ meta.string.regexp.shell meta.group.regexp.shell # ^ punctuation.section.group.begin.regexp.shell # ^ invalid.illegal.unexpected-quantifier.regexp.shell # ^ punctuation.section.group.end.regexp.shell [[ $foo =~ (?:bar) ]] -#^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell # ^^^^^^^ meta.string.regexp.shell meta.group.regexp.shell # ^ punctuation.section.group.begin.regexp.shell # ^ invalid.illegal.unexpected-quantifier.regexp.shell # ^ punctuation.section.group.end.regexp.shell [[ $foo =~ (?i:bar) ]] -#^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell # ^^^^^^^^ meta.string.regexp.shell meta.group.regexp.shell # ^ punctuation.section.group.begin.regexp.shell # ^ invalid.illegal.unexpected-quantifier.regexp.shell # ^ punctuation.section.group.end.regexp.shell [[ ' foo ' =~ ( foo ) ]] # evaluates to true -#^^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell # ^^^^^^^ meta.string.shell string.quoted.single.shell # ^^ keyword.operator.comparison.shell # ^^^^^^^ meta.string.regexp.shell meta.group.regexp.shell # ^ punctuation.section.group.begin.regexp.shell # ^ punctuation.section.group.end.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ ' foo ' =~ ([ ]foo[ ]) ]] # evaluates to true -#^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell # ^^^^^^^ meta.string.shell string.quoted.single.shell # ^ meta.string.regexp.shell meta.group.regexp.shell - meta.set # ^^^ meta.string.regexp.shell meta.group.regexp.shell meta.set.regexp.shell @@ -8287,10 +8287,10 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^ punctuation.definition.set.begin.regexp.shell # ^ punctuation.definition.set.end.regexp.shell # ^ punctuation.section.group.end.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ foo =~ ^foo//:/[}] ]] -#^^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell #^^^^^^^^^ - meta.string.regexp.shell # ^^^^^^^^ meta.string.regexp.shell - meta.set # ^^^ meta.string.regexp.shell meta.set.regexp.shell @@ -8298,7 +8298,7 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^^ keyword.operator.comparison.shell # ^ punctuation.definition.set.begin.regexp.shell # ^ punctuation.definition.set.end.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ foo =~ ^[0-9]+\.[0-9]+(([ab]|rc)[0-9]+)?$ ]] # ^ meta.group.regexp.shell - meta.group meta.group @@ -8309,7 +8309,7 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^ punctuation.section.group.end.regexp.shell [[ ' foobar' =~ [\ ]foo* ]] -#^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell # ^ - meta.conditional #^^^^^^^^^^^^^^^ - meta.string.regexp.shell # ^^^^ meta.set.regexp.shell @@ -8321,7 +8321,7 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^ keyword.operator.quantifier.regexp.shell [[ a\$bc =~ ^a'$b'c$ ]] -#^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell # ^^^^^^^^ meta.string.regexp.shell - variable # ^ keyword.control.anchor.regexp.shell # ^ punctuation.definition.string.begin.shell @@ -8329,7 +8329,7 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^ keyword.control.anchor.regexp.shell [[ a"$bc"c =~ ^a"$bc"c$ ]] -#^^^^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +#^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell # ^^^^^^^^^ meta.string.regexp.shell # ^ keyword.control.anchor.regexp.shell # ^ punctuation.definition.string.begin.shell @@ -8341,8 +8341,8 @@ echo '([^.[:space:]]+) Class::method()' # colon not scoped as path separator # ^^^^^^^^^^^^^^^^^^^^^ string.quoted.single - punctuation.separator.sequence [[ $foo =~ 'bar' || $foo =~ "baz" && $bar =~ baz ]] -# <- meta.conditional.shell support.function.test.begin.shell -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell +# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell # ^^^^ meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell # ^^^^ - meta.string # ^^ keyword.operator.comparison.shell @@ -8360,13 +8360,13 @@ echo '([^.[:space:]]+) Class::method()' # colon not scoped as path separator # ^^ keyword.operator.comparison.shell # ^^^ meta.string.regexp.shell # ^^^^ - meta.string -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ ( $foo =~ 'bar' || $foo =~ "baz" ) && $bar =~ baz ]] -# <- meta.conditional.shell support.function.test.begin.shell -#^^ meta.conditional.shell - meta.group -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell meta.group.shell -# ^^^^^^^^^^^^^^^^^^ meta.conditional.shell - meta.group +# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell +#^^ meta.compound.conditional.shell - meta.group +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell meta.group.shell +# ^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell - meta.group #^^^^ - meta.string # ^ punctuation.section.group.begin.shell # ^^^^ meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell @@ -8387,90 +8387,90 @@ echo '([^.[:space:]]+) Class::method()' # colon not scoped as path separator # ^^ keyword.operator.comparison.shell # ^^^ meta.string.regexp.shell # ^^^^ - meta.string -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ $foo =~ ; ]] # unquoted semicolons are illegal -# <- meta.conditional.shell support.function.test.begin.shell -#^^^^^^^^^^^^^^ meta.conditional.shell +# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell +#^^^^^^^^^^^^^^ meta.compound.conditional.shell # ^ - meta.conditional # ^^ keyword.operator.comparison.shell # ^ invalid.illegal.unexpected-token.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ ( $foo =~ ; ) ]] # unquoted semicolons are illegal -# <- meta.conditional.shell support.function.test.begin.shell -#^^ meta.conditional.shell - meta.group -# ^^^^^^^^^^^^^ meta.conditional.shell meta.group.shell -# ^^^ meta.conditional.shell - meta.group +# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell +#^^ meta.compound.conditional.shell - meta.group +# ^^^^^^^^^^^^^ meta.compound.conditional.shell meta.group.shell +# ^^^ meta.compound.conditional.shell - meta.group # ^ - meta.conditional # ^^ keyword.operator.comparison.shell # ^ invalid.illegal.unexpected-token.shell # ^ punctuation.section.group.end.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ $foo =~ (;) ]] # unquoted semicolons allowed in pattern groups -# <- meta.conditional.shell support.function.test.begin.shell -#^^^^^^^^^^ meta.conditional.shell - meta.group -# ^^^ meta.conditional.shell meta.string.regexp.shell meta.group.regexp.shell string.unquoted.shell -# ^^^ meta.conditional.shell - meta.group +# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell +#^^^^^^^^^^ meta.compound.conditional.shell - meta.group +# ^^^ meta.compound.conditional.shell meta.string.regexp.shell meta.group.regexp.shell string.unquoted.shell +# ^^^ meta.compound.conditional.shell - meta.group # ^ - meta.conditional # ^^ keyword.operator.comparison.shell # ^ punctuation.section.group.begin.regexp.shell # ^ punctuation.section.group.end.regexp.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ ( $foo =~ (;) ) ]] # unquoted semicolons allowed in pattern groups -# <- meta.conditional.shell support.function.test.begin.shell -#^^ meta.conditional.shell - meta.group -# ^^^^^^^^^^ meta.conditional.shell meta.group.shell - meta.group meta.group -# ^^^ meta.conditional.shell meta.group.shell meta.string.regexp.shell meta.group.regexp.shell string.unquoted.shell -# ^ meta.conditional.shell meta.group.shell - meta.group meta.group -# ^^^ meta.conditional.shell - meta.group +# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell +#^^ meta.compound.conditional.shell - meta.group +# ^^^^^^^^^^ meta.compound.conditional.shell meta.group.shell - meta.group meta.group +# ^^^ meta.compound.conditional.shell meta.group.shell meta.string.regexp.shell meta.group.regexp.shell string.unquoted.shell +# ^ meta.compound.conditional.shell meta.group.shell - meta.group meta.group +# ^^^ meta.compound.conditional.shell - meta.group # ^ - meta.conditional # ^^ keyword.operator.comparison.shell # ^ punctuation.section.group.begin.regexp.shell # ^ punctuation.section.group.end.regexp.shell # ^ punctuation.section.group.end.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ $foo =~ \; ]] # escaped semicolons are allowed -# <- meta.conditional.shell support.function.test.begin.shell -#^^^^^^^^^^^^^^^ meta.conditional.shell +# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell +#^^^^^^^^^^^^^^^ meta.compound.conditional.shell # ^ - meta.conditional # ^^ keyword.operator.comparison.shell # ^^ constant.character.escape.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ ( $foo =~ \; ) ]] # escaped semicolons are allowed -# <- meta.conditional.shell support.function.test.begin.shell -#^^ meta.conditional.shell - meta.group -# ^^^^^^^^^^^^^^ meta.conditional.shell meta.group.shell -# ^^^ meta.conditional.shell - meta.group +# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell +#^^ meta.compound.conditional.shell - meta.group +# ^^^^^^^^^^^^^^ meta.compound.conditional.shell meta.group.shell +# ^^^ meta.compound.conditional.shell - meta.group # ^ - meta.conditional # ^^ keyword.operator.comparison.shell # ^^ constant.character.escape.shell # ^ punctuation.section.group.end.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ $foo =~ ";" ]] -# <- meta.conditional.shell support.function.test.begin.shell -#^^^^^^^^^^^^^^^^ meta.conditional.shell +# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell +#^^^^^^^^^^^^^^^^ meta.compound.conditional.shell # ^ - meta.conditional # ^^ keyword.operator.comparison.shell # ^^^ string -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell [[ ( $foo =~ ";" ) ]] -# <- meta.conditional.shell support.function.test.begin.shell -#^^ meta.conditional.shell - meta.group -# ^^^^^^^^^^ meta.conditional.shell meta.group.shell - meta.string.regexp -# ^^^ meta.conditional.shell meta.group.shell meta.string.regexp.shell -# ^^ meta.conditional.shell meta.group.shell - meta.string -# ^^^ meta.conditional.shell - meta.group +# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell +#^^ meta.compound.conditional.shell - meta.group +# ^^^^^^^^^^ meta.compound.conditional.shell meta.group.shell - meta.string.regexp +# ^^^ meta.compound.conditional.shell meta.group.shell meta.string.regexp.shell +# ^^ meta.compound.conditional.shell meta.group.shell - meta.string +# ^^^ meta.compound.conditional.shell - meta.group # ^ - meta.conditional # ^^ keyword.operator.comparison.shell # ^ punctuation.section.group.end.shell -# ^^ support.function.test.end.shell +# ^^ punctuation.section.compound.end.shell ############################################################################### @@ -10045,7 +10045,7 @@ let "two=5+5"; if [[ "$X" == "1" ]]; then X="one"; fi # ^ punctuation.definition.quoted.end.shell # ^ punctuation.terminator.statement.shell # ^^ keyword.control.conditional.if.shell -# ^^^^^^^^^^^^^^^^^ meta.conditional.shell +# ^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell # ^ punctuation.terminator.statement.shell # ^^^^ keyword.control.conditional.then.shell # ^ variable.other.readwrite.shell @@ -11263,18 +11263,18 @@ sudo --reset-timestamp -n -f -- rm -rf ![ ] # <- punctuation.definition.history.shell -#^ support.function.test.begin.shell -# ^ support.function.test.end.shell +#^ punctuation.section.compound.begin.shell +# ^ punctuation.section.compound.end.shell ! [ ] # <- keyword.operator.logical.shell -# ^ support.function.test.begin.shell -# ^ support.function.test.end.shell +# ^ punctuation.section.compound.begin.shell +# ^ punctuation.section.compound.end.shell [ ] -# <- meta.conditional.shell support.function.test.begin.shell -#^^^ meta.conditional.shell -# ^ support.function.test.end.shell +# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell +#^^^ meta.compound.conditional.shell +# ^ punctuation.section.compound.end.shell [ ] @@ -11282,162 +11282,162 @@ sudo --reset-timestamp -n -f -- rm -rf [ \ ] -# <- meta.conditional.shell support.function.test.end.shell +# <- meta.compound.conditional.shell punctuation.section.compound.end.shell [ # comment ] -# <- meta.conditional.shell support.function.test.begin.shell +# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell #^ - meta.conditional - comment # ^^^^^^^^^^^^ comment.line.number-sign.shell - meta.conditional [ ; cmd ] -# <- meta.conditional.shell support.function.test.begin.shell +# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell #^^^^^^^^^ - meta.conditional # ^ punctuation.terminator.statement.shell # ^^^ variable.function.shell # ^ string.unquoted.shell [ && cmd ] -# <- meta.conditional.shell support.function.test.begin.shell +# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell #^^^^^^^^^^ - meta.conditional # ^^ keyword.operator.logical.shell # ^^^ variable.function.shell # ^ string.unquoted.shell [ || cmd ] -# <- meta.conditional.shell support.function.test.begin.shell +# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell #^^^^^^^^^^ - meta.conditional # ^^ keyword.operator.logical.shell # ^^^ variable.function.shell # ^ string.unquoted.shell [ >>cmd ] -# <- meta.conditional.shell support.function.test.begin.shell -#^^^^^^^^ meta.conditional.shell +# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell +#^^^^^^^^ meta.compound.conditional.shell # ^^^^^ meta.redirection.shell # ^^ keyword.operator.assignment.redirection.shell # ^^^ string.unquoted.shell -# ^ support.function.test.end.shell +# ^ punctuation.section.compound.end.shell [ <= str ] -# <- meta.conditional.shell support.function.test.begin.shell -#^^^^^^^^^^^^^ meta.conditional.shell +# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell +#^^^^^^^^^^^^^ meta.compound.conditional.shell # ^^^ meta.string.shell string.unquoted.shell # ^^ invalid.illegal.operator.shell # ^^^ meta.string.shell string.unquoted.shell -# ^ support.function.test.end.shell +# ^ punctuation.section.compound.end.shell [ str <= str ] -# <- meta.conditional.shell support.function.test.begin.shell -#^^^^^^^^^^^^^ meta.conditional.shell +# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell +#^^^^^^^^^^^^^ meta.compound.conditional.shell # ^^^ meta.string.shell string.unquoted.shell # ^^ invalid.illegal.operator.shell # ^^^ meta.string.shell string.unquoted.shell -# ^ support.function.test.end.shell +# ^ punctuation.section.compound.end.shell [ str = str ] -# <- meta.conditional.shell support.function.test.begin.shell -#^^^^^^^^^^^^ meta.conditional.shell +# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell +#^^^^^^^^^^^^ meta.compound.conditional.shell # ^^^ meta.string.shell string.unquoted.shell # ^ keyword.operator.comparison.shell # ^^^ meta.string.shell string.unquoted.shell -# ^ support.function.test.end.shell +# ^ punctuation.section.compound.end.shell [ str < str ] -# <- meta.conditional.shell support.function.test.begin.shell -#^^^^^^^^^^^^ meta.conditional.shell +# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell +#^^^^^^^^^^^^ meta.compound.conditional.shell # ^^^ meta.string.shell string.unquoted.shell # ^ keyword.operator.comparison.shell # ^^^ meta.string.shell string.unquoted.shell -# ^ support.function.test.end.shell +# ^ punctuation.section.compound.end.shell [ str > str ] -# <- meta.conditional.shell support.function.test.begin.shell -#^^^^^^^^^^^^ meta.conditional.shell +# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell +#^^^^^^^^^^^^ meta.compound.conditional.shell # ^^^ meta.string.shell string.unquoted.shell # ^ keyword.operator.comparison.shell # ^^^ meta.string.shell string.unquoted.shell -# ^ support.function.test.end.shell +# ^ punctuation.section.compound.end.shell [ $arg -lt 2 ] -# <- meta.conditional.shell support.function.test.begin.shell -#^^^^^^^^^^^^^ meta.conditional.shell +# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell +#^^^^^^^^^^^^^ meta.compound.conditional.shell # ^^^^ variable.other.readwrite.shell # ^^^ keyword.operator.comparison.shell # ^ meta.number.integer.decimal.shell constant.numeric.value.shell -# ^ support.function.test.end.shell +# ^ punctuation.section.compound.end.shell ############################################################################### # Bash Numeric Constants # @@ -11810,8 +11810,8 @@ function clk { # ^ keyword.operator.assignment.shell # ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell string.unquoted.shell [[ -r ${base}/hwmon/hwmon0/temp1_input && -r ${base}/power_profile ]] || return 1 - # <- support.function.test.begin.shell - # ^^ support.function.test.end.shell + # <- punctuation.section.compound.begin.shell + # ^^ punctuation.section.compound.end.shell case $1 in low|high|default) printf '%s\n' "temp: $(<${base}/hwmon/hwmon0/temp1_input)C" "old profile: $(<${base}/power_profile)" From 2a4aac13e6fe938c81562f47c9b914b65b91c6ba Mon Sep 17 00:00:00 2001 From: deathaxe Date: Thu, 1 Aug 2024 20:26:19 +0200 Subject: [PATCH 040/113] [ShellScript] Refactor compound commands This commit applies `meta.compound.command` to compound commands to distinguish them via level-3 scope name from the others. --- ShellScript/Bash.sublime-syntax | 16 +-- ShellScript/test/syntax_test_bash.sh | 100 +++++++++--------- .../test/syntax_test_shell_unix_generic.sh | 6 +- 3 files changed, 61 insertions(+), 61 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 7a25f37674..c78686b313 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -591,7 +591,7 @@ contexts: 1: meta.coproc.shell 2: meta.coproc.identifier.shell 3: entity.name.function.shell - 4: meta.coproc.command.shell meta.compound.shell + 4: meta.coproc.command.shell meta.compound.command.shell punctuation.section.compound.begin.shell set: cmd-coproc-compound-command - match: '' @@ -602,10 +602,10 @@ contexts: - include: statement cmd-coproc-compound-command: - - meta_content_scope: meta.coproc.command.shell meta.compound.shell + - meta_content_scope: meta.coproc.command.shell meta.compound.command.shell - match: \} scope: - meta.coproc.command.shell meta.compound.shell + meta.coproc.command.shell meta.compound.command.shell punctuation.section.compound.end.shell pop: 1 - include: statements @@ -1090,14 +1090,14 @@ contexts: push: cmd-compound-parens-body cmd-compound-braces-body: - - meta_scope: meta.compound.shell + - meta_scope: meta.compound.command.shell - match: \} scope: punctuation.section.compound.end.shell pop: 1 - include: statements cmd-compound-parens-body: - - meta_scope: meta.compound.shell + - meta_scope: meta.compound.command.shell - match: \) scope: punctuation.section.compound.end.shell pop: 1 @@ -1830,16 +1830,16 @@ contexts: meta.number.integer.decimal.shell constant.numeric.value.shell 2: keyword.operator.assignment.redirection.shell - 3: meta.compound.shell + 3: meta.compound.command.shell punctuation.section.compound.begin.shell push: redirections-process-body redirections-process-body: - meta_scope: meta.redirection.shell - - meta_content_scope: meta.compound.shell + - meta_content_scope: meta.compound.command.shell - match: \) scope: - meta.compound.shell + meta.compound.command.shell punctuation.section.compound.end.shell pop: 1 - include: statements diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index 12b0c3ae3e..f74266e012 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -1791,7 +1791,7 @@ asdf foo && FOO=some-value pwd # ^^^ meta.function-call.identifier.shell support.function.pwd.shell (cd Layer1-linux && PLATFORM=${PLATFORM} ./build ) && -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.shell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.command.shell # <- punctuation.section.compound.begin.shell # ^^ keyword.operator.logical.shell # ^ variable.other.readwrite.shell @@ -1801,7 +1801,7 @@ asdf foo && FOO=some-value pwd # ^ punctuation.section.compound.end.shell # ^^ keyword.operator.logical.shell (cd Layer2-nodejs && PLATFORM=${PLATFORM} ./build ) && -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.shell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.command.shell # <- punctuation.section.compound.begin.shell # ^^ keyword.operator.logical.shell # ^ variable.other.readwrite.shell @@ -1811,7 +1811,7 @@ asdf foo && FOO=some-value pwd # ^ punctuation.section.compound.end.shell # ^^ keyword.operator.logical.shell (cd Layer3-base && PLATFORM=${PLATFORM} ./build ) && -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.shell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.command.shell # <- punctuation.section.compound.begin.shell # ^^ keyword.operator.logical.shell # ^ variable.other.readwrite.shell @@ -1821,7 +1821,7 @@ asdf foo && FOO=some-value pwd # ^ punctuation.section.compound.end.shell # ^^ keyword.operator.logical.shell (cd Layer4-custom && PLATFORM=${PLATFORM} name=${NOSN} ./build ) || err $? -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.shell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.command.shell # <- punctuation.section.compound.begin.shell # ^^ keyword.operator.logical.shell # ^ variable.other.readwrite.shell @@ -2111,14 +2111,14 @@ esac ############################################################################### (foo) -# <- meta.compound.shell punctuation.section.compound.begin.shell -#^^^ meta.compound.shell meta.function-call.identifier.shell variable.function.shell -# ^ meta.compound.shell punctuation.section.compound.end.shell +# <- meta.compound.command.shell punctuation.section.compound.begin.shell +#^^^ meta.compound.command.shell meta.function-call.identifier.shell variable.function.shell +# ^ meta.compound.command.shell punctuation.section.compound.end.shell # ^ - meta { foo -o } -# <- meta.compound.shell punctuation.section.compound.begin.shell -#^^^^^^^^^ meta.compound.shell - meta.compound meta.compound +# <- meta.compound.command.shell punctuation.section.compound.begin.shell +#^^^^^^^^^ meta.compound.command.shell - meta.compound meta.compound # ^^^ meta.function-call.identifier.shell # ^^^ meta.function-call.arguments.shell # ^^ - meta.function-call @@ -2129,23 +2129,23 @@ esac # ^ punctuation.section.compound.end.shell { -# <- meta.compound.shell punctuation.section.compound.begin.shell -#^ meta.compound.shell - meta.compound meta.compound +# <- meta.compound.command.shell punctuation.section.compound.begin.shell +#^ meta.compound.command.shell - meta.compound meta.compound { -#^ meta.compound.shell - meta.compound meta.compound -# ^^ meta.compound.shell meta.compound.shell +#^ meta.compound.command.shell - meta.compound meta.compound +# ^^ meta.compound.command.shell meta.compound.command.shell # ^ punctuation.section.compound.begin.shell foo args -#^^^^^^^^^^^^ meta.compound.shell meta.compound.shell +#^^^^^^^^^^^^ meta.compound.command.shell meta.compound.command.shell # ^^^ meta.function-call.identifier.shell variable.function.shell # ^^^^^ meta.function-call.arguments.shell } 2>> "$stderr_log" -#^^ meta.compound.shell meta.compound.shell -# ^ meta.compound.shell - meta.compound meta.compound -# ^^^^^^^^^^^^^^^^^ meta.compound.shell meta.redirection.shell +#^^ meta.compound.command.shell meta.compound.command.shell +# ^ meta.compound.command.shell - meta.compound meta.compound +# ^^^^^^^^^^^^^^^^^ meta.compound.command.shell meta.redirection.shell # ^ punctuation.section.compound.end.shell } 1>> "$stdout_log" -# <- meta.compound.shell - meta.compound meta.compound +# <- meta.compound.command.shell - meta.compound meta.compound #^ - meta # ^^^^^^^^^^^^^^^^^ meta.redirection.shell # <- punctuation.section.compound.end.shell @@ -2217,7 +2217,7 @@ coproc awk '{print "foo" $0;fflush()}' coproc { ls thisfiledoesntexist; read; 2>&1 } | foo # <- meta.coproc.shell keyword.declaration.coproc.shell #^^^^^^ meta.coproc.shell -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.coproc.command.shell meta.compound.shell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.coproc.command.shell meta.compound.command.shell # ^^^ - meta.coproc - meta.compound - meta.function-call # ^^^ meta.function-call.identifier.shell # ^ - meta.function-call - meta.function.coproc @@ -2243,7 +2243,7 @@ coproc myls { ls thisfiledoesntexist; read; 2>&1 } | foo # <- meta.coproc.shell keyword.declaration.coproc.shell #^^^^^^ meta.coproc.shell # ^^^^^ meta.coproc.identifier.shell - meta.compound -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.coproc.command.shell meta.compound.shell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.coproc.command.shell meta.compound.command.shell # ^^^ - meta.function-call # ^^^ meta.function-call.identifier.shell #^^^^^ keyword.declaration.coproc.shell @@ -2260,13 +2260,13 @@ coproc myls { ls thisfiledoesntexist; read; 2>&1 } | foo # ^^^ variable.function.shell { coproc tee { tee logfile ;} >&3 ;} 3>&1 -# <- meta.compound.shell punctuation.section.compound.begin.shell -# ^^^^^^^ meta.compound.shell meta.coproc.shell -# ^^^^ meta.compound.shell meta.coproc.identifier.shell -# ^^^^^^^^^^^^^^^^ meta.compound.shell meta.coproc.command.shell meta.compound.shell -# ^ meta.compound.shell - meta.redirection - meta.coproc -# ^^^ meta.compound.shell meta.redirection.shell - meta.coproc -# ^^^ meta.compound.shell - meta.redirection - meta.coproc +# <- meta.compound.command.shell punctuation.section.compound.begin.shell +# ^^^^^^^ meta.compound.command.shell meta.coproc.shell +# ^^^^ meta.compound.command.shell meta.coproc.identifier.shell +# ^^^^^^^^^^^^^^^^ meta.compound.command.shell meta.coproc.command.shell meta.compound.command.shell +# ^ meta.compound.command.shell - meta.redirection - meta.coproc +# ^^^ meta.compound.command.shell meta.redirection.shell - meta.coproc +# ^^^ meta.compound.command.shell - meta.redirection - meta.coproc # ^ - meta # ^^^^ meta.redirection.shell # ^^^^^^ keyword.declaration.coproc.shell @@ -2288,15 +2288,15 @@ coproc foobar { # <- meta.coproc.shell keyword.declaration.coproc.shell #^^^^^^ meta.coproc.shell # ^^^^^^^ meta.coproc.identifier.shell -# ^^ meta.coproc.command.shell meta.compound.shell +# ^^ meta.coproc.command.shell meta.compound.command.shell #^^^^^ keyword.declaration.coproc.shell # ^^^^^^ entity.name.function.shell # ^ punctuation.section.compound.begin.shell read -#^^^^^^^^ meta.coproc.command.shell meta.compound.shell -# ^^^^ meta.coproc.command.shell meta.compound.shell meta.function-call.identifier.shell support.function.read.shell +#^^^^^^^^ meta.coproc.command.shell meta.compound.command.shell +# ^^^^ meta.coproc.command.shell meta.compound.command.shell meta.function-call.identifier.shell support.function.read.shell } -# <- meta.coproc.command.shell meta.compound.shell punctuation.section.compound.end.shell +# <- meta.coproc.command.shell meta.compound.command.shell punctuation.section.compound.end.shell #^ - meta @@ -3033,16 +3033,16 @@ charclass=\}ower # ^^ constant.character.escape.shell (foo=bar) -# <- meta.compound.shell punctuation.section.compound.begin.shell -#^^^^^^^^ meta.compound.shell +# <- meta.compound.command.shell punctuation.section.compound.begin.shell +#^^^^^^^^ meta.compound.command.shell #^^^ meta.variable.shell variable.other.readwrite.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell # ^ punctuation.section.compound.end.shell - string-unquoted { foo=bar } -# <- meta.compound.shell punctuation.section.compound.begin.shell -#^^^^^^^^^^ meta.compound.shell +# <- meta.compound.command.shell punctuation.section.compound.begin.shell +#^^^^^^^^^^ meta.compound.command.shell # ^^^ meta.variable.shell variable.other.readwrite.shell # ^ keyword.operator.assignment.shell # ^^^ meta.string.shell string.unquoted.shell @@ -3256,7 +3256,7 @@ foo=`some-command -x` foo=`(uname -r --) 2>/dev/null` # ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell meta.interpolation.command.shell -# ^^^^^^^^^^^^^ meta.compound.shell +# ^^^^^^^^^^^^^ meta.compound.command.shell # ^ punctuation.section.interpolation.begin.shell # ^^^^^ variable.function.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell @@ -3268,7 +3268,7 @@ foo=`(uname -r --) 2>/dev/null` foo=`(uname -r) 2>/dev/null` || foo=unknown # ^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell meta.interpolation.command.shell -# ^^^^^^^^^^ meta.compound.shell +# ^^^^^^^^^^ meta.compound.command.shell # ^ punctuation.section.interpolation.begin.shell # ^^^^^ variable.function.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell @@ -3846,14 +3846,14 @@ z..2} # ^^ punctuation.section.interpolation.end.shell { : {1..21} } -# ^^^^ meta.compound.shell - meta.interpolation -# ^^^^^^^ meta.compound.shell meta.interpolation.brace.shell -# ^^ meta.compound.shell - meta.interpolation +# ^^^^ meta.compound.command.shell - meta.interpolation +# ^^^^^^^ meta.compound.command.shell meta.interpolation.brace.shell +# ^^ meta.compound.command.shell - meta.interpolation ( : {1..21} ) -# ^^^^ meta.compound.shell - meta.interpolation -# ^^^^^^^ meta.compound.shell meta.interpolation.brace.shell -# ^^ meta.compound.shell - meta.interpolation +# ^^^^ meta.compound.command.shell - meta.interpolation +# ^^^^^^^ meta.compound.command.shell meta.interpolation.brace.shell +# ^^ meta.compound.command.shell - meta.interpolation any --arg{1..4}={1..4} # ^^^^^ meta.parameter.option.shell variable.parameter.option.shell - meta.interpolation @@ -8628,10 +8628,10 @@ tr "o" "a" < <(echo "Foo") wc <(cat /usr/share/dict/linux.words) # ^ meta.function-call.arguments.shell - meta.redirection # ^ meta.function-call.arguments.shell meta.redirection.shell - meta.compound -# ^ meta.function-call.arguments.shell meta.redirection.shell meta.compound.shell - meta.function-call meta.function-call -# ^^^ meta.function-call.arguments.shell meta.redirection.shell meta.compound.shell meta.function-call.identifier.shell -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.redirection.shell meta.compound.shell meta.function-call.arguments.shell -# ^ meta.function-call.arguments.shell meta.redirection.shell meta.compound.shell - meta.function-call meta.function-call +# ^ meta.function-call.arguments.shell meta.redirection.shell meta.compound.command.shell - meta.function-call meta.function-call +# ^^^ meta.function-call.arguments.shell meta.redirection.shell meta.compound.command.shell meta.function-call.identifier.shell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.redirection.shell meta.compound.command.shell meta.function-call.arguments.shell +# ^ meta.function-call.arguments.shell meta.redirection.shell meta.compound.command.shell - meta.function-call meta.function-call # ^ keyword.operator.assignment.redirection.shell # ^ punctuation.section.compound.begin.shell # ^^^ variable.function.shell @@ -8639,10 +8639,10 @@ wc <(cat /usr/share/dict/linux.words) comm <(ls -l) <(ls -al) # ^ meta.redirection.shell - meta.compound -# ^^^^^^^ meta.redirection.shell meta.compound.shell +# ^^^^^^^ meta.redirection.shell meta.compound.command.shell # ^ - meta.redirection - meta.compound # ^ meta.redirection.shell - meta.compound -# ^^^^^^^^ meta.redirection.shell meta.compound.shell +# ^^^^^^^^ meta.redirection.shell meta.compound.command.shell # ^ - meta.redirection - meta.compound # ^ keyword.operator.assignment.redirection.shell # ^ punctuation.section.compound.begin.shell @@ -10058,7 +10058,7 @@ let test -z $2 && { } #^^ meta.function-call.identifier.shell support.function.let.shell # ^^^^^^^^^^^ meta.function-call.arguments.shell meta.arithmetic.shell # ^^^^ - meta.arithmetic - meta.compound -# ^^^ meta.compound.shell +# ^^^ meta.compound.command.shell #^^ support.function.let.shell # ^^^^ variable.other.readwrite.shell # ^ keyword.operator.arithmetic.shell diff --git a/ShellScript/test/syntax_test_shell_unix_generic.sh b/ShellScript/test/syntax_test_shell_unix_generic.sh index 3df5db6646..36ecf65c11 100644 --- a/ShellScript/test/syntax_test_shell_unix_generic.sh +++ b/ShellScript/test/syntax_test_shell_unix_generic.sh @@ -1,9 +1,9 @@ # SYNTAX TEST "Packages/ShellScript/Shell-Unix-Generic.sublime-syntax" [[ ]] -# <- support.function.test.begin - # <- support.function.test.begin - # ^^ support.function.test.end +# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell + # <- meta.compound.conditional.shell punctuation.section.compound.begin.shell + # ^^ meta.compound.conditional.shell punctuation.section.compound.end.shell # make sure the prototype is included # <- comment.line.number-sign punctuation.definition.comment From 05b9ea57331ba655ea860255cf502d14c00655f1 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Thu, 1 Aug 2024 21:16:38 +0200 Subject: [PATCH 041/113] [ShellScript] Refacotr case clauses This commit... 1. scopes case statements `meta.statement.case` 2. scopes case clauses `meta.clause.[pattern|body]` 3. scopes case pattern parens `punctuation.definition.pattern.[begin|end]` ... in order to prepare for syntax based folding and align with scope naming guidelines with regards to punctuation. --- ShellScript/Bash.sublime-syntax | 39 +++-- ShellScript/test/syntax_test_bash.sh | 241 +++++++++++++++------------ 2 files changed, 153 insertions(+), 127 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index c78686b313..7978af4a4b 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -1335,8 +1335,8 @@ contexts: - match: else{{cmd_break}} scope: keyword.control.conditional.else.shell - match: case{{cmd_break}} - scope: keyword.control.conditional.case.shell - push: [case-meta, case-word] + scope: meta.statement.conditional.case.shell keyword.control.conditional.case.shell + push: case-word - match: esac{{cmd_break}} scope: keyword.control.conditional.end.shell # loops @@ -1368,17 +1368,14 @@ contexts: scope: keyword.control.flow.return.shell push: flow-args - case-meta: - - meta_include_prototype: false - - meta_scope: meta.conditional.case.shell - - include: immediately-pop - case-end: - match: esac{{cmd_break}} scope: keyword.control.conditional.end.shell pop: 1 case-word: + - meta_include_prototype: false + - meta_content_scope: meta.statement.conditional.case.word.shell - match: in{{cmd_break}} scope: keyword.control.in.shell set: case-body @@ -1388,23 +1385,21 @@ contexts: - include: cmd-args-values case-body: + - meta_include_prototype: false + - meta_scope: meta.statement.conditional.case.shell - include: case-end - include: comments - match: \(|(?=\S) - scope: keyword.control.conditional.patterns.begin.shell - push: - - case-clause-commands - - case-clause-patterns + scope: meta.clause.pattern.shell punctuation.definition.pattern.begin.shell + push: case-clause-patterns case-clause-patterns: - - meta_scope: meta.patterns.shell - - meta_content_scope: meta.string.regexp.shell string.unquoted.shell + - meta_content_scope: meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell - match: \) - scope: keyword.control.conditional.patterns.end.shell - pop: 1 + scope: meta.clause.pattern.shell punctuation.definition.pattern.end.shell + set: case-clause-commands # emergency bail outs if ')' is missing - - match: (?=;;&?|;&) - pop: 1 + - include: case-clause-end - include: line-continuations - include: case-clause-pattern-content @@ -1424,12 +1419,16 @@ contexts: - include: case-clause-pattern-content case-clause-commands: - - match: ;;&?|;& - scope: punctuation.terminator.case.clause.shell - pop: 1 + - meta_content_scope: meta.clause.body.shell + - include: case-clause-end - include: case-end-ahead - include: statements + case-clause-end: + - match: ;;&?|;& + scope: meta.clause.shell punctuation.terminator.clause.shell + pop: 1 + case-end-ahead: - match: (?=esac{{cmd_break}}) pop: 1 diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index f74266e012..2e7201910f 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -1850,49 +1850,52 @@ case- esac # <- keyword.control.conditional.end.shell -#^^^ keyword.control.conditional.end.shell - meta.conditional.case +#^^^ keyword.control.conditional.end.shell - meta.statement.conditional.case case -# <- meta.conditional.case.shell keyword.control.conditional.case.shell -#^^^ meta.conditional.case.shell keyword.control.conditional.case.shell +# <- keyword.control.conditional.case.shell +#^^^ keyword.control.conditional.case.shell esac -# <- meta.conditional.case.shell keyword.control.conditional.end.shell -#^^^ meta.conditional.case.shell keyword.control.conditional.end.shell +# <- keyword.control.conditional.end.shell +#^^^ keyword.control.conditional.end.shell case var in ( patt ( esac -#^ meta.conditional.case.shell -# ^ meta.patterns.shell - meta.string - meta.group - string -# ^^^^^^ meta.patterns.shell meta.string.regexp.shell string.unquoted.shell - meta.group -# ^^ meta.patterns.shell meta.string.regexp.shell meta.group.regexp.shell string.unquoted.shell -# ^^^^ meta.conditional.case.shell -# ^ keyword.control.conditional.patterns.begin.shell +#^ meta.statement.conditional.case.shell +# ^ meta.clause.pattern.shell - meta.string - meta.group - string +# ^^^^^^ meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell - meta.group +# ^^ meta.clause.pattern.shell meta.string.regexp.shell meta.group.regexp.shell string.unquoted.shell +# ^^^^ meta.statement.conditional.case.shell +# ^ punctuation.definition.pattern.begin.shell # ^ punctuation.definition.group.begin.regexp.shell -# ^^^^ meta.conditional.case.shell keyword.control.conditional.end.shell +# ^^^^ keyword.control.conditional.end.shell # ^ - meta.conditional case # comment -#^^^^^^^^^^^^^^^^ meta.conditional.case.shell +#^^^ meta.statement.conditional.case.shell +# ^^^^^^^^^^^^^ meta.statement.conditional.case.word.shell #^^^ keyword.control.conditional.case.shell # ^^^^^^^^^^ comment.line.number-sign.shell var # comment -#^^^^^^^^^^^^^^^^ meta.conditional.case.shell +#^^^^^^^^^^^^^^^^ meta.statement.conditional.case.word.shell # ^^^^^^^^^^ comment.line.number-sign.shell in # comment -#^^^^^^^^^^^^^^^^^ meta.conditional.case.shell +# <- meta.statement.conditional.case.word.shell +#^ meta.statement.conditional.case.word.shell +# ^^^^^^^^^^^^^^^^ meta.statement.conditional.case.shell # ^^ keyword.control.in.shell # ^^^^^^^^^^ comment.line.number-sign.shell pattern) # comment -#^ meta.conditional.case.shell -# ^^^^^^^ meta.conditional.case.shell meta.patterns.shell meta.string.regexp.shell string.unquoted.shell - meta.group -# ^ meta.patterns.shell - meta.string - meta.group - string -# ^^^^^^^^^^^ meta.conditional.case.shell - meta.patterns +#^ meta.statement.conditional.case.shell +# ^^^^^^^ meta.statement.conditional.case.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell - meta.group +# ^ meta.clause.pattern.shell - meta.clause.body - meta.string - meta.group - string +# ^^^^^^^^^^^ meta.statement.conditional.case.shell meta.clause.body.shell - meta.clause.pattern # ^^^^^^^^^^ comment.line.number-sign.shell esac -# <- meta.conditional.case.shell keyword.control.conditional.end.shell -#^^^ meta.conditional.case.shell keyword.control.conditional.end.shell +# <- meta.statement.conditional.case.shell keyword.control.conditional.end.shell +#^^^ meta.statement.conditional.case.shell keyword.control.conditional.end.shell case "$1" in @@ -1904,32 +1907,45 @@ case "$1" in # ^ meta.string.shell string.quoted.double.shell punctuation.definition.string.end.shell # ^^ keyword.control.in.shell setup ) +# <- meta.statement.conditional.case.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell +#^^^^^ meta.statement.conditional.case.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell +# ^ meta.statement.conditional.case.shell meta.clause.pattern.shell punctuation.definition.pattern.end.shell # <- - variable.function - support.function - meta.function-call -# ^ keyword.control.conditional.patterns.end.shell +# ^ punctuation.definition.pattern.end.shell echo Preparing the server... -# <- meta.function-call support.function.echo -# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments +# <- meta.statement.conditional.case.shell meta.clause.body.shell meta.function-call.identifier.shell support.function.echo.shell +#^^^ meta.statement.conditional.case.shell meta.clause.body.shell meta.function-call.identifier.shell support.function.echo.shell +# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.statement.conditional.case.shell meta.clause.body.shell meta.function-call.arguments.shell ;; -# <- punctuation.terminator.case.clause.shell -#^ punctuation.terminator.case.clause.shell +# <- meta.statement.conditional.case.shell meta.clause.shell punctuation.terminator.clause.shell +#^ meta.statement.conditional.case.shell meta.clause.shell punctuation.terminator.clause.shell +# ^ meta.statement.conditional.case.shell - meta.clause dep\ loy ) +# <- meta.statement.conditional.case.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell +#^^^ meta.statement.conditional.case.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell +# ^ meta.statement.conditional.case.shell meta.clause.pattern.shell punctuation.definition.pattern.end.shell # <- - variable.function - support.function - meta.function-call -# ^ keyword.control.conditional.patterns.end.shell +# ^ punctuation.definition.pattern.end.shell echo Deploying... -# <- meta.function-call support.function.echo -# ^^^^^^^^^^^^^ meta.function-call.arguments +# <- meta.statement.conditional.case.shell meta.clause.body.shell meta.function-call.identifier.shell support.function.echo.shell +#^^^ meta.statement.conditional.case.shell meta.clause.body.shell meta.function-call.identifier.shell support.function.echo.shell +# ^^^^^^^^^^^^^ meta.statement.conditional.case.shell meta.clause.body.shell meta.function-call.arguments.shell ;; -# <- punctuation.terminator.case.clause.shell -#^ punctuation.terminator.case.clause.shell +# <- meta.statement.conditional.case.shell meta.clause.shell punctuation.terminator.clause.shell +#^ meta.statement.conditional.case.shell meta.clause.shell punctuation.terminator.clause.shell +# ^ meta.statement.conditional.case.shell - meta.clause * ) -# <- constant.other.wildcard.asterisk.shell -# ^ keyword.control.conditional.patterns.end.shell +# <- meta.statement.conditional.case.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell constant.other.wildcard.asterisk.shell +#^ meta.statement.conditional.case.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell +# ^ meta.statement.conditional.case.shell meta.clause.pattern.shell punctuation.definition.pattern.end.shell +# ^ meta.statement.conditional.case.shell meta.clause.body.shell cat <<'ENDCAT' # comment -# <- meta.function-call.identifier.shell variable.function.shell -# ^^ meta.function-call.arguments.shell - meta.string - meta.tag -# ^^^^^^^^ meta.function-call.arguments.shell meta.string.heredoc.shell meta.tag.heredoc.shell - string.unquoted.heredoc -# ^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.heredoc.shell - meta.tag - string.unquoted.heredoc +# <- meta.statement.conditional.case.shell meta.clause.body.shell meta.function-call.identifier.shell meta.path.shell variable.function.shell +#^^ meta.statement.conditional.case.shell meta.clause.body.shell meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^ meta.statement.conditional.case.shell meta.clause.body.shell meta.function-call.arguments.shell - meta.string - meta.tag +# ^^^^^^^^ meta.statement.conditional.case.shell meta.clause.body.shell meta.function-call.arguments.shell meta.string.heredoc.shell meta.tag.heredoc.shell - string.unquoted.heredoc +# ^^^^^^^^^^^ meta.statement.conditional.case.shell meta.clause.body.shell meta.function-call.arguments.shell meta.string.heredoc.shell - meta.tag - string.unquoted.heredoc # ^^ keyword.operator.assignment.redirection.shell # ^ punctuation.definition.tag.begin.shell - entity # ^^^^^^ entity.name.tag.heredoc.shell @@ -1939,17 +1955,20 @@ cat <<'ENDCAT' # comment foo # <- meta.function-call.arguments.shell meta.string.heredoc.shell string.unquoted.heredoc.shell ENDCAT -# <- meta.function-call.arguments.shell meta.string.heredoc.shell meta.tag.heredoc.shell entity.name.tag.heredoc.shell +# <- meta.statement.conditional.case.shell meta.clause.body.shell meta.function-call.arguments.shell meta.string.heredoc.shell meta.tag.heredoc.shell entity.name.tag.heredoc.shell ;; -# <- punctuation.terminator.case.clause.shell -#^ punctuation.terminator.case.clause.shell +# <- meta.statement.conditional.case.shell meta.clause.shell punctuation.terminator.clause.shell +#^ meta.statement.conditional.case.shell meta.clause.shell punctuation.terminator.clause.shell +# ^ meta.statement.conditional.case.shell - meta.clause esac -# <- meta.conditional.case.shell keyword.control.conditional.end.shell -#^^^ meta.conditional.case.shell keyword.control.conditional.end.shell +# <- meta.statement.conditional.case.shell keyword.control.conditional.end.shell +#^^^ meta.statement.conditional.case.shell keyword.control.conditional.end.shell case "${foo}" in- in_ in=10 in -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.case.shell +#^^^ meta.statement.conditional.case.shell +# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.statement.conditional.case.word.shell +# ^^^ meta.statement.conditional.case.shell # <- keyword.control.conditional.case.shell #^^^ keyword.control.conditional.case.shell # ^^ - keyword.control.in @@ -1957,52 +1976,60 @@ case "${foo}" in- in_ in=10 in # ^^ - keyword.control.in # ^^ keyword.control.in ( help | h ) bar ;; -#^^^ meta.conditional.case.shell - meta.patterns -# ^ meta.patterns.shell - meta.string - meta.group - string -# ^^^^^^^^^^ meta.conditional.case.shell meta.patterns.shell meta.string.regexp.shell string.unquoted.shell - meta.group -# ^ meta.patterns.shell - meta.string - meta.group - string -# ^^^^^^^^ meta.conditional.case.shell - meta.patterns - # <- keyword.control.conditional.patterns.begin.shell - # ^ keyword.control.conditional.patterns.end.shell - # ^^ punctuation.terminator.case.clause.shell +#^^^ meta.statement.conditional.case.shell - meta.clause.pattern +# ^ meta.clause.pattern.shell - meta.string - meta.group - string +# ^^^^^^^^^^ meta.statement.conditional.case.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell - meta.group +# ^ meta.clause.pattern.shell - meta.string - meta.group - string +# ^^^^^ meta.statement.conditional.case.shell meta.clause.body.shell - meta.clause.pattern +# ^^ meta.statement.conditional.case.shell meta.clause.shell +# ^ meta.statement.conditional.case.shell - meta.clause +# ^ punctuation.definition.pattern.begin.shell +# ^ keyword.operator.logical.regexp.shell +# ^ punctuation.definition.pattern.end.shell +# ^^ punctuation.terminator.clause.shell do1 ) foo1 ;& -#^^^ meta.conditional.case.shell - meta.patterns -# ^^^^ meta.conditional.case.shell meta.patterns.shell meta.string.regexp.shell string.unquoted.shell - meta.group -# ^ meta.patterns.shell - meta.string - meta.group - string -# ^^^^^^^^^ meta.conditional.case.shell - meta.patterns - # ^ keyword.control.conditional.patterns.end.shell - # ^^ punctuation.terminator.case.clause.shell +#^^^ meta.statement.conditional.case.shell - meta.clause.pattern +# ^^^^ meta.statement.conditional.case.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell - meta.group +# ^ meta.clause.pattern.shell - meta.string - meta.group - string +# ^^^^^^ meta.statement.conditional.case.shell meta.clause.body.shell - meta.clause.pattern +# ^^ meta.statement.conditional.case.shell meta.clause.shell +# ^ meta.statement.conditional.case.shell - meta.clause +# ^ punctuation.definition.pattern.end.shell +# ^^ punctuation.terminator.clause.shell (do2 ) foo2 ;;& -#^^^ meta.conditional.case.shell - meta.patterns -# ^ meta.patterns.shell - meta.string - meta.group - string -# ^^^^ meta.conditional.case.shell meta.patterns.shell meta.string.regexp.shell string.unquoted.shell - meta.group -# ^ meta.patterns.shell - meta.string - meta.group - string -# ^^^^^^^^^^ meta.conditional.case.shell - meta.patterns - # <- keyword.control.conditional.patterns.begin.shell - # ^ keyword.control.conditional.patterns.end.shell - # ^^^ punctuation.terminator.case.clause.shell +#^^^ meta.statement.conditional.case.shell - meta.clause.pattern +# ^ meta.clause.pattern.shell - meta.string - meta.group - string +# ^^^^ meta.statement.conditional.case.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell - meta.group +# ^ meta.clause.pattern.shell - meta.string - meta.group - string +# ^^^^^^ meta.statement.conditional.case.shell meta.clause.body.shell +# ^^^ meta.statement.conditional.case.shell meta.clause.shell +# ^ meta.statement.conditional.case.shell - meta.clause +# ^ punctuation.definition.pattern.begin.shell +# ^ punctuation.definition.pattern.end.shell +# ^^^ punctuation.terminator.clause.shell *) bar -#^^^ meta.conditional.case.shell - meta.patterns -# ^ meta.conditional.case.shell meta.patterns.shell meta.string.regexp.shell string.unquoted.shell - meta.group -# ^ meta.patterns.shell - meta.string - meta.group - string -# ^^^^^ meta.conditional.case.shell - meta.patterns - #^ keyword.control.conditional.patterns.end.shell +#^^^ meta.statement.conditional.case.shell - meta.clause.pattern +# ^ meta.statement.conditional.case.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell - meta.group +# ^ meta.clause.pattern.shell - meta.string - meta.group - string +# ^^^^^ meta.statement.conditional.case.shell meta.clause.body.shell +# ^ meta.string.regexp.shell string.unquoted.shell constant.other.wildcard.asterisk.shell +# ^ punctuation.definition.pattern.end.shell esac -# <- meta.conditional.case.shell keyword.control.conditional.end.shell -#^^^ meta.conditional.case.shell keyword.control.conditional.end.shell +# <- meta.statement.conditional.case.shell keyword.control.conditional.end.shell +#^^^ meta.statement.conditional.case.shell keyword.control.conditional.end.shell # ^ - meta.conditional - keyword case $TERM in sun-cmd) - # ^ keyword.control.conditional.patterns.end.shell + # ^ punctuation.definition.pattern.end.shell update_terminal_cwd() { print -Pn "\e]l%~\e\\" };; # ^ meta.function punctuation.section.block.end.shell - # ^^ punctuation.terminator.case.clause.shell + # ^^ punctuation.terminator.clause.shell *xterm*|rxvt|(dt|k|E)term) - #^^^^^^^^ meta.patterns.shell meta.string.regexp.shell string.unquoted.shell - # ^^^^^^^^ meta.patterns.shell meta.string.regexp.shell meta.group.regexp.shell string.unquoted.shell - # ^^^^ meta.patterns.shell meta.string.regexp.shell string.unquoted.shell - # ^ meta.patterns.shell - meta.string - meta.group - string + #^^^^^^^^ meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell + # ^^^^^^^^ meta.clause.pattern.shell meta.string.regexp.shell meta.group.regexp.shell string.unquoted.shell + # ^^^^ meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell + # ^ meta.clause.pattern.shell - meta.string - meta.group - string # ^ constant.other.wildcard.asterisk.shell # ^ keyword.operator.logical.regexp.shell # ^ keyword.operator.logical.regexp.shell @@ -2010,26 +2037,26 @@ case $TERM in # ^ keyword.operator.logical.regexp.shell # ^ keyword.operator.logical.regexp.shell # ^ punctuation.definition.group.end.regexp.shell - # ^ keyword.control.conditional.patterns.end.shell + # ^ punctuation.definition.pattern.end.shell update_terminal_cwd() { print -Pn "\e]2;%~\a" };; # ^ meta.function punctuation.section.block.end.shell - # ^^ punctuation.terminator.case.clause.shell + # ^^ punctuation.terminator.clause.shell *) - # <- meta.patterns.shell meta.string.regexp.shell string.unquoted.shell constant.other.wildcard.asterisk.shell - #^ keyword.control.conditional.patterns.end.shell + # <- meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell constant.other.wildcard.asterisk.shell + #^ punctuation.definition.pattern.end.shell update_terminal_cwd() {};; # ^ meta.function punctuation.section.block.end.shell - # ^^ punctuation.terminator.case.clause.shell + # ^^ punctuation.terminator.clause.shell esac # <- keyword.control.conditional.end.shell case $SERVER in # <- keyword.control.conditional.case.shell ws-+([0-9]).host.com) echo "Web Server" -#^^^ meta.patterns.shell meta.string.regexp.shell - meta.group -# ^^^^^^^ meta.patterns.shell meta.string.regexp.shell meta.group.regexp.shell -# ^^^^^^^^^ meta.patterns.shell meta.string.regexp.shell - meta.group -# ^ meta.patterns.shell - meta.string - meta.group - string +#^^^ meta.clause.pattern.shell meta.string.regexp.shell - meta.group +# ^^^^^^^ meta.clause.pattern.shell meta.string.regexp.shell meta.group.regexp.shell +# ^^^^^^^^^ meta.clause.pattern.shell meta.string.regexp.shell - meta.group +# ^ meta.clause.pattern.shell - meta.string - meta.group - string #^^^^^^^^^^^^^^^^^^^ string.unquoted.shell # ^ keyword.operator.quantifier.regexp.shell # ^ punctuation.definition.group.begin.regexp.shell @@ -2038,14 +2065,14 @@ ws-+([0-9]).host.com) echo "Web Server" # ^ punctuation.separator.sequence.regexp.shell # ^ punctuation.definition.set.end.regexp.shell # ^ punctuation.definition.group.end.regexp.shell -# ^ keyword.control.conditional.patterns.end.shell +# ^ punctuation.definition.pattern.end.shell ;; -# <- punctuation.terminator.case.clause.shell -#^ punctuation.terminator.case.clause.shell +# <- punctuation.terminator.clause.shell +#^ punctuation.terminator.clause.shell db-+([0-9])\.host\.com) echo "DB server" -#^^^ meta.patterns.shell meta.string.regexp.shell - meta.group -# ^^^^^^^ meta.patterns.shell meta.string.regexp.shell meta.group.regexp.shell -# ^^^^^^^^^^^ meta.patterns.shell meta.string.regexp.shell - meta.group +#^^^ meta.clause.pattern.shell meta.string.regexp.shell - meta.group +# ^^^^^^^ meta.clause.pattern.shell meta.string.regexp.shell meta.group.regexp.shell +# ^^^^^^^^^^^ meta.clause.pattern.shell meta.string.regexp.shell - meta.group # ^ keyword.operator.quantifier.regexp.shell # ^ punctuation.definition.group.begin.regexp.shell # ^ punctuation.definition.set.begin.regexp.shell @@ -2053,10 +2080,10 @@ db-+([0-9])\.host\.com) echo "DB server" # ^ punctuation.separator.sequence.regexp.shell # ^ punctuation.definition.set.end.regexp.shell # ^ punctuation.definition.group.end.regexp.shell -# ^ keyword.control.conditional.patterns.end.shell +# ^ punctuation.definition.pattern.end.shell ;; -# <- punctuation.terminator.case.clause.shell -#^ punctuation.terminator.case.clause.shell +# <- punctuation.terminator.clause.shell +#^ punctuation.terminator.clause.shell bk-+([0-9])\.host\.com) echo "Backup server" # ^ keyword.operator.quantifier.regexp.shell # ^ punctuation.definition.group.begin.regexp.shell @@ -2065,18 +2092,18 @@ bk-+([0-9])\.host\.com) echo "Backup server" # ^ punctuation.separator.sequence.regexp.shell # ^ punctuation.definition.set.end.regexp.shell # ^ punctuation.definition.group.end.regexp.shell -# ^ keyword.control.conditional.patterns.end.shell +# ^ punctuation.definition.pattern.end.shell # ^^^^ support.function.echo.shell ;; -# <- punctuation.terminator.case.clause.shell -#^ punctuation.terminator.case.clause.shell +# <- punctuation.terminator.clause.shell +#^ punctuation.terminator.clause.shell *)echo "Unknown server" # <- constant.other.wildcard.asterisk.shell -#^ keyword.control.conditional.patterns.end.shell +#^ punctuation.definition.pattern.end.shell # ^^^^ support.function.echo.shell ;; -# <- punctuation.terminator.case.clause.shell -#^ punctuation.terminator.case.clause.shell +# <- punctuation.terminator.clause.shell +#^ punctuation.terminator.clause.shell esac # <- keyword.control.conditional.end.shell #^^^ keyword.control.conditional.end.shell @@ -2860,7 +2887,7 @@ __git_aliased_command () case "$word" in {) : skip start of shell helper function ;; # ^ - punctuation.section.interpolation.begin -# ^ keyword.control.conditional.patterns.end.shell +# ^ punctuation.definition.pattern.end.shell \'*) : skip opening quote after sh -c ;; *) echo "$word" @@ -10207,20 +10234,20 @@ f() { $1) local "$x"'+=(1)' ;;& # <- keyword.declaration.variable.shell - # ^^^ punctuation.terminator.case.clause.shell + # ^^^ punctuation.terminator.clause.shell $2) local "$x"'+=(2)' ;& # <- keyword.declaration.variable.shell - # ^^ punctuation.terminator.case.clause.shell + # ^^ punctuation.terminator.clause.shell $3) local "$x"'+=(3)' ;; # <- keyword.declaration.variable.shell - # ^^ punctuation.terminator.case.clause.shell + # ^^ punctuation.terminator.clause.shell $1|$2) local "$x"'+=(4)' # <- keyword.declaration.variable.shell esac - # <- meta.function.body.shell meta.block.shell meta.conditional.case.shell + # <- meta.function.body.shell meta.block.shell meta.statement.conditional.case.shell # <- keyword.control.conditional.end.shell IFS=, local -a "$x"'=("${x}: ${'"$x"'[*]}")' From c84458af821a74074d53715799755e3940f5feea Mon Sep 17 00:00:00 2001 From: deathaxe Date: Thu, 1 Aug 2024 16:54:56 +0200 Subject: [PATCH 042/113] [ShellScript] Verify eval command higlighting --- ShellScript/test/syntax_test_bash.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index 2e7201910f..08b23cf36a 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -9687,6 +9687,32 @@ printFunction "$variableString1" "`declare -p variableArray`" # ^ punctuation.section.interpolation.end.shell +############################################################################### +# 4.2 Bash Builtin Commands (eval) # +# https://www.gnu.org/software/bash/manual/bash.html#index-eval # +############################################################################### + +eval +# <- meta.function-call.identifier.shell support.function.eval.shell +#^^^ meta.function-call.identifier.shell support.function.eval.shell + +eval ls . +# <- meta.function-call.identifier.shell support.function.eval.shell +#^^^ meta.function-call.identifier.shell support.function.eval.shell +# ^^^^^ meta.function-call.arguments.shell +# ^^ meta.string.shell string.unquoted.shell +# ^ meta.string.shell string.unquoted.shell + +eval "echo Helo ${name:a " + 2":$len}" ! +# <- meta.function-call.identifier.shell support.function.eval.shell +#^^^ meta.function-call.identifier.shell support.function.eval.shell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell +# ^^^^^^^^^^^ meta.string.shell string.quoted.double.shell +# ^^^^^^^^^^^^^^^^^^^^^ meta.string.shell meta.interpolation.parameter.shell +# ^ meta.string.shell string.quoted.double.shell punctuation.definition.string.end.shell +# ^ meta.string.shell string.unquoted.shell + + ############################################################################### # 4.2 Bash Builtin Commands (exec) # # https://www.gnu.org/software/bash/manual/bash.html#index-exec # From 02c7a78dc0f60204c9e93806968594e61312136b Mon Sep 17 00:00:00 2001 From: deathaxe Date: Thu, 1 Aug 2024 21:46:39 +0200 Subject: [PATCH 043/113] [ShellScript] Fix single statement termination --- ShellScript/Bash.sublime-syntax | 4 +--- ShellScript/test/syntax_test_bash.sh | 7 +++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 7978af4a4b..5dd6528b74 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -264,8 +264,6 @@ contexts: statement: - include: redirections - - include: operators - - include: terminators - include: def-anonymous - include: cmd-alias - include: cmd-arithmetic @@ -286,9 +284,9 @@ contexts: - include: def-variables - include: def-functions - include: booleans + - include: eoc-pop - include: cmd-basic - include: illegal-stray - - include: eol-pop ###[ COMMENTS ]################################################################ diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index 08b23cf36a..027cf68997 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -2215,10 +2215,9 @@ coproc ls thisfiledoesntexist; read; 2>&1 # ^ meta.coproc.command.shell # ^^ meta.coproc.command.shell meta.function-call.identifier.shell # ^^^^^^^^^^^^^^^^^^^^ meta.coproc.command.shell meta.function-call.arguments.shell -# ^^ meta.coproc.command.shell - meta.function-call.identifier.shell -# ^^^^ meta.coproc.command.shell meta.function-call.identifier.shell -# ^^^^^^ meta.coproc.command.shell - meta.function-call.identifier.shell -# ^ - meta.coproc +# ^^^^^^^^^^^^^ - meta.coproc +# ^^^^ meta.function-call.identifier.shell +# ^^^^^^ - meta.function-call.identifier.shell #^^^^^ keyword.declaration.coproc.shell # ^^ variable.function.shell # ^ punctuation.terminator.statement.shell From 7dc59cdf3078c521f2cbc81ff4704444900f03a7 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Fri, 2 Aug 2024 12:14:34 +0200 Subject: [PATCH 044/113] [ShellScript] Fix indentation rules This commit... 1. adds indentation rules for case clauses 2. fixes indentation rules for if statements 3. adds indentation tests 4. adjusts code style of indentation rules --- ShellScript/Bash.sublime-syntax | 43 +++-- ...Rules - Case Clause Patterns.tmPreferences | 14 ++ .../Indentation Rules - Case.tmPreferences | 18 ++ ...Indentation Rules - Comments.tmPreferences | 12 ++ ShellScript/Indentation Rules.tmPreferences | 41 +++-- ShellScript/test/syntax_test_bash.sh | 168 +++++++++--------- .../test/syntax_test_reindent_case.bash | 99 +++++++++++ .../test/syntax_test_reindent_for.bash | 115 ++++++++++++ ShellScript/test/syntax_test_reindent_if.bash | 122 +++++++++++++ .../test/syntax_test_reindent_select.bash | 37 ++++ .../test/syntax_test_reindent_until.bash | 32 ++++ .../test/syntax_test_reindent_while.bash | 32 ++++ 12 files changed, 626 insertions(+), 107 deletions(-) create mode 100644 ShellScript/Indentation Rules - Case Clause Patterns.tmPreferences create mode 100644 ShellScript/Indentation Rules - Case.tmPreferences create mode 100644 ShellScript/Indentation Rules - Comments.tmPreferences create mode 100644 ShellScript/test/syntax_test_reindent_case.bash create mode 100644 ShellScript/test/syntax_test_reindent_for.bash create mode 100644 ShellScript/test/syntax_test_reindent_if.bash create mode 100644 ShellScript/test/syntax_test_reindent_select.bash create mode 100644 ShellScript/test/syntax_test_reindent_until.bash create mode 100644 ShellScript/test/syntax_test_reindent_while.bash diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 5dd6528b74..e798dea557 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -1336,7 +1336,7 @@ contexts: scope: meta.statement.conditional.case.shell keyword.control.conditional.case.shell push: case-word - match: esac{{cmd_break}} - scope: keyword.control.conditional.end.shell + scope: keyword.control.conditional.endcase.shell # loops - match: do{{cmd_break}} scope: keyword.control.loop.do.shell @@ -1366,16 +1366,11 @@ contexts: scope: keyword.control.flow.return.shell push: flow-args - case-end: - - match: esac{{cmd_break}} - scope: keyword.control.conditional.end.shell - pop: 1 - case-word: - meta_include_prototype: false - meta_content_scope: meta.statement.conditional.case.word.shell - match: in{{cmd_break}} - scope: keyword.control.in.shell + scope: meta.statement.conditional.case.shell keyword.control.conditional.in.shell set: case-body - include: case-end - include: comments @@ -1383,24 +1378,34 @@ contexts: - include: cmd-args-values case-body: - - meta_include_prototype: false - - meta_scope: meta.statement.conditional.case.shell + - meta_content_scope: meta.statement.conditional.case.body.shell - include: case-end - include: comments + - include: case-clauses + + case-clauses: - match: \(|(?=\S) scope: meta.clause.pattern.shell punctuation.definition.pattern.begin.shell - push: case-clause-patterns + push: case-clause-pattern - case-clause-patterns: + case-clause-pattern: - meta_content_scope: meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell - match: \) scope: meta.clause.pattern.shell punctuation.definition.pattern.end.shell - set: case-clause-commands + set: case-clause-after-pattern # emergency bail outs if ')' is missing - include: case-clause-end - include: line-continuations - include: case-clause-pattern-content + case-clause-after-pattern: + # required to handle scope specific indentation rules + - meta_include_prototype: false + - meta_content_scope: meta.clause.shell + - include: comments + - match: ^|(?=\S) + set: case-clause-body + case-clause-pattern-content: # [Bash] 3.2.4.2: Each pattern undergoes tilde expansion, parameter # expansion, command substitution, and arithmetic expansion. @@ -1416,7 +1421,7 @@ contexts: - include: pattern-group-end - include: case-clause-pattern-content - case-clause-commands: + case-clause-body: - meta_content_scope: meta.clause.body.shell - include: case-clause-end - include: case-end-ahead @@ -1427,6 +1432,18 @@ contexts: scope: meta.clause.shell punctuation.terminator.clause.shell pop: 1 + case-end: + - match: esac{{cmd_break}} + scope: keyword.control.conditional.endcase.shell + set: case-end-meta + + case-end-meta: + # This context is required for case...esac specific + # indentation rules to be correctly applied. + - meta_include_prototype: false + - meta_scope: meta.statement.conditional.case.end.shell + - include: immediately-pop + case-end-ahead: - match: (?=esac{{cmd_break}}) pop: 1 diff --git a/ShellScript/Indentation Rules - Case Clause Patterns.tmPreferences b/ShellScript/Indentation Rules - Case Clause Patterns.tmPreferences new file mode 100644 index 0000000000..c390cfde45 --- /dev/null +++ b/ShellScript/Indentation Rules - Case Clause Patterns.tmPreferences @@ -0,0 +1,14 @@ + + + + scope + meta.clause.pattern.shell, meta.clause.shell + settings + + decreaseIndentPattern + . + increaseIndentPattern + . + + + diff --git a/ShellScript/Indentation Rules - Case.tmPreferences b/ShellScript/Indentation Rules - Case.tmPreferences new file mode 100644 index 0000000000..fe875fd805 --- /dev/null +++ b/ShellScript/Indentation Rules - Case.tmPreferences @@ -0,0 +1,18 @@ + + + + scope + source.shell meta.statement.conditional.case + settings + + decreaseIndentPattern + + increaseIndentPattern + + bracketIndentNextLinePattern + + disableIndentNextLinePattern + + + + diff --git a/ShellScript/Indentation Rules - Comments.tmPreferences b/ShellScript/Indentation Rules - Comments.tmPreferences new file mode 100644 index 0000000000..affbcae205 --- /dev/null +++ b/ShellScript/Indentation Rules - Comments.tmPreferences @@ -0,0 +1,12 @@ + + + + scope + source.shell comment.line + settings + + preserveIndent + + + + diff --git a/ShellScript/Indentation Rules.tmPreferences b/ShellScript/Indentation Rules.tmPreferences index 1013a025a4..a62726dd9b 100644 --- a/ShellScript/Indentation Rules.tmPreferences +++ b/ShellScript/Indentation Rules.tmPreferences @@ -2,23 +2,40 @@ scope - source.shell - comment - string + + source.shell, + meta.clause.body.shell + settings decreaseIndentPattern - ^\s*(\}|(elif|else|fi|esac|done)\b) + increaseIndentPattern - (?x) - ^\s*(elif|else|case)\b - | ^.*(\{|\b(do)\b)\s*$ - | ^.*\bthen\b\s*$ - - indentNextLinePattern - ^.*[^\\]\\$ + disableIndentNextLinePattern - ^\s*then\s*$ - bracketIndentNextLinePattern - ^\s*if\b.*(?!\bthen\b)$ + + + indentParens + + indentSquareBrackets + + preserveIndent + diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index 027cf68997..04e705f444 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -1849,27 +1849,27 @@ case- #^^^^ - keyword esac -# <- keyword.control.conditional.end.shell -#^^^ keyword.control.conditional.end.shell - meta.statement.conditional.case +# <- keyword.control.conditional.endcase.shell +#^^^ keyword.control.conditional.endcase.shell - meta.statement.conditional.case case # <- keyword.control.conditional.case.shell #^^^ keyword.control.conditional.case.shell esac -# <- keyword.control.conditional.end.shell -#^^^ keyword.control.conditional.end.shell +# <- keyword.control.conditional.endcase.shell +#^^^ keyword.control.conditional.endcase.shell case var in ( patt ( esac -#^ meta.statement.conditional.case.shell +#^ meta.statement.conditional.case.body.shell # ^ meta.clause.pattern.shell - meta.string - meta.group - string # ^^^^^^ meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell - meta.group # ^^ meta.clause.pattern.shell meta.string.regexp.shell meta.group.regexp.shell string.unquoted.shell -# ^^^^ meta.statement.conditional.case.shell +# ^^^^ meta.statement.conditional.case.end.shell # ^ punctuation.definition.pattern.begin.shell # ^ punctuation.definition.group.begin.regexp.shell -# ^^^^ keyword.control.conditional.end.shell +# ^^^^ keyword.control.conditional.endcase.shell # ^ - meta.conditional @@ -1884,18 +1884,19 @@ case # comment in # comment # <- meta.statement.conditional.case.word.shell #^ meta.statement.conditional.case.word.shell -# ^^^^^^^^^^^^^^^^ meta.statement.conditional.case.shell -# ^^ keyword.control.in.shell +# ^^ meta.statement.conditional.case.shell +# ^^^^^^^^^^^^^ meta.statement.conditional.case.body.shell +# ^^ keyword.control.conditional.in.shell # ^^^^^^^^^^ comment.line.number-sign.shell pattern) # comment -#^ meta.statement.conditional.case.shell -# ^^^^^^^ meta.statement.conditional.case.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell - meta.group +#^ meta.statement.conditional.case.body.shell +# ^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell - meta.group # ^ meta.clause.pattern.shell - meta.clause.body - meta.string - meta.group - string -# ^^^^^^^^^^^ meta.statement.conditional.case.shell meta.clause.body.shell - meta.clause.pattern +# ^^^^^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.shell - meta.clause.pattern # ^^^^^^^^^^ comment.line.number-sign.shell esac -# <- meta.statement.conditional.case.shell keyword.control.conditional.end.shell -#^^^ meta.statement.conditional.case.shell keyword.control.conditional.end.shell +# <- meta.statement.conditional.case.end.shell keyword.control.conditional.endcase.shell +#^^^ meta.statement.conditional.case.end.shell keyword.control.conditional.endcase.shell case "$1" in @@ -1905,47 +1906,47 @@ case "$1" in # ^ meta.string.shell meta.interpolation.parameter.shell variable.language.positional.shell punctuation.definition.variable.shell # ^ meta.string.shell meta.interpolation.parameter.shell variable.language.positional.shell # ^ meta.string.shell string.quoted.double.shell punctuation.definition.string.end.shell -# ^^ keyword.control.in.shell +# ^^ keyword.control.conditional.in.shell setup ) -# <- meta.statement.conditional.case.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell -#^^^^^ meta.statement.conditional.case.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell -# ^ meta.statement.conditional.case.shell meta.clause.pattern.shell punctuation.definition.pattern.end.shell +# <- meta.statement.conditional.case.body.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell +#^^^^^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell +# ^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell punctuation.definition.pattern.end.shell # <- - variable.function - support.function - meta.function-call # ^ punctuation.definition.pattern.end.shell echo Preparing the server... -# <- meta.statement.conditional.case.shell meta.clause.body.shell meta.function-call.identifier.shell support.function.echo.shell -#^^^ meta.statement.conditional.case.shell meta.clause.body.shell meta.function-call.identifier.shell support.function.echo.shell -# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.statement.conditional.case.shell meta.clause.body.shell meta.function-call.arguments.shell +# <- meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.identifier.shell support.function.echo.shell +#^^^ meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.identifier.shell support.function.echo.shell +# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.arguments.shell ;; -# <- meta.statement.conditional.case.shell meta.clause.shell punctuation.terminator.clause.shell -#^ meta.statement.conditional.case.shell meta.clause.shell punctuation.terminator.clause.shell -# ^ meta.statement.conditional.case.shell - meta.clause +# <- meta.statement.conditional.case.body.shell meta.clause.shell punctuation.terminator.clause.shell +#^ meta.statement.conditional.case.body.shell meta.clause.shell punctuation.terminator.clause.shell +# ^ meta.statement.conditional.case.body.shell - meta.clause dep\ loy ) -# <- meta.statement.conditional.case.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell -#^^^ meta.statement.conditional.case.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell -# ^ meta.statement.conditional.case.shell meta.clause.pattern.shell punctuation.definition.pattern.end.shell +# <- meta.statement.conditional.case.body.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell +#^^^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell +# ^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell punctuation.definition.pattern.end.shell # <- - variable.function - support.function - meta.function-call # ^ punctuation.definition.pattern.end.shell echo Deploying... -# <- meta.statement.conditional.case.shell meta.clause.body.shell meta.function-call.identifier.shell support.function.echo.shell -#^^^ meta.statement.conditional.case.shell meta.clause.body.shell meta.function-call.identifier.shell support.function.echo.shell -# ^^^^^^^^^^^^^ meta.statement.conditional.case.shell meta.clause.body.shell meta.function-call.arguments.shell +# <- meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.identifier.shell support.function.echo.shell +#^^^ meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.identifier.shell support.function.echo.shell +# ^^^^^^^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.arguments.shell ;; -# <- meta.statement.conditional.case.shell meta.clause.shell punctuation.terminator.clause.shell -#^ meta.statement.conditional.case.shell meta.clause.shell punctuation.terminator.clause.shell -# ^ meta.statement.conditional.case.shell - meta.clause +# <- meta.statement.conditional.case.body.shell meta.clause.shell punctuation.terminator.clause.shell +#^ meta.statement.conditional.case.body.shell meta.clause.shell punctuation.terminator.clause.shell +# ^ meta.statement.conditional.case.body.shell - meta.clause * ) -# <- meta.statement.conditional.case.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell constant.other.wildcard.asterisk.shell -#^ meta.statement.conditional.case.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell -# ^ meta.statement.conditional.case.shell meta.clause.pattern.shell punctuation.definition.pattern.end.shell -# ^ meta.statement.conditional.case.shell meta.clause.body.shell +# <- meta.statement.conditional.case.body.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell constant.other.wildcard.asterisk.shell +#^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell +# ^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell punctuation.definition.pattern.end.shell +# ^ meta.statement.conditional.case.body.shell meta.clause.shell cat <<'ENDCAT' # comment -# <- meta.statement.conditional.case.shell meta.clause.body.shell meta.function-call.identifier.shell meta.path.shell variable.function.shell -#^^ meta.statement.conditional.case.shell meta.clause.body.shell meta.function-call.identifier.shell meta.path.shell variable.function.shell -# ^^ meta.statement.conditional.case.shell meta.clause.body.shell meta.function-call.arguments.shell - meta.string - meta.tag -# ^^^^^^^^ meta.statement.conditional.case.shell meta.clause.body.shell meta.function-call.arguments.shell meta.string.heredoc.shell meta.tag.heredoc.shell - string.unquoted.heredoc -# ^^^^^^^^^^^ meta.statement.conditional.case.shell meta.clause.body.shell meta.function-call.arguments.shell meta.string.heredoc.shell - meta.tag - string.unquoted.heredoc +# <- meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.identifier.shell meta.path.shell variable.function.shell +#^^ meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^ meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.arguments.shell - meta.string - meta.tag +# ^^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.arguments.shell meta.string.heredoc.shell meta.tag.heredoc.shell - string.unquoted.heredoc +# ^^^^^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.arguments.shell meta.string.heredoc.shell - meta.tag - string.unquoted.heredoc # ^^ keyword.operator.assignment.redirection.shell # ^ punctuation.definition.tag.begin.shell - entity # ^^^^^^ entity.name.tag.heredoc.shell @@ -1955,68 +1956,73 @@ cat <<'ENDCAT' # comment foo # <- meta.function-call.arguments.shell meta.string.heredoc.shell string.unquoted.heredoc.shell ENDCAT -# <- meta.statement.conditional.case.shell meta.clause.body.shell meta.function-call.arguments.shell meta.string.heredoc.shell meta.tag.heredoc.shell entity.name.tag.heredoc.shell +# <- meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.arguments.shell meta.string.heredoc.shell meta.tag.heredoc.shell entity.name.tag.heredoc.shell ;; -# <- meta.statement.conditional.case.shell meta.clause.shell punctuation.terminator.clause.shell -#^ meta.statement.conditional.case.shell meta.clause.shell punctuation.terminator.clause.shell -# ^ meta.statement.conditional.case.shell - meta.clause +# <- meta.statement.conditional.case.body.shell meta.clause.shell punctuation.terminator.clause.shell +#^ meta.statement.conditional.case.body.shell meta.clause.shell punctuation.terminator.clause.shell +# ^ meta.statement.conditional.case.body.shell - meta.clause esac -# <- meta.statement.conditional.case.shell keyword.control.conditional.end.shell -#^^^ meta.statement.conditional.case.shell keyword.control.conditional.end.shell +# <- meta.statement.conditional.case.end.shell keyword.control.conditional.endcase.shell +#^^^ meta.statement.conditional.case.end.shell keyword.control.conditional.endcase.shell case "${foo}" in- in_ in=10 in #^^^ meta.statement.conditional.case.shell # ^^^^^^^^^^^^^^^^^^^^^^^^ meta.statement.conditional.case.word.shell -# ^^^ meta.statement.conditional.case.shell +# ^^ meta.statement.conditional.case.shell +# ^ meta.statement.conditional.case.body.shell # <- keyword.control.conditional.case.shell #^^^ keyword.control.conditional.case.shell -# ^^ - keyword.control.in -# ^^ - keyword.control.in -# ^^ - keyword.control.in -# ^^ keyword.control.in +# ^^ - keyword.control.conditional.in +# ^^ - keyword.control.conditional.in +# ^^ - keyword.control.conditional.in +# ^^ keyword.control.conditional.in ( help | h ) bar ;; -#^^^ meta.statement.conditional.case.shell - meta.clause.pattern +#^^^ meta.statement.conditional.case.body.shell - meta.clause.pattern # ^ meta.clause.pattern.shell - meta.string - meta.group - string -# ^^^^^^^^^^ meta.statement.conditional.case.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell - meta.group +# ^^^^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell - meta.group # ^ meta.clause.pattern.shell - meta.string - meta.group - string -# ^^^^^ meta.statement.conditional.case.shell meta.clause.body.shell - meta.clause.pattern -# ^^ meta.statement.conditional.case.shell meta.clause.shell -# ^ meta.statement.conditional.case.shell - meta.clause +# ^ meta.statement.conditional.case.body.shell meta.clause.shell +# ^^^^ meta.statement.conditional.case.body.shell meta.clause.body.shell - meta.clause.pattern +# ^^ meta.statement.conditional.case.body.shell meta.clause.shell +# ^ meta.statement.conditional.case.body.shell - meta.clause # ^ punctuation.definition.pattern.begin.shell # ^ keyword.operator.logical.regexp.shell # ^ punctuation.definition.pattern.end.shell # ^^ punctuation.terminator.clause.shell do1 ) foo1 ;& -#^^^ meta.statement.conditional.case.shell - meta.clause.pattern -# ^^^^ meta.statement.conditional.case.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell - meta.group +#^^^ meta.statement.conditional.case.body.shell - meta.clause.pattern +# ^^^^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell - meta.group # ^ meta.clause.pattern.shell - meta.string - meta.group - string -# ^^^^^^ meta.statement.conditional.case.shell meta.clause.body.shell - meta.clause.pattern -# ^^ meta.statement.conditional.case.shell meta.clause.shell -# ^ meta.statement.conditional.case.shell - meta.clause +# ^ meta.statement.conditional.case.body.shell meta.clause.shell +# ^^^^^ meta.statement.conditional.case.body.shell meta.clause.body.shell - meta.clause.pattern +# ^^ meta.statement.conditional.case.body.shell meta.clause.shell +# ^ meta.statement.conditional.case.body.shell - meta.clause # ^ punctuation.definition.pattern.end.shell # ^^ punctuation.terminator.clause.shell (do2 ) foo2 ;;& -#^^^ meta.statement.conditional.case.shell - meta.clause.pattern +#^^^ meta.statement.conditional.case.body.shell - meta.clause.pattern # ^ meta.clause.pattern.shell - meta.string - meta.group - string -# ^^^^ meta.statement.conditional.case.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell - meta.group -# ^ meta.clause.pattern.shell - meta.string - meta.group - string -# ^^^^^^ meta.statement.conditional.case.shell meta.clause.body.shell -# ^^^ meta.statement.conditional.case.shell meta.clause.shell -# ^ meta.statement.conditional.case.shell - meta.clause +# ^^^^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell - meta.group +# ^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell - meta.string - meta.group - string +# ^ meta.statement.conditional.case.body.shell meta.clause.shell +# ^^^^^ meta.statement.conditional.case.body.shell meta.clause.body.shell +# ^^^ meta.statement.conditional.case.body.shell meta.clause.shell +# ^ meta.statement.conditional.case.body.shell - meta.clause # ^ punctuation.definition.pattern.begin.shell # ^ punctuation.definition.pattern.end.shell # ^^^ punctuation.terminator.clause.shell *) bar -#^^^ meta.statement.conditional.case.shell - meta.clause.pattern -# ^ meta.statement.conditional.case.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell - meta.group -# ^ meta.clause.pattern.shell - meta.string - meta.group - string -# ^^^^^ meta.statement.conditional.case.shell meta.clause.body.shell +#^^^ meta.statement.conditional.case.body.shell - meta.clause.pattern +# ^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell - meta.group +# ^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell - meta.string - meta.group - string +# ^ meta.statement.conditional.case.body.shell meta.clause.shell +# ^^^^ meta.statement.conditional.case.body.shell meta.clause.body.shell # ^ meta.string.regexp.shell string.unquoted.shell constant.other.wildcard.asterisk.shell # ^ punctuation.definition.pattern.end.shell esac -# <- meta.statement.conditional.case.shell keyword.control.conditional.end.shell -#^^^ meta.statement.conditional.case.shell keyword.control.conditional.end.shell +# <- meta.statement.conditional.case.end.shell keyword.control.conditional.endcase.shell +#^^^ meta.statement.conditional.case.end.shell keyword.control.conditional.endcase.shell # ^ - meta.conditional - keyword case $TERM in @@ -2048,7 +2054,7 @@ case $TERM in # ^ meta.function punctuation.section.block.end.shell # ^^ punctuation.terminator.clause.shell esac -# <- keyword.control.conditional.end.shell +# <- keyword.control.conditional.endcase.shell case $SERVER in # <- keyword.control.conditional.case.shell @@ -2105,8 +2111,8 @@ bk-+([0-9])\.host\.com) echo "Backup server" # <- punctuation.terminator.clause.shell #^ punctuation.terminator.clause.shell esac -# <- keyword.control.conditional.end.shell -#^^^ keyword.control.conditional.end.shell +# <- keyword.control.conditional.endcase.shell +#^^^ keyword.control.conditional.endcase.shell case $_G_unquoted_arg in *[\[\~\#\&\*\(\)\{\}\|\;\<\>\?\'\ ]*|*]*|"") @@ -10272,8 +10278,7 @@ f() { local "$x"'+=(4)' # <- keyword.declaration.variable.shell esac - # <- meta.function.body.shell meta.block.shell meta.statement.conditional.case.shell - # <- keyword.control.conditional.end.shell + # <- keyword.control.conditional.endcase.shell IFS=, local -a "$x"'=("${x}: ${'"$x"'[*]}")' # ^ variable.language.builtin.shell @@ -10281,7 +10286,6 @@ f() { # ^ meta.string.shell string.unquoted.shell # ^ keyword.declaration.variable.shell done - # <- meta.function.body.shell meta.block.shell # <- keyword.control.loop.end.shell } # <- meta.function.body.shell meta.block.shell punctuation.section.block.end.shell @@ -11874,7 +11878,7 @@ function clk { echo "Usage: $FUNCNAME [ low | high | default ]" printf '%s\n' "temp: $(<${base}/hwmon/hwmon0/temp1_input)C" "current profile: $(<${base}/power_profile)" esac - # <- meta.function keyword.control.conditional.end.shell + # <- meta.function keyword.control.conditional.endcase.shell } # <- punctuation.section.block.end.shell diff --git a/ShellScript/test/syntax_test_reindent_case.bash b/ShellScript/test/syntax_test_reindent_case.bash new file mode 100644 index 0000000000..5bd2bbc9e6 --- /dev/null +++ b/ShellScript/test/syntax_test_reindent_case.bash @@ -0,0 +1,99 @@ +# SYNTAX TEST reindent-unchanged "Packages/ShellScript/Bash.sublime-syntax" + +# --- + +case $var in foo) echo yes ;; *) echo no ;; esac + +# --- + +case $var in +foo) + echo yes + ;; +*) + echo no + ;; +esac + +# --- + +case + $var +in +foo) + echo yes + ;; +*) + echo no + ;; +esac + +# --- + +case # comment + $var # comment +in # comment +foo) # comment + echo yes # comment + ;; # comment +*) # comment + echo no # comment + ;; # comment +esac # comment + +# --- + +case $var1 in +1) + case $var2 in + 1) + # comment + case $var3 in + 1) + # comment + echo 1.1.1 + ;; + *) + # comment + echo 1.1.n + ;; + esac + ;; + *) + case $var3 in + 1) # comment + echo 1.n.1 + ;; + *) # comment + echo 1.n.n + ;; + esac && foo + ;; + esac > foo + ;; +*) + case $var2 in + 1) + case $var3 in + 1) + echo n.1.1 + ;; + *) + echo n.1.n + ;; + esac + ;; + *) + case $var3 in + 1) + echo n.n.1 + ;; + *) + echo n.n.n + ;; + esac + ;; + esac + ;; +esac + diff --git a/ShellScript/test/syntax_test_reindent_for.bash b/ShellScript/test/syntax_test_reindent_for.bash new file mode 100644 index 0000000000..c9ca54cd3f --- /dev/null +++ b/ShellScript/test/syntax_test_reindent_for.bash @@ -0,0 +1,115 @@ +# SYNTAX TEST reindent-unchanged "Packages/ShellScript/Bash.sublime-syntax" + +# --- + +for ((i = 0; i < 10; i++)); do echo $i; done; + +# --- + +for ((i = 0; i < 10; i++)); do echo $i; +done; + +# --- + +for ((i = 0; i < 10; i++)); do + echo $i; +done; + +# --- + +for ((i = 0; i < 10; i++)) +do + echo $i; +done; + +# --- + +for + ((i = 0; i < 10; i++)) +do + echo $i; +done; + +# --- + +for (( + i = 0; + i < 10; + i++ +)) +do + echo $i; +done; + +# --- + +for + (( + i = 0; + i < 10; + i++ + )) +do + echo $i; +done; + +# --- + +for ((i = 0; i < 10; i++)); do + for ((k = 0; k < 10; k++)); do + echo \[$i,$k\]; + done; +done; + +# --- + +for var in foo bar baz; do echo $var; done; + +# --- + +for var in foo bar baz; do echo $var; +done; + +# --- + +for var in foo bar baz; do + echo $var; +done; + +# --- + +for var \ +in foo bar baz; +do + echo $var; +done; + +# --- + +for var in foo bar baz; +do echo $var; +done; + +# --- + +for var \ +in foo bar baz; +do echo $var; +done; + +# --- + +for var in foo bar baz; +do + echo $var; +done; + +# --- + +for \ + var \ +in \ + foo bar baz; +do + echo $var; +done; diff --git a/ShellScript/test/syntax_test_reindent_if.bash b/ShellScript/test/syntax_test_reindent_if.bash new file mode 100644 index 0000000000..d93c78e912 --- /dev/null +++ b/ShellScript/test/syntax_test_reindent_if.bash @@ -0,0 +1,122 @@ +# SYNTAX TEST reindent-unchanged "Packages/ShellScript/Bash.sublime-syntax" + +# --- + +if [[ $var == 1 ]]; then echo 1; elif [[ $var == 2 ]]; then echo 2; else echo nothing; fi; + +# --- + +if [[ $var == 1 ]]; then echo 1; elif [[ $var == 2 ]]; then echo 2; else echo nothing; +fi; + +# --- + +if [[ $var == 1 ]]; then echo 1; elif [[ $var == 2 ]]; then echo 2; +else echo nothing; +fi; + +# --- + +if [[ $var == 1 ]]; then echo 1; elif [[ $var == 2 ]]; then + echo 2; +else echo nothing; +fi; + +# --- + +if [[ $var == 1 ]]; then echo 1; +elif [[ $var == 2 ]]; then + echo 2; +else + echo nothing; +fi; + +# --- + +if [[ $var == 1 ]]; then + echo 1; +elif [[ $var == 2 ]]; then + echo 2; +else + echo nothing; +fi; + +# --- + +if [[ $var == 1 ]] +then + echo 1; +elif [[ $var == 2 ]] +then + echo 2; +else + echo nothing; +fi; + +# --- + +if + [[ $var == 1 ]] +then + echo 1; +elif + [[ $var == 2 ]] +then + echo 2; +else + echo nothing; +fi; + +# --- + +if [[ $var1 == 1 ]] +then + if [[ $var2 == 1 ]] + then + if [[ $var3 == 1 ]] + then + echo 1.1.1; + elif [[ $var3 == 2 ]] + then + echo 1.1.2; + else + echo 1.1.n; + fi; + elif [[ $var2 == 2 ]] + then + echo 2.2; + else + echo 2.n; + fi; +elif [[ $var1 == 2 ]] +then + echo 2; +else + echo n; +fi; + +# --- + +if + if + if + [[ $var1 == 1 ]] + then + true + else + false + fi + then + false + elif + [[ $var2 == 1 ]] + then + true + else + false + fi +then + echo success +else + echo failed +fi diff --git a/ShellScript/test/syntax_test_reindent_select.bash b/ShellScript/test/syntax_test_reindent_select.bash new file mode 100644 index 0000000000..1d28011044 --- /dev/null +++ b/ShellScript/test/syntax_test_reindent_select.bash @@ -0,0 +1,37 @@ +# SYNTAX TEST reindent-unchanged "Packages/ShellScript/Bash.sublime-syntax" + +select var in foo bar baz; do echo $var; done; + +# --- + +select var in foo bar baz; do echo $var; +done; + +# --- + +select var in foo bar baz; do + echo $var; +done; + +# --- + +select var in foo bar baz; +do echo $var; +done; + +# --- + +select var in foo bar baz; +do + echo $var; +done; + +# --- + +select \ + var \ +in \ + foo bar baz; +do + echo $var; +done; diff --git a/ShellScript/test/syntax_test_reindent_until.bash b/ShellScript/test/syntax_test_reindent_until.bash new file mode 100644 index 0000000000..bb9772bbce --- /dev/null +++ b/ShellScript/test/syntax_test_reindent_until.bash @@ -0,0 +1,32 @@ +# SYNTAX TEST reindent-unchanged "Packages/ShellScript/Bash.sublime-syntax" + +until (( $var > 10 )); do echo $var; (( $var += 1 )); done; + +# --- + +until (( $var > 10 )); do echo $var; (( $var += 1 )); +done; + +# --- + +until (( $var > 10 )); do + echo $var; + (( $var += 1 )); +done; + +# --- + +until (( $var > 10 )) +do + echo $var; + (( $var += 1 )); +done; + +# --- + +until + (( $var > 10 )) +do + echo $var; + (( $var += 1 )); +done; diff --git a/ShellScript/test/syntax_test_reindent_while.bash b/ShellScript/test/syntax_test_reindent_while.bash new file mode 100644 index 0000000000..87fa3aea90 --- /dev/null +++ b/ShellScript/test/syntax_test_reindent_while.bash @@ -0,0 +1,32 @@ +# SYNTAX TEST reindent-unchanged "Packages/ShellScript/Bash.sublime-syntax" + +while (( $var < 10 )); do echo $var; (( $var += 1 )); done; + +# --- + +while (( $var < 10 )); do echo $var; (( $var += 1 )); +done; + +# --- + +while (( $var < 10 )); do + echo $var; + (( $var += 1 )); +done; + +# --- + +while (( $var < 10 )) +do + echo $var; + (( $var += 1 )); +done; + +# --- + +while + (( $var < 10 )) +do + echo $var; + (( $var += 1 )); +done; From dacc3b821931d90e228d98ce9f260e0a35661dc8 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Fri, 26 Jul 2024 09:53:29 +0200 Subject: [PATCH 045/113] [ShellScript] Syntax based folding --- Makefile/syntax_test_makefile.mak | 2 +- ShellScript/Bash.sublime-syntax | 2 +- ShellScript/Fold.tmPreferences | 79 ++++++++++++++++++++++++++++ ShellScript/test/syntax_test_bash.sh | 20 +++---- 4 files changed, 91 insertions(+), 12 deletions(-) create mode 100644 ShellScript/Fold.tmPreferences diff --git a/Makefile/syntax_test_makefile.mak b/Makefile/syntax_test_makefile.mak index 3a71cd77a8..5ff40f0b8e 100644 --- a/Makefile/syntax_test_makefile.mak +++ b/Makefile/syntax_test_makefile.mak @@ -1001,7 +1001,7 @@ TESTTOOL = sh -c '\ fi' TESTTOOL # ^^^ meta.string.makefile meta.interpolation.makefile # ^^^^^^^^^ meta.string.makefile string.unquoted.makefile - meta.interpolation -# ^^ source.shell.embedded keyword.control.conditional.end.shell - source.shell source.shell +# ^^ source.shell.embedded keyword.control.conditional.endif.shell - source.shell source.shell # ^ punctuation.section.interpolation.end.makefile diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index e798dea557..af2adcdd77 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -1329,7 +1329,7 @@ contexts: - match: elif{{cmd_break}} scope: keyword.control.conditional.elseif.shell - match: fi{{cmd_break}} - scope: keyword.control.conditional.end.shell + scope: keyword.control.conditional.endif.shell - match: else{{cmd_break}} scope: keyword.control.conditional.else.shell - match: case{{cmd_break}} diff --git a/ShellScript/Fold.tmPreferences b/ShellScript/Fold.tmPreferences new file mode 100644 index 0000000000..ef55f170f1 --- /dev/null +++ b/ShellScript/Fold.tmPreferences @@ -0,0 +1,79 @@ + + + + scope + source.shell + settings + + foldScopes + + + begin + punctuation.section.block.begin + end + punctuation.section.block.end + excludeTrailingNewlines + + + + begin + punctuation.section.compound.begin + end + punctuation.section.compound.end + excludeTrailingNewlines + + + + begin + punctuation.section.group.begin + end + punctuation.section.group.end + excludeTrailingNewlines + + + + begin + keyword.control.conditional.then + end + keyword.control.conditional.else, keyword.control.conditional.elseif, keyword.control.conditional.endif + + + begin + keyword.control.conditional.if, keyword.control.conditional.elseif + end + keyword.control.conditional.then + + + begin + keyword.control.conditional.else + end + keyword.control.conditional.endif + + + begin + keyword.control.conditional.case + end + keyword.control.conditional.endcase + excludeTrailingNewlines + + + + begin + meta.clause.pattern punctuation.definition.pattern.end + end + punctuation.terminator.clause + excludeTrailingNewlines + + + + begin + keyword.control.loop.do + end + keyword.control.loop.end + excludeTrailingNewlines + + + + + + diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index 04e705f444..e28fc8e93a 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -1644,7 +1644,7 @@ if [[ $- =~ *i* ]] ; then echo shell is not interactive; fi # ^^^^ keyword.control.conditional.then.shell # ^^^^ support.function.echo.shell # ^ punctuation.terminator.statement.shell -# ^^ keyword.control.conditional.end.shell +# ^^ keyword.control.conditional.endif.shell if [[ "$ERL_TOP" != ";"; ]];then;fi #^ keyword.control.conditional.if.shell @@ -1656,7 +1656,7 @@ if [[ "$ERL_TOP" != ";"; ]];then;fi # ^ punctuation.terminator.statement.shell # ^^^^ keyword.control.conditional.then.shell # ^ punctuation.terminator.statement.shell -# ^^ keyword.control.conditional.end.shell +# ^^ keyword.control.conditional.endif.shell if [[ ! -z "$PLATFORM" ]] && ! cmd || ! cmd2; then PLATFORM=docker; fi #^ keyword.control.conditional.if.shell @@ -1720,7 +1720,7 @@ if [ ! -f q4m-$Q4MVER.tar.gz ]; then : # ^ meta.function-call.identifier.shell support.function.colon.shell fi -# <- keyword.control.conditional.end.shell +# <- keyword.control.conditional.endif.shell if true ; then false ; fi #^ keyword.control.conditional.if.shell @@ -1729,7 +1729,7 @@ if true ; then false ; fi # ^^^^ keyword.control.conditional.then.shell # ^^^^^ constant.language.boolean.false.shell # ^ punctuation.terminator.statement.shell -# ^^ keyword.control.conditional.end.shell +# ^^ keyword.control.conditional.endif.shell if (ruby extconf.rb && # ^ punctuation.section.compound.begin.shell @@ -1780,7 +1780,7 @@ elif [ "$1" ]; then # ^ keyword.operator.assignment.shell # ^^ variable.language.positional.shell fi -# <- keyword.control.conditional.end.shell +# <- keyword.control.conditional.endif.shell asdf foo && FOO=some-value pwd # <- meta.function-call.identifier.shell variable.function.shell @@ -8788,7 +8788,7 @@ if opam upgrade --check; then # ^^^ keyword.operator.herestring # ^ - keyword.control.heredoc-token - string.unquoted.heredoc fi -# <- keyword.control.conditional.end - string.unquoted.heredoc +# <- keyword.control.conditional.endif.shell - string cat -c <<<$(echo pipephobic) # ^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments @@ -10110,7 +10110,7 @@ let "two=5+5"; if [[ "$X" == "1" ]]; then X="one"; fi # ^ keyword.operator.assignment.shell # ^^^^^ string.quoted.double.shell # ^ punctuation.terminator.statement.shell -# ^^ keyword.control.conditional.end.shell +# ^^ keyword.control.conditional.endif.shell let test -z $2 && { } #^^ meta.function-call.identifier.shell support.function.let.shell @@ -10637,7 +10637,7 @@ if test expr -a expr ; then echo "success"; fi # ^^^^ keyword.control.conditional.then.shell # ^^^^ support.function.echo.shell # ^ punctuation.terminator.statement.shell -# ^^ keyword.control.conditional.end.shell +# ^^ keyword.control.conditional.endif.shell if test "$VAR" != ";";then;fi # ^ - meta.function-call @@ -10650,7 +10650,7 @@ if test "$VAR" != ";";then;fi # ^ punctuation.terminator.statement.shell # ^^^^ keyword.control.conditional.then.shell # ^ punctuation.terminator.statement.shell -# ^^ keyword.control.conditional.end.shell +# ^^ keyword.control.conditional.endif.shell ############################################################################### @@ -11908,7 +11908,7 @@ else remotefilter="grep" done # <- keyword.control.loop.end.shell fi -# <- keyword.control.conditional.end.shell +# <- keyword.control.conditional.endif.shell curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | POETRY_PREVIEW=1 python # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell string.unquoted.shell From 536f44c47dd35ed23f7332ca95a3d4e664a76a1d Mon Sep 17 00:00:00 2001 From: deathaxe Date: Fri, 2 Aug 2024 17:30:10 +0200 Subject: [PATCH 046/113] [ShellScript] Adjust completion rules This commit cancels completions immediately after each reserved word to 1. give snippets precedence over completions 2. prefer enter adding a linefeed rather than committing a completion --- ShellScript/Completion Rules.tmPreferences | 30 +++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/ShellScript/Completion Rules.tmPreferences b/ShellScript/Completion Rules.tmPreferences index 034ef714b9..6b76acbe51 100644 --- a/ShellScript/Completion Rules.tmPreferences +++ b/ShellScript/Completion Rules.tmPreferences @@ -5,8 +5,36 @@ source.shell settings + cancelCompletion - ^.*\b(fi|esac|then|do|done)$ + From 8e4b0f79b2ddd8fb66d483045da354c2f8784ccb Mon Sep 17 00:00:00 2001 From: deathaxe Date: Fri, 2 Aug 2024 17:34:13 +0200 Subject: [PATCH 047/113] [ShelScript] Adjust `in` keyword scope This commit scopes `in` as `keyword.operator.iterator`. --- ShellScript/Bash.sublime-syntax | 2 +- ShellScript/test/syntax_test_bash.sh | 30 ++++++++++++++-------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index af2adcdd77..1975722042 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -1464,7 +1464,7 @@ contexts: loop-iterator-var: - match: in{{cmd_break}} - scope: keyword.control.in.shell + scope: keyword.operator.iterator.in.shell set: loop-iterator-wordlist - include: cmd-args-end - include: variables diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index e28fc8e93a..0fd51bcd4f 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -912,7 +912,7 @@ for \ var in $vars; #<- variable.other.readwrite.shell #^^ variable.other.readwrite.shell -# ^^ keyword.control.in.shell +# ^^ keyword.operator.iterator.in.shell # ^^^^^ meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell # ^ punctuation.terminator.statement.shell @@ -995,7 +995,7 @@ for \ for i in str1 $str2 "str3" 'str4' st$r5; do echo $i; done; # <- keyword.control.loop.for.shell # ^ variable.other.readwrite.shell -# ^^ keyword.control.in.shell +# ^^ keyword.operator.iterator.in.shell # ^^^^ meta.string.shell string.unquoted.shell # ^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell # ^^^^^^ meta.string.shell string.quoted.double.shell @@ -1012,7 +1012,7 @@ for i in str1 $str2 "str3" 'str4' st$r5; do echo $i; done; for i in for in do echo done; do echo $i; done; # <- keyword.control.loop.for.shell -# ^^ keyword.control.in.shell +# ^^ keyword.operator.iterator.in.shell # ^ - meta.string # ^^^ meta.string.shell string.unquoted.shell # ^ - meta.string @@ -1034,7 +1034,7 @@ for i in for in do echo done; do echo $i; done; for i in { [ \( ; do echo $i; done; # <- keyword.control.loop.for.shell # ^ variable.other.readwrite.shell -# ^^ keyword.control.in.shell +# ^^ keyword.operator.iterator.in.shell # ^ - meta.string # ^ meta.string.shell string.unquoted.shell # ^ - meta.string @@ -1053,7 +1053,7 @@ for i in { [ \( ; do echo $i; done; for i in Date: Thu, 18 Jul 2024 21:59:10 +0200 Subject: [PATCH 048/113] [ShellScript] Simplify built-ins This commit drops all command specific contexts and thus highlighting, because a syntax definition is not a linter and thus doesn't need to highlight unsupported command arguments `illegal`. That's cumbersome to maintain for multiple shell dialects and likely to fail once shells evolve. Therefore only syntactically important special cases are kept untouched. --- Makefile/syntax_test_makefile.mak | 4 +- ShellScript/Bash.sublime-syntax | 186 ++----- ShellScript/Makefile | 15 - ...commands-builtin-shell-bash.sublime-syntax | 471 ------------------ ShellScript/commands-builtin-shell-bash.yml | 155 ------ ShellScript/test/syntax_test_bash.sh | 416 ++++++++-------- ShellScript/tools/update-commands.py | 108 ---- 7 files changed, 255 insertions(+), 1100 deletions(-) delete mode 100644 ShellScript/Makefile delete mode 100644 ShellScript/commands-builtin-shell-bash.sublime-syntax delete mode 100644 ShellScript/commands-builtin-shell-bash.yml delete mode 100644 ShellScript/tools/update-commands.py diff --git a/Makefile/syntax_test_makefile.mak b/Makefile/syntax_test_makefile.mak index 5ff40f0b8e..92b47b8037 100644 --- a/Makefile/syntax_test_makefile.mak +++ b/Makefile/syntax_test_makefile.mak @@ -1059,13 +1059,13 @@ foo: # ^ constant.character.escape.makefile # ^ punctuation # ^ punctuation.section.interpolation.begin.shell - # ^^^^ support.function.echo.shell + # ^^^^ support.function.shell # ^ constant.character.escape.makefile # ^ punctuation.definition.variable.shell # ^^^^^ variable.language.builtin.shell test "$$abc" = "$$def" - # ^ support.function.test.shell + # ^ support.function.shell # ^^^^^^^ string.quoted.double.shell # ^ constant.character.escape.makefile # ^ punctuation.definition.variable.shell diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 1975722042..bf9d8d9226 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -6,8 +6,6 @@ name: Bash scope: source.shell.bash version: 2 -extends: Packages/ShellScript/commands-builtin-shell-bash.sublime-syntax - file_extensions: - sh - bash @@ -64,8 +62,14 @@ variables: cmd_break: (?!{{cmd_char}}) cmd_char: '[^{{metachar}}]' + builtin_cmds: |- + (?x: \. | \: | bg | bind | builtin | caller | cd | command | disown | enable + | eval | fg | getopts | hash | help | jobs | kill | logout | mapfile | printf + | pwd | read | readarray | set | shift | shopt | source | su | suspend | times + | type | ulimit | umask | wait ){{cmd_break}} + # Command options are identifiers, which may start with interpolation. - opt_punctuation: '(--|[-+]){{word_begin}}' + opt_punctuation: (--|[-+])(?={{word_char}}) opt_break: (?![^={{metachar}}]) variable_begin: (?={{variable_first_char}}) @@ -350,7 +354,7 @@ contexts: - match: \{ # Bash expects `{{cmd_break}}` but we don't care. scope: punctuation.section.block.begin.shell set: def-anonymous-block-body - - include: cmd-args-illegal-options + - include: illegal-options - include: line-continuations - include: comments - include: else-pop @@ -524,16 +528,10 @@ contexts: - include: immediately-pop cmd-alias-args: - - match: ([-+])p{{opt_break}} - scope: - meta.parameter.option.shell - variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - - include: cmd-args-illegal-options - match: --{{word_break}} scope: keyword.operator.end-of-options.shell set: cmd-alias-args-definitions + - include: cmd-args-options - include: cmd-alias-args-definitions cmd-alias-args-definitions: @@ -558,7 +556,7 @@ contexts: scope: punctuation.section.compound.begin.shell push: cmd-arithmetic-body - match: let{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.let.shell + scope: meta.function-call.identifier.shell support.function.shell push: cmd-arithmetic-args cmd-arithmetic-body: @@ -630,7 +628,7 @@ contexts: variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell - set: cmd-declare-functions + set: cmd-args-end-of-options-then-function-declarations # option contains any mix of iA or Ai - match: ([-+])(?:[agIlnrtux]*?i[iagIlnrtux]*?A|[agIlnrtux]*?A[aAgIlnrtux]*?i)[aAgiIlnrtux]*?{{opt_break}} scope: @@ -638,7 +636,7 @@ contexts: variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell - set: cmd-declare-variables-with-arithmetic-mappings + set: cmd-args-end-of-options-then-variables-arithmetic-mappings # option contains any mix of ia or ai or i - match: ([-+])[aAgiIlnrtux]*?i[aAgiIlnrtux]*?{{opt_break}} scope: @@ -656,17 +654,8 @@ contexts: 1: punctuation.definition.parameter.shell set: cmd-declare-variables-with-literal-mappings # anything else is a variable with any value - - include: cmd-declare-options - include: cmd-args-end-of-options-then-variables-literal-values - cmd-declare-functions: - - include: cmd-declare-options - - include: cmd-args-end-of-options-then-function-declarations - - cmd-declare-variables-with-arithmetic-mappings: - - include: cmd-declare-options - - include: cmd-args-end-of-options-then-variables-arithmetic-mappings - cmd-declare-variables-with-arithmetic-values: - match: ([-+])[aAgiIlnrtux]*?A[aAgiIlnrtux]*?{{opt_break}} scope: @@ -674,8 +663,7 @@ contexts: variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell - set: cmd-declare-variables-with-arithmetic-mappings - - include: cmd-declare-options + set: cmd-args-end-of-options-then-variables-arithmetic-mappings - include: cmd-args-end-of-options-then-variables-arithmetic-values cmd-declare-variables-with-literal-mappings: @@ -685,25 +673,16 @@ contexts: variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell - set: cmd-declare-variables-with-arithmetic-mappings - - include: cmd-declare-options + set: cmd-args-end-of-options-then-variables-arithmetic-mappings - include: cmd-args-end-of-options-then-variables-literal-mappings - cmd-declare-options: - - match: ([-+])(?:[aAgiIlnrtux]+|p){{opt_break}} - scope: - meta.parameter.option.shell - variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - ###[ ECHO BUILTINS ]########################################################### cmd-echo: - match: echo{{cmd_break}} scope: meta.function-call.identifier.shell - support.function.echo.shell + support.function.shell push: cmd-echo-args cmd-echo-args: @@ -727,7 +706,7 @@ contexts: - match: exec{{cmd_break}} scope: meta.function-call.identifier.shell - support.function.exec.shell + support.function.shell push: cmd-exec-args cmd-exec-args: @@ -740,18 +719,12 @@ contexts: captures: 1: punctuation.definition.parameter.shell push: cmd-args-option-maybe-value - - match: ([-+])[cl]+{{opt_break}} - scope: - meta.parameter.option.shell - variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - match: --{{word_break}} scope: meta.function-call.arguments.shell keyword.operator.end-of-options.shell pop: 1 - - include: cmd-args-illegal-options + - include: cmd-args-options - include: else-pop ###[ EXPORT BUILTINS ]######################################################### @@ -760,7 +733,7 @@ contexts: - match: export{{cmd_break}} scope: meta.function-call.identifier.shell - support.function.export.shell + support.function.shell push: - cmd-args-meta - cmd-export-args @@ -772,25 +745,9 @@ contexts: variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell - set: cmd-export-options-then-functions - - include: cmd-export-options-then-variables - - cmd-export-options-then-functions: - - include: cmd-export-options - - include: cmd-args-end-of-options-then-function-declarations - - cmd-export-options-then-variables: - - include: cmd-export-options + set: cmd-args-end-of-options-then-function-declarations - include: cmd-args-end-of-options-then-variables-literal-values - cmd-export-options: - - match: ([-+])[np]{{opt_break}} - scope: - meta.parameter.option.shell - variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - ###[ READONLY BUILTINS ]####################################################### cmd-readonly: @@ -808,7 +765,7 @@ contexts: variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell - set: cmd-readonly-options-then-functions + set: cmd-args-end-of-options-then-function-declarations # options contain -A => associative array (wins over -a) - match: ([-+])a?Aa?{{opt_break}} scope: @@ -817,11 +774,7 @@ contexts: captures: 1: punctuation.definition.parameter.shell set: cmd-readonly-options-then-mappings - - include: cmd-readonly-options-then-variables - - cmd-readonly-options-then-functions: - - include: cmd-readonly-options - - include: cmd-args-end-of-options-then-function-declarations + - include: cmd-args-end-of-options-then-variables-literal-values cmd-readonly-options-then-mappings: - match: ([-+])[aA]*f[aA]*{{opt_break}} @@ -830,22 +783,9 @@ contexts: variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell - set: cmd-readonly-options-then-functions - - include: cmd-readonly-options + set: cmd-args-end-of-options-then-function-declarations - include: cmd-args-end-of-options-then-variables-literal-mappings - cmd-readonly-options-then-variables: - - include: cmd-readonly-options - - include: cmd-args-end-of-options-then-variables-literal-values - - cmd-readonly-options: - - match: ([-+])(?:[aAf]+|p){{opt_break}} - scope: - meta.parameter.option.shell - variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - ###[ SUDO BUILTINS ]########################################################### cmd-sudo: @@ -853,22 +793,12 @@ contexts: - match: sudo{{cmd_break}} scope: meta.function-call.identifier.shell - support.function.sudo.shell + support.function.shell push: cmd-sudo-args cmd-sudo-args: - meta_content_scope: meta.function-call.arguments.shell - include: cmd-args-end - - match: (--)(?x:askpass|auth-type|background|close-from|login-class| - preserve-env|edit|group|set-home|help|host|login|remove-timestamp| - reset-timestamp|list|non-interactive|preserve-groups|prompt|role| - stdin|shell|type|other-user|user|version|validate){{opt_break}} - scope: - meta.parameter.option.shell - variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - push: cmd-args-option-maybe-assignment - match: ([-+])[AbEeHiKklnPSsUuVv]*[aCcghprt]{{opt_break}} scope: meta.parameter.option.shell @@ -876,18 +806,12 @@ contexts: captures: 1: punctuation.definition.parameter.shell push: cmd-args-option-maybe-value - - match: ([-+])[AbEeHiKklnPSsUuVv]+{{opt_break}} - scope: - meta.parameter.option.shell - variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - match: --{{word_break}} scope: meta.function-call.arguments.shell keyword.operator.end-of-options.shell pop: 1 - - include: cmd-args-illegal-options + - include: cmd-args-options - include: else-pop ###[ TEST BUILTINS ]########################################################### @@ -900,7 +824,7 @@ contexts: scope: punctuation.section.compound.begin.shell push: builtin-test-body - match: test{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.test.shell + scope: meta.function-call.identifier.shell support.function.shell push: cmd-test-args builtin-test-body: @@ -1026,19 +950,10 @@ contexts: - match: unalias{{cmd_break}} scope: meta.function-call.identifier.shell - support.function.unalias.shell + support.function.shell push: - cmd-args-meta - - cmd-unalias-args - - cmd-unalias-args: - - match: ([-+])a{{opt_break}} - scope: - meta.parameter.option.shell - variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - - include: cmd-args-end-of-options-then-function-references + - cmd-args-end-of-options-then-function-references ###[ UNSET BUILTINS ]########################################################## @@ -1046,7 +961,7 @@ contexts: - match: unset{{cmd_break}} scope: meta.function-call.identifier.shell - support.function.unset.shell + support.function.shell push: - cmd-args-meta - cmd-unset-args @@ -1058,25 +973,9 @@ contexts: variable.parameter.option.shell captures: 1: punctuation.definition.parameter.shell - set: cmd-unset-options-then-functions - - include: cmd-unset-options-then-variables - - cmd-unset-options-then-functions: - - include: cmd-unset-options - - include: cmd-args-end-of-options-then-function-references - - cmd-unset-options-then-variables: - - include: cmd-unset-options + set: cmd-args-end-of-options-then-function-references - include: cmd-args-end-of-options-then-variables-literal-values - cmd-unset-options: - - match: ([-+])[nv]+{{opt_break}} - scope: - meta.parameter.option.shell - variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - ###[ COMMANDS ]################################################################ cmd-compound: @@ -1109,6 +1008,13 @@ contexts: - match: \! scope: punctuation.definition.history.shell + cmd-builtins: + - match: '{{builtin_cmds}}' + scope: meta.function-call.identifier.shell meta.path.shell support.function.shell + push: + - cmd-args-meta + - cmd-args + cmd-basic: - match: \$?\" scope: punctuation.definition.quoted.begin.shell @@ -1158,10 +1064,6 @@ contexts: - include: redirections - include: eoc-pop - cmd-args-illegal-options: - - match: (--|[-+]){{identifier}} - scope: invalid.illegal.parameter.shell - cmd-args-options: - match: '{{opt_punctuation}}' scope: punctuation.definition.parameter.shell @@ -1214,10 +1116,10 @@ contexts: - include: cmd-args-values cmd-args-end-of-options-then-function-declarations: - - include: cmd-args-illegal-options - match: --{{word_break}} scope: keyword.operator.end-of-options.shell set: cmd-args-function-declarations + - include: cmd-args-options - include: cmd-args-function-declarations cmd-args-function-declarations: @@ -1234,10 +1136,10 @@ contexts: pop: 1 cmd-args-end-of-options-then-function-references: - - include: cmd-args-illegal-options - match: --{{word_break}} scope: keyword.operator.end-of-options.shell set: cmd-args-function-references + - include: cmd-args-options - include: cmd-args-function-references cmd-args-function-references: @@ -1253,10 +1155,10 @@ contexts: pop: 1 cmd-args-end-of-options-then-variables-arithmetic-mappings: - - include: cmd-args-illegal-options - match: --{{word_break}} scope: keyword.operator.end-of-options.shell set: cmd-args-variables-arithmetic-mappings + - include: cmd-args-options - include: cmd-args-variables-arithmetic-mappings cmd-args-variables-arithmetic-mappings: @@ -1268,10 +1170,10 @@ contexts: - include: illegal-words cmd-args-end-of-options-then-variables-arithmetic-values: - - include: cmd-args-illegal-options - match: --{{word_break}} scope: keyword.operator.end-of-options.shell set: cmd-args-variables-arithmetic-values + - include: cmd-args-options - include: cmd-args-variables-arithmetic-values cmd-args-variables-arithmetic-values: @@ -1283,10 +1185,10 @@ contexts: - include: illegal-words cmd-args-end-of-options-then-variables-literal-mappings: - - include: cmd-args-illegal-options - match: --{{word_break}} scope: keyword.operator.end-of-options.shell set: cmd-args-variables-literal-mappings + - include: cmd-args-options - include: cmd-args-variables-literal-mappings cmd-args-variables-literal-mappings: @@ -1298,10 +1200,10 @@ contexts: - include: illegal-words cmd-args-end-of-options-then-variables-literal-values: - - include: cmd-args-illegal-options - match: --{{word_break}} scope: keyword.operator.end-of-options.shell set: cmd-args-variables-literal-values + - include: cmd-args-options - include: cmd-args-variables-literal-values cmd-args-variables-literal-values: @@ -3127,6 +3029,10 @@ contexts: ###[ ILLEGALS ]################################################################ + illegal-options: + - match: (--|[-+]){{identifier}} + scope: invalid.illegal.parameter.shell + illegal-stray: - match: '[)}\]]' scope: invalid.illegal.stray.shell diff --git a/ShellScript/Makefile b/ShellScript/Makefile deleted file mode 100644 index 7450965c08..0000000000 --- a/ShellScript/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -# The update script is located in the tools subdirectory because otherwise -# Sublime will read the file during start-up. No need for that. - -all: $(addsuffix .sublime-syntax, $(basename $(wildcard *.yml))) - -%.sublime-syntax: %.yml tools/update-commands.py - @printf "$< ==> $@ ... " - @python tools/update-commands.py $< $@ - @echo "Done." - -test: - @-/usr/bin/env bash test/syntax_test_bash.sh 2>&1 \ - | sed -nE "/^test\/syntax_test_bash.sh: line [[:digit:]]+: syntax .*/p" - -.PHONY: test diff --git a/ShellScript/commands-builtin-shell-bash.sublime-syntax b/ShellScript/commands-builtin-shell-bash.sublime-syntax deleted file mode 100644 index a8b33948f4..0000000000 --- a/ShellScript/commands-builtin-shell-bash.sublime-syntax +++ /dev/null @@ -1,471 +0,0 @@ -%YAML 1.2 ---- -# Automatically generated file -- do not edit! -# -# The main context is filled with relevant rules by the Bash.sublime-syntax -# Don't include `cmd-builtin` here as essential contexts are missing in this -# abstract syntax defintion. -scope: commands.builtin.shell.bash -version: 2 -hidden: true -contexts: - main: [] - cmd-builtins: - - match: bind{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.bind.shell - push: - - cmd-args-meta - - cmd-bind-args - - match: builtin{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.builtin.shell - push: - - cmd-args-meta - - cmd-builtin-args - - match: caller{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.caller.shell - push: - - cmd-args-meta - - cmd-caller-args - - match: :{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.colon.shell - push: - - cmd-args-meta - - cmd-colon-args - - match: command{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.command.shell - push: - - cmd-args-meta - - cmd-command-args - - match: cd{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.cd.shell - push: - - cmd-args-meta - - cmd-cd-args - - match: \.{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.dot.shell - push: - - cmd-args-meta - - cmd-dot-args - - match: enable{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.enable.shell - push: - - cmd-args-meta - - cmd-enable-args - - match: help{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.help.shell - push: - - cmd-args-meta - - cmd-help-args - - match: logout{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.logout.shell - push: - - cmd-args-meta - - cmd-logout-args - - match: mapfile{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.mapfile.shell - push: - - cmd-args-meta - - cmd-mapfile-args - - match: printf{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.printf.shell - push: - - cmd-args-meta - - cmd-printf-args - - match: read{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.read.shell - push: - - cmd-args-meta - - cmd-read-args - - match: readarray{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.readarray.shell - push: - - cmd-args-meta - - cmd-readarray-args - - match: source{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.source.shell - push: - - cmd-args-meta - - cmd-source-args - - match: type{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.type.shell - push: - - cmd-args-meta - - cmd-type-args - - match: ulimit{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.ulimit.shell - push: - - cmd-args-meta - - cmd-ulimit-args - - match: eval{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.eval.shell - push: - - cmd-args-meta - - cmd-eval-args - - match: getopts{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.getopts.shell - push: - - cmd-args-meta - - cmd-getopts-args - - match: hash{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.hash.shell - push: - - cmd-args-meta - - cmd-hash-args - - match: pwd{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.pwd.shell - push: - - cmd-args-meta - - cmd-pwd-args - - match: shift{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.shift.shell - push: - - cmd-args-meta - - cmd-shift-args - - match: times{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.times.shell - push: - - cmd-args-meta - - cmd-times-args - - match: trap{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.trap.shell - push: - - cmd-args-meta - - cmd-trap-args - - match: umask{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.umask.shell - push: - - cmd-args-meta - - cmd-umask-args - - match: set{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.set.shell - push: - - cmd-args-meta - - cmd-set-args - - match: shopt{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.shopt.shell - push: - - cmd-args-meta - - cmd-shopt-args - - match: bg{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.bg.shell - push: - - cmd-args-meta - - cmd-bg-args - - match: fg{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.fg.shell - push: - - cmd-args-meta - - cmd-fg-args - - match: jobs{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.jobs.shell - push: - - cmd-args-meta - - cmd-jobs-args - - match: kill{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.kill.shell - push: - - cmd-args-meta - - cmd-kill-args - - match: wait{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.wait.shell - push: - - cmd-args-meta - - cmd-wait-args - - match: disown{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.disown.shell - push: - - cmd-args-meta - - cmd-disown-args - - match: suspend{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.suspend.shell - push: - - cmd-args-meta - - cmd-suspend-args - - match: su{{cmd_break}} - scope: meta.function-call.identifier.shell support.function.su.shell - push: - - cmd-args-meta - - cmd-su-args - cmd-bind-args: - - include: cmd-args-end - - include: cmd-args-end-of-options-then-ambigious - - match: ([-+])[lpsvPSVX]*[mqurfx] - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - push: cmd-args-option-maybe-value - - match: ([-+])[lpsvPSVX]+ - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - - include: cmd-args-values - cmd-builtin-args: - - include: cmd-args-end - - include: cmd-args-end-of-options-then-ambigious - - include: cmd-args-values - cmd-caller-args: - - include: cmd-args-end - - include: cmd-args-end-of-options-then-ambigious - - include: cmd-args-values - cmd-colon-args: - - include: cmd-args-end - - include: cmd-args-values - cmd-command-args: - - include: cmd-args-end - - include: cmd-args-end-of-options-then-ambigious - - match: ([-+])[pVv]+ - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - - include: cmd-args-values - cmd-cd-args: - - include: cmd-args-end - - include: cmd-args-end-of-options-then-ambigious - - match: ([-+])[LPe@] - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - push: cmd-args-option-maybe-value - - include: cmd-args-values - cmd-dot-args: - - include: cmd-args-end - - include: cmd-args-values - cmd-enable-args: - - include: cmd-args-end - - include: cmd-args-end-of-options-then-ambigious - - match: ([-+])[dnps]*[af] - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - push: cmd-args-option-maybe-value - - match: ([-+])[dnps]+ - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - - include: cmd-args-values - cmd-help-args: - - include: cmd-args-end - - include: cmd-args-end-of-options-then-ambigious - - match: ([-+])[dms]+ - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - - include: cmd-args-values - cmd-logout-args: - - include: cmd-args-end - - include: cmd-args-end-of-options-then-ambigious - - include: cmd-args-values - cmd-mapfile-args: - - include: cmd-args-end - - include: cmd-args-end-of-options-then-ambigious - - match: ([-+])[dnOstuCc] - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - push: cmd-args-option-maybe-value - - include: cmd-args-values - cmd-printf-args: - - include: cmd-args-end - - include: cmd-args-end-of-options-then-ambigious - - match: ([-+])[v] - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - push: cmd-args-option-maybe-value - - include: cmd-args-values - cmd-read-args: - - include: cmd-args-end - - include: cmd-args-end-of-options-then-ambigious - - match: ([-+])[ers]*[adeinNprstu] - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - push: cmd-args-option-maybe-value - - match: ([-+])[ers]+ - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - - include: cmd-args-values - cmd-readarray-args: - - include: cmd-args-end - - include: cmd-args-end-of-options-then-ambigious - - match: ([-+])[ers]*[adeinNprstu] - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - push: cmd-args-option-maybe-value - - match: ([-+])[ers]+ - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - - include: cmd-args-values - cmd-source-args: - - include: cmd-args-end - - include: cmd-args-end-of-options-then-ambigious - - include: cmd-args-values - cmd-type-args: - - include: cmd-args-end - - include: cmd-args-end-of-options-then-ambigious - - match: ([-+])[afptP]+ - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - - include: cmd-args-values - cmd-ulimit-args: - - include: cmd-args-end - - include: cmd-args-end-of-options-then-ambigious - - match: ([-+])[HSabcdefiklmnpqrstuvxPT]+ - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - - include: cmd-args-values - cmd-eval-args: - - include: cmd-args-end - - include: cmd-args-values - cmd-getopts-args: - - include: cmd-args-end - - include: cmd-args-end-of-options-then-ambigious - - include: cmd-args-values - cmd-hash-args: - - include: cmd-args-end - - include: cmd-args-end-of-options-then-ambigious - - match: ([-+])[dt]*[rpl] - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - push: cmd-args-option-maybe-value - - match: ([-+])[dt]+ - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - - include: cmd-args-values - cmd-pwd-args: - - include: cmd-args-end - - include: cmd-args-end-of-options-then-ambigious - - match: ([-+])[LP]+ - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - - include: cmd-args-values - cmd-shift-args: - - include: cmd-args-end - - include: cmd-args-values - cmd-times-args: - - include: cmd-args-end - - include: cmd-args-end-of-options-then-ambigious - - include: cmd-args-values - cmd-trap-args: - - include: cmd-args-end - - include: cmd-args-end-of-options-then-ambigious - - match: ([-+])[lp]+ - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - - include: cmd-args-values - cmd-umask-args: - - include: cmd-args-end - - include: cmd-args-end-of-options-then-ambigious - - match: ([-+])[pS] - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - push: cmd-args-option-maybe-value - - include: cmd-args-values - cmd-set-args: - - include: cmd-args-end - - include: cmd-args-end-of-options-then-ambigious - - match: ([-+])[abefhkmnptuvxBCEHPT]*[o] - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - push: cmd-args-option-maybe-value - - match: ([-+])[abefhkmnptuvxBCEHPT]+ - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - - include: cmd-args-values - cmd-shopt-args: - - include: cmd-args-end - - include: cmd-args-end-of-options-then-ambigious - - match: ([-+])[pqsu]*[o] - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - push: cmd-args-option-maybe-value - - match: ([-+])[pqsu]+ - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - - include: cmd-args-values - cmd-bg-args: - - include: cmd-args-end - - include: cmd-args-end-of-options-then-ambigious - - include: cmd-args-values - cmd-fg-args: - - include: cmd-args-end - - include: cmd-args-end-of-options-then-ambigious - - include: cmd-args-values - cmd-jobs-args: - - include: cmd-args-end - - include: cmd-args-end-of-options-then-ambigious - - match: ([-+])[lnprs]*[x] - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - push: cmd-args-option-maybe-value - - match: ([-+])[lnprs]+ - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - - include: cmd-args-values - cmd-kill-args: - - include: cmd-args-end - - include: cmd-args-end-of-options-then-ambigious - - match: ([-+])[snlL]+ - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - - include: cmd-args-values - cmd-wait-args: - - include: cmd-args-end - - include: cmd-args-end-of-options-then-ambigious - - match: ([-+])[fnp]+ - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - - include: cmd-args-values - cmd-disown-args: - - include: cmd-args-end - - include: cmd-args-end-of-options-then-ambigious - - match: ([-+])[ar]*[h] - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - push: cmd-args-option-maybe-value - - match: ([-+])[ar]+ - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - - include: cmd-args-values - cmd-suspend-args: - - include: cmd-args-end - - include: cmd-args-end-of-options-then-ambigious - - match: ([-+])[f] - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - push: cmd-args-option-maybe-value - - include: cmd-args-values - cmd-su-args: - - include: cmd-args-end - - include: cmd-args-end-of-options-then-ambigious - - match: ([-+])[mp]*[-cls] - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - push: cmd-args-option-maybe-value - - match: ([-+])[mp]+ - scope: meta.parameter.option.shell variable.parameter.option.shell - captures: - 1: punctuation.definition.parameter.shell - - include: cmd-args-values diff --git a/ShellScript/commands-builtin-shell-bash.yml b/ShellScript/commands-builtin-shell-bash.yml deleted file mode 100644 index a545af921e..0000000000 --- a/ShellScript/commands-builtin-shell-bash.yml +++ /dev/null @@ -1,155 +0,0 @@ -%YAML 1.2 ---- -###[ BUILTIN BASH COMMANDS ]################################################### - -bind: - short-options: mqurfx - short-options-compact: lpsvPSVX - -builtin: - ~ - -caller: - ~ - -colon: - match: ":" - allow-end-of-options-token: false - scope: support.function.colon.shell - -command: - short-options-compact: pVv - -cd: - short-options: LPe@ - -dot: - match: "\\." - allow-end-of-options-token: false - scope: support.function.dot.shell - -enable: - short-options: af - short-options-compact: dnps - -help: - short-options-compact: dms - -logout: - ~ - -mapfile: - short-options: dnOstuCc - -printf: - short-options: v - -read: - short-options-compact: ers - short-options: adeinNprstu - -readarray: - short-options-compact: ers - short-options: adeinNprstu - -source: - allow-end-of-options-token: false - scope: support.function.dot.shell - -type: - short-options-compact: afptP - -ulimit: - short-options-compact: HSabcdefiklmnpqrstuvxPT - -# "unalias" is handled in the syntax def, don't put it here! - -eval: - allow-end-of-options-token: false - -# "exec" is handled in the syntax def, don't put it here! - -# "exit" is handled as keyword.control.flow in the syntax def, don't put it here! - -# "export" is handled as storage.modifier in the syntax def, don't put it here! -# export, readonly, declare, local, typeset - -getopts: - ~ - -hash: - short-options: rpl - short-options-compact: dt - -pwd: - short-options-compact: LP - -# "readonly" is handled as storage.modifier in the syntax def, don't put it here! - -# "return" is handled as keyword.control.flow in the syntax def, don't put it here! - -shift: - allow-end-of-options-token: false - allow-numeric-args: true - -times: - ~ - -trap: - short-options-compact: lp - -umask: - short-options: pS - allow-numeric-args: true - -# "unset" is handled in the syntax def, don't put it here! - -# "echo" is handled in the syntax def, don't put it here! - -set: - short-options-compact: abefhkmnptuvxBCEHPT - short-options: o - allow-end-of-options-token: true - allow-short-end-of-options-token: true - -source: - ~ - -shopt: - short-options-compact: pqsu - short-options: o - -# These are from -# https://www.gnu.org/software/bash/manual/bash.html#Job-Control-Builtins - -bg: - ~ - -fg: - ~ - -jobs: - short-options-compact: lnprs - short-options: x - -kill: - short-options-compact: snlL - # TODO: -sigspec - -wait: - short-options-compact: "fnp" - -disown: - short-options-compact: ar - short-options: h - -suspend: - short-options: f - -###[ BUILTIN LINUX COMMANDS ]################################################## - -su: - allow-end-of-options-token: true - short-options-compact: mp - short-options: -cls -... diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index 0fd51bcd4f..60ed4a1d63 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -105,14 +105,14 @@ $(( echo hello, world! #^^^^^^^^^^^^^^^^^ - meta.function-call meta.function-call -# <- meta.function-call.identifier.shell support.function.echo.shell -#^^^ meta.function-call.identifier.shell support.function.echo.shell +# <- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell support.function.shell # ^^^^^^^^^^^^^^ meta.function-call.arguments.shell - variable # ^ - meta.function-call echo hello, \ -# <- meta.function-call.identifier.shell support.function.echo.shell -#^^^ meta.function-call.identifier.shell support.function.echo.shell +# <- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell support.function.shell # ^^^^^^^^^^ meta.function-call.arguments.shell # ^ punctuation.separator.continuation.line.shell # ^ - punctuation @@ -142,7 +142,7 @@ echo This is a smiley :-\) \(I have to escape the parentheses, though!\) # ^^ constant.character.escape.shell echo the q"uick" f"ox" ju"mp"ed o"ve"r t'he' 'la'zy 'dog' -#^^^ meta.function-call.identifier.shell support.function.echo.shell +#^^^ meta.function-call.identifier.shell support.function.shell # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell # ^ - meta.function-call # ^ punctuation.definition.string.begin.shell @@ -168,7 +168,7 @@ echo the q"uick" f"ox" ju"mp"ed o"ve"r t'he' 'la'zy 'dog' # ^ punctuation.definition.string.end.shell echo 'no\e$capes\in\$ingle\quotes' -#^^^ meta.function-call.identifier.shell support.function.echo.shell +#^^^ meta.function-call.identifier.shell support.function.shell # ^ meta.function-call.arguments.shell - keyword - string # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell string.quoted.single.shell - constant - keyword - variable # ^ punctuation.definition.string.begin.shell @@ -207,7 +207,7 @@ echo -e "\e[33mcolored text\e[0m uncolored" # ^^^^^ constant.character.escape.color.shell echo -e -a -n <1 ! # unknown options start printed text -#^^^ meta.function-call.identifier.shell support.function.echo.shell +#^^^ meta.function-call.identifier.shell support.function.shell # ^^^^^^^^^ meta.function-call.arguments.shell # ^^ variable.parameter.option.shell # ^^ meta.string.shell string.unquoted.shell @@ -283,7 +283,7 @@ echo `echo \`echo hello, world!\`` # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interpolation.command.shell # ^ - meta.interpolation # ^ punctuation.section.interpolation.begin.shell -# ^^^^ support.function.echo +# ^^^^ support.function # ^^ constant.character.escape # ^^ constant.character.escape # ^ punctuation.section.interpolation.end.shell @@ -293,7 +293,7 @@ echo `echo \`echo hello, world!\\` # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interpolation.command.shell # ^ - meta.interpolation # ^ punctuation.section.interpolation.begin.shell -# ^^^^ support.function.echo +# ^^^^ support.function # ^^ constant.character.escape # ^^ constant.character.escape # ^ punctuation.section.interpolation.end.shell @@ -303,7 +303,7 @@ echo `echo \`echo hello\\\`, world\\\\\`!` # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interpolation.command.shell # ^ - meta.interpolation # ^ punctuation.section.interpolation.begin.shell -# ^^^^ support.function.echo +# ^^^^ support.function # ^^ constant.character.escape # ^^^^ constant.character.escape # ^^^^^^ constant.character.escape @@ -330,7 +330,7 @@ echo git rev-list "$(echo --all)" | grep -P 'c354a80' # ^ string.quoted.double.shell punctuation.definition.string.begin.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^^^^ support.function.echo.shell +# ^^^^ support.function.shell # ^^^^^ - variable # ^ punctuation.section.interpolation.end.shell # ^ string.quoted.double.shell punctuation.definition.string.end.shell @@ -510,8 +510,7 @@ set +Euo pipefail # ^^^ variable.parameter.option.shell - punctuation set +Eou pipefail # ^ variable.parameter.option.shell punctuation.definition.parameter.shell -# ^^ variable.parameter.option.shell - punctuation -# ^ - variable.parameter.option - punctuation +# ^^^ variable.parameter.option.shell - punctuation set -e -- -o {str,ing} # ^^ variable.parameter.option.shell # ^ - variable - keyword @@ -528,28 +527,27 @@ read -d '' -sn 1 -t1 -- -t1 10 # ^^^^ - meta.parameter # ^^^ meta.parameter.option.shell # ^^^ - meta.parameter -# ^^ meta.parameter.option.shell -# ^^^^^^^^^^^ - meta.parameter -#^^^ support.function.read.shell +# ^^^ meta.parameter.option.shell +# ^^^^^^^^^^ - meta.parameter +#^^^ support.function.shell # ^ variable.parameter.option.shell punctuation.definition.parameter.shell # ^ variable.parameter.option.shell - punctuation # ^^ string.quoted.single.shell # ^^^ variable.parameter.option.shell # ^ meta.number.integer.decimal.shell constant.numeric.value.shell -# ^^ variable.parameter.option.shell -# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^^^ variable.parameter.option.shell # ^^ keyword.operator.end-of-options.shell # ^^^^ - constant - variable # ^^ constant.numeric.value.shell shift 2 -- -#^^^^ meta.function-call.identifier.shell support.function.shift.shell +#^^^^ meta.function-call.identifier.shell support.function.shell # ^^^^^ meta.function-call.arguments.shell # ^ meta.number.integer.decimal.shell constant.numeric.value.shell -# ^^ - keyword +# ^^ keyword.operator.end-of-options.shell umask 0777 -#^^^^ meta.function-call.identifier.shell support.function.umask.shell +#^^^^ meta.function-call.identifier.shell support.function.shell # ^^^^^ meta.function-call.arguments.shell # ^ meta.number.integer.octal.shell constant.numeric.base.shell # ^^^ meta.number.integer.octal.shell constant.numeric.value.shell @@ -735,7 +733,7 @@ sleep 2 & jobs # ^^ meta.function-call.arguments.shell # ^^^ - meta.function-call # ^ keyword.operator -# ^^^^ meta.function-call.identifier.shell support.function.jobs.shell +# ^^^^ meta.function-call.identifier.shell support.function.shell {foo} -o --option -- -o # <- meta.function-call.identifier.shell variable.function.shell - meta.interpolation @@ -774,8 +772,8 @@ ${foo}/${bar}/${baz} # ^^^^^^ meta.interpolation.parameter.shell - variable.function echo>foo.txt -# <- meta.function-call.identifier.shell support.function.echo.shell -#^^^ meta.function-call.identifier.shell support.function.echo.shell +# <- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell support.function.shell # ^^^^^^^^ meta.function-call.arguments.shell - support.function # ^ keyword.operator.assignment.redirection.shell @@ -786,11 +784,11 @@ ls>foo.txt # ^ keyword.operator.assignment.redirection.shell cd foo/bar-2345 -#^ meta.function-call.identifier.shell support.function.cd.shell +#^ meta.function-call.identifier.shell support.function.shell # ^^^^^^^^^^^^^ meta.function-call.arguments.shell - constant.numeric cd foo/bar2345 -#^ meta.function-call.identifier.shell support.function.cd.shell +#^ meta.function-call.identifier.shell support.function.shell # ^^^^^^^^^^^^ meta.function-call.arguments.shell - constant.numeric @@ -933,7 +931,7 @@ for x; do # ^ punctuation.terminator.statement.shell # ^^ keyword.control.loop.do.shell echo "${!x}" -# ^^^^ meta.function-call.identifier.shell support.function.echo.shell +# ^^^^ meta.function-call.identifier.shell support.function.shell # ^^^^^^^^ meta.function-call.arguments.shell done #<- keyword.control.loop.end.shell @@ -953,7 +951,7 @@ for (( i = 0; i < 10; i++ )); do # ^ punctuation.terminator.statement.shell # ^^ keyword.control.loop.do.shell echo $i - # <- meta.function-call support.function.echo.shell + # <- meta.function-call support.function.shell # ^ meta.function-call.arguments punctuation.definition.variable.shell # ^ meta.function-call.arguments variable.other.readwrite.shell done @@ -975,7 +973,7 @@ for (( i = 0; i < 10; i++ )) #; do do #<- keyword.control.loop.do.shell echo $i - # <- meta.function-call support.function.echo.shell + # <- meta.function-call support.function.shell # ^ meta.function-call.arguments punctuation.definition.variable.shell # ^ meta.function-call.arguments variable.other.readwrite.shell done @@ -986,7 +984,7 @@ for \ # ^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.arithmetic.shell # ^^ keyword.control.loop.do.shell # ^^^^^^^ meta.function-call -# ^^^^ support.function.echo.shell +# ^^^^ support.function.shell # ^^ variable.other.readwrite.shell # ^ punctuation.terminator.statement.shell # ^^^^ keyword.control.loop.end.shell @@ -1004,7 +1002,7 @@ for i in str1 $str2 "str3" 'str4' st$r5; do echo $i; done; # ^^^ meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell # ^ punctuation.terminator.statement.shell # ^^ keyword.control.loop.do.shell -# ^^^^ meta.function-call.identifier.shell support.function.echo.shell +# ^^^^ meta.function-call.identifier.shell support.function.shell # ^^ meta.function-call.arguments.shell meta.interpolation.parameter.shell variable.other.readwrite.shell # ^ punctuation.terminator.statement.shell # ^^^^ keyword.control.loop.end.shell @@ -1025,7 +1023,7 @@ for i in for in do echo done; do echo $i; done; # ^^^^ meta.string.shell string.unquoted.shell # ^ punctuation.terminator.statement.shell # ^^ keyword.control.loop.do.shell -# ^^^^ support.function.echo.shell +# ^^^^ support.function.shell # ^^ variable.other.readwrite.shell # ^ punctuation.terminator.statement.shell # ^^^^ keyword.control.loop.end.shell @@ -1044,7 +1042,7 @@ for i in { [ \( ; do echo $i; done; # ^ - meta.string # ^ punctuation.terminator.statement.shell # ^^ keyword.control.loop.do.shell -# ^^^^ support.function.echo.shell +# ^^^^ support.function.shell # ^^ variable.other.readwrite.shell # ^ punctuation.terminator.statement.shell # ^^^^ keyword.control.loop.end.shell @@ -1057,7 +1055,7 @@ for i in &1 #^^^^^ keyword.declaration.coproc.shell # ^^ variable.function.shell # ^ punctuation.terminator.statement.shell -# ^^^^ support.function.read.shell +# ^^^^ support.function.shell # ^ punctuation.terminator.statement.shell # ^ meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell # ^^ keyword.operator.assignment.redirection.shell @@ -2262,7 +2260,7 @@ coproc { ls thisfiledoesntexist; read; 2>&1 } | foo # ^ punctuation.section.compound.begin.shell # ^^ variable.function.shell # ^ punctuation.terminator.statement.shell -# ^^^^ support.function.read.shell +# ^^^^ support.function.shell # ^ punctuation.terminator.statement.shell # ^ meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell # ^^ keyword.operator.assignment.redirection.shell @@ -2282,7 +2280,7 @@ coproc myls { ls thisfiledoesntexist; read; 2>&1 } | foo # ^ punctuation.section.compound.begin.shell # ^^ variable.function.shell # ^ punctuation.terminator.statement.shell -# ^^^^ support.function.read.shell +# ^^^^ support.function.shell # ^ punctuation.terminator.statement.shell # ^ meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell # ^^ keyword.operator.assignment.redirection.shell @@ -2326,7 +2324,7 @@ coproc foobar { # ^ punctuation.section.compound.begin.shell read #^^^^^^^^ meta.coproc.command.shell meta.compound.command.shell -# ^^^^ meta.coproc.command.shell meta.compound.command.shell meta.function-call.identifier.shell support.function.read.shell +# ^^^^ meta.coproc.command.shell meta.compound.command.shell meta.function-call.identifier.shell support.function.shell } # <- meta.coproc.command.shell meta.compound.command.shell punctuation.section.compound.end.shell #^ - meta @@ -2473,7 +2471,7 @@ function () ; {} arg # ^^ meta.function.body.shell meta.block.shell # ^^^^ invalid.illegal.unexpected-token.shell # ^ punctuation.terminator.statement.shell -# ^^^^ support.function.echo.shell +# ^^^^ support.function.shell # ^^^^ meta.string.shell string.unquoted.shell func () {} rest && echo done @@ -2484,7 +2482,7 @@ function () ; {} arg # ^^ meta.function.body.shell meta.block.shell # ^^^^ invalid.illegal.unexpected-token.shell # ^^ keyword.operator.logical.shell -# ^^^^ support.function.echo.shell +# ^^^^ support.function.shell # ^^^^ meta.string.shell string.unquoted.shell logC () { [[ $# == 2 ]] && tput setaf $2 || tput setaf 3; echo -e "$1"; tput setaf 15; } @@ -2531,7 +2529,7 @@ logExit ( ) { #^ meta.compound.conditional.shell punctuation.section.compound.begin.shell # ^^ meta.compound.conditional.shell punctuation.section.compound.end.shell # ^^ keyword.operator.logical.shell - # ^^^^ meta.function-call.identifier.shell support.function.echo.shell + # ^^^^ meta.function-call.identifier.shell support.function.shell tput setaf 15; # <- meta.function meta.function-call variable.function # ^ meta.function punctuation.terminator.statement @@ -2613,7 +2611,7 @@ function foo ( ) { # ^ punctuation.section.block.begin.shell echo 'hello from foo' # <- meta.function.body.shell meta.block.shell meta.function-call.identifier.shell - # <- support.function.echo.shell + # <- support.function.shell } # <- meta.function.body.shell meta.block.shell punctuation.section.block.end.shell #^ - meta.function @@ -2628,7 +2626,7 @@ f () ( # ^ meta.function.body.shell meta.block.shell punctuation.section.block.begin.shell echo hello # <- meta.function.body.shell meta.block.shell meta.function-call.identifier.shell - # <- support.function.echo.shell + # <- support.function.shell ) # <- meta.function.body.shell meta.block.shell punctuation.section.block.end.shell #^ - meta.function @@ -2642,7 +2640,7 @@ function f ( # ^ entity.name.function.shell # ^ punctuation.section.block.begin.shell echo hello - # <- meta.function meta.function-call support.function.echo + # <- meta.function meta.function-call support.function ) # <- meta.function.body.shell meta.block.shell punctuation.section.block.end.shell #^ - meta.function @@ -3240,7 +3238,7 @@ foo=`cd -L` # ^^^ meta.string.shell meta.interpolation.command.shell meta.function-call.arguments.shell # ^ meta.string.shell meta.interpolation.command.shell # ^ punctuation.section.interpolation.begin.shell -# ^^ support.function.cd.shell +# ^^ support.function.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell # ^ punctuation.section.interpolation.end.shell @@ -3250,7 +3248,7 @@ foo=`echo -e` # ^^^ meta.string.shell meta.interpolation.command.shell meta.function-call.arguments.shell # ^ meta.string.shell meta.interpolation.command.shell # ^ punctuation.section.interpolation.begin.shell -# ^^^^ support.function.echo.shell +# ^^^^ support.function.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell # ^ punctuation.section.interpolation.end.shell @@ -3260,7 +3258,7 @@ foo=`let 5+5` # ^^^^ meta.string.shell meta.interpolation.command.shell meta.function-call.arguments.shell meta.arithmetic.shell # ^ meta.string.shell meta.interpolation.command.shell # ^ punctuation.section.interpolation.begin.shell -# ^^^ support.function.let.shell +# ^^^ support.function.shell # ^ meta.number.integer.decimal.shell constant.numeric.value.shell # ^ keyword.operator.arithmetic.shell # ^ meta.number.integer.decimal.shell constant.numeric.value.shell @@ -8706,7 +8704,7 @@ LC_ALL=C 2> /dev/null # <- meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell #^^ keyword.operator.assignment.redirection # ^ meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell -# ^^^^ meta.function-call support.function.echo +# ^^^^ meta.function-call support.function # ^^^^ meta.function-call.arguments touch file.txt @@ -8739,7 +8737,7 @@ cat </dev/null -#^^ support.function.let.shell +#^^ support.function.shell let - -#^^ support.function.let.shell +#^^ support.function.shell let() -#^^ support.function.let.shell +#^^ support.function.shell let[] #^^^^ - storage - keyword.declaration let{} @@ -10041,10 +10039,10 @@ let+= #^^^^ - storage - keyword.declaration let expr 'expr' "expr" -# <- meta.function-call.identifier.shell support.function.let.shell +# <- meta.function-call.identifier.shell support.function.shell #^^ meta.function-call.identifier.shell # ^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.arithmetic.shell -#^^ support.function.let.shell +#^^ support.function.shell # ^^^^ variable.other.readwrite.shell # ^ punctuation.definition.quoted.begin.shell # ^^^^ variable.other.readwrite.shell @@ -10065,13 +10063,13 @@ let 5+5 # comment #^^ meta.function-call.identifier.shell # ^^^^ meta.function-call.arguments.shell meta.arithmetic.shell # ^ - meta.arithmetic -#^^ support.function.let.shell +#^^ support.function.shell # ^ meta.number.integer.decimal.shell constant.numeric.value.shell # ^ keyword.operator.arithmetic.shell # ^ meta.number.integer.decimal.shell constant.numeric.value.shell let var[10]=5*(20+$idx) -# <- meta.function-call.identifier.shell support.function.let.shell +# <- meta.function-call.identifier.shell support.function.shell #^^ meta.function-call.identifier.shell # ^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.arithmetic.shell # ^^^ meta.variable.shell variable.other.readwrite.shell @@ -10089,11 +10087,11 @@ let var[10]=5*(20+$idx) # ^ punctuation.section.group.end.shell let "two=5+5"; if [[ "$X" == "1" ]]; then X="one"; fi -# <- meta.function-call.identifier.shell support.function.let.shell +# <- meta.function-call.identifier.shell support.function.shell #^^ meta.function-call.identifier.shell # ^^^^^^^^^^ meta.function-call.arguments.shell meta.arithmetic.shell # ^ - meta.function-call - meta.arithmetic -#^^ support.function.let.shell +#^^ support.function.shell # ^ punctuation.definition.quoted.begin.shell # ^^^ variable.other.readwrite.shell # ^ keyword.operator.assignment.shell @@ -10113,11 +10111,11 @@ let "two=5+5"; if [[ "$X" == "1" ]]; then X="one"; fi # ^^ keyword.control.conditional.endif.shell let test -z $2 && { } -#^^ meta.function-call.identifier.shell support.function.let.shell +#^^ meta.function-call.identifier.shell support.function.shell # ^^^^^^^^^^^ meta.function-call.arguments.shell meta.arithmetic.shell # ^^^^ - meta.arithmetic - meta.compound # ^^^ meta.compound.command.shell -#^^ support.function.let.shell +#^^ support.function.shell # ^^^^ variable.other.readwrite.shell # ^ keyword.operator.arithmetic.shell # ^ variable.other.readwrite.shell @@ -10127,7 +10125,7 @@ let test -z $2 && { } # ^ punctuation.section.compound.end.shell let $var == test -z $5 && cmd -#^^ meta.function-call.identifier.shell support.function.let.shell +#^^ meta.function-call.identifier.shell support.function.shell # ^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.arithmetic.shell # ^^^^^^^^ - meta.arithmetic # ^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell @@ -10140,7 +10138,7 @@ let $var == test -z $5 && cmd # ^^^ variable.function.shell let 'test -z $2 && { }' -#^^ meta.function-call.identifier.shell support.function.let.shell +#^^ meta.function-call.identifier.shell support.function.shell # ^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.arithmetic.shell # ^ punctuation.definition.quoted.begin.shell # ^^^^ variable.other.readwrite.shell @@ -10479,21 +10477,21 @@ typeset -f _init_completion > /dev/null && complete -F _upto upto ############################################################################### test -# <- meta.function-call.identifier.shell support.function.test.shell -#^^^ meta.function-call.identifier.shell support.function.test.shell +# <- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell support.function.shell # ^ - meta.function-call test; -#^^^ support.function.test.shell +#^^^ support.function.shell test& -#^^^ support.function.test.shell +#^^^ support.function.shell test| -#^^^ support.function.test.shell +#^^^ support.function.shell test>/dev/null -#^^^ support.function.test.shell +#^^^ support.function.shell test - -#^^^ support.function.test.shell +#^^^ support.function.shell test() -#^^^ support.function.test.shell +#^^^ support.function.shell test[] #^^^^^ - support.function test{} @@ -10516,39 +10514,39 @@ test+= #^^^^^ - support.function test $var != 0 -#<- meta.function-call.identifier.shell support.function.test.shell -#^^^ meta.function-call.identifier.shell support.function.test.shell +#<- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell support.function.shell # ^^^^^^^^^^ meta.function-call.arguments.shell - meta.string.regexp # ^ - meta.function-call # ^^ keyword.operator.comparison.shell # ^ constant.numeric.value.shell test $var == true -#<- meta.function-call.identifier.shell support.function.test.shell -#^^^ meta.function-call.identifier.shell support.function.test.shell +#<- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell support.function.shell # ^^^^^^^^^^^^^ meta.function-call.arguments.shell - meta.string.regexp # ^^ keyword.operator.comparison.shell # ^^^^ constant.language.boolean.true.shell test str == "str" -#<- meta.function-call.identifier.shell support.function.test.shell -#^^^ meta.function-call.identifier.shell support.function.test.shell +#<- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell support.function.shell # ^^^^^^^^^^^^^ meta.function-call.arguments.shell # ^^^ meta.string.shell string.unquoted.shell # ^^ keyword.operator.comparison.shell # ^^^^^ meta.string.shell string.quoted.double.shell test str != "str" -#<- meta.function-call.identifier.shell support.function.test.shell -#^^^ meta.function-call.identifier.shell support.function.test.shell +#<- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell support.function.shell # ^^^^^^^^^^^^^ meta.function-call.arguments.shell # ^^^ meta.string.shell string.unquoted.shell # ^^ keyword.operator.comparison.shell # ^^^^^ meta.string.shell string.quoted.double.shell test str < 'str' -# <- meta.function-call.identifier.shell support.function.test.shell -#^^^ meta.function-call.identifier.shell support.function.test.shell +# <- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell support.function.shell # ^^^^^^^^^^^^ meta.function-call.arguments.shell # ^ - meta.function-call # ^^^ meta.string.shell string.unquoted.shell @@ -10556,8 +10554,8 @@ test str < 'str' # ^^^^^ meta.string.shell string.quoted.single.shell test str > str -# <- meta.function-call.identifier.shell support.function.test.shell -#^^^ meta.function-call.identifier.shell support.function.test.shell +# <- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell support.function.shell # ^^^^^^^^^^ meta.function-call.arguments.shell # ^ - meta.function-call # ^^^ meta.string.shell string.unquoted.shell @@ -10565,8 +10563,8 @@ test str > str # ^^^ meta.string.shell string.unquoted.shell test var[0] != var[^0-9]*$ -#<- meta.function-call.identifier.shell support.function.test.shell -#^^^ meta.function-call.identifier.shell support.function.test.shell +#<- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell support.function.shell # ^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell # ^^^^^^ meta.string.shell string.unquoted.shell # ^^^ meta.set.regexp.shell @@ -10574,8 +10572,8 @@ test var[0] != var[^0-9]*$ # ^^^^^^^^^^^ meta.string.shell string.unquoted.shell - meta.string.regexp test $var[0] != var[^0-9]*$ -#<- meta.function-call.identifier.shell support.function.test.shell -#^^^ meta.function-call.identifier.shell support.function.test.shell +#<- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell support.function.shell # ^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell # ^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell # ^^^ meta.set.regexp.shell @@ -10583,8 +10581,8 @@ test $var[0] != var[^0-9]*$ # ^^^^^^^^^^^ meta.string.shell string.unquoted.shell - meta.string.regexp test ${var[0]} != var[^0-9]*$ -#<- meta.function-call.identifier.shell support.function.test.shell -#^^^ meta.function-call.identifier.shell support.function.test.shell +#<- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell support.function.shell # ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell # ^^^^^^^^^ meta.interpolation.parameter.shell # ^^^ variable.other.readwrite.shell @@ -10593,8 +10591,8 @@ test ${var[0]} != var[^0-9]*$ # ^^^^^^^^^^^ meta.string.shell string.unquoted.shell - meta.string.regexp test expr -a expr -o expr -- | cmd |& cmd -# <- meta.function-call.identifier.shell support.function.test.shell -#^^^ meta.function-call.identifier.shell support.function.test.shell +# <- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell support.function.shell # ^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell # ^^^ - meta.function-call # ^^ meta.parameter.option.shell variable.parameter.option.shell @@ -10605,22 +10603,22 @@ test expr -a expr -o expr -- | cmd |& cmd # ^^ keyword.operator.assignment.pipe.shell test ! $line == ^[0-9]+$ -# <- meta.function-call.identifier.shell support.function.test.shell +# <- meta.function-call.identifier.shell support.function.shell #^^^ meta.function-call.identifier.shell - meta.function-call.arguments # ^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell - meta.function-call.identifier # ^ - meta.function-call -#^^^ support.function.test.shell +#^^^ support.function.shell # ^ keyword.operator.logical.shell # ^^^^^ variable.other.readwrite.shell # ^^ keyword.operator.comparison.shell # ^^^^^^^^ meta.string.shell string.unquoted.shell test ! $line =~ ^[0-9]+$ >> /file -# <- meta.function-call.identifier.shell support.function.test.shell +# <- meta.function-call.identifier.shell support.function.shell #^^^ meta.function-call.identifier.shell - meta.function-call.arguments # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell - meta.function-call.identifier - meta.group # ^ - meta.function-call -#^^^ support.function.test.shell +#^^^ support.function.shell # ^ keyword.operator.logical.shell # ^^^^^ variable.other.readwrite.shell # ^^ invalid.illegal.operator.shell @@ -10629,19 +10627,19 @@ test ! $line =~ ^[0-9]+$ >> /file if test expr -a expr ; then echo "success"; fi # ^ - meta.function-call -# ^^^^ meta.function-call.identifier.shell support.function.test.shell +# ^^^^ meta.function-call.identifier.shell support.function.shell # ^^^^^^^^^^^^^ meta.function-call.arguments.shell # ^^^^^^^^ - meta.function-call # ^^ meta.parameter.option.shell variable.parameter.option.shell # ^ punctuation.terminator.statement.shell # ^^^^ keyword.control.conditional.then.shell -# ^^^^ support.function.echo.shell +# ^^^^ support.function.shell # ^ punctuation.terminator.statement.shell # ^^ keyword.control.conditional.endif.shell if test "$VAR" != ";";then;fi # ^ - meta.function-call -# ^^^^ meta.function-call.identifier.shell support.function.test.shell +# ^^^^ meta.function-call.identifier.shell support.function.shell # ^^^^^^^^^^^^^^ meta.function-call.arguments.shell # ^^^^^^ meta.string.shell # ^^ keyword.operator.comparison.shell @@ -10660,16 +10658,16 @@ if test "$VAR" != ";";then;fi unalias unalias -a -b -# <- meta.function-call.identifier.shell support.function.unalias.shell -#^^^^^^ meta.function-call.identifier.shell support.function.unalias.shell +# <- meta.function-call.identifier.shell support.function.shell +#^^^^^^ meta.function-call.identifier.shell support.function.shell # ^^^^^^ meta.function-call.arguments.shell # ^ - meta.function # ^^ variable.parameter.option.shell -# ^^ invalid.illegal.parameter.shell +# ^^ variable.parameter.option.shell unalias foo -# <- meta.function-call.identifier.shell support.function.unalias.shell -#^^^^^^ meta.function-call.identifier.shell support.function.unalias.shell +# <- meta.function-call.identifier.shell support.function.shell +#^^^^^^ meta.function-call.identifier.shell support.function.shell # ^^^^ meta.function-call.arguments.shell # ^ - meta.function # ^ - meta.variable - variable @@ -10677,8 +10675,8 @@ unalias foo # ^ - meta.variable - variable unalias foo # comment -# <- meta.function-call.identifier.shell support.function.unalias.shell -#^^^^^^ meta.function-call.identifier.shell support.function.unalias.shell +# <- meta.function-call.identifier.shell support.function.shell +#^^^^^^ meta.function-call.identifier.shell support.function.shell # ^^^^ meta.function-call.arguments.shell # ^^^^^^^^^^ - meta.function # ^ - meta.variable - variable @@ -10694,12 +10692,12 @@ unalias foo # comment unset unset foo b'a'r ba${z} # 'foo' and 'bar' are variable names -# <- meta.function-call.identifier.shell support.function.unset.shell +# <- meta.function-call.identifier.shell support.function.shell #^^^^ meta.function-call.identifier.shell # ^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell # ^ - meta.function-call # ^^^^^ meta.variable.shell -#^^^^ support.function.unset.shell +#^^^^ support.function.shell # ^ - meta.variable - support - variable # ^^^ meta.variable.shell variable.other.readwrite.shell # ^ - meta.variable - variable @@ -10714,11 +10712,11 @@ unset foo b'a'r ba${z} # 'foo' and 'bar' are variable names unset -n unset -nfv foo = == ==cmd cmd=name -# <- meta.function-call.identifier.shell support.function.unset.shell +# <- meta.function-call.identifier.shell support.function.shell #^^^^ meta.function-call.identifier.shell # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell # ^ - meta.function-call -#^^^^ support.function.unset.shell +#^^^^ support.function.shell # ^^^^ meta.parameter.option.shell variable.parameter.option.shell # ^ - variable # ^^^ variable.function.shell @@ -10733,7 +10731,7 @@ unset -nfv foo = == ==cmd cmd=name # ^ - variable unset -f -n -v foo b'a'r; unset -vn foo 2>& /dev/null -# <- meta.function-call.identifier.shell support.function.unset.shell +# <- meta.function-call.identifier.shell support.function.shell #^^^^ meta.function-call.identifier.shell # ^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell # ^^ - meta.function-call @@ -10750,7 +10748,7 @@ unset -f -n -v foo b'a'r; unset -vn foo 2>& /dev/null # ^ punctuation.definition.quoted.begin.shell # ^ punctuation.definition.quoted.end.shell # ^ punctuation.terminator.statement.shell -# ^^^^^ support.function.unset.shell +# ^^^^^ support.function.shell # ^ - support - variable # ^^^ meta.parameter.option.shell variable.parameter.option.shell # ^ - variable @@ -10760,7 +10758,7 @@ unset -f -n -v foo b'a'r; unset -vn foo 2>& /dev/null # ^^ keyword.operator.assignment.redirection.shell unset -f -x +v -- foo bar; unset -vn -- foo -# <- meta.function-call.identifier.shell support.function.unset.shell +# <- meta.function-call.identifier.shell support.function.shell #^^^^ meta.function-call.identifier.shell # ^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell # ^^ - meta.function-call @@ -10768,7 +10766,7 @@ unset -f -x +v -- foo bar; unset -vn -- foo # ^^^^^^^^^^^ meta.function-call.arguments.shell # ^ - meta.function-call # ^^ meta.parameter.option.shell variable.parameter.option.shell -# ^^ invalid.illegal.parameter.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell # ^^^^ - variable # ^^ keyword.operator.end-of-options.shell @@ -10776,7 +10774,7 @@ unset -f -x +v -- foo bar; unset -vn -- foo # ^ - variable # ^^^ variable.function.shell # ^ punctuation.terminator.statement.shell -# ^^^^^ support.function.unset.shell +# ^^^^^ support.function.shell # ^ - support - variable # ^^^ meta.parameter.option.shell variable.parameter.option.shell # ^^^^ - variable @@ -10789,7 +10787,7 @@ unset- unset+ # <- - support.function unset() -# <- support.function.unset.shell +# <- support.function.shell unset[] # <- - support.function unset{} @@ -10807,16 +10805,16 @@ unset-= ############################################################################### sudo rm -rf -# <- meta.function-call.identifier.shell support.function.sudo.shell -#^^^ meta.function-call.identifier.shell support.function.sudo.shell +# <- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell support.function.shell # ^^ meta.function-call.identifier.shell variable.function.shell # ^^^^ meta.function-call.arguments.shell # ^^^ meta.parameter.option.shell variable.parameter.option.shell # ^ punctuation.definition.parameter.shell sudo -b -g network --host=$foo rm -rf -# <- meta.function-call.identifier.shell support.function.sudo.shell -#^^^ meta.function-call.identifier.shell support.function.sudo.shell +# <- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell support.function.shell # ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell # ^^ meta.function-call.identifier.shell # ^^^^ meta.function-call.arguments.shell @@ -10835,8 +10833,8 @@ sudo -b -g network --host=$foo rm -rf # ^ punctuation.definition.parameter.shell sudo --reset-timestamp -n -f -- rm -rf -# <- meta.function-call.identifier.shell support.function.sudo.shell -#^^^ meta.function-call.identifier.shell support.function.sudo.shell +# <- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell support.function.shell # ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell # ^ - meta.function-call # ^^ meta.function-call.identifier.shell @@ -10844,7 +10842,7 @@ sudo --reset-timestamp -n -f -- rm -rf # ^ - meta.function-call # ^^^^^^^^^^^^^^^^^ meta.parameter.option.shell variable.parameter.option.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell -# ^^ invalid.illegal.parameter.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell # ^^ keyword.operator.end-of-options.shell # ^^ variable.function.shell # ^^^ meta.parameter.option.shell variable.parameter.option.shell @@ -11334,7 +11332,7 @@ sudo --reset-timestamp -n -f -- rm -rf [ ] -# <- - meta.conditional - support.function.test +# <- - meta.conditional - support.function [ \ ] @@ -11814,43 +11812,43 @@ true false ############################################################################### fg fg -# <- meta.function-call.identifier.shell support.function.fg.shell -#^ meta.function-call.identifier.shell support.function.fg.shell +# <- meta.function-call.identifier.shell support.function.shell +#^ meta.function-call.identifier.shell support.function.shell # ^^^ meta.function-call.arguments.shell - support bg bg -# <- meta.function-call.identifier.shell support.function.bg.shell -#^ meta.function-call.identifier.shell support.function.bg.shell +# <- meta.function-call.identifier.shell support.function.shell +#^ meta.function-call.identifier.shell support.function.shell # ^^^ meta.function-call.arguments.shell - support jobs jobs -# <- meta.function-call.identifier.shell support.function.jobs.shell -#^^^ meta.function-call.identifier.shell support.function.jobs.shell +# <- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell support.function.shell # ^^^^^ meta.function-call.arguments.shell - support kill -s -# <- meta.function-call.identifier.shell support.function.kill.shell -#^^^ meta.function-call.identifier.shell support.function.kill.shell +# <- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell support.function.shell # ^^^ meta.function-call.arguments.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell wait -fn -p varname -# <- meta.function-call.identifier.shell support.function.wait.shell -#^^^ meta.function-call.identifier.shell support.function.wait.shell +# <- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell support.function.shell # ^^^^^^^^^^^^^^^ meta.function-call.arguments.shell # ^^^ meta.parameter.option.shell variable.parameter.option.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell # ^^^^^^^ meta.string.shell string.unquoted.shell disown -ar -# <- meta.function-call.identifier.shell support.function.disown.shell -#^^^^^ meta.function-call.identifier.shell support.function.disown.shell +# <- meta.function-call.identifier.shell support.function.shell +#^^^^^ meta.function-call.identifier.shell support.function.shell # ^^^^ meta.function-call.arguments.shell # ^^^ meta.parameter.option.shell variable.parameter.option.shell suspend -f -# <- meta.function-call.identifier.shell support.function.suspend.shell -#^^^^^^ meta.function-call.identifier.shell support.function.suspend.shell +# <- meta.function-call.identifier.shell support.function.shell +#^^^^^^ meta.function-call.identifier.shell support.function.shell # ^^^ meta.function-call.arguments.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell diff --git a/ShellScript/tools/update-commands.py b/ShellScript/tools/update-commands.py deleted file mode 100644 index c1c97f6a33..0000000000 --- a/ShellScript/tools/update-commands.py +++ /dev/null @@ -1,108 +0,0 @@ -import os -import sys -import yaml - - -def main(): - with open(sys.argv[1], "r") as stream: - commands_input = yaml.load(stream, Loader=yaml.SafeLoader) - - main = [] - contexts = { - "main": [], - "cmd-builtins": main - } - - for command, value in commands_input.items(): - if not value: - value = {} - - cmd_args = [{"include": "cmd-args-end"}] - - allow_eoo = value.get("allow-end-of-options-token", True) - if allow_eoo: - cmd_args.append({"include": "cmd-args-end-of-options-then-ambigious"}) - - long_options = value.get("long-options") - if long_options: - cmd_args.append({ - "match": rf"(--)(?:{'|'.join(long_options)}){{{{opt_break}}}}", - "scope": "meta.parameter.option.shell variable.parameter.option.shell", - "captures": { - 1: "punctuation.definition.parameter.shell" - }, - "push": "cmd-args-option-maybe-assignment" - }) - - short_options = value.get("short-options") - short_options_compact = value.get("short-options-compact") - - if short_options: - if short_options_compact: - opts = f"[{short_options_compact}]*[{short_options}]" - else: - opts = f"[{short_options}]" - - cmd_args.append({ - "match": rf"([-+]){opts}", - "scope": "meta.parameter.option.shell variable.parameter.option.shell", - "captures": { - 1: "punctuation.definition.parameter.shell" - }, - "push": "cmd-args-option-maybe-value" - }) - - if short_options_compact: - cmd_args.append({ - "match": rf"([-+])[{short_options_compact}]+", - "scope": "meta.parameter.option.shell variable.parameter.option.shell", - "captures": { - 1: "punctuation.definition.parameter.shell" - } - }) - - cmd_args.append({"include": "cmd-args-values"}) - - contexts[f"cmd-{command}-args"] = cmd_args - - match = f"{value.get('match', command)}{{{{cmd_break}}}}" - scope = "meta.function-call.identifier.shell " + value.get("scope", f"support.function.{command}.shell") - main.append({ - "match": match, - "scope": scope, - "push": ["cmd-args-meta", f"cmd-{command}-args"] - }) - - commands_output = { - "scope": os.path.splitext(sys.argv[1])[0].replace("-", "."), - "version": 2, - "hidden": True, - "contexts": contexts - } - - with open(sys.argv[2], "w") as stream: - print("%YAML 1.2\n---", file=stream) - print( - "# Automatically generated file -- do not edit!\n" - "#\n" - "# The main context is filled with relevant rules by the Bash.sublime-syntax\n" - "# Don't include `cmd-builtin` here as essential contexts are missing in this\n" - "# abstract syntax defintion.", - file=stream - ) - - noalias_dumper = yaml.dumper.SafeDumper - noalias_dumper.ignore_aliases = lambda self, data: True - yaml.dump(commands_output, - stream, - default_flow_style=False, - allow_unicode=True, - default_style='', - sort_keys=False, - Dumper=noalias_dumper) - - return 0 - - -if __name__ == '__main__': - exit(main()) From d939663b8aac99d58213705f14ba2e29ab5d8f17 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 3 Aug 2024 08:34:12 +0200 Subject: [PATCH 049/113] [ShellScript] Refactor context switch architecture This commit... 1. `set`s command arguments' contexts onto stack rather than `pushing` them. 2. adjusts everything for it to work. Results: - a re-usable `statement` context, which consumes a single command and its arguments. - syntax cache size is reduced from 110kB to 88kB by this change - switching contexts of commands to push into if...else blocks etc. becomes much cheaper with regards to compiled syntax size. --- ShellScript/Bash.sublime-syntax | 141 +++++++++++---------------- ShellScript/test/syntax_test_bash.sh | 3 +- 2 files changed, 57 insertions(+), 87 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index bf9d8d9226..0da8e93c9b 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -239,55 +239,33 @@ contexts: statements: - include: comments - - include: line-continuations + - include: terminators + - match: (?=\S) + push: statement + + statement: - include: redirections - include: operators - - include: terminators - include: def-anonymous - include: cmd-alias - include: cmd-arithmetic - include: cmd-compound - - include: cmd-echo - - include: cmd-historic - - include: cmd-sudo - - include: cmd-test - include: cmd-control - include: cmd-coproc - - include: cmd-exec - - include: cmd-unalias - - include: cmd-unset - - include: cmd-builtins - include: cmd-declare - - include: cmd-export - - include: cmd-readonly - - include: def-variables - - include: def-functions - - include: booleans - - include: cmd-basic - - include: illegal-stray - - statement: - - include: redirections - - include: def-anonymous - - include: cmd-alias - - include: cmd-arithmetic - - include: cmd-compound - include: cmd-echo + - include: cmd-exec + - include: cmd-export - include: cmd-historic + - include: cmd-readonly - include: cmd-sudo - include: cmd-test - - include: cmd-control - - include: cmd-coproc - - include: cmd-exec - include: cmd-unalias - include: cmd-unset - - include: cmd-builtins - - include: cmd-declare - - include: cmd-export - - include: cmd-readonly - - include: def-variables - - include: def-functions - - include: booleans + - include: cmd-builtin + - include: def-variable + - include: def-function + - include: boolean - include: eoc-pop - include: cmd-basic - include: illegal-stray @@ -338,7 +316,7 @@ contexts: captures: 1: punctuation.section.parameters.begin.shell 2: punctuation.section.parameters.end.shell - push: def-anonymous-body + set: def-anonymous-body def-anonymous-begin: # anonymous functions are immediatelly called @@ -370,7 +348,7 @@ contexts: ###[ FUNCTION DEFINITIONS ]#################################################### - def-functions: + def-function: # [Bash] 3.3 Shell Functions - match: function{{cmd_break}} scope: keyword.declaration.function.shell @@ -378,8 +356,9 @@ contexts: branch: - def-function-begin - def-anonymous-begin + pop: 1 - match: (?={{cmd_literal}}\s*\(\s*\)) - push: + set: - def-function-body - def-function-params - def-function-name @@ -461,9 +440,9 @@ contexts: ###[ VARIABLE DEFINITIONS ]#################################################### - def-variables: + def-variable: - match: (?={{identifier}}(?:\[[^\]]*\])*{{varassign}}) - push: + set: - literal-array-value-assignment - variable-name-begin @@ -518,7 +497,7 @@ contexts: cmd-alias: - match: alias{{cmd_break}} scope: keyword.declaration.alias.shell - push: + set: - cmd-alias-args-meta - cmd-alias-args @@ -554,10 +533,10 @@ contexts: cmd-arithmetic: - match: \(\( scope: punctuation.section.compound.begin.shell - push: cmd-arithmetic-body + set: cmd-arithmetic-body - match: let{{cmd_break}} scope: meta.function-call.identifier.shell support.function.shell - push: cmd-arithmetic-args + set: cmd-arithmetic-args cmd-arithmetic-body: - meta_scope: meta.compound.arithmetic.shell @@ -579,39 +558,29 @@ contexts: scope: meta.coproc.shell keyword.declaration.coproc.shell - push: cmd-coproc-identifier + set: cmd-coproc-identifier cmd-coproc-identifier: - - match: (\s*)(({{cmd_literal}})\s*)?(\{) + - match: (?:(\s*)(({{cmd_literal}})\s*)?(?=\{))? captures: 1: meta.coproc.shell 2: meta.coproc.identifier.shell 3: entity.name.function.shell - 4: meta.coproc.command.shell meta.compound.command.shell - punctuation.section.compound.begin.shell - set: cmd-coproc-compound-command - - match: '' - set: cmd-coproc-basic-command - - cmd-coproc-basic-command: - - meta_scope: meta.coproc.command.shell - - include: statement + set: + - cmd-coproc-command-meta + - statement - cmd-coproc-compound-command: - - meta_content_scope: meta.coproc.command.shell meta.compound.command.shell - - match: \} - scope: - meta.coproc.command.shell meta.compound.command.shell - punctuation.section.compound.end.shell - pop: 1 - - include: statements + cmd-coproc-command-meta: + - meta_include_prototype: false + - meta_content_scope: meta.coproc.command.shell + - include: immediately-pop ###[ DECLARE BUILTINS ]######################################################## cmd-declare: - match: (declare|local|typeset){{cmd_break}} scope: keyword.declaration.variable.shell - push: + set: - cmd-declare-args-meta - cmd-declare-args @@ -683,7 +652,7 @@ contexts: scope: meta.function-call.identifier.shell support.function.shell - push: cmd-echo-args + set: cmd-echo-args cmd-echo-args: - meta_content_scope: meta.function-call.arguments.shell @@ -707,7 +676,7 @@ contexts: scope: meta.function-call.identifier.shell support.function.shell - push: cmd-exec-args + set: cmd-exec-args cmd-exec-args: - meta_content_scope: meta.function-call.arguments.shell @@ -734,7 +703,7 @@ contexts: scope: meta.function-call.identifier.shell support.function.shell - push: + set: - cmd-args-meta - cmd-export-args @@ -753,7 +722,7 @@ contexts: cmd-readonly: - match: readonly{{cmd_break}} scope: keyword.declaration.variable.shell - push: + set: - cmd-declare-args-meta - cmd-readonly-args @@ -794,7 +763,7 @@ contexts: scope: meta.function-call.identifier.shell support.function.shell - push: cmd-sudo-args + set: cmd-sudo-args cmd-sudo-args: - meta_content_scope: meta.function-call.arguments.shell @@ -819,13 +788,13 @@ contexts: cmd-test: - match: \[\[(?=\s) scope: punctuation.section.compound.begin.shell - push: compound-test-body + set: compound-test-body - match: \[(?=\s) scope: punctuation.section.compound.begin.shell - push: builtin-test-body + set: builtin-test-body - match: test{{cmd_break}} scope: meta.function-call.identifier.shell support.function.shell - push: cmd-test-args + set: cmd-test-args builtin-test-body: - meta_scope: meta.compound.conditional.shell @@ -951,7 +920,7 @@ contexts: scope: meta.function-call.identifier.shell support.function.shell - push: + set: - cmd-args-meta - cmd-args-end-of-options-then-function-references @@ -962,7 +931,7 @@ contexts: scope: meta.function-call.identifier.shell support.function.shell - push: + set: - cmd-args-meta - cmd-unset-args @@ -981,10 +950,10 @@ contexts: cmd-compound: - match: \{{{cmd_break}} scope: punctuation.section.compound.begin.shell - push: cmd-compound-braces-body + set: cmd-compound-braces-body - match: \( scope: punctuation.section.compound.begin.shell - push: cmd-compound-parens-body + set: cmd-compound-parens-body cmd-compound-braces-body: - meta_scope: meta.compound.command.shell @@ -1008,7 +977,7 @@ contexts: - match: \! scope: punctuation.definition.history.shell - cmd-builtins: + cmd-builtin: - match: '{{builtin_cmds}}' scope: meta.function-call.identifier.shell meta.path.shell support.function.shell push: @@ -1018,24 +987,24 @@ contexts: cmd-basic: - match: \$?\" scope: punctuation.definition.quoted.begin.shell - push: + set: - cmd-name-body - path-pattern-double-quoted-body - path-pattern-quoted-begin - match: \$\' scope: punctuation.definition.quoted.begin.shell - push: + set: - cmd-name-body - path-pattern-ansi-c-body - path-pattern-quoted-begin - match: \' scope: punctuation.definition.quoted.begin.shell - push: + set: - cmd-name-body - path-pattern-single-quoted-body - path-pattern-quoted-begin - match: '{{cmd_begin}}' - push: + set: - cmd-name-body - path-pattern-begin @@ -1236,7 +1205,7 @@ contexts: scope: keyword.control.conditional.else.shell - match: case{{cmd_break}} scope: meta.statement.conditional.case.shell keyword.control.conditional.case.shell - push: case-word + set: case-word - match: esac{{cmd_break}} scope: keyword.control.conditional.endcase.shell # loops @@ -1246,10 +1215,10 @@ contexts: scope: keyword.control.loop.end.shell - match: for{{cmd_break}} scope: keyword.control.loop.for.shell - push: for-args + set: for-args - match: select{{cmd_break}} scope: keyword.control.loop.select.shell - push: loop-iterator-var + set: loop-iterator-var - match: until{{cmd_break}} scope: keyword.control.loop.until.shell - match: while{{cmd_break}} @@ -1257,16 +1226,16 @@ contexts: # flow - match: break{{cmd_break}} scope: keyword.control.flow.break.shell - push: flow-args + set: flow-args - match: continue{{cmd_break}} scope: keyword.control.flow.continue.shell - push: flow-args + set: flow-args - match: exit{{cmd_break}} scope: keyword.control.flow.exit.shell - push: flow-args + set: flow-args - match: return{{cmd_break}} scope: keyword.control.flow.return.shell - push: flow-args + set: flow-args case-word: - meta_include_prototype: false diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index 60ed4a1d63..59e7b01c19 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -2255,7 +2255,8 @@ coproc { ls thisfiledoesntexist; read; 2>&1 } | foo # ^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell # ^^ - meta.function-call.identifier.shell # ^^^^ meta.function-call.identifier.shell -# ^^^^^^^^ - meta.function-call.identifier.shell +# ^^^^^^^^^^^ - meta.function-call +# ^^^ meta.function-call.identifier.shell #^^^^^ keyword.declaration.coproc.shell # ^ punctuation.section.compound.begin.shell # ^^ variable.function.shell From adbb88c9b49bc0ce047be89696e61350aeca66d5 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 3 Aug 2024 08:33:28 +0200 Subject: [PATCH 050/113] [ShellScript] Reorganize variables --- ShellScript/Bash.sublime-syntax | 211 ++++++++++++++++----------- ShellScript/test/syntax_test_bash.sh | 8 - 2 files changed, 125 insertions(+), 94 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 0da8e93c9b..1f796f8948 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -45,13 +45,8 @@ first_line_match: |- ############################################################################### variables: - is_interpolation: (?=\$[({{{identifier_char}}{{special_variable}}]|`) - - # posix identifiers (alpha-numeric) - identifier: '{{identifier_first_char}}{{identifier_char}}*' - identifier_first_char: '[[:alpha:]_]' - identifier_char: '[[:alnum:]_]' - identifier_break: (?!{{identifier_char}}) + # Language identifier in shebang + shebang_language: \b(?:bash|zsh|sh|tcsh|ash|dash)\b # Commands literals are command names without interpolation or quotation. cmd_literal: '{{cmd_literal_char}}+{{cmd_break}}' @@ -62,30 +57,85 @@ variables: cmd_break: (?!{{cmd_char}}) cmd_char: '[^{{metachar}}]' - builtin_cmds: |- - (?x: \. | \: | bg | bind | builtin | caller | cd | command | disown | enable - | eval | fg | getopts | hash | help | jobs | kill | logout | mapfile | printf - | pwd | read | readarray | set | shift | shopt | source | su | suspend | times - | type | ulimit | umask | wait ){{cmd_break}} - # Command options are identifiers, which may start with interpolation. opt_punctuation: (--|[-+])(?={{word_char}}) opt_break: (?![^={{metachar}}]) + # Variable names variable_begin: (?={{variable_first_char}}) variable_first_char: '[[:alpha:]_''"$%]' + # POSIX identifiers (alpha-numeric) + identifier: '{{identifier_first_char}}{{identifier_char}}*' + identifier_first_char: '[[:alpha:]_]' + identifier_char: '[[:alnum:]_]' + identifier_break: (?!{{identifier_char}}) + + # Generic identifiers (shell words) word_begin: (?=\S) word_break: (?!{{word_char}}) word_char: '[^{{metachar}}]' - # Shell Parameter Expansions + # A character that, when unquoted, separates words. A metacharacter is a + # space, tab, newline, or one of the following characters: ‘|’, ‘&’, ‘;’, + # ‘(’, ‘)’, ‘<’, or ‘>’. + metachar: '[\s|&;()<>]' + + # Parameter expansions + is_interpolation: (?=\$[({{{identifier_char}}{{special_variables}}]|`) + parameter_switch: '[AEKLPQUaku]' + + # POSIX extended regexp quantifiers + character_quantifier: '[?*+]' + lazy_or_possessive: '[?+]?' + ranged_quantifier: \{\d+(?:,\d*)?\} + + posix_classes: |- + (?x: ascii | alnum | alpha | blank | cntrl | digit | graph + | lower | print | punct | space | upper | word | xdigit ) + + + varassign: '[-+]?=' + wspace: (?:\s+|^) + + no_escape_behind: (?’. - metachar: '[\s|&;()<>]' + ){{identifier_break}} - nbc: '[^{}()=\s]*' # non bracket characters (and also non-whitespace, parens) - varassign: '[-+]?=' - wspace: (?:\s+|^) + # 3.4.2 Special Parameters + # https://www.gnu.org/software/bash/manual/bash.html#Special-Parameters + special_variables: '[$#@!*?-]' - no_escape_behind: (? Date: Sun, 4 Aug 2024 08:21:00 +0200 Subject: [PATCH 051/113] [ShellScript] Tweak loop iterator context structure This commit... 1. adds meta scopes to loop control statements 2. restricts loop iterator to single token --- ShellScript/Bash.sublime-syntax | 40 +- ShellScript/test/syntax_test_bash.sh | 771 ++++++++++++++++++++------- 2 files changed, 623 insertions(+), 188 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 1f796f8948..fdc352c643 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -1251,10 +1251,15 @@ contexts: scope: keyword.control.loop.end.shell - match: for{{cmd_break}} scope: keyword.control.loop.for.shell - set: for-args + set: + - for-meta + - for-args - match: select{{cmd_break}} scope: keyword.control.loop.select.shell - set: loop-iterator-var + set: + - select-meta + - loop-iterator-wordlist + - loop-iterator-var - match: until{{cmd_break}} scope: keyword.control.loop.until.shell - match: while{{cmd_break}} @@ -1360,6 +1365,11 @@ contexts: - include: number - include: string-path-pattern + for-meta: + - meta_include_prototype: false + - meta_scope: meta.statement.loop.for.shell + - include: immediately-pop + for-args: - meta_include_prototype: false - include: eoc-pop @@ -1367,20 +1377,32 @@ contexts: scope: punctuation.section.compound.begin.shell set: cmd-arithmetic-body - match: (?=\S) - set: loop-iterator-var + set: + - loop-iterator-wordlist + - variable-name-begin + + select-meta: + - meta_include_prototype: false + - meta_scope: meta.statement.loop.select.shell + - include: immediately-pop loop-iterator-var: + - include: eoc-pop + - match: (?=\S) + set: variable-name-begin + + loop-iterator-wordlist: - match: in{{cmd_break}} scope: keyword.operator.iterator.in.shell - set: loop-iterator-wordlist + set: loop-iterator-wordlist-body - include: cmd-args-end - - match: '{{variable_begin}}' - push: - - variable-subscription - - variable-name-begin + - include: else-pop - loop-iterator-wordlist: + loop-iterator-wordlist-body: - meta_include_prototype: false + - meta_content_scope: meta.sequence.list.shell + - match: \( + scope: invalid.illegal.unexpected-token.shell - include: cmd-args-end - include: string-path-patterns diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index b0326463e6..e346f42412 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -827,58 +827,30 @@ c1 -c1 c1 && ${C2} -c2 c2 || c3 -c3 ${C3} ; c4 -${C4} c4 | c5 -c5 c5 # ^^ variable.function # ^ variable.parameter - ############################################################################### # 3.2.5 Compound Commands # -# 3.2.5.1 Looping Constructs (for loops) # +# 3.2.5.1 Looping Constructs (do..done) # # https://www.gnu.org/software/bash/manual/bash.html#index-for # ############################################################################### -for; -#^^ keyword.control.loop.for.shell -for& -#^^ keyword.control.loop.for.shell -for| -#^^ keyword.control.loop.for.shell -for>/dev/null -#^^ keyword.control.loop.for.shell -for - -#^^ keyword.control.loop.for.shell -for() -#^^ keyword.control.loop.for.shell -for[] -#^^^^ - keyword.control -for{} -#^^^^ - keyword.control -for- -#^^^ - keyword.control --for -#^^^ - keyword.control -for+ -#^^^ - keyword.control -for$ -#^^^ - keyword.control -for$var -#^^^^^^ - keyword.control -for= -#^^^ - keyword.control -for-= -#^^^^ - keyword.control -for+= -#^^^^ - keyword.control - do; #^^ keyword.control.loop.do.shell +# ^ - keyword.control.loop do& #^^ keyword.control.loop.do.shell +# ^ - keyword.control.loop do| #^^ keyword.control.loop.do.shell +# ^ - keyword.control.loop do>/dev/null #^^ keyword.control.loop.do.shell +# ^ - keyword.control.loop do - #^^ keyword.control.loop.do.shell +# ^ - keyword.control.loop do() #^^ keyword.control.loop.do.shell +# ^ - keyword.control.loop do[] #^^^^ - keyword.control do{} @@ -900,45 +872,146 @@ do$var do+= #^^^^ - keyword.control -for -var in $vars; -# <- - variable.other -#^^ - variable.other -#^^^^^^^^^^^ meta.function-call + done; +#^^^^ keyword.control.loop.end.shell +# ^ - keyword.control.loop + done& +#^^^^ keyword.control.loop.end.shell +# ^ - keyword.control.loop + done| +#^^^^ keyword.control.loop.end.shell +# ^ - keyword.control.loop + done>/dev/null +#^^^^ keyword.control.loop.end.shell +# ^ - keyword.control.loop + done - +#^^^^ keyword.control.loop.end.shell +# ^ - keyword.control.loop + done() +#^^^^ keyword.control.loop.end.shell +# ^ - keyword.control.loop + done[] +#^^^^^^ - keyword.control + done{} +#^^^^^^ - keyword.control + done- +#^^^^^ - keyword.control + -done +#^^^^^ - keyword.control + done+ +#^^^^^ - keyword.control + done$ +#^^^^^ - keyword.control +done$var +#^^^^^^^^ - keyword.control + done= +#^^^^^ - keyword.control + done-= +#^^^^^^ - keyword.control + done+= +#^^^^^^ - keyword.control -for \ -var in $vars; -#<- variable.other.readwrite.shell -#^^ variable.other.readwrite.shell -# ^^ keyword.operator.iterator.in.shell -# ^^^^^ meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell +do +# <- keyword.control.loop.do.shell +#^ keyword.control.loop.do.shell + + break +# ^^^^^ keyword.control.flow.break.shell + break 2; +# ^^^^^ keyword.control.flow.break.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.terminator.statement.shell + break ${levels}; +# ^^^^^ keyword.control.flow.break.shell +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.terminator.statement.shell + continue +# ^^^^^^^^ keyword.control.flow.continue.shell + continue 2; +# ^^^^^^^^ keyword.control.flow.continue.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.terminator.statement.shell + continue ${levels}; +# ^^^^^^^^ keyword.control.flow.continue.shell +# ^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.terminator.statement.shell + + exit +# ^^^^ keyword.control.flow.exit.shell + exit 2; +# ^^^^ keyword.control.flow.exit.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.terminator.statement.shell + exit ${code}; +# ^^^^ keyword.control.flow.exit.shell +# ^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.terminator.statement.shell + + return +# ^^^^^^ keyword.control.flow.return.shell + return 2; +# ^^^^^^ keyword.control.flow.return.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell # ^ punctuation.terminator.statement.shell + return ${code}; +# ^^^^^^ keyword.control.flow.return.shell +# ^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.terminator.statement.shell -for done -# <- keyword.control.loop.for.shell -#^^ keyword.control.loop.for.shell -# ^^^^ variable.other.readwrite.shell - keyword +done +# <- keyword.control.loop.end.shell +#^^^ keyword.control.loop.end.shell -for do done -# <- keyword.control.loop.for.shell -#^^ keyword.control.loop.for.shell -# ^^ variable.other.readwrite.shell - keyword -# ^^^^ variable.other.readwrite.shell - keyword -for x; do -#<- keyword.control.loop.for.shell +############################################################################### +# 3.2.5 Compound Commands # +# 3.2.5.1 Looping Constructs (for loops) # +# https://www.gnu.org/software/bash/manual/bash.html#index-for # +############################################################################### + +for; #^^ keyword.control.loop.for.shell -# ^ punctuation.terminator.statement.shell -# ^^ keyword.control.loop.do.shell - echo "${!x}" -# ^^^^ meta.function-call.identifier.shell support.function.shell -# ^^^^^^^^ meta.function-call.arguments.shell -done -#<- keyword.control.loop.end.shell +# ^ - keyword.control.loop +for& +#^^ keyword.control.loop.for.shell +# ^ - keyword.control.loop +for| +#^^ keyword.control.loop.for.shell +# ^ - keyword.control.loop +for>/dev/null +#^^ keyword.control.loop.for.shell +# ^ - keyword.control.loop +for - +#^^ keyword.control.loop.for.shell +# ^ - keyword.control.loop +for() +#^^ keyword.control.loop.for.shell +# ^ - keyword.control.loop +for[] +#^^^^ - keyword.control +for{} +#^^^^ - keyword.control +for- +#^^^ - keyword.control +-for +#^^^ - keyword.control +for+ +#^^^ - keyword.control +for$ +#^^^ - keyword.control +for$var +#^^^^^^ - keyword.control +for= +#^^^ - keyword.control +for-= +#^^^^ - keyword.control +for+= +#^^^^ - keyword.control for (( i = 0; i < 10; i++ )); do -# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.arithmetic.shell -# <- keyword.control.loop.for.shell +# <- meta.statement.loop.for.shell keyword.control.loop.for.shell +#^^^ meta.statement.loop.for.shell - meta.compound +# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.statement.loop.for.shell meta.compound.arithmetic.shell # ^^ punctuation.section.compound.begin.shell # ^ keyword.operator.assignment.shell # ^ meta.number.integer.decimal.shell constant.numeric.value.shell - punctuation @@ -958,8 +1031,9 @@ done # <- keyword.control.loop.end.shell for (( i = 0; i < 10; i++ )) #; do -# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.arithmetic.shell -# <- keyword.control.loop.for.shell +# <- meta.statement.loop.for.shell keyword.control.loop.for.shell +#^^^ meta.statement.loop.for.shell - meta.compound +# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.statement.loop.for.shell meta.compound.arithmetic.shell # ^^ punctuation.section.compound.begin.shell # ^ keyword.operator.assignment.shell # ^ meta.number.integer.decimal.shell constant.numeric.value.shell - punctuation @@ -971,7 +1045,7 @@ for (( i = 0; i < 10; i++ )) #; do # ^^ punctuation.section.compound.end.shell # ^^^^^^ comment.line.number-sign.shell do -#<- keyword.control.loop.do.shell +# <- keyword.control.loop.do.shell echo $i # <- meta.function-call support.function.shell # ^ meta.function-call.arguments punctuation.definition.variable.shell @@ -981,7 +1055,8 @@ done for \ (( i = 0; i < 10; i++ )) do echo $i; done; -# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.arithmetic.shell +#^ meta.statement.loop.for.shell - meta.compound +# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.statement.loop.for.shell meta.compound.arithmetic.shell # ^^ keyword.control.loop.do.shell # ^^^^^^^ meta.function-call # ^^^^ support.function.shell @@ -990,26 +1065,57 @@ for \ # ^^^^ keyword.control.loop.end.shell # ^ punctuation.terminator.statement.shell -for i in str1 $str2 "str3" 'str4' st$r5; do echo $i; done; -# <- keyword.control.loop.for.shell +# Iterator form + + +for in +# <- meta.statement.loop.for.shell keyword.control.loop.for.shell +#^^^^^ meta.statement.loop.for.shell +#^^ keyword.control.loop.for.shell +# ^^ variable.other.readwrite.shell - keyword + +for in in in in +# <- meta.statement.loop.for.shell keyword.control.loop.for.shell +#^^^^^^^^^^^^^^ meta.statement.loop.for.shell +#^^ keyword.control.loop.for.shell +# ^^ variable.other.readwrite.shell - keyword +# ^^ keyword.operator.iterator.in.shell +# ^^ meta.string.shell string.unquoted.shell +# ^^ meta.string.shell string.unquoted.shell + +for do do do do +# <- meta.statement.loop.for.shell keyword.control.loop.for.shell +#^^^^^^ meta.statement.loop.for.shell +# ^^^^^^^^ - meta.statement.loop +#^^ keyword.control.loop.for.shell +# ^^ variable.other.readwrite.shell - keyword +# ^^ keyword.control.loop.do.shell +# ^^ keyword.control.loop.do.shell +# ^^ keyword.control.loop.do.shell + +for done done +# <- meta.statement.loop.for.shell keyword.control.loop.for.shell +#^^^^^^^^ meta.statement.loop.for.shell +# ^^^^ - meta.statement.loop +#^^ keyword.control.loop.for.shell +# ^^^^ variable.other.readwrite.shell - keyword +# ^^^^ keyword.control.loop.end.shell + +for x; do echo "${!x}"; done +#<- meta.statement.loop.for.shell keyword.control.loop.for.shell +#^^^^ meta.statement.loop.for.shell +#^^ keyword.control.loop.for.shell # ^ variable.other.readwrite.shell -# ^^ keyword.operator.iterator.in.shell -# ^^^^ meta.string.shell string.unquoted.shell -# ^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell -# ^^^^^^ meta.string.shell string.quoted.double.shell -# ^^^^^^ meta.string.shell string.quoted.single.shell -# ^^ meta.string.shell string.unquoted.shell -# ^^^ meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell -# ^ punctuation.terminator.statement.shell -# ^^ keyword.control.loop.do.shell -# ^^^^ meta.function-call.identifier.shell support.function.shell -# ^^ meta.function-call.arguments.shell meta.interpolation.parameter.shell variable.other.readwrite.shell -# ^ punctuation.terminator.statement.shell -# ^^^^ keyword.control.loop.end.shell -# ^ punctuation.terminator.statement.shell +# ^ punctuation.terminator.statement.shell +# ^^ keyword.control.loop.do.shell +# ^^^^ meta.function-call.identifier.shell support.function.shell +# ^^^^^^^^ meta.function-call.arguments.shell +# ^ punctuation.terminator.statement.shell +# ^^^^ keyword.control.loop.end.shell for i in for in do echo done; do echo $i; done; -# <- keyword.control.loop.for.shell +# <- meta.statement.loop.for.shell keyword.control.loop.for.shell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.statement.loop.for.shell # ^^ keyword.operator.iterator.in.shell # ^ - meta.string # ^^^ meta.string.shell string.unquoted.shell @@ -1030,7 +1136,8 @@ for i in for in do echo done; do echo $i; done; # ^ punctuation.terminator.statement.shell for i in { [ \( ; do echo $i; done; -# <- keyword.control.loop.for.shell +# <- meta.statement.loop.for.shell keyword.control.loop.for.shell +#^^^^^^^^^^^^^^ meta.statement.loop.for.shell # ^ variable.other.readwrite.shell # ^^ keyword.operator.iterator.in.shell # ^ - meta.string @@ -1048,8 +1155,28 @@ for i in { [ \( ; do echo $i; done; # ^^^^ keyword.control.loop.end.shell # ^ punctuation.terminator.statement.shell +for i in str1 $str2 "str3" 'str4' st$r5; do echo $i; done; +# <- meta.statement.loop.for.shell keyword.control.loop.for.shell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.statement.loop.for.shell +# ^ variable.other.readwrite.shell +# ^^ keyword.operator.iterator.in.shell +# ^^^^ meta.string.shell string.unquoted.shell +# ^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^^^^^^ meta.string.shell string.quoted.double.shell +# ^^^^^^ meta.string.shell string.quoted.single.shell +# ^^ meta.string.shell string.unquoted.shell +# ^^^ meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^ punctuation.terminator.statement.shell +# ^^ keyword.control.loop.do.shell +# ^^^^ meta.function-call.identifier.shell support.function.shell +# ^^ meta.function-call.arguments.shell meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^ punctuation.terminator.statement.shell +# ^^^^ keyword.control.loop.end.shell +# ^ punctuation.terminator.statement.shell + for i in /dev/null +#^^^^^ keyword.control.loop.select.shell +# ^ - keyword.control.loop +select - +#^^^^^ keyword.control.loop.select.shell +# ^ - keyword.control.loop +select() +#^^^^^ keyword.control.loop.select.shell +# ^ - keyword.control.loop +select[] +#^^^^^^^ - keyword.control +select{} +#^^^^^^^ - keyword.control +select- +#^^^^^^ - keyword.control +-select +#^^^^^^ - keyword.control +select+ +#^^^^^^ - keyword.control +select$ +#^^^^^^ - keyword.control +select$var +#^^^^^^^^^ - keyword.control +select= +#^^^^^^ - keyword.control +select-= +#^^^^^^^ - keyword.control +select+= +#^^^^^^^ - keyword.control + +select select select select +# <- meta.statement.loop.select.shell keyword.control.loop.select.shell +#^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.statement.loop.select.shell +# ^ - meta.statement.loop +#^^^^^ keyword.control.loop.select.shell +# ^^^^^^ variable.other.readwrite.shell +# ^^^^^^ keyword.control.loop.select.shell +# ^^^^^^ variable.other.readwrite.shell + +select in in in select do done; do echo $in; done; +# <- meta.statement.loop.select.shell keyword.control.loop.select.shell +#^^^^^^^^^^^ meta.statement.loop.select.shell - meta.sequence +# ^^^^^^^^^^^^^^^^^^ meta.statement.loop.select.shell meta.sequence.list.shell +# ^^ - meta.statement.loop - meta.sequence +#^^^^^ keyword.control.loop.select.shell +# ^^ variable.other.readwrite.shell +# ^^ keyword.operator.iterator.in.shell +# ^ - meta.string - string +# ^^ meta.string.shell string.unquoted.shell +# ^ - meta.string - string +# ^^^^^^ meta.string.shell string.unquoted.shell +# ^ - meta.string - string +# ^^ meta.string.shell string.unquoted.shell +# ^ - meta.string - string +# ^^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.terminator.statement.shell +# ^^ keyword.control.loop.do.shell +# ^^^^ support.function.shell +# ^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^ punctuation.terminator.statement.shell +# ^^^^ keyword.control.loop.end.shell +# ^ punctuation.terminator.statement.shell + +select \ + fname in ~/**/*.~\$tmp; do rm -f $fname; done; +# <- meta.statement.loop.select.shell +#^^^^^^^^^ meta.statement.loop.select.shell - meta.sequence +# ^ meta.statement.loop.select.shell meta.sequence.list.shell - meta.string +# ^^^^^^^^^^^^^ meta.statement.loop.select.shell meta.sequence.list.shell meta.string.shell +# ^^ - meta.statement.loop - meta.sequence +# ^^^^^ variable.other.readwrite.shell +# ^^ keyword.operator.iterator.in.shell +# ^ meta.interpolation.tilde.shell variable.language.tilde.shell - string +# ^^^^^^^^^^^^ string.unquoted.shell +# ^^ constant.other.wildcard.asterisk.shell +# ^ constant.other.wildcard.asterisk.shell +# ^^ constant.character.escape.shell + +select \ + fname \ + in ~/**/*.~\$tmp; do rm -f $fname; done; +# <- meta.statement.loop.select.shell +#^^^ meta.statement.loop.select.shell - meta.sequence +# ^ meta.statement.loop.select.shell meta.sequence.list.shell - meta.string +# ^^^^^^^^^^^^^ meta.statement.loop.select.shell meta.sequence.list.shell meta.string.shell +# ^^ - meta.statement.loop - meta.sequence +# ^^ keyword.operator.iterator.in.shell +# ^ meta.interpolation.tilde.shell variable.language.tilde.shell - string +# ^^^^^^^^^^^^ string.unquoted.shell +# ^^ constant.other.wildcard.asterisk.shell +# ^ constant.other.wildcard.asterisk.shell +# ^^ constant.character.escape.shell + +select \ + fname \ + in \ + ~/**/*.~\$tmp; do rm -f $fname; done; +# <- meta.statement.loop.select.shell +#^ meta.statement.loop.select.shell meta.sequence.list.shell - meta.string +# ^^^^^^^^^^^^^ meta.statement.loop.select.shell meta.sequence.list.shell meta.string.shell +# ^^ - meta.statement.loop - meta.sequence +# ^ meta.interpolation.tilde.shell variable.language.tilde.shell - string +# ^^^^^^^^^^^^ string.unquoted.shell +# ^^ constant.other.wildcard.asterisk.shell +# ^ constant.other.wildcard.asterisk.shell +# ^^ constant.character.escape.shell select fname in *; # <- keyword.control.loop.select.shell @@ -1262,16 +1536,101 @@ done # https://www.gnu.org/software/bash/manual/bash.html#index-until # ############################################################################### -do echo bar; until ! { [[ true ]]; } -# <- keyword.control.loop.do.shell -# ^^^^^ keyword.control.loop.until.shell -# ^ keyword.operator.logical.shell -# ^ punctuation.section.compound.begin.shell -# ^^ punctuation.section.compound.begin.shell -# ^^^^ constant.language.boolean.true.shell -# ^^ punctuation.section.compound.end.shell -# ^ punctuation.terminator.statement.shell -# ^ punctuation.section.compound.end.shell +until; +#^^^^ keyword.control.loop.until.shell +# ^ - keyword.control.loop +until& +#^^^^ keyword.control.loop.until.shell +# ^ - keyword.control.loop +until| +#^^^^ keyword.control.loop.until.shell +# ^ - keyword.control.loop +until>/dev/null +#^^^^ keyword.control.loop.until.shell +# ^ - keyword.control.loop +until - +#^^^^ keyword.control.loop.until.shell +# ^ - keyword.control.loop +until() +#^^^^ keyword.control.loop.until.shell +# ^ - keyword.control.loop +until[] +#^^^^^^ - keyword.control +until{} +#^^^^^^ - keyword.control +until- +#^^^^^ - keyword.control +-until +#^^^^^ - keyword.control +until+ +#^^^^^ - keyword.control +until$ +#^^^^^ - keyword.control +until$var +#^^^^^^^^ - keyword.control +until= +#^^^^^ - keyword.control +until-= +#^^^^^^ - keyword.control +until+= +#^^^^^^ - keyword.control + +until test-commands --arg val; do cmd --arg; done +# <- keyword.control.loop.until.shell +#^^^^ keyword.control.loop.until.shell +# ^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^^^^^^^^^ meta.function-call.arguments.shell +# ^ punctuation.terminator.statement.shell +# ^^ keyword.control.loop.do.shell +# ^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^^^^^ meta.function-call.arguments.shell +# ^ punctuation.terminator.statement.shell +# ^^^^ keyword.control.loop.end.shell + +until + test-commands --arg val; do cmd --arg; done +# ^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^^^^^^^^^ meta.function-call.arguments.shell +# ^ punctuation.terminator.statement.shell +# ^^ keyword.control.loop.do.shell +# ^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^^^^^ meta.function-call.arguments.shell +# ^ punctuation.terminator.statement.shell +# ^^^^ keyword.control.loop.end.shell + +until + test-commands \ + --arg val; do cmd --arg; done +#^^^^^^^^^^ meta.function-call.arguments.shell +# ^ punctuation.terminator.statement.shell +# ^^ keyword.control.loop.do.shell +# ^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^^^^^ meta.function-call.arguments.shell +# ^ punctuation.terminator.statement.shell +# ^^^^ keyword.control.loop.end.shell + +until + test-commands \ + --arg val +#^^^^^^^^^^ meta.function-call.arguments.shell + do cmd --arg; done +# ^^ keyword.control.loop.do.shell +# ^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^^^^^ meta.function-call.arguments.shell +# ^ punctuation.terminator.statement.shell +# ^^^^ keyword.control.loop.end.shell + +until ! (( i < 10 )) ; do echo Step $(( i+= 1 ))...; done +# <- keyword.control.loop.until.shell +#^^^^ keyword.control.loop.until.shell +# ^ keyword.operator.logical.shell +# ^^^^^^^^^^^^ meta.compound.arithmetic.shell +# ^ punctuation.terminator.statement.shell +# ^^ keyword.control.loop.do.shell +# ^^^^ meta.function-call.identifier.shell support.function.shell +# ^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell +# ^ punctuation.terminator.statement.shell +# ^^^^ keyword.control.loop.end.shell ############################################################################### @@ -1280,35 +1639,89 @@ do echo bar; until ! { [[ true ]]; } # https://www.gnu.org/software/bash/manual/bash.html#index-while # ############################################################################### -while true; do -# <- keyword.control.loop.while +while; #^^^^ keyword.control.loop.while.shell -# ^ - constant - keyword -# ^^^^ constant.language.boolean.true.shell -# ^ punctuation.terminator.statement.shell -# ^^ keyword.control.loop.do.shell - break -# ^^^^^ keyword.control.flow.break.shell - break 2; -# ^^^^^ keyword.control.flow.break.shell -# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ - keyword.control.loop +while& +#^^^^ keyword.control.loop.while.shell +# ^ - keyword.control.loop +while| +#^^^^ keyword.control.loop.while.shell +# ^ - keyword.control.loop +while>/dev/null +#^^^^ keyword.control.loop.while.shell +# ^ - keyword.control.loop +while - +#^^^^ keyword.control.loop.while.shell +# ^ - keyword.control.loop +while() +#^^^^ keyword.control.loop.while.shell +# ^ - keyword.control.loop +while[] +#^^^^^^ - keyword.control +while{} +#^^^^^^ - keyword.control +while- +#^^^^^ - keyword.control +-while +#^^^^^ - keyword.control +while+ +#^^^^^ - keyword.control +while$ +#^^^^^ - keyword.control +while$var +#^^^^^^^^ - keyword.control +while= +#^^^^^ - keyword.control +while-= +#^^^^^^ - keyword.control +while+= +#^^^^^^ - keyword.control + +while test-commands --arg val; do cmd --arg; done +# <- keyword.control.loop.while.shell +#^^^^ keyword.control.loop.while.shell +# ^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^^^^^^^^^ meta.function-call.arguments.shell +# ^ punctuation.terminator.statement.shell +# ^^ keyword.control.loop.do.shell +# ^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^^^^^ meta.function-call.arguments.shell +# ^ punctuation.terminator.statement.shell +# ^^^^ keyword.control.loop.end.shell + +while + test-commands --arg val; do cmd --arg; done +# ^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^^^^^^^^^ meta.function-call.arguments.shell +# ^ punctuation.terminator.statement.shell +# ^^ keyword.control.loop.do.shell +# ^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^^^^^ meta.function-call.arguments.shell +# ^ punctuation.terminator.statement.shell +# ^^^^ keyword.control.loop.end.shell + +while + test-commands \ + --arg val; do cmd --arg; done +#^^^^^^^^^^ meta.function-call.arguments.shell # ^ punctuation.terminator.statement.shell - break ${levels}; -# ^^^^^ keyword.control.flow.break.shell -# ^^^^^^^^^ meta.interpolation.parameter.shell -# ^ punctuation.terminator.statement.shell - continue -# ^^^^^^^^ keyword.control.flow.continue.shell - continue 2; -# ^^^^^^^^ keyword.control.flow.continue.shell -# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^^ keyword.control.loop.do.shell +# ^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^^^^^ meta.function-call.arguments.shell +# ^ punctuation.terminator.statement.shell +# ^^^^ keyword.control.loop.end.shell + +while + test-commands \ + --arg val +#^^^^^^^^^^ meta.function-call.arguments.shell + do cmd --arg; done +# ^^ keyword.control.loop.do.shell +# ^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^^^^^ meta.function-call.arguments.shell # ^ punctuation.terminator.statement.shell - continue ${levels}; -# ^^^^^^^^ keyword.control.flow.continue.shell -# ^^^^^^^^^ meta.interpolation.parameter.shell -# ^ punctuation.terminator.statement.shell -done -# <- keyword.control.loop.end +# ^^^^ keyword.control.loop.end.shell while ! true; do echo bar; done # <- keyword.control.loop.while.shell From 656378ced6978048ba992b9cfc82a8586e4d8cc3 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 4 Aug 2024 10:15:59 +0200 Subject: [PATCH 052/113] [ShellScript] Add command and time built-ins --- ShellScript/Bash.sublime-syntax | 22 ++++++++++-- ShellScript/test/syntax_test_bash.sh | 50 ++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 3 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index fdc352c643..e26a74f690 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -106,9 +106,9 @@ variables: # https://www.gnu.org/software/bash/manual/bash.html#Bash-Builtins # Note: Contains thosw, which are not present as dedicated context builtin_cmds: |- - (?x: \. | \: | bg | bind | builtin | caller | cd | command | disown | enable - | eval | fg | getopts | hash | help | jobs | kill | logout | mapfile | printf - | pwd | read | readarray | set | shift | shopt | source | su | suspend | times + (?x: \. | \: | bg | bind | builtin | caller | cd | disown | enable | eval | fg + | getopts | hash | help | jobs | kill | logout | mapfile | printf | pwd + | read | readarray | set | shift | shopt | source | su | suspend | times | trap | type | ulimit | umask | wait ){{cmd_break}} # 5 Shell Variables @@ -289,6 +289,7 @@ contexts: - include: def-anonymous - include: cmd-alias - include: cmd-arithmetic + - include: cmd-command - include: cmd-compound - include: cmd-control - include: cmd-coproc @@ -587,6 +588,21 @@ contexts: - include: cmd-args-end - include: expression-content +###[ COMMAND BUILTINS ]######################################################## + + cmd-command: + - match: (?:command|time){{cmd_break}} + scope: + meta.function-call.identifier.shell + support.function.shell + set: cmd-command-args + + cmd-command-args: + - meta_content_scope: meta.function-call.arguments.shell + - include: cmd-args-end + - include: cmd-args-options + - include: else-pop + ###[ COPROC BUILTINS ]######################################################### cmd-coproc: diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index e346f42412..5fd3dccd44 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -10104,6 +10104,28 @@ printFunction "$variableString1" "`declare -p variableArray`" # ^ punctuation.section.interpolation.end.shell +############################################################################### +# 4.2 Bash Builtin Commands (command) # +# https://www.gnu.org/software/bash/manual/bash.html#index-command # +############################################################################### + +command +# <- meta.function-call.identifier.shell support.function.shell +#^^^^^^ meta.function-call.identifier.shell support.function.shell + +command -pV -v cmd -a val +# <- meta.function-call.identifier.shell support.function.shell +#^^^^^^ meta.function-call.identifier.shell +# ^^^^^^^^ meta.function-call.arguments.shell +# ^^^ meta.function-call.identifier.shell meta.path.shell +# ^^^^^^^ meta.function-call.arguments.shell +# ^^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^^ variable.function.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^^ meta.string.shell string.unquoted.shell + + ############################################################################### # 4.2 Bash Builtin Commands (eval) # # https://www.gnu.org/software/bash/manual/bash.html#index-eval # @@ -11065,6 +11087,34 @@ if test "$VAR" != ";";then;fi # ^^ keyword.control.conditional.endif.shell +############################################################################### +# 4.2 Bash Builtin Commands (time) # +# https://www.gnu.org/software/bash/manual/bash.html#index-time # +############################################################################### + +time cmd1 --arg val | cmd2 -n |& cmd3 +# <- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell support.function.shell +# ^ meta.function-call.arguments.shell +# ^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^^^^^^^^^ meta.function-call.arguments.shell +# ^^^^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ keyword.operator.assignment.pipe.shell +# ^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^^ meta.function-call.arguments.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^ keyword.operator.assignment.pipe.shell +# ^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell + +time -p cmd -p +# <- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell +# ^^^^ meta.function-call.arguments.shell +# ^^^ meta.function-call.identifier.shell +# ^^^ meta.function-call.arguments.shell + + ############################################################################### # 4.2 Bash Builtin Commands (unalias) # # https://www.gnu.org/software/bash/manual/bash.html#index-unalias # From 3c39ca0bafd639a8566d7bc9730be6ec6390b02a Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 4 Aug 2024 10:39:03 +0200 Subject: [PATCH 053/113] [ShellScript] Add command modifiers --- ShellScript/Bash.sublime-syntax | 9 ++++++++- ShellScript/test/syntax_test_bash.sh | 21 +++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index e26a74f690..863451225f 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -106,11 +106,14 @@ variables: # https://www.gnu.org/software/bash/manual/bash.html#Bash-Builtins # Note: Contains thosw, which are not present as dedicated context builtin_cmds: |- - (?x: \. | \: | bg | bind | builtin | caller | cd | disown | enable | eval | fg + (?x: \. | \: | bg | bind | caller | cd | disown | enable | eval | fg | getopts | hash | help | jobs | kill | logout | mapfile | printf | pwd | read | readarray | set | shift | shopt | source | su | suspend | times | trap | type | ulimit | umask | wait ){{cmd_break}} + modifier_cmds: |- + (?x: builtin ){{cmd_break}} + # 5 Shell Variables # https://www.gnu.org/software/bash/manual/bash.html#Shell-Variables builtin_variables: |- @@ -1030,6 +1033,10 @@ contexts: scope: punctuation.definition.history.shell cmd-builtin: + # cmd modifier commands are directly followed by simple commands + - match: '{{modifier_cmds}}' + scope: meta.function-call.identifier.shell meta.path.shell support.function.shell + # shell built-in commands with arbritary arguments - match: '{{builtin_cmds}}' scope: meta.function-call.identifier.shell meta.path.shell support.function.shell push: diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index 5fd3dccd44..84a4e22e85 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -10104,6 +10104,27 @@ printFunction "$variableString1" "`declare -p variableArray`" # ^ punctuation.section.interpolation.end.shell +############################################################################### +# 4.2 Bash Builtin Commands (builtin) # +# https://www.gnu.org/software/bash/manual/bash.html#index-builtin # +############################################################################### + +builtin +# <- meta.function-call.identifier.shell support.function.shell +#^^^^^^ meta.function-call.identifier.shell support.function.shell + +builtin -pV -v cmd -a val +# <- meta.function-call.identifier.shell support.function.shell +#^^^^^^ meta.function-call.identifier.shell +# ^^^ meta.function-call.identifier.shell +# ^^^^^^^^^^^^^^ meta.function-call.arguments.shell +# ^^^ variable.function.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^^ meta.string.shell string.unquoted.shell + + ############################################################################### # 4.2 Bash Builtin Commands (command) # # https://www.gnu.org/software/bash/manual/bash.html#index-command # From 500f7126bf07622f1a41f269382fd73df4375a22 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 4 Aug 2024 12:36:37 +0200 Subject: [PATCH 054/113] [ShellScript] Add trap built-in --- ShellScript/Bash.sublime-syntax | 87 +++++++++++++++++-- ShellScript/test/syntax_test_bash.sh | 121 ++++++++++++++++++++++++--- 2 files changed, 191 insertions(+), 17 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 863451225f..76abf1aaca 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -109,7 +109,7 @@ variables: (?x: \. | \: | bg | bind | caller | cd | disown | enable | eval | fg | getopts | hash | help | jobs | kill | logout | mapfile | printf | pwd | read | readarray | set | shift | shopt | source | su | suspend | times - | trap | type | ulimit | umask | wait ){{cmd_break}} + | type | ulimit | umask | wait ){{cmd_break}} modifier_cmds: |- (?x: builtin ){{cmd_break}} @@ -231,7 +231,7 @@ variables: special_variables: '[$#@!*?-]' signal_names: |- - (?x: SIG {{signal_subnames}} ){{word_break}} + (?x: EXIT | DEBUG | SIG {{signal_subnames}} ){{word_break}} signal_subnames: |- (?x: @@ -304,6 +304,7 @@ contexts: - include: cmd-readonly - include: cmd-sudo - include: cmd-test + - include: cmd-trap - include: cmd-unalias - include: cmd-unset - include: cmd-builtin @@ -555,11 +556,10 @@ contexts: cmd-alias-args-definitions: - include: cmd-args-end - - match: = - scope: keyword.operator.assignment.shell - push: literal-array-value - match: '{{word_begin}}' - push: alias-name-chars + push: + - statements-value-assignment + - alias-name-chars alias-name-chars: - meta_scope: meta.variable.shell entity.name.function.shell @@ -968,6 +968,29 @@ contexts: - include: comments - include: cmd-args-values +###[ TRAP BUILTINS ]########################################################### + + cmd-trap: + - match: trap{{cmd_break}} + scope: + meta.function-call.identifier.shell + support.function.shell + set: + - cmd-args-meta + - cmd-trap-sigspec + - cmd-trap-command + + cmd-trap-command: + - include: cmd-args-end + - include: cmd-args-options + - include: statements-word + + cmd-trap-sigspec: + - include: cmd-args-end + - match: '{{signal_names}}' + scope: constant.language.signal.shell + - include: cmd-args-values + ###[ UNALIAS BUILTINS ]######################################################## cmd-unalias: @@ -1591,6 +1614,54 @@ contexts: - include: boolean - include: string-path-pattern +###[ STATEMENT VALUE ASSIGNMENTS ]############################################# + + statements-value-assignment: + - match: '{{varassign}}' + scope: keyword.operator.assignment.shell + set: statements-value + - include: line-continuations + - include: immediately-pop + + statements-value: + - include: statements-word + - include: immediately-pop + + statements-word: + - match: \" + scope: + meta.string.shell string.quoted.double.shell + punctuation.section.string.begin.shell + embed: statements + embed_scope: meta.string.shell + escape: '{{no_escape_behind}}\"' + escape_captures: + 0: meta.string.shell string.quoted.double.shell + punctuation.section.string.end.shell + pop: 1 + - match: \' + scope: + meta.string.shell string.quoted.single.shell + punctuation.section.string.begin.shell + embed: statements + embed_scope: meta.string.shell + escape: '{{no_escape_behind}}''' + escape_captures: + 0: meta.string.shell string.quoted.single.shell + punctuation.section.string.end.shell + pop: 1 + - match: '{{cmd_begin}}' + set: + - unquoted-statements-word-body + - path-pattern-begin + + unquoted-statements-word-body: + - meta_scope: meta.string.shell meta.path.shell variable.function.shell + - include: line-continuations + - include: path-pattern-content + - match: '{{cmd_break}}' + pop: 1 + ###[ ARRAY VALUE PROTOTYPES ]################################################## explicit-mapping-keys: @@ -2307,6 +2378,10 @@ contexts: - include: immediately-pop path-pattern-content: + - include: path-pattern-common + - include: pattern-charsets + + path-pattern-common: - match: \$?\" scope: punctuation.definition.quoted.begin.shell push: path-pattern-double-quoted-body diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index 84a4e22e85..b2b905edb0 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -9425,7 +9425,7 @@ alias foo=bar # ^ - meta.declaration.alias # ^^^ meta.variable.shell entity.name.function.shell # ^ keyword.operator.assignment.shell -# ^^^ meta.string.shell string.unquoted.shell +# ^^^ meta.string.shell meta.path.shell variable.function.shell alias foo=bar -p 7za=qux # <- meta.declaration.alias.shell keyword.declaration.alias.shell @@ -9433,11 +9433,11 @@ alias foo=bar -p 7za=qux # ^ - meta.declaration.alias # ^^^ meta.variable.shell entity.name.function.shell # ^ keyword.operator.assignment.shell -# ^^^ meta.string.shell string.unquoted.shell +# ^^^ meta.string.shell meta.path.shell variable.function.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell # ^^^ meta.variable.shell entity.name.function.shell # ^ keyword.operator.assignment.shell -# ^^^ meta.string.shell string.unquoted.shell +# ^^^ meta.string.shell meta.path.shell variable.function.shell alias -p foo=bar 7za=qux # <- meta.declaration.alias.shell keyword.declaration.alias.shell @@ -9446,10 +9446,10 @@ alias -p foo=bar 7za=qux # ^^ meta.parameter.option.shell variable.parameter.option.shell # ^^^ meta.variable.shell entity.name.function.shell # ^ keyword.operator.assignment.shell -# ^^^ meta.string.shell string.unquoted.shell +# ^^^ meta.string.shell meta.path.shell variable.function.shell # ^^^ meta.variable.shell entity.name.function.shell # ^ keyword.operator.assignment.shell -# ^^^ meta.string.shell string.unquoted.shell +# ^^^ meta.string.shell meta.path.shell variable.function.shell alias -a -p -- foo=bar baz=qux # <- meta.declaration.alias.shell keyword.declaration.alias.shell @@ -9460,10 +9460,10 @@ alias -a -p -- foo=bar baz=qux # ^^ keyword.operator.end-of-options.shell # ^^^ meta.variable.shell entity.name.function.shell # ^ keyword.operator.assignment.shell -# ^^^ meta.string.shell string.unquoted.shell +# ^^^ meta.string.shell meta.path.shell variable.function.shell # ^^^ meta.variable.shell entity.name.function.shell # ^ keyword.operator.assignment.shell -# ^^^ meta.string.shell string.unquoted.shell +# ^^^ meta.string.shell meta.path.shell variable.function.shell alias $foo=bar # <- meta.declaration.alias.shell keyword.declaration.alias.shell @@ -9471,7 +9471,7 @@ alias $foo=bar # ^ - meta.declaration.alias # ^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell # ^ keyword.operator.assignment.shell -# ^^^ meta.string.shell string.unquoted.shell +# ^^^ meta.string.shell meta.path.shell variable.function.shell alias ..='cd ..' # <- meta.declaration.alias.shell keyword.declaration.alias.shell @@ -9479,7 +9479,11 @@ alias ..='cd ..' #^^^^ keyword.declaration.alias.shell # ^^ meta.variable.shell entity.name.function.shell # ^ keyword.operator.assignment.shell -# ^^^^^^^ meta.string.shell string.quoted.single.shell +# ^ meta.string.shell string.quoted.single.shell punctuation.section.string.begin.shell +# ^^ meta.string.shell meta.function-call.identifier.shell meta.path.shell support.function.shell - string +# ^ meta.string.shell meta.function-call.arguments.shell - string +# ^^ meta.string.shell meta.function-call.arguments.shell meta.string.shell string.unquoted.shell +# ^ meta.string.shell string.quoted.single.shell punctuation.section.string.end.shell alias -p ..='cd ..' # <- meta.declaration.alias.shell keyword.declaration.alias.shell @@ -9488,7 +9492,11 @@ alias -p ..='cd ..' # ^^ meta.parameter.option.shell variable.parameter.option.shell # ^^ meta.variable.shell entity.name.function.shell # ^ keyword.operator.assignment.shell -# ^^^^^^^ meta.string.shell string.quoted.single.shell +# ^ meta.string.shell string.quoted.single.shell punctuation.section.string.begin.shell +# ^^ meta.string.shell meta.function-call.identifier.shell meta.path.shell support.function.shell - string +# ^ meta.string.shell meta.function-call.arguments.shell - string +# ^^ meta.string.shell meta.function-call.arguments.shell meta.string.shell string.unquoted.shell +# ^ meta.string.shell string.quoted.single.shell punctuation.section.string.end.shell alias -- -='cd -' # <- meta.declaration.alias.shell keyword.declaration.alias.shell @@ -9497,7 +9505,11 @@ alias -- -='cd -' # ^^ keyword.operator.end-of-options.shell # ^ meta.variable.shell entity.name.function.shell # ^ keyword.operator.assignment.shell -# ^^^^^^ meta.string.shell string.quoted.single.shell +# ^ meta.string.shell string.quoted.single.shell punctuation.section.string.begin.shell +# ^^ meta.string.shell meta.function-call.identifier.shell meta.path.shell support.function.shell - string +# ^ meta.string.shell meta.function-call.arguments.shell - string +# ^ meta.string.shell meta.function-call.arguments.shell meta.string.shell string.unquoted.shell +# ^ meta.string.shell string.quoted.single.shell punctuation.section.string.end.shell ############################################################################### @@ -11136,6 +11148,93 @@ time -p cmd -p # ^^^ meta.function-call.arguments.shell +############################################################################### +# 4.2 Bash Builtin Commands (trap) # +# https://www.gnu.org/software/bash/manual/bash.html#index-trap # +############################################################################### + +trap +# <- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell support.function.shell + +trap cmd +# <- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell support.function.shell +# ^ meta.function-call.arguments.shell +# ^^^ meta.function-call.arguments.shell meta.path.shell variable.function.shell + +trap cmd EXIT +# <- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell support.function.shell +# ^^^^^^^^^ meta.function-call.arguments.shell - meta.function-call meta-function-call +# ^^^ meta.path.shell variable.function.shell +# ^^^^ constant.language.signal.shell + +trap -p cmd EXIT +# <- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell support.function.shell +# ^^^^^^^^^^^^ meta.function-call.arguments.shell - meta.function-call meta-function-call +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^^ meta.path.shell variable.function.shell +# ^^^^ constant.language.signal.shell + +trap 'cmd --args="value"' SIGINT +# <- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell support.function.shell +# ^ meta.function-call.arguments.shell - meta.function-call meta-function-call +# ^ meta.function-call.arguments.shell meta.string.shell string.quoted.single.shell +# ^^^ meta.function-call.arguments.shell meta.string.shell meta.function-call.identifier.shell +# ^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell meta.function-call.arguments.shell +# ^ meta.function-call.arguments.shell meta.string.shell string.quoted.single.shell +# ^^^^^^^ meta.function-call.arguments.shell - meta.function-call meta-function-call +# ^ punctuation.section.string.begin.shell +# ^^^ variable.function.shell +# ^^^^^^ meta.parameter.option.shell variable.parameter.option.shell +# ^ keyword.operator.assignment.shell +# ^^^^^^^ meta.string.shell string.quoted.double.shell +# ^ punctuation.section.string.end.shell +# ^^^^^^ constant.language.signal.shell + +trap "cmd --args='value'" SIGKILL +# <- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell support.function.shell +# ^ meta.function-call.arguments.shell - meta.function-call meta-function-call +# ^ meta.function-call.arguments.shell meta.string.shell string.quoted.double.shell +# ^^^ meta.function-call.arguments.shell meta.string.shell meta.function-call.identifier.shell +# ^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell meta.function-call.arguments.shell +# ^ meta.function-call.arguments.shell meta.string.shell string.quoted.double.shell +# ^^^^^^^ meta.function-call.arguments.shell - meta.function-call meta-function-call +# ^ punctuation.section.string.begin.shell +# ^^^ variable.function.shell +# ^^^^^^ meta.parameter.option.shell variable.parameter.option.shell +# ^ keyword.operator.assignment.shell +# ^^^^^^^ meta.string.shell string.quoted.single.shell +# ^ punctuation.section.string.end.shell +# ^^^^^^^ constant.language.signal.shell + +trap "\"cmd\" --args=\"val${ue}\"" SIGKILL +# <- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell support.function.shell +# ^ meta.function-call.arguments.shell - meta.function-call meta-function-call +# ^ meta.function-call.arguments.shell meta.string.shell string.quoted.double.shell +# ^^^^^^^ meta.function-call.arguments.shell meta.string.shell meta.function-call.identifier.shell +# ^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell meta.function-call.arguments.shell +# ^ meta.function-call.arguments.shell meta.string.shell string.quoted.double.shell +# ^^^^^^^ meta.function-call.arguments.shell - meta.function-call meta-function-call +# ^ punctuation.section.string.begin.shell +# ^^^^^^^ variable.function.shell +# ^^ constant.character.escape.shell +# ^^ constant.character.escape.shell +# ^^^^^^ meta.parameter.option.shell variable.parameter.option.shell +# ^ keyword.operator.assignment.shell +# ^^^^^ meta.string.shell string.unquoted.shell +# ^^ constant.character.escape.shell +# ^^^^^ meta.string.shell meta.interpolation.parameter.shell +# ^^ constant.character.escape.shell +# ^ punctuation.section.string.end.shell +# ^^^^^^^ constant.language.signal.shell + + ############################################################################### # 4.2 Bash Builtin Commands (unalias) # # https://www.gnu.org/software/bash/manual/bash.html#index-unalias # From 5e21020f52f1ce1c84e732258c62fb1309045651 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Thu, 1 Aug 2024 19:31:21 +0200 Subject: [PATCH 055/113] [ShellScript] Add Zsh Syntax This commit... 1. reorganizes ShellScript package by moving all dialect specific files into separate sub directories, while maintaining only syntax definitions and basic sublime-... files in the top-level directory. That's required for maintainability and to keep track which meta files address certain dialects. - Shell: targets all shells - Bash: bash specific meta-data - Zsh: zsh specific meta-data 2. Adds Zsh syntax definition, indentation rules, ... --- ShellScript/Bash.sublime-syntax | 21 +- .../{ => Bash}/Completion Rules.tmPreferences | 2 +- .../tests}/syntax_test_reindent_case.bash | 0 .../tests}/syntax_test_reindent_for.bash | 0 .../tests}/syntax_test_reindent_if.bash | 0 .../tests}/syntax_test_reindent_select.bash | 0 .../tests/syntax_test_reindent_until.bash | 32 + .../tests/syntax_test_reindent_while.bash | 32 + .../tests/syntax_test_scope.bash} | 0 ShellScript/Shell-Unix-Generic.sublime-syntax | 3 +- .../{ => Shell}/Comments.tmPreferences | 0 ShellScript/{ => Shell}/Fold.tmPreferences | 9 + ...Rules - Case Clause Patterns.tmPreferences | 0 .../Indentation Rules - Case.tmPreferences | 0 ...Indentation Rules - Comments.tmPreferences | 0 .../Indentation Rules.tmPreferences | 5 +- .../Snippets/case.sublime-snippet} | 6 +- .../Snippets/elif.sublime-snippet} | 2 +- .../Snippets/env-shebang.sublime-snippet} | 0 .../Snippets/for-in.sublime-snippet} | 2 +- .../Snippets/for.sublime-snippet} | 2 +- .../Snippets/if.sublime-snippet} | 2 +- .../Snippets/until.sublime-snippet} | 2 +- .../Snippets/while.sublime-snippet} | 2 +- .../Symbol List - Coproc.tmPreferences | 0 .../Symbol List - Functions.tmPreferences | 0 .../tests/syntax_test_scope.sh} | 0 ShellScript/Zsh.sublime-settings | 3 + ShellScript/Zsh.sublime-syntax | 931 +++++ .../Zsh/Completion Rules.tmPreferences | 50 + .../Zsh/Indentation Rules.tmPreferences | 55 + .../Zsh/Snippets/foreach-in.sublime-snippet | 8 + .../Zsh/Snippets/foreach.sublime-snippet | 8 + .../Zsh/Snippets/repeat.sublime-snippet | 8 + .../Zsh/tests/syntax_test_reindent_case.zsh | 192 + .../Zsh/tests/syntax_test_reindent_for.zsh | 219 + .../tests/syntax_test_reindent_foreach.zsh | 84 + .../Zsh/tests/syntax_test_reindent_if.zsh | 199 + .../Zsh/tests/syntax_test_reindent_repeat.zsh | 121 + .../Zsh/tests/syntax_test_reindent_select.zsh | 122 + .../Zsh/tests/syntax_test_reindent_until.zsh | 127 + .../Zsh/tests/syntax_test_reindent_while.zsh | 127 + ShellScript/Zsh/tests/syntax_test_scope.zsh | 3531 +++++++++++++++++ .../test/syntax_test_reindent_until.bash | 32 - .../test/syntax_test_reindent_while.bash | 32 - 45 files changed, 5881 insertions(+), 90 deletions(-) rename ShellScript/{ => Bash}/Completion Rules.tmPreferences (94%) rename ShellScript/{test => Bash/tests}/syntax_test_reindent_case.bash (100%) rename ShellScript/{test => Bash/tests}/syntax_test_reindent_for.bash (100%) rename ShellScript/{test => Bash/tests}/syntax_test_reindent_if.bash (100%) rename ShellScript/{test => Bash/tests}/syntax_test_reindent_select.bash (100%) create mode 100644 ShellScript/Bash/tests/syntax_test_reindent_until.bash create mode 100644 ShellScript/Bash/tests/syntax_test_reindent_while.bash rename ShellScript/{test/syntax_test_bash.sh => Bash/tests/syntax_test_scope.bash} (100%) mode change 100755 => 100644 rename ShellScript/{ => Shell}/Comments.tmPreferences (100%) rename ShellScript/{ => Shell}/Fold.tmPreferences (88%) rename ShellScript/{ => Shell}/Indentation Rules - Case Clause Patterns.tmPreferences (100%) rename ShellScript/{ => Shell}/Indentation Rules - Case.tmPreferences (100%) rename ShellScript/{ => Shell}/Indentation Rules - Comments.tmPreferences (100%) rename ShellScript/{ => Shell}/Indentation Rules.tmPreferences (91%) rename ShellScript/{Snippets/case-..-esac-(case).sublime-snippet => Shell/Snippets/case.sublime-snippet} (67%) rename ShellScript/{Snippets/elif-..-(elif).sublime-snippet => Shell/Snippets/elif.sublime-snippet} (77%) rename ShellScript/{Snippets/#!-usr-bin-env-(!env).sublime-snippet => Shell/Snippets/env-shebang.sublime-snippet} (100%) rename ShellScript/{Snippets/for-in-done-(forin).sublime-snippet => Shell/Snippets/for-in.sublime-snippet} (78%) rename ShellScript/{Snippets/for-...-done-(for).sublime-snippet => Shell/Snippets/for.sublime-snippet} (78%) rename ShellScript/{Snippets/if-...-then-(if).sublime-snippet => Shell/Snippets/if.sublime-snippet} (77%) rename ShellScript/{Snippets/until-(done).sublime-snippet => Shell/Snippets/until.sublime-snippet} (78%) rename ShellScript/{Snippets/while-(done).sublime-snippet => Shell/Snippets/while.sublime-snippet} (78%) rename ShellScript/{ => Shell}/Symbol List - Coproc.tmPreferences (100%) rename ShellScript/{ => Shell}/Symbol List - Functions.tmPreferences (100%) rename ShellScript/{test/syntax_test_shell_unix_generic.sh => Shell/tests/syntax_test_scope.sh} (100%) create mode 100644 ShellScript/Zsh.sublime-settings create mode 100644 ShellScript/Zsh.sublime-syntax create mode 100644 ShellScript/Zsh/Completion Rules.tmPreferences create mode 100644 ShellScript/Zsh/Indentation Rules.tmPreferences create mode 100644 ShellScript/Zsh/Snippets/foreach-in.sublime-snippet create mode 100644 ShellScript/Zsh/Snippets/foreach.sublime-snippet create mode 100644 ShellScript/Zsh/Snippets/repeat.sublime-snippet create mode 100644 ShellScript/Zsh/tests/syntax_test_reindent_case.zsh create mode 100644 ShellScript/Zsh/tests/syntax_test_reindent_for.zsh create mode 100644 ShellScript/Zsh/tests/syntax_test_reindent_foreach.zsh create mode 100644 ShellScript/Zsh/tests/syntax_test_reindent_if.zsh create mode 100644 ShellScript/Zsh/tests/syntax_test_reindent_repeat.zsh create mode 100644 ShellScript/Zsh/tests/syntax_test_reindent_select.zsh create mode 100644 ShellScript/Zsh/tests/syntax_test_reindent_until.zsh create mode 100644 ShellScript/Zsh/tests/syntax_test_reindent_while.zsh create mode 100644 ShellScript/Zsh/tests/syntax_test_scope.zsh delete mode 100644 ShellScript/test/syntax_test_reindent_until.bash delete mode 100644 ShellScript/test/syntax_test_reindent_while.bash diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 76abf1aaca..ec44679902 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -11,7 +11,6 @@ file_extensions: - bash - bashrc # e.g.: /etc/bash.bashrc - ash - - zsh hidden_file_extensions: - .bash_aliases @@ -25,11 +24,6 @@ hidden_file_extensions: - .bashrc - .profile - .textmate_init - - .zlogin - - .zlogout - - .zprofile - - .zshenv - - .zshrc - APKBUILD # https://wiki.alpinelinux.org/wiki/APKBUILD_Reference - PKGBUILD # https://jlk.fjfi.cvut.cz/arch/manpages/man/PKGBUILD.5 - ebuild @@ -37,16 +31,15 @@ hidden_file_extensions: first_line_match: |- (?xi: - ^ \#! .* \b(bash|zsh|sh|tcsh|ash|dash)\b # shebang + ^ \#! .* \b(bash|sh|tcsh|ash|dash)\b # shebang | ^ \s* \# .*? -\*- .*? \bshell(-script)?\b .*? -\*- # editorconfig - | ^ \#(autoload|compdef)\b # zsh completions ) ############################################################################### variables: # Language identifier in shebang - shebang_language: \b(?:bash|zsh|sh|tcsh|ash|dash)\b + shebang_language: \b(?:bash|sh|tcsh|ash|dash)\b # Commands literals are command names without interpolation or quotation. cmd_literal: '{{cmd_literal_char}}+{{cmd_break}}' @@ -94,7 +87,7 @@ variables: (?x: ascii | alnum | alpha | blank | cntrl | digit | graph | lower | print | punct | space | upper | word | xdigit ) - + digit: \d varassign: '[-+]?=' wspace: (?:\s+|^) @@ -2136,14 +2129,14 @@ contexts: # a number in that base. When specifying n, the digits greater than 9 are # represented by the lowercase letters, the uppercase letters, ‘@’, and ‘_’, # in that order. - - match: (\d+#)([[:alnum:]@_]+)({{word_char}}*) + - match: (\d{{digit}}*#)([[:alnum:]@_]+)({{word_char}}*) scope: meta.number.integer.other.shell captures: 1: constant.numeric.base.shell 2: constant.numeric.value.shell 3: invalid.illegal.shell # If base# is omitted, then base 10 is used. - - match: \d+(?![.\w]) + - match: \d{{digit}}*(?![.\w]) scope: meta.number.integer.decimal.shell constant.numeric.value.shell number: @@ -2163,14 +2156,14 @@ contexts: 2: constant.numeric.base.shell 3: constant.numeric.value.shell pop: 1 - - match: ([-+]?)(\d+#)([[:alnum:]@_]+){{word_break}} + - match: ([-+]?)(\d{{digit}}*#)([[:alnum:]@_]+){{word_break}} scope: meta.number.integer.other.she captures: 1: keyword.operator.arithmetic.shell 2: constant.numeric.base.shell 3: constant.numeric.value.shell # If base# is omitted, then base 10 is used. - - match: ([-+]?)(\d+){{word_break}} + - match: ([-+]?)(\d{{digit}}*){{word_break}} scope: meta.number.integer.decimal.shell captures: 1: keyword.operator.arithmetic.shell diff --git a/ShellScript/Completion Rules.tmPreferences b/ShellScript/Bash/Completion Rules.tmPreferences similarity index 94% rename from ShellScript/Completion Rules.tmPreferences rename to ShellScript/Bash/Completion Rules.tmPreferences index 6b76acbe51..6ed9735f2a 100644 --- a/ShellScript/Completion Rules.tmPreferences +++ b/ShellScript/Bash/Completion Rules.tmPreferences @@ -2,7 +2,7 @@ scope - source.shell + source.shell.bash settings + begin + meta.statement.loop.foreach punctuation.section.sequence.end + end + keyword.control.loop.endforeach + excludeTrailingNewlines + + diff --git a/ShellScript/Indentation Rules - Case Clause Patterns.tmPreferences b/ShellScript/Shell/Indentation Rules - Case Clause Patterns.tmPreferences similarity index 100% rename from ShellScript/Indentation Rules - Case Clause Patterns.tmPreferences rename to ShellScript/Shell/Indentation Rules - Case Clause Patterns.tmPreferences diff --git a/ShellScript/Indentation Rules - Case.tmPreferences b/ShellScript/Shell/Indentation Rules - Case.tmPreferences similarity index 100% rename from ShellScript/Indentation Rules - Case.tmPreferences rename to ShellScript/Shell/Indentation Rules - Case.tmPreferences diff --git a/ShellScript/Indentation Rules - Comments.tmPreferences b/ShellScript/Shell/Indentation Rules - Comments.tmPreferences similarity index 100% rename from ShellScript/Indentation Rules - Comments.tmPreferences rename to ShellScript/Shell/Indentation Rules - Comments.tmPreferences diff --git a/ShellScript/Indentation Rules.tmPreferences b/ShellScript/Shell/Indentation Rules.tmPreferences similarity index 91% rename from ShellScript/Indentation Rules.tmPreferences rename to ShellScript/Shell/Indentation Rules.tmPreferences index a62726dd9b..4d42ce10d6 100644 --- a/ShellScript/Indentation Rules.tmPreferences +++ b/ShellScript/Shell/Indentation Rules.tmPreferences @@ -4,7 +4,7 @@ scope source.shell, - meta.clause.body.shell + source.shell meta.clause.body settings @@ -27,9 +27,10 @@ | .* (?: [({\[] | \b(?: do | in | then )\b ) \s* (?: \#.* | \\ )? $ ) ]]> + bracketIndentNextLinePattern + disableIndentNextLinePattern - indentParens indentSquareBrackets diff --git a/ShellScript/Snippets/case-..-esac-(case).sublime-snippet b/ShellScript/Shell/Snippets/case.sublime-snippet similarity index 67% rename from ShellScript/Snippets/case-..-esac-(case).sublime-snippet rename to ShellScript/Shell/Snippets/case.sublime-snippet index 8c238438cd..fe3c1f5785 100644 --- a/ShellScript/Snippets/case-..-esac-(case).sublime-snippet +++ b/ShellScript/Shell/Snippets/case.sublime-snippet @@ -1,9 +1,11 @@ case - source.shell.bash + source.shell.bash, source.shell.zsh case … esac diff --git a/ShellScript/Snippets/elif-..-(elif).sublime-snippet b/ShellScript/Shell/Snippets/elif.sublime-snippet similarity index 77% rename from ShellScript/Snippets/elif-..-(elif).sublime-snippet rename to ShellScript/Shell/Snippets/elif.sublime-snippet index 2898dfb6d5..6ce67255a0 100644 --- a/ShellScript/Snippets/elif-..-(elif).sublime-snippet +++ b/ShellScript/Shell/Snippets/elif.sublime-snippet @@ -2,6 +2,6 @@ elif - source.shell.bash + source.shell.bash, source.shell.zsh elif … diff --git a/ShellScript/Snippets/#!-usr-bin-env-(!env).sublime-snippet b/ShellScript/Shell/Snippets/env-shebang.sublime-snippet similarity index 100% rename from ShellScript/Snippets/#!-usr-bin-env-(!env).sublime-snippet rename to ShellScript/Shell/Snippets/env-shebang.sublime-snippet diff --git a/ShellScript/Snippets/for-in-done-(forin).sublime-snippet b/ShellScript/Shell/Snippets/for-in.sublime-snippet similarity index 78% rename from ShellScript/Snippets/for-in-done-(forin).sublime-snippet rename to ShellScript/Shell/Snippets/for-in.sublime-snippet index cd39e386f0..902a07c339 100644 --- a/ShellScript/Snippets/for-in-done-(forin).sublime-snippet +++ b/ShellScript/Shell/Snippets/for-in.sublime-snippet @@ -3,6 +3,6 @@ ${0:#statements} done]]> forin - source.shell.bash + source.shell.bash, source.shell.zsh for … in … done diff --git a/ShellScript/Snippets/for-...-done-(for).sublime-snippet b/ShellScript/Shell/Snippets/for.sublime-snippet similarity index 78% rename from ShellScript/Snippets/for-...-done-(for).sublime-snippet rename to ShellScript/Shell/Snippets/for.sublime-snippet index 9079ef4427..b2d4bc76e3 100644 --- a/ShellScript/Snippets/for-...-done-(for).sublime-snippet +++ b/ShellScript/Shell/Snippets/for.sublime-snippet @@ -3,6 +3,6 @@ ${0:#statements} done]]> for - source.shell.bash + source.shell.bash, source.shell.zsh for … done diff --git a/ShellScript/Snippets/if-...-then-(if).sublime-snippet b/ShellScript/Shell/Snippets/if.sublime-snippet similarity index 77% rename from ShellScript/Snippets/if-...-then-(if).sublime-snippet rename to ShellScript/Shell/Snippets/if.sublime-snippet index 20322aa0d5..c59e0c095b 100644 --- a/ShellScript/Snippets/if-...-then-(if).sublime-snippet +++ b/ShellScript/Shell/Snippets/if.sublime-snippet @@ -3,6 +3,6 @@ ${0:#statements} fi]]> if - source.shell.bash + source.shell.bash, source.shell.zsh if … fi diff --git a/ShellScript/Snippets/until-(done).sublime-snippet b/ShellScript/Shell/Snippets/until.sublime-snippet similarity index 78% rename from ShellScript/Snippets/until-(done).sublime-snippet rename to ShellScript/Shell/Snippets/until.sublime-snippet index 67999de3a6..39445a71b8 100644 --- a/ShellScript/Snippets/until-(done).sublime-snippet +++ b/ShellScript/Shell/Snippets/until.sublime-snippet @@ -3,6 +3,6 @@ ${0:#statements} done]]> until - source.shell.bash + source.shell.bash, source.shell.zsh until … done diff --git a/ShellScript/Snippets/while-(done).sublime-snippet b/ShellScript/Shell/Snippets/while.sublime-snippet similarity index 78% rename from ShellScript/Snippets/while-(done).sublime-snippet rename to ShellScript/Shell/Snippets/while.sublime-snippet index 5fdedde07c..f1f58252aa 100644 --- a/ShellScript/Snippets/while-(done).sublime-snippet +++ b/ShellScript/Shell/Snippets/while.sublime-snippet @@ -3,6 +3,6 @@ ${0:#statements} done]]> while - source.shell.bash + source.shell.bash, source.shell.zsh while … done diff --git a/ShellScript/Symbol List - Coproc.tmPreferences b/ShellScript/Shell/Symbol List - Coproc.tmPreferences similarity index 100% rename from ShellScript/Symbol List - Coproc.tmPreferences rename to ShellScript/Shell/Symbol List - Coproc.tmPreferences diff --git a/ShellScript/Symbol List - Functions.tmPreferences b/ShellScript/Shell/Symbol List - Functions.tmPreferences similarity index 100% rename from ShellScript/Symbol List - Functions.tmPreferences rename to ShellScript/Shell/Symbol List - Functions.tmPreferences diff --git a/ShellScript/test/syntax_test_shell_unix_generic.sh b/ShellScript/Shell/tests/syntax_test_scope.sh similarity index 100% rename from ShellScript/test/syntax_test_shell_unix_generic.sh rename to ShellScript/Shell/tests/syntax_test_scope.sh diff --git a/ShellScript/Zsh.sublime-settings b/ShellScript/Zsh.sublime-settings new file mode 100644 index 0000000000..2f602dbd49 --- /dev/null +++ b/ShellScript/Zsh.sublime-settings @@ -0,0 +1,3 @@ +{ + "default_line_ending": "unix", +} diff --git a/ShellScript/Zsh.sublime-syntax b/ShellScript/Zsh.sublime-syntax new file mode 100644 index 0000000000..722bf87a24 --- /dev/null +++ b/ShellScript/Zsh.sublime-syntax @@ -0,0 +1,931 @@ +%YAML 1.2 +--- +# https://www.sublimetext.com/docs/syntax.html +# https://zsh-manual.netlify.app/shell-grammar/ +# https://zsh.sourceforge.io/Doc/Release/ +name: Zsh +scope: source.shell.zsh +version: 2 + +extends: Packages/ShellScript/Bash.sublime-syntax + +file_extensions: + - zsh + +hidden_file_extensions: + - .zlogin + - .zlogout + - .zprofile + - .zshenv + - .zshrc + +first_line_match: |- + (?xi: + ^ \#! .* \bzsh\b # shebang + | ^ \#(autoload|compdef)\b # zsh completions + ) + +############################################################################### + +contexts: + +###[ ANONYMOUS FUNCTION DEFINITIONS ]########################################## + + def-anonymous-body: + - meta_prepend: true + - include: terminators + +###[ FUNCTION DEFINITIONS ]#################################################### + + def-function-begin: + - meta_include_prototype: false + - meta_scope: meta.function.shell + - match: '' + set: + - def-function-body + - def-function-params + - def-function-name + - def-function-flag + + def-function-flag: + - clear_scopes: 1 + - meta_scope: meta.function.shell + - match: ([-+])[tTuU]{{opt_break}} + scope: meta.parameter.option.shell variable.parameter.option.shell + captures: + 1: punctuation.definition.parameter.shell + pop: 1 + - include: line-continuations + - include: comments + - include: else-pop + + def-function-name: + - meta_prepend: true + - match: '{{hook_functions}}' + scope: entity.name.function.shell support.function.shell.zsh + pop: 1 + - match: '{{trap_functions}}' + scope: entity.name.function.shell support.function.shell.zsh + pop: 1 + + def-function-body: + - meta_include_prototype: false + - meta_content_scope: meta.function.shell + - include: def-function-body-braces + - include: line-continuations + - include: comments + - include: terminators + - match: (?=\S) + set: + - def-function-simple-body + - statement + + def-function-simple-body: + - meta_include_prototype: false + - meta_content_scope: meta.function.body.shell + - include: immediately-pop + + def-function-end: + - meta_prepend: true + - include: redirections + +###[ BUILTINS ]################################################################ + + cmd-builtin: + - meta_prepend: true + - match: autoload{{cmd_break}} + scope: + meta.function-call.identifier.shell + support.function.shell.zsh + set: + - cmd-args-meta + - cmd-args-end-of-options-then-function-references + +###[ COMMANDS ]################################################################ + + cmd-compound: + - match: \{ + scope: punctuation.section.block.begin.shell + set: cmd-compound-braces-body + - match: \( + scope: punctuation.section.compound.begin.shell + set: cmd-compound-parens-body + + cmd-compound-braces-body: + - meta_scope: meta.block.shell + - match: \} + scope: punctuation.section.block.end.shell + pop: 1 + - include: statements + +###[ CONTROL STATEMENTS ]###################################################### + + cmd-control: + - meta_append: true + # 6.3 Complex Commands + - match: always{{cmd_break}} + scope: keyword.control.exception.always.shell.zsh + - match: repeat{{cmd_break}} + scope: keyword.control.loop.repeat.shell.zsh + set: + - repeat-meta + - repeat-args + # 6.4 Alternate Forms For Complex Commands + - match: foreach{{cmd_break}} + scope: keyword.control.loop.foreach.shell.zsh + set: + - foreach-meta + - loop-iterator-wordlist + - loop-iterator-var + - match: end{{cmd_break}} + scope: keyword.control.loop.endforeach.shell.zsh + + case-word: + - meta_prepend: true + - match: \{ + scope: punctuation.section.block.begin.shell.zsh + set: case-block-body + + case-block-body: + - meta_scope: meta.statement.conditional.case.body.shell meta.block.shell.zsh + - match: \} + scope: punctuation.section.block.end.shell.zsh + pop: 1 + - include: comments + - include: case-clauses + + foreach-meta: + - meta_include_prototype: false + - meta_scope: meta.statement.loop.foreach.shell.zsh + - include: immediately-pop + + repeat-meta: + - meta_include_prototype: false + - meta_scope: meta.statement.loop.repeat.shell.zsh + - include: immediately-pop + + repeat-args: + - meta_include_prototype: false + - include: eoc-pop + - include: arithmetic-word + + loop-iterator-wordlist: + - meta_prepend: true + - match: \( + scope: punctuation.section.sequence.begin.shell.zsh + set: loop-iterator-wordlist-group-body + + loop-iterator-wordlist-group-body: + - meta_scope: meta.sequence.list.shell.zsh + - match: \) + scope: punctuation.section.sequence.end.shell.zsh + pop: 1 + - include: comments + - include: string-path-patterns + +###[ ARITHMETIC EXPRESSIONS ]################################################## + + expression-common: + - meta_prepend: true + - include: zsh-expression-flags + - include: zsh-expression-function-call + + zsh-expression-flags: + - match: \[# + scope: punctuation.definition.modifier.begin.shell.zsh + push: zsh-expression-flag-body + + zsh-expression-flag-body: + - meta_scope: meta.modifier.base.shell.zsh + - meta_content_scope: storage.modifier.mode.base.shell.zsh + - match: \] + scope: punctuation.definition.modifier.end.shell.zsh + pop: 1 + - include: string-interpolations + + zsh-expression-function-call: + - match: '{{identifier}}(?=\s*\()' + scope: meta.function-call.identifier.shell.zsh variable.function.shell.zsh + push: zsh-expression-function-argument-list + + zsh-expression-function-argument-list: + - meta_content_scope: meta.function-call.identifier.shell.zsh + - match: \( + scope: punctuation.section.arguments.begin.shell.zsh + set: zsh-expression-function-argument-list-body + + zsh-expression-function-argument-list-body: + - meta_scope: meta.function-call.arguments.shell.zsh + - match: \) + scope: punctuation.section.arguments.end.shell.zsh + pop: 1 + - include: expression-common + +###[ OPERATORS ]############################################################### + + operators: + - meta_prepend: true + - match: \&[|!] + scope: keyword.operator.assignment.pipe.shell.zsh + +###[ REDIRECTIONS AND HEREDOCS ]############################################### + + redirections-input: + # not looking like a number range + - match: (\d*)(<(?:&|(?!(?:\{.*?\}|\S)*>))) + captures: + 1: meta.file-descriptor.shell + meta.number.integer.decimal.shell + constant.numeric.value.shell + 2: keyword.operator.assignment.redirection.shell + push: + - redirection-meta + - redirection-descriptor + +###[ LITERALS ]################################################################ + + numbers: + - meta_prepend: true + - match: (\d{{digit}}*(\.){{digit}}*(?:[eE][-+]?{{digit}}*)?)({{word_char}}*) + scope: meta.number.float.decimal.shell.zsh + captures: + 1: constant.numeric.value.shell.zsh + 2: punctuation.separator.decimal.shell.zsh + 3: invalid.illegal.shell.zsh + + number: + - meta_prepend: true + - match: ([-+]?)(\d{{digit}}*(\.){{digit}}*(?:[eE][-+]?{{digit}}*)?){{word_break}} + scope: meta.number.float.decimal.shell.zsh + captures: + 1: keyword.operator.arithmetic.shell.zsh + 2: constant.numeric.value.shell.zsh + 3: punctuation.separator.decimal.shell.zsh + pop: 1 + +###[ STRING PATH PATTERN MATCHING ]############################################ + + string-path-patterns: + - meta_prepend: true + - match: \^ + scope: keyword.operator.logical.regexp.shell.zsh + push: + - string-path-pattern-body + - maybe-tilde-interpolation + + string-path-pattern: + - meta_prepend: true + - match: \^ + scope: keyword.operator.logical.regexp.shell.zsh + set: + - string-path-pattern-body + - maybe-tilde-interpolation + + string-path-pattern-content: + - meta_prepend: true + - include: zsh-pattern-flags + - include: zsh-pattern-operators + - include: zsh-pattern-ranges + +###[ PATH PATTERN MATCHING ]################################################### + + path-pattern-content: + - meta_prepend: true + - include: zsh-pattern-flags + - include: zsh-pattern-operators + - include: zsh-pattern-ranges + +###[ SHELL PATTERN MATCHING ]################################################## + + pattern-main-content: + - meta_prepend: true + - include: zsh-pattern-flags + - include: zsh-pattern-operators + - include: zsh-pattern-ranges + + pattern-groups: + # KSH_GLOB is optional (hence not matching ? and * in favor of ZSH globs) + - match: ([+@!]??)(\() + captures: + 1: string.unquoted.shell keyword.operator.quantifier.regexp.shell + 2: meta.group.regexp.shell string.unquoted.shell punctuation.definition.group.begin.regexp.shell + push: pattern-group-body + + pattern-group-content: + - meta_prepend: true + - match: (?=e(?:[<{(\[]|.["'])) + push: zsh-evaluation-interpolation + - include: zsh-pattern-flags + - include: zsh-pattern-operators + - include: zsh-pattern-ranges + + zsh-evaluation-interpolation: + - clear_scopes: 1 + - meta_scope: meta.interpolation.command.shell.zsh + - match: e\{(["']?) + scope: punctuation.section.interpolation.begin.shell.zsh + embed: statements + escape: \1\} + escape_captures: + 0: punctuation.section.interpolation.end.shell.zsh + - match: e\[(["']?) + scope: punctuation.section.interpolation.begin.shell.zsh + embed: statements + escape: \1\] + escape_captures: + 0: punctuation.section.interpolation.end.shell.zsh + - match: e\((["']?) + scope: punctuation.section.interpolation.begin.shell.zsh + embed: statements + escape: \3\) + escape_captures: + 0: punctuation.section.interpolation.end.shell.zsh + - match: e<(["']?) + scope: punctuation.section.interpolation.begin.shell.zsh + embed: statements + escape: \3> + escape_captures: + 0: punctuation.section.interpolation.end.shell.zsh + - match: e(.)(['"]?) + scope: punctuation.section.interpolation.begin.shell.zsh + embed: statements + escape: \2\1 + escape_captures: + 0: punctuation.section.interpolation.end.shell.zsh + - include: immediately-pop + + zsh-pattern-flags: + - match: \(# + scope: punctuation.definition.modifier.begin.shell.zsh + push: zsh-pattern-flag-body + + zsh-pattern-flag-body: + - clear_scopes: 1 + - meta_scope: meta.modifier.glob.shell.zsh + - meta_content_scope: storage.modifier.mode.glob.shell.zsh + - include: zsh-pattern-flag-end + - include: string-interpolations + - match: \, + scope: punctuation.separator.sequence.shell + - match: q + scope: storage.modifier.mode.glob.shell.zsh + set: zsh-pattern-flag-qualifier-body + + zsh-pattern-flag-qualifier-body: + # Contains glob qualifiers if EXTENDED_GLOB is set + # https://zsh.sourceforge.io/Doc/Release/Expansion.html#Glob-Qualifiers + - clear_scopes: 1 + - meta_scope: meta.modifier.glob.shell.zsh + - include: zsh-pattern-flag-end + - include: string-interpolations + + zsh-pattern-flag-end: + - match: \) + scope: punctuation.definition.modifier.end.shell.zsh + pop: 1 + - include: line-continuations + + zsh-pattern-operators: + - match: '[~^]' + scope: keyword.operator.logical.regexp.shell.zsh + push: maybe-tilde-interpolation + - match: \#{1,2} + scope: keyword.operator.quantifier.regexp.shell.zsh + + zsh-pattern-ranges: + - match: (?=\d*<) + branch_point: zsh-pattern-range + branch: + - zsh-pattern-range-begin + - zsh-pattern-range-fallback + + zsh-pattern-range-begin: + - meta_include_prototype: false + - match: \< + scope: punctuation.definition.range.begin.shell.zsh + set: zsh-pattern-range-body + - match: \d+ + scope: meta.number.integer.decimal.shell constant.numeric.value.shell + + zsh-pattern-range-body: + - meta_scope: meta.range.shell.zsh + - match: \> + scope: punctuation.definition.range.end.shell.zsh + pop: 1 + - include: line-continuations + - include: expansions-variables + - match: \- + scope: keyword.operator.range.shell.zsh + - match: ([-+]?)(\d+) + scope: meta.number.integer.decimal.shell + captures: + 1: keyword.operator.arithmetic.shell + 2: constant.numeric.value.shell + - match: '' + fail: zsh-pattern-range + + zsh-pattern-range-fallback: + - meta_include_prototype: false + # input redirection + - match: (\d*)(<&?) + captures: + 1: meta.file-descriptor.shell + meta.number.integer.decimal.shell + constant.numeric.value.shell + 2: keyword.operator.assignment.redirection.shell + set: redirection-descriptor + +###[ ARITHMETIC EXPANSIONS ]################################################### + + expansions-arithmetic: + - meta_prepend: true + - match: (\$)(\[) + captures: + 1: punctuation.definition.variable.shell.zsh + 2: punctuation.section.interpolation.begin.shell.zsh + push: zsh-arithmetic-expansion-body + + zsh-arithmetic-expansion-body: + - meta_scope: meta.interpolation.arithmetic.shell.zsh + - match: \] + scope: punctuation.section.interpolation.end.shell.zsh + pop: 1 + - include: expression-content + +###[ PARAMETER EXPANSIONS ]#################################################### + + expansions-parameter: + - match: (\$)(\{) + captures: + 1: punctuation.definition.variable.shell + 2: punctuation.section.interpolation.begin.shell + push: + - expansion-parameter-meta + - expansion-parameter-modifier + - expansion-parameter-name + - expansion-parameter-operator + - zsh-parameter-flags + # https://www.gnu.org/software/bash/manual/bash.html#Positional-Parameters + - match: (\$)\d + scope: variable.language.positional.shell + captures: + 1: punctuation.definition.variable.shell + push: zsh-parameter-subscription + # https://www.gnu.org/software/bash/manual/bash.html#Shell-Variables + - match: (\$){{builtin_variables}} + scope: variable.language.builtin.shell + captures: + 1: punctuation.definition.variable.shell + push: zsh-parameter-subscription + # https://www.gnu.org/software/bash/manual/bash.html#Special-Parameters + - match: (\$){{special_variables}} + scope: variable.language.special.shell + captures: + 1: punctuation.definition.variable.shell + push: zsh-parameter-subscription + - match: (\$){{identifier}} + scope: variable.other.readwrite.shell + captures: + 1: punctuation.definition.variable.shell + push: zsh-parameter-subscription + + expansion-parameter-operator: + # 14.3 Parameter Expansion + # https://zsh.sourceforge.io/Doc/Release/Expansion.html#Parameter-Expansion + - meta_prepend: true + # Expand elements like brace expansion + - match: \^{1,2} + scope: keyword.operator.expansion.brace.shell.zsh + pop: 1 + # Allow globbing, file expansion on result + - match: \~{1,2} + scope: keyword.operator.expansion.glob.shell.zsh + pop: 1 + # Split words of result like lesser shells + - match: \={1,2} + scope: keyword.operator.expansion.split.shell.zsh + pop: 1 + # 1 if var is set, else 0 + - match: \+ + scope: keyword.operator.expansion.valid.shell.zsh + pop: 1 + + expansion-parameter-modifier: + # 14.3 Parameter Expansion + - meta_prepend: true + # $var if non-null, else str and set var to it + - match: ::= + scope: keyword.operator.assignment.shell.zsh + set: + - expansion-parameter-value + - maybe-tilde-interpolation + - match: :# + scope: keyword.operator.assignment.shell.zsh + set: + - expansion-parameter-value + - maybe-tilde-interpolation + + expansion-parameter-pattern: + - meta_prepend: true + - include: zsh-pattern-flags + - include: zsh-pattern-operators + - include: zsh-pattern-ranges + + expansion-parameter-pattern-group-body: + - meta_prepend: true + - include: zsh-pattern-flags + - include: zsh-pattern-operators + - include: zsh-pattern-ranges + + expansion-parameter-pattern-groups: + # KSH_GLOB is optional (hence not matching ? and * in favor of ZSH globs) + - match: ([+@!]??)(\() + captures: + 1: string.unquoted.shell keyword.operator.quantifier.regexp.shell + 2: meta.group.regexp.shell string.unquoted.shell punctuation.definition.group.begin.regexp.shell + push: expansion-parameter-pattern-group-body + + zsh-parameter-subscription: + - meta_include_prototype: false + - meta_scope: meta.interpolation.parameter.shell + - include: variable-subscription + + zsh-parameter-flags: + # 14.3.1 Parameter Expansion Flags + # https://zsh.sourceforge.io/Doc/Release/Expansion.html#Parameter-Expansion-Flags + - match: \( + scope: punctuation.definition.modifier.begin.shell.zsh + set: zsh-parameter-flag-body + - include: immediately-pop + + zsh-parameter-flag-body: + - meta_scope: meta.modifier.parameter.shell.zsh + - match: \) + scope: punctuation.definition.modifier.end.shell.zsh + pop: 1 + # bailout from unbalanced brackets + - include: brace-pop + # flag:expr: + - match: '[Ilr]' + scope: storage.modifier.expansion.flag.shell.zsh + push: zsh-parameter-flag-expression-argument + # _:flags: + - match: (_)(\W)(.*?)(\2) + captures: + 1: storage.modifier.expansion.flag.reserved.shell.zsh + 2: punctuation.section.argument.begin.shell.zsh + 3: invalid.illegal.unsupported.shell.zsh + 4: punctuation.section.argument.end.shell.zsh + # simple single char flags + # TODO: `*` enables extended globs -> handle in syntax? + - match: '[-~#%*@0ABCDEFLMNOPQRSTUVWXZabcefgijkmnopqstuvwz]' + scope: storage.modifier.expansion.flag.shell.zsh + # string arguments + - match: \< + scope: punctuation.section.argument.begin.shell.zsh + push: zsh-parameter-flag-angle-string-argument + - match: \{ + scope: punctuation.section.argument.begin.shell.zsh + push: zsh-parameter-flag-brace-string-argument + - match: \[ + scope: punctuation.section.argument.begin.shell.zsh + push: zsh-parameter-flag-bracket-string-argument + - match: \( + scope: punctuation.section.argument.begin.shell.zsh + push: zsh-parameter-flag-paren-string-argument + - match: (\W) + scope: punctuation.section.argument.begin.shell.zsh + push: zsh-parameter-flag-string-argument + + zsh-parameter-flag-expression-argument: + - meta_include_prototype: false + - match: \< + scope: punctuation.section.argument.begin.shell.zsh + set: zsh-parameter-flag-angle-expression-argument + - match: \{ + scope: punctuation.section.argument.begin.shell.zsh + set: zsh-parameter-flag-brace-expression-argument + - match: \[ + scope: punctuation.section.argument.begin.shell.zsh + set: zsh-parameter-flag-bracket-expression-argument + - match: \( + scope: punctuation.section.argument.begin.shell.zsh + set: zsh-parameter-flag-paren-expression-argument + - match: (\W) + scope: punctuation.section.argument.begin.shell.zsh + set: zsh-parameter-flag-other-expression-argument + - include: immediately-pop + + zsh-parameter-flag-angle-expression-argument: + - meta_include_prototype: false + - meta_scope: meta.argument.shell.zsh + - meta_content_scope: meta.arithmetic.shell + - match: \> + scope: punctuation.section.argument.end.shell.zsh + pop: 1 + - include: brace-pop + - include: expression-content + + zsh-parameter-flag-brace-expression-argument: + - meta_include_prototype: false + - meta_scope: meta.argument.shell.zsh + - meta_content_scope: meta.arithmetic.shell + - match: \} + scope: punctuation.section.argument.end.shell.zsh + pop: 1 + - include: expression-content + + zsh-parameter-flag-bracket-expression-argument: + - meta_include_prototype: false + - meta_scope: meta.argument.shell.zsh + - meta_content_scope: meta.arithmetic.shell + - match: \] + scope: punctuation.section.argument.end.shell.zsh + pop: 1 + - include: brace-pop + - include: expression-content + + zsh-parameter-flag-paren-expression-argument: + - meta_include_prototype: false + - meta_scope: meta.argument.shell.zsh + - meta_content_scope: meta.arithmetic.shell + - match: \) + scope: punctuation.section.argument.end.shell.zsh + pop: 1 + - include: brace-pop + - include: expression-content + + zsh-parameter-flag-other-expression-argument: + - meta_include_prototype: false + - meta_scope: meta.argument.shell.zsh + - meta_content_scope: meta.arithmetic.shell + - match: \1 + scope: punctuation.section.argument.end.shell.zsh + pop: 1 + - include: brace-pop + - include: expression-content + + zsh-parameter-flag-angle-string-argument: + - meta_include_prototype: false + - meta_scope: meta.argument.shell.zsh + - meta_content_scope: meta.string.shell.zsh string.unquoted.shell.zsh + - match: \> + scope: punctuation.section.argument.end.shell.zsh + pop: 1 + - include: brace-pop + - include: string-unquoted-content + + zsh-parameter-flag-brace-string-argument: + - meta_include_prototype: false + - meta_scope: meta.argument.shell.zsh + - meta_content_scope: meta.string.shell.zsh string.unquoted.shell.zsh + - match: \} + scope: punctuation.section.argument.end.shell.zsh + pop: 1 + - include: string-unquoted-content + + zsh-parameter-flag-bracket-string-argument: + - meta_include_prototype: false + - meta_scope: meta.argument.shell.zsh + - meta_content_scope: meta.string.shell.zsh string.unquoted.shell.zsh + - match: \] + scope: punctuation.section.argument.end.shell.zsh + pop: 1 + - include: brace-pop + - include: string-unquoted-content + + zsh-parameter-flag-paren-string-argument: + - meta_include_prototype: false + - meta_scope: meta.argument.shell.zsh + - meta_content_scope: meta.string.shell.zsh string.unquoted.shell.zsh + - match: \) + scope: punctuation.section.argument.end.shell.zsh + pop: 1 + - include: brace-pop + - include: string-unquoted-content + + zsh-parameter-flag-string-argument: + - meta_include_prototype: false + - meta_scope: meta.argument.shell.zsh + - meta_content_scope: meta.string.shell.zsh string.unquoted.shell.zsh + - match: \1 + scope: punctuation.section.argument.end.shell.zsh + pop: 1 + - include: brace-pop + - include: string-unquoted-content + +###[ TILDE EXPANSIONS ]######################################################## + + tilde-interpolation: + - meta_append: true + - include: equals-expansion + + tilde-modifier: + - meta_prepend: true + # 14.7.1 Dynamic named directories + # https://zsh.sourceforge.io/Doc/Release/Expansion.html#Dynamic-named-directories + - match: \[ + scope: punctuation.section.brackets.begin.shell.zsh + push: tilde-modifier-function + + tilde-modifier-function: + - meta_scope: meta.brackets.shell.zsh + - meta_content_scope: meta.function-call.identifier.shell.zsh variable.function.shell.zsh + - match: \] + scope: punctuation.section.brackets.end.shell.zsh + pop: 2 + - include: literal-unquoted-content + + equals-expansion: + # 14.7.3 ‘=’ expansion + # https://zsh.sourceforge.io/Doc/Release/Expansion.html#g_t_0060_003d_0027-expansion + - match: = + scope: punctuation.definition.expansion.shell.zsh + pop: 1 + +###[ VARIABLES ]############################################################### + +variables: + # Language identifier in shebang + shebang_language: \bzsh\b + + # Numbers + digit: '[\d_]' + + # Parameter expansions + is_interpolation: (?=\$[({\[{{identifier_char}}{{special_variables}}]|`) + + # A character that, when unquoted, separates words. + # Bash ones + `{` and `}` + metachar: '[\s|&;(){}<>]' + + # 9.3.1 Hook Functions + hook_functions: |- + (?x: chpwd | periodic | precmd | preexec | zshaddhistory | zshexit ){{cmd_break}} + + # 9.3.2 Trap Functions + trap_functions: |- + (?x: TRAP (?: DEBUG | EXIT | ZERR | {{signal_subnames}} ) ){{cmd_break}} + + # 17 Shell Builtin Commands + # https://zsh.sourceforge.io/Doc/Release/Shell-Builtin-Commands.html#Shell-Builtin-Commands + builtin_cmds: |- + (?x: \. | \: | bg | bindkey | bye | cap | cd | chdir | clone | comparguments + | compcall | compctl | compdescribe | compfiles | compgroups | compquote + | comptags | comptry | compvalues | dirs | disable | disown | echotc + | echoti | emulate | enable | eval | fc | fg | float | functions | getcap + | getln | getopts | hash | history | integer | job | jobs | kill | limit + | logout | popd | print | printf | pushd | pushln | pwd | r | read | rehash + | sched | set | setcap | setopt | shift | source | stat | suspend | times + | trap | ttyctl | type | typeset | ulimit | umask | unfunction | unhash + | unlimit | unsetopt | vared | wait | whence | where | which | zcompile + | zformat | zftp | zle | zmodload | zparseopts | zprof | zpty | zregexparse + | zsocket | zstyle | ztcp ){{cmd_break}} + + modifier_cmds: |- + (?x: builtin | nocorrect | noglob ){{cmd_break}} + + # 14.8.1 Glob Operators + posix_classes: |- + (?x: + # POSIX classes + ascii | alnum | alpha | blank | cntrl | digit | graph + | lower | print | punct | space | upper | word | xdigit + # ZSH specific classes + | IDENT | IFS | IFSSPACE | INCOMPLETE | WORD ) + + # 15.5 Parameters Set By The Shell + # https://zsh.sourceforge.io/Doc/Release/Parameters.html#Parameters-Set-By-The-Shell + # 15.6 Parameters Used By The Shell + # https://zsh.sourceforge.io/Doc/Release/Parameters.html#Parameters-Used-By-The-Shell + builtin_variables: |- + (?x: + _ + | ARGC + | argv + | ARGV0 + | BAUD + | CDPATH + | cdpath + | COLUMNS + | CORRECT_IGNORE + | CORRECT_IGNORE_FILE + | CPUTYPE + | DIRSTACKSIZE + | EGID + | ENV + | ERRNO + | EUID + | FCEDIT + | fignore + | fpath + | FUNCNEST + | GID + | histchars + | HISTCHARS + | HISTCMD + | HISTFILE + | HISTORY_IGNORE + | HISTSIZE + | HOME + | HOST + | IFS + | KEYBOARD_HACK + | KEYTIMEOUT + | LANG + | LC_ALL + | LC_COLLATE + | LC_CTYPE + | LC_MESSAGES + | LC_NUMERIC + | LC_TIME + | LINENO + | LINES + | LISTMAX + | LOGNAME + | MACHTYPE + | MAIL + | MAILCHECK + | mailpath + | manpath + | match + | MATCH + | mbegin + | MBEGIN + | mend + | MEND + | module_path + | NULLCMD + | OLDPWD + | OPTARG + | OPTIND + | OSTYPE + | PATH + | path + | pipestatus + | POSTEDIT + | PPID + | PROMPT + | prompt + | PROMPT2 + | PROMPT3 + | PROMPT4 + | PROMPT_EOL_MARK + | PS1 + | PS2 + | PS3 + | PS4 + | psvar + | PWD + | RANDOM + | READNULLCMD + | REPLY + | reply + | REPORTMEMORY + | REPORTTIME + | RPROMPT + | RPROMPT2 + | RPS1 + | RPS2 + | SAVEHIST + | SECONDS + | SHELL + | SHLVL + | signals + | SPROMPT + | status + | STTY + | TERM + | TERMINFO + | TERMINFO_DIRS + | TIMEFMT + | TMOUT + | TMPPREFIX + | TMPSUFFIX + | TRY_BLOCK_ERROR + | TRY_BLOCK_INTERRUPT + | TTY + | TTYIDLE + | UID + | USERNAME + | VENDOR + | WORDCHARS + | ZBEEP + | ZDOTDIR + | zle_bracketed_paste + | zle_highlight + | ZLE_LINE_ABORTED + | ZLE_REMOVE_SUFFIX_CHARS + | ZLE_RPROMPT_INDENT + | ZLE_SPACE_SUFFIX_CHARS + | ZSH_ARGZERO + | zsh_eval_context + | ZSH_EXECUTION_STRING + | ZSH_NAME + | ZSH_PATCHLEVEL + | zsh_scheduled_events + | ZSH_SCRIPT + | ZSH_SUBSHELL + | ZSH_VERSION + ){{identifier_break}} + diff --git a/ShellScript/Zsh/Completion Rules.tmPreferences b/ShellScript/Zsh/Completion Rules.tmPreferences new file mode 100644 index 0000000000..32a7beaaa3 --- /dev/null +++ b/ShellScript/Zsh/Completion Rules.tmPreferences @@ -0,0 +1,50 @@ + + + + scope + source.shell.zsh + settings + + + cancelCompletion + + + + diff --git a/ShellScript/Zsh/Indentation Rules.tmPreferences b/ShellScript/Zsh/Indentation Rules.tmPreferences new file mode 100644 index 0000000000..4a49dabdc6 --- /dev/null +++ b/ShellScript/Zsh/Indentation Rules.tmPreferences @@ -0,0 +1,55 @@ + + + + scope + + source.shell.zsh, + source.shell.zsh meta.clause.body + + settings + + decreaseIndentPattern + + increaseIndentPattern + + bracketIndentNextLinePattern + + disableIndentNextLinePattern + + indentParens + + indentSquareBrackets + + preserveIndent + + + + diff --git a/ShellScript/Zsh/Snippets/foreach-in.sublime-snippet b/ShellScript/Zsh/Snippets/foreach-in.sublime-snippet new file mode 100644 index 0000000000..433d7c9778 --- /dev/null +++ b/ShellScript/Zsh/Snippets/foreach-in.sublime-snippet @@ -0,0 +1,8 @@ + + + foreachin + source.shell.zsh + foreach … done + diff --git a/ShellScript/Zsh/Snippets/foreach.sublime-snippet b/ShellScript/Zsh/Snippets/foreach.sublime-snippet new file mode 100644 index 0000000000..64c5b0f0a1 --- /dev/null +++ b/ShellScript/Zsh/Snippets/foreach.sublime-snippet @@ -0,0 +1,8 @@ + + + foreach + source.shell.zsh + foreach … done + diff --git a/ShellScript/Zsh/Snippets/repeat.sublime-snippet b/ShellScript/Zsh/Snippets/repeat.sublime-snippet new file mode 100644 index 0000000000..2c0e786707 --- /dev/null +++ b/ShellScript/Zsh/Snippets/repeat.sublime-snippet @@ -0,0 +1,8 @@ + + + repeat + source.shell.zsh + repeat … done + diff --git a/ShellScript/Zsh/tests/syntax_test_reindent_case.zsh b/ShellScript/Zsh/tests/syntax_test_reindent_case.zsh new file mode 100644 index 0000000000..45adbe87a4 --- /dev/null +++ b/ShellScript/Zsh/tests/syntax_test_reindent_case.zsh @@ -0,0 +1,192 @@ +# SYNTAX TEST reindent-unchanged "Packages/ShellScript/Zsh.sublime-syntax" + +## +## Bash compatible syntax +## + +case $var in foo) echo yes ;; *) echo no ;; esac + +# --- + +case $var in +foo) + echo yes + ;; +*) + echo no + ;; +esac + +# --- + +case + $var +in +foo) + echo yes + ;; +*) + echo no + ;; +esac + +# --- + +case # comment + $var # comment +in # comment +foo) # comment + echo yes # comment + ;; # comment +*) # comment + echo no # comment + ;; # comment +esac # comment + +# --- + +case $var1 in +1) + case $var2 in + 1) + case $var3 in + 1) + echo 1.1.1 + ;; + *) + echo 1.1.n + ;; + esac + ;; + *) + case $var3 in + 1) + echo 1.n.1 + ;; + *) + echo 1.n.n + ;; + esac + ;; + esac + ;; +*) + case $var2 in + 1) + case $var3 in + 1) + echo n.1.1 + ;; + *) + echo n.1.n + ;; + esac + ;; + *) + case $var3 in + 1) + echo n.n.1 + ;; + *) + echo n.n.n + ;; + esac + ;; + esac + ;; +esac + +## +## ZSH specific syntax +## + +case $var { foo) echo yes ;; *) echo no ;; } + +# --- + +case $var { +foo) + echo yes + ;; +*) + echo no + ;; +} + +# --- + +case $var +{ +foo) + echo yes + ;; +*) + echo no + ;; +} + +# --- + +case + $var +{ +foo) + echo yes + ;; +*) + echo no + ;; +} + +# --- + +case $var1 { +1) + case $var2 { + 1) + case $var3 { + 1) + echo 1.1.1 + ;; + *) + echo 1.1.n + ;; + } + ;; + *) + case $var3 { + 1) + echo 1.n.1 + ;; + *) + echo 1.n.n + ;; + } + ;; + } + ;; +*) + case $var2 { + 1) + case $var3 { + 1) + echo n.1.1 + ;; + *) + echo n.1.n + ;; + } + ;; + *) + case $var3 { + 1) + echo n.n.1 + ;; + *) + echo n.n.n + ;; + } + ;; + } + ;; +} diff --git a/ShellScript/Zsh/tests/syntax_test_reindent_for.zsh b/ShellScript/Zsh/tests/syntax_test_reindent_for.zsh new file mode 100644 index 0000000000..437348343c --- /dev/null +++ b/ShellScript/Zsh/tests/syntax_test_reindent_for.zsh @@ -0,0 +1,219 @@ +# SYNTAX TEST reindent-unchanged "Packages/ShellScript/Zsh.sublime-syntax" + +## +## Bash compatible syntax +## + +for ((i = 0; i < 10; i++)); do echo $i; done; + +# --- + +for ((i = 0; i < 10; i++)); do echo $i; +done; + +# --- + +for ((i = 0; i < 10; i++)); do + echo $i; +done; + +# --- + +for ((i = 0; i < 10; i++)) +do + echo $i; +done; + +# --- + +for + ((i = 0; i < 10; i++)) +do + echo $i; +done; + +# --- + +for (( + i = 0; + i < 10; + i++ +)) +do + echo $i; +done; + +# --- + +for + (( + i = 0; + i < 10; + i++ + )) +do + echo $i; +done; + +# --- + +for ((i = 0; i < 10; i++)); do + for ((k = 0; k < 10; k++)); do + echo \[$i,$k\]; + done; +done; + +# --- + +for var in foo bar baz; do echo $var; done; + +# --- + +for var in foo bar baz; do echo $var; +done; + +# --- + +for var in foo bar baz; do + echo $var; +done; + +# --- + +for var \ +in foo bar baz; do + echo $var; +done; + +# --- + +for var in foo bar baz; +do echo $var; +done; + +# --- + +for var \ +in foo bar baz; +do echo $var; +done; + +# --- + +for var in foo bar baz; +do + echo $var; +done; + +# --- + +for \ + var \ +in \ + foo bar baz; +do + echo $var; +done; + +## +## ZSH specific syntax +## + +for (( i = 0; i < 10; i++ )) { echo $i } + +# --- + +for (( i = 0; i < 10; i++ )) { + echo $i +} + +# --- + +for (( i = 0; i < 10; i++ )) +{ + echo $i +} + +# --- + +for (( + i = 0; + i < 10; + i++ +)) +{ + echo $i +} + +# --- + +for var in (foo bar baz) ; { echo $i } + +# --- + +for var in (foo bar baz) ; { + echo $i +} + +# --- + +for var \ +in (foo bar baz) ; { + echo $i +} + +# --- + +for var in (foo bar baz) +{ + echo $i +} + +# --- + +for var \ +in (foo bar baz) +{ + echo $i +} + +# --- + +for var in ( + foo + bar + baz +) ; { + echo $i +} + +# --- + +for \ + var \ +in ( + foo + bar + baz +) ; { + echo $i +} + +# --- + +for \ + var \ +in ( + foo + bar + baz +) +{ + echo $i +} + +# --- + +for var (foo bar baz) + echo $i +echo done! diff --git a/ShellScript/Zsh/tests/syntax_test_reindent_foreach.zsh b/ShellScript/Zsh/tests/syntax_test_reindent_foreach.zsh new file mode 100644 index 0000000000..ea3605032f --- /dev/null +++ b/ShellScript/Zsh/tests/syntax_test_reindent_foreach.zsh @@ -0,0 +1,84 @@ +# SYNTAX TEST reindent-unchanged "Packages/ShellScript/Zsh.sublime-syntax" + +foreach var in foo bar baz; do echo $var; done; + +# --- + +foreach var in foo bar baz; do echo $var; +done; + +# --- + +foreach var in foo bar baz; do + echo $var; +done; + +# --- + +foreach \ + var in foo bar baz; +do + echo $var; +done; + +# --- + +foreach \ + var \ +in foo bar baz; +do + echo $var; +done; + +# --- + +foreach \ + var \ +in \ + foo bar baz; +do + echo $var; +done; + +# --- + +foreach \ + var \ +in \ + foo \ + bar \ + baz; +do + echo $var; +done; + +# --- + +foreach var (foo bar baz) echo $i; end; + +# --- + +foreach var (foo bar baz) echo $i; +end; + +# --- + +foreach var (foo bar baz) + echo $i; +end; + +# --- + +foreach \ + var \ + (foo bar baz) + echo $i; +end; + +# --- + +foreach var (foo bar baz) + echo $i + echo ... +end; +echo done! diff --git a/ShellScript/Zsh/tests/syntax_test_reindent_if.zsh b/ShellScript/Zsh/tests/syntax_test_reindent_if.zsh new file mode 100644 index 0000000000..1bb90f6918 --- /dev/null +++ b/ShellScript/Zsh/tests/syntax_test_reindent_if.zsh @@ -0,0 +1,199 @@ +# SYNTAX TEST reindent-unchanged "Packages/ShellScript/Zsh.sublime-syntax" + +## +## Bash compatible syntax +## + +if [[ $var == 1 ]]; then echo 1; elif [[ $var == 2 ]]; then echo 2; else echo nothing; fi; + +# --- + +if [[ $var == 1 ]]; then echo 1; elif [[ $var == 2 ]]; then echo 2; else echo nothing; +fi; + +# --- + +if [[ $var == 1 ]]; then echo 1; elif [[ $var == 2 ]]; then echo 2; +else echo nothing; +fi; + +# --- + +if [[ $var == 1 ]]; then echo 1; elif [[ $var == 2 ]]; then + echo 2; +else echo nothing; +fi; + +# --- + +if [[ $var == 1 ]]; then echo 1; +elif [[ $var == 2 ]]; then + echo 2; +else + echo nothing; +fi; + +# --- + +if [[ $var == 1 ]]; then + echo 1; +elif [[ $var == 2 ]]; then + echo 2; +else + echo nothing; +fi; + +# --- + +if [[ $var == 1 ]] +then + echo 1; +elif [[ $var == 2 ]] +then + echo 2; +else + echo nothing; +fi; + +# --- + +if + [[ $var == 1 ]] +then + echo 1; +elif + [[ $var == 2 ]] +then + echo 2; +else + echo nothing; +fi; + +# --- + +if [[ $var1 == 1 ]] +then + if [[ $var2 == 1 ]] + then + if [[ $var3 == 1 ]] + then + echo 1.1.1; + elif [[ $var3 == 2 ]] + then + echo 1.1.2; + else + echo 1.1.n; + fi; + elif [[ $var2 == 2 ]] + then + echo 2.2; + else + echo 2.n; + fi; +elif [[ $var1 == 2 ]] +then + echo 2; +else + echo n; +fi; + +# --- + +if + if + if + [[ $var1 == 1 ]] + then + true + else + false + fi + then + false + elif + [[ $var2 == 1 ]] + then + true + else + false + fi +then + echo success +else + echo failed +fi + +## +## ZSH specific syntax +## + +# note: no semicolon between test-commands and `then` required + +if [[ $var == 1 ]] then echo 1; elif [[ $var == 2 ]] then echo 2; else echo nothing; fi; + +# --- + +if [[ $var == 1 ]] then echo 1; elif [[ $var == 2 ]] then echo 2; else echo nothing; +fi; + +# --- + +if [[ $var == 1 ]] then echo 1; elif [[ $var == 2 ]] then echo 2; +else echo nothing; +fi; + +# --- + +if [[ $var == 1 ]] then echo 1; elif [[ $var == 2 ]] then + echo 2; +else echo nothing; +fi; + +# --- + +if [[ $var == 1 ]] then echo 1; +elif [[ $var == 2 ]] then + echo 2; +else + echo nothing; +fi; + +# --- + +if [[ $var == 1 ]] then + echo 1; +elif [[ $var == 2 ]] then + echo 2; +else + echo nothing; +fi; + +# --- + +if [[ $var == 1 ]] then { echo 1; } elif [[ $var == 2 ]] then { echo 2; } else { echo nothing; } fi + +# --- + +if [[ $var == 1 ]] then + { echo 1; } +elif [[ $var == 2 ]] then + { echo 2; } +else + { echo nothing; } +fi + +# --- + +if [[ $var == 1 ]] then + { + echo 1; + } +elif [[ $var == 2 ]] then + { + echo 2; + } +else + { + echo nothing; + } +fi diff --git a/ShellScript/Zsh/tests/syntax_test_reindent_repeat.zsh b/ShellScript/Zsh/tests/syntax_test_reindent_repeat.zsh new file mode 100644 index 0000000000..712642cfdf --- /dev/null +++ b/ShellScript/Zsh/tests/syntax_test_reindent_repeat.zsh @@ -0,0 +1,121 @@ +# SYNTAX TEST reindent-unchanged "Packages/ShellScript/Zsh.sublime-syntax" + +## +## Bash compatible syntax +## + +repeat var; do echo $var; (( var += 1 )); done; + +# --- + +repeat var; do echo $var; (( var += 1 )); +done; + +# --- + +repeat var; do + echo $var; + (( var += 1 )); +done; + +# --- + +repeat var +do + echo $var; + (( var += 1 )); +done; + +# --- + +repeat + var +do + echo $var; + (( var += 1 )); +done; + +## +## ZSH specific syntax +## + +repeat var; { echo $var; (( var += 1 )); } + +# --- + +repeat var; { echo $var; (( var += 1 )); +} + +# --- + +repeat var; { + echo $var; (( var += 1 )); +} + +# --- + +repeat var; { + echo $var; + (( var += 1 )); +} + +# --- + +repeat var +{ + echo $var; + (( var += 1 )); +} + +# --- + +repeat var; { + # comment + echo $var; (( var += 1 )); +} + +# --- + +repeat var; { + # comment + echo $var; + # comment + (( var += 1 )); +} + +# --- + +repeat var +{ + # comment + echo $var; + # comment + (( var += 1 )); +} + +# --- + +repeat var; { # comment + echo $var; (( var += 1 )); # comment +} # comment + +# --- + +repeat var; { # comment + echo $var; # comment + (( var += 1 )); # comment +} # comment + +# --- + +repeat var # comment +{ # comment + echo $var; # comment + (( var += 1 )); # comment +} # comment + +# --- + +repeat var + echo $(( var += 1 )) +echo done! diff --git a/ShellScript/Zsh/tests/syntax_test_reindent_select.zsh b/ShellScript/Zsh/tests/syntax_test_reindent_select.zsh new file mode 100644 index 0000000000..516ee9ad4e --- /dev/null +++ b/ShellScript/Zsh/tests/syntax_test_reindent_select.zsh @@ -0,0 +1,122 @@ +# SYNTAX TEST reindent-unchanged "Packages/ShellScript/Zsh.sublime-syntax" + +## +## Bash compatible syntax +## + +select var in foo bar baz; do echo $var; done; + +# --- + +select var in foo bar baz; do echo $var; +done; + +# --- + +select var in foo bar baz; do + echo $var; +done; + +# --- + +select var in foo bar baz; +do echo $var; +done; + +# --- + +select var in foo bar baz; +do + echo $var; +done; + +# --- + +select \ + var \ +in \ + foo bar baz; +do + echo $var; +done; + +## +## ZSH specific syntax +## + +select var in (foo bar baz) ; { echo $i } + +# --- + +select var in (foo bar baz) ; { + echo $i +} + +# --- + +select var \ +in (foo bar baz) ; { + echo $i +} + +# --- + +select var in (foo bar baz) +{ + echo $i +} + +# --- + +select var \ +in (foo bar baz) +{ + echo $i +} + +# --- + +select var in ( + foo + bar + baz +) ; { + echo $i +} + +# --- + +select \ + var \ +in ( + foo + bar + baz +) ; { + echo $i +} + +# --- + +select \ + var \ +in ( + foo + bar + baz +) +{ + echo $i +} + +# --- + +select var (foo bar baz) + echo $i +echo done! + +# --- + +select var $list + echo $i +echo done! diff --git a/ShellScript/Zsh/tests/syntax_test_reindent_until.zsh b/ShellScript/Zsh/tests/syntax_test_reindent_until.zsh new file mode 100644 index 0000000000..11ca48d694 --- /dev/null +++ b/ShellScript/Zsh/tests/syntax_test_reindent_until.zsh @@ -0,0 +1,127 @@ +# SYNTAX TEST reindent-unchanged "Packages/ShellScript/Zsh.sublime-syntax" + +## +## Bash compatible syntax +## + +until (( var > 10 )); do echo $var; (( var += 1 )); done; + +# --- + +until (( var > 10 )); do echo $var; (( var += 1 )); +done; + +# --- + +until (( var > 10 )); do + echo $var; + (( var += 1 )); +done; + +# --- + +until (( var > 10 )) +do + echo $var; + (( var += 1 )); +done; + +# --- + +until + (( var > 10 )) +do + echo $var; + (( var += 1 )); +done; + +## +## ZSH specific syntax +## + +until (( var > 10 )); { echo $var; (( var += 1 )); } + +# --- + +until (( var > 10 )); { echo $var; (( var += 1 )); +} + +# --- + +until (( var > 10 )); { + echo $var; (( var += 1 )); +} + +# --- + +until (( var > 10 )); { + echo $var; + (( var += 1 )); +} + +# --- + +until (( var > 10 )) +{ + echo $var; + (( var += 1 )); +} + +# --- + +until (( var > 10 )); { + # comment + echo $var; (( var += 1 )); +} + +# --- + +until (( var > 10 )); { + # comment + echo $var; + # comment + (( var += 1 )); +} + +# --- + +until (( var > 10 )) +{ + # comment + echo $var; + # comment + (( var += 1 )); +} + +# --- + +until (( var > 10 )); { # comment + echo $var; (( var += 1 )); # comment +} # comment + +# --- + +until (( var > 10 )); { # comment + echo $var; # comment + (( var += 1 )); # comment +} # comment + +# --- + +until (( var > 10 )) # comment +{ # comment + echo $var; # comment + (( var += 1 )); # comment +} # comment + +# --- + +until (( var > 10 )) + echo $(( var += 1 )) +echo done! + +# --- + +until finished + echo $(( var += 1 )) +echo done! diff --git a/ShellScript/Zsh/tests/syntax_test_reindent_while.zsh b/ShellScript/Zsh/tests/syntax_test_reindent_while.zsh new file mode 100644 index 0000000000..dcb5aea4be --- /dev/null +++ b/ShellScript/Zsh/tests/syntax_test_reindent_while.zsh @@ -0,0 +1,127 @@ +# SYNTAX TEST reindent-unchanged "Packages/ShellScript/Zsh.sublime-syntax" + +## +## Bash compatible syntax +## + +while (( var < 10 )); do echo $var; (( var += 1 )); done; + +# --- + +while (( var < 10 )); do echo $var; (( var += 1 )); +done; + +# --- + +while (( var < 10 )); do + echo $var; + (( var += 1 )); +done; + +# --- + +while (( var < 10 )) +do + echo $var; + (( var += 1 )); +done; + +# --- + +while + (( var < 10 )) +do + echo $var; + (( var += 1 )); +done; + +## +## ZSH specific syntax +## + +while (( var < 10 )); { echo $var; (( var += 1 )); } + +# --- + +while (( var < 10 )); { echo $var; (( var += 1 )); +} + +# --- + +while (( var < 10 )); { + echo $var; (( var += 1 )); +} + +# --- + +while (( var < 10 )); { + echo $var; + (( var += 1 )); +} + +# --- + +while (( var < 10 )) +{ + echo $var; + (( var += 1 )); +} + +# --- + +while (( var < 10 )); { + # comment + echo $var; (( var += 1 )); +} + +# --- + +while (( var < 10 )); { + # comment + echo $var; + # comment + (( var += 1 )); +} + +# --- + +while (( var < 10 )) +{ + # comment + echo $var; + # comment + (( var += 1 )); +} + +# --- + +while (( var < 10 )); { # comment + echo $var; (( var += 1 )); # comment +} # comment + +# --- + +while (( var < 10 )); { # comment + echo $var; # comment + (( var += 1 )); # comment +} # comment + +# --- + +while (( var < 10 )) # comment +{ # comment + echo $var; # comment + (( var += 1 )); # comment +} # comment + +# --- + +while (( var < 10 )) + echo $(( var += 1 )) +echo done! + +# --- + +while running + echo $(( var += 1 )) +echo done! diff --git a/ShellScript/Zsh/tests/syntax_test_scope.zsh b/ShellScript/Zsh/tests/syntax_test_scope.zsh new file mode 100644 index 0000000000..2f63e8fedc --- /dev/null +++ b/ShellScript/Zsh/tests/syntax_test_scope.zsh @@ -0,0 +1,3531 @@ +# SYNTAX TEST "Packages/ShellScript/Zsh.sublime-syntax" + +############################################################################### +# 6 Shell Grammar # +# https://zsh.sourceforge.io/Doc/Release/Shell-Grammar.html # +############################################################################### + +# 6.1 Simple Commands & Pipelines + +echo foo +# <- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell support.function.shell +# ^^^^ meta.function-call.arguments.shell + +echo foo | sed 's/foo/bar/' +# <- meta.function-call.identifier.shell support.function.shell +#^^^^^^^ meta.function-call +# ^ keyword.operator.assignment.pipe.shell +# ^^^^^^^^^^^^^^^^ meta.function-call +# ^^^ variable.function.shell +# ^^^^^^^^^^^^ meta.string.shell string.quoted.single.shell + +dmesg &| grep panic &! print yes +# <- meta.function-call.identifier.shell variable.function.shell +#^^^^ meta.function-call.identifier.shell variable.function.shell +# ^^ keyword.operator.assignment.pipe.shell +# ^^^^^^^^^^ meta.function-call +# ^^ keyword.operator.assignment.pipe.shell +# ^^^^^^^^^ meta.function-call + +# 6.2 Precommand Modifiers + +builtin cmd -a val +# <- meta.function-call.identifier.shell support.function.shell +#^^^^^^ meta.function-call.identifier.shell support.function.shell +# ^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^^^^^^ meta.function-call.arguments.shell + +exec -cl -a argv0 +# <- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell support.function.shell +# ^^^^^^^^^^^^^ meta.function-call.arguments.shell +# ^^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^^^^ meta.string.shell string.unquoted.shell + +nocorrect cmd +# <- meta.function-call.identifier.shell support.function.shell +#^^^^^^^^ meta.function-call.identifier.shell support.function.shell +# ^^^ meta.function-call.identifier.shell variable.function.shell + +noglob cmd **/file.txt +# <- meta.function-call.identifier.shell support.function.shell +#^^^^^ meta.function-call.identifier.shell support.function.shell +# ^^^ meta.function-call.identifier.shell variable.function.shell +# ^^^^^^^^^^^^ meta.function-call.arguments.shell + +# 6.3 Complex Commands + +if [[ -f ~./foo ]] echo 'yes' elif [[ ]] { echo 'no' } else { echo 'error' } +# <- keyword.control.conditional.if.shell +# ^^^^^^^^^^^^^^^ meta.compound.conditional.shell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call - meta.conditional - meta.compound +# ^^^ - meta.function-call +# ^ invalid.illegal.stray.shell +# ^^^^ keyword.control.conditional.else.shell +# ^^^^^^^^^^^^^^^^ meta.block.shell + +# if list then list [ elif list then list ] ... [ else list ] fi +if [[ -f ~./foo ]] echo 'oh'; echo 'yes'; elif [[ ]] echo 'oh' | echo ' no'; else echo 'error'; fi +# <- keyword.control.conditional.if.shell +# ^^^^^^^^^^^^^^^ meta.compound.conditional.shell +# ^^^^^^^^^ meta.function-call +# ^ punctuation.terminator.statement.shell +# ^^^^^^^^^^ meta.function-call +# ^ punctuation.terminator.statement.shell +# ^^^^ keyword.control.conditional.elseif.shell +# ^^^^^^ meta.compound.conditional.shell +# ^^^^^^^^^ meta.function-call +# ^ keyword.operator.assignment.pipe.shell +# ^^^^^^^^^^ meta.function-call +# ^ punctuation.terminator.statement.shell +# ^^^^ keyword.control.conditional.else.shell +# ^^^^^^^^^^^^ meta.function-call +# ^ punctuation.terminator.statement.shell +# ^^ keyword.control.conditional.endif.shell + +# for name ... [ in word ... ] term do list done +for name in word1 word2; do echo me; done +# <- keyword.control.loop.for.shell +#^^ keyword.control.loop.for.shell +# ^^^^ variable.other.readwrite.shell +# ^^ keyword.operator.iterator.in.shell +# ^^^^^ meta.string.shell string.unquoted.shell +# ^^^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.terminator.statement.shell +# ^^ keyword.control.loop.do.shell +# ^^^^ meta.function-call.identifier.shell support.function.shell +# ^^ meta.function-call.arguments.shell +# ^ punctuation.terminator.statement.shell +# ^^^^ keyword.control.loop.end.shell + +# for (( [expr1] ; [expr2] ; [expr3] )) do list done +for (( i = 1; i < 10; i++ )) do echo $i; done +# <- keyword.control.loop.for.shell +#^^ keyword.control.loop.for.shell +# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.arithmetic.shell +# ^^ punctuation.section.compound.begin.shell +# ^ variable.other.readwrite.shell +# ^ keyword.operator.assignment.shell +# ^ constant.numeric.value.shell +# ^ punctuation.terminator.statement.shell +# ^ variable.other.readwrite.shell +# ^ keyword.operator.comparison.shell +# ^^ constant.numeric.value.shell +# ^ punctuation.terminator.statement.shell +# ^ variable.other.readwrite.shell +# ^^ keyword.operator.arithmetic.shell +# ^^ punctuation.section.compound.end.shell +# ^^ keyword.control.loop.do.shell +# ^^^^ meta.function-call.identifier.shell support.function.shell +# ^^^ meta.function-call.arguments.shell +# ^ punctuation.terminator.statement.shell +# ^^^^ keyword.control.loop.end.shell + +# repeat word do list done +repeat $i+10 do echo .; done +# <- meta.statement.loop.repeat.shell keyword.control.loop.repeat.shell +#^^^^^^^^^^^ meta.statement.loop.repeat.shell +#^^^^^ keyword.control.loop.repeat.shell +# ^^ variable.other.readwrite.shell +# ^ keyword.operator.arithmetic.shell +# ^^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^^ keyword.control.loop.do.shell +# ^^^^^^ meta.function-call +# ^ punctuation.terminator.statement.shell +# ^^^^ keyword.control.loop.end.shell + +# until list do list done +until (( i > 10 )) ; do echo $i; (( i += 1 )); done +# <- keyword.control.loop.until.shell +#^^^^ keyword.control.loop.until.shell +# ^^^^^^^^^^^^ meta.compound.arithmetic.shell +# ^ punctuation.terminator.statement.shell +# ^^ keyword.control.loop.do.shell +# ^^^^^^^ meta.function-call +# ^ punctuation.terminator.statement.shell +# ^^^^^^^^^^^^ meta.compound.arithmetic.shell +# ^ punctuation.terminator.statement.shell +# ^^^^ keyword.control.loop.end.shell + +# while list do list done +while (( i < 10 )) ; do echo $i; (( i += 1 )); done +# <- keyword.control.loop.while.shell +#^^^^ keyword.control.loop.while.shell +# ^^^^^^^^^^^^ meta.compound.arithmetic.shell +# ^ punctuation.terminator.statement.shell +# ^^ keyword.control.loop.do.shell +# ^^^^^^^ meta.function-call +# ^ punctuation.terminator.statement.shell +# ^^^^^^^^^^^^ meta.compound.arithmetic.shell +# ^ punctuation.terminator.statement.shell +# ^^^^ keyword.control.loop.end.shell + +# select name [ in word ... term ] do list done +select name in word1 word2; do echo $name; done +# <- keyword.control.loop.select.shell +#^^^^^ keyword.control.loop.select.shell +# ^^^^ variable.other.readwrite.shell +# ^^ keyword.operator.iterator.in.shell +# ^^^^^ meta.string.shell string.unquoted.shell +# ^^^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.terminator.statement.shell +# ^^ keyword.control.loop.do.shell +# ^^^^^^^^^^ meta.function-call +# ^ punctuation.terminator.statement.shell +# ^^^^ keyword.control.loop.end.shell + +# ( list ) execute list in subshell +(ls .) >1 +# <- meta.compound.command.shell punctuation.section.compound.begin.shell +#^^^^^ meta.compound.command.shell +# ^ punctuation.section.compound.end.shell +# ^ keyword.operator.assignment.redirection.shell +# ^ meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell + +# { list } execute list +{ls .} >1 +# <- meta.block.shell punctuation.section.block.begin.shell +#^^^^^ meta.block.shell +# ^ punctuation.section.block.end.shell +# ^ keyword.operator.assignment.redirection.shell +# ^ meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell + +# { try-list } always { always-list } +{ try-list } always { always-list } +# <- meta.block.shell punctuation.section.block.begin.shell +#^^^^^^^^^^^ meta.block.shell +# ^^^^^^^^ variable.function.shell +# ^ punctuation.section.block.end.shell +# ^^^^^^ keyword.control.exception.always.shell +# ^^^^^^^^^^^^^^^ meta.block.shell +# ^ punctuation.section.block.begin.shell +# ^^^^^^^^^^^ variable.function.shell +# ^ punctuation.section.block.end.shell + +# function [ -T ] word ... [ () ] [ term ] { list } +function func { echo foo; } +# <- meta.function.shell keyword.declaration.function.shell +#^^^^^^^ meta.function.shell keyword.declaration.function.shell +# ^ meta.function.shell - entity +# ^^^^ meta.function.identifier.shell entity.name.function.shell +# ^ meta.function.identifier.shell - entity +# ^^^^^^^^^^^^^ meta.function.body.shell meta.block.shell +# ^ punctuation.section.block.begin.shell +# ^^^^^^^^ meta.function-call +# ^ punctuation.terminator.statement.shell +# ^ punctuation.section.block.end.shell + +function -T func { echo foo; } +# <- meta.function.shell keyword.declaration.function.shell +#^^^^^^^^^^ meta.function.shell +# ^^^^^^ meta.function.identifier.shell +# ^^^^^^^^^^^^^ meta.function.body.shell meta.block.shell +#^^^^^^^ keyword.declaration.function.shell +# ^^ variable.parameter.option.shell +# ^^^^ entity.name.function.shell +# ^ punctuation.section.block.begin.shell +# ^^^^^^^^ meta.function-call +# ^ punctuation.terminator.statement.shell +# ^ punctuation.section.block.end.shell + +function -T func; { echo foo; } +# <- meta.function.shell keyword.declaration.function.shell +#^^^^^^^^^^ meta.function.shell +# ^^^^^ meta.function.identifier.shell +# ^^ meta.function.shell - meta.block +# ^^^^^^^^^^^^^ meta.function.body.shell meta.block.shell +#^^^^^^^ keyword.declaration.function.shell +# ^^ variable.parameter.option.shell +# ^^^^ entity.name.function.shell +# ^ punctuation.terminator.statement.shell +# ^ punctuation.section.block.begin.shell +# ^^^^^^^^ meta.function-call +# ^ punctuation.terminator.statement.shell +# ^ punctuation.section.block.end.shell + +function -T func() { echo foo; } +# <- meta.function.shell keyword.declaration.function.shell +#^^^^^^^^^^ meta.function.shell +# ^^^^^ meta.function.identifier.shell +# ^^ meta.function.parameters.shell +# ^ meta.function.shell - meta.block +# ^^^^^^^^^^^^^ meta.function.body.shell meta.block.shell +#^^^^^^^ keyword.declaration.function.shell +# ^^ variable.parameter.option.shell +# ^^^^ entity.name.function.shell +# ^ punctuation.section.parameters.begin.shell +# ^ punctuation.section.parameters.end.shell +# ^ punctuation.section.block.begin.shell +# ^^^^^^^^ meta.function-call +# ^ punctuation.terminator.statement.shell +# ^ punctuation.section.block.end.shell + +function -T func(); { echo foo; } +# <- meta.function.shell keyword.declaration.function.shell +#^^^^^^^^^^ meta.function.shell +# ^^^^^ meta.function.identifier.shell +# ^^ meta.function.parameters.shell +# ^^ meta.function.shell - meta.block +# ^^^^^^^^^^^^^ meta.function.body.shell meta.block.shell +#^^^^^^^ keyword.declaration.function.shell +# ^^ variable.parameter.option.shell +# ^^^^ entity.name.function.shell +# ^ punctuation.section.parameters.begin.shell +# ^ punctuation.section.parameters.end.shell +# ^ punctuation.terminator.statement.shell +# ^ punctuation.section.block.begin.shell +# ^^^^^^^^ meta.function-call +# ^ punctuation.terminator.statement.shell +# ^ punctuation.section.block.end.shell + +func() { ... } 2>&1 +# <- meta.function.identifier.shell entity.name.function.shell +#^^^ meta.function.identifier.shell entity.name.function.shell +# ^^ meta.function.parameters.shell +# ^ meta.function.shell - meta.block +# ^^^^^^^ meta.function.body.shell meta.block.shell +# ^ punctuation.section.block.begin.shell +# ^^^ meta.function-call.identifier.shell variable.function.shell +# ^ punctuation.section.block.end.shell +# ^^^^^^ - meta.function +# ^ meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell +# ^^ keyword.operator.assignment.redirection.shell +# ^ meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell + +time cmd1 arg | cmd2 -t >1 +# <- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell support.function.shell +# ^ meta.function-call.arguments.shell +# ^^^^ meta.function-call.identifier.shell +# ^^^^ meta.function-call.arguments.shell +# ^^^ - meta.function-call +# ^^^^ meta.function-call.identifier.shell +# ^^^^^^ meta.function-call.arguments.shell +# ^^^^ variable.function.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ keyword.operator.assignment.pipe.shell +# ^^^^ variable.function.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^ keyword.operator.assignment.redirection.shell +# ^ meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell + +# 6.4 Alternate Forms For Complex Commands + +if [[ -f ~./foo ]] { echo 'yes' } elif [[ ]] { echo 'no' } else { echo 'error' } +# <- keyword.control.conditional.if.shell +# ^^^^^^^^^^^^^^^ meta.compound.conditional.shell +# ^^^^^^^^^^^^^^ meta.block.shell +# ^^^^ keyword.control.conditional.elseif.shell +# ^^^^^^ meta.compound.conditional.shell +# ^^^^^^^^^^^^^ meta.block.shell +# ^^^^ keyword.control.conditional.else.shell +# ^^^^^^^^^^^^^^^^ meta.block.shell + +if [[ -f ~./foo ]] then { echo 'yes' } elif [[ ]] then { echo 'no' } else { echo 'error' } +# <- keyword.control.conditional.if.shell +# ^^^^^^^^^^^^^^^ meta.compound.conditional.shell +# ^^^^ keyword.control.conditional.then.shell +# ^^^^^^^^^^^^^^ meta.block.shell +# ^^^^ keyword.control.conditional.elseif.shell +# ^^^^^^ meta.compound.conditional.shell +# ^^^^ keyword.control.conditional.then.shell +# ^^^^^^^^^^^^^ meta.block.shell +# ^^^^ keyword.control.conditional.else.shell +# ^^^^^^^^^^^^^^^^ meta.block.shell + +# for name ... ( word ... ) sublist +for name ( word1 $word2 ) print $name +# <- keyword.control.loop.for.shell +#^^ keyword.control.loop.for.shell +# ^^^^ variable.other.readwrite.shell +# ^^^^^^^^^^^^^^^^ meta.sequence.list.shell +# ^ punctuation.section.sequence.begin.shell +# ^^^^^ meta.string.shell string.unquoted.shell +# ^^^^^^ meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^ punctuation.section.sequence.end.shell +# ^^^^^^^^^^^ meta.function-call +# ^^^^^ support.function.shell +# ^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell + +# for name ... [ in word ... ] term sublist +for name in word1 word2; echo me; +# <- keyword.control.loop.for.shell +#^^ keyword.control.loop.for.shell +# ^^^^ variable.other.readwrite.shell +# ^^ keyword.operator.iterator.in.shell +# ^^^^^ meta.string.shell string.unquoted.shell +# ^^^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.terminator.statement.shell +# ^^^^ meta.function-call.identifier.shell support.function.shell +# ^^ meta.function-call.arguments.shell +# ^ punctuation.terminator.statement.shell + +# for (( [expr1] ; [expr2] ; [expr3] )) sublist +for (( i = 1; i < 10; i++ )) echo $i; +# <- keyword.control.loop.for.shell +#^^ keyword.control.loop.for.shell +# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.arithmetic.shell +# ^^^^^^^ meta.function-call +# ^^ punctuation.section.compound.begin.shell +# ^ variable.other.readwrite.shell +# ^ keyword.operator.assignment.shell +# ^ constant.numeric.value.shell +# ^ punctuation.terminator.statement.shell +# ^ variable.other.readwrite.shell +# ^ keyword.operator.comparison.shell +# ^^ constant.numeric.value.shell +# ^ punctuation.terminator.statement.shell +# ^ variable.other.readwrite.shell +# ^^ keyword.operator.arithmetic.shell +# ^^ punctuation.section.compound.end.shell +# ^^^^ support.function.shell +# ^^ variable.other.readwrite.shell +# ^ punctuation.terminator.statement.shell + +# foreach name ... ( word ... ) list end +foreach name ( word1 word2 ) echo $name; end +# <- meta.statement.loop.foreach.shell.zsh keyword.control.loop.foreach.shell.zsh +#^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.statement.loop.foreach.shell.zsh +#^^^^^^ keyword.control.loop.foreach.shell.zsh +# ^^^^ variable.other.readwrite.shell +# ^^^^^^^^^^^^^^^ meta.sequence.list.shell.zsh +# ^ punctuation.section.sequence.begin.shell.zsh +# ^^^^^ meta.string.shell string.unquoted.shell +# ^^^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.sequence.end.shell.zsh +# ^^^^^^^^^^ meta.function-call +# ^^^^ support.function.shell +# ^^^^^ variable.other.readwrite.shell +# ^ punctuation.terminator.statement.shell +# ^^^ keyword.control.loop.endforeach.shell.zsh + +foreach + name ( word1 word2 ) echo $name; end +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.statement.loop.foreach.shell.zsh +# ^^^^ variable.function.shell + +foreach \ + name ( word1 word2 ) echo $name; end +# ^^^^^^^ meta.statement.loop.foreach.shell.zsh - meta.sequence +# ^^^^^^^^^^^^^^^ meta.statement.loop.foreach.shell.zsh meta.sequence.list.shell.zsh +# ^^^^ variable.other.readwrite.shell +# ^ punctuation.section.sequence.begin.shell.zsh +# ^^^^^ meta.string.shell string.unquoted.shell +# ^^^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.sequence.end.shell.zsh + +foreach \ + name \ + ( word1 word2 ) echo $name; end +# ^^^^^^^^^^^^^^^ meta.statement.loop.foreach.shell.zsh meta.sequence.list.shell.zsh +# ^ punctuation.section.sequence.begin.shell.zsh +# ^^^^^ meta.string.shell string.unquoted.shell +# ^^^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.sequence.end.shell.zsh +# ^^^^^^^^^^ meta.function-call +# ^^^^ support.function.shell +# ^^^^^ variable.other.readwrite.shell +# ^ punctuation.terminator.statement.shell +# ^^^ keyword.control.loop.endforeach.shell.zsh + +foreach \ + name \ + ( +# ^^ meta.statement.loop.foreach.shell.zsh meta.sequence.list.shell.zsh +# ^ punctuation.section.sequence.begin.shell.zsh + word1 +# ^^^^^ meta.string.shell string.unquoted.shell + word2 +# ^^^^^ meta.string.shell string.unquoted.shell + ) echo $name; end +# ^ meta.statement.loop.foreach.shell.zsh meta.sequence.list.shell.zsh punctuation.section.sequence.end.shell.zsh +# ^^^^^^^^^^ meta.function-call +# ^^^^ support.function.shell +# ^^^^^ variable.other.readwrite.shell +# ^ punctuation.terminator.statement.shell +# ^^^ keyword.control.loop.endforeach.shell.zsh + +# repeat word sublist +repeat $i+10 echo .; +# <- meta.statement.loop.repeat.shell.zsh keyword.control.loop.repeat.shell.zsh +#^^^^^^^^^^^ meta.statement.loop.repeat.shell.zsh +#^^^^^ keyword.control.loop.repeat.shell.zsh +# ^^ variable.other.readwrite.shell +# ^ keyword.operator.arithmetic.shell +# ^^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^^^^^^ meta.function-call +# ^ punctuation.terminator.statement.shell + +# until list { list } +until (( i > 10 )) { echo $i; (( i += 1 )); } +# <- keyword.control.loop.until.shell +#^^^^ keyword.control.loop.until.shell +# ^^^^^^^^^^^^ meta.compound.arithmetic.shell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.shell +# ^ punctuation.section.block.begin.shell +# ^^^^^^^ meta.function-call +# ^ punctuation.terminator.statement.shell +# ^^^^^^^^^^^^ meta.compound.arithmetic.shell +# ^ punctuation.terminator.statement.shell +# ^ punctuation.section.block.end.shell + +# while list do list done +while (( i < 10 )) { echo $i; (( i += 1 )); } +# <- keyword.control.loop.while.shell +#^^^^ keyword.control.loop.while.shell +# ^^^^^^^^^^^^ meta.compound.arithmetic.shell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.shell +# ^ punctuation.section.block.begin.shell +# ^^^^^^^ meta.function-call +# ^ punctuation.terminator.statement.shell +# ^^^^^^^^^^^^ meta.compound.arithmetic.shell +# ^ punctuation.terminator.statement.shell +# ^ punctuation.section.block.end.shell + +# select name [ in word ... term ] do list done +select name in word1 word2; do echo $name; done; +# <- keyword.control.loop.select.shell +#^^^^^ keyword.control.loop.select.shell +# ^^^^ variable.other.readwrite.shell +# ^^ keyword.operator.iterator.in.shell +# ^^^^^ meta.string.shell string.unquoted.shell +# ^^^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.terminator.statement.shell +# ^^ keyword.control.loop.do.shell +# ^^^^^^^^^^ meta.function-call +# ^ punctuation.terminator.statement.shell +# ^^^^ keyword.control.loop.end.shell +# ^ punctuation.terminator.statement.shell + +# case word { [ [(] pattern [ | pattern ] ... ) list (;;|;&|;|) ] ... } +case $word { +# <- meta.statement.conditional.case.shell keyword.control.conditional.case.shell +#^^^ meta.statement.conditional.case.shell +# ^^^^^^^ meta.statement.conditional.case.word.shell +# ^^ meta.statement.conditional.case.body.shell meta.block.shell.zsh +#^^^ keyword.control.conditional.case.shell +# ^^^^^ variable.other.readwrite.shell +# ^ punctuation.section.block.begin.shell + pattern | pa*?ern ) +# ^^ meta.statement.conditional.case.body.shell +# ^^^^^^^^^^^^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell meta.string.regexp.shell +# ^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell - meta.string +# ^ keyword.operator.logical.regexp.shell +# ^ constant.other.wildcard.asterisk.shell +# ^ constant.other.wildcard.questionmark.shell +# ^ punctuation.definition.pattern.end.shell + cmd -arg value;; +#^^^^^^^^^^^^^^^^^^^^^ meta.statement.conditional.case.body.shell meta.block.shell.zsh meta.clause.body.shell +# ^^ meta.statement.conditional.case.body.shell meta.block.shell.zsh meta.clause.shell +# ^^^^^^ - meta.function-call +# ^^^ meta.function-call.identifier.shell variable.function.shell +# ^^^^^^^^^^^ meta.function-call.arguments.shell +# ^^ punctuation.terminator.clause.shell +} +# <- meta.statement.conditional.case.body.shell punctuation.section.block.end.shell + +############################################################################### +# 7 Redirection # +# https://zsh.sourceforge.io/Doc/Release/Redirection.html#Redirection # +############################################################################### + +# Open file word for reading as standard input. It is an error to open a file +# in this fashion if it does not exist. +: < word +# ^^^^^^ meta.redirection.shell +# ^ keyword.operator.assignment.redirection.shell + +# Open file word for reading and writing as standard input. If the file does +# not exist then it is created. +: <> word +# ^^^^^^^ meta.redirection.shell +# ^^ keyword.operator.assignment.redirection.shell + +# Open file word for writing as standard output. If the file does not exist +# then it is created. +: > word >| word >! word +# ^^^^^^ meta.redirection.shell +# ^ keyword.operator.assignment.redirection.shell +# ^^^^^^^ meta.redirection.shell +# ^^ keyword.operator.assignment.redirection.shell +# ^^^^^^^ meta.redirection.shell +# ^^ keyword.operator.assignment.redirection.shell + +# Open file word for writing in append mode as standard output. If the file +# does not exist, and the CLOBBER and APPEND_CREATE options are both unset, +# this causes an error; otherwise, the file is created. +: >> word >>| word >>! word +# ^^^^^^^ meta.redirection.shell +# ^^ keyword.operator.assignment.redirection.shell +# ^^^^^^^^ meta.redirection.shell +# ^^^ keyword.operator.assignment.redirection.shell +# ^^^^^^^^ meta.redirection.shell +# ^^^ keyword.operator.assignment.redirection.shell + +# The shell input is read up to a line that is the same as word, or to an +# end-of-file. +: << word +# ^^ keyword.operator.assignment.redirection.shell +# ^^^^^ meta.string.heredoc.shell +# ^^^^ entity.name.tag.heredoc.shell +word +# <- entity.name.tag.heredoc.shell + +# Perform shell expansion on word and pass the result to standard input. +: <<< word +# ^^^ keyword.operator.herestring.shell +# ^^^^ meta.string.shell string.unquoted.shell + +# The standard input/output is duplicated from file descriptor number (see dup2(2)). +: <& 1 >& 1 +# ^^^^ meta.redirection.shell +# ^^ keyword.operator.assignment.redirection.shell +# ^^^^ meta.redirection.shell +# ^^ keyword.operator.assignment.redirection.shell + +# Close the standard input/output. +: <& - >& - +# ^^^^ meta.redirection.shell +# ^^ keyword.operator.assignment.redirection.shell +# ^^^^ meta.redirection.shell +# ^^ keyword.operator.assignment.redirection.shell + +# Redirects both standard output and standard error (file descriptor 2) in the +# manner of ‘>| word’. +: >&| word >&! word &>| word &>! word +# ^^^^^^^^ meta.redirection.shell +# ^^^ keyword.operator.assignment.redirection.shell +# ^^^^^^^^ meta.redirection.shell +# ^^^ keyword.operator.assignment.redirection.shell +# ^^^^^^^^ meta.redirection.shell +# ^^^ keyword.operator.assignment.redirection.shell +# ^^^^^^^^ meta.redirection.shell +# ^^^ keyword.operator.assignment.redirection.shell + +# Redirects both standard output and standard error (file descriptor 2) in the +# manner of ‘>> word’. +: >>& word &>> word +# ^^^^^^^^ meta.redirection.shell +# ^^^ keyword.operator.assignment.redirection.shell +# ^^^^^^^^ meta.redirection.shell +# ^^^ keyword.operator.assignment.redirection.shell + +# Redirects both standard output and standard error (file descriptor 2) in the +# manner of ‘>>| word’. +: >>&| word >>&! word &>>| word &>>! word +# ^^^^^^^^^ meta.redirection.shell +# ^^^^ keyword.operator.assignment.redirection.shell +# ^^^^^^^^^ meta.redirection.shell +# ^^^^ keyword.operator.assignment.redirection.shell +# ^^^^^^^^^ meta.redirection.shell +# ^^^^ keyword.operator.assignment.redirection.shell +# ^^^^^^^^^ meta.redirection.shell +# ^^^^ keyword.operator.assignment.redirection.shell + + +############################################################################### +# 8 Command Execution # +############################################################################### + +cmd +# <- meta.function-call.identifier.shell meta.path.shell variable.function.shell +#^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^ - meta.function + +/path/to/app +# <- meta.function-call.identifier.shell meta.path.shell variable.function.shell punctuation.separator.path.shell +#^^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^ - meta.function + +./.bin/app +# <- meta.function-call.identifier.shell meta.path.shell variable.function.shell constant.other.path.self.shell +#^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +#^ punctuation.separator.path.shell +# ^ - constant +# ^ punctuation.separator.path.shell + +../.bin/app +# <- meta.function-call.identifier.shell meta.path.shell variable.function.shell constant.other.path.parent.shell +#^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +#^ constant.other.path.parent.shell +# ^ punctuation.separator.path.shell +# ^ - constant +# ^ punctuation.separator.path.shell + + +############################################################################### +# 9 Functions # +# https://zsh.sourceforge.io/Doc/Release/Functions.html#Functions # +############################################################################### + +function name () echo "$0 called with $*!" +# <- meta.function.shell keyword.declaration.function.shell +#^^^^^^^^ meta.function.shell +# ^^^^^ meta.function.identifier.shell +# ^^ meta.function.parameters.shell +# ^ meta.function.shell +# ^^^^ meta.function.body.shell meta.function-call.identifier.shell +# ^ meta.function.body.shell meta.function-call.arguments.shell +# ^^^^^^^^^^^^^^^^^^^^ meta.function.body.shell meta.function-call.arguments.shell meta.string.shell +#^^^^^^^ keyword.declaration.function.shell +# ^^^^ entity.name.function.shell +# ^ punctuation.section.parameters.begin.shell +# ^ punctuation.section.parameters.end.shell +# ^^^^ support.function.shell + + +############################################################################### +# 9.1 Autoloading Functions # +# https://zsh.sourceforge.io/Doc/Release/Functions.html#Autoloading-Functions # +############################################################################### + +function -u func; +# <- meta.function.shell keyword.declaration.function.shell +#^^^^^^^^^^ meta.function.shell +# ^^^^^ meta.function.identifier.shell +#^^^^^^^ keyword.declaration.function.shell +# ^^ variable.parameter.option.shell +# ^^^^ entity.name.function.shell + +typeset -fu func; +# <- meta.declaration.variable.shell keyword.declaration.variable.shell +#^^^^^^^^^^^^^^^ meta.declaration.variable.shell +# ^^^ variable.parameter.option.shell +# ^^^^ entity.name.function.shell + +autoload +X +# <- meta.function-call.identifier.shell support.function.shell.zsh +#^^^^^^^ meta.function-call.identifier.shell support.function.shell.zsh +# ^^^ meta.function-call.arguments.shell +# ^^ variable.parameter.option.shell + +fpath=(~/myfuncs $fpath) +autoload myfunc1 myfunc2 +# <- meta.function-call.identifier.shell support.function.shell.zsh +#^^^^^^^ meta.function-call.identifier.shell support.function.shell.zsh +# ^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell +# ^^^^^^^ variable.function.shell +# ^^^^^^^ variable.function.shell + + +############################################################################### +# 9.2 Anonymous Functions # +# https://zsh.sourceforge.io/Doc/Release/Functions.html#Anonymous-Functions # +############################################################################### + + () +#^^ - meta.function-call - meta.function +# ^^ meta.function-call.shell meta.function.anonymous.parameters.shell +# ^ meta.function-call.shell meta.function.anonymous.shell + + () + {} +# ^^^ meta.function-call.shell +# ^ meta.function.anonymous.shell - meta.block +# ^^ meta.function.anonymous.body.shell meta.block.shell +# ^ - meta.function +# ^ punctuation.section.block.begin.shell +# ^ punctuation.section.block.end.shell + + () \ + {} +# ^^^ meta.function-call.shell +# ^ meta.function.anonymous.shell - meta.block +# ^^ meta.function.anonymous.body.shell meta.block.shell +# ^ - meta.function +# ^ punctuation.section.block.begin.shell +# ^ punctuation.section.block.end.shell + + () ; { +# ^^^^^^^ meta.function-call.shell +# ^^ meta.function.anonymous.parameters.shell +# ^^^ meta.function.anonymous.shell +# ^^ meta.function.anonymous.body.shell meta.block.shell +# ^ punctuation.section.parameters.begin.shell +# ^ punctuation.section.parameters.end.shell +# ^ punctuation.terminator.statement.shell +# ^ punctuation.section.block.begin.shell + local variable=inside +# ^^^^^^^^^^^^^^^^^^^^^ meta.function-call.shell meta.function.anonymous.body.shell meta.block.shell meta.declaration.variable.shell + print "I am $variable with arguments $*" +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.shell meta.function.anonymous.body.shell meta.block.shell +} this and that +# <- meta.function-call.shell meta.function.anonymous.body.shell meta.block.shell punctuation.section.block.end.shell +#^^^^^^^^^^^^^^ meta.function-call.arguments.shell +# ^^^^ meta.string.shell string.unquoted.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^^^^ meta.string.shell string.unquoted.shell + +function {} arg +# <- meta.function-call.shell meta.function.anonymous.shell keyword.declaration.function.shell +#^^^^^^^^^^ meta.function-call.shell +#^^^^^^^^ meta.function.anonymous.shell +# ^^ meta.function.anonymous.body.shell meta.block.shell +# ^^^^ meta.function-call.arguments.shell +#^^^^^^^ keyword.declaration.function.shell +# ^ punctuation.section.block.begin.shell +# ^ punctuation.section.block.end.shell +# ^^^ meta.string.shell string.unquoted.shell + +function -U {} arg +# <- meta.function-call.shell meta.function.anonymous.shell keyword.declaration.function.shell +#^^^^^^^^^^^^^ meta.function-call.shell +#^^^^^^^^^^^ meta.function.anonymous.shell +# ^^ meta.function.anonymous.body.shell meta.block.shell +# ^^^^ meta.function-call.arguments.shell +#^^^^^^^ keyword.declaration.function.shell +# ^^ invalid.illegal.parameter.shell +# ^ punctuation.section.block.begin.shell +# ^ punctuation.section.block.end.shell +# ^^^ meta.string.shell string.unquoted.shell + +function ; {} arg +# <- meta.function-call.shell meta.function.anonymous.shell keyword.declaration.function.shell +#^^^^^^^^^^^^ meta.function-call.shell +#^^^^^^^^^^ meta.function.anonymous.shell +# ^^ meta.function.anonymous.body.shell meta.block.shell +# ^^^^ meta.function-call.arguments.shell +#^^^^^^^ keyword.declaration.function.shell +# ^ punctuation.terminator.statement.shell +# ^ punctuation.section.block.begin.shell +# ^ punctuation.section.block.end.shell +# ^^^ meta.string.shell string.unquoted.shell + +function () {} arg +# <- meta.function-call.shell meta.function.anonymous.shell keyword.declaration.function.shell +#^^^^^^^^^^^^^ meta.function-call.shell +#^^^^^^^^ meta.function.anonymous.shell +# ^^ meta.function.anonymous.parameters.shell +# ^ meta.function.anonymous.shell +# ^^ meta.function.anonymous.body.shell meta.block.shell +# ^^^^ meta.function-call.arguments.shell +#^^^^^^^ keyword.declaration.function.shell +# ^ punctuation.section.parameters.begin.shell +# ^ punctuation.section.parameters.end.shell +# ^ punctuation.section.block.begin.shell +# ^ punctuation.section.block.end.shell +# ^^^ meta.string.shell string.unquoted.shell + +function () ; {} arg +# <- meta.function-call.shell meta.function.anonymous.shell keyword.declaration.function.shell +#^^^^^^^^^^^^^^^ meta.function-call.shell +#^^^^^^^^ meta.function.anonymous.shell +# ^^ meta.function.anonymous.parameters.shell +# ^^^ meta.function.anonymous.shell +# ^^ meta.function.anonymous.body.shell meta.block.shell +# ^^^^ meta.function-call.arguments.shell +#^^^^^^^ keyword.declaration.function.shell +# ^ punctuation.section.parameters.begin.shell +# ^ punctuation.section.parameters.end.shell +# ^ punctuation.terminator.statement.shell +# ^ punctuation.section.block.begin.shell +# ^ punctuation.section.block.end.shell +# ^^^ meta.string.shell string.unquoted.shell + +function { +# <- meta.function-call.shell meta.function.anonymous.shell keyword.declaration.function.shell +#^^^^^^^^ meta.function-call.shell meta.function.anonymous.shell - meta.block +# ^^ meta.function-call.shell meta.function.anonymous.body.shell meta.block.shell +#^^^^^^^ keyword.declaration.function.shell +# ^ punctuation.section.block.begin.shell + local variable=inside +# ^^^^^^^^^^^^^^^^^^^^^ meta.function-call.shell meta.function.anonymous.body.shell meta.block.shell meta.declaration.variable.shell + print "I am $variable with arguments $*" +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.shell meta.function.anonymous.body.shell meta.block.shell meta.function-call +} this and that +# <- meta.function-call.shell meta.function.anonymous.body.shell meta.block.shell punctuation.section.block.end.shell +#^^^^^^^^^^^^^^ meta.function-call.arguments.shell +# ^^^^ meta.string.shell string.unquoted.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^^^^ meta.string.shell string.unquoted.shell + + +############################################################################### +# 9.3 Special Functions # +# https://zsh.sourceforge.io/Doc/Release/Functions.html#Special-Functions # +############################################################################### + +# 9.3.1 Hook Functions + + chpwd() {} +# ^^^^^ meta.function.identifier.shell entity.name.function.shell support.function.shell.zsh +# ^^ meta.function.parameters.shell +# ^ meta.function.shell +# ^^ meta.function.body.shell meta.block.shell + + periodic() {} +# ^^^^^^^^ meta.function.identifier.shell entity.name.function.shell support.function.shell.zsh +# ^^ meta.function.parameters.shell +# ^ meta.function.shell +# ^^ meta.function.body.shell meta.block.shell + + precmd() {} +# ^^^^^^ meta.function.identifier.shell entity.name.function.shell support.function.shell.zsh +# ^^ meta.function.parameters.shell +# ^ meta.function.shell +# ^^ meta.function.body.shell meta.block.shell + + preexec() {} +# ^^^^^^^ meta.function.identifier.shell entity.name.function.shell support.function.shell.zsh +# ^^ meta.function.parameters.shell +# ^ meta.function.shell +# ^^ meta.function.body.shell meta.block.shell + + zshaddhistory() {} +# ^^^^^^^^^^^^^ meta.function.identifier.shell entity.name.function.shell support.function.shell.zsh +# ^^ meta.function.parameters.shell +# ^ meta.function.shell +# ^^ meta.function.body.shell meta.block.shell + + zshexit() {} +# ^^^^^^^ meta.function.identifier.shell entity.name.function.shell support.function.shell.zsh +# ^^ meta.function.parameters.shell +# ^ meta.function.shell +# ^^ meta.function.body.shell meta.block.shell + +# 9.3.2 Trap Functions + + TRAPDEBUG() {} # ZSH specific trap +# ^^^^^^^^^ meta.function.identifier.shell entity.name.function.shell support.function.shell.zsh +# ^^ meta.function.parameters.shell +# ^ meta.function.shell +# ^^ meta.function.body.shell meta.block.shell + + TRAPEXIT() {} # ZSH specific trap +# ^^^^^^^^ meta.function.identifier.shell entity.name.function.shell support.function.shell.zsh +# ^^ meta.function.parameters.shell +# ^ meta.function.shell +# ^^ meta.function.body.shell meta.block.shell + + TRAPINT() {} # called if SIGINT is received +# ^^^^^^^ meta.function.identifier.shell entity.name.function.shell support.function.shell.zsh +# ^^ meta.function.parameters.shell +# ^ meta.function.shell +# ^^ meta.function.body.shell meta.block.shell + + TRAPTERM() {} # called if SIGTERM is received +# ^^^^^^^^ meta.function.identifier.shell entity.name.function.shell support.function.shell.zsh +# ^^ meta.function.parameters.shell +# ^ meta.function.shell +# ^^ meta.function.body.shell meta.block.shell + + TRAPRTMAX-1() {} # called if SIGRTMAX-1 is received +# ^^^^^^^^^^^ meta.function.identifier.shell entity.name.function.shell support.function.shell.zsh +# ^^ meta.function.parameters.shell +# ^ meta.function.shell +# ^^ meta.function.body.shell meta.block.shell + + TRAPRTMIN+1() {} # called if SIGRTMIN+1 is received +# ^^^^^^^^^^^ meta.function.identifier.shell entity.name.function.shell support.function.shell.zsh +# ^^ meta.function.parameters.shell +# ^ meta.function.shell +# ^^ meta.function.body.shell meta.block.shell + + +############################################################################### +# 11 Arithmetic Evaluation # +# https://zsh.sourceforge.io/Doc/Release/Arithmetic-Evaluation.html # +############################################################################### + + let val = 1 + 2 +# ^^^ meta.function-call.identifier.shell +# ^^^^^^^^^^^^ meta.function-call.arguments.shell meta.arithmetic.shell +# ^^^ support.function.shell +# ^^^ variable.other.readwrite.shell +# ^ keyword.operator.assignment.shell +# ^ constant.numeric.value.shell +# ^ keyword.operator.arithmetic.shell +# ^ constant.numeric.value.shell + + let 'val = 1 + 2' +# ^^^ meta.function-call.identifier.shell +# ^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.arithmetic.shell +# ^^^ support.function.shell +# ^ punctuation.definition.quoted.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ keyword.operator.assignment.shell +# ^ constant.numeric.value.shell +# ^ keyword.operator.arithmetic.shell +# ^ constant.numeric.value.shell +# ^ punctuation.definition.quoted.end.shell + + let "val = 1 + 2" +# ^^^ meta.function-call.identifier.shell +# ^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.arithmetic.shell +# ^^^ support.function.shell +# ^ punctuation.definition.quoted.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ keyword.operator.assignment.shell +# ^ constant.numeric.value.shell +# ^ keyword.operator.arithmetic.shell +# ^ constant.numeric.value.shell +# ^ punctuation.definition.quoted.end.shell + + (( val = 1. + 1.23 + 1.23e-10 )) # floating point numbers +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.arithmetic.shell +# ^^ punctuation.section.compound.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ keyword.operator.assignment.shell +# ^^ meta.number.float.decimal.shell.zsh constant.numeric.value.shell.zsh +# ^ keyword.operator.arithmetic.shell +# ^^^^ meta.number.float.decimal.shell.zsh constant.numeric.value.shell.zsh +# ^ keyword.operator.arithmetic.shell +# ^^^^^^^^ meta.number.float.decimal.shell.zsh constant.numeric.value.shell.zsh +# ^^ punctuation.section.compound.end.shell + + (( 123_24_32_ + _42234 )) +# ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.arithmetic.shell +# ^^^^^^^^^^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ keyword.operator.arithmetic.shell +# ^^^^^^ meta.variable.shell variable.other.readwrite.shell + + (( 3_162.277_660_168_379_5 )) # numbers can contain underscores +# ^^^^^^^^^^^^^^^^^^^^^^^ meta.number.float.decimal.shell.zsh constant.numeric.value.shell.zsh + + (( 2_4#234_2abd27 )) +# ^^^^ meta.number.integer.other.shell constant.numeric.base.shell +# ^^^^^^^^^^ meta.number.integer.other.shell constant.numeric.value.shell + + (( abs(1 - 5) + 3 )) # arithmetic function calls +# ^^^^^^^^^^^^^^^^^^^^ meta.compound.arithmetic.shell +# ^^^ meta.function-call.identifier.shell.zsh +# ^^^^^^^ meta.function-call.arguments.shell.zsh +# ^^ punctuation.section.compound.begin.shell +# ^^^ variable.function.shell.zsh +# ^ punctuation.section.arguments.begin.shell.zsh +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ keyword.operator.arithmetic.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.section.arguments.end.shell.zsh +# ^ keyword.operator.arithmetic.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^^ punctuation.section.compound.end.shell + + (( [#16_4] 65536 ** 2 )) +# ^^ meta.compound.arithmetic.shell punctuation.section.compound.begin.shell - meta.arithmetic +# ^ meta.compound.arithmetic.shell meta.arithmetic.shell - meta.modifier +# ^^^^^^^ meta.compound.arithmetic.shell meta.arithmetic.shell meta.modifier.base.shell.zsh +# ^^^^^^^^^^^^ meta.compound.arithmetic.shell meta.arithmetic.shell - meta.modifier +# ^^ meta.compound.arithmetic.shell punctuation.section.compound.end.shell - meta.arithmetic +# ^^ punctuation.definition.modifier.begin.shell.zsh +# ^^^^ storage.modifier.mode.base.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^^^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^^ keyword.operator.arithmetic.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell + + (( [#$base] 65536 ** 2 )) +# ^^ meta.compound.arithmetic.shell punctuation.section.compound.begin.shell - meta.arithmetic +# ^ meta.compound.arithmetic.shell meta.arithmetic.shell - meta.modifier +# ^^^^^^^^ meta.compound.arithmetic.shell meta.arithmetic.shell meta.modifier.base.shell.zsh +# ^^^^^^^^^^^^ meta.compound.arithmetic.shell meta.arithmetic.shell - meta.modifier +# ^^ meta.compound.arithmetic.shell punctuation.section.compound.end.shell - meta.arithmetic +# ^^ punctuation.definition.modifier.begin.shell.zsh +# ^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^^^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^^ keyword.operator.arithmetic.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell + +: $(( val = 1 + 2 )) # aritmetic expansions +# ^^^^^^^^^^^^^^^^^^ meta.string.shell meta.interpolation.arithmetic.shell +# ^ punctuation.definition.variable.shell +# ^^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ keyword.operator.assignment.shell +# ^ constant.numeric.value.shell +# ^ keyword.operator.arithmetic.shell +# ^ constant.numeric.value.shell +# ^^ punctuation.section.interpolation.end.shell + +: ${val:start + 3:len % 5} # aritmetic evaluation in substitutions +# ^^^^^^ meta.string.shell meta.interpolation.parameter.shell - meta.arithmetic +# ^^^^^^^^^ meta.string.shell meta.interpolation.parameter.shell meta.arithmetic.shell +# ^ meta.string.shell meta.interpolation.parameter.shell - meta.arithmetic +# ^^^^^^^ meta.string.shell meta.interpolation.parameter.shell meta.arithmetic.shell +# ^ meta.string.shell meta.interpolation.parameter.shell - meta.arithmetic + + +############################################################################### +# 14.3 Parameter Expansion # +# https://zsh.sourceforge.io/Doc/Release/Expansion.html#Parameter-Expansion # +############################################################################### + +: ${var} # Substitute contents of var, no splitting +# ^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${#var} # Length of var in words (array) or bytes +# ^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.length.shell +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${+var} # 1 if var is set, else 0 (ZSH only) +# ^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.valid.shell +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${=var} # Split words of result like lesser shells (ZSH only) +# ^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.split.shell +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${==var} # Turn off splitting words of result like lesser shells (ZSH only) +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^ keyword.operator.expansion.split.shell +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${^var} # Expand elements like brace expansion (ZSH only) +# ^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.brace.shell +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${^^var} # Turn off expanding elements like brace expansion (ZSH only) +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^ keyword.operator.expansion.brace.shell +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${~var} # Allow globbing, file expansion on result (ZSH only) +# ^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.glob.shell +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${~~var} # Disallow globbing, file expansion on result (ZSH only) +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^ keyword.operator.expansion.glob.shell +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +## Flags + +: ${(#)var} # Evaluate the resulting words as numeric expressions and interpret these as character codes. +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(%)var} # Expand all % escapes in the resulting words in the same way as in prompts +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(@)var} # In double quotes, array elements are put into separate words. +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(A)var} # Convert the substitution into an array expression, even if it otherwise would be scalar. +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(a)var} # Sort in array index order; when combined with ‘O’ sort in reverse array index order. +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(b)var} # Quote with backslashes only characters that are special to pattern matching +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(c)var} # With ${#name}, count the total number of characters in an array +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(C)var} # Capitalize the resulting words. +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(D)var} # Assume the string or array elements contain directories and attempt to substitute the leading part of these by names. +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(e)var} # Perform single word shell expansions, namely parameter expansion, command substitution and arithmetic expansion, on the result. +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(f)var} # Split the result of the expansion at newlines. +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(F)var} # Join the words of arrays together using newline as a separator +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(i)var} # Sort case-insensitively. May be combined with ‘n’ or ‘O’. +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(k)var} # If name refers to an associative array, substitute the keys (element names) rather than the values of the elements. +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(L)var} # Convert all letters in the result to lower case. +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(n)var} # Sort decimal integers numerically +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(-)var} # As n, but a leading minus sign indicates a negative decimal integer. +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(o)var} # Sort the resulting words in ascending order +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(O)var} # Sort the resulting words in descending order +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(p)var} # This forces the value of the parameter name to be interpreted as a further parameter name +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(q)var} # Quote characters that are special to the shell in the resulting words with backslashes +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(Q)var} # Remove one level of quotes from the resulting words. +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(t)var} # Use a string describing the type of the parameter where the value of the parameter would usually appear. +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(u)var} # Expand only the first occurrence of each unique word. +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(U)var} # Convert all letters in the result to upper case. +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(v)var} # Used with k, substitute (as two consecutive words) both the key and the value of each associative array element. +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(V)var} # Make any special characters in the resulting words visible. +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(w)var} # With ${#name}, count words in arrays or strings; the s flag may be used to set a word delimiter. +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(W)var} # Similar to w with the difference that empty words between repeated delimiters are also counted. +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(X)var} # With this flag, parsing errors occurring with the Q, e and # flags or the pattern matching forms such as ‘${name#pattern}’ are reported. +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(z)var} # Split the result of the expansion into words using shell parsing to find the words +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(0)var} # Split the result of the expansion on null bytes. This is a shorthand for ‘ps:\0:’. +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(~)var} # +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(j<:>)var} ${(j{:})var} ${(j[:])var} ${(j(:))var} ${(j.:.)var} # Join the words of arrays together using string as a separator. +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.section.argument.begin.shell.zsh +# ^ string.unquoted.shell.zsh +# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta.interpolation +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.section.argument.begin.shell.zsh +# ^ string.unquoted.shell.zsh +# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta.interpolation +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.section.argument.begin.shell.zsh +# ^ string.unquoted.shell.zsh +# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta.interpolation +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.section.argument.begin.shell.zsh +# ^ string.unquoted.shell.zsh +# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta.interpolation +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.section.argument.begin.shell.zsh +# ^ string.unquoted.shell.zsh +# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta.interpolation + +: ${(l:expr::string1::string2:)var} +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifer +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.section.argument.begin.shell.zsh +# ^^^^ variable.other.readwrite.shell +# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.section.argument.begin.shell.zsh +# ^^^^^^^ meta.string.shell.zsh string.unquoted.shell.zsh +# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.section.argument.begin.shell.zsh +# ^^^^^^^meta.string.shell.zsh string.unquoted.shell.zsh +# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(m)var} # Only useful together with one of the flags l or r or with the # length operator +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(r:expr:)var} ${(r)var} +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifer +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.section.argument.begin.shell.zsh +# ^^^^ variable.other.readwrite.shell +# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifer +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.section.argument.begin.shell.zsh +# ^^^^ variable.other.readwrite.shell +# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(r:expr::string1:)var} +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifer +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.section.argument.begin.shell.zsh +# ^^^^ variable.other.readwrite.shell +# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.section.argument.begin.shell.zsh +# ^^^^^^^ meta.string.shell.zsh string.unquoted.shell.zsh +# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(r:expr::string1::string2:)var} +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifer +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.section.argument.begin.shell.zsh +# ^^^^ variable.other.readwrite.shell +# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.section.argument.begin.shell.zsh +# ^^^^^^^ meta.string.shell.zsh string.unquoted.shell.zsh +# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.section.argument.begin.shell.zsh +# ^^^^^^^meta.string.shell.zsh string.unquoted.shell.zsh +# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(s.:.)var} ${(s:del$im:)var} # Force field splitting at the separator string. +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.section.argument.begin.shell.zsh +# ^ string.unquoted.shell.zsh +# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta.interpolation +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^^^^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.section.argument.begin.shell.zsh +# ^^^ string.unquoted.shell.zsh - variable +# ^^^ variable.other.readwrite.shell - string +# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta.interpolation + +: ${(Z+c+)var} ${(Z+C+)var} ${(Z+n+)var} ${(Z+Cn+)var} ${(Z+$opt+)var} # As z but takes a combination of option letters between a following pair of delimiter characters. +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.section.argument.begin.shell.zsh +# ^ meta.string.shell.zsh string.unquoted.shell.zsh +# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.section.argument.begin.shell.zsh +# ^ meta.string.shell.zsh string.unquoted.shell.zsh +# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.section.argument.begin.shell.zsh +# ^ meta.string.shell.zsh string.unquoted.shell.zsh +# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.section.argument.begin.shell.zsh +# ^^ meta.string.shell.zsh string.unquoted.shell.zsh +# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh - meta.interpolation meta.interpolation +# ^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh meta.interpolation.parameter.shell +# ^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh - meta.interpolation meta.interpolation +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.section.argument.begin.shell.zsh +# ^^^^ meta.string.shell.zsh meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(_:expr:)var} # The underscore (_) flag is reserved for future use. +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.reserved.shell.zsh +# ^ punctuation.section.argument.begin.shell.zsh +# ^^^^ invalid.illegal.unsupported.shell.zsh +# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(S)var} # Search for the match that starts closest to the start of the string +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(I:expr:)var} # Search the `expr`th match (where `expr`` evaluates to a number). +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh - meta.arithmetic +# ^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh meta.arithmetic.shell meta.variable.shell +# ^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh - meta.arithmetic +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.section.argument.begin.shell.zsh +# ^^^^ variable.other.readwrite.shell +# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(*)var} # Enable EXTENDED_GLOB for substitution via ${.../...} or ${...//...}. +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(B)var} # Include the index of the beginning of the match in the result. +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(E)var} # Include the index one character past the end of the match in the result (note this is inconsistent with other uses of parameter index). +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(M)var} # Include the matched portion in the result. +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(N)var} # Include the length of the match in the result. +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(R)var} # Include the unmatched portion in the result (the Rest). +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: ${(#)#var} # Flags can be combined with leading operators +# ^^ meta.interpolation.parameter.shell - meta.modifier +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^ keyword.operator.expansion.length.shell +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +## Operators + +: ${var:-str} # $var if non-null, else str +# ^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^^ keyword.operator.assignment.shell +# ^^^ string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${var-str} # $var if set (even if null) else str +# ^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ keyword.operator.assignment.shell +# ^^^ string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${var:=str} # $var if non-null, else str and set var to it +# ^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^^ keyword.operator.assignment.shell +# ^^^ string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${var::=str} # Same but always use str +# ^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^^^ keyword.operator.assignment.shell +# ^^^ string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${var:?str} # $var if non-null else error, abort +# ^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^^ keyword.operator.assignment.shell +# ^^^ string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + + +: ${var:+str} # str if $var is non-null +# ^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^^ keyword.operator.assignment.shell +# ^^^ string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${var#pat} # min match of pat removed from head +# ^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ keyword.operator.expansion.shell +# ^^^ meta.string.regexp.shell +# ^ punctuation.section.interpolation.end.shell + +: ${var##pat} # max match of pat removed from head +# ^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^^ keyword.operator.expansion.shell +# ^^^ meta.string.regexp.shell +# ^ punctuation.section.interpolation.end.shell + +: ${var%pat} # min match of pat removed from tail +# ^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ keyword.operator.expansion.shell +# ^^^ meta.string.regexp.shell +# ^ punctuation.section.interpolation.end.shell + +: ${var%%pat} # max match of pat removed from tail +# ^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^^ keyword.operator.expansion.shell +# ^^^ meta.string.regexp.shell +# ^ punctuation.section.interpolation.end.shell + +: ${var:#pat} # $var unless pat matches, then empty +# ^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^^ keyword.operator.assignment.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${var/p/r} # One occurrence of p replaced by r +# ^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ keyword.operator.substitution.shell +# ^ meta.string.regexp.shell string.unquoted.shell +# ^ keyword.operator.substitution.shell +# ^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${var//p/r} # All occurrences of p replaced by r +# ^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^^ keyword.operator.substitution.shell +# ^ meta.string.regexp.shell string.unquoted.shell +# ^ keyword.operator.substitution.shell +# ^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${${var%p}#q} # Apply %p then #q to $var +# ^^ meta.interpolation.parameter.shell +# ^^^^^^^^ meta.interpolation.parameter.shell meta.interpolation.parameter.shell +# ^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ keyword.operator.expansion.shell +# ^ meta.string.regexp.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell +# ^ keyword.operator.expansion.shell +# ^ meta.string.regexp.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell + +: ${^foo//:/[}] +# ^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.brace.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^ - punctuation +# ^ punctuation.section.interpolation.end.shell + +: ${^foo//:/[\}]} +# ^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ keyword.operator.expansion.brace.shell.zsh +# ^^^ variable.other.readwrite.shell +# ^^^^ meta.string.shell string.unquoted.shell +# ^^ constant.character.escape.shell +# ^ punctuation.section.interpolation.end.shell + +############################################################################### +# 14.5 Arithmetic Expansion +# https://zsh.sourceforge.io/Doc/Release/Expansion.html#Arithmetic-Expansion +############################################################################### + +# Bash Style +: $(( a = b + (2 % c) )) +# ^^^^^^^^^^^^ meta.string.shell meta.interpolation.arithmetic.shell - meta.group +# ^^^^^^^ meta.string.shell meta.interpolation.arithmetic.shell meta.group.shell +# ^^^ meta.string.shell meta.interpolation.arithmetic.shell - meta.group +# ^ - meta.string - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^^ punctuation.section.interpolation.begin.shell +# ^ variable.other.readwrite.shell +# ^ keyword.operator.assignment.shell +# ^ variable.other.readwrite.shell +# ^ keyword.operator.arithmetic.shell +# ^ punctuation.section.group.begin.shell +# ^ constant.numeric.value.shell +# ^ keyword.operator.arithmetic.shell +# ^ variable.other.readwrite.shell +# ^ punctuation.section.group.end.shell +# ^^ punctuation.section.interpolation.end.shell + +: $(( # foo )) +# ^^^^^^^^^^^^ meta.interpolation.arithmetic.shell +# ^ punctuation.definition.variable.shell +# ^^ punctuation.section.interpolation.begin.shell +# ^ invalid.illegal.unexpected-token.shell +# ^^^ variable.other.readwrite.shell +# ^^ punctuation.section.interpolation.end.shell + +: $(( #foo )) +# ^^^^^^^^^^^ meta.interpolation.arithmetic.shell +# ^ punctuation.definition.variable.shell +# ^^ punctuation.section.interpolation.begin.shell +# ^ invalid.illegal.unexpected-token.shell +# ^^^ variable.other.readwrite.shell +# ^^ punctuation.section.interpolation.end.shell + +# Zsh Style +: $[ a = b + (2 % c) ] +# ^^^^^^^^^^^ meta.string.shell meta.interpolation.arithmetic.shell - meta.group +# ^^^^^^^ meta.string.shell meta.interpolation.arithmetic.shell meta.group.shell +# ^^ meta.string.shell meta.interpolation.arithmetic.shell - meta.group +# ^ - meta.string - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.other.readwrite.shell +# ^ keyword.operator.assignment.shell +# ^ variable.other.readwrite.shell +# ^ keyword.operator.arithmetic.shell +# ^ punctuation.section.group.begin.shell +# ^ constant.numeric.value.shell +# ^ keyword.operator.arithmetic.shell +# ^ variable.other.readwrite.shell +# ^ punctuation.section.group.end.shell +# ^ punctuation.section.interpolation.end.shell + +: $[ # foo ] +# ^^^^^^^^^^ meta.interpolation.arithmetic.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ invalid.illegal.unexpected-token.shell +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + +: $[ #foo ] +# ^^^^^^^^^ meta.interpolation.arithmetic.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ invalid.illegal.unexpected-token.shell +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell + + +############################################################################### +# 14.6 Brace Expansion +# https://zsh.sourceforge.io/Doc/Release/Expansion.html#Brace-Expansion +############################################################################### + +: prefix{a,b,c}suffix +# ^^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation +# ^ meta.string.shell meta.interpolation.brace.shell punctuation.section.interpolation.begin.shell +# ^ meta.string.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell +# ^ meta.string.shell meta.interpolation.brace.shell punctuation.separator.sequence.shell +# ^ meta.string.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell +# ^ meta.string.shell meta.interpolation.brace.shell punctuation.separator.sequence.shell +# ^ meta.string.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell +# ^ meta.string.shell meta.interpolation.brace.shell punctuation.section.interpolation.end.shell +# ^^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation + +: {a,b,~,%,!,.,\,,\{,\},*,?,-1,+2,0," ",' '} +#^ - meta.interpolation +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell meta.interpolation.brace.shell - meta.interpolation.brace meta.interpolation.brace +# ^ punctuation.section.interpolation.begin.shell +# ^ meta.string.shell string.unquoted.shell +# ^ punctuation.separator.sequence.shell +# ^ meta.string.shell string.unquoted.shell +# ^ punctuation.separator.sequence.shell +# ^ keyword.operator.logical.regexp.shell +# ^ punctuation.separator.sequence.shell +# ^ meta.string.shell string.unquoted.shell - keyword - punctuation - variable +# ^ punctuation.separator.sequence.shell +# ^ meta.string.shell string.unquoted.shell - keyword - punctuation - variable +# ^ punctuation.separator.sequence.shell +# ^ meta.string.shell string.unquoted.shell - keyword - punctuation - variable +# ^ punctuation.separator.sequence.shell +# ^^ meta.string.shell string.unquoted.shell constant.character.escape.shell +# ^ punctuation.separator.sequence.shell +# ^^ meta.string.shell string.unquoted.shell constant.character.escape.shell +# ^ punctuation.separator.sequence.shell +# ^^ meta.string.shell string.unquoted.shell constant.character.escape.shell +# ^ punctuation.separator.sequence.shell +# ^ meta.string.shell string.unquoted.shell constant.other.wildcard.asterisk.shell +# ^ punctuation.separator.sequence.shell +# ^ meta.string.shell string.unquoted.shell constant.other.wildcard.questionmark.shell +# ^ punctuation.separator.sequence.shell +# ^^ meta.string.shell string.unquoted.shell +# ^ punctuation.separator.sequence.shell +# ^^ meta.string.shell string.unquoted.shell +# ^ punctuation.separator.sequence.shell +# ^ meta.string.shell string.unquoted.shell +# ^ punctuation.separator.sequence.shell +# ^^^ meta.string.shell string.quoted.double.shell +# ^ punctuation.separator.sequence.shell +# ^^^ meta.string.shell string.quoted.single.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta.interpolation + +: {${foo},${bar},$(ls ~),foo${bar}buz,a{a,b,c}d} +# ^ meta.string.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation +# ^^^^^^ meta.string.shell meta.interpolation.brace.shell meta.interpolation.parameter.shell +# ^ meta.string.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation +# ^^^^^^ meta.string.shell meta.interpolation.brace.shell meta.interpolation.parameter.shell +# ^ meta.string.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation +# ^^^^^^^ meta.string.shell meta.interpolation.brace.shell meta.interpolation.command.shell +# ^ meta.string.shell meta.interpolation.brace.shell punctuation.separator.sequence.shell +# ^^^ meta.string.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell +# ^^^^^^ meta.string.shell meta.interpolation.brace.shell meta.string.shell meta.interpolation.parameter.shell +# ^^^ meta.string.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell +# ^ meta.string.shell meta.interpolation.brace.shell punctuation.separator.sequence.shell +# ^ meta.string.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell +# ^^^^^^^ meta.string.shell meta.interpolation.brace.shell meta.string.shell meta.interpolation.brace.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ meta.string.shell string.unquoted.shell +# ^ punctuation.separator.sequence.shell +# ^ meta.string.shell string.unquoted.shell +# ^ punctuation.separator.sequence.shell +# ^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell +# ^ meta.interpolation.brace.shell meta.string.shell string.unquoted.shell +# ^ meta.interpolation.brace.shell - meta.interpolation meta.interpolation + +: {foo\ +bar,baz} +# <- meta.interpolation.brace.shell +#^^^^^^^ meta.interpolation.brace.shell +# ^ - meta.interpolation + +: {..,..2} +# ^^^^^^^^ meta.interpolation.brace.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^ meta.interpolation.brace.shell meta.string.shell string.unquoted.shell - keyword +# ^ punctuation.separator.sequence.shell +# ^^ meta.interpolation.brace.shell meta.string.shell string.unquoted.shell - keyword +# ^ - constant.numeric +# ^ punctuation.section.interpolation.end.shell + +: {{foo,{bar,baz},foo},bar,{1..10}} +# ^ meta.string.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation +# ^^^^^ meta.string.shell meta.interpolation.brace.shell meta.string.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation meta.interpolation +# ^^^^^^^^^ meta.string.shell meta.interpolation.brace.shell meta.string.shell meta.interpolation.brace.shell meta.string.shell meta.interpolation.brace.shell +# ^^^^^ meta.string.shell meta.interpolation.brace.shell meta.string.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation meta.interpolation +# ^^^^^ meta.string.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation +# ^^^^^^^ meta.string.shell meta.interpolation.brace.shell meta.string.shell meta.interpolation.brace.shell +# ^ meta.string.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation +# ^ - meta.string - meta.interpolation +# ^^ punctuation.section.interpolation.begin.shell +# ^^^ string.unquoted.shell +# ^ punctuation.separator.sequence.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ string.unquoted.shell +# ^ punctuation.separator.sequence.shell +# ^^^ string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell +# ^ punctuation.separator.sequence.shell +# ^^^ string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell +# ^ punctuation.separator.sequence.shell +# ^^^ string.unquoted.shell +# ^ punctuation.separator.sequence.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^^ keyword.operator.range.shell +# ^^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^^ punctuation.section.interpolation.end.shell + +: {*,?} +# ^^^^^ meta.interpolation.brace.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ constant.other.wildcard.asterisk.shell +# ^ punctuation.separator.sequence.shell +# ^ constant.other.wildcard.questionmark.shell +# ^ punctuation.section.interpolation.end.shell + +# Patterns to be brace expanded take the form of ... +# a sequence expression between a pair of braces + +: {1..10} +#^ - meta.interpolation +# ^^^^^^^ meta.interpolation.brace.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^^ keyword.operator.range.shell +# ^^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ - meta.interpolation + +: {1..10..2} +#^ - meta.interpolation +# ^^^^^^^^^^ meta.interpolation.brace.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^^ keyword.operator.range.shell +# ^^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^^ keyword.operator.range.shell +# ^ constant.numeric.value.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta.interpolation + +: {-10..+10} +#^ - meta.interpolation +# ^^^^^^^^^^ meta.interpolation.brace.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ meta.interpolation.brace.shell meta.number.integer.decimal.shell keyword.operator.arithmetic.shell +# ^^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^^ keyword.operator.range.shell +# ^ meta.number.integer.decimal.shell keyword.operator.arithmetic.shell +# ^^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta.interpolation + +: {-10..+10..-5} +#^ - meta.interpolation +# ^^^^^^^^^^^^^^ meta.interpolation.brace.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ meta.number.integer.decimal.shell keyword.operator.arithmetic.shell +# ^^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^^ keyword.operator.range.shell +# ^ meta.number.integer.decimal.shell keyword.operator.arithmetic.shell +# ^^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^^ keyword.operator.range.shell +# ^ meta.number.integer.decimal.shell keyword.operator.arithmetic.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta.interpolation + +: {a..z} +#^ - meta.interpolation +# ^^^^^^ meta.interpolation.brace.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ constant.character.shell +# ^^ keyword.operator.range.shell +# ^ constant.character.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta.interpolation + +: {a..z..2} +#^ - meta.interpolation +# ^^^^^^^^^ meta.interpolation.brace.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ meta.interpolation.brace.shell constant.character.shell +# ^^ keyword.operator.range.shell +# ^ constant.character.shell +# ^^ keyword.operator.range.shell +# ^ constant.numeric.value.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta.interpolation + +: {\ +a..z..2} +# <- meta.interpolation.brace.shell constant.character.shell +#^^^^^^^ meta.interpolation.brace.shell +#^^ keyword.operator.range.shell +# ^ constant.character.shell +# ^^ keyword.operator.range.shell +# ^ constant.numeric.value.shell +# ^ punctuation.section.interpolation.end.shell + +: {\ +a..\ +z..2} +# <- meta.interpolation.brace.shell constant.character.shell +#^^^^ meta.interpolation.brace.shell +#^^ keyword.operator.range.shell +# ^ constant.numeric.value.shell +# ^ punctuation.section.interpolation.end.shell + +: {a..z..2\ +} +# <- meta.interpolation.brace.shell punctuation.section.interpolation.end.shell + +: {${start}..$(( start + len ))..${incr}} +# ^ meta.interpolation.brace.shell - meta.interpolation meta.interpolation +# ^^^^^^^^ meta.interpolation.brace.shell meta.interpolation.parameter.shell +# ^^ meta.interpolation.brace.shell - meta.interpolation meta.interpolation +# ^^^^^^^^^^^^^^^^^^ meta.interpolation.brace.shell meta.interpolation.arithmetic.shell +# ^^ meta.interpolation.brace.shell - meta.interpolation meta.interpolation +# ^^^^^^^ meta.interpolation.brace.shell meta.interpolation.parameter.shell +# ^ meta.interpolation.brace.shell - meta.interpolation meta.interpolation +# ^ meta.interpolation.brace.shell punctuation.section.interpolation.begin.shell +# ^ meta.interpolation.parameter.shell punctuation.definition.variable.shell +# ^ meta.interpolation.parameter.shell punctuation.section.interpolation.begin.shell +# ^^^^^ variable.other.readwrite.shell +# ^ punctuation.section.interpolation.end.shell +# ^^ keyword.operator.range.shell +# ^ meta.interpolation.arithmetic.shell punctuation.definition.variable.shell +# ^^ punctuation.section.interpolation.begin.shell +# ^^^^^ meta.variable.shell variable.other.readwrite.shell +# ^ keyword.operator.arithmetic.shell +# ^^^ meta.variable.shell variable.other.readwrite.shell +# ^^ meta.interpolation.arithmetic.shell punctuation.section.interpolation.end.shell +# ^^ keyword.operator.range.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^^ variable.other.readwrite.shell +# ^^ punctuation.section.interpolation.end.shell + + { : {1..21} } +# ^^^^ meta.block.shell - meta.interpolation +# ^^^^^^^ meta.block.shell meta.interpolation.brace.shell +# ^^ meta.block.shell - meta.interpolation + + ( : {1..21} ) +# ^^^^ meta.compound.command.shell - meta.interpolation +# ^^^^^^^ meta.compound.command.shell meta.interpolation.brace.shell +# ^^ meta.compound.command.shell - meta.interpolation + +any --arg{1..4}={1..4} +# ^^^^^ meta.parameter.option.shell variable.parameter.option.shell - meta.interpolation +# ^^^^^^ meta.function-call.arguments.shell meta.parameter.option.shell meta.interpolation.brace.shell - variable.parameter +# ^ keyword.operator.assignment.shell +# ^^^^^^ meta.string.shell meta.interpolation.brace.shell + +any --arg{1..4} ={1..4} +# ^^^^^ meta.parameter.option.shell variable.parameter.option.shell - meta.interpolation +# ^^^^^^ meta.function-call.arguments.shell meta.parameter.option.shell meta.interpolation.brace.shell - variable.parameter +# ^ meta.string.shell string.unquoted.shell - meta.interpolation +# ^^^^^^ meta.string.shell meta.interpolation.brace.shell + +any --arg{1,2,3}={1,2,3} +# ^^^^^ meta.parameter.option.shell variable.parameter.option.shell - meta.interpolation +# ^^^^^^^ meta.function-call.arguments.shell meta.parameter.option.shell meta.interpolation.brace.shell - variable.parameter +# ^ keyword.operator.assignment.shell +# ^^^^^^^ meta.string.shell meta.interpolation.brace.shell + +any --arg{1,2,3} ={1,2,3} +# ^^^^^ meta.parameter.option.shell variable.parameter.option.shell - meta.interpolation +# ^^^^^^^ meta.function-call.arguments.shell meta.parameter.option.shell meta.interpolation.brace.shell - variable.parameter +# ^ meta.string.shell string.unquoted.shell - meta.interpolation +# ^^^^^^^ meta.string.shell meta.interpolation.brace.shell + +# invalid brace expansions due to whitespace + +: {} {*} {1} {a} {foo} {'bar'} {"baz"} +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.interpolation + +: { 1..9} {1..9 } {1.. 9} {1 ..9} {a, b, c} +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.interpolation + +: {1..&} {1..|} {1..<} {1..>} {(..)} {a..)} +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.interpolation + +: {a..z\ + ..2} +#^^^^^ - meta.interpolation + +: {foo\ + bar,baz} +#^^^^^^^^^^ - meta.interpolation + +: '{foo,bar,baz}' '{1..10}' +# ^^^^^^^^^^^^^^^ meta.string.shell string.quoted.single.shell - meta.interpolation +# ^^^^^^^^^ meta.string.shell string.quoted.single.shell - meta.interpolation + +: "{foo,bar,baz}" "{1..10}" +# ^^^^^^^^^^^^^^^ meta.string.shell string.quoted.double.shell - meta.interpolation +# ^^^^^^^^^ meta.string.shell string.quoted.double.shell - meta.interpolation + + +############################################################################### +# 14.7 Filename Expansion +# https://zsh.sourceforge.io/Doc/Release/Expansion.html#Filename-Expansion +############################################################################### + +: ~ # expand to $HOME +# ^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ - meta.interpolation + +: ~/ # expand to $HOME +# ^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ - meta.interpolation + +: ~+ # expand to current working dir +# ^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ - meta.interpolation + +: ~+/ # expand to current working dir +# ^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ - meta.interpolation + +: ~- # expand to previous working dir +# ^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ - meta.interpolation + +: ~-/ # expand to previous working dir +# ^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ - meta.interpolation + +: ~0 # expand to current working dir +# ^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ - meta.interpolation + +: ~0/ # expand to current working dir +# ^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ - meta.interpolation + +: ~1 # expand to previous working dir +# ^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ - meta.interpolation + +: ~1/ # expand to previous working dir +# ^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ - meta.interpolation + +: ~+0 # equivalent to ~+ +# ^^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ - meta.interpolation + +: ~+0/ # equivalent to ~+ +# ^^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ - meta.interpolation + +: ~+1 # top of directory stack +# ^^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ - meta.interpolation + +: ~+1/ # top of directory stack +# ^^^ meta.interpolation.tilde.shell variable.language.tilde.shell +# ^ - meta.interpolation + +# 14.7.1 Dynamic named directories + +: ~[...]/ +# ^ meta.string.shell meta.interpolation.tilde.shell - meta.brackets - meta.interpolation meta.function-call +# ^ meta.string.shell meta.interpolation.tilde.shell meta.brackets - meta.interpolation meta.function-call +# ^^^ meta.string.shell meta.interpolation.tilde.shell meta.brackets.shell.zsh meta.function-call.identifier.shell.zsh variable.function.shell.zsh +# ^ meta.string.shell meta.interpolation.tilde.shell meta.brackets - meta.interpolation meta.function-call +# ^ variable.language.tilde.shell +# ^ punctuation.section.brackets.begin.shell.zsh - variable variable +# ^^^ variable.function.shell.zsh - variable variable +# ^ punctuation.section.brackets.end.shell.zsh - variable variable + +: ~[dyn_${dir}_name]/ +# ^ meta.string.shell meta.interpolation.tilde.shell - meta.interpolation meta.function-call +# ^ meta.string.shell meta.interpolation.tilde.shell meta.brackets - meta.interpolation meta.function-call +# ^^^^ meta.function-call.arguments.shell meta.string.shell meta.interpolation.tilde.shell meta.brackets.shell.zsh meta.function-call.identifier.shell.zsh - meta.interpolation.parameter +# ^^^^^^ meta.string.shell meta.interpolation.tilde.shell meta.brackets.shell.zsh meta.function-call.identifier.shell.zsh meta.interpolation.parameter.shell +# ^^^^^ meta.function-call.arguments.shell meta.string.shell meta.interpolation.tilde.shell meta.brackets.shell.zsh meta.function-call.identifier.shell.zsh - meta.interpolation.parameter +# ^ meta.string.shell meta.interpolation.tilde.shell meta.brackets - meta.interpolation meta.function-call +# ^ meta.string.shell string.unquoted.shell - meta.interpolation +# ^ variable.language.tilde.shell +# ^ punctuation.section.brackets.begin.shell.zsh - variable variable +# ^^^^ variable.function.shell.zsh - variable variable +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell - variable variable +# ^ punctuation.section.interpolation.end.shell +# ^^^^^ variable.function.shell.zsh - variable variable +# ^ punctuation.section.brackets.end.shell.zsh - variable variable + +dyn_dir_name() { + emulate -L zsh + setopt extendedglob + local -a match mbegin mend + if [[ $1 = d ]]; then + # turn the directory into a name + if [[ $2 = (#b)(/home/pws/perforce/)([^/]##)* ]]; then + typeset -ga reply + reply=(p:$match[2] $(( ${#match[1]} + ${#match[2]} )) ) + else + return 1 + fi + elif [[ $1 = n ]]; then + # turn the name into a directory + [[ $2 != (#b)p:(?*) ]] && return 1 + typeset -ga reply + reply=(/home/pws/perforce/$match[1]) + elif [[ $1 = c ]]; then + # complete names + local expl + local -a dirs + dirs=(/home/pws/perforce/*(/:t)) + dirs=(p:${^dirs}) + _wanted dynamic-dirs expl 'dynamic directory' compadd -S\] -a dirs + return + else + return 1 + fi + return 0 +} + +# 14.7.2 Static named directories + +~n_a-m.e/ ~n_a-m.e/ +# <- meta.function-call.identifier.shell meta.path.shell meta.interpolation.tilde.shell variable.language.tilde.shell +#^^^^^^^ meta.function-call.identifier.shell meta.path.shell meta.interpolation.tilde.shell constant.other.username.shell +# ^ meta.function-call.identifier.shell meta.path.shell variable.function.shell punctuation.separator.path.shell +# ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell +# ^^^^^^^ meta.string.shell meta.interpolation.tilde.shell constant.other.username.shell - variable +# ^ meta.string.shell - meta.interpolation + +~n_${a-m}.e/ ~n_${a-m}.e/ +# <- meta.function-call.identifier.shell meta.path.shell meta.interpolation.tilde.shell variable.language.tilde.shell - variable.function +#^^ meta.function-call.identifier.shell meta.path.shell meta.interpolation.tilde.shell constant.other.username.shell +# ^^^^^^ meta.function-call.identifier.shell meta.path.shell meta.interpolation.tilde.shell meta.interpolation.parameter.shell +# ^^ meta.function-call.identifier.shell meta.path.shell meta.interpolation.tilde.shell constant.other.username.shell +# ^ meta.function-call.identifier.shell meta.path.shell variable.function.shell punctuation.separator.path.shell +# ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell +# ^^ meta.string.shell meta.interpolation.tilde.shell constant.other.username.shell - variable +# ^^^^^^ meta.string.shell meta.interpolation.tilde.shell meta.interpolation.parameter.shell +# ^^ meta.string.shell meta.interpolation.tilde.shell constant.other.username.shell - variable +# ^ meta.string.shell - meta.interpolation + +# 14.7.3 ‘=’ expansion + +=command =command +# <- meta.function-call.identifier.shell meta.path.shell variable.function.shell punctuation.definition.expansion.shell.zsh +#^^^^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^^^^^^^ meta.function-call.arguments.shell meta.string.shell string.unquoted.shell +# ^ punctuation.definition.expansion.shell + + +############################################################################### +# 14.8 Filename Generation +# 14.8.1 Glob Operators +# https://zsh.sourceforge.io/Doc/Release/Expansion.html#Glob-Operators +############################################################################### + +: * +# ^ constant.other.wildcard.asterisk.shell + +: ? +# ^ constant.other.wildcard.questionmark.shell + +: [[:alnum:]] # The character is alphanumeric +# ^^^^^^^^^^^ meta.set.regexp.shell +# ^^ punctuation.definition.set.begin.regexp.shell +# ^^^^^^^ constant.other.posix-class.regexp.shell +# ^^ punctuation.definition.set.end.regexp.shell + +: [[:alpha:]] # The character is alphabetic +# ^^^^^^^^^^^ meta.set.regexp.shell +# ^^ punctuation.definition.set.begin.regexp.shell +# ^^^^^^^ constant.other.posix-class.regexp.shell +# ^^ punctuation.definition.set.end.regexp.shell + +: [[:ascii:]] # The character is 7-bit, i.e. is a single-byte character without the top bit set. +# ^^^^^^^^^^^ meta.set.regexp.shell +# ^^ punctuation.definition.set.begin.regexp.shell +# ^^^^^^^ constant.other.posix-class.regexp.shell +# ^^ punctuation.definition.set.end.regexp.shell + +: [[:blank:]] # The character is a blank character +# ^^^^^^^^^^^ meta.set.regexp.shell +# ^^ punctuation.definition.set.begin.regexp.shell +# ^^^^^^^ constant.other.posix-class.regexp.shell +# ^^ punctuation.definition.set.end.regexp.shell + +: [[:cntrl:]] # The character is a control character +# ^^^^^^^^^^^ meta.set.regexp.shell +# ^^ punctuation.definition.set.begin.regexp.shell +# ^^^^^^^ constant.other.posix-class.regexp.shell +# ^^ punctuation.definition.set.end.regexp.shell + +: [[:digit:]] # The character is a decimal digit +# ^^^^^^^^^^^ meta.set.regexp.shell +# ^^ punctuation.definition.set.begin.regexp.shell +# ^^^^^^^ constant.other.posix-class.regexp.shell +# ^^ punctuation.definition.set.end.regexp.shell + +: [[:graph:]] # The character is a printable character other than whitespace +# ^^^^^^^^^^^ meta.set.regexp.shell +# ^^ punctuation.definition.set.begin.regexp.shell +# ^^^^^^^ constant.other.posix-class.regexp.shell +# ^^ punctuation.definition.set.end.regexp.shell + +: [[:lower:]] # The character is a lowercase letter +# ^^^^^^^^^^^ meta.set.regexp.shell +# ^^ punctuation.definition.set.begin.regexp.shell +# ^^^^^^^ constant.other.posix-class.regexp.shell +# ^^ punctuation.definition.set.end.regexp.shell + +: [[:print:]] # The character is printable +# ^^^^^^^^^^^ meta.set.regexp.shell +# ^^ punctuation.definition.set.begin.regexp.shell +# ^^^^^^^ constant.other.posix-class.regexp.shell +# ^^ punctuation.definition.set.end.regexp.shell + +: [[:punct:]] # The character is printable but neither alphanumeric nor whitespace +# ^^^^^^^^^^^ meta.set.regexp.shell +# ^^ punctuation.definition.set.begin.regexp.shell +# ^^^^^^^ constant.other.posix-class.regexp.shell +# ^^ punctuation.definition.set.end.regexp.shell + +: [[:space:]] # The character is whitespace +# ^^^^^^^^^^^ meta.set.regexp.shell +# ^^ punctuation.definition.set.begin.regexp.shell +# ^^^^^^^ constant.other.posix-class.regexp.shell +# ^^ punctuation.definition.set.end.regexp.shell + +: [[:upper:]] # The character is an uppercase letter +# ^^^^^^^^^^^ meta.set.regexp.shell +# ^^ punctuation.definition.set.begin.regexp.shell +# ^^^^^^^ constant.other.posix-class.regexp.shell +# ^^ punctuation.definition.set.end.regexp.shell + +: [[:xdigit:]] # The character is a hexadecimal digit +# ^^^^^^^^^^^^ meta.set.regexp.shell +# ^^ punctuation.definition.set.begin.regexp.shell +# ^^^^^^^^ constant.other.posix-class.regexp.shell +# ^^ punctuation.definition.set.end.regexp.shell + +# Another set of named classes is handled internally by the shell and is not sensitive to the locale: + +: [[:IDENT:]] # The character is allowed to form part of a shell identifier, such as a parameter name. +# ^^^^^^^^^^^ meta.set.regexp.shell +# ^^ punctuation.definition.set.begin.regexp.shell +# ^^^^^^^ constant.other.posix-class.regexp.shell +# ^^ punctuation.definition.set.end.regexp.shell + +: [[:IFS:]] # The character is used as an input field separator, i.e. is contained in the IFS parameter +# ^^^^^^^^^ meta.set.regexp.shell +# ^^ punctuation.definition.set.begin.regexp.shell +# ^^^^^ constant.other.posix-class.regexp.shell +# ^^ punctuation.definition.set.end.regexp.shell + +: [[:IFSSPACE:]] # The character is an IFS white space character. +# ^^^^^^^^^^^^^^ meta.set.regexp.shell +# ^^ punctuation.definition.set.begin.regexp.shell +# ^^^^^^^^^^ constant.other.posix-class.regexp.shell +# ^^ punctuation.definition.set.end.regexp.shell + +: [[:INCOMPLETE:]] # Matches a byte that starts an incomplete multibyte character. +# ^^^^^^^^^^^^^^^^ meta.set.regexp.shell +# ^^ punctuation.definition.set.begin.regexp.shell +# ^^^^^^^^^^^^ constant.other.posix-class.regexp.shell +# ^^ punctuation.definition.set.end.regexp.shell + +: [[:WORD:]] # The character is treated as part of a word. +# ^^^^^^^^^^ meta.set.regexp.shell +# ^^ punctuation.definition.set.begin.regexp.shell +# ^^^^^^ constant.other.posix-class.regexp.shell +# ^^ punctuation.definition.set.end.regexp.shell + +: [^.][!\ ] # Like [...], except that it matches any character which is not in the given set. +# ^^^^^^^^^ meta.string.shell string.unquoted.shell meta.set.regexp.shell +# ^ punctuation.definition.set.begin.regexp.shell +# ^ keyword.operator.logical.regexp.shell +# ^ punctuation.definition.set.end.regexp.shell +# ^ punctuation.definition.set.begin.regexp.shell +# ^ keyword.operator.logical.regexp.shell +# ^^ constant.character.escape.shell +# ^ punctuation.definition.set.end.regexp.shell + +: <-> # Matches any number +# ^^^ meta.range.shell.zsh +# ^ punctuation.definition.range.begin.shell.zsh +# ^ keyword.operator.range.shell.zsh +# ^ punctuation.definition.range.end.shell.zsh + +: <2-> # Matches any number greator or equal 2 +# ^^^^ meta.range.shell.zsh +# ^ punctuation.definition.range.begin.shell.zsh +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ keyword.operator.range.shell.zsh +# ^ punctuation.definition.range.end.shell.zsh + +: <-5> # Matches any number greator or equal 2 +# ^^^^ meta.range.shell.zsh +# ^ punctuation.definition.range.begin.shell.zsh +# ^ keyword.operator.range.shell.zsh +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.definition.range.end.shell.zsh + +: <2-5> # Matches numbers from 2 to 5 +# ^^^^ meta.range.shell.zsh +# ^ punctuation.definition.range.begin.shell.zsh +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ keyword.operator.range.shell.zsh +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.definition.range.end.shell.zsh + +: <$start-$end> # Matches numbers from $start to $end +# ^ meta.range.shell.zsh punctuation.definition.range.begin.shell.zsh +# ^^^^^^ meta.range.shell.zsh meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^ meta.range.shell.zsh keyword.operator.range.shell.zsh +# ^^^^ meta.range.shell.zsh meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^ meta.range.shell.zsh punctuation.definition.range.end.shell.zsh + +: <${start: 1 + 2 : 5}-${end:${pt0}:${len}}> # Matches numbers from calculated start to end +# ^ meta.range.shell.zsh punctuation.definition.range.begin.shell.zsh +# ^^^^^^^^^^^^^^^^^^^ meta.range.shell.zsh meta.interpolation.parameter.shell +# ^ meta.range.shell.zsh keyword.operator.range.shell.zsh +# ^^^^^^^^^^^^^^^^^^^^ meta.range.shell.zsh meta.interpolation.parameter.shell +# ^ meta.range.shell.zsh punctuation.definition.range.end.shell.zsh + +: <${start##<1-5>0}-> +# ^ meta.range.shell.zsh - meta.interpolation - meta.range meta.range +# ^^^^^^^^^ meta.range.shell.zsh meta.interpolation.parameter.shell - meta.range meta.range +# ^^^^^ meta.range.shell.zsh meta.interpolation.parameter.shell meta.string.regexp.shell meta.range.shell.zsh +# ^^ meta.range.shell.zsh meta.interpolation.parameter.shell - meta.range meta.range +# ^^ meta.range.shell.zsh +# ^ - meta.range + +: foo<5-21> foo<5-21>bar <5-21>bar +# ^^^^^^ meta.range.shell.zsh +# ^^^^^^ meta.range.shell.zsh +# ^^^^^^ meta.range.shell.zsh + +: 1<1-5> 1<1-5>0 <1-5>0 +# ^^^^^ meta.range.shell.zsh +# ^^^^^ meta.range.shell.zsh +# ^^^^^ meta.range.shell.zsh + +: foo/(a*/)#bar # bar matches foo/bar, foo/any/bar, foo/any/anyother/bar, ... +# ^^^^ meta.string.shell string.unquoted.shell +# ^^^^^ meta.string.shell meta.group.regexp.shell string.unquoted.shell +# ^^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.definition.group.begin.regexp.shell +# ^ constant.other.wildcard.asterisk.shell +# ^ punctuation.definition.group.end.regexp.shell +# ^ keyword.operator.quantifier.regexp.shell.zsh + +: (foo|bar)|baz +# ^^^^^^^^^ meta.group.regexp.shell string.unquoted.shell +# ^ punctuation.definition.group.begin.regexp.shell +# ^ keyword.operator.logical.regexp.shell +# ^ punctuation.definition.group.end.regexp.shell +# ^ keyword.operator.assignment.pipe.shell +# ^^^ variable.function.shell + + ^foo/bar ^foo/bar # Matches anything except the pattern x +# ^^^^^^^^ meta.function-call.identifier.shell meta.path.shell +# ^ meta.function-call.arguments.shell - variable - string +# ^^^^^^^^ meta.function-call.arguments.shell meta.string.shell +# ^ - meta +# ^^^^^^^^ variable.function.shell +# ^ keyword.operator.logical.regexp.shell.zsh +# ^ punctuation.separator.path.shell +# ^^^^^^^^ string.unquoted.shell +# ^ keyword.operator.logical.regexp.shell.zsh + + ^~/foo/bar ^~/foo/bar # Matches anything except the pattern x +# ^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell +# ^ meta.function-call.arguments.shell - variable - string +# ^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell +# ^ - meta +# ^ keyword.operator.logical.regexp.shell.zsh +# ^ variable.language.tilde.shell +# ^^^^^^^^ variable.function.shell +# ^ punctuation.separator.path.shell +# ^ punctuation.separator.path.shell +# ^ string.unquoted.shell keyword.operator.logical.regexp.shell.zsh +# ^ variable.language.tilde.shell +# ^^^^^^^^ string.unquoted.shell + + /foo~/bar /foo~/bar # Match anything that matches the pattern x but does not match y +# ^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell +# ^ meta.function-call.arguments.shell - variable - string +# ^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell +# ^ - meta +# ^^^^^^^^^ variable.function.shell +# ^ punctuation.separator.path.shell +# ^ keyword.operator.logical.regexp.shell.zsh +# ^ punctuation.separator.path.shell +# ^^^^^^^^^ string.unquoted.shell +# ^ keyword.operator.logical.regexp.shell.zsh + + ^/foo~^/bar ^/foo~^/bar +# ^^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell +# ^ meta.function-call.arguments.shell - variable - string +# ^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell +# ^ - meta +# ^^^^^^^^^^^ variable.function.shell +# ^ keyword.operator.logical.regexp.shell.zsh +# ^ punctuation.separator.path.shell +# ^^ keyword.operator.logical.regexp.shell.zsh +# ^ punctuation.separator.path.shell +# ^^^^^^^^^^^ string.unquoted.shell +# ^ keyword.operator.logical.regexp.shell.zsh +# ^^ keyword.operator.logical.regexp.shell.zsh + + ~/foo~~/bar ~/foo~~/bar +# ^^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell +# ^ meta.function-call.arguments.shell - variable - string +# ^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell +# ^ - meta +# ^ variable.language.tilde.shell +# ^^^^^ variable.function.shell +# ^ punctuation.separator.path.shell +# ^ keyword.operator.logical.regexp.shell.zsh +# ^ variable.language.tilde.shell +# ^^^^ variable.function.shell +# ^ punctuation.separator.path.shell +# ^ variable.language.tilde.shell +# ^^^^ string.unquoted.shell +# ^ keyword.operator.logical.regexp.shell.zsh +# ^ variable.language.tilde.shell +# ^^^^ string.unquoted.shell + + ^~/foo~^~/bar ^~/foo~^~/bar +# ^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell +# ^ meta.function-call.arguments.shell - variable - string +# ^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell +# ^ - meta +# ^ variable.language.tilde.shell +# ^^^^ variable.function.shell +# ^ punctuation.separator.path.shell +# ^^ keyword.operator.logical.regexp.shell.zsh +# ^ variable.language.tilde.shell +# ^^^^ variable.function.shell +# ^ punctuation.separator.path.shell +# ^ variable.language.tilde.shell +# ^^^^ string.unquoted.shell +# ^^ keyword.operator.logical.regexp.shell.zsh +# ^ variable.language.tilde.shell +# ^^^^ string.unquoted.shell + + +############################################################################### +# 14.8.2 ksh-like Glob Operators +# https://zsh.sourceforge.io/Doc/Release/Expansion.html#ksh_002dlike-Glob-Operators +############################################################################### + +: @(...) is (...) # Match the pattern in the parentheses. (Like ‘(...)’.) +# ^ keyword.operator.quantifier.regexp.shell +# ^^^^^ meta.group.regexp.shell +# ^ punctuation.definition.group.begin.regexp.shell +# ^ punctuation.definition.group.end.regexp.shell +# ^^^^^ meta.group.regexp.shell +# ^ punctuation.definition.group.begin.regexp.shell +# ^ punctuation.definition.group.end.regexp.shell + +# note: scope * as glob instead of operator as it is more likely in ZSH +: *(...) is (...)# # Match any number of occurrences. (Like ‘(...)#’, except that recursive directory searching is not supported.) +# ^ constant.other.wildcard.asterisk.shell +# ^^^^^ meta.group.regexp.shell +# ^ punctuation.definition.group.begin.regexp.shell +# ^ punctuation.definition.group.end.regexp.shell +# ^^^^^ meta.group.regexp.shell +# ^ punctuation.definition.group.begin.regexp.shell +# ^ punctuation.definition.group.end.regexp.shell +# ^ keyword.operator.quantifier.regexp.shell + +: +(...) is (...)## # Match at least one occurrence. (Like ‘(...)##’, except that recursive directory searching is not supported.) +# ^ keyword.operator.quantifier.regexp.shell +# ^^^^^ meta.group.regexp.shell +# ^ punctuation.definition.group.begin.regexp.shell +# ^ punctuation.definition.group.end.regexp.shell +# ^^^^^ meta.group.regexp.shell +# ^ punctuation.definition.group.begin.regexp.shell +# ^ punctuation.definition.group.end.regexp.shell +# ^^ keyword.operator.quantifier.regexp.shell + +# note: scope ? as glob instead of operator as it is more likely in ZSH +: ?(...) is (|...) # Match zero or one occurrence. (Like ‘(|...)’.) +# ^ constant.other.wildcard.questionmark.shell +# ^^^^^ meta.group.regexp.shell +# ^ punctuation.definition.group.begin.regexp.shell +# ^ punctuation.definition.group.end.regexp.shell +# ^^^^^^ meta.group.regexp.shell +# ^ punctuation.definition.group.begin.regexp.shell +# ^ keyword.operator.logical.regexp.shell +# ^ punctuation.definition.group.end.regexp.shell + +: !(...) is (^(...)) # Match anything but the expression in parentheses. (Like ‘(^(...))’.) +# ^ keyword.operator.quantifier.regexp.shell +# ^^^^^ meta.group.regexp.shell +# ^ punctuation.definition.group.begin.regexp.shell +# ^ punctuation.definition.group.end.regexp.shell +# ^^ meta.group.regexp.shell - meta.group.regexp meta.group.regexp +# ^ punctuation.definition.group.begin.regexp.shell +# ^ keyword.operator.logical.regexp.shell +# ^^^^^ meta.group.regexp.shell meta.group.regexp.shell +# ^ punctuation.definition.group.begin.regexp.shell +# ^^ punctuation.definition.group.end.regexp.shell +# ^ meta.group.regexp.shell - meta.group.regexp meta.group.regexp + + +############################################################################### +# 14.8.4 Globbing Flags +# https://zsh.sourceforge.io/Doc/Release/Expansion.html#Globbing-Flags +############################################################################### + +: (#i) # Match case insensitively +# ^^^^ meta.modifier.glob.shell.zsh +# ^^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.mode.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: (#l) # Lower case matches upper case +# ^^^^ meta.modifier.glob.shell.zsh +# ^^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.mode.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: (#I) # Match case sensitively +# ^^^^ meta.modifier.glob.shell.zsh +# ^^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.mode.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: (#b) # Parentheses set match, mbegin, mend +# ^^^^ meta.modifier.glob.shell.zsh +# ^^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.mode.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: (#B) # Parentheses no longer set arrays +# ^^^^ meta.modifier.glob.shell.zsh +# ^^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.mode.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: (#c1) # requires exactly N matches +# ^^^^^ meta.modifier.glob.shell.zsh +# ^^ punctuation.definition.modifier.begin.shell.zsh +# ^^ storage.modifier.mode.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: (#c,4) # requires maximum M matches +# ^^^^^^ meta.modifier.glob.shell.zsh +# ^^ punctuation.definition.modifier.begin.shell.zsh +# ^^^ storage.modifier.mode.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: (#c1,) # requires at least N matches +# ^^^^^^ meta.modifier.glob.shell.zsh +# ^^ punctuation.definition.modifier.begin.shell.zsh +# ^^^ storage.modifier.mode.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: (#c1,4) # requires between N and M matches +# ^^^^^^^ meta.modifier.glob.shell.zsh +# ^^ punctuation.definition.modifier.begin.shell.zsh +# ^^^^ storage.modifier.mode.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: (#c$start,$end) # requires between N and M matches +# ^^^ meta.modifier.glob.shell.zsh - meta.interpolation +# ^^^^^^ meta.modifier.glob.shell.zsh meta.interpolation.parameter.shell +# ^ meta.modifier.glob.shell.zsh - meta.interpolation +# ^^^^ meta.modifier.glob.shell.zsh meta.interpolation.parameter.shell +# ^ meta.modifier.glob.shell.zsh - meta.interpolation +# ^^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.mode.glob.shell.zsh +# ^^^^^^ variable.other.readwrite.shell +# ^ punctuation.separator.sequence.shell +# ^^^^ variable.other.readwrite.shell +# ^ punctuation.definition.modifier.end.shell.zsh + +: (#m) # Match in MATCH, MBEGIN, MEND +# ^^^^ meta.modifier.glob.shell.zsh +# ^^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.mode.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: (#M) # Don’t use MATCH etc. +# ^^^^ meta.modifier.glob.shell.zsh +# ^^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.mode.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: (#a3) # Match with num approximations +# ^^^^^ meta.modifier.glob.shell.zsh +# ^^ punctuation.definition.modifier.begin.shell.zsh +# ^^ storage.modifier.mode.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: (#s) # Match only at start of test string +# ^^^^ meta.modifier.glob.shell.zsh +# ^^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.mode.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: (#e) # Match only at end of test string +# ^^^^ meta.modifier.glob.shell.zsh +# ^^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.mode.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: (#q) # A ‘q’ and everything up to the closing parenthesis of the globbing flags are ignored by the pattern matching code. +# ^^^^ meta.modifier.glob.shell.zsh +# ^^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.mode.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: (#qexpr) # expr is a a set of glob qualifiers (below) +# ^^^^^^^^ meta.modifier.glob.shell.zsh +# ^^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.mode.glob.shell.zsh +# ^^^^ - storage.modifier.mode.glob +# ^ punctuation.definition.modifier.end.shell.zsh + +: (#u) # Respect the current locale in determining the presence of multibyte characters in a pattern +# ^^^^ meta.modifier.glob.shell.zsh +# ^^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.mode.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: (#U) # All characters are considered to be a single byte long. +# ^^^^ meta.modifier.glob.shell.zsh +# ^^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.mode.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +# examples + +: (#ia2)readme # case-insensitive matching of readme with up to two errors. +# ^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh - string +# ^^^^^^ meta.string.shell string.unquoted.shell + +: ((#i)foo)bar +# ^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell +# ^ meta.group.regexp.shell punctuation.definition.group.begin.regexp.shell +# ^^^^ meta.group.regexp.shell meta.modifier.glob.shell.zsh - string +# ^^^^ meta.group.regexp.shell string.unquoted.shell +# ^^^ string.unquoted.shell + +arr=(veldt jynx grimps waqf zho buck) +print ${arr//(#m)[aeiou]/${(U)MATCH}} +# ^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell meta.interpolation.parameter.shell - meta.interpolation.parameter meta.interpolation.parameter +# ^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell meta.interpolation.parameter.shell meta.string.shell meta.interpolation.parameter.shell +# ^ meta.function-call.arguments.shell meta.string.shell meta.interpolation.parameter.shell - meta.interpolation.parameter meta.interpolation.parameter +# ^ meta.interpolation.parameter.shell punctuation.definition.variable.shell +# ^ meta.interpolation.parameter.shell punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^^ keyword.operator.substitution.shell +# ^^^^ meta.interpolation.parameter.shell meta.string.regexp.shell meta.modifier.glob.shell.zsh +# ^^^^^^^ meta.interpolation.parameter.shell meta.string.regexp.shell meta.set.regexp.shell +# ^ keyword.operator.substitution.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^^ variable.language.builtin.shell +# ^^ punctuation.section.interpolation.end.shell + +: *((#s)|/)test((#e)|/)* +# ^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell +# ^ constant.other.wildcard.asterisk.shell +# ^ meta.group.regexp.shell - meta.modifier +# ^^^^ meta.group.regexp.shell meta.modifier.glob.shell.zsh - string +# ^^^ meta.group.regexp.shell - meta.modifier +# ^^^^^^^^ string.unquoted.shell +# ^ meta.group.regexp.shell - meta.modifier +# ^^^^ meta.group.regexp.shell meta.modifier.glob.shell.zsh - string +# ^^^ meta.group.regexp.shell string.unquoted.shell - meta.modifier +# ^ constant.other.wildcard.asterisk.shell + + +############################################################################### +# 14.8.7 Glob Qualifiers +# https://zsh.sourceforge.io/Doc/Release/Expansion.html#Glob-Qualifiers +############################################################################### + +# lists all directories and symbolic links that point to directories, and +ls -ld -- *(-/) +# ^ meta.string.shell string.unquoted.shell constant.other.wildcard.asterisk.shell +# ^^^^ meta.string.shell meta.group.regexp.shell string.unquoted.shell + +# lists all broken symbolic links, and +ls -ld -- *(-@) +# ^ meta.string.shell string.unquoted.shell constant.other.wildcard.asterisk.shell +# ^^^^ meta.string.shell meta.group.regexp.shell string.unquoted.shell + +# lists all world-writable device files in the current directory, and +ls -ld -- *(%W) +# ^ meta.string.shell string.unquoted.shell constant.other.wildcard.asterisk.shell +# ^^^^ meta.string.shell meta.group.regexp.shell string.unquoted.shell + +# lists all files in the current directory that are world-writable or world-executable, and +ls -ld -- *(W,X) +# ^ meta.string.shell string.unquoted.shell constant.other.wildcard.asterisk.shell +# ^^^^^ meta.string.shell meta.group.regexp.shell string.unquoted.shell + +# outputs the basename of all root-owned files beginning with the string ‘foo’ +# in /tmp, ignoring symlinks, and +print -rC1 /tmp/foo*(u0^@:t) +# ^^^^^^^^^ meta.string.shell string.unquoted.shell +# ^^^^^^^^ meta.string.shell meta.group.regexp.shell string.unquoted.shell + +# lists all files having a link count of one whose names contain a dot (but +# not those starting with a dot, since GLOB_DOTS is explicitly switched off) +# except for lex.c, lex.h, parse.c and parse.h. +ls -ld -- *.*~(lex|parse).[ch](^D^l1) +# ^^^^ meta.string.shell string.unquoted.shell +# ^^^^^^^^^^^ meta.string.shell meta.group.regexp.shell string.unquoted.shell +# ^ meta.string.shell string.unquoted.shell +# ^^^^ meta.string.shell string.unquoted.shell meta.set.regexp.shell +# ^^^^^^^ meta.string.shell meta.group.regexp.shell string.unquoted.shell + +# demonstrates how colon modifiers and other qualifiers may be chained together. +# TODO: colon initiats history expansions' modifiers +print -rC1 b*.pro(#q:s/pro/shmo/)(#q.:s/builtin/shmiltin/) +# ^^^^^^ meta.string.shell string.unquoted.shell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ - meta.string - meta.modifier + +###[ COMMON EXPANSIONS ]####################################################### + +# https://wiki.zshell.dev/community/zsh_guide/roadmap/expansion +ls *(.) # List just regular files +ls -ld *(/om[1,3]) # Show three newest directories, "om" orders by modification. "[1,3]" works like Python slice +rm -i *(.L0) # Remove zero length files, prompt for each file +ls *(^m0) # Files not modified today +ls **/*(.x) # List all executable files in this tree +ls *~*.*(.) # List all files that does not have a dot in the filename +ls -l */**(Lk+100) # List all files larger than 100kb in this tree +ls DATA_[0-9](#c4,7).csv # List DATA_nnnn.csv to DATA_nnnnnnn.csv +rm ../debianpackage(.) # Remove files only +ls -d *(/) # List directories only +ls /etc/*(@) # List symlinks only +ls -l *.(png|jpg|gif) # List pictures only +ls *(*) # List executables only +ls /etc/**/zsh # Which directories contain zsh? +ls **/*(-@) # List dangling symlinks (** recurses down directory trees) +ls foo*~*bar* # Match everything that starts with foo but doesn't contain bar +ls *(e:'file $REPLY | grep -q JPEG':) # Match all files of which file says that they are JPEGs +ls -ldrt -- *(mm+15) # List all files older than 15mins +ls -ldrt -- *(.mm+15) # List just regular files +ls -ld /my/path/**/*(D@-^@) # List the unbroken symlinks under a directory +ls -Lldrt -- *(-mm+15) # List the age of the pointed-to file for symlinks +ls -l **/README # Search for README in all Subdirectories +ls -l foo<23-> # List files beginning at foo23 upwards (foo23, foo24, foo25, ..) +ls -l 200406{04..10}*(N) # List all files that begin with the date strings from June 4 through June 9 of 2004 +ls -l 200406<4-10>.* # List will match the form of 200406XX +ls -l *.(c|h) # Show only all *.c and *.h files +ls -l *(R) # Show only world-readable files +ls -fld *(OL) # Sort the output from ls -l by file size +ls -fl *(DOL[1,5]) # Print only 5 lines by the ls command (is equal to: ls -laS | head -n 5) +ls -l *(G[users]) # Show only files are owned from group users +ls *(L0f.go-w.) # Show only empty files which nor group or world writable +ls *.c~foo.c # Show only all *.c files and ignore foo.c +print -rl /home/me/**/*(D/e{'reply=($REPLY/*(N[-1]:t))'}) # Find all directories, list their contents, and output the first item in the above list +print -rl /**/*~^*/path(|/*) # Find command to search for directory name instead of basename +print -l ~/*(ND.^w) # List files in the current directory that are not writable by the owner +print -rl -- *(Dmh+10^/) # List all files which have not been updated in the last 10 hours +print -rl -- **/*(Dom[1,10]) # List the ten newest files in directories and subdirectories (recursive) +print -rl -- /path/to/dir/**/*(D.om[5,10]) # Display the 5-10 last modified files +print -rl -- **/*.c(D.OL[1,10]:h) | sort -u # Print the path of the directories holding the ten biggest C regular files in the current directory and subdirectories +print directory/**/*(om[1]) # Find most recent file in a directory +for a in ./**/*\ *(Dod); do mv $a ${a:h}/${a:t:gs/ /_}; done # Remove spaces from filenames + + +### [ ARRAY VARIABLES ] ####################################################### + +var[1]=Hello +# <- meta.variable.shell variable.other.readwrite.shell +#^^ meta.variable.shell variable.other.readwrite.shell +# ^^^ meta.variable.shell meta.item-access.shell +# ^ punctuation.section.item-access.begin.shell - meta.string - string +# ^ meta.string.shell string.unquoted.shell - punctuation +# ^ punctuation.section.item-access.end.shell - meta.string - string +# ^ keyword.operator.assignment.shell +# ^^^^^ meta.string.shell string.unquoted.shell + +echo $var[1] World +#<- meta.function-call.identifier.shell support.function.shell +#^^^ meta.function-call.identifier.shell support.function.shell +# ^^^^^^^^^^^^^^ meta.function-call.arguments.shell +# ^^^^^^^ meta.string.shell meta.interpolation.parameter.shell +# ^^^ meta.item-access.shell - variable +# ^ punctuation.section.item-access.begin.shell - string +# ^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.item-access.end.shell - string +# ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation + + +############################################################################## +# 15.5 Parameters Set By The Shell +# https://zsh.sourceforge.io/Doc/Release/Parameters.html#Parameters-Set-By-The-Shell +############################################################################## + +: $ARGC +# ^^^^^ variable.language.builtin.shell +: $argv +# ^^^^^ variable.language.builtin.shell +: $status +# ^^^^^^^ variable.language.builtin.shell +: $pipestatus +# ^^^^^^^^^^^ variable.language.builtin.shell +: $CPUTYPE +# ^^^^^^^^ variable.language.builtin.shell +: $EGID +# ^^^^^ variable.language.builtin.shell +: $EUID +# ^^^^^ variable.language.builtin.shell +: $ERRNO +# ^^^^^^ variable.language.builtin.shell +: $FUNCNEST +# ^^^^^^^^^ variable.language.builtin.shell +: $GID +# ^^^^ variable.language.builtin.shell +: $HISTCMD +# ^^^^^^^^ variable.language.builtin.shell +: $HOST +# ^^^^^ variable.language.builtin.shell +: $LINENO +# ^^^^^^^ variable.language.builtin.shell +: $LOGNAME +# ^^^^^^^^ variable.language.builtin.shell +: $MACHTYPE +# ^^^^^^^^^ variable.language.builtin.shell +: $OLDPWD +# ^^^^^^^ variable.language.builtin.shell +: $OPTARG +# ^^^^^^^ variable.language.builtin.shell +: $OPTIND +# ^^^^^^^ variable.language.builtin.shell +: $OSTYPE +# ^^^^^^^ variable.language.builtin.shell +: $PPID +# ^^^^^ variable.language.builtin.shell +: $PWD +# ^^^^ variable.language.builtin.shell +: $RANDOM +# ^^^^^^^ variable.language.builtin.shell +: $SECONDS +# ^^^^^^^^ variable.language.builtin.shell +: $SHLVL +# ^^^^^^ variable.language.builtin.shell +: $signals +# ^^^^^^^^ variable.language.builtin.shell +: $TRY_BLOCK_ERROR +# ^^^^^^^^^^^^^^^^ variable.language.builtin.shell +: $TRY_BLOCK_INTERRUPT +# ^^^^^^^^^^^^^^^^^^^^ variable.language.builtin.shell +: $TTY +# ^^^^ variable.language.builtin.shell +: $TTYIDLE +# ^^^^^^^^ variable.language.builtin.shell +: $UID +# ^^^^ variable.language.builtin.shell +: $USERNAME +# ^^^^^^^^^ variable.language.builtin.shell +: $VENDOR +# ^^^^^^^ variable.language.builtin.shell +: $zsh_eval_context +# ^^^^^^^^^^^^^^^^^ variable.language.builtin.shell +: $ZSH_ARGZERO +# ^^^^^^^^^^^^ variable.language.builtin.shell +: $ZSH_EXECUTION_STRING +# ^^^^^^^^^^^^^^^^^^^^^ variable.language.builtin.shell +: $ZSH_NAME +# ^^^^^^^^^ variable.language.builtin.shell +: $ZSH_PATCHLEVEL +# ^^^^^^^^^^^^^^^ variable.language.builtin.shell +: $zsh_scheduled_events +# ^^^^^^^^^^^^^^^^^^^^^ variable.language.builtin.shell +: $ZSH_SCRIPT +# ^^^^^^^^^^^ variable.language.builtin.shell +: $ZSH_SUBSHELL +# ^^^^^^^^^^^^^ variable.language.builtin.shell +: $ZSH_VERSION +# ^^^^^^^^^^^^ variable.language.builtin.shell + +############################################################################## +# 15.6 Parameters Used By The Shell +# https://zsh.sourceforge.io/Doc/Release/Parameters.html#Parameters-Used-By-The-Shell +############################################################################## + +: $ARGV0 +# ^^^^^^ variable.language.builtin.shell +: $BAUD +# ^^^^^ variable.language.builtin.shell +: $cdpath +# ^^^^^^^ variable.language.builtin.shell +: $COLUMNS +# ^^^^^^^^ variable.language.builtin.shell +: $CORRECT_IGNORE +# ^^^^^^^^^^^^^^^ variable.language.builtin.shell +: $CORRECT_IGNORE_FILE +# ^^^^^^^^^^^^^^^^^^^^ variable.language.builtin.shell +: $DIRSTACKSIZE +# ^^^^^^^^^^^^^ variable.language.builtin.shell +: $ENV +# ^^^^ variable.language.builtin.shell +: $FCEDIT +# ^^^^^^^ variable.language.builtin.shell +: $fignore +# ^^^^^^^^ variable.language.builtin.shell +: $fpath +# ^^^^^^ variable.language.builtin.shell +: $histchars +# ^^^^^^^^^^ variable.language.builtin.shell +: $HISTCHARS +# ^^^^^^^^^^ variable.language.builtin.shell +: $HISTFILE +# ^^^^^^^^^ variable.language.builtin.shell +: $HISTORY_IGNORE +# ^^^^^^^^^^^^^^^ variable.language.builtin.shell +: $HISTSIZE +# ^^^^^^^^^ variable.language.builtin.shell +: $HOME +# ^^^^^ variable.language.builtin.shell +: $IFS +# ^^^^ variable.language.builtin.shell +: $KEYBOARD_HACK +# ^^^^^^^^^^^^^^ variable.language.builtin.shell +: $KEYTIMEOUT +# ^^^^^^^^^^^ variable.language.builtin.shell +: $LANG +# ^^^^^ variable.language.builtin.shell +: $LC_ALL +# ^^^^^^^ variable.language.builtin.shell +: $LC_COLLATE +# ^^^^^^^^^^^ variable.language.builtin.shell +: $LC_CTYPE +# ^^^^^^^^^ variable.language.builtin.shell +: $LC_MESSAGES +# ^^^^^^^^^^^^ variable.language.builtin.shell +: $LC_NUMERIC +# ^^^^^^^^^^^ variable.language.builtin.shell +: $LC_TIME +# ^^^^^^^^ variable.language.builtin.shell +: $LINES +# ^^^^^^ variable.language.builtin.shell +: $LISTMAX +# ^^^^^^^^ variable.language.builtin.shell +: $MAIL +# ^^^^^ variable.language.builtin.shell +: $MAILCHECK +# ^^^^^^^^^^ variable.language.builtin.shell +: $mailpath +# ^^^^^^^^^ variable.language.builtin.shell +: $manpath +# ^^^^^^^^ variable.language.builtin.shell +: $match +# ^^^^^^ variable.language.builtin.shell +: $mbegin +# ^^^^^^^ variable.language.builtin.shell +: $mend +# ^^^^^ variable.language.builtin.shell +: $MATCH +# ^^^^^^ variable.language.builtin.shell +: $MBEGIN +# ^^^^^^^ variable.language.builtin.shell +: $MEND +# ^^^^^ variable.language.builtin.shell +: $module_path +# ^^^^^^^^^^^^ variable.language.builtin.shell +: $NULLCMD +# ^^^^^^^^ variable.language.builtin.shell +: $path +# ^^^^^ variable.language.builtin.shell +: $POSTEDIT +# ^^^^^^^^^ variable.language.builtin.shell +: $PROMPT +# ^^^^^^^ variable.language.builtin.shell +: $PROMPT2 +# ^^^^^^^^ variable.language.builtin.shell +: $PROMPT3 +# ^^^^^^^^ variable.language.builtin.shell +: $PROMPT4 +# ^^^^^^^^ variable.language.builtin.shell +: $prompt +# ^^^^^^^ variable.language.builtin.shell +: $PROMPT_EOL_MARK +# ^^^^^^^^^^^^^^^^ variable.language.builtin.shell +: $PS1 +# ^^^^ variable.language.builtin.shell +: $PS2 +# ^^^^ variable.language.builtin.shell +: $PS3 +# ^^^^ variable.language.builtin.shell +: $PS4 +# ^^^^ variable.language.builtin.shell +: $psvar +# ^^^^^^ variable.language.builtin.shell +: $READNULLCMD +# ^^^^^^^^^^^^ variable.language.builtin.shell +: $REPORTMEMORY +# ^^^^^^^^^^^^^ variable.language.builtin.shell +: $REPORTTIME +# ^^^^^^^^^^^ variable.language.builtin.shell +: $REPLY +# ^^^^^^ variable.language.builtin.shell +: $reply +# ^^^^^^ variable.language.builtin.shell +: $RPROMPT +# ^^^^^^^^ variable.language.builtin.shell +: $RPS1 +# ^^^^^ variable.language.builtin.shell +: $RPROMPT2 +# ^^^^^^^^^ variable.language.builtin.shell +: $RPS2 +# ^^^^^ variable.language.builtin.shell +: $SAVEHIST +# ^^^^^^^^^ variable.language.builtin.shell +: $SPROMPT +# ^^^^^^^^ variable.language.builtin.shell +: $STTY +# ^^^^^ variable.language.builtin.shell +: $TERM +# ^^^^^ variable.language.builtin.shell +: $TERMINFO +# ^^^^^^^^^ variable.language.builtin.shell +: $TERMINFO_DIRS +# ^^^^^^^^^^^^^^ variable.language.builtin.shell +: $TIMEFMT +# ^^^^^^^^ variable.language.builtin.shell +: $TMOUT +# ^^^^^^ variable.language.builtin.shell +: $TMPPREFIX +# ^^^^^^^^^^ variable.language.builtin.shell +: $TMPSUFFIX +# ^^^^^^^^^^ variable.language.builtin.shell +: $WORDCHARS +# ^^^^^^^^^^ variable.language.builtin.shell +: $ZBEEP +# ^^^^^^ variable.language.builtin.shell +: $ZDOTDIR +# ^^^^^^^^ variable.language.builtin.shell +: $zle_bracketed_paste +# ^^^^^^^^^^^^^^^^^^^^ variable.language.builtin.shell +: $zle_highlight +# ^^^^^^^^^^^^^^ variable.language.builtin.shell +: $ZLE_LINE_ABORTED +# ^^^^^^^^^^^^^^^^^ variable.language.builtin.shell +: $ZLE_REMOVE_SUFFIX_CHARS +# ^^^^^^^^^^^^^^^^^^^^^^^^ variable.language.builtin.shell +: $ZLE_SPACE_SUFFIX_CHARS +# ^^^^^^^^^^^^^^^^^^^^^^^ variable.language.builtin.shell +: $ZLE_RPROMPT_INDENT +# ^^^^^^^^^^^^^^^^^^^ variable.language.builtin.shell diff --git a/ShellScript/test/syntax_test_reindent_until.bash b/ShellScript/test/syntax_test_reindent_until.bash deleted file mode 100644 index bb9772bbce..0000000000 --- a/ShellScript/test/syntax_test_reindent_until.bash +++ /dev/null @@ -1,32 +0,0 @@ -# SYNTAX TEST reindent-unchanged "Packages/ShellScript/Bash.sublime-syntax" - -until (( $var > 10 )); do echo $var; (( $var += 1 )); done; - -# --- - -until (( $var > 10 )); do echo $var; (( $var += 1 )); -done; - -# --- - -until (( $var > 10 )); do - echo $var; - (( $var += 1 )); -done; - -# --- - -until (( $var > 10 )) -do - echo $var; - (( $var += 1 )); -done; - -# --- - -until - (( $var > 10 )) -do - echo $var; - (( $var += 1 )); -done; diff --git a/ShellScript/test/syntax_test_reindent_while.bash b/ShellScript/test/syntax_test_reindent_while.bash deleted file mode 100644 index 87fa3aea90..0000000000 --- a/ShellScript/test/syntax_test_reindent_while.bash +++ /dev/null @@ -1,32 +0,0 @@ -# SYNTAX TEST reindent-unchanged "Packages/ShellScript/Bash.sublime-syntax" - -while (( $var < 10 )); do echo $var; (( $var += 1 )); done; - -# --- - -while (( $var < 10 )); do echo $var; (( $var += 1 )); -done; - -# --- - -while (( $var < 10 )); do - echo $var; - (( $var += 1 )); -done; - -# --- - -while (( $var < 10 )) -do - echo $var; - (( $var += 1 )); -done; - -# --- - -while - (( $var < 10 )) -do - echo $var; - (( $var += 1 )); -done; From d2b8e15571f659fca1d5214befc38affa3f50854 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 4 Aug 2024 14:46:04 +0200 Subject: [PATCH 056/113] [Markdown] Adjust tests and add zsh code fences --- Markdown/Markdown.sublime-syntax | 22 +++++++++++++- Markdown/Shell (for Markdown).sublime-syntax | 16 +++++----- Markdown/tests/syntax_test_markdown.md | 31 +++++++++++++------- 3 files changed, 49 insertions(+), 20 deletions(-) diff --git a/Markdown/Markdown.sublime-syntax b/Markdown/Markdown.sublime-syntax index 2185b0e70c..4c65f033b3 100644 --- a/Markdown/Markdown.sublime-syntax +++ b/Markdown/Markdown.sublime-syntax @@ -1953,7 +1953,7 @@ contexts: - match: |- (?x) {{fenced_code_block_start}} - (?i:\s*(shell-script|sh|bash|zsh)) + (?i:\s*(shell-script|sh|bash)) {{fenced_code_block_trailing_infostring_characters}} captures: 0: meta.code-fence.definition.begin.shell-script.markdown-gfm @@ -1970,6 +1970,26 @@ contexts: 0: meta.code-fence.definition.end.shell-script.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown 2: meta.fold.code-fence.end.markdown + - match: |- + (?x) + {{fenced_code_block_start}} + (?i:\s*(zsh)) + {{fenced_code_block_trailing_infostring_characters}} + captures: + 0: meta.code-fence.definition.begin.shell-script.markdown-gfm + 2: punctuation.definition.raw.code-fence.begin.markdown + 5: constant.other.language-name.markdown + 6: comment.line.infostring.markdown + 7: meta.fold.code-fence.begin.markdown + embed: scope:source.shell.zsh + embed_scope: + markup.raw.code-fence.shell-script.markdown-gfm + source.shell.zsh + escape: '{{fenced_code_block_escape}}' + escape_captures: + 0: meta.code-fence.definition.end.shell-script.markdown-gfm + 1: punctuation.definition.raw.code-fence.end.markdown + 2: meta.fold.code-fence.end.markdown fenced-sql: - match: |- diff --git a/Markdown/Shell (for Markdown).sublime-syntax b/Markdown/Shell (for Markdown).sublime-syntax index 4abc326da9..92486b1383 100644 --- a/Markdown/Shell (for Markdown).sublime-syntax +++ b/Markdown/Shell (for Markdown).sublime-syntax @@ -8,14 +8,6 @@ hidden: true extends: Packages/ShellScript/Shell-Unix-Generic.sublime-syntax contexts: - prototype: - - meta_prepend: true - # continuation lines begin with `> ` - - match: ^\s*(>)\s - captures: - 1: comment.other.shell - scope: comment.other.shell - main: - match: ^(?=\s*\$\s) push: shell-interactive @@ -27,3 +19,11 @@ contexts: 1: comment.other.shell embed: statements escape: (? ` + - match: ^\s*(>)\s + captures: + 1: comment.other.shell + pop: 1 diff --git a/Markdown/tests/syntax_test_markdown.md b/Markdown/tests/syntax_test_markdown.md index 92e5e9e3d6..9d6afddc03 100644 --- a/Markdown/tests/syntax_test_markdown.md +++ b/Markdown/tests/syntax_test_markdown.md @@ -1790,7 +1790,7 @@ foo # test | ^^^^^ source.shell comment.line.number-sign echo hello, \ -| ^^ punctuation.separator.continuation.line +| ^ punctuation.separator.continuation.line echo This is a smiley :-\) \(I have to escape the parentheses, though!\) | ^^ constant.character.escape ``` @@ -1985,7 +1985,7 @@ var_dump(expression); ```python |^^^^^^^^ meta.code-fence.definition.begin - meta.fold - markup -| ^ meta.code-fence.definition.begin meta.fold.code-fence.begin - merkup +| ^ meta.code-fence.definition.begin meta.fold.code-fence.begin - markup |^^ punctuation.definition.raw.code-fence.begin | ^^^^^^ constant.other.language-name def function(): @@ -2000,7 +2000,7 @@ unclosed_paren = ( ```regex |^^^^^^^ meta.code-fence.definition.begin - meta.fold - markup -| ^ meta.code-fence.definition.begin meta.fold.code-fence.begin - merkup +| ^ meta.code-fence.definition.begin meta.fold.code-fence.begin - markup (?x) \s+ | <- markup.raw.code-fence.regexp.markdown-gfm source.regexp @@ -2011,7 +2011,7 @@ unclosed_paren = ( ```scala |^^^^^^^ meta.code-fence.definition.begin - meta.fold - markup -| ^ meta.code-fence.definition.begin meta.fold.code-fence.begin - merkup +| ^ meta.code-fence.definition.begin meta.fold.code-fence.begin - markup | <- markup.raw.code-fence.scala.markdown-gfm source.scala ``` @@ -2021,7 +2021,7 @@ unclosed_paren = ( ```sh |^^^^ meta.code-fence.definition.begin - meta.fold - markup -| ^ meta.code-fence.definition.begin meta.fold.code-fence.begin - merkup +| ^ meta.code-fence.definition.begin meta.fold.code-fence.begin - markup | <- markup.raw.code-fence.shell-script.markdown-gfm source.shell.bash ``` @@ -2030,12 +2030,12 @@ unclosed_paren = ( ```shell |^^^^^^^ meta.code-fence.definition.begin - meta.fold - markup -| ^ meta.code-fence.definition.begin meta.fold.code-fence.begin - merkup +| ^ meta.code-fence.definition.begin meta.fold.code-fence.begin - markup function foo () { | <- markup.raw.code-fence.shell.markdown-gfm source.shell.interactive.markdown meta.function.shell keyword.declaration.function.shell } -| <- markup.raw.code-fence.shell.markdown-gfm source.shell.interactive.markdown meta.function.shell meta.compound.shell punctuation.section.compound.end.shell +| <- markup.raw.code-fence.shell.markdown-gfm source.shell.interactive.markdown meta.function.body.shell meta.block.shell punctuation.section.block.end.shell $ ls ~ | <- markup.raw.code-fence.shell.markdown-gfm source.shell.interactive comment.other.shell @@ -2067,7 +2067,7 @@ function foo () {} ```shell | ^^^^^^^^ meta.code-fence.definition.begin - meta.fold - markup -| ^ meta.code-fence.definition.begin meta.fold.code-fence.begin - merkup +| ^ meta.code-fence.definition.begin meta.fold.code-fence.begin - markup $ ls | ^^^^^ markup.raw.code-fence.shell.markdown-gfm source.shell.interactive.markdown | ^ comment.other.shell @@ -2083,9 +2083,18 @@ function foo () {} | <- meta.code-fence.definition.end.shell-script.markdown-gfm punctuation.definition.raw.code-fence.end.markdown |^^ meta.code-fence.definition.end.shell-script.markdown-gfm punctuation.definition.raw.code-fence.end.markdown +```zsh +|^^^^^ meta.code-fence.definition.begin - meta.fold - markup +| ^ meta.code-fence.definition.begin meta.fold.code-fence.begin - markup + +| <- markup.raw.code-fence.shell-script.markdown-gfm source.shell.zsh +``` +| <- meta.code-fence.definition.end.shell-script.markdown-gfm punctuation.definition.raw.code-fence.end.markdown +|^^ meta.code-fence.definition.end.shell-script.markdown-gfm punctuation.definition.raw.code-fence.end.markdown + ```sql |^^^^^ meta.code-fence.definition.begin - meta.fold - markup -| ^ meta.code-fence.definition.begin meta.fold.code-fence.begin - merkup +| ^ meta.code-fence.definition.begin meta.fold.code-fence.begin - markup |^^ punctuation.definition.raw.code-fence.begin.markdown | ^^^ constant.other.language-name SELECT TOP 10 * @@ -2112,7 +2121,7 @@ declare type foo = 'bar' ```xml |^^^^^ meta.code-fence.definition.begin - meta.fold - markup -| ^ meta.code-fence.definition.begin meta.fold.code-fence.begin - merkup +| ^ meta.code-fence.definition.begin meta.fold.code-fence.begin - markup |^^ punctuation.definition.raw.code-fence.begin.markdown | ^^^ constant.other.language-name @@ -2128,7 +2137,7 @@ declare type foo = 'bar' ```jsx:file.jsx |^^^^^^^^^^^^^^ meta.code-fence.definition.begin - meta.fold - markup -| ^ meta.code-fence.definition.begin meta.fold.code-fence.begin - merkup +| ^ meta.code-fence.definition.begin meta.fold.code-fence.begin - markup |^^ punctuation.definition.raw.code-fence.begin.markdown | ^^^ constant.other.language-name.markdown | ^^^^^^^^^ comment.line.infostring.markdown From 8ba9bf2ce38518ad888d13980a04f530523888fd Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 4 Aug 2024 15:14:14 +0200 Subject: [PATCH 057/113] [ShellScript] Fix symbol definitions --- .../Bash/tests/syntax_test_symbol.bash | 86 +++++++++++++++++ .../Reference List - Functions.tmPreferences | 20 ++++ .../Shell/Symbol List - Coproc.tmPreferences | 18 ---- .../Symbol List - Functions.tmPreferences | 17 +++- ShellScript/Zsh/tests/syntax_test_symbol.zsh | 96 +++++++++++++++++++ 5 files changed, 216 insertions(+), 21 deletions(-) create mode 100644 ShellScript/Bash/tests/syntax_test_symbol.bash create mode 100644 ShellScript/Shell/Reference List - Functions.tmPreferences delete mode 100644 ShellScript/Shell/Symbol List - Coproc.tmPreferences create mode 100644 ShellScript/Zsh/tests/syntax_test_symbol.zsh diff --git a/ShellScript/Bash/tests/syntax_test_symbol.bash b/ShellScript/Bash/tests/syntax_test_symbol.bash new file mode 100644 index 0000000000..3b9743986f --- /dev/null +++ b/ShellScript/Bash/tests/syntax_test_symbol.bash @@ -0,0 +1,86 @@ +# SYNTAX TEST "Packages/ShellScript/Bash.sublime-syntax" + +############################################################################### +# ALIAS symbols +############################################################################### + +alias myabbr="git \"status\"" +# @@@@@@ definition +# @@@ reference + + myabbr +# @@@@@@ reference + +( myabbr ) +# @@@@@@ reference + +{ myabbr } +# @@@@@@ reference + +var=`myabbr` +# @@@@@@ reference + + unalias myabbr +# @@@@@@@ reference +# @@@@@@ reference + +############################################################################### +# COPROC symbols +############################################################################### + +coproc proc { func1 running } +# @@@@ definition +# @@@@@ reference + +############################################################################### +# FUNCTION symbols +############################################################################### + +function func1() { func2() } +# @@@@@ definition +# @@@@@ definition + +function $fname() +# @@@@@@ definition + +function f$name() +# @@@@@@ definition + +function f${name:$start:5}() +# @@@@@@@@@@@@@@@@@ definition + + func3() +# @@@@@ definition + + func3 +# @@@@@ reference + + 'func3' +# @@@@@ reference + + "func3" +# @@@@@ reference + +( func3 ) +# @@@@@ reference + +{ func3 } +# @@@@@ reference + + trap 'func3' SIGTERM +# @@@@ reference +# @@@@@ reference + + trap "func3" SIGTERM +# @@@@ reference +# @@@@@ reference + + trap `func3` SIGTERM +# @@@@ reference +# @@@@@ reference + + /usr/bin/app arg +# @@@@@@@@@@@@ reference + + ~/.bin/**/app?[Nn]ame arg +# @@@@@@@@@@@@@@@@@@@@@ reference diff --git a/ShellScript/Shell/Reference List - Functions.tmPreferences b/ShellScript/Shell/Reference List - Functions.tmPreferences new file mode 100644 index 0000000000..9c57bbdca0 --- /dev/null +++ b/ShellScript/Shell/Reference List - Functions.tmPreferences @@ -0,0 +1,20 @@ + + + + scope + + meta.function-call.identifier.shell variable.function, + meta.function-call.identifier.shell meta.interpolation + + settings + + showInIndexedReferenceList + 1 + symbolIndexTransformation + + s/\\\n//g; + s/['"]//g; + + + + diff --git a/ShellScript/Shell/Symbol List - Coproc.tmPreferences b/ShellScript/Shell/Symbol List - Coproc.tmPreferences deleted file mode 100644 index 216eb9212e..0000000000 --- a/ShellScript/Shell/Symbol List - Coproc.tmPreferences +++ /dev/null @@ -1,18 +0,0 @@ - - - - scope - entity.name.coproc.shell - settings - - showInSymbolList - 1 - showInIndexedSymbolList - 1 - symbolTransformation - s/\\\n//g; - symbolIndexTransformation - s/\\\n//g; - - - diff --git a/ShellScript/Shell/Symbol List - Functions.tmPreferences b/ShellScript/Shell/Symbol List - Functions.tmPreferences index fbcfd3dd4c..9d56a46237 100644 --- a/ShellScript/Shell/Symbol List - Functions.tmPreferences +++ b/ShellScript/Shell/Symbol List - Functions.tmPreferences @@ -2,7 +2,12 @@ scope - entity.name.function.shell + + meta.coproc.identifier.shell entity.name.function, + meta.coproc.identifier.shell meta.interpolation, + meta.function.identifier.shell entity.name.function, + meta.function.identifier.shell meta.interpolation + settings showInSymbolList @@ -10,9 +15,15 @@ showInIndexedSymbolList 1 symbolTransformation - s/\\\n//g; + + s/\\\n//g; + s/['"]//g; + symbolIndexTransformation - s/\\\n//g; + + s/\\\n//g; + s/['"]//g; + diff --git a/ShellScript/Zsh/tests/syntax_test_symbol.zsh b/ShellScript/Zsh/tests/syntax_test_symbol.zsh new file mode 100644 index 0000000000..2396b1b23f --- /dev/null +++ b/ShellScript/Zsh/tests/syntax_test_symbol.zsh @@ -0,0 +1,96 @@ +# SYNTAX TEST "Packages/ShellScript/Zsh.sublime-syntax" + +############################################################################### +# ALIAS symbols +############################################################################### + +alias myabbr="git \"status\"" +# @@@@@@ definition +# @@@ reference + + myabbr +# @@@@@@ reference + +( myabbr ) +# @@@@@@ reference + +{ myabbr } +# @@@@@@ reference + +var=`myabbr` +# @@@@@@ reference + + unalias myabbr +# @@@@@@@ reference +# @@@@@@ reference + +############################################################################### +# COPROC symbols +############################################################################### + +coproc proc { func1 running } +# @@@@ definition +# @@@@@ reference + +############################################################################### +# FUNCTION symbols +############################################################################### + +function func1() { func2() } +# @@@@@ definition +# @@@@@ definition + +function $fname() +# @@@@@@ definition + +function f$name() +# @@@@@@ definition + +function f${name:$start:5}() +# @@@@@@@@@@@@@@@@@ definition + + func3() +# @@@@@ definition + + func3 +# @@@@@ reference + + 'func3' +# @@@@@ reference + + "func3" +# @@@@@ reference + +( func3 ) +# @@@@@ reference + +{ func3 } +# @@@@@ reference + + trap 'func3' SIGTERM +# @@@@ reference +# @@@@@ reference + + trap "func3" SIGTERM +# @@@@ reference +# @@@@@ reference + + trap `func3` SIGTERM +# @@@@ reference +# @@@@@ reference + + /usr/bin/app arg +# @@@@@@@@@@@@ reference + + ~/.bin/**/app?[Nn]ame arg +# @@@@@@@@@@@@@@@@@@@@@ reference + +############################################################################### +# ZSH SPECIAL FUNCTION symbols +############################################################################### + + zshexit() {} +# @@@@@@@ definition + + TRAPEXIT() {} +# @@@@@@@@ definition From f31dca10eaced82f04d45b57c1d93e2e5ca59a4a Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 4 Aug 2024 20:38:48 +0200 Subject: [PATCH 058/113] [ShellScript] Refactor HEREDOC This commit... 1. implements heredocs by top-most `embed...escape` pattern. This... - reduces compiled syntax cache size from 100kB to 90kB - reliably terminates heredoc strings with a single `escape` pattern - reduces syntax definition complexity and repetitions 2. restricts `meta.string.heredoc` scope to the string part excluding lines of opening and closing HEREDOC tags. That's required for herdoc specific indentation rules. --- ShellScript/Bash.sublime-syntax | 190 ++++++------------ .../tests/syntax_test_reindent_heredoc.bash | 100 +++++++++ ShellScript/Bash/tests/syntax_test_scope.bash | 149 +++++++------- .../Indentation Rules - Heredoc.tmPreferences | 17 ++ ShellScript/Zsh/tests/syntax_test_scope.zsh | 7 +- 5 files changed, 259 insertions(+), 204 deletions(-) create mode 100644 ShellScript/Bash/tests/syntax_test_reindent_heredoc.bash create mode 100644 ShellScript/Shell/Indentation Rules - Heredoc.tmPreferences diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index ec44679902..e9e52f8b29 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -54,6 +54,12 @@ variables: opt_punctuation: (--|[-+])(?={{word_char}}) opt_break: (?![^={{metachar}}]) + # HEREDOC tag names + heredoc: '{{heredoc_first_char}}{{heredoc_char}}*' + heredoc_first_char: '[[:alpha:]_]' + heredoc_char: '[[:alnum:]_.-]' + heredoc_break: (?!{{heredoc_char}}) + # Variable names variable_begin: (?={{variable_first_char}}) variable_first_char: '[[:alpha:]_''"$%]' @@ -1937,117 +1943,70 @@ contexts: 2: keyword.operator.herestring.shell redirections-here-document: - # These are the variants that allow tabs before the end token - - match: (\d*)(<<-)\s*((')({{identifier}})(')) - captures: - 1: meta.file-descriptor.shell - meta.number.integer.decimal.shell - constant.numeric.value.shell - 2: keyword.operator.assignment.redirection.shell - 3: meta.string.heredoc.shell meta.tag.heredoc.shell - 4: punctuation.definition.tag.begin.shell - 5: entity.name.tag.heredoc.shell - 6: punctuation.definition.tag.end.shell - push: [heredocs-body-allow-tabs-no-expansion, heredocs-preamble, cmd-args] - - match: (\d*)(<<-)\s*((")({{identifier}})(")) - captures: - 1: meta.file-descriptor.shell - meta.number.integer.decimal.shell - constant.numeric.value.shell - 2: keyword.operator.assignment.redirection.shell - 3: meta.string.heredoc.shell meta.tag.heredoc.shell - 4: punctuation.definition.tag.begin.shell - 5: entity.name.tag.heredoc.shell - 6: punctuation.definition.tag.end.shell - push: [heredocs-body-allow-tabs-no-expansion, heredocs-preamble, cmd-args] - - match: (\d*)(<<-)\s*((\\)({{identifier}})) - captures: - 1: meta.file-descriptor.shell - meta.number.integer.decimal.shell - constant.numeric.value.shell - 2: keyword.operator.assignment.redirection.shell - 3: meta.string.heredoc.shell meta.tag.heredoc.shell - 4: punctuation.definition.tag.shell - 5: entity.name.tag.heredoc.shell - push: [heredocs-body-allow-tabs-no-expansion, heredocs-preamble, cmd-args] - - match: (\d*)(<<-)\s*({{identifier}}) + - match: (\d*)(<<-)\s*(?=["'\\]?({{heredoc}})) captures: 1: meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell 2: keyword.operator.assignment.redirection.shell - 3: meta.string.heredoc.shell meta.tag.heredoc.shell entity.name.tag.heredoc.shell - push: [heredocs-body-allow-tabs, heredocs-preamble, cmd-args] - # These are the variants that DON'T allow tabs before the end token - - match: (\d*)(<<)\s*((')({{identifier}})(')) - captures: - 1: meta.file-descriptor.shell - meta.number.integer.decimal.shell - constant.numeric.value.shell - 2: keyword.operator.assignment.redirection.shell - 3: meta.string.heredoc.shell meta.tag.heredoc.shell - 4: punctuation.definition.tag.begin.shell - 5: entity.name.tag.heredoc.shell - 6: punctuation.definition.tag.end.shell - push: [heredocs-body-no-expansion, heredocs-preamble, cmd-args] - - match: (\d*)(<<)\s*((")({{identifier}})(")) - captures: - 1: meta.file-descriptor.shell - meta.number.integer.decimal.shell - constant.numeric.value.shell - 2: keyword.operator.assignment.redirection.shell - 3: meta.string.heredoc.shell meta.tag.heredoc.shell - 4: punctuation.definition.tag.begin.shell - 5: entity.name.tag.heredoc.shell - 6: punctuation.definition.tag.end.shell - push: [heredocs-body-no-expansion, heredocs-preamble, cmd-args] - - match: (\d*)(<<)\s*((\\)({{identifier}})) - captures: - 1: meta.file-descriptor.shell - meta.number.integer.decimal.shell - constant.numeric.value.shell - 2: keyword.operator.assignment.redirection.shell - 3: meta.string.heredoc.shell meta.tag.heredoc.shell - 4: punctuation.definition.tag.shell - 5: entity.name.tag.heredoc.shell - push: [heredocs-body-no-expansion, heredocs-preamble, cmd-args] - - match: (\d*)(<<)\s*({{identifier}}) + embed: heredoc-begin + escape: ^\t*(\3)$\n? + escape_captures: + 0: meta.tag.heredoc.end.shell + 1: entity.name.tag.heredoc.shell + - match: (\d*)(<<)\s*(?=["'\\]?({{heredoc}})) captures: 1: meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell 2: keyword.operator.assignment.redirection.shell - 3: meta.string.heredoc.shell meta.tag.heredoc.shell entity.name.tag.heredoc.shell - push: [heredocs-body, heredocs-preamble, cmd-args] + embed: heredoc-begin + escape: ^(\3)$\n? + escape_captures: + 0: meta.tag.heredoc.end.shell + 1: entity.name.tag.heredoc.shell - heredocs-body: - - meta_scope: meta.string.heredoc.shell - - meta_content_scope: string.unquoted.heredoc.shell - - include: heredocs-body-common-with-expansion - - match: ^\3$ # the third capture from redirections-here-document - scope: meta.tag.heredoc.shell entity.name.tag.heredoc.shell - pop: 1 - - match: ^\3(\s+)\n # the third capture from redirections-here-document + heredoc-begin: + # These are the variants that allow tabs before the end token + - match: (')({{heredoc}})(') + scope: meta.tag.heredoc.begin.shell captures: - 1: invalid.illegal.unexpected-whitespace.shell - # rather not pop, but sublime throws an error otherwise. - pop: 1 - - heredocs-body-allow-tabs: - - meta_scope: meta.string.heredoc.shell - - meta_content_scope: string.unquoted.heredoc.shell - - include: heredocs-body-common-with-expansion - - match: ^\t*(\3)$ # the third capture from redirections-here-document + 1: punctuation.definition.tag.begin.shell + 2: entity.name.tag.heredoc.shell + 3: punctuation.definition.tag.end.shell + push: + - heredoc-preamble-no-expansion + - cmd-args + - match: (")({{heredoc}})(") + scope: meta.tag.heredoc.begin.shell captures: - 1: meta.tag.heredoc.shell entity.name.tag.heredoc.shell - pop: 1 - - match: ^\t*\3(\s+)\n # the third capture from redirections-here-document + 1: punctuation.definition.tag.begin.shell + 2: entity.name.tag.heredoc.shell + 3: punctuation.definition.tag.end.shell + push: + - heredoc-preamble-no-expansion + - cmd-args + - match: (\\)({{heredoc}}) + scope: meta.tag.heredoc.begin.shell captures: - 1: invalid.illegal.unexpected-whitespace.shell - # rather not pop, but sublime throws an error otherwise. - pop: 1 + 1: punctuation.definition.tag.shell + 2: entity.name.tag.heredoc.shell + push: + - heredoc-preamble-no-expansion + - cmd-args + - match: '{{heredoc}}' + scope: meta.tag.heredoc.begin.shell entity.name.tag.heredoc.shell + push: + - heredoc-preamble + - cmd-args - heredocs-body-common-with-expansion: + heredoc-preamble: + - match: ^ + set: heredoc-body + - include: statements + + heredoc-body: + - meta_scope: meta.string.heredoc.shell string.unquoted.heredoc.shell # [Bash] 3.6.6: all lines of the here-document are subjected to parameter # expansion, command substitution, and arithmetic expansion, the character # sequence \newline is ignored, and ‘\’ must be used to quote the @@ -2056,43 +2015,14 @@ contexts: - include: brace-interpolations - include: string-interpolations - heredocs-body-no-expansion: - - meta_scope: meta.string.heredoc.shell - - meta_content_scope: string.unquoted.heredoc.shell - - match: ^\5$ # the fourth capture from redirections-here-document - scope: meta.tag.heredoc.shell entity.name.tag.heredoc.shell - pop: 1 - - match: ^\5(\s+)\n # the fourth capture from redirections-here-document - captures: - 1: invalid.illegal.unexpected-whitespace.shell - # rather not pop, but sublime throws an error otherwise. - pop: 1 - - heredocs-body-allow-tabs-no-expansion: - - meta_scope: meta.string.heredoc.shell - - meta_content_scope: string.unquoted.heredoc.shell - - match: ^\t*(\5)$ # the fourth capture from redirections-here-document - captures: - 1: meta.tag.heredoc.shell entity.name.tag.heredoc.shell - pop: 1 - - match: ^\t*\5(\s+)\n # the fourth capture from redirections-here-document - captures: - 1: invalid.illegal.unexpected-whitespace.shell - # rather not pop, but sublime throws an error otherwise. - pop: 1 - - heredocs-preamble: - # This enables us to keep parsing on the line where the start token of - # the heredoc is. Once the first line has ended, we enter the body of - # the heredoc, where everything is just an unquoted string. - # One clear_scope for the string.unquoted. - # The problem with this is that when we also end a function definition - # on the same line (with the "}" token), we cannot do that. - - clear_scopes: 1 + heredoc-preamble-no-expansion: - match: ^ - pop: 1 + set: heredoc-body-no-expansion - include: statements + heredoc-body-no-expansion: + - meta_scope: meta.string.heredoc.shell string.unquoted.heredoc.shell + ###[ LITERALS ]################################################################ booleans: diff --git a/ShellScript/Bash/tests/syntax_test_reindent_heredoc.bash b/ShellScript/Bash/tests/syntax_test_reindent_heredoc.bash new file mode 100644 index 0000000000..5f1d3eb885 --- /dev/null +++ b/ShellScript/Bash/tests/syntax_test_reindent_heredoc.bash @@ -0,0 +1,100 @@ +# SYNTAX TEST reindent-unchanged "Packages/ShellScript/Bash.sublime-syntax" + +doc=<<'EOF' + # Markdown + + 1. list item + + ```sh + #!/usr/bin/env bash + + if [[ $var == 1 ]]; then + echo 1; + elif [[ $var == 2 ]]; then + echo 2; + else + echo nothing; + fi; + ``` + + - sub list item + followed by something + - sub list item + followed by something +EOF + +function foo() { + + heredoc1=<<'EOF' + # Markdown + + 1. list item + + ```sh + #!/usr/bin/env bash + + if [[ $var == 1 ]]; then + echo 1; + elif [[ $var == 2 ]]; then + echo 2; + else + echo nothing; + fi; + ``` + + - sub list item + followed by something + - sub list item + followed by something +EOF + + if [[ -z heredoc2 ]]; then + heredoc2=<<-'EOF' ; if true goto + # Markdown + + 1. list item + + ```sh + #!/usr/bin/env bash + + if [[ $var == 1 ]]; then + echo 1; + elif [[ $var == 2 ]]; then + echo 2; + else + echo nothing; + fi; + ``` + + - sub list item + followed by something + - sub list item + followed by something + EOF + fi; + + if [[ -z heredoc2 ]]; then + heredoc2=<<-'EOF' ; if true goto + # Markdown + + 1. list item + + ```sh + #!/usr/bin/env bash + + if [[ $var == 1 ]]; then + echo 1; + elif [[ $var == 2 ]]; then + echo 2; + else + echo nothing; + fi; + ``` + + - sub list item + followed by something + - sub list item + followed by something + EOF + fi; +} \ No newline at end of file diff --git a/ShellScript/Bash/tests/syntax_test_scope.bash b/ShellScript/Bash/tests/syntax_test_scope.bash index b2b905edb0..95681bf816 100644 --- a/ShellScript/Bash/tests/syntax_test_scope.bash +++ b/ShellScript/Bash/tests/syntax_test_scope.bash @@ -2356,8 +2356,8 @@ cat <<'ENDCAT' # comment # <- meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.identifier.shell meta.path.shell variable.function.shell #^^ meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.identifier.shell meta.path.shell variable.function.shell # ^^ meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.arguments.shell - meta.string - meta.tag -# ^^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.arguments.shell meta.string.heredoc.shell meta.tag.heredoc.shell - string.unquoted.heredoc -# ^^^^^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.arguments.shell meta.string.heredoc.shell - meta.tag - string.unquoted.heredoc +# ^^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.arguments.shell meta.tag.heredoc.begin.shell - string.unquoted.heredoc +# ^^^^^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.arguments.shell - meta.tag - string.unquoted.heredoc # ^^ keyword.operator.assignment.redirection.shell # ^ punctuation.definition.tag.begin.shell - entity # ^^^^^^ entity.name.tag.heredoc.shell @@ -2367,7 +2367,7 @@ cat <<'ENDCAT' # comment foo # <- meta.function-call.arguments.shell meta.string.heredoc.shell string.unquoted.heredoc.shell ENDCAT -# <- meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.arguments.shell meta.string.heredoc.shell meta.tag.heredoc.shell entity.name.tag.heredoc.shell +# <- meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.arguments.shell meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell ;; # <- meta.statement.conditional.case.body.shell meta.clause.shell punctuation.terminator.clause.shell #^ meta.statement.conditional.case.body.shell meta.clause.shell punctuation.terminator.clause.shell @@ -9141,17 +9141,18 @@ exec >&${tee[1]} 2>&1 ############################################################################### var=world! -cat < foo.txt -#^^^^^^ - meta.string - meta.tag -# ^^^^^^^^^^^^^^^^^^^^^^ meta.string.heredoc.shell meta.tag.heredoc.shell - string.unquoted.heredoc -# ^^^^^^^^^^^ meta.string.heredoc.shell - meta.tag - string.unquoted.heredoc +#^^^^^^ - meta.tag - meta.string - string +# ^^^^^^^^^^^^^^^^^^^^^^ meta.tag.heredoc.begin.shell - meta.string - string +# ^^^ - meta.tag - meta.string - string +# ^^^^^^^ meta.redirection.shell meta.string.shell string.unquoted.shell - meta.string.heredoc # ^^ keyword.operator.assignment.redirection.shell # ^ - entiy - keyword # ^^^^^^^^^^^^^^^^^^^^^^ entity.name.tag.heredoc.shell @@ -9245,14 +9248,14 @@ cat << redirection_comes_next > foo.txt hello # <- meta.function-call.arguments.shell meta.string.heredoc.shell string.unquoted.heredoc.shell redirection_comes_next -#<- meta.function-call.arguments.shell meta.string.heredoc.shell meta.tag.heredoc.shell entity.name.tag.heredoc.shell -#^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.heredoc.shell meta.tag.heredoc.shell entity.name.tag.heredoc.shell -# ^ - meta.function-call - meta.string - meta.tag - entity +#<- meta.function-call.arguments.shell meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell - meta.string - string +#^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell - meta.string - string +# ^ meta.function-call.arguments.shell meta.tag.heredoc.end.shell - entity - meta.string - string cat << FARAWAY -#^^^^^^^^^^ - meta.string - meta.tag -# ^^^^^^^ meta.string.heredoc.shell meta.tag.heredoc.shell - string.unquoted.heredoc -# ^ meta.string.heredoc.shell - meta.tag - string.unquoted.heredoc +#^^^^^^^^^^ - meta.tag - meta.string - string +# ^^^^^^^ meta.tag.heredoc.begin.shell - meta.string - string +# ^ - meta.tag - meta.string - string # ^^ keyword.operator.assignment.redirection.shell # ^^^^^ - entiy - keyword # ^^^^^^^ entity.name.tag.heredoc.shell @@ -9260,14 +9263,14 @@ cat << FARAWAY foo # <- meta.function-call.arguments.shell meta.string.heredoc.shell string.unquoted.heredoc.shell FARAWAY -#<- meta.function-call.arguments.shell meta.string.heredoc.shell meta.tag.heredoc.shell entity.name.tag.heredoc.shell -#^^^^^^ meta.function-call.arguments.shell meta.string.heredoc.shell meta.tag.heredoc.shell entity.name.tag.heredoc.shell -# ^ - meta.function-call - meta.string - meta.tag - entity +#<- meta.function-call.arguments.shell meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell - meta.string - string +#^^^^^^ meta.function-call.arguments.shell meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell - meta.string - string +# ^ meta.function-call.arguments.shell meta.tag.heredoc.end.shell - entity - meta.string - string cat <<- INDENTED #^^^^^^^ - meta.string - meta.tag -# ^^^^^^^^ meta.string.heredoc.shell meta.tag.heredoc.shell - string.unquoted.heredoc -# ^ meta.string.heredoc.shell - meta.tag - string.unquoted.heredoc +# ^^^^^^^^ meta.tag.heredoc.begin.shell - meta.string - string +# ^ - meta.tag - meta.string - string # ^^^ keyword.operator.assignment.redirection.shell # ^ - entity - keyword # ^^^^^^^^ entity.name.tag.heredoc.shell @@ -9276,14 +9279,14 @@ cat <<- INDENTED # ^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.heredoc.shell string.unquoted.heredoc.shell - meta.interpolation # ^^^^^^ meta.function-call.arguments.shell meta.string.heredoc.shell meta.interpolation.parameter.shell - string INDENTED -# <- meta.function-call.arguments.shell meta.string.heredoc.shell - meta.tag -#^^^^^^^^ meta.function-call.arguments.shell meta.string.heredoc.shell meta.tag.heredoc.shell entity.name.tag.heredoc.shell -# ^ - meta.function-call - meta.string - meta.tag - entity +# <- meta.function-call.arguments.shell meta.tag.heredoc.end.shell - entity - meta.string - string +#^^^^^^^^ meta.function-call.arguments.shell meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell - meta.string - string +# ^ meta.function-call.arguments.shell meta.tag.heredoc.end.shell - entity - meta.string - string cat <<- 'indented_without_expansions' #^^^^^^^^ - meta.string - meta.tag -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.heredoc.shell meta.tag.heredoc.shell - string.unquoted.heredoc -# ^ meta.string.heredoc.shell - meta.tag - string.unquoted.heredoc +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.tag.heredoc.begin.shell - meta.string - string +# ^ - meta.tag - meta.string - string # ^^^ keyword.operator.assignment.redirection.shell # ^ punctuation.definition.tag.begin.shell - entity # ^^^^^^^^^^^^^^^^^^^^^^^^^^^ entity.name.tag.heredoc.shell @@ -9292,22 +9295,23 @@ cat <<- 'indented_without_expansions' #^^^^^^^^^^ meta.function-call.arguments.shell meta.string.heredoc.shell string.unquoted.heredoc.shell - meta.interpolation # ^^^ - variable.other indented_without_expansions -#^ meta.function-call.arguments.shell meta.string.heredoc.shell - meta.tag -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.heredoc.shell meta.tag.heredoc.shell entity.name.tag.heredoc.shell -# ^ - meta.function-call - meta.string - meta.tag - entity +# <- meta.function-call.arguments.shell meta.tag.heredoc.end.shell - entity - meta.string - string +#^ meta.function-call.arguments.shell meta.tag.heredoc.end.shell - entity - meta.string - string +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell - meta.string - string +# ^ meta.function-call.arguments.shell meta.tag.heredoc.end.shell - entity - meta.string - string variable=$(cat <$dummy.c #^^ meta.function-call.identifier.shell variable.function.shell # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell - string.unquoted.heredoc # ^^^^^^^^^^^ meta.string.shell string.quoted.single.shell -# ^^^^ - meta.string -# ^^^ meta.string.heredoc.shell meta.tag.heredoc.shell -# ^^^^^^^^^^ meta.string.heredoc.shell - meta.tag +# ^^^^ - meta.tag - meta.string +# ^^^ meta.tag.heredoc.begin.shell - meta.string +# ^ - meta.tag - meta.string.heredoc +# ^^^^^^^^^ meta.redirection.shell - meta.tag - meta.string.heredoc # ^^ keyword.operator.assignment.redirection.shell # ^^^ entity.name.tag.heredoc.shell # ^ keyword.operator.assignment.redirection.shell @@ -9403,9 +9408,9 @@ sed 's/^ //' << EOF >$dummy.c exit (-1); } EOF -# <- meta.function-call.arguments.shell meta.string.heredoc.shell meta.tag.heredoc.shell entity.name.tag.heredoc.shell -#^^ meta.function-call.arguments.shell meta.string.heredoc.shell meta.tag.heredoc.shell entity.name.tag.heredoc.shell -# ^ - meta.function-call - meta.string - meta.tag - entity +# <- meta.function-call.arguments.shell meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell - meta.string - string +#^^ meta.function-call.arguments.shell meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell - meta.string - string +# ^ meta.function-call.arguments.shell meta.tag.heredoc.end.shell - entity - meta.string - string ############################################################################### @@ -11948,12 +11953,14 @@ sudo --reset-timestamp -n -f -- rm -rf # ^^^ string.unquoted.shell # ^ punctuation.section.compound.end.shell -[ < + + + scope + + source.shell meta.string.heredoc, + source.shell meta.tag.heredoc.end + + settings + + unIndentedLinePattern + . + preserveIndent + + + + diff --git a/ShellScript/Zsh/tests/syntax_test_scope.zsh b/ShellScript/Zsh/tests/syntax_test_scope.zsh index 2f63e8fedc..c41c5ef544 100644 --- a/ShellScript/Zsh/tests/syntax_test_scope.zsh +++ b/ShellScript/Zsh/tests/syntax_test_scope.zsh @@ -568,10 +568,11 @@ case $word { # end-of-file. : << word # ^^ keyword.operator.assignment.redirection.shell -# ^^^^^ meta.string.heredoc.shell -# ^^^^ entity.name.tag.heredoc.shell +# ^^^^ meta.tag.heredoc.begin.shell entity.name.tag.heredoc.shell word -# <- entity.name.tag.heredoc.shell +# <- meta.function-call.arguments.shell meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell +#^^^ meta.function-call.arguments.shell meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell +# ^ meta.function-call.arguments.shell meta.tag.heredoc.end.shell - entity # Perform shell expansion on word and pass the result to standard input. : <<< word From 2139db2b6e164452df04a74c2605b2002dcb6b70 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Mon, 5 Aug 2024 17:15:27 +0200 Subject: [PATCH 059/113] [ShellScript] Move variables main context to the bottom --- ShellScript/Bash.sublime-syntax | 472 ++++++++++++++++---------------- 1 file changed, 236 insertions(+), 236 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index e9e52f8b29..e1c372c5f1 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -37,242 +37,6 @@ first_line_match: |- ############################################################################### -variables: - # Language identifier in shebang - shebang_language: \b(?:bash|sh|tcsh|ash|dash)\b - - # Commands literals are command names without interpolation or quotation. - cmd_literal: '{{cmd_literal_char}}+{{cmd_break}}' - cmd_literal_char: '[^{{metachar}}%$\\"''`]' - - # Command names are non-posix identifiers, which may include assignment operators. - cmd_begin: (?={{cmd_char}}) - cmd_break: (?!{{cmd_char}}) - cmd_char: '[^{{metachar}}]' - - # Command options are identifiers, which may start with interpolation. - opt_punctuation: (--|[-+])(?={{word_char}}) - opt_break: (?![^={{metachar}}]) - - # HEREDOC tag names - heredoc: '{{heredoc_first_char}}{{heredoc_char}}*' - heredoc_first_char: '[[:alpha:]_]' - heredoc_char: '[[:alnum:]_.-]' - heredoc_break: (?!{{heredoc_char}}) - - # Variable names - variable_begin: (?={{variable_first_char}}) - variable_first_char: '[[:alpha:]_''"$%]' - - # POSIX identifiers (alpha-numeric) - identifier: '{{identifier_first_char}}{{identifier_char}}*' - identifier_first_char: '[[:alpha:]_]' - identifier_char: '[[:alnum:]_]' - identifier_break: (?!{{identifier_char}}) - - # Generic identifiers (shell words) - word_begin: (?=\S) - word_break: (?!{{word_char}}) - word_char: '[^{{metachar}}]' - - # A character that, when unquoted, separates words. A metacharacter is a - # space, tab, newline, or one of the following characters: ‘|’, ‘&’, ‘;’, - # ‘(’, ‘)’, ‘<’, or ‘>’. - metachar: '[\s|&;()<>]' - - # Parameter expansions - is_interpolation: (?=\$[({{{identifier_char}}{{special_variables}}]|`) - parameter_switch: '[AEKLPQUaku]' - - # POSIX extended regexp quantifiers - character_quantifier: '[?*+]' - lazy_or_possessive: '[?+]?' - ranged_quantifier: \{\d+(?:,\d*)?\} - - posix_classes: |- - (?x: ascii | alnum | alpha | blank | cntrl | digit | graph - | lower | print | punct | space | upper | word | xdigit ) - - digit: \d - varassign: '[-+]?=' - wspace: (?:\s+|^) - - no_escape_behind: (?’. + metachar: '[\s|&;()<>]' + + # Parameter expansions + is_interpolation: (?=\$[({{{identifier_char}}{{special_variables}}]|`) + parameter_switch: '[AEKLPQUaku]' + + # POSIX extended regexp quantifiers + character_quantifier: '[?*+]' + lazy_or_possessive: '[?+]?' + ranged_quantifier: \{\d+(?:,\d*)?\} + + posix_classes: |- + (?x: ascii | alnum | alpha | blank | cntrl | digit | graph + | lower | print | punct | space | upper | word | xdigit ) + + digit: \d + varassign: '[-+]?=' + wspace: (?:\s+|^) + + no_escape_behind: (? Date: Fri, 2 Aug 2024 19:03:04 +0200 Subject: [PATCH 060/113] [ShellScript] Add basic completions --- .../Builtin Command Names.sublime-completions | 45 ++ .../Bash/Variable Names.sublime-completions | 321 +++++++++++ .../Bash/Variables.sublime-completions | 384 +++++++++++++ .../Builtin Command Names.sublime-completions | 175 ++++++ .../Shell/Keywords.sublime-completions | 78 +++ ShellScript/Shell/Signals.sublime-completions | 398 +++++++++++++ .../Shell/Variable Names.sublime-completions | 216 +++++++ .../Shell/Variables.sublime-completions | 258 +++++++++ .../Builtin Command Names.sublime-completions | 370 ++++++++++++ ShellScript/Zsh/Keywords.sublime-completions | 25 + ...Special Function Names.sublime-completions | 452 +++++++++++++++ .../Zsh/Special Functions.sublime-completions | 525 ++++++++++++++++++ .../Zsh/Variable Names.sublime-completions | 426 ++++++++++++++ ShellScript/Zsh/Variables.sublime-completions | 510 +++++++++++++++++ 14 files changed, 4183 insertions(+) create mode 100644 ShellScript/Bash/Builtin Command Names.sublime-completions create mode 100644 ShellScript/Bash/Variable Names.sublime-completions create mode 100644 ShellScript/Bash/Variables.sublime-completions create mode 100644 ShellScript/Shell/Builtin Command Names.sublime-completions create mode 100644 ShellScript/Shell/Keywords.sublime-completions create mode 100644 ShellScript/Shell/Signals.sublime-completions create mode 100644 ShellScript/Shell/Variable Names.sublime-completions create mode 100644 ShellScript/Shell/Variables.sublime-completions create mode 100644 ShellScript/Zsh/Builtin Command Names.sublime-completions create mode 100644 ShellScript/Zsh/Keywords.sublime-completions create mode 100644 ShellScript/Zsh/Special Function Names.sublime-completions create mode 100644 ShellScript/Zsh/Special Functions.sublime-completions create mode 100644 ShellScript/Zsh/Variable Names.sublime-completions create mode 100644 ShellScript/Zsh/Variables.sublime-completions diff --git a/ShellScript/Bash/Builtin Command Names.sublime-completions b/ShellScript/Bash/Builtin Command Names.sublime-completions new file mode 100644 index 0000000000..e7a04c4131 --- /dev/null +++ b/ShellScript/Bash/Builtin Command Names.sublime-completions @@ -0,0 +1,45 @@ +{ + "scope": "source.shell.bash meta.function-call.identifier - source.shell.bash meta.function.identifier meta.interpolation", + "completions": [ + { + "trigger": "bind", + "kind": ["function", "f", "command"], + "details": "bash built-in", + }, + { + "trigger": "caller", + "kind": ["function", "f", "command"], + "details": "bash built-in", + }, + { + "trigger": "help", + "kind": ["function", "f", "command"], + "details": "bash built-in", + }, + { + "trigger": "mapfile", + "kind": ["function", "f", "command"], + "details": "bash built-in", + }, + { + "trigger": "readarray", + "kind": ["function", "f", "command"], + "details": "bash built-in", + }, + { + "trigger": "shopt", + "kind": ["function", "f", "command"], + "details": "bash built-in", + }, + { + "trigger": "set", + "kind": ["function", "f", "command"], + "details": "bash built-in", + }, + { + "trigger": "unset", + "kind": ["function", "f", "command"], + "details": "bash built-in", + }, + ], +} \ No newline at end of file diff --git a/ShellScript/Bash/Variable Names.sublime-completions b/ShellScript/Bash/Variable Names.sublime-completions new file mode 100644 index 0000000000..b853eda550 --- /dev/null +++ b/ShellScript/Bash/Variable Names.sublime-completions @@ -0,0 +1,321 @@ +{ + "scope": "source.shell.bash meta.interpolation.parameter variable, source.shell.bash meta.arithmetic", + "completions": [ + { + "trigger": "BASH", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASHOPTS", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASHPID", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_ALIASES", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_ARGC", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_ARGV", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_ARGV0", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_CMDS", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_COMMAND", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_COMPAT", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_ENV", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_EXECUTION_STRING", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_LINENO", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_LOADABLES_PATH", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_REMATCH", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_SOURCE", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_SUBSHELL", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_VERSINFO", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_VERSION", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_XTRACEFD", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "CHILD_MAX", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "COMPREPLY", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "COMP_CWORD", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "COMP_KEY", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "COMP_LINE", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "COMP_POINT", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "COMP_TYPE", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "COMP_WORDBREAKS", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "COMP_WORDS", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "COPROC", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "DIRSTACK", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "EPOCHREALTIME", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "EPOCHSECONDS", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "EXECIGNORE", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "FIGNORE", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "FUNCNAME", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "GLOBIGNORE", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "GROUPS", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "HISTCONTROL", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "HISTFILESIZE", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "HISTIGNORE", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "HISTTIMEFORMAT", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "HOSTFILE", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "HOSTNAME", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "HOSTTYPE", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "IGNOREEOF", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "INPUTRC", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "INSIDE_EMACS", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "MAILPATH", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "MAPFILE", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "OPTERR", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "PIPESTATUS", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "POSIXLY_CORRECT", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "PROMPT_COMMAND", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "PROMPT_DIRTRIM", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "PS0", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "READLINE_ARGUMENT", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "READLINE_LINE", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "READLINE_MARK", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "READLINE_POINT", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "SHELLOPTS", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "SRANDOM", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "TIMEFORMAT", + "kind": "variable", + "details": "bash built-in variable", + }, + + ] +} \ No newline at end of file diff --git a/ShellScript/Bash/Variables.sublime-completions b/ShellScript/Bash/Variables.sublime-completions new file mode 100644 index 0000000000..3663bf8c95 --- /dev/null +++ b/ShellScript/Bash/Variables.sublime-completions @@ -0,0 +1,384 @@ +{ + "scope": "source.shell.bash variable - source.shell meta.interpolation.parameter, source.shell.bash string", + "completions": [ + { + "trigger": "BASH", + "contents": "\\$BASH", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASHOPTS", + "contents": "\\$BASHOPTS", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASHPID", + "contents": "\\$BASHPID", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_ALIASES", + "contents": "\\$BASH_ALIASES", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_ARGC", + "contents": "\\$BASH_ARGC", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_ARGV", + "contents": "\\$BASH_ARGV", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_ARGV0", + "contents": "\\$BASH_ARGV0", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_CMDS", + "contents": "\\$BASH_CMDS", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_COMMAND", + "contents": "\\$BASH_COMMAND", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_COMPAT", + "contents": "\\$BASH_COMPAT", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_ENV", + "contents": "\\$BASH_ENV", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_EXECUTION_STRING", + "contents": "\\$BASH_EXECUTION_STRING", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_LINENO", + "contents": "\\$BASH_LINENO", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_LOADABLES_PATH", + "contents": "\\$BASH_LOADABLES_PATH", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_REMATCH", + "contents": "\\$BASH_REMATCH", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_SOURCE", + "contents": "\\$BASH_SOURCE", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_SUBSHELL", + "contents": "\\$BASH_SUBSHELL", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_VERSINFO", + "contents": "\\$BASH_VERSINFO", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_VERSION", + "contents": "\\$BASH_VERSION", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "BASH_XTRACEFD", + "contents": "\\$BASH_XTRACEFD", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "CHILD_MAX", + "contents": "\\$CHILD_MAX", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "COMPREPLY", + "contents": "\\$COMPREPLY", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "COMP_CWORD", + "contents": "\\$COMP_CWORD", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "COMP_KEY", + "contents": "\\$COMP_KEY", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "COMP_LINE", + "contents": "\\$COMP_LINE", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "COMP_POINT", + "contents": "\\$COMP_POINT", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "COMP_TYPE", + "contents": "\\$COMP_TYPE", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "COMP_WORDBREAKS", + "contents": "\\$COMP_WORDBREAKS", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "COMP_WORDS", + "contents": "\\$COMP_WORDS", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "COPROC", + "contents": "\\$COPROC", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "DIRSTACK", + "contents": "\\$DIRSTACK", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "EPOCHREALTIME", + "contents": "\\$EPOCHREALTIME", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "EPOCHSECONDS", + "contents": "\\$EPOCHSECONDS", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "EXECIGNORE", + "contents": "\\$EXECIGNORE", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "FIGNORE", + "contents": "\\$FIGNORE", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "FUNCNAME", + "contents": "\\$FUNCNAME", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "GLOBIGNORE", + "contents": "\\$GLOBIGNORE", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "GROUPS", + "contents": "\\$GROUPS", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "HISTCONTROL", + "contents": "\\$HISTCONTROL", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "HISTFILESIZE", + "contents": "\\$HISTFILESIZE", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "HISTIGNORE", + "contents": "\\$HISTIGNORE", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "HISTTIMEFORMAT", + "contents": "\\$HISTTIMEFORMAT", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "HOSTFILE", + "contents": "\\$HOSTFILE", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "HOSTNAME", + "contents": "\\$HOSTNAME", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "HOSTTYPE", + "contents": "\\$HOSTTYPE", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "IGNOREEOF", + "contents": "\\$IGNOREEOF", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "INPUTRC", + "contents": "\\$INPUTRC", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "INSIDE_EMACS", + "contents": "\\$INSIDE_EMACS", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "MAILPATH", + "contents": "\\$MAILPATH", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "MAPFILE", + "contents": "\\$MAPFILE", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "OPTERR", + "contents": "\\$OPTERR", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "PIPESTATUS", + "contents": "\\$PIPESTATUS", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "POSIXLY_CORRECT", + "contents": "\\$POSIXLY_CORRECT", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "PROMPT_COMMAND", + "contents": "\\$PROMPT_COMMAND", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "PROMPT_DIRTRIM", + "contents": "\\$PROMPT_DIRTRIM", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "PS0", + "contents": "\\$PS0", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "READLINE_ARGUMENT", + "contents": "\\$READLINE_ARGUMENT", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "READLINE_LINE", + "contents": "\\$READLINE_LINE", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "READLINE_MARK", + "contents": "\\$READLINE_MARK", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "READLINE_POINT", + "contents": "\\$READLINE_POINT", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "SHELLOPTS", + "contents": "\\$SHELLOPTS", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "SRANDOM", + "contents": "\\$SRANDOM", + "kind": "variable", + "details": "bash built-in variable", + }, + { + "trigger": "TIMEFORMAT", + "contents": "\\$TIMEFORMAT", + "kind": "variable", + "details": "bash built-in variable", + }, + + ] +} \ No newline at end of file diff --git a/ShellScript/Shell/Builtin Command Names.sublime-completions b/ShellScript/Shell/Builtin Command Names.sublime-completions new file mode 100644 index 0000000000..e82a747a97 --- /dev/null +++ b/ShellScript/Shell/Builtin Command Names.sublime-completions @@ -0,0 +1,175 @@ +{ + "scope": "source.shell meta.function-call.identifier - source.shell meta.function.identifier meta.interpolation", + "completions": [ + { + "trigger": "alias", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "break", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "builtin", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "cd", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "command", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "continue", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "declare", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "echo", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "enable", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "eval", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "exec", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "exit", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "export", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "getopts", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "hash", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "let", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "local", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "logout", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "printf", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "pwd", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "read", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "readonly", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "return", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "shift", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "source", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "test", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "time", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "times", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "trap", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "type", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "typeset", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "ulimit", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "umask", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + { + "trigger": "unalias", + "kind": ["function", "f", "command"], + "details": "shell built-in", + }, + ], +} \ No newline at end of file diff --git a/ShellScript/Shell/Keywords.sublime-completions b/ShellScript/Shell/Keywords.sublime-completions new file mode 100644 index 0000000000..13b62fc7f1 --- /dev/null +++ b/ShellScript/Shell/Keywords.sublime-completions @@ -0,0 +1,78 @@ +{ + "scope": "source.shell meta.function-call.identifier - source.shell meta.function.identifier meta.interpolation", + "completions": [ + + // control + + { + "trigger": "case", + "kind": "keyword", + "details": "shell control keyword" + }, + { + "trigger": "do", + "kind": "keyword", + "details": "shell control keyword" + }, + { + "trigger": "done", + "kind": "keyword", + "details": "shell control keyword" + }, + { + "trigger": "elif", + "kind": "keyword", + "details": "shell control keyword" + }, + { + "trigger": "else", + "kind": "keyword", + "details": "shell control keyword" + }, + { + "trigger": "esac", + "kind": "keyword", + "details": "shell control keyword" + }, + { + "trigger": "fi", + "kind": "keyword", + "details": "shell control keyword" + }, + { + "trigger": "for", + "kind": "keyword", + "details": "shell control keyword" + }, + { + "trigger": "if", + "kind": "keyword", + "details": "shell control keyword" + }, + { + "trigger": "in", + "kind": "keyword", + "details": "shell control keyword" + }, + { + "trigger": "select", + "kind": "keyword", + "details": "shell control keyword" + }, + { + "trigger": "then", + "kind": "keyword", + "details": "shell control keyword" + }, + { + "trigger": "until", + "kind": "keyword", + "details": "shell control keyword" + }, + { + "trigger": "while", + "kind": "keyword", + "details": "shell control keyword" + }, + ] +} \ No newline at end of file diff --git a/ShellScript/Shell/Signals.sublime-completions b/ShellScript/Shell/Signals.sublime-completions new file mode 100644 index 0000000000..741394f820 --- /dev/null +++ b/ShellScript/Shell/Signals.sublime-completions @@ -0,0 +1,398 @@ +{ + // + // POSIX or Unix Variables shared by all shells + // + "scope": "source.shell variable - meta.interpolation.parameter, source.shell string", + "completions": [ + { + "trigger": "DEBUG", + "annotation": "zsh", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "EXIT", + "annotation": "zsh", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "ZERR", + "annotation": "zsh", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGHUP", + "annotation": "signal 1", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGINT", + "annotation": "signal 2", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGQUIT", + "annotation": "signal 3", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGILL", + "annotation": "signal 4", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGTRAP", + "annotation": "signal 5", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGABRT", + "annotation": "signal 6", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGBUS", + "annotation": "signal 7", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGFPE", + "annotation": "signal 8", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGKILL", + "annotation": "signal 9", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGUSR1", + "annotation": "signal 10", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGSEGV", + "annotation": "signal 11", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGUSR2", + "annotation": "signal 12", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGPIPE", + "annotation": "signal 13", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGALRM", + "annotation": "signal 14", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGTERM", + "annotation": "signal 15", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGSTKFLT", + "annotation": "signal 16", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGCHLD", + "annotation": "signal 17", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGCONT", + "annotation": "signal 18", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGSTOP", + "annotation": "signal 19", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGTSTP", + "annotation": "signal 20", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGTTIN", + "annotation": "signal 21", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGTTOU", + "annotation": "signal 22", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGURG", + "annotation": "signal 23", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGXCPU", + "annotation": "signal 24", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGXFSZ", + "annotation": "signal 25", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGVTALRM", + "annotation": "signal 26", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGPROF", + "annotation": "signal 27", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGWINCH", + "annotation": "signal 28", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGIO", + "annotation": "signal 29", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGPWR", + "annotation": "signal 30", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGSYS", + "annotation": "signal 31", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGRTMIN", + "annotation": "signal 34", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGRTMIN+1", + "annotation": "signal 35", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGRTMIN+2", + "annotation": "signal 36", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGRTMIN+3", + "annotation": "signal 37", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGRTMIN+4", + "annotation": "signal 38", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGRTMIN+5", + "annotation": "signal 39", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGRTMIN+6", + "annotation": "signal 40", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGRTMIN+7", + "annotation": "signal 41", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGRTMIN+8", + "annotation": "signal 42", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGRTMIN+9", + "annotation": "signal 43", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGRTMIN+10", + "annotation": "signal 44", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGRTMIN+11", + "annotation": "signal 45", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGRTMIN+12", + "annotation": "signal 46", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGRTMIN+13", + "annotation": "signal 47", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGRTMIN+14", + "annotation": "signal 48", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGRTMIN+15", + "annotation": "signal 49", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGRTMAX-14", + "annotation": "signal 50", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGRTMAX-13", + "annotation": "signal 51", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGRTMAX-12", + "annotation": "signal 52", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGRTMAX-11", + "annotation": "signal 53", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGRTMAX-10", + "annotation": "signal 54", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGRTMAX-9", + "annotation": "signal 55", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGRTMAX-8", + "annotation": "signal 56", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGRTMAX-7", + "annotation": "signal 57", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGRTMAX-6", + "annotation": "signal 58", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGRTMAX-5", + "annotation": "signal 59", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGRTMAX-4", + "annotation": "signal 60", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGRTMAX-3", + "annotation": "signal 61", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGRTMAX-2", + "annotation": "signal 62", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGRTMAX-1", + "annotation": "signal 63", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + { + "trigger": "SIGRTMAX", + "annotation": "signal 64", + "kind": ["variable", "s", "signal"], + "details": " ", + }, + ] +} \ No newline at end of file diff --git a/ShellScript/Shell/Variable Names.sublime-completions b/ShellScript/Shell/Variable Names.sublime-completions new file mode 100644 index 0000000000..eacc59773c --- /dev/null +++ b/ShellScript/Shell/Variable Names.sublime-completions @@ -0,0 +1,216 @@ +{ + "scope": "source.shell meta.interpolation.parameter variable, source.shell meta.arithmetic", + "completions": [ + { + "trigger": "CDPATH", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "COLUMNS", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "ENV", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "EUID", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "FCEDIT", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "FUNCNEST", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "HISTCMD", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "HISTFILE", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "HISTSIZE", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "HOME", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "IFS", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "LANG", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "LC_ALL", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "LC_COLLATE", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "LC_CTYPE", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "LC_MESSAGES", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "LC_NUMERIC", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "LC_TIME", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "LINENO", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "LINES", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "MACHTYPE", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "MAIL", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "MAILCHECK", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "OLDPWD", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "OPTARG", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "OPTIND", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "OSTYPE", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "PATH", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "PPID", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "PS1", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "PS2", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "PS3", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "PS4", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "PWD", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "RANDOM", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "REPLY", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "SECONDS", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "SHELL", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "SHLVL", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "TMOUT", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "UID", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "histchars", + "kind": "variable", + "details": "shell built-in variable", + }, + + ] +} \ No newline at end of file diff --git a/ShellScript/Shell/Variables.sublime-completions b/ShellScript/Shell/Variables.sublime-completions new file mode 100644 index 0000000000..10160754c4 --- /dev/null +++ b/ShellScript/Shell/Variables.sublime-completions @@ -0,0 +1,258 @@ +{ + "scope": "source.shell variable - source.shell meta.interpolation.parameter, source.shell string", + "completions": [ + { + "trigger": "CDPATH", + "contents": "\\$CDPATH", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "COLUMNS", + "contents": "\\$COLUMNS", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "ENV", + "contents": "\\$ENV", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "EUID", + "contents": "\\$EUID", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "FCEDIT", + "contents": "\\$FCEDIT", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "FUNCNEST", + "contents": "\\$FUNCNEST", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "HISTCMD", + "contents": "\\$HISTCMD", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "HISTFILE", + "contents": "\\$HISTFILE", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "HISTSIZE", + "contents": "\\$HISTSIZE", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "HOME", + "contents": "\\$HOME", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "IFS", + "contents": "\\$IFS", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "LANG", + "contents": "\\$LANG", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "LC_ALL", + "contents": "\\$LC_ALL", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "LC_COLLATE", + "contents": "\\$LC_COLLATE", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "LC_CTYPE", + "contents": "\\$LC_CTYPE", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "LC_MESSAGES", + "contents": "\\$LC_MESSAGES", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "LC_NUMERIC", + "contents": "\\$LC_NUMERIC", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "LC_TIME", + "contents": "\\$LC_TIME", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "LINENO", + "contents": "\\$LINENO", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "LINES", + "contents": "\\$LINES", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "MACHTYPE", + "contents": "\\$MACHTYPE", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "MAIL", + "contents": "\\$MAIL", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "MAILCHECK", + "contents": "\\$MAILCHECK", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "OLDPWD", + "contents": "\\$OLDPWD", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "OPTARG", + "contents": "\\$OPTARG", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "OPTIND", + "contents": "\\$OPTIND", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "OSTYPE", + "contents": "\\$OSTYPE", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "PATH", + "contents": "\\$PATH", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "PPID", + "contents": "\\$PPID", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "PS1", + "contents": "\\$PS1", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "PS2", + "contents": "\\$PS2", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "PS3", + "contents": "\\$PS3", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "PS4", + "contents": "\\$PS4", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "PWD", + "contents": "\\$PWD", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "RANDOM", + "contents": "\\$RANDOM", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "REPLY", + "contents": "\\$REPLY", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "SECONDS", + "contents": "\\$SECONDS", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "SHELL", + "contents": "\\$SHELL", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "SHLVL", + "contents": "\\$SHLVL", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "TMOUT", + "contents": "\\$TMOUT", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "UID", + "contents": "\\$UID", + "kind": "variable", + "details": "shell built-in variable", + }, + { + "trigger": "histchars", + "contents": "\\$histchars", + "kind": "variable", + "details": "shell built-in variable", + }, + + ] +} \ No newline at end of file diff --git a/ShellScript/Zsh/Builtin Command Names.sublime-completions b/ShellScript/Zsh/Builtin Command Names.sublime-completions new file mode 100644 index 0000000000..60a9a328ba --- /dev/null +++ b/ShellScript/Zsh/Builtin Command Names.sublime-completions @@ -0,0 +1,370 @@ +{ + "scope": "source.shell.zsh meta.function-call.identifier - source.shell.zsh meta.function.identifier meta.interpolation", + "completions": [ + { + "trigger": "autoload", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "bg", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "bindkey", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "bye", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "cap", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "chdir", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "clone", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "comparguments", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "compcall", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "compctl", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "compdescribe", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "compfiles", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "compgroups", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "compquote", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "comptags", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "comptry", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "compvalues", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "dirs", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "disable", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "disown", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "echotc", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "echoti", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "emulate", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "false", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "fc", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "fg", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "float", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "functions", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "getcap", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "getln", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "history", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "integer", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "job", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "jobs", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "kill", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "limit", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "noglob", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "popd", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "print", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "pushd", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "pushln", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "r", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "rehash", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "sched", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "set", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "setcap", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "setopt", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "stat", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "suspend", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "true", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "ttyctl", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "unfunction", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "unhash", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "unlimit", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "unset", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "unsetopt", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "vared", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "wait", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "whence", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "where", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "which", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "zcompile", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "zformat", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "zftp", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "zle", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "zmodload", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "zparseopts", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "zprof", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "zpty", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "zregexparse", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "zsocket", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "zstyle", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + { + "trigger": "ztcp", + "kind": ["function", "f", "command"], + "details": "zsh built-in" + }, + ], +} \ No newline at end of file diff --git a/ShellScript/Zsh/Keywords.sublime-completions b/ShellScript/Zsh/Keywords.sublime-completions new file mode 100644 index 0000000000..186e4902a5 --- /dev/null +++ b/ShellScript/Zsh/Keywords.sublime-completions @@ -0,0 +1,25 @@ +{ + "scope": "source.shell.zsh meta.function-call.identifier - source.shell.zsh meta.function.identifier meta.interpolation", + "completions": [ + { + "trigger": "always", + "kind": "keyword", + "details": "zsh", + }, + { + "trigger": "foreach", + "kind": "keyword", + "details": "zsh", + }, + { + "trigger": "repeat", + "kind": "keyword", + "details": "zsh", + }, + { + "trigger": "end", + "kind": "keyword", + "details": "zsh", + }, + ], +} \ No newline at end of file diff --git a/ShellScript/Zsh/Special Function Names.sublime-completions b/ShellScript/Zsh/Special Function Names.sublime-completions new file mode 100644 index 0000000000..60e9a93af6 --- /dev/null +++ b/ShellScript/Zsh/Special Function Names.sublime-completions @@ -0,0 +1,452 @@ +{ + "scope": "source.shell.zsh meta.function.identifier - source.shell.zsh meta.function.identifier meta.interpolation", + "completions": [ + + // Hook Functions + + { + "trigger": "chpwd", + "kind": ["function", "h", "Hook"], + "annotation": "zsh", + "details": "executed on directory change", + }, + { + "trigger": "periodic", + "kind": ["function", "h", "Hook"], + "annotation": "zsh", + "details": "executed every $PERIOD seconds", + }, + { + "trigger": "precmd", + "kind": ["function", "h", "Hook"], + "annotation": "zsh", + "details": "executed before each prompt", + }, + { + "trigger": "preexec", + "kind": ["function", "h", "Hook"], + "annotation": "zsh", + "details": "executed before each command", + }, + { + "trigger": "zshaddhistory", + "kind": ["function", "h", "Hook"], + "annotation": "zsh", + "details": "executed before history command", + }, + { + "trigger": "zshexit", + "kind": ["function", "h", "Hook"], + "annotation": "zsh", + "details": "executed before shell exits", + }, + + // Zsh Trap Functions + + { + "trigger": "TRAPDEBUG", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed if DEBUG_BEFORE_CMD is set", + }, + { + "trigger": "TRAPEXIT", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed if shell or function exits", + }, + { + "trigger": "TRAPZERR", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed if command has non-zero exit status", + }, + + // Signal Trap Functions + + { + "trigger": "TRAPABRT", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGABRT", + }, + { + "trigger": "TRAPALRM", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGALRM", + }, + { + "trigger": "TRAPBUS", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGBUS", + }, + { + "trigger": "TRAPCHLD", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGCHLD", + }, + { + "trigger": "TRAPCONT", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGCONT", + }, + { + "trigger": "TRAPFPE", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGFPE", + }, + { + "trigger": "TRAPHUP", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGHUP", + }, + { + "trigger": "TRAPILL", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGILL", + }, + { + "trigger": "TRAPINT", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGINT", + }, + { + "trigger": "TRAPIO", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGIO", + }, + { + "trigger": "TRAPKILL", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGKILL", + }, + { + "trigger": "TRAPLWP", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGLWP", + }, + { + "trigger": "TRAPPIPE", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGPIPE", + }, + { + "trigger": "TRAPPROF", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGPROF", + }, + { + "trigger": "TRAPPWR", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGPWR", + }, + { + "trigger": "TRAPQUIT", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGQUIT", + }, + { + "trigger": "TRAPRTMAX", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMAX", + }, + { + "trigger": "TRAPRTMAX-1", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMAX", + }, + { + "trigger": "TRAPRTMAX-2", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMAX", + }, + { + "trigger": "TRAPRTMAX-3", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMAX", + }, + { + "trigger": "TRAPRTMAX-4", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMAX", + }, + { + "trigger": "TRAPRTMAX-5", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMAX", + }, + { + "trigger": "TRAPRTMAX-6", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMAX", + }, + { + "trigger": "TRAPRTMAX-7", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMAX", + }, + { + "trigger": "TRAPRTMAX-8", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMAX", + }, + { + "trigger": "TRAPRTMAX-9", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMAX", + }, + { + "trigger": "TRAPRTMAX-10", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMAX", + }, + { + "trigger": "TRAPRTMAX-11", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMAX", + }, + { + "trigger": "TRAPRTMAX-12", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMAX", + }, + { + "trigger": "TRAPRTMAX-13", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMAX", + }, + { + "trigger": "TRAPRTMAX-14", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMAX", + }, + { + "trigger": "TRAPRTMIN", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMIN", + }, + { + "trigger": "TRAPRTMIN+1", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMIN", + }, + { + "trigger": "TRAPRTMIN+2", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMIN", + }, + { + "trigger": "TRAPRTMIN+3", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMIN", + }, + { + "trigger": "TRAPRTMIN+4", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMIN", + }, + { + "trigger": "TRAPRTMIN+5", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMIN", + }, + { + "trigger": "TRAPRTMIN+6", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMIN", + }, + { + "trigger": "TRAPRTMIN+7", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMIN", + }, + { + "trigger": "TRAPRTMIN+8", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMIN", + }, + { + "trigger": "TRAPRTMIN+9", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMIN", + }, + { + "trigger": "TRAPRTMIN+10", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMIN", + }, + { + "trigger": "TRAPRTMIN+11", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMIN", + }, + { + "trigger": "TRAPRTMIN+12", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMIN", + }, + { + "trigger": "TRAPRTMIN+13", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMIN", + }, + { + "trigger": "TRAPRTMIN+14", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMIN", + }, + { + "trigger": "TRAPRTMIN+15", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMIN", + }, + { + "trigger": "TRAPSEGV", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGSEGV", + }, + { + "trigger": "TRAPSTKFLT", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGSTKFLT", + }, + { + "trigger": "TRAPSTOP", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGSTOP", + }, + { + "trigger": "TRAPSYS", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGSYS", + }, + { + "trigger": "TRAPTERM", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGTERM", + }, + { + "trigger": "TRAPTRAP", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGTRAP", + }, + { + "trigger": "TRAPTSTP", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGTSTP", + }, + { + "trigger": "TRAPTTIN", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGTTIN", + }, + { + "trigger": "TRAPTTOU", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGTTOU", + }, + { + "trigger": "TRAPURG", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGURG", + }, + { + "trigger": "TRAPUSR1", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGUSR1", + }, + { + "trigger": "TRAPUSR2", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGUSR2", + }, + { + "trigger": "TRAPVTALRM", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGVTALRM", + }, + { + "trigger": "TRAPWAITING", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGWAITING", + }, + { + "trigger": "TRAPWINCH", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGWINCH", + }, + { + "trigger": "TRAPXCPU", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGXCPU", + }, + { + "trigger": "TRAPXFSZ", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGXFSZ", + }, + ], +} \ No newline at end of file diff --git a/ShellScript/Zsh/Special Functions.sublime-completions b/ShellScript/Zsh/Special Functions.sublime-completions new file mode 100644 index 0000000000..ae45dd35e1 --- /dev/null +++ b/ShellScript/Zsh/Special Functions.sublime-completions @@ -0,0 +1,525 @@ +{ + "scope": "source.shell.zsh meta.function-call.identifier - source.shell.zsh meta.function-call.identifier meta.interpolation", + "completions": [ + + // Hook Funxtions + + { + "trigger": "chpwd", + "contents": "chpwd() {$0}", + "kind": ["function", "h", "Hook"], + "annotation": "zsh", + "details": "executed on directory change", + }, + { + "trigger": "periodic", + "contents": "periodic() {$0}", + "kind": ["function", "h", "Hook"], + "annotation": "zsh", + "details": "executed every $PERIOD seconds", + }, + { + "trigger": "precmd", + "contents": "precmd() {$0}", + "kind": ["function", "h", "Hook"], + "annotation": "zsh", + "details": "executed before each prompt", + }, + { + "trigger": "preexec", + "contents": "preexec() {$0}", + "kind": ["function", "h", "Hook"], + "annotation": "zsh", + "details": "executed before each command", + }, + { + "trigger": "zshaddhistory", + "contents": "zshaddhistory() {$0}", + "kind": ["function", "h", "Hook"], + "annotation": "zsh", + "details": "executed before history command", + }, + { + "trigger": "zshexit", + "contents": "zshexit() {$0}", + "kind": ["function", "h", "Hook"], + "annotation": "zsh", + "details": "executed before shell exits", + }, + + // Zsh Trap Functions + + { + "trigger": "TRAPDEBUG", + "contents": "TRAPDEBUG() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed if DEBUG_BEFORE_CMD is set", + }, + { + "trigger": "TRAPEXIT", + "contents": "TRAPEXIT() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed if shell or function exits", + }, + { + "trigger": "TRAPZERR", + "contents": "TRAPZERR() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed if command has non-zero exit status", + }, + + // Signal Trap Functions + + { + "trigger": "TRAPABRT", + "contents": "TRAPABRT() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGABRT", + }, + { + "trigger": "TRAPALRM", + "contents": "TRAPALRM() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGALRM", + }, + { + "trigger": "TRAPBUS", + "contents": "TRAPBUS() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGBUS", + }, + { + "trigger": "TRAPCHLD", + "contents": "TRAPCHLD() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGCHLD", + }, + { + "trigger": "TRAPCONT", + "contents": "TRAPCONT() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGCONT", + }, + { + "trigger": "TRAPFPE", + "contents": "TRAPFPE() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGFPE", + }, + { + "trigger": "TRAPHUP", + "contents": "TRAPHUP() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGHUP", + }, + { + "trigger": "TRAPILL", + "contents": "TRAPILL() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGILL", + }, + { + "trigger": "TRAPINT", + "contents": "TRAPINT() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGINT", + }, + { + "trigger": "TRAPIO", + "contents": "TRAPIO() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGIO", + }, + { + "trigger": "TRAPKILL", + "contents": "TRAPKILL() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGKILL", + }, + { + "trigger": "TRAPLWP", + "contents": "TRAPLWP() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGLWP", + }, + { + "trigger": "TRAPPIPE", + "contents": "TRAPPIPE() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGPIPE", + }, + { + "trigger": "TRAPPROF", + "contents": "TRAPPROF() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGPROF", + }, + { + "trigger": "TRAPPWR", + "contents": "TRAPPWR() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGPWR", + }, + { + "trigger": "TRAPQUIT", + "contents": "TRAPQUIT() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGQUIT", + }, + { + "trigger": "TRAPRTMAX", + "contents": "TRAPRTMAX() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMAX", + }, + { + "trigger": "TRAPRTMAX-1", + "contents": "TRAPRTMAX() {$0}-1", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMAX", + }, + { + "trigger": "TRAPRTMAX-2", + "contents": "TRAPRTMAX() {$0}-2", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMAX", + }, + { + "trigger": "TRAPRTMAX-3", + "contents": "TRAPRTMAX() {$0}-3", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMAX", + }, + { + "trigger": "TRAPRTMAX-4", + "contents": "TRAPRTMAX() {$0}-4", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMAX", + }, + { + "trigger": "TRAPRTMAX-5", + "contents": "TRAPRTMAX() {$0}-5", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMAX", + }, + { + "trigger": "TRAPRTMAX-6", + "contents": "TRAPRTMAX() {$0}-6", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMAX", + }, + { + "trigger": "TRAPRTMAX-7", + "contents": "TRAPRTMAX() {$0}-7", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMAX", + }, + { + "trigger": "TRAPRTMAX-8", + "contents": "TRAPRTMAX() {$0}-8", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMAX", + }, + { + "trigger": "TRAPRTMAX-9", + "contents": "TRAPRTMAX() {$0}-9", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMAX", + }, + { + "trigger": "TRAPRTMAX-10", + "contents": "TRAPRTMAX() {$0}-10", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMAX", + }, + { + "trigger": "TRAPRTMAX-11", + "contents": "TRAPRTMAX() {$0}-11", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMAX", + }, + { + "trigger": "TRAPRTMAX-12", + "contents": "TRAPRTMAX() {$0}-12", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMAX", + }, + { + "trigger": "TRAPRTMAX-13", + "contents": "TRAPRTMAX() {$0}-13", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMAX", + }, + { + "trigger": "TRAPRTMAX-14", + "contents": "TRAPRTMAX() {$0}-14", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMAX", + }, + { + "trigger": "TRAPRTMIN", + "contents": "TRAPRTMIN() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMIN", + }, + { + "trigger": "TRAPRTMIN+1", + "contents": "TRAPRTMIN() {$0}+1", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMIN", + }, + { + "trigger": "TRAPRTMIN+2", + "contents": "TRAPRTMIN() {$0}+2", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMIN", + }, + { + "trigger": "TRAPRTMIN+3", + "contents": "TRAPRTMIN() {$0}+3", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMIN", + }, + { + "trigger": "TRAPRTMIN+4", + "contents": "TRAPRTMIN() {$0}+4", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMIN", + }, + { + "trigger": "TRAPRTMIN+5", + "contents": "TRAPRTMIN() {$0}+5", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMIN", + }, + { + "trigger": "TRAPRTMIN+6", + "contents": "TRAPRTMIN() {$0}+6", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMIN", + }, + { + "trigger": "TRAPRTMIN+7", + "contents": "TRAPRTMIN() {$0}+7", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMIN", + }, + { + "trigger": "TRAPRTMIN+8", + "contents": "TRAPRTMIN() {$0}+8", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMIN", + }, + { + "trigger": "TRAPRTMIN+9", + "contents": "TRAPRTMIN() {$0}+9", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMIN", + }, + { + "trigger": "TRAPRTMIN+10", + "contents": "TRAPRTMIN() {$0}+10", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMIN", + }, + { + "trigger": "TRAPRTMIN+11", + "contents": "TRAPRTMIN() {$0}+11", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMIN", + }, + { + "trigger": "TRAPRTMIN+12", + "contents": "TRAPRTMIN() {$0}+12", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMIN", + }, + { + "trigger": "TRAPRTMIN+13", + "contents": "TRAPRTMIN() {$0}+13", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMIN", + }, + { + "trigger": "TRAPRTMIN+14", + "contents": "TRAPRTMIN() {$0}+14", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMIN", + }, + { + "trigger": "TRAPRTMIN+15", + "contents": "TRAPRTMIN() {$0}+15", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGRTMIN", + }, + { + "trigger": "TRAPSEGV", + "contents": "TRAPSEGV() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGSEGV", + }, + { + "trigger": "TRAPSTKFLT", + "contents": "TRAPSTKFLT() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGSTKFLT", + }, + { + "trigger": "TRAPSTOP", + "contents": "TRAPSTOP() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGSTOP", + }, + { + "trigger": "TRAPSYS", + "contents": "TRAPSYS() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGSYS", + }, + { + "trigger": "TRAPTERM", + "contents": "TRAPTERM() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGTERM", + }, + { + "trigger": "TRAPTRAP", + "contents": "TRAPTRAP() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGTRAP", + }, + { + "trigger": "TRAPTSTP", + "contents": "TRAPTSTP() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGTSTP", + }, + { + "trigger": "TRAPTTIN", + "contents": "TRAPTTIN() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGTTIN", + }, + { + "trigger": "TRAPTTOU", + "contents": "TRAPTTOU() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGTTOU", + }, + { + "trigger": "TRAPURG", + "contents": "TRAPURG() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGURG", + }, + { + "trigger": "TRAPUSR1", + "contents": "TRAPUSR1() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGUSR1", + }, + { + "trigger": "TRAPUSR2", + "contents": "TRAPUSR2() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGUSR2", + }, + { + "trigger": "TRAPVTALRM", + "contents": "TRAPVTALRM() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGVTALRM", + }, + { + "trigger": "TRAPWAITING", + "contents": "TRAPWAITING() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGWAITING", + }, + { + "trigger": "TRAPWINCH", + "contents": "TRAPWINCH() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGWINCH", + }, + { + "trigger": "TRAPXCPU", + "contents": "TRAPXCPU() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGXCPU", + }, + { + "trigger": "TRAPXFSZ", + "contents": "TRAPXFSZ() {$0}", + "kind": ["function", "t", "Trap"], + "annotation": "zsh", + "details": "executed on SIGXFSZ", + }, + ], +} \ No newline at end of file diff --git a/ShellScript/Zsh/Variable Names.sublime-completions b/ShellScript/Zsh/Variable Names.sublime-completions new file mode 100644 index 0000000000..c73cf41445 --- /dev/null +++ b/ShellScript/Zsh/Variable Names.sublime-completions @@ -0,0 +1,426 @@ +{ + "scope": "source.shell.zsh meta.interpolation.parameter variable, source.shell.zsh meta.arithmetic", + "completions": [ + { + "trigger": "ARGC", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "ARGV0", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "BAUD", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "CORRECT_IGNORE", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "CORRECT_IGNORE_FILE", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "CPUTYPE", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "DIRSTACKSIZE", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "EGID", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "ERRNO", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "GID", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "HISTCHARS", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "HISTORY_IGNORE", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "HOST", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "KEYBOARD_HACK", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "KEYTIMEOUT", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "LISTMAX", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "LOGNAME", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "MATCH", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "MBEGIN", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "MEND", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "NULLCMD", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "POSTEDIT", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "PROMPT", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "PROMPT2", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "PROMPT3", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "PROMPT4", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "PROMPT_EOL_MARK", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "READNULLCMD", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "REPORTMEMORY", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "REPORTTIME", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "RPROMPT", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "RPROMPT2", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "RPS1", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "RPS2", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "SAVEHIST", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "SPROMPT", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "STTY", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "TERM", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "TERMINFO", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "TERMINFO_DIRS", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "TIMEFMT", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "TMPPREFIX", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "TMPSUFFIX", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "TRY_BLOCK_ERROR", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "TRY_BLOCK_INTERRUPT", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "TTY", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "TTYIDLE", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "USERNAME", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "VENDOR", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "WORDCHARS", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "ZBEEP", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "ZDOTDIR", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "ZLE_LINE_ABORTED", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "ZLE_REMOVE_SUFFIX_CHARS", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "ZLE_RPROMPT_INDENT", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "ZLE_SPACE_SUFFIX_CHARS", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "ZSH_ARGZERO", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "ZSH_EXECUTION_STRING", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "ZSH_NAME", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "ZSH_PATCHLEVEL", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "ZSH_SCRIPT", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "ZSH_SUBSHELL", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "ZSH_VERSION", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "argv", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "cdpath", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "fignore", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "fpath", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "mailpath", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "manpath", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "match", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "mbegin", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "mend", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "module_path", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "path", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "pipestatus", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "prompt", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "psvar", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "reply", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "signals", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "status", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "zle_bracketed_paste", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "zle_highlight", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "zsh_eval_context", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "zsh_scheduled_events", + "kind": "variable", + "details": "zsh built-in variable", + }, + + ] +} \ No newline at end of file diff --git a/ShellScript/Zsh/Variables.sublime-completions b/ShellScript/Zsh/Variables.sublime-completions new file mode 100644 index 0000000000..e9d1d4adbd --- /dev/null +++ b/ShellScript/Zsh/Variables.sublime-completions @@ -0,0 +1,510 @@ +{ + "scope": "source.shell.zsh variable - source.shell meta.interpolation.parameter, source.shell.zsh string", + "completions": [ + { + "trigger": "ARGC", + "contents": "\\$ARGC", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "ARGV0", + "contents": "\\$ARGV0", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "BAUD", + "contents": "\\$BAUD", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "CORRECT_IGNORE", + "contents": "\\$CORRECT_IGNORE", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "CORRECT_IGNORE_FILE", + "contents": "\\$CORRECT_IGNORE_FILE", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "CPUTYPE", + "contents": "\\$CPUTYPE", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "DIRSTACKSIZE", + "contents": "\\$DIRSTACKSIZE", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "EGID", + "contents": "\\$EGID", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "ERRNO", + "contents": "\\$ERRNO", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "GID", + "contents": "\\$GID", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "HISTCHARS", + "contents": "\\$HISTCHARS", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "HISTORY_IGNORE", + "contents": "\\$HISTORY_IGNORE", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "HOST", + "contents": "\\$HOST", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "KEYBOARD_HACK", + "contents": "\\$KEYBOARD_HACK", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "KEYTIMEOUT", + "contents": "\\$KEYTIMEOUT", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "LISTMAX", + "contents": "\\$LISTMAX", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "LOGNAME", + "contents": "\\$LOGNAME", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "MATCH", + "contents": "\\$MATCH", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "MBEGIN", + "contents": "\\$MBEGIN", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "MEND", + "contents": "\\$MEND", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "NULLCMD", + "contents": "\\$NULLCMD", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "POSTEDIT", + "contents": "\\$POSTEDIT", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "PROMPT", + "contents": "\\$PROMPT", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "PROMPT2", + "contents": "\\$PROMPT2", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "PROMPT3", + "contents": "\\$PROMPT3", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "PROMPT4", + "contents": "\\$PROMPT4", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "PROMPT_EOL_MARK", + "contents": "\\$PROMPT_EOL_MARK", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "READNULLCMD", + "contents": "\\$READNULLCMD", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "REPORTMEMORY", + "contents": "\\$REPORTMEMORY", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "REPORTTIME", + "contents": "\\$REPORTTIME", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "RPROMPT", + "contents": "\\$RPROMPT", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "RPROMPT2", + "contents": "\\$RPROMPT2", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "RPS1", + "contents": "\\$RPS1", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "RPS2", + "contents": "\\$RPS2", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "SAVEHIST", + "contents": "\\$SAVEHIST", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "SPROMPT", + "contents": "\\$SPROMPT", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "STTY", + "contents": "\\$STTY", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "TERM", + "contents": "\\$TERM", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "TERMINFO", + "contents": "\\$TERMINFO", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "TERMINFO_DIRS", + "contents": "\\$TERMINFO_DIRS", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "TIMEFMT", + "contents": "\\$TIMEFMT", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "TMPPREFIX", + "contents": "\\$TMPPREFIX", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "TMPSUFFIX", + "contents": "\\$TMPSUFFIX", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "TRY_BLOCK_ERROR", + "contents": "\\$TRY_BLOCK_ERROR", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "TRY_BLOCK_INTERRUPT", + "contents": "\\$TRY_BLOCK_INTERRUPT", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "TTY", + "contents": "\\$TTY", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "TTYIDLE", + "contents": "\\$TTYIDLE", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "USERNAME", + "contents": "\\$USERNAME", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "VENDOR", + "contents": "\\$VENDOR", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "WORDCHARS", + "contents": "\\$WORDCHARS", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "ZBEEP", + "contents": "\\$ZBEEP", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "ZDOTDIR", + "contents": "\\$ZDOTDIR", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "ZLE_LINE_ABORTED", + "contents": "\\$ZLE_LINE_ABORTED", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "ZLE_REMOVE_SUFFIX_CHARS", + "contents": "\\$ZLE_REMOVE_SUFFIX_CHARS", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "ZLE_RPROMPT_INDENT", + "contents": "\\$ZLE_RPROMPT_INDENT", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "ZLE_SPACE_SUFFIX_CHARS", + "contents": "\\$ZLE_SPACE_SUFFIX_CHARS", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "ZSH_ARGZERO", + "contents": "\\$ZSH_ARGZERO", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "ZSH_EXECUTION_STRING", + "contents": "\\$ZSH_EXECUTION_STRING", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "ZSH_NAME", + "contents": "\\$ZSH_NAME", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "ZSH_PATCHLEVEL", + "contents": "\\$ZSH_PATCHLEVEL", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "ZSH_SCRIPT", + "contents": "\\$ZSH_SCRIPT", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "ZSH_SUBSHELL", + "contents": "\\$ZSH_SUBSHELL", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "ZSH_VERSION", + "contents": "\\$ZSH_VERSION", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "argv", + "contents": "\\$argv", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "cdpath", + "contents": "\\$cdpath", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "fignore", + "contents": "\\$fignore", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "fpath", + "contents": "\\$fpath", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "mailpath", + "contents": "\\$mailpath", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "manpath", + "contents": "\\$manpath", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "match", + "contents": "\\$match", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "mbegin", + "contents": "\\$mbegin", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "mend", + "contents": "\\$mend", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "module_path", + "contents": "\\$module_path", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "path", + "contents": "\\$path", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "pipestatus", + "contents": "\\$pipestatus", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "prompt", + "contents": "\\$prompt", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "psvar", + "contents": "\\$psvar", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "reply", + "contents": "\\$reply", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "signals", + "contents": "\\$signals", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "status", + "contents": "\\$status", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "zle_bracketed_paste", + "contents": "\\$zle_bracketed_paste", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "zle_highlight", + "contents": "\\$zle_highlight", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "zsh_eval_context", + "contents": "\\$zsh_eval_context", + "kind": "variable", + "details": "zsh built-in variable", + }, + { + "trigger": "zsh_scheduled_events", + "contents": "\\$zsh_scheduled_events", + "kind": "variable", + "details": "zsh built-in variable", + }, + + ] +} \ No newline at end of file From f7663c85f96ec2c9b0a1d8d4b6bebcac6682493d Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 6 Aug 2024 11:12:04 +0200 Subject: [PATCH 061/113] [ShellScript] Allow overriding indentation restrictions This commit adds `tab_indent` and `no_indent` variables, which can be used by extending syntaxes to easily remove indentation restrictions. --- ShellScript/Bash.sublime-syntax | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index e1c372c5f1..9b97bcad9f 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -100,8 +100,10 @@ contexts: pop: 1 shebang: - - match: ^\#! - scope: punctuation.definition.comment.shell + # allow extending syntaxes like Markdown to ignore indentation restrictions + - match: '{{no_indent}}(\#!)' + captures: + 1: punctuation.definition.comment.shell set: shebang-body - match: ^|(?=\S) # Note: Ensure to highlight shebang if Bash is embedded. pop: 1 @@ -1714,7 +1716,7 @@ contexts: constant.numeric.value.shell 2: keyword.operator.assignment.redirection.shell embed: heredoc-begin - escape: ^\t*(\3)$\n? + escape: '{{tab_indent}}(\3)$\n?' escape_captures: 0: meta.tag.heredoc.end.shell 1: entity.name.tag.heredoc.shell @@ -1725,7 +1727,7 @@ contexts: constant.numeric.value.shell 2: keyword.operator.assignment.redirection.shell embed: heredoc-begin - escape: ^(\3)$\n? + escape: '{{no_indent}}(\3)$\n?' escape_captures: 0: meta.tag.heredoc.end.shell 1: entity.name.tag.heredoc.shell @@ -2932,6 +2934,11 @@ variables: # space, tab, newline, or one of the following characters: ‘|’, ‘&’, ‘;’, # ‘(’, ‘)’, ‘<’, or ‘>’. metachar: '[\s|&;()<>]' + wspace: (?:\s+|^) + + # Indentation and whitespace patterns + no_indent: ^ + tab_indent: ^\t* # Parameter expansions is_interpolation: (?=\$[({{{identifier_char}}{{special_variables}}]|`) @@ -2948,7 +2955,6 @@ variables: digit: \d varassign: '[-+]?=' - wspace: (?:\s+|^) no_escape_behind: (? Date: Tue, 6 Aug 2024 12:02:59 +0200 Subject: [PATCH 062/113] [Markdown] Improve embedded shells This commit... 1. merges code blocks with shell-script and interactive shells. Both now use the same extended syntax, which detects interactive shell by checking the first lines of code. 2. implements lazy indentation for shebang and HEREDOCs to scope them correctly, even if fenced code block is indented. --- .../Bash (for Markdown).sublime-syntax | 41 +++++ .../Zsh (for Markdown).sublime-syntax | 9 + Markdown/Markdown.sublime-syntax | 39 +---- Markdown/Shell (for Markdown).sublime-syntax | 29 ---- Markdown/tests/syntax_test_markdown.md | 164 +++++++++++++----- 5 files changed, 178 insertions(+), 104 deletions(-) create mode 100644 Markdown/Embeddings/Bash (for Markdown).sublime-syntax create mode 100644 Markdown/Embeddings/Zsh (for Markdown).sublime-syntax delete mode 100644 Markdown/Shell (for Markdown).sublime-syntax diff --git a/Markdown/Embeddings/Bash (for Markdown).sublime-syntax b/Markdown/Embeddings/Bash (for Markdown).sublime-syntax new file mode 100644 index 0000000000..b0d0d7a0a8 --- /dev/null +++ b/Markdown/Embeddings/Bash (for Markdown).sublime-syntax @@ -0,0 +1,41 @@ +%YAML 1.2 +--- +scope: source.shell.bash.embedded.markdown +version: 2 +hidden: true + +extends: Packages/ShellScript/Bash.sublime-syntax + +contexts: + main: + - meta_include_prototype: false + # found shebang => normal script + - match: ^(?=\s*#!) + set: [statements, shebang] + # first non-comment line starts with `$` => interactive shell + - match: ^(?=\s*\$\s) + set: shell-interactive + # some script without shebang + - match: ^(?=\s*[^#]) + set: statements + - include: comments + + shell-interactive: + - match: ^\s*(\$)(?=\s) + captures: + 1: comment.other.shell + embed: statements + escape: '{{no_escape_behind}}\n' + + line-continuation-body: + - meta_prepend: true + # continuation line of interactive shells begin with `> ` + - match: ^\s*(>)\s + captures: + 1: comment.other.shell + pop: 1 + +variables: + # lazy escaping from heredoc as shell maybe indented + no_indent: ^\s* + tab_indent: ^\s* diff --git a/Markdown/Embeddings/Zsh (for Markdown).sublime-syntax b/Markdown/Embeddings/Zsh (for Markdown).sublime-syntax new file mode 100644 index 0000000000..6beb998390 --- /dev/null +++ b/Markdown/Embeddings/Zsh (for Markdown).sublime-syntax @@ -0,0 +1,9 @@ +%YAML 1.2 +--- +scope: source.shell.zsh.embedded.markdown +version: 2 +hidden: true + +extends: + - Bash (for Markdown).sublime-syntax + - Packages/ShellScript/Zsh.sublime-syntax diff --git a/Markdown/Markdown.sublime-syntax b/Markdown/Markdown.sublime-syntax index 4c65f033b3..9d6ffd0db8 100644 --- a/Markdown/Markdown.sublime-syntax +++ b/Markdown/Markdown.sublime-syntax @@ -1128,7 +1128,6 @@ contexts: - include: fenced-rust - include: fenced-scala - include: fenced-shell - - include: fenced-shell-script - include: fenced-sql - include: fenced-tsx - include: fenced-typescript @@ -1931,7 +1930,7 @@ contexts: - match: |- (?x) {{fenced_code_block_start}} - (?i:\s*(console|shell)) + (?i:\s*(console|bash|shell(?:-script)?|sh)) {{fenced_code_block_trailing_infostring_characters}} captures: 0: meta.code-fence.definition.begin.shell.markdown-gfm @@ -1939,55 +1938,33 @@ contexts: 5: constant.other.language-name.markdown 6: comment.line.infostring.markdown 7: meta.fold.code-fence.begin.markdown - embed: scope:source.shell.interactive.markdown + embed: scope:source.shell.bash.embedded.markdown embed_scope: markup.raw.code-fence.shell.markdown-gfm - source.shell.interactive.markdown + source.shell.bash.embedded.markdown escape: '{{fenced_code_block_escape}}' escape_captures: 0: meta.code-fence.definition.end.shell.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown 2: meta.fold.code-fence.end.markdown - - fenced-shell-script: - - match: |- - (?x) - {{fenced_code_block_start}} - (?i:\s*(shell-script|sh|bash)) - {{fenced_code_block_trailing_infostring_characters}} - captures: - 0: meta.code-fence.definition.begin.shell-script.markdown-gfm - 2: punctuation.definition.raw.code-fence.begin.markdown - 5: constant.other.language-name.markdown - 6: comment.line.infostring.markdown - 7: meta.fold.code-fence.begin.markdown - embed: scope:source.shell.bash - embed_scope: - markup.raw.code-fence.shell-script.markdown-gfm - source.shell.bash - escape: '{{fenced_code_block_escape}}' - escape_captures: - 0: meta.code-fence.definition.end.shell-script.markdown-gfm - 1: punctuation.definition.raw.code-fence.end.markdown - 2: meta.fold.code-fence.end.markdown - match: |- (?x) {{fenced_code_block_start}} (?i:\s*(zsh)) {{fenced_code_block_trailing_infostring_characters}} captures: - 0: meta.code-fence.definition.begin.shell-script.markdown-gfm + 0: meta.code-fence.definition.begin.shell.markdown-gfm 2: punctuation.definition.raw.code-fence.begin.markdown 5: constant.other.language-name.markdown 6: comment.line.infostring.markdown 7: meta.fold.code-fence.begin.markdown - embed: scope:source.shell.zsh + embed: scope:source.shell.zsh.embedded.markdown embed_scope: - markup.raw.code-fence.shell-script.markdown-gfm - source.shell.zsh + markup.raw.code-fence.shell.markdown-gfm + source.shell.zsh.embedded.markdown escape: '{{fenced_code_block_escape}}' escape_captures: - 0: meta.code-fence.definition.end.shell-script.markdown-gfm + 0: meta.code-fence.definition.end.shell.markdown-gfm 1: punctuation.definition.raw.code-fence.end.markdown 2: meta.fold.code-fence.end.markdown diff --git a/Markdown/Shell (for Markdown).sublime-syntax b/Markdown/Shell (for Markdown).sublime-syntax deleted file mode 100644 index 92486b1383..0000000000 --- a/Markdown/Shell (for Markdown).sublime-syntax +++ /dev/null @@ -1,29 +0,0 @@ -%YAML 1.2 ---- -name: Interactive Unix Shell -scope: source.shell.interactive.markdown -version: 2 -hidden: true - -extends: Packages/ShellScript/Shell-Unix-Generic.sublime-syntax - -contexts: - main: - - match: ^(?=\s*\$\s) - push: shell-interactive - - include: statements - - shell-interactive: - - match: ^\s*(\$)(?=\s) - captures: - 1: comment.other.shell - embed: statements - escape: (? ` - - match: ^\s*(>)\s - captures: - 1: comment.other.shell - pop: 1 diff --git a/Markdown/tests/syntax_test_markdown.md b/Markdown/tests/syntax_test_markdown.md index 9d6afddc03..612c424efd 100644 --- a/Markdown/tests/syntax_test_markdown.md +++ b/Markdown/tests/syntax_test_markdown.md @@ -1783,19 +1783,55 @@ foo ## https://fenced-code-block-embedded-syntaxes-tests ```bash -| <- meta.code-fence.definition.begin.shell-script.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown -|^^ meta.code-fence.definition.begin.shell-script.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown -| ^^^^ meta.code-fence.definition.begin.shell-script.markdown-gfm constant.other.language-name.markdown -| ^ meta.code-fence.definition.begin.shell-script.markdown-gfm meta.fold.code-fence.begin +| <- meta.code-fence.definition.begin.shell.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown +|^^ meta.code-fence.definition.begin.shell.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown +| ^^^^ meta.code-fence.definition.begin.shell.markdown-gfm constant.other.language-name.markdown +| ^ meta.code-fence.definition.begin.shell.markdown-gfm meta.fold.code-fence.begin # test -| ^^^^^ source.shell comment.line.number-sign +| <- markup.raw.code-fence.shell.markdown-gfm source.shell.bash.embedded.markdown comment.line.number-sign.shell punctuation.definition.comment.shell +|^^^^^^ markup.raw.code-fence.shell.markdown-gfm source.shell.bash.embedded.markdown comment.line.number-sign.shell echo hello, \ | ^ punctuation.separator.continuation.line echo This is a smiley :-\) \(I have to escape the parentheses, though!\) | ^^ constant.character.escape +heredoc=< /foo/ -| <- markup.raw.code-fence.shell.markdown-gfm source.shell.interactive.markdown comment.other.shell -|^^^^^^^ markup.raw.code-fence.shell.markdown-gfm source.shell.interactive.markdown +| <- markup.raw.code-fence.shell.markdown-gfm source.shell.bash.embedded.markdown comment.other.shell +|^^^^^^^ markup.raw.code-fence.shell.markdown-gfm source.shell.bash.embedded.markdown $ ls \ > /foo/ bar -| <- markup.raw.code-fence.shell.markdown-gfm source.shell.interactive.markdown - meta.function-call -|^^^ markup.raw.code-fence.shell.markdown-gfm source.shell.interactive.markdown - meta.function-call - -function foo () {} -| <- markup.raw.code-fence.shell.markdown-gfm source.shell.interactive.markdown - meta.function -|^^^^^^^^^^^^^^^^^^ markup.raw.code-fence.shell.markdown-gfm source.shell.interactive.markdown - meta.function +| <- markup.raw.code-fence.shell.markdown-gfm source.shell.bash.embedded.markdown - meta.function-call +|^^^ markup.raw.code-fence.shell.markdown-gfm source.shell.bash.embedded.markdown - meta.function-call ``` | <- meta.code-fence.definition.end.shell.markdown-gfm punctuation.definition.raw.code-fence.end.markdown |^^ meta.code-fence.definition.end.shell.markdown-gfm punctuation.definition.raw.code-fence.end.markdown | ^ meta.code-fence.definition.end.shell.markdown-gfm meta.fold.code-fence.end - punctuation ```shell -| ^^^^^^^^ meta.code-fence.definition.begin - meta.fold - markup -| ^ meta.code-fence.definition.begin meta.fold.code-fence.begin - markup $ ls -| ^^^^^ markup.raw.code-fence.shell.markdown-gfm source.shell.interactive.markdown +| ^^^^^ markup.raw.code-fence.shell.markdown-gfm source.shell.bash.embedded.markdown | ^ comment.other.shell | ^^ meta.function-call.identifier.shell variable.function.shell ``` | ^^^ meta.code-fence.definition.end.shell.markdown-gfm punctuation.definition.raw.code-fence.end.markdown | ^ meta.code-fence.definition.end.shell.markdown-gfm meta.fold.code-fence.end - punctuation -```shell-script - -| <- markup.raw.code-fence.shell-script.markdown-gfm source.shell.bash -``` -| <- meta.code-fence.definition.end.shell-script.markdown-gfm punctuation.definition.raw.code-fence.end.markdown -|^^ meta.code-fence.definition.end.shell-script.markdown-gfm punctuation.definition.raw.code-fence.end.markdown - -```zsh -|^^^^^ meta.code-fence.definition.begin - meta.fold - markup -| ^ meta.code-fence.definition.begin meta.fold.code-fence.begin - markup - -| <- markup.raw.code-fence.shell-script.markdown-gfm source.shell.zsh -``` -| <- meta.code-fence.definition.end.shell-script.markdown-gfm punctuation.definition.raw.code-fence.end.markdown -|^^ meta.code-fence.definition.end.shell-script.markdown-gfm punctuation.definition.raw.code-fence.end.markdown - ```sql |^^^^^ meta.code-fence.definition.begin - meta.fold - markup | ^ meta.code-fence.definition.begin meta.fold.code-fence.begin - markup @@ -2191,6 +2215,58 @@ declare type foo = 'bar' |^^ meta.code-fence.definition.end.text.markdown-gfm punctuation.definition.raw.code-fence.end.markdown | ^ meta.code-fence.definition.end.text.markdown-gfm meta.fold.code-fence.end - punctuation +```zsh +|^^ meta.code-fence.definition.begin.shell.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown +| ^^^ meta.code-fence.definition.begin.shell.markdown-gfm constant.other.language-name.markdown +| ^ meta.code-fence.definition.begin meta.fold.code-fence.begin - markup +# test +| <- markup.raw.code-fence.shell.markdown-gfm source.shell.zsh.embedded.markdown comment.line.number-sign.shell punctuation.definition.comment.shell +|^^^^^^ markup.raw.code-fence.shell.markdown-gfm source.shell.zsh.embedded.markdown comment.line.number-sign.shell +echo hello, \ +| ^ punctuation.separator.continuation.line +echo This is a smiley :-\) \(I have to escape the parentheses, though!\) +| ^^ constant.character.escape +heredoc=< Date: Tue, 6 Aug 2024 12:20:03 +0200 Subject: [PATCH 063/113] [ShellScript] Reorganize some variables --- ShellScript/Bash.sublime-syntax | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 9b97bcad9f..80734106a9 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -2940,10 +2940,17 @@ variables: no_indent: ^ tab_indent: ^\t* + # A lookbehind used in embed..escape patterns, to check for unescaped characters + # in embed...escape statements. + no_escape_behind: (? Date: Tue, 6 Aug 2024 12:27:58 +0200 Subject: [PATCH 064/113] [ShellScript] Fix HEREDOCs in ZSH --- ShellScript/Zsh.sublime-syntax | 4 +- ShellScript/Zsh/tests/syntax_test_scope.zsh | 88 +++++++++++++++++++++ 2 files changed, 89 insertions(+), 3 deletions(-) diff --git a/ShellScript/Zsh.sublime-syntax b/ShellScript/Zsh.sublime-syntax index 722bf87a24..7586f0dc29 100644 --- a/ShellScript/Zsh.sublime-syntax +++ b/ShellScript/Zsh.sublime-syntax @@ -393,7 +393,7 @@ contexts: scope: keyword.operator.quantifier.regexp.shell.zsh zsh-pattern-ranges: - - match: (?=\d*<) + - match: (?=<[^<&]) branch_point: zsh-pattern-range branch: - zsh-pattern-range-begin @@ -404,8 +404,6 @@ contexts: - match: \< scope: punctuation.definition.range.begin.shell.zsh set: zsh-pattern-range-body - - match: \d+ - scope: meta.number.integer.decimal.shell constant.numeric.value.shell zsh-pattern-range-body: - meta_scope: meta.range.shell.zsh diff --git a/ShellScript/Zsh/tests/syntax_test_scope.zsh b/ShellScript/Zsh/tests/syntax_test_scope.zsh index c41c5ef544..6dd6752832 100644 --- a/ShellScript/Zsh/tests/syntax_test_scope.zsh +++ b/ShellScript/Zsh/tests/syntax_test_scope.zsh @@ -625,6 +625,89 @@ word # ^^^^^^^^^ meta.redirection.shell # ^^^^ keyword.operator.assignment.redirection.shell +heredoc=<<__HERE.DOC-TAG__ +# ^^ keyword.operator.assignment.redirection.shell +# ^^^^^^^^^^^^^^^^ meta.tag.heredoc.begin.shell entity.name.tag.heredoc.shell + + if [[ -z "~/$file" ]] then echo "${msg}"; fi; +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.heredoc.shell +# ^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^^^^^^ meta.interpolation.parameter.shell +__HERE.DOC-TAG__ +# <- meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell +#^^^^^^^^^^^^^^^ meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell +# ^ meta.tag.heredoc.end.shell - entity + +heredoc=<<'EOF' +# ^^ keyword.operator.assignment.redirection.shell +# ^^^^^ meta.tag.heredoc.begin.shell +# ^ punctuation.definition.tag.begin.shell +# ^^^ entity.name.tag.heredoc.shell +# ^ punctuation.definition.tag.end.shell + + if [[ -z "~/$file" ]] then echo "${msg}"; fi; +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.heredoc.shell string.unquoted.heredoc.shell - meta.interpolation +EOF +# <- meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell +#^^ meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell +# ^ meta.tag.heredoc.end.shell - entity + +heredoc=<<"EOF" +# ^^ keyword.operator.assignment.redirection.shell +# ^^^^^ meta.tag.heredoc.begin.shell +# ^ punctuation.definition.tag.begin.shell +# ^^^ entity.name.tag.heredoc.shell +# ^ punctuation.definition.tag.end.shell + + if [[ -z "~/$file" ]] then echo "${msg}"; fi; +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.heredoc.shell string.unquoted.heredoc.shell - meta.interpolation +EOF +# <- meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell +#^^ meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell +# ^ meta.tag.heredoc.end.shell - entity + +heredoc=<<-__HERE.DOC-TAG__ +# ^^^ keyword.operator.assignment.redirection.shell +# ^^^^^^^^^^^^^^^^ meta.tag.heredoc.begin.shell entity.name.tag.heredoc.shell + + if [[ -z "~/$file" ]] then echo "${msg}"; fi; +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.heredoc.shell +# ^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^^^^^^ meta.interpolation.parameter.shell +__HERE.DOC-TAG__ +# <- meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell +#^^^^^^^^^^^^^^^ meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell +# ^ meta.tag.heredoc.end.shell - entity + +heredoc=<<-'EOF' +# ^^^ keyword.operator.assignment.redirection.shell +# ^^^^^ meta.tag.heredoc.begin.shell +# ^ punctuation.definition.tag.begin.shell +# ^^^ entity.name.tag.heredoc.shell +# ^ punctuation.definition.tag.end.shell + + if [[ -z "~/$file" ]] then echo "${msg}"; fi; +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.heredoc.shell string.unquoted.heredoc.shell - meta.interpolation +EOF +# <- meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell +#^^ meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell +# ^ meta.tag.heredoc.end.shell - entity + +heredoc=<<-"EOF" +# ^^^ keyword.operator.assignment.redirection.shell +# ^^^^^ meta.tag.heredoc.begin.shell +# ^ punctuation.definition.tag.begin.shell +# ^^^ entity.name.tag.heredoc.shell +# ^ punctuation.definition.tag.end.shell + + if [[ -z "~/$file" ]] then echo "${msg}"; fi; +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.heredoc.shell string.unquoted.heredoc.shell - meta.interpolation +EOF +# <- meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell +#^^ meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell +# ^ meta.tag.heredoc.end.shell - entity + + ############################################################################### # 8 Command Execution # @@ -2819,6 +2902,11 @@ dyn_dir_name() { # ^^^^^ meta.range.shell.zsh # ^^^^^ meta.range.shell.zsh +: thisoutput +# ^^^^^^^ - meta.range +# ^ keyword.operator.assignment.redirection.shell +# ^ keyword.operator.assignment.redirection.shell + : foo/(a*/)#bar # bar matches foo/bar, foo/any/bar, foo/any/anyother/bar, ... # ^^^^ meta.string.shell string.unquoted.shell # ^^^^^ meta.string.shell meta.group.regexp.shell string.unquoted.shell From 3e2a3891a2d0246eb12dd9062b6eddd8eb052c40 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 6 Aug 2024 12:57:48 +0200 Subject: [PATCH 065/113] [ShellScript] Fix HERESTRING body This commit ensures the word after `<<<` operator is always scoped plain string without pattern matching or globbing being applied. That wasn't the case in assignment statements before. --- ShellScript/Bash.sublime-syntax | 11 +- ShellScript/Bash/tests/syntax_test_scope.bash | 114 +++++++++++++---- ShellScript/Zsh/tests/syntax_test_scope.zsh | 119 +++++++++++++++--- 3 files changed, 201 insertions(+), 43 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 80734106a9..3b503a4074 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -1706,7 +1706,16 @@ contexts: 1: meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell - 2: keyword.operator.herestring.shell + 2: keyword.operator.assignment.herestring.shell + push: here-string-body + + here-string-body: + - meta_include_prototype: false + - meta_content_scope: meta.string.herestring.shell string.unquoted.shell + - include: line-continuations + - include: string-unquoted-content + - match: '{{word_break}}' + pop: 1 redirections-here-document: - match: (\d*)(<<-)\s*(?=["'\\]?({{heredoc}})) diff --git a/ShellScript/Bash/tests/syntax_test_scope.bash b/ShellScript/Bash/tests/syntax_test_scope.bash index 95681bf816..0af3bce087 100644 --- a/ShellScript/Bash/tests/syntax_test_scope.bash +++ b/ShellScript/Bash/tests/syntax_test_scope.bash @@ -9183,33 +9183,6 @@ Hello, ${var} WHAT # <- meta.function-call.arguments.shell meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell - meta.string - string -cat <<< "A wild herestring appears" ; cat more stuff | bar | qux -# <- meta.function-call.identifier.shell variable.function.shell -# ^^^ meta.function-call.arguments keyword.operator.herestring -# ^ meta.function-call.arguments string.quoted.double punctuation.definition.string.begin -# ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments string.quoted.double -# ^ meta.function-call.arguments string.quoted.double punctuation.definition.string.end -# ^ -# ^ punctuation.terminator.statement -# ^ - meta.function-call -# ^^^ meta.function-call.identifier.shell variable.function.shell -# ^^^^^^^^^^^ meta.function-call.arguments -# ^ keyword.operator.assignment.pipe.shell -# ^ keyword.operator.assignment.pipe.shell - -if opam upgrade --check; then - opam upgrade --dry-run <<& 1 # ^^^^ meta.redirection.shell @@ -625,6 +610,22 @@ word # ^^^^^^^^^ meta.redirection.shell # ^^^^ keyword.operator.assignment.redirection.shell + +############################################################################### +# 7 Redirection # +# HERE DOCUMENTS # +############################################################################### + +# The shell input is read up to a line that is the same as word, or to an +# end-of-file. +: << word +# ^^ keyword.operator.assignment.redirection.shell +# ^^^^ meta.tag.heredoc.begin.shell entity.name.tag.heredoc.shell +word +# <- meta.function-call.arguments.shell meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell +#^^^ meta.function-call.arguments.shell meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell +# ^ meta.function-call.arguments.shell meta.tag.heredoc.end.shell - entity + heredoc=<<__HERE.DOC-TAG__ # ^^ keyword.operator.assignment.redirection.shell # ^^^^^^^^^^^^^^^^ meta.tag.heredoc.begin.shell entity.name.tag.heredoc.shell @@ -708,6 +709,94 @@ EOF # ^ meta.tag.heredoc.end.shell - entity +############################################################################### +# 7 Redirection # +# HERESTRINGS # +############################################################################### + +# Perform shell expansion on word and pass the result to standard input. + +: <<< word --opt ~/**/[Ff]oo?.bar +# ^^^ keyword.operator.assignment.herestring +# ^^^^ meta.string.herestring.shell string.unquoted.shell +# ^^^^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^^^^^^^^^^^^^^^ meta.string.shell +# ^ variable.language.tilde.shell +# ^^ constant.other.wildcard.asterisk.shell +# ^^^^ meta.set.regexp.shell +# ^ constant.other.wildcard.questionmark.shell + +: <<< "word --opt ~/**/[Ff]oo?.bar" +# ^^^ keyword.operator.assignment.herestring +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.herestring.shell string.quoted.double.shell - constant - variable + +: 1<<< "word --opt" +# ^ meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell +# ^^^ keyword.operator.assignment.herestring +# ^^^^^^^^^^^^ meta.string.herestring.shell string.quoted.double.shell + +herestring=<<<${here}string +# ^^^ keyword.operator.assignment.herestring +# ^^^^^^^ meta.string.herestring.shell meta.interpolation.parameter.shell +# ^^^^^^ meta.string.herestring.shell string.unquoted.shell +# + +herestring=<<<"This is a \\$here \"\$string.\"" +# ^^^^^^^^^^^^^ meta.string.herestring.shell string.quoted.double.shell - meta.interpolation +# ^^^^^ meta.string.herestring.shell meta.interpolation.parameter.shell - string +# ^^^^^^^^^^^^^^^ meta.string.herestring.shell string.quoted.double.shell - meta.interpolation +# ^^^ keyword.operator.assignment.herestring +# ^ punctuation.definition.string.begin.shell +# ^^ constant.character.escape.shell +# ^^^^^ variable.other.readwrite.shell +# ^ punctuation.definition.variable.shell +# ^^^^ constant.character.escape.shell +# ^^ constant.character.escape.shell +# ^ punctuation.definition.string.end.shell + +cat <<< "This is a \\$here \"\$string.\"" ; cat more stuff | bar | qux +# <- meta.function-call.identifier.shell variable.function.shell +# ^^^^ meta.function-call.arguments.shell - meta.string +# ^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.herestring.shell string.quoted.double.shell - meta.interpolation +# ^^^^^ meta.function-call.arguments.shell meta.string.herestring.shell meta.interpolation.parameter.shell - string +# ^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.herestring.shell string.quoted.double.shell - meta.interpolation +# ^^^ - meta.function-call +# ^^^ meta.function-call.identifier.shell +# ^^^^^^^^^^^ meta.function-call.arguments.shell +# ^^^ - meta.function-call +# ^^^ meta.function-call.identifier.shell +# ^^^ - meta.function-call +# ^^^ meta.function-call.identifier.shell +# ^^^ keyword.operator.assignment.herestring +# ^ punctuation.definition.string.begin.shell +# ^^ constant.character.escape.shell +# ^^^^^ variable.other.readwrite.shell +# ^ punctuation.definition.variable.shell +# ^^^^ constant.character.escape.shell +# ^^ constant.character.escape.shell +# ^ punctuation.definition.string.end.shell +# ^ punctuation.terminator.statement.shell +# ^^^ variable.function.shell +# ^^^^ meta.string.shell string.unquoted.shell +# ^^^^^ meta.string.shell string.unquoted.shell +# ^ keyword.operator.assignment.pipe.shell +# ^^^ variable.function.shell +# ^ keyword.operator.assignment.pipe.shell +# ^^^ variable.function.shell + +cat -c <<<$(echo pipephobic) +# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments +# ^^^ keyword.operator.assignment.herestring.shell +# ^^^^^^^^^^^^^^^^^^ meta.string.herestring.shell meta.interpolation.command.shell +# ^^^^ support.function + +if opam upgrade --check; then + opam upgrade --dry-run << Date: Tue, 6 Aug 2024 18:51:28 +0200 Subject: [PATCH 066/113] [ShellScript] Remove obsolete parameter expansion context --- ShellScript/Bash.sublime-syntax | 26 +++++++------------ ShellScript/Bash/tests/syntax_test_scope.bash | 2 +- ShellScript/Zsh.sublime-syntax | 4 +-- 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 3b503a4074..39996614f8 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -2682,7 +2682,7 @@ contexts: - match: :?[-+=?] scope: keyword.operator.assignment.shell set: - - expansion-parameter-value + - expansion-parameter-pattern - maybe-tilde-interpolation # ${parameter:offset:length} - match: ':' @@ -2721,6 +2721,14 @@ contexts: - include: expansion-parameter-end - include: expression-content + expansion-parameter-substitution-pattern: + # [3.5.8.1] Pattern Matching in parameter expansions' substitutions + - meta_content_scope: meta.string.regexp.shell string.unquoted.shell + - match: / + scope: keyword.operator.substitution.shell + set: expansion-parameter-string + - include: expansion-parameter-pattern + expansion-parameter-pattern: # [3.5.8.1] Pattern Matching in parameter expansions - meta_content_scope: meta.string.regexp.shell string.unquoted.shell @@ -2794,26 +2802,12 @@ contexts: - include: pattern-charset-end - include: pattern-charset-content - expansion-parameter-substitution-pattern: - # [3.5.8.1] Pattern Matching in parameter expansions' substitutions - - meta_content_scope: meta.string.regexp.shell string.unquoted.shell - - match: / - scope: keyword.operator.substitution.shell - set: expansion-parameter-substitution-value - - include: expansion-parameter-pattern - - expansion-parameter-substitution-value: + expansion-parameter-string: - meta_include_prototype: false - meta_content_scope: meta.string.shell string.unquoted.shell - include: expansion-parameter-end - include: string-unquoted-content - expansion-parameter-value: - - meta_include_prototype: false - - meta_content_scope: meta.string.shell string.unquoted.shell - - include: expansion-parameter-end - - include: pattern-main-content - expansion-parameter-end: - match: \} scope: punctuation.section.interpolation.end.shell diff --git a/ShellScript/Bash/tests/syntax_test_scope.bash b/ShellScript/Bash/tests/syntax_test_scope.bash index 0af3bce087..473064dfff 100644 --- a/ShellScript/Bash/tests/syntax_test_scope.bash +++ b/ShellScript/Bash/tests/syntax_test_scope.bash @@ -7692,7 +7692,7 @@ a\/b/c/d} : ${foo:="$bar"} # ^^^^^^^^ meta.interpolation.parameter.shell - meta.interpolation meta.interpolation -# ^^^^ meta.interpolation.parameter.shell meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^^^^ meta.interpolation.parameter.shell meta.interpolation.parameter.shell variable.other.readwrite.shell # ^^ meta.interpolation.parameter.shell - meta.interpolation meta.interpolation # ^ punctuation.definition.string.begin.shell # ^ punctuation.definition.variable.shell diff --git a/ShellScript/Zsh.sublime-syntax b/ShellScript/Zsh.sublime-syntax index 7586f0dc29..2184402b39 100644 --- a/ShellScript/Zsh.sublime-syntax +++ b/ShellScript/Zsh.sublime-syntax @@ -515,12 +515,12 @@ contexts: - match: ::= scope: keyword.operator.assignment.shell.zsh set: - - expansion-parameter-value + - expansion-parameter-pattern - maybe-tilde-interpolation - match: :# scope: keyword.operator.assignment.shell.zsh set: - - expansion-parameter-value + - expansion-parameter-pattern - maybe-tilde-interpolation expansion-parameter-pattern: From ebd183c24f88d5e688d76448b07f1b5c96332ef3 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 6 Aug 2024 21:02:27 +0200 Subject: [PATCH 067/113] [ShellScript] Exclude prototype from all string contexts ... to prefer and enforce usage of `string-prototype`. --- ShellScript/Bash.sublime-syntax | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 39996614f8..eb272fdf13 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -662,6 +662,7 @@ contexts: - include: test-expression-common compound-test-eregexp: + - meta_include_prototype: false - meta_content_scope: meta.string.regexp.shell string.unquoted.shell - match: (?=[\s;]) pop: 1 @@ -669,6 +670,7 @@ contexts: - include: eregexp-main-content compound-test-pattern: + - meta_include_prototype: false - meta_content_scope: meta.string.regexp.shell string.unquoted.shell - match: (?=[\s;]) pop: 1 @@ -698,11 +700,13 @@ contexts: - include: test-expression-common compound-test-group-eregexp: + - meta_include_prototype: false - meta_content_scope: meta.string.regexp.shell string.unquoted.shell - include: compound-test-group-pattern-end - include: eregexp-group-content compound-test-group-pattern: + - meta_include_prototype: false - meta_content_scope: meta.string.regexp.shell string.unquoted.shell - include: compound-test-group-pattern-end - include: pattern-group-content @@ -1112,6 +1116,7 @@ contexts: push: case-clause-pattern case-clause-pattern: + - meta_include_prototype: false - meta_content_scope: meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell - match: \) scope: meta.clause.pattern.shell punctuation.definition.pattern.end.shell @@ -1140,6 +1145,7 @@ contexts: case-clause-pattern-group-body: - clear_scopes: 1 # clear `string.unquoted` + - meta_include_prototype: false - meta_content_scope: meta.group.regexp.shell string.unquoted.shell - include: pattern-group-end - include: case-clause-pattern-content @@ -2007,6 +2013,7 @@ contexts: - maybe-tilde-interpolation string-path-pattern-body: + - meta_include_prototype: false - meta_scope: meta.string.shell string.unquoted.shell - include: line-continuations - include: string-path-pattern-content @@ -2243,6 +2250,7 @@ contexts: pattern-group-body: - clear_scopes: 1 # clear `string.unquoted` + - meta_include_prototype: false - meta_content_scope: meta.group.regexp.shell string.unquoted.shell - include: pattern-group-end - include: pattern-group-content @@ -2311,6 +2319,7 @@ contexts: eregexp-group-body: - clear_scopes: 1 # clear `string.unquoted` + - meta_include_prototype: false - meta_scope: meta.group.regexp.shell string.unquoted.shell - match: \) scope: punctuation.section.group.end.regexp.shell @@ -2723,6 +2732,7 @@ contexts: expansion-parameter-substitution-pattern: # [3.5.8.1] Pattern Matching in parameter expansions' substitutions + - meta_include_prototype: false - meta_content_scope: meta.string.regexp.shell string.unquoted.shell - match: / scope: keyword.operator.substitution.shell @@ -2731,6 +2741,7 @@ contexts: expansion-parameter-pattern: # [3.5.8.1] Pattern Matching in parameter expansions + - meta_include_prototype: false - meta_content_scope: meta.string.regexp.shell string.unquoted.shell - include: expansion-parameter-end - include: string-unquoted-content @@ -2770,6 +2781,7 @@ contexts: expansion-parameter-pattern-group-body: - clear_scopes: 1 # clear `string.unquoted` + - meta_include_prototype: false - meta_content_scope: meta.group.regexp.shell string.unquoted.shell - include: pattern-group-end - include: string-unquoted-content From dd8ed902a5621d8bd0e618883d53d97625046c87 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 6 Aug 2024 21:08:52 +0200 Subject: [PATCH 068/113] [ShellScript] Fix context order --- ShellScript/Zsh.sublime-syntax | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ShellScript/Zsh.sublime-syntax b/ShellScript/Zsh.sublime-syntax index 2184402b39..2ef690a578 100644 --- a/ShellScript/Zsh.sublime-syntax +++ b/ShellScript/Zsh.sublime-syntax @@ -529,12 +529,6 @@ contexts: - include: zsh-pattern-operators - include: zsh-pattern-ranges - expansion-parameter-pattern-group-body: - - meta_prepend: true - - include: zsh-pattern-flags - - include: zsh-pattern-operators - - include: zsh-pattern-ranges - expansion-parameter-pattern-groups: # KSH_GLOB is optional (hence not matching ? and * in favor of ZSH globs) - match: ([+@!]??)(\() @@ -543,6 +537,12 @@ contexts: 2: meta.group.regexp.shell string.unquoted.shell punctuation.definition.group.begin.regexp.shell push: expansion-parameter-pattern-group-body + expansion-parameter-pattern-group-body: + - meta_prepend: true + - include: zsh-pattern-flags + - include: zsh-pattern-operators + - include: zsh-pattern-ranges + zsh-parameter-subscription: - meta_include_prototype: false - meta_scope: meta.interpolation.parameter.shell From 497e9d2baa3a21f8768d49c8c9c102a942b97c33 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Wed, 7 Aug 2024 10:14:42 +0200 Subject: [PATCH 069/113] [ShellScript] Add special treatment of mapfile built-in --- ShellScript/Bash.sublime-syntax | 37 ++++++++++- ShellScript/Bash/tests/syntax_test_scope.bash | 64 +++++++++++++++++++ ShellScript/Zsh.sublime-syntax | 2 + ShellScript/Zsh/tests/syntax_test_scope.zsh | 10 +++ 4 files changed, 112 insertions(+), 1 deletion(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index eb272fdf13..d524aaf330 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -64,6 +64,7 @@ contexts: - include: cmd-exec - include: cmd-export - include: cmd-historic + - include: cmd-mapfile - include: cmd-readonly - include: cmd-sudo - include: cmd-test @@ -537,6 +538,35 @@ contexts: set: cmd-args-end-of-options-then-function-declarations - include: cmd-args-end-of-options-then-variables-literal-values +###[ MAPFILE BUILTINS ]######################################################## + + cmd-mapfile: + # bash only + - match: mapfile{{cmd_break}} + scope: + meta.function-call.identifier.shell + support.function.shell + set: + - cmd-args-meta + - cmd-mapfile-args + + cmd-mapfile-args: + - match: ([-+])t*C{{opt_break}} + scope: + meta.parameter.option.shell + variable.parameter.option.shell + captures: + 1: punctuation.definition.parameter.shell + push: cmd-args-option-maybe-command + - match: ([-+])[t]*[cdnOsu]{{opt_break}} + scope: + meta.parameter.option.shell + variable.parameter.option.shell + captures: + 1: punctuation.definition.parameter.shell + push: cmd-args-option-maybe-value + - include: cmd-args-end-of-options-then-variables-literal-values + ###[ READONLY BUILTINS ]####################################################### cmd-readonly: @@ -907,6 +937,11 @@ contexts: - include: line-continuations - include: immediately-pop + cmd-args-option-maybe-command: + - include: cmd-args-end + - include: statements-word + - include: else-pop + cmd-args-option-maybe-value: # NOTE: this context is used in commands-builtin-shell-bash.sublime-syntax - meta_include_prototype: false @@ -2984,7 +3019,7 @@ variables: # Note: Contains thosw, which are not present as dedicated context builtin_cmds: |- (?x: \. | \: | bg | bind | caller | cd | disown | enable | eval | fg - | getopts | hash | help | jobs | kill | logout | mapfile | printf | pwd + | getopts | hash | help | jobs | kill | logout | printf | pwd | read | readarray | set | shift | shopt | source | su | suspend | times | type | ulimit | umask | wait ){{cmd_break}} diff --git a/ShellScript/Bash/tests/syntax_test_scope.bash b/ShellScript/Bash/tests/syntax_test_scope.bash index 473064dfff..a7bee9a420 100644 --- a/ShellScript/Bash/tests/syntax_test_scope.bash +++ b/ShellScript/Bash/tests/syntax_test_scope.bash @@ -10823,6 +10823,70 @@ f() { # <- meta.function.body.shell meta.block.shell punctuation.section.block.end.shell +############################################################################### +# 4.2 Bash Builtin Commands (mapfile) # +# https://www.gnu.org/software/bash/manual/bash.html#index-mapfile # +# mapfile [-d delim] [-n count] [-O origin] [-s count] # +# [-t] [-u fd] [-C callback] [-c quantum] [array] # +############################################################################### + +mapfile +# <- meta.function-call.identifier.shell support.function.shell +#^^^^^^ meta.function-call.identifier.shell support.function.shell +# ^ - meta.function-call + +mapfile array +# <- meta.function-call.identifier.shell support.function.shell +#^^^^^^ meta.function-call.identifier.shell support.function.shell +# ^^^^^^ meta.function-call.arguments.shell +# ^^^^^ variable.other.readwrite.shell +# ^ - meta.function-call + +mapfile -C ; result=10 +# ^^^ meta.function-call.arguments.shell +# ^^^^^^^^^^^^^ - meta.function-call +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^ punctuation.terminator.statement.shell +# ^^^^^^ variable.other.readwrite.shell +# ^ keyword.operator.assignment.shell +# ^^ string.unquoted.shell + +mapfile -C "~/.bin/app -p $val arg" array +# <- meta.function-call.identifier.shell support.function.shell +#^^^^^^ meta.function-call.identifier.shell support.function.shell +# ^^^^ meta.function-call.arguments.shell - meta.string +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^ meta.function-call.arguments.shell meta.string.shell string.quoted.double.shell punctuation.section.string.begin.shell +# ^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell meta.function-call.identifier.shell +# ^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell meta.function-call.arguments.shell +# ^ meta.function-call.arguments.shell meta.string.shell string.quoted.double.shell punctuation.section.string.end.shell +# ^ meta.function-call.arguments.shell - meta.string - variable +# ^^^^^ meta.function-call.arguments.shell meta.variable.shell variable.other.readwrite.shell +# ^ - meta.function-call + +mapfile -d ";" -n 10 -O $origin -s 5 -t -u 20 -C callback -c 10 array +# <- meta.function-call.identifier.shell support.function.shell +#^^^^^^ meta.function-call.identifier.shell support.function.shell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell +# ^ - meta.function-call +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^^ meta.string.shell string.quoted.double.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^^^^^^ meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^^^^^^^ meta.string.shell variable.function.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^^^^^ meta.variable.shell variable.other.readwrite.shell + + ############################################################################### # 4.2 Bash Builtin Commands (readonly) # # https://www.gnu.org/software/bash/manual/bash.html#index-readonly # diff --git a/ShellScript/Zsh.sublime-syntax b/ShellScript/Zsh.sublime-syntax index 2ef690a578..2d2c9c425d 100644 --- a/ShellScript/Zsh.sublime-syntax +++ b/ShellScript/Zsh.sublime-syntax @@ -101,6 +101,8 @@ contexts: - cmd-args-meta - cmd-args-end-of-options-then-function-references + cmd-mapfile: [] + ###[ COMMANDS ]################################################################ cmd-compound: diff --git a/ShellScript/Zsh/tests/syntax_test_scope.zsh b/ShellScript/Zsh/tests/syntax_test_scope.zsh index 06ed1ae5b4..e1f374f3a6 100644 --- a/ShellScript/Zsh/tests/syntax_test_scope.zsh +++ b/ShellScript/Zsh/tests/syntax_test_scope.zsh @@ -3707,3 +3707,13 @@ echo $var[1] World # ^^^^^^^^^^^^^^^^^^^^^^^ variable.language.builtin.shell : $ZLE_RPROMPT_INDENT # ^^^^^^^^^^^^^^^^^^^ variable.language.builtin.shell + + +############################################################################## +# 17 Shell Builtin Commands +# https://zsh.sourceforge.io/Doc/Release/Shell-Builtin-Commands.html +############################################################################## + +mapfile # mapfile is not a known/built-in command in ZSH +# <- meta.function-call.identifier.shell variable.function.shell - support.function +#^^^^^^ meta.function-call.identifier.shell variable.function.shell - support.function From 6e9a4b3d80ca6e34bb9751ac19a44794b4f50051 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Wed, 7 Aug 2024 10:35:20 +0200 Subject: [PATCH 070/113] [ShellScript] Tweak command reference scopes and symbols This commit... 1. introduces a common `meta.command` scope applied to function calls and function name references. 2. adjusts reference definitions accordingly. Goal is a common and unique scope to target function or command references. --- ShellScript/Bash.sublime-syntax | 14 +- ShellScript/Bash/tests/syntax_test_scope.bash | 184 +++++++++--------- .../Bash/tests/syntax_test_symbol.bash | 12 ++ .../Reference List - Functions.tmPreferences | 4 +- ShellScript/Zsh/tests/syntax_test_scope.zsh | 50 ++--- 5 files changed, 138 insertions(+), 126 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index d524aaf330..ca3007fe78 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -328,7 +328,7 @@ contexts: - alias-name-chars alias-name-chars: - - meta_scope: meta.variable.shell entity.name.function.shell + - meta_scope: meta.command.shell entity.name.function.shell - include: line-continuations - include: literal-unquoted-content - match: '{{opt_break}}' @@ -857,10 +857,10 @@ contexts: cmd-builtin: # cmd modifier commands are directly followed by simple commands - match: '{{modifier_cmds}}' - scope: meta.function-call.identifier.shell meta.path.shell support.function.shell + scope: meta.function-call.identifier.shell meta.command.shell support.function.shell # shell built-in commands with arbritary arguments - match: '{{builtin_cmds}}' - scope: meta.function-call.identifier.shell meta.path.shell support.function.shell + scope: meta.function-call.identifier.shell meta.command.shell support.function.shell push: - cmd-args-meta - cmd-args @@ -890,7 +890,7 @@ contexts: - path-pattern-begin cmd-name-body: - - meta_scope: meta.function-call.identifier.shell meta.path.shell variable.function.shell + - meta_scope: meta.function-call.identifier.shell meta.command.shell variable.function.shell - include: line-continuations - include: path-pattern-content - match: '{{cmd_break}}' @@ -984,7 +984,7 @@ contexts: push: function-declaration-name-chars function-declaration-name-chars: - - meta_scope: meta.variable.shell entity.name.function.shell + - meta_scope: meta.command.shell entity.name.function.shell - include: line-continuations - include: literal-unquoted-content - match: '{{word_break}}' @@ -1003,7 +1003,7 @@ contexts: push: function-reference-name-chars function-reference-name-chars: - - meta_scope: meta.variable.shell variable.function.shell + - meta_scope: meta.command.shell variable.function.shell - include: line-continuations - include: literal-unquoted-content - match: '{{word_break}}' @@ -1462,7 +1462,7 @@ contexts: - path-pattern-begin unquoted-statements-word-body: - - meta_scope: meta.string.shell meta.path.shell variable.function.shell + - meta_scope: meta.string.shell meta.command.shell variable.function.shell - include: line-continuations - include: path-pattern-content - match: '{{cmd_break}}' diff --git a/ShellScript/Bash/tests/syntax_test_scope.bash b/ShellScript/Bash/tests/syntax_test_scope.bash index a7bee9a420..0e469fc31e 100644 --- a/ShellScript/Bash/tests/syntax_test_scope.bash +++ b/ShellScript/Bash/tests/syntax_test_scope.bash @@ -340,8 +340,8 @@ echo git rev-list "$(echo --all)" | grep -P 'c354a80' # ^^^^^^^^^ meta.string.shell string.quoted.single.shell ' echo ' -# <- meta.function-call.identifier.shell meta.path.shell -#^^^^^^^ meta.function-call.identifier.shell meta.path.shell +# <- meta.function-call.identifier.shell meta.command.shell +#^^^^^^^ meta.function-call.identifier.shell meta.command.shell # <- variable.function.shell punctuation.definition.quoted.begin.shell #^^^^^^^ variable.function.shell # ^ punctuation.definition.quoted.end.shell @@ -418,8 +418,8 @@ $e'ch'o Hello, world! # ^ punctuation.definition.quoted.end.shell ./~foo/../bar../baz.sh -# <- meta.function-call.identifier.shell meta.path.shell variable.function.shell constant.other.path.self.shell -#^^^^^^^^^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# <- meta.function-call.identifier.shell meta.command.shell variable.function.shell constant.other.path.self.shell +#^^^^^^^^^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell #^ punctuation.separator.path.shell # ^ - variable.language # ^ punctuation.separator.path.shell @@ -429,8 +429,8 @@ $e'ch'o Hello, world! # ^ punctuation.separator.path.shell "./~foo/../bar../baz.sh" -# <- meta.function-call.identifier.shell meta.path.shell variable.function.shell punctuation.definition.quoted.begin.shell -#^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# <- meta.function-call.identifier.shell meta.command.shell variable.function.shell punctuation.definition.quoted.begin.shell +#^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell #^ constant.other.path.self.shell # ^ punctuation.separator.path.shell # ^ - variable.language @@ -442,8 +442,8 @@ $e'ch'o Hello, world! # ^ punctuation.definition.quoted.end.shell "./"~foo"/../"bar"../"baz.sh -# <- meta.function-call.identifier.shell meta.path.shell variable.function.shell punctuation.definition.quoted.begin.shell -#^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# <- meta.function-call.identifier.shell meta.command.shell variable.function.shell punctuation.definition.quoted.begin.shell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell #^ constant.other.path.self.shell # ^ punctuation.separator.path.shell # ^ punctuation.definition.quoted.end.shell @@ -459,8 +459,8 @@ $e'ch'o Hello, world! # ^ punctuation.definition.quoted.end.shell ../my?script[1-9].* -# <- meta.function-call.identifier.shell meta.path.shell variable.function.shell constant.other.path.parent.shell -#^^^^^^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# <- meta.function-call.identifier.shell meta.command.shell variable.function.shell constant.other.path.parent.shell +#^^^^^^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell #^ constant.other.path.parent.shell # ^ punctuation.separator.path.shell # ^ constant.other.wildcard.questionmark.shell @@ -471,8 +471,8 @@ $e'ch'o Hello, world! # ^ constant.other.wildcard.asterisk.shell "../my?script[1-9].*" # no pattern matching within quotes -# <- meta.function-call.identifier.shell meta.path.shell variable.function.shell punctuation.definition.quoted.begin.shell -#^^^^^^^^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# <- meta.function-call.identifier.shell meta.command.shell variable.function.shell punctuation.definition.quoted.begin.shell +#^^^^^^^^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell #^^ constant.other.path.parent.shell # ^ punctuation.separator.path.shell # ^ - constant @@ -750,9 +750,9 @@ sleep 2 & jobs # ^^ - variable [foo] -o -# <- meta.function-call.identifier.shell meta.path.shell variable.function.shell meta.set.regexp.shell punctuation.definition.set.begin.regexp.shell -#^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell meta.set.regexp.shell - punctuation -# ^ meta.function-call.identifier.shell meta.path.shell variable.function.shell meta.set.regexp.shell punctuation.definition.set.end.regexp.shell +# <- meta.function-call.identifier.shell meta.command.shell variable.function.shell meta.set.regexp.shell punctuation.definition.set.begin.regexp.shell +#^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell meta.set.regexp.shell - punctuation +# ^ meta.function-call.identifier.shell meta.command.shell variable.function.shell meta.set.regexp.shell punctuation.definition.set.end.regexp.shell # ^^^ meta.function-call.arguments.shell $foo -o @@ -1578,22 +1578,22 @@ until+= until test-commands --arg val; do cmd --arg; done # <- keyword.control.loop.until.shell #^^^^ keyword.control.loop.until.shell -# ^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell # ^^^^^^^^^^ meta.function-call.arguments.shell # ^ punctuation.terminator.statement.shell # ^^ keyword.control.loop.do.shell -# ^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell # ^^^^^^ meta.function-call.arguments.shell # ^ punctuation.terminator.statement.shell # ^^^^ keyword.control.loop.end.shell until test-commands --arg val; do cmd --arg; done -# ^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell # ^^^^^^^^^^ meta.function-call.arguments.shell # ^ punctuation.terminator.statement.shell # ^^ keyword.control.loop.do.shell -# ^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell # ^^^^^^ meta.function-call.arguments.shell # ^ punctuation.terminator.statement.shell # ^^^^ keyword.control.loop.end.shell @@ -1604,7 +1604,7 @@ until #^^^^^^^^^^ meta.function-call.arguments.shell # ^ punctuation.terminator.statement.shell # ^^ keyword.control.loop.do.shell -# ^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell # ^^^^^^ meta.function-call.arguments.shell # ^ punctuation.terminator.statement.shell # ^^^^ keyword.control.loop.end.shell @@ -1615,7 +1615,7 @@ until #^^^^^^^^^^ meta.function-call.arguments.shell do cmd --arg; done # ^^ keyword.control.loop.do.shell -# ^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell # ^^^^^^ meta.function-call.arguments.shell # ^ punctuation.terminator.statement.shell # ^^^^ keyword.control.loop.end.shell @@ -1681,22 +1681,22 @@ while+= while test-commands --arg val; do cmd --arg; done # <- keyword.control.loop.while.shell #^^^^ keyword.control.loop.while.shell -# ^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell # ^^^^^^^^^^ meta.function-call.arguments.shell # ^ punctuation.terminator.statement.shell # ^^ keyword.control.loop.do.shell -# ^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell # ^^^^^^ meta.function-call.arguments.shell # ^ punctuation.terminator.statement.shell # ^^^^ keyword.control.loop.end.shell while test-commands --arg val; do cmd --arg; done -# ^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell # ^^^^^^^^^^ meta.function-call.arguments.shell # ^ punctuation.terminator.statement.shell # ^^ keyword.control.loop.do.shell -# ^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell # ^^^^^^ meta.function-call.arguments.shell # ^ punctuation.terminator.statement.shell # ^^^^ keyword.control.loop.end.shell @@ -1707,7 +1707,7 @@ while #^^^^^^^^^^ meta.function-call.arguments.shell # ^ punctuation.terminator.statement.shell # ^^ keyword.control.loop.do.shell -# ^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell # ^^^^^^ meta.function-call.arguments.shell # ^ punctuation.terminator.statement.shell # ^^^^ keyword.control.loop.end.shell @@ -1718,7 +1718,7 @@ while #^^^^^^^^^^ meta.function-call.arguments.shell do cmd --arg; done # ^^ keyword.control.loop.do.shell -# ^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell # ^^^^^^ meta.function-call.arguments.shell # ^ punctuation.terminator.statement.shell # ^^^^ keyword.control.loop.end.shell @@ -2353,8 +2353,8 @@ echo Deploying... # ^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell punctuation.definition.pattern.end.shell # ^ meta.statement.conditional.case.body.shell meta.clause.shell cat <<'ENDCAT' # comment -# <- meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.identifier.shell meta.path.shell variable.function.shell -#^^ meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.identifier.shell meta.path.shell variable.function.shell +# <- meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.identifier.shell meta.command.shell variable.function.shell +#^^ meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.identifier.shell meta.command.shell variable.function.shell # ^^ meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.arguments.shell - meta.string - meta.tag # ^^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.arguments.shell meta.tag.heredoc.begin.shell - string.unquoted.heredoc # ^^^^^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.arguments.shell - meta.tag - string.unquoted.heredoc @@ -2802,7 +2802,7 @@ function ; {} arg # <- meta.function-call.shell meta.function.anonymous.shell keyword.declaration.function.shell #^^^^^^^^ meta.function-call.shell meta.function.anonymous.shell # ^^^^^^^^^ - meta.function.anonymous -# ^^ meta.function-call.identifier.shell meta.path.shell +# ^^ meta.function-call.identifier.shell meta.command.shell # ^^^^ meta.function-call.arguments.shell #^^^^^^^ keyword.declaration.function.shell # ^ punctuation.terminator.statement.shell @@ -3115,7 +3115,7 @@ foo:foo () { } "~" # <- meta.function-call.identifier.shell variable.function.shell punctuation.definition.quoted.begin.shell -#^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +#^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell # ^ punctuation.definition.quoted.end.shell ^ () { # <- meta.function entity.name.function @@ -3769,8 +3769,8 @@ my-var=20 # not a variable due to command interpolation in name B$(cat)OWL=$(($(cat food.txt | wc -l) + 5)) -# <- meta.function-call.identifier.shell meta.path.shell -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell +# <- meta.function-call.identifier.shell meta.command.shell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.command.shell ############################################################################### @@ -4506,8 +4506,8 @@ test $me -eq ~/~foo # ^ - variable.language.tilde "~/.bin/~app" -# <- meta.function-call.identifier.shell meta.path.shell variable.function.shell punctuation.definition.quoted.begin.shell -#^^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# <- meta.function-call.identifier.shell meta.command.shell variable.function.shell punctuation.definition.quoted.begin.shell +#^^^^^^^^^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell #^ - variable.language.tilde # ^ punctuation.separator.path.shell # ^ punctuation.separator.path.shell @@ -4520,32 +4520,32 @@ test $me -eq ~/~foo ############################################################################### $__ $__ -# <- meta.function-call.identifier.shell meta.path.shell meta.interpolation.parameter.shell variable.other.readwrite.shell punctuation.definition.variable.shell -#^^ meta.function-call.identifier.shell meta.path.shell meta.interpolation.parameter.shell variable.other.readwrite.shell - variable variable +# <- meta.function-call.identifier.shell meta.command.shell meta.interpolation.parameter.shell variable.other.readwrite.shell punctuation.definition.variable.shell +#^^ meta.function-call.identifier.shell meta.command.shell meta.interpolation.parameter.shell variable.other.readwrite.shell - variable variable # ^ meta.function-call.arguments.shell - meta.string - meta.interpolation - variable # ^^^ meta.function-call.arguments.shell meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell # ^ punctuation.definition.variable.shell # ^ - meta.function-call - meta.string - meta.interpolation - variable $var_0 $var_0 -# <- meta.function-call.identifier.shell meta.path.shell meta.interpolation.parameter.shell variable.other.readwrite.shell punctuation.definition.variable.shell -#^^^^^ meta.function-call.identifier.shell meta.path.shell meta.interpolation.parameter.shell variable.other.readwrite.shell - variable variable +# <- meta.function-call.identifier.shell meta.command.shell meta.interpolation.parameter.shell variable.other.readwrite.shell punctuation.definition.variable.shell +#^^^^^ meta.function-call.identifier.shell meta.command.shell meta.interpolation.parameter.shell variable.other.readwrite.shell - variable variable # ^ meta.function-call.arguments.shell - meta.string - meta.interpolation - variable # ^^^^^^ meta.function-call.arguments.shell meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell # ^ punctuation.definition.variable.shell # ^ - meta.function-call - meta.string - meta.interpolation - variable $_var0 $_var0 -# <- meta.function-call.identifier.shell meta.path.shell meta.interpolation.parameter.shell variable.other.readwrite.shell punctuation.definition.variable.shell -#^^^^^ meta.function-call.identifier.shell meta.path.shell meta.interpolation.parameter.shell variable.other.readwrite.shell - variable variable +# <- meta.function-call.identifier.shell meta.command.shell meta.interpolation.parameter.shell variable.other.readwrite.shell punctuation.definition.variable.shell +#^^^^^ meta.function-call.identifier.shell meta.command.shell meta.interpolation.parameter.shell variable.other.readwrite.shell - variable variable # ^ meta.function-call.arguments.shell - meta.string - meta.interpolation - variable # ^^^^^^ meta.function-call.arguments.shell meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell # ^ punctuation.definition.variable.shell # ^ - meta.function-call - meta.string - meta.interpolation - variable $_0var_ $_0var_ -# <- meta.function-call.identifier.shell meta.path.shell meta.interpolation.parameter.shell variable.other.readwrite.shell punctuation.definition.variable.shell -#^^^^^^ meta.function-call.identifier.shell meta.path.shell meta.interpolation.parameter.shell variable.other.readwrite.shell - variable variable +# <- meta.function-call.identifier.shell meta.command.shell meta.interpolation.parameter.shell variable.other.readwrite.shell punctuation.definition.variable.shell +#^^^^^^ meta.function-call.identifier.shell meta.command.shell meta.interpolation.parameter.shell variable.other.readwrite.shell - variable variable # ^ meta.function-call.arguments.shell - meta.string - meta.interpolation - variable # ^^^^^^^ meta.function-call.arguments.shell meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell # ^ punctuation.definition.variable.shell @@ -8939,21 +8939,21 @@ echo '([^.[:space:]]+) Class::method()' # colon not scoped as path separator # ^ - meta.redirection > out~put- -# ^^ meta.redirection.shell - meta.path +# ^^ meta.redirection.shell - meta.command # ^^^^^^^^ meta.redirection.shell # ^ keyword.operator.assignment.redirection.shell # ^ - variable # ^ - punctuation > ~/.local/file -# ^^ meta.redirection.shell - meta.path +# ^^ meta.redirection.shell - meta.command # ^ meta.redirection.shell meta.string.shell meta.interpolation.tilde.shell # ^^^^^^^^^^^^ meta.redirection.shell meta.string.shell string.unquoted.shell - meta.interpolation # ^ keyword.operator.assignment.redirection.shell # ^ variable.language.tilde.shell > "~/.local/file" -# ^^ meta.redirection.shell - meta.path +# ^^ meta.redirection.shell - meta.command # ^^^^^^^^^^^^^^^ meta.redirection.shell meta.string.shell string.quoted.double.shell # ^ keyword.operator.assignment.redirection.shell # ^ punctuation.definition.string.begin.shell @@ -8961,7 +8961,7 @@ echo '([^.[:space:]]+) Class::method()' # colon not scoped as path separator # ^ punctuation.definition.string.end.shell > "~/.local/file" -# ^^ meta.redirection.shell - meta.path +# ^^ meta.redirection.shell - meta.command # ^^^^^^^^^^^^^^^ meta.redirection.shell meta.string.shell string.quoted.double.shell # ^ keyword.operator.assignment.redirection.shell # ^ punctuation.definition.string.begin.shell @@ -9039,25 +9039,25 @@ foo | bar 2>&1 foo | bar --opt1 arg1 < file.txt # ^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell -# ^^ meta.redirection.shell - meta.path +# ^^ meta.redirection.shell - meta.command # ^ keyword.operator.assignment.redirection.shell # ^^^^^^^^ meta.redirection.shell foo | bar --opt1 arg1 > file.txt # ^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell -# ^^ meta.redirection.shell - meta.path +# ^^ meta.redirection.shell - meta.command # ^ keyword.operator.assignment.redirection.shell # ^^^^^^^^ meta.redirection.shell foo -x arg1 &>/dev/null # ^^^^^^^^^ meta.function-call.arguments.shell - meta.redirection -# ^^ meta.function-call.arguments.shell meta.redirection.shell - meta.path +# ^^ meta.function-call.arguments.shell meta.redirection.shell - meta.command # ^^ keyword.operator.assignment.redirection.shell # ^^^^^^^^^ meta.function-call.arguments.shell meta.redirection.shell foo -x arg1 &> /dev/null # ^^^^^^^^^ meta.function-call.arguments.shell - meta.redirection -# ^^^ meta.function-call.arguments.shell meta.redirection.shell - meta.path +# ^^^ meta.function-call.arguments.shell meta.redirection.shell - meta.command # ^^ keyword.operator.assignment.redirection.shell # ^^^^^^^^^ meta.function-call.arguments.shell meta.redirection.shell # ^ - meta.function @@ -9109,7 +9109,7 @@ gzip | tee >(md5sum - | sed 's/-$/mydata.lz2/'>mydata-gz.md5) > mydata.gz # ^ keyword.operator.assignment.redirection.shell LC_ALL=C 2> /dev/null -# ^^^ meta.redirection.shell - meta.path +# ^^^ meta.redirection.shell - meta.command # ^ meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell # ^ keyword.operator.assignment.redirection # ^^^^^^^^^ meta.redirection.shell - variable @@ -9488,33 +9488,33 @@ alias foo=bar # <- meta.declaration.alias.shell keyword.declaration.alias.shell #^^^^^^^^^^^^ meta.declaration.alias.shell # ^ - meta.declaration.alias -# ^^^ meta.variable.shell entity.name.function.shell +# ^^^ meta.command.shell entity.name.function.shell # ^ keyword.operator.assignment.shell -# ^^^ meta.string.shell meta.path.shell variable.function.shell +# ^^^ meta.string.shell meta.command.shell variable.function.shell alias foo=bar -p 7za=qux # <- meta.declaration.alias.shell keyword.declaration.alias.shell #^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.alias.shell # ^ - meta.declaration.alias -# ^^^ meta.variable.shell entity.name.function.shell +# ^^^ meta.command.shell entity.name.function.shell # ^ keyword.operator.assignment.shell -# ^^^ meta.string.shell meta.path.shell variable.function.shell +# ^^^ meta.string.shell meta.command.shell variable.function.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell -# ^^^ meta.variable.shell entity.name.function.shell +# ^^^ meta.command.shell entity.name.function.shell # ^ keyword.operator.assignment.shell -# ^^^ meta.string.shell meta.path.shell variable.function.shell +# ^^^ meta.string.shell meta.command.shell variable.function.shell alias -p foo=bar 7za=qux # <- meta.declaration.alias.shell keyword.declaration.alias.shell #^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.alias.shell # ^ - meta.declaration.alias # ^^ meta.parameter.option.shell variable.parameter.option.shell -# ^^^ meta.variable.shell entity.name.function.shell +# ^^^ meta.command.shell entity.name.function.shell # ^ keyword.operator.assignment.shell -# ^^^ meta.string.shell meta.path.shell variable.function.shell -# ^^^ meta.variable.shell entity.name.function.shell +# ^^^ meta.string.shell meta.command.shell variable.function.shell +# ^^^ meta.command.shell entity.name.function.shell # ^ keyword.operator.assignment.shell -# ^^^ meta.string.shell meta.path.shell variable.function.shell +# ^^^ meta.string.shell meta.command.shell variable.function.shell alias -a -p -- foo=bar baz=qux # <- meta.declaration.alias.shell keyword.declaration.alias.shell @@ -9523,12 +9523,12 @@ alias -a -p -- foo=bar baz=qux # ^^ meta.parameter.option.shell variable.parameter.option.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell # ^^ keyword.operator.end-of-options.shell -# ^^^ meta.variable.shell entity.name.function.shell +# ^^^ meta.command.shell entity.name.function.shell # ^ keyword.operator.assignment.shell -# ^^^ meta.string.shell meta.path.shell variable.function.shell -# ^^^ meta.variable.shell entity.name.function.shell +# ^^^ meta.string.shell meta.command.shell variable.function.shell +# ^^^ meta.command.shell entity.name.function.shell # ^ keyword.operator.assignment.shell -# ^^^ meta.string.shell meta.path.shell variable.function.shell +# ^^^ meta.string.shell meta.command.shell variable.function.shell alias $foo=bar # <- meta.declaration.alias.shell keyword.declaration.alias.shell @@ -9536,16 +9536,16 @@ alias $foo=bar # ^ - meta.declaration.alias # ^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell # ^ keyword.operator.assignment.shell -# ^^^ meta.string.shell meta.path.shell variable.function.shell +# ^^^ meta.string.shell meta.command.shell variable.function.shell alias ..='cd ..' # <- meta.declaration.alias.shell keyword.declaration.alias.shell #^^^^^^^^^^^^^^^ meta.declaration.alias.shell #^^^^ keyword.declaration.alias.shell -# ^^ meta.variable.shell entity.name.function.shell +# ^^ meta.command.shell entity.name.function.shell # ^ keyword.operator.assignment.shell # ^ meta.string.shell string.quoted.single.shell punctuation.section.string.begin.shell -# ^^ meta.string.shell meta.function-call.identifier.shell meta.path.shell support.function.shell - string +# ^^ meta.string.shell meta.function-call.identifier.shell meta.command.shell support.function.shell - string # ^ meta.string.shell meta.function-call.arguments.shell - string # ^^ meta.string.shell meta.function-call.arguments.shell meta.string.shell string.unquoted.shell # ^ meta.string.shell string.quoted.single.shell punctuation.section.string.end.shell @@ -9555,10 +9555,10 @@ alias -p ..='cd ..' #^^^^^^^^^^^^^^^^^^ meta.declaration.alias.shell #^^^^ keyword.declaration.alias.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell -# ^^ meta.variable.shell entity.name.function.shell +# ^^ meta.command.shell entity.name.function.shell # ^ keyword.operator.assignment.shell # ^ meta.string.shell string.quoted.single.shell punctuation.section.string.begin.shell -# ^^ meta.string.shell meta.function-call.identifier.shell meta.path.shell support.function.shell - string +# ^^ meta.string.shell meta.function-call.identifier.shell meta.command.shell support.function.shell - string # ^ meta.string.shell meta.function-call.arguments.shell - string # ^^ meta.string.shell meta.function-call.arguments.shell meta.string.shell string.unquoted.shell # ^ meta.string.shell string.quoted.single.shell punctuation.section.string.end.shell @@ -9568,10 +9568,10 @@ alias -- -='cd -' #^^^^^^^^^^^^^^^^ meta.declaration.alias.shell #^^^^ keyword.declaration.alias.shell # ^^ keyword.operator.end-of-options.shell -# ^ meta.variable.shell entity.name.function.shell +# ^ meta.command.shell entity.name.function.shell # ^ keyword.operator.assignment.shell # ^ meta.string.shell string.quoted.single.shell punctuation.section.string.begin.shell -# ^^ meta.string.shell meta.function-call.identifier.shell meta.path.shell support.function.shell - string +# ^^ meta.string.shell meta.function-call.identifier.shell meta.command.shell support.function.shell - string # ^ meta.string.shell meta.function-call.arguments.shell - string # ^ meta.string.shell meta.function-call.arguments.shell meta.string.shell string.unquoted.shell # ^ meta.string.shell string.quoted.single.shell punctuation.section.string.end.shell @@ -10145,7 +10145,7 @@ declare -f _init_completion > /dev/null && complete -F _upto upto # ^ - meta.function-call #^^^^^^ keyword.declaration.variable.shell # ^^ variable.parameter.option.shell -# ^^^^^^^^^^^^^^^^ meta.variable.shell entity.name.function.shell +# ^^^^^^^^^^^^^^^^ meta.command.shell entity.name.function.shell # ^ keyword.operator.assignment.redirection.shell # ^^ keyword.operator.logical.shell # ^^^^^^^^ variable.function.shell @@ -10215,7 +10215,7 @@ command -pV -v cmd -a val # <- meta.function-call.identifier.shell support.function.shell #^^^^^^ meta.function-call.identifier.shell # ^^^^^^^^ meta.function-call.arguments.shell -# ^^^ meta.function-call.identifier.shell meta.path.shell +# ^^^ meta.function-call.identifier.shell meta.command.shell # ^^^^^^^ meta.function-call.arguments.shell # ^^^ meta.parameter.option.shell variable.parameter.option.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell @@ -10449,21 +10449,21 @@ export -f foo #^^^^^ meta.function-call.identifier.shell support.function.shell # ^^^^^^^ meta.function-call.arguments.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell -# ^^^ meta.variable.shell entity.name.function.shell +# ^^^ meta.command.shell entity.name.function.shell export -f = # <- meta.function-call.identifier.shell support.function.shell #^^^^^ meta.function-call.identifier.shell support.function.shell # ^^^^^ meta.function-call.arguments.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell -# ^ meta.variable.shell entity.name.function.shell +# ^ meta.command.shell entity.name.function.shell export -f ==cmd # <- meta.function-call.identifier.shell support.function.shell #^^^^^ meta.function-call.identifier.shell support.function.shell # ^^^^^^^^^ meta.function-call.arguments.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell -# ^^^^^ meta.variable.shell entity.name.function.shell +# ^^^^^ meta.command.shell entity.name.function.shell export PATH="$PATH:$HOME/.local/bin" # ^^^^ meta.function-call.identifier.shell support.function.shell @@ -10776,7 +10776,7 @@ local -fn foo #^^^^^^^^^^^^ meta.declaration.variable.shell #^^^^ keyword.declaration.variable.shell # ^^^ meta.parameter.option.shell variable.parameter.option.shell -# ^^^ meta.variable.shell entity.name.function.shell +# ^^^ meta.command.shell entity.name.function.shell f() { local -a "$@" @@ -10881,7 +10881,7 @@ mapfile -d ";" -n 10 -O $origin -s 5 -t -u 20 -C callback -c 10 array # ^^ meta.parameter.option.shell variable.parameter.option.shell # ^^ meta.number.integer.decimal.shell constant.numeric.value.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell -# ^^^^^^^^ meta.string.shell variable.function.shell +# ^^^^^^^^ meta.string.shell meta.command.shell variable.function.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell # ^^ meta.number.integer.decimal.shell constant.numeric.value.shell # ^^^^^ meta.variable.shell variable.other.readwrite.shell @@ -10979,7 +10979,7 @@ readonly -A -f foo # 'foo' is a variable name # ^ - variable # ^^ meta.parameter.option.shell variable.parameter.option.shell # ^ - variable -# ^^^ meta.variable.shell entity.name.function.shell +# ^^^ meta.command.shell entity.name.function.shell # ^ - variable readonly -Af foo # 'foo' is a variable name @@ -10990,7 +10990,7 @@ readonly -Af foo # 'foo' is a variable name # ^ - storage - variable # ^^^ meta.parameter.option.shell variable.parameter.option.shell # ^ - variable -# ^^^ meta.variable.shell entity.name.function.shell +# ^^^ meta.command.shell entity.name.function.shell # ^ - variable readonly -f -A foo # 'foo' is a variable name @@ -11003,7 +11003,7 @@ readonly -f -A foo # 'foo' is a variable name # ^ - variable # ^^ meta.parameter.option.shell variable.parameter.option.shell # ^ - variable -# ^^^ meta.variable.shell entity.name.function.shell +# ^^^ meta.command.shell entity.name.function.shell # ^ - variable readonly -fA foo # 'foo' is a variable name @@ -11014,7 +11014,7 @@ readonly -fA foo # 'foo' is a variable name # ^ - storage - variable # ^^^ meta.parameter.option.shell variable.parameter.option.shell # ^ - variable -# ^^^ meta.variable.shell entity.name.function.shell +# ^^^ meta.command.shell entity.name.function.shell # ^ - variable readonly -f foo # 'foo' is a variable name @@ -11025,7 +11025,7 @@ readonly -f foo # 'foo' is a variable name # ^ - storage - variable # ^^ meta.parameter.option.shell variable.parameter.option.shell # ^ - variable -# ^^^ meta.variable.shell entity.name.function.shell +# ^^^ meta.command.shell entity.name.function.shell # ^ - variable foo=`readonly x=5` @@ -11062,7 +11062,7 @@ typeset -f _init_completion > /dev/null && complete -F _upto upto # ^ - meta.function-call #^^^^^^ keyword.declaration.variable.shell # ^^ variable.parameter.option.shell -# ^^^^^^^^^^^^^^^^ meta.variable.shell entity.name.function.shell +# ^^^^^^^^^^^^^^^^ meta.command.shell entity.name.function.shell # ^ keyword.operator.assignment.redirection.shell # ^^ keyword.operator.logical.shell # ^^^^^^^^ variable.function.shell @@ -11258,16 +11258,16 @@ time cmd1 --arg val | cmd2 -n |& cmd3 # <- meta.function-call.identifier.shell support.function.shell #^^^ meta.function-call.identifier.shell support.function.shell # ^ meta.function-call.arguments.shell -# ^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell # ^^^^^^^^^^ meta.function-call.arguments.shell # ^^^^^ meta.parameter.option.shell variable.parameter.option.shell # ^^^ meta.string.shell string.unquoted.shell # ^ keyword.operator.assignment.pipe.shell -# ^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell # ^^^ meta.function-call.arguments.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell # ^^ keyword.operator.assignment.pipe.shell -# ^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell time -p cmd -p # <- meta.function-call.identifier.shell support.function.shell @@ -11290,13 +11290,13 @@ trap cmd # <- meta.function-call.identifier.shell support.function.shell #^^^ meta.function-call.identifier.shell support.function.shell # ^ meta.function-call.arguments.shell -# ^^^ meta.function-call.arguments.shell meta.path.shell variable.function.shell +# ^^^ meta.function-call.arguments.shell meta.command.shell variable.function.shell trap cmd EXIT # <- meta.function-call.identifier.shell support.function.shell #^^^ meta.function-call.identifier.shell support.function.shell # ^^^^^^^^^ meta.function-call.arguments.shell - meta.function-call meta-function-call -# ^^^ meta.path.shell variable.function.shell +# ^^^ meta.command.shell variable.function.shell # ^^^^ constant.language.signal.shell trap -p cmd EXIT @@ -11304,7 +11304,7 @@ trap -p cmd EXIT #^^^ meta.function-call.identifier.shell support.function.shell # ^^^^^^^^^^^^ meta.function-call.arguments.shell - meta.function-call meta-function-call # ^^ meta.parameter.option.shell variable.parameter.option.shell -# ^^^ meta.path.shell variable.function.shell +# ^^^ meta.command.shell variable.function.shell # ^^^^ constant.language.signal.shell trap 'cmd --args="value"' SIGINT diff --git a/ShellScript/Bash/tests/syntax_test_symbol.bash b/ShellScript/Bash/tests/syntax_test_symbol.bash index 3b9743986f..90f01d2d81 100644 --- a/ShellScript/Bash/tests/syntax_test_symbol.bash +++ b/ShellScript/Bash/tests/syntax_test_symbol.bash @@ -49,6 +49,10 @@ function f$name() function f${name:$start:5}() # @@@@@@@@@@@@@@@@@ definition + export -f func3 +# @@@@@@ reference +# @@@@@ definition + func3() # @@@@@ definition @@ -67,6 +71,14 @@ function f${name:$start:5}() { func3 } # @@@@@ reference + mapfile -C func3 array +# @@@@@@@ reference +# @@@@@ reference + + mapfile -C "func3 arg" array +# @@@@@@@ reference +# @@@@@ reference + trap 'func3' SIGTERM # @@@@ reference # @@@@@ reference diff --git a/ShellScript/Shell/Reference List - Functions.tmPreferences b/ShellScript/Shell/Reference List - Functions.tmPreferences index 9c57bbdca0..fa52a48066 100644 --- a/ShellScript/Shell/Reference List - Functions.tmPreferences +++ b/ShellScript/Shell/Reference List - Functions.tmPreferences @@ -3,8 +3,8 @@ scope - meta.function-call.identifier.shell variable.function, - meta.function-call.identifier.shell meta.interpolation + meta.command.shell meta.interpolation - meta.command.shell meta.interpolation.command, + meta.command.shell variable.function settings diff --git a/ShellScript/Zsh/tests/syntax_test_scope.zsh b/ShellScript/Zsh/tests/syntax_test_scope.zsh index e1f374f3a6..2c3de9f683 100644 --- a/ShellScript/Zsh/tests/syntax_test_scope.zsh +++ b/ShellScript/Zsh/tests/syntax_test_scope.zsh @@ -33,7 +33,7 @@ dmesg &| grep panic &! print yes builtin cmd -a val # <- meta.function-call.identifier.shell support.function.shell #^^^^^^ meta.function-call.identifier.shell support.function.shell -# ^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# ^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell # ^^^^^^^ meta.function-call.arguments.shell exec -cl -a argv0 @@ -803,25 +803,25 @@ fi ############################################################################### cmd -# <- meta.function-call.identifier.shell meta.path.shell variable.function.shell -#^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# <- meta.function-call.identifier.shell meta.command.shell variable.function.shell +#^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell # ^ - meta.function /path/to/app -# <- meta.function-call.identifier.shell meta.path.shell variable.function.shell punctuation.separator.path.shell -#^^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# <- meta.function-call.identifier.shell meta.command.shell variable.function.shell punctuation.separator.path.shell +#^^^^^^^^^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell # ^ - meta.function ./.bin/app -# <- meta.function-call.identifier.shell meta.path.shell variable.function.shell constant.other.path.self.shell -#^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# <- meta.function-call.identifier.shell meta.command.shell variable.function.shell constant.other.path.self.shell +#^^^^^^^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell #^ punctuation.separator.path.shell # ^ - constant # ^ punctuation.separator.path.shell ../.bin/app -# <- meta.function-call.identifier.shell meta.path.shell variable.function.shell constant.other.path.parent.shell -#^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# <- meta.function-call.identifier.shell meta.command.shell variable.function.shell constant.other.path.parent.shell +#^^^^^^^^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell #^ constant.other.path.parent.shell # ^ punctuation.separator.path.shell # ^ - constant @@ -2771,19 +2771,19 @@ dyn_dir_name() { # 14.7.2 Static named directories ~n_a-m.e/ ~n_a-m.e/ -# <- meta.function-call.identifier.shell meta.path.shell meta.interpolation.tilde.shell variable.language.tilde.shell -#^^^^^^^ meta.function-call.identifier.shell meta.path.shell meta.interpolation.tilde.shell constant.other.username.shell -# ^ meta.function-call.identifier.shell meta.path.shell variable.function.shell punctuation.separator.path.shell +# <- meta.function-call.identifier.shell meta.command.shell meta.interpolation.tilde.shell variable.language.tilde.shell +#^^^^^^^ meta.function-call.identifier.shell meta.command.shell meta.interpolation.tilde.shell constant.other.username.shell +# ^ meta.function-call.identifier.shell meta.command.shell variable.function.shell punctuation.separator.path.shell # ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell # ^^^^^^^ meta.string.shell meta.interpolation.tilde.shell constant.other.username.shell - variable # ^ meta.string.shell - meta.interpolation ~n_${a-m}.e/ ~n_${a-m}.e/ -# <- meta.function-call.identifier.shell meta.path.shell meta.interpolation.tilde.shell variable.language.tilde.shell - variable.function -#^^ meta.function-call.identifier.shell meta.path.shell meta.interpolation.tilde.shell constant.other.username.shell -# ^^^^^^ meta.function-call.identifier.shell meta.path.shell meta.interpolation.tilde.shell meta.interpolation.parameter.shell -# ^^ meta.function-call.identifier.shell meta.path.shell meta.interpolation.tilde.shell constant.other.username.shell -# ^ meta.function-call.identifier.shell meta.path.shell variable.function.shell punctuation.separator.path.shell +# <- meta.function-call.identifier.shell meta.command.shell meta.interpolation.tilde.shell variable.language.tilde.shell - variable.function +#^^ meta.function-call.identifier.shell meta.command.shell meta.interpolation.tilde.shell constant.other.username.shell +# ^^^^^^ meta.function-call.identifier.shell meta.command.shell meta.interpolation.tilde.shell meta.interpolation.parameter.shell +# ^^ meta.function-call.identifier.shell meta.command.shell meta.interpolation.tilde.shell constant.other.username.shell +# ^ meta.function-call.identifier.shell meta.command.shell variable.function.shell punctuation.separator.path.shell # ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell # ^^ meta.string.shell meta.interpolation.tilde.shell constant.other.username.shell - variable # ^^^^^^ meta.string.shell meta.interpolation.tilde.shell meta.interpolation.parameter.shell @@ -2793,8 +2793,8 @@ dyn_dir_name() { # 14.7.3 ‘=’ expansion =command =command -# <- meta.function-call.identifier.shell meta.path.shell variable.function.shell punctuation.definition.expansion.shell.zsh -#^^^^^^^ meta.function-call.identifier.shell meta.path.shell variable.function.shell +# <- meta.function-call.identifier.shell meta.command.shell variable.function.shell punctuation.definition.expansion.shell.zsh +#^^^^^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell # ^^^^^^^^ meta.function-call.arguments.shell meta.string.shell string.unquoted.shell # ^ punctuation.definition.expansion.shell @@ -3014,7 +3014,7 @@ dyn_dir_name() { # ^^^ variable.function.shell ^foo/bar ^foo/bar # Matches anything except the pattern x -# ^^^^^^^^ meta.function-call.identifier.shell meta.path.shell +# ^^^^^^^^ meta.function-call.identifier.shell meta.command.shell # ^ meta.function-call.arguments.shell - variable - string # ^^^^^^^^ meta.function-call.arguments.shell meta.string.shell # ^ - meta @@ -3025,7 +3025,7 @@ dyn_dir_name() { # ^ keyword.operator.logical.regexp.shell.zsh ^~/foo/bar ^~/foo/bar # Matches anything except the pattern x -# ^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell +# ^^^^^^^^^^ meta.function-call.identifier.shell meta.command.shell # ^ meta.function-call.arguments.shell - variable - string # ^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell # ^ - meta @@ -3039,7 +3039,7 @@ dyn_dir_name() { # ^^^^^^^^ string.unquoted.shell /foo~/bar /foo~/bar # Match anything that matches the pattern x but does not match y -# ^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell +# ^^^^^^^^^ meta.function-call.identifier.shell meta.command.shell # ^ meta.function-call.arguments.shell - variable - string # ^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell # ^ - meta @@ -3051,7 +3051,7 @@ dyn_dir_name() { # ^ keyword.operator.logical.regexp.shell.zsh ^/foo~^/bar ^/foo~^/bar -# ^^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell +# ^^^^^^^^^^^ meta.function-call.identifier.shell meta.command.shell # ^ meta.function-call.arguments.shell - variable - string # ^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell # ^ - meta @@ -3065,7 +3065,7 @@ dyn_dir_name() { # ^^ keyword.operator.logical.regexp.shell.zsh ~/foo~~/bar ~/foo~~/bar -# ^^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell +# ^^^^^^^^^^^ meta.function-call.identifier.shell meta.command.shell # ^ meta.function-call.arguments.shell - variable - string # ^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell # ^ - meta @@ -3083,7 +3083,7 @@ dyn_dir_name() { # ^^^^ string.unquoted.shell ^~/foo~^~/bar ^~/foo~^~/bar -# ^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.path.shell +# ^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.command.shell # ^ meta.function-call.arguments.shell - variable - string # ^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell # ^ - meta From 9783c6e68c290e0c6407a7d4800e01183684898a Mon Sep 17 00:00:00 2001 From: deathaxe Date: Wed, 7 Aug 2024 11:02:58 +0200 Subject: [PATCH 071/113] [ShellScript] Add special treatment for readarray built-in The command equals `mapfile`. --- ShellScript/Bash.sublime-syntax | 4 +- ShellScript/Bash/tests/syntax_test_scope.bash | 64 +++++++++++++++++++ .../Bash/tests/syntax_test_symbol.bash | 8 +++ 3 files changed, 74 insertions(+), 2 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index ca3007fe78..60394aff76 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -542,7 +542,7 @@ contexts: cmd-mapfile: # bash only - - match: mapfile{{cmd_break}} + - match: (?:mapfile|readarray){{cmd_break}} scope: meta.function-call.identifier.shell support.function.shell @@ -3020,7 +3020,7 @@ variables: builtin_cmds: |- (?x: \. | \: | bg | bind | caller | cd | disown | enable | eval | fg | getopts | hash | help | jobs | kill | logout | printf | pwd - | read | readarray | set | shift | shopt | source | su | suspend | times + | read | set | shift | shopt | source | su | suspend | times | type | ulimit | umask | wait ){{cmd_break}} modifier_cmds: |- diff --git a/ShellScript/Bash/tests/syntax_test_scope.bash b/ShellScript/Bash/tests/syntax_test_scope.bash index 0e469fc31e..12355f8633 100644 --- a/ShellScript/Bash/tests/syntax_test_scope.bash +++ b/ShellScript/Bash/tests/syntax_test_scope.bash @@ -10887,6 +10887,70 @@ mapfile -d ";" -n 10 -O $origin -s 5 -t -u 20 -C callback -c 10 array # ^^^^^ meta.variable.shell variable.other.readwrite.shell +############################################################################### +# 4.2 Bash Builtin Commands (readarray) # +# https://www.gnu.org/software/bash/manual/bash.html#index-readarray # +# readarray [-d delim] [-n count] [-O origin] [-s count] # +# [-t] [-u fd] [-C callback] [-c quantum] [array] # +############################################################################### + +readarray +# <- meta.function-call.identifier.shell support.function.shell +#^^^^^^^^ meta.function-call.identifier.shell support.function.shell +# ^ - meta.function-call + +readarray array +# <- meta.function-call.identifier.shell support.function.shell +#^^^^^^^^ meta.function-call.identifier.shell support.function.shell +# ^^^^^^ meta.function-call.arguments.shell +# ^^^^^ variable.other.readwrite.shell +# ^ - meta.function-call + +readarray -C ; result=10 +# ^^^ meta.function-call.arguments.shell +# ^^^^^^^^^^^^^ - meta.function-call +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^ punctuation.terminator.statement.shell +# ^^^^^^ variable.other.readwrite.shell +# ^ keyword.operator.assignment.shell +# ^^ string.unquoted.shell + +readarray -C "~/.bin/app -p $val arg" array +# <- meta.function-call.identifier.shell support.function.shell +#^^^^^^^^ meta.function-call.identifier.shell support.function.shell +# ^^^^ meta.function-call.arguments.shell - meta.string +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^ meta.function-call.arguments.shell meta.string.shell string.quoted.double.shell punctuation.section.string.begin.shell +# ^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell meta.function-call.identifier.shell +# ^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell meta.function-call.arguments.shell +# ^ meta.function-call.arguments.shell meta.string.shell string.quoted.double.shell punctuation.section.string.end.shell +# ^ meta.function-call.arguments.shell - meta.string - variable +# ^^^^^ meta.function-call.arguments.shell meta.variable.shell variable.other.readwrite.shell +# ^ - meta.function-call + +readarray -d ";" -n 10 -O $origin -s 5 -t -u 20 -C callback -c 10 array +# <- meta.function-call.identifier.shell support.function.shell +#^^^^^^^^ meta.function-call.identifier.shell support.function.shell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell +# ^ - meta.function-call +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^^ meta.string.shell string.quoted.double.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^^^^^^ meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^^^^^^^ meta.string.shell meta.command.shell variable.function.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^^^^^ meta.variable.shell variable.other.readwrite.shell + + ############################################################################### # 4.2 Bash Builtin Commands (readonly) # # https://www.gnu.org/software/bash/manual/bash.html#index-readonly # diff --git a/ShellScript/Bash/tests/syntax_test_symbol.bash b/ShellScript/Bash/tests/syntax_test_symbol.bash index 90f01d2d81..7fdcbe5f43 100644 --- a/ShellScript/Bash/tests/syntax_test_symbol.bash +++ b/ShellScript/Bash/tests/syntax_test_symbol.bash @@ -79,6 +79,14 @@ function f${name:$start:5}() # @@@@@@@ reference # @@@@@ reference + readarray -C func3 array +# @@@@@@@@@ reference +# @@@@@ reference + + readarray -C "func3 arg" array +# @@@@@@@@@ reference +# @@@@@ reference + trap 'func3' SIGTERM # @@@@ reference # @@@@@ reference From bd8a70cc89fc7f56196abe7252109a5d5b5b4c24 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Wed, 7 Aug 2024 11:05:12 +0200 Subject: [PATCH 072/113] [Markdown] Adjust syntax tests --- Markdown/tests/syntax_test_markdown.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Markdown/tests/syntax_test_markdown.md b/Markdown/tests/syntax_test_markdown.md index 612c424efd..4c16dd57dd 100644 --- a/Markdown/tests/syntax_test_markdown.md +++ b/Markdown/tests/syntax_test_markdown.md @@ -1802,7 +1802,7 @@ EOF | <- markup.raw.code-fence.shell.markdown-gfm source.shell.bash.embedded.markdown meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell |^^ markup.raw.code-fence.shell.markdown-gfm source.shell.bash.embedded.markdown meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell $ cmd # no interactive shell marker -| <- markup.raw.code-fence.shell.markdown-gfm source.shell.bash.embedded.markdown meta.function-call.identifier.shell meta.path.shell variable.function.shell +| <- markup.raw.code-fence.shell.markdown-gfm source.shell.bash.embedded.markdown meta.function-call.identifier.shell variable.function.shell |^^^^ markup.raw.code-fence.shell.markdown-gfm source.shell.bash.embedded.markdown meta.function-call.arguments.shell ``` | <- meta.code-fence.definition.end.shell punctuation.definition.raw.code-fence.end @@ -1819,7 +1819,7 @@ $ cmd # no interactive shell marker | ^^^ markup.raw.code-fence.shell.markdown-gfm source.shell.bash.embedded.markdown meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell $ cmd # no interactive shell marker -| ^ markup.raw.code-fence.shell.markdown-gfm source.shell.bash.embedded.markdown meta.function-call.identifier.shell meta.path.shell variable.function.shell +| ^ markup.raw.code-fence.shell.markdown-gfm source.shell.bash.embedded.markdown meta.function-call.identifier.shell variable.function.shell | ^^^^ markup.raw.code-fence.shell.markdown-gfm source.shell.bash.embedded.markdown meta.function-call.arguments.shell ``` | ^^^ meta.code-fence.definition.end.shell.markdown-gfm punctuation.definition.raw.code-fence.end.markdown @@ -2235,7 +2235,7 @@ EOF |^^ markup.raw.code-fence.shell.markdown-gfm source.shell.zsh.embedded.markdown meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell $ cmd # no interactive shell marker -| <- markup.raw.code-fence.shell.markdown-gfm source.shell.zsh.embedded.markdown meta.function-call.identifier.shell meta.path.shell variable.function.shell +| <- markup.raw.code-fence.shell.markdown-gfm source.shell.zsh.embedded.markdown meta.function-call.identifier.shell variable.function.shell |^^^^ markup.raw.code-fence.shell.markdown-gfm source.shell.zsh.embedded.markdown meta.function-call.arguments.shell ``` @@ -2253,7 +2253,7 @@ $ cmd # no interactive shell marker | ^^^ markup.raw.code-fence.shell.markdown-gfm source.shell.zsh.embedded.markdown meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell $ cmd # no interactive shell marker -| ^ markup.raw.code-fence.shell.markdown-gfm source.shell.zsh.embedded.markdown meta.function-call.identifier.shell meta.path.shell variable.function.shell +| ^ markup.raw.code-fence.shell.markdown-gfm source.shell.zsh.embedded.markdown meta.function-call.identifier.shell variable.function.shell | ^^^^ markup.raw.code-fence.shell.markdown-gfm source.shell.zsh.embedded.markdown meta.function-call.arguments.shell ``` | ^^^ meta.code-fence.definition.end.shell.markdown-gfm punctuation.definition.raw.code-fence.end.markdown From 0662b9270a5554f9e3f53e7edfaff0be947ad816 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Wed, 7 Aug 2024 11:22:48 +0200 Subject: [PATCH 073/113] [ShellScript] Reorganize bash built-in tests - add command arguments call spec to comments - sort builtin and command tests between alias and declare alphabetically --- ShellScript/Bash/tests/syntax_test_scope.bash | 98 +++++++++++-------- 1 file changed, 55 insertions(+), 43 deletions(-) diff --git a/ShellScript/Bash/tests/syntax_test_scope.bash b/ShellScript/Bash/tests/syntax_test_scope.bash index 12355f8633..ee19a5d376 100644 --- a/ShellScript/Bash/tests/syntax_test_scope.bash +++ b/ShellScript/Bash/tests/syntax_test_scope.bash @@ -9477,6 +9477,7 @@ fi # 4.2 Bash Builtin Commands (alias) # # https://www.gnu.org/software/bash/manual/bash.html#index-alias # # https://www.gnu.org/software/bash/manual/bash.html#Aliases # +# alias [-p] [name[=value] …] # ############################################################################### alias @@ -9577,9 +9578,55 @@ alias -- -='cd -' # ^ meta.string.shell string.quoted.single.shell punctuation.section.string.end.shell +############################################################################### +# 4.2 Bash Builtin Commands (builtin) # +# https://www.gnu.org/software/bash/manual/bash.html#index-builtin # +# builtin [shell-builtin [args]] # +############################################################################### + +builtin +# <- meta.function-call.identifier.shell support.function.shell +#^^^^^^ meta.function-call.identifier.shell support.function.shell + +builtin -pV -v cmd -a val +# <- meta.function-call.identifier.shell support.function.shell +#^^^^^^ meta.function-call.identifier.shell +# ^^^ meta.function-call.identifier.shell +# ^^^^^^^^^^^^^^ meta.function-call.arguments.shell +# ^^^ variable.function.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^^ meta.string.shell string.unquoted.shell + + +############################################################################### +# 4.2 Bash Builtin Commands (command) # +# https://www.gnu.org/software/bash/manual/bash.html#index-command # +# command [-pVv] command [arguments …] # +############################################################################### + +command +# <- meta.function-call.identifier.shell support.function.shell +#^^^^^^ meta.function-call.identifier.shell support.function.shell + +command -pV -v cmd -a val +# <- meta.function-call.identifier.shell support.function.shell +#^^^^^^ meta.function-call.identifier.shell +# ^^^^^^^^ meta.function-call.arguments.shell +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^^^^^ meta.function-call.arguments.shell +# ^^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^^ variable.function.shell +# ^^ meta.parameter.option.shell variable.parameter.option.shell +# ^^^ meta.string.shell string.unquoted.shell + + ############################################################################### # 4.2 Bash Builtin Commands (declare) # # https://www.gnu.org/software/bash/manual/bash.html#index-declare # +# declare [-aAfFgiIlnrtux] [-p] [name[=value] …] # ############################################################################### declare # comment @@ -10181,49 +10228,6 @@ printFunction "$variableString1" "`declare -p variableArray`" # ^ punctuation.section.interpolation.end.shell -############################################################################### -# 4.2 Bash Builtin Commands (builtin) # -# https://www.gnu.org/software/bash/manual/bash.html#index-builtin # -############################################################################### - -builtin -# <- meta.function-call.identifier.shell support.function.shell -#^^^^^^ meta.function-call.identifier.shell support.function.shell - -builtin -pV -v cmd -a val -# <- meta.function-call.identifier.shell support.function.shell -#^^^^^^ meta.function-call.identifier.shell -# ^^^ meta.function-call.identifier.shell -# ^^^^^^^^^^^^^^ meta.function-call.arguments.shell -# ^^^ variable.function.shell -# ^^ meta.parameter.option.shell variable.parameter.option.shell -# ^^^ meta.string.shell string.unquoted.shell -# ^^ meta.parameter.option.shell variable.parameter.option.shell -# ^^^ meta.string.shell string.unquoted.shell - - -############################################################################### -# 4.2 Bash Builtin Commands (command) # -# https://www.gnu.org/software/bash/manual/bash.html#index-command # -############################################################################### - -command -# <- meta.function-call.identifier.shell support.function.shell -#^^^^^^ meta.function-call.identifier.shell support.function.shell - -command -pV -v cmd -a val -# <- meta.function-call.identifier.shell support.function.shell -#^^^^^^ meta.function-call.identifier.shell -# ^^^^^^^^ meta.function-call.arguments.shell -# ^^^ meta.function-call.identifier.shell meta.command.shell -# ^^^^^^^ meta.function-call.arguments.shell -# ^^^ meta.parameter.option.shell variable.parameter.option.shell -# ^^ meta.parameter.option.shell variable.parameter.option.shell -# ^^^ variable.function.shell -# ^^ meta.parameter.option.shell variable.parameter.option.shell -# ^^^ meta.string.shell string.unquoted.shell - - ############################################################################### # 4.2 Bash Builtin Commands (eval) # # https://www.gnu.org/software/bash/manual/bash.html#index-eval # @@ -10533,6 +10537,7 @@ url="https://sublimetext.com/" ############################################################################### # 4.2 Bash Builtin Commands (let) # # https://www.gnu.org/software/bash/manual/bash.html#index-let # +# let expression [expression …] # ############################################################################### let @@ -10688,6 +10693,7 @@ let 'test -z $2 && { }' ############################################################################### # 4.2 Bash Builtin Commands (local) # # https://www.gnu.org/software/bash/manual/bash.html#index-local # +# local [option] name[=value] … # ############################################################################### local @@ -10954,6 +10960,7 @@ readarray -d ";" -n 10 -O $origin -s 5 -t -u 20 -C callback -c 10 array ############################################################################### # 4.2 Bash Builtin Commands (readonly) # # https://www.gnu.org/software/bash/manual/bash.html#index-readonly # +# readonly [-aAf] [-p] [name[=value]] … # ############################################################################### readonly foo # 'foo' is a variable name @@ -11105,6 +11112,7 @@ foo=`readonly x=5` ############################################################################### # 4.2 Bash Builtin Commands (typeset) # # https://www.gnu.org/software/bash/manual/bash.html#index-typeset # +# typeset [-afFgrxilnrtux] [-p] [name[=value] …] # ############################################################################### typeset foo # 'foo' is a variable name @@ -11136,6 +11144,7 @@ typeset -f _init_completion > /dev/null && complete -F _upto upto ############################################################################### # 4.2 Bash Builtin Commands (test) # # https://www.gnu.org/software/bash/manual/bash.html#index-test # +# test expr # ############################################################################### test @@ -11316,6 +11325,7 @@ if test "$VAR" != ";";then;fi ############################################################################### # 4.2 Bash Builtin Commands (time) # # https://www.gnu.org/software/bash/manual/bash.html#index-time # +# time pipeline # ############################################################################### time cmd1 --arg val | cmd2 -n |& cmd3 @@ -11344,6 +11354,7 @@ time -p cmd -p ############################################################################### # 4.2 Bash Builtin Commands (trap) # # https://www.gnu.org/software/bash/manual/bash.html#index-trap # +# trap [-lp] [arg] [sigspec …] # ############################################################################### trap @@ -11431,6 +11442,7 @@ trap "\"cmd\" --args=\"val${ue}\"" SIGKILL ############################################################################### # 4.2 Bash Builtin Commands (unalias) # # https://www.gnu.org/software/bash/manual/bash.html#index-unalias # +# unalias [-a] [name … ] # ############################################################################### unalias From 36b6740fd1f518d2e50928b829b6fef7af4b1fa3 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Fri, 9 Aug 2024 15:31:41 +0200 Subject: [PATCH 074/113] [ShellScript] Scope quoted statements `meta.quoted` Align with quoted expressions --- ShellScript/Bash.sublime-syntax | 24 ++-- ShellScript/Bash/tests/syntax_test_scope.bash | 106 +++++++++--------- 2 files changed, 62 insertions(+), 68 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 60394aff76..7565df3e30 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -1435,26 +1435,20 @@ contexts: statements-word: - match: \" - scope: - meta.string.shell string.quoted.double.shell - punctuation.section.string.begin.shell + scope: meta.quoted.shell punctuation.definition.quoted.begin.shell embed: statements - embed_scope: meta.string.shell + embed_scope: meta.quoted.shell escape: '{{no_escape_behind}}\"' escape_captures: - 0: meta.string.shell string.quoted.double.shell - punctuation.section.string.end.shell + 0: meta.quoted.shell punctuation.definition.quoted.end.shell pop: 1 - match: \' - scope: - meta.string.shell string.quoted.single.shell - punctuation.section.string.begin.shell + scope: meta.quoted.shell punctuation.definition.quoted.begin.shell embed: statements - embed_scope: meta.string.shell + embed_scope: meta.quoted.shell escape: '{{no_escape_behind}}''' escape_captures: - 0: meta.string.shell string.quoted.single.shell - punctuation.section.string.end.shell + 0: meta.quoted.shell punctuation.definition.quoted.end.shell pop: 1 - match: '{{cmd_begin}}' set: @@ -1462,7 +1456,7 @@ contexts: - path-pattern-begin unquoted-statements-word-body: - - meta_scope: meta.string.shell meta.command.shell variable.function.shell + - meta_scope: meta.command.shell variable.function.shell - include: line-continuations - include: path-pattern-content - match: '{{cmd_break}}' @@ -1512,11 +1506,11 @@ contexts: set: arithmetic-word-unquoted-body arithmetic-word-double-quoted-body: - - meta_scope: meta.arithmetic.shell + - meta_scope: meta.quoted.shell meta.arithmetic.shell - include: expression-double-quoted-body arithmetic-word-single-quoted-body: - - meta_scope: meta.arithmetic.shell + - meta_scope: meta.quoted.shell meta.arithmetic.shell - include: expression-single-quoted-body arithmetic-word-unquoted-body: diff --git a/ShellScript/Bash/tests/syntax_test_scope.bash b/ShellScript/Bash/tests/syntax_test_scope.bash index ee19a5d376..ef6ea292c9 100644 --- a/ShellScript/Bash/tests/syntax_test_scope.bash +++ b/ShellScript/Bash/tests/syntax_test_scope.bash @@ -9491,7 +9491,7 @@ alias foo=bar # ^ - meta.declaration.alias # ^^^ meta.command.shell entity.name.function.shell # ^ keyword.operator.assignment.shell -# ^^^ meta.string.shell meta.command.shell variable.function.shell +# ^^^ meta.command.shell variable.function.shell alias foo=bar -p 7za=qux # <- meta.declaration.alias.shell keyword.declaration.alias.shell @@ -9499,11 +9499,11 @@ alias foo=bar -p 7za=qux # ^ - meta.declaration.alias # ^^^ meta.command.shell entity.name.function.shell # ^ keyword.operator.assignment.shell -# ^^^ meta.string.shell meta.command.shell variable.function.shell +# ^^^ meta.command.shell variable.function.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell # ^^^ meta.command.shell entity.name.function.shell # ^ keyword.operator.assignment.shell -# ^^^ meta.string.shell meta.command.shell variable.function.shell +# ^^^ meta.command.shell variable.function.shell alias -p foo=bar 7za=qux # <- meta.declaration.alias.shell keyword.declaration.alias.shell @@ -9512,10 +9512,10 @@ alias -p foo=bar 7za=qux # ^^ meta.parameter.option.shell variable.parameter.option.shell # ^^^ meta.command.shell entity.name.function.shell # ^ keyword.operator.assignment.shell -# ^^^ meta.string.shell meta.command.shell variable.function.shell +# ^^^ meta.command.shell variable.function.shell # ^^^ meta.command.shell entity.name.function.shell # ^ keyword.operator.assignment.shell -# ^^^ meta.string.shell meta.command.shell variable.function.shell +# ^^^ meta.command.shell variable.function.shell alias -a -p -- foo=bar baz=qux # <- meta.declaration.alias.shell keyword.declaration.alias.shell @@ -9526,10 +9526,10 @@ alias -a -p -- foo=bar baz=qux # ^^ keyword.operator.end-of-options.shell # ^^^ meta.command.shell entity.name.function.shell # ^ keyword.operator.assignment.shell -# ^^^ meta.string.shell meta.command.shell variable.function.shell +# ^^^ meta.command.shell variable.function.shell # ^^^ meta.command.shell entity.name.function.shell # ^ keyword.operator.assignment.shell -# ^^^ meta.string.shell meta.command.shell variable.function.shell +# ^^^ meta.command.shell variable.function.shell alias $foo=bar # <- meta.declaration.alias.shell keyword.declaration.alias.shell @@ -9537,7 +9537,7 @@ alias $foo=bar # ^ - meta.declaration.alias # ^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell # ^ keyword.operator.assignment.shell -# ^^^ meta.string.shell meta.command.shell variable.function.shell +# ^^^ meta.command.shell variable.function.shell alias ..='cd ..' # <- meta.declaration.alias.shell keyword.declaration.alias.shell @@ -9545,11 +9545,11 @@ alias ..='cd ..' #^^^^ keyword.declaration.alias.shell # ^^ meta.command.shell entity.name.function.shell # ^ keyword.operator.assignment.shell -# ^ meta.string.shell string.quoted.single.shell punctuation.section.string.begin.shell -# ^^ meta.string.shell meta.function-call.identifier.shell meta.command.shell support.function.shell - string -# ^ meta.string.shell meta.function-call.arguments.shell - string -# ^^ meta.string.shell meta.function-call.arguments.shell meta.string.shell string.unquoted.shell -# ^ meta.string.shell string.quoted.single.shell punctuation.section.string.end.shell +# ^ meta.quoted.shell punctuation.definition.quoted.begin.shell +# ^^ meta.quoted.shell meta.function-call.identifier.shell meta.command.shell support.function.shell - string +# ^ meta.quoted.shell meta.function-call.arguments.shell - string +# ^^ meta.quoted.shell meta.function-call.arguments.shell meta.string.shell string.unquoted.shell +# ^ meta.quoted.shell punctuation.definition.quoted.end.shell alias -p ..='cd ..' # <- meta.declaration.alias.shell keyword.declaration.alias.shell @@ -9558,11 +9558,11 @@ alias -p ..='cd ..' # ^^ meta.parameter.option.shell variable.parameter.option.shell # ^^ meta.command.shell entity.name.function.shell # ^ keyword.operator.assignment.shell -# ^ meta.string.shell string.quoted.single.shell punctuation.section.string.begin.shell -# ^^ meta.string.shell meta.function-call.identifier.shell meta.command.shell support.function.shell - string -# ^ meta.string.shell meta.function-call.arguments.shell - string -# ^^ meta.string.shell meta.function-call.arguments.shell meta.string.shell string.unquoted.shell -# ^ meta.string.shell string.quoted.single.shell punctuation.section.string.end.shell +# ^ meta.quoted.shell punctuation.definition.quoted.begin.shell +# ^^ meta.quoted.shell meta.function-call.identifier.shell meta.command.shell support.function.shell - string +# ^ meta.quoted.shell meta.function-call.arguments.shell - string +# ^^ meta.quoted.shell meta.function-call.arguments.shell meta.string.shell string.unquoted.shell +# ^ meta.quoted.shell punctuation.definition.quoted.end.shell alias -- -='cd -' # <- meta.declaration.alias.shell keyword.declaration.alias.shell @@ -9571,11 +9571,11 @@ alias -- -='cd -' # ^^ keyword.operator.end-of-options.shell # ^ meta.command.shell entity.name.function.shell # ^ keyword.operator.assignment.shell -# ^ meta.string.shell string.quoted.single.shell punctuation.section.string.begin.shell -# ^^ meta.string.shell meta.function-call.identifier.shell meta.command.shell support.function.shell - string -# ^ meta.string.shell meta.function-call.arguments.shell - string -# ^ meta.string.shell meta.function-call.arguments.shell meta.string.shell string.unquoted.shell -# ^ meta.string.shell string.quoted.single.shell punctuation.section.string.end.shell +# ^ meta.quoted.shell punctuation.definition.quoted.begin.shell +# ^^ meta.quoted.shell meta.function-call.identifier.shell meta.command.shell support.function.shell - string +# ^ meta.quoted.shell meta.function-call.arguments.shell - string +# ^ meta.quoted.shell meta.function-call.arguments.shell meta.string.shell string.unquoted.shell +# ^ meta.quoted.shell punctuation.definition.quoted.end.shell ############################################################################### @@ -10862,11 +10862,11 @@ mapfile -C "~/.bin/app -p $val arg" array #^^^^^^ meta.function-call.identifier.shell support.function.shell # ^^^^ meta.function-call.arguments.shell - meta.string # ^^ meta.parameter.option.shell variable.parameter.option.shell -# ^ meta.function-call.arguments.shell meta.string.shell string.quoted.double.shell punctuation.section.string.begin.shell -# ^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell meta.function-call.identifier.shell -# ^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell meta.function-call.arguments.shell -# ^ meta.function-call.arguments.shell meta.string.shell string.quoted.double.shell punctuation.section.string.end.shell -# ^ meta.function-call.arguments.shell - meta.string - variable +# ^ meta.function-call.arguments.shell meta.quoted.shell punctuation.definition.quoted.begin.shell +# ^^^^^^^^^^ meta.function-call.arguments.shell meta.quoted.shell meta.function-call.identifier.shell +# ^^^^^^^^^^^^ meta.function-call.arguments.shell meta.quoted.shell meta.function-call.arguments.shell +# ^ meta.function-call.arguments.shell meta.quoted.shell punctuation.definition.quoted.end.shell +# ^ meta.function-call.arguments.shell - meta.quoted - variable # ^^^^^ meta.function-call.arguments.shell meta.variable.shell variable.other.readwrite.shell # ^ - meta.function-call @@ -10887,7 +10887,7 @@ mapfile -d ";" -n 10 -O $origin -s 5 -t -u 20 -C callback -c 10 array # ^^ meta.parameter.option.shell variable.parameter.option.shell # ^^ meta.number.integer.decimal.shell constant.numeric.value.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell -# ^^^^^^^^ meta.string.shell meta.command.shell variable.function.shell +# ^^^^^^^^ meta.command.shell variable.function.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell # ^^ meta.number.integer.decimal.shell constant.numeric.value.shell # ^^^^^ meta.variable.shell variable.other.readwrite.shell @@ -10926,11 +10926,11 @@ readarray -C "~/.bin/app -p $val arg" array #^^^^^^^^ meta.function-call.identifier.shell support.function.shell # ^^^^ meta.function-call.arguments.shell - meta.string # ^^ meta.parameter.option.shell variable.parameter.option.shell -# ^ meta.function-call.arguments.shell meta.string.shell string.quoted.double.shell punctuation.section.string.begin.shell -# ^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell meta.function-call.identifier.shell -# ^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell meta.function-call.arguments.shell -# ^ meta.function-call.arguments.shell meta.string.shell string.quoted.double.shell punctuation.section.string.end.shell -# ^ meta.function-call.arguments.shell - meta.string - variable +# ^ meta.function-call.arguments.shell meta.quoted.shell punctuation.definition.quoted.begin.shell +# ^^^^^^^^^^ meta.function-call.arguments.shell meta.quoted.shell meta.function-call.identifier.shell +# ^^^^^^^^^^^^ meta.function-call.arguments.shell meta.quoted.shell meta.function-call.arguments.shell +# ^ meta.function-call.arguments.shell meta.quoted.shell punctuation.definition.quoted.end.shell +# ^ meta.function-call.arguments.shell - meta.quoted - variable # ^^^^^ meta.function-call.arguments.shell meta.variable.shell variable.other.readwrite.shell # ^ - meta.function-call @@ -10951,7 +10951,7 @@ readarray -d ";" -n 10 -O $origin -s 5 -t -u 20 -C callback -c 10 array # ^^ meta.parameter.option.shell variable.parameter.option.shell # ^^ meta.number.integer.decimal.shell constant.numeric.value.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell -# ^^^^^^^^ meta.string.shell meta.command.shell variable.function.shell +# ^^^^^^^^ meta.command.shell variable.function.shell # ^^ meta.parameter.option.shell variable.parameter.option.shell # ^^ meta.number.integer.decimal.shell constant.numeric.value.shell # ^^^^^ meta.variable.shell variable.other.readwrite.shell @@ -11386,46 +11386,46 @@ trap 'cmd --args="value"' SIGINT # <- meta.function-call.identifier.shell support.function.shell #^^^ meta.function-call.identifier.shell support.function.shell # ^ meta.function-call.arguments.shell - meta.function-call meta-function-call -# ^ meta.function-call.arguments.shell meta.string.shell string.quoted.single.shell -# ^^^ meta.function-call.arguments.shell meta.string.shell meta.function-call.identifier.shell -# ^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell meta.function-call.arguments.shell -# ^ meta.function-call.arguments.shell meta.string.shell string.quoted.single.shell +# ^ meta.function-call.arguments.shell meta.quoted.shell +# ^^^ meta.function-call.arguments.shell meta.quoted.shell meta.function-call.identifier.shell +# ^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.quoted.shell meta.function-call.arguments.shell +# ^ meta.function-call.arguments.shell meta.quoted.shell # ^^^^^^^ meta.function-call.arguments.shell - meta.function-call meta-function-call -# ^ punctuation.section.string.begin.shell +# ^ punctuation.definition.quoted.begin.shell # ^^^ variable.function.shell # ^^^^^^ meta.parameter.option.shell variable.parameter.option.shell # ^ keyword.operator.assignment.shell # ^^^^^^^ meta.string.shell string.quoted.double.shell -# ^ punctuation.section.string.end.shell +# ^ punctuation.definition.quoted.end.shell # ^^^^^^ constant.language.signal.shell trap "cmd --args='value'" SIGKILL # <- meta.function-call.identifier.shell support.function.shell #^^^ meta.function-call.identifier.shell support.function.shell # ^ meta.function-call.arguments.shell - meta.function-call meta-function-call -# ^ meta.function-call.arguments.shell meta.string.shell string.quoted.double.shell -# ^^^ meta.function-call.arguments.shell meta.string.shell meta.function-call.identifier.shell -# ^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell meta.function-call.arguments.shell -# ^ meta.function-call.arguments.shell meta.string.shell string.quoted.double.shell +# ^ meta.function-call.arguments.shell meta.quoted.shell +# ^^^ meta.function-call.arguments.shell meta.quoted.shell meta.function-call.identifier.shell +# ^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.quoted.shell meta.function-call.arguments.shell +# ^ meta.function-call.arguments.shell meta.quoted.shell # ^^^^^^^ meta.function-call.arguments.shell - meta.function-call meta-function-call -# ^ punctuation.section.string.begin.shell +# ^ punctuation.definition.quoted.begin.shell # ^^^ variable.function.shell # ^^^^^^ meta.parameter.option.shell variable.parameter.option.shell # ^ keyword.operator.assignment.shell # ^^^^^^^ meta.string.shell string.quoted.single.shell -# ^ punctuation.section.string.end.shell +# ^ punctuation.definition.quoted.end.shell # ^^^^^^^ constant.language.signal.shell trap "\"cmd\" --args=\"val${ue}\"" SIGKILL # <- meta.function-call.identifier.shell support.function.shell #^^^ meta.function-call.identifier.shell support.function.shell # ^ meta.function-call.arguments.shell - meta.function-call meta-function-call -# ^ meta.function-call.arguments.shell meta.string.shell string.quoted.double.shell -# ^^^^^^^ meta.function-call.arguments.shell meta.string.shell meta.function-call.identifier.shell -# ^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell meta.function-call.arguments.shell -# ^ meta.function-call.arguments.shell meta.string.shell string.quoted.double.shell +# ^ meta.function-call.arguments.shell meta.quoted.shell +# ^^^^^^^ meta.function-call.arguments.shell meta.quoted.shell meta.function-call.identifier.shell +# ^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.quoted.shell meta.function-call.arguments.shell +# ^ meta.function-call.arguments.shell meta.quoted.shell # ^^^^^^^ meta.function-call.arguments.shell - meta.function-call meta-function-call -# ^ punctuation.section.string.begin.shell +# ^ punctuation.definition.quoted.begin.shell # ^^^^^^^ variable.function.shell # ^^ constant.character.escape.shell # ^^ constant.character.escape.shell @@ -11435,7 +11435,7 @@ trap "\"cmd\" --args=\"val${ue}\"" SIGKILL # ^^ constant.character.escape.shell # ^^^^^ meta.string.shell meta.interpolation.parameter.shell # ^^ constant.character.escape.shell -# ^ punctuation.section.string.end.shell +# ^ punctuation.definition.quoted.end.shell # ^^^^^^^ constant.language.signal.shell From 6b7e7eebce4b57910aab4369e56fa300b4b34c01 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Wed, 7 Aug 2024 19:33:22 +0200 Subject: [PATCH 075/113] [ShellScript] Improve ZSH extended glob support --- ShellScript/Bash.sublime-syntax | 7 +- ShellScript/Zsh.sublime-syntax | 713 ++++++--- ShellScript/Zsh/tests/syntax_test_scope.zsh | 1572 ++++++++++++++++--- 3 files changed, 1839 insertions(+), 453 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 7565df3e30..8ba74a9641 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -1595,10 +1595,9 @@ contexts: scope: keyword.operator.assignment.shell - match: '[&|^~]' scope: keyword.operator.bitwise.shell - - match: \, - scope: punctuation.separator.sequence.shell - match: \:|\? scope: keyword.operator.ternary.shell + - include: comma-separators - include: terminators # Shell variables are allowed as operands; parameter expansion is performed # before the expression is evaluated. Within an expression, shell variables @@ -1649,6 +1648,10 @@ contexts: - match: \||\& scope: keyword.operator.assignment.pipe.shell + comma-separators: + - match: ',' + scope: punctuation.separator.sequence.shell + terminators: - match: ; scope: punctuation.terminator.statement.shell diff --git a/ShellScript/Zsh.sublime-syntax b/ShellScript/Zsh.sublime-syntax index 2d2c9c425d..ef63f047d2 100644 --- a/ShellScript/Zsh.sublime-syntax +++ b/ShellScript/Zsh.sublime-syntax @@ -285,155 +285,57 @@ contexts: string-path-pattern-content: - meta_prepend: true - - include: zsh-pattern-flags - - include: zsh-pattern-operators - - include: zsh-pattern-ranges + - include: zsh-glob-flags + - include: zsh-glob-operators + - include: zsh-glob-ranges ###[ PATH PATTERN MATCHING ]################################################### path-pattern-content: - meta_prepend: true - - include: zsh-pattern-flags - - include: zsh-pattern-operators - - include: zsh-pattern-ranges + - include: zsh-glob-flags + - include: zsh-glob-operators + - include: zsh-glob-ranges ###[ SHELL PATTERN MATCHING ]################################################## pattern-main-content: - meta_prepend: true - - include: zsh-pattern-flags - - include: zsh-pattern-operators - - include: zsh-pattern-ranges + - include: zsh-glob-flags + - include: zsh-glob-operators + - include: zsh-glob-ranges pattern-groups: - # KSH_GLOB is optional (hence not matching ? and * in favor of ZSH globs) - - match: ([+@!]??)(\() - captures: - 1: string.unquoted.shell keyword.operator.quantifier.regexp.shell - 2: meta.group.regexp.shell string.unquoted.shell punctuation.definition.group.begin.regexp.shell - push: pattern-group-body - - pattern-group-content: - - meta_prepend: true - - match: (?=e(?:[<{(\[]|.["'])) - push: zsh-evaluation-interpolation - - include: zsh-pattern-flags - - include: zsh-pattern-operators - - include: zsh-pattern-ranges - - zsh-evaluation-interpolation: - - clear_scopes: 1 - - meta_scope: meta.interpolation.command.shell.zsh - - match: e\{(["']?) - scope: punctuation.section.interpolation.begin.shell.zsh - embed: statements - escape: \1\} - escape_captures: - 0: punctuation.section.interpolation.end.shell.zsh - - match: e\[(["']?) - scope: punctuation.section.interpolation.begin.shell.zsh - embed: statements - escape: \1\] - escape_captures: - 0: punctuation.section.interpolation.end.shell.zsh - - match: e\((["']?) - scope: punctuation.section.interpolation.begin.shell.zsh - embed: statements - escape: \3\) - escape_captures: - 0: punctuation.section.interpolation.end.shell.zsh - - match: e<(["']?) - scope: punctuation.section.interpolation.begin.shell.zsh - embed: statements - escape: \3> - escape_captures: - 0: punctuation.section.interpolation.end.shell.zsh - - match: e(.)(['"]?) - scope: punctuation.section.interpolation.begin.shell.zsh - embed: statements - escape: \2\1 - escape_captures: - 0: punctuation.section.interpolation.end.shell.zsh - - include: immediately-pop + # KSH_GLOB is optional (hence don't support it) + - match: (?=\() + branch_point: pattern-group + branch: + - zsh-glob-qualifier + - pattern-group - zsh-pattern-flags: - - match: \(# - scope: punctuation.definition.modifier.begin.shell.zsh - push: zsh-pattern-flag-body + pattern-group: + - match: \( + scope: punctuation.definition.group.begin.regexp.shell + set: pattern-group-body - zsh-pattern-flag-body: - - clear_scopes: 1 - - meta_scope: meta.modifier.glob.shell.zsh - - meta_content_scope: storage.modifier.mode.glob.shell.zsh - - include: zsh-pattern-flag-end - - include: string-interpolations - - match: \, - scope: punctuation.separator.sequence.shell - - match: q - scope: storage.modifier.mode.glob.shell.zsh - set: zsh-pattern-flag-qualifier-body + pattern-group-body: + - clear_scopes: 1 # clear `string.unquoted` + - meta_include_prototype: false + - meta_scope: meta.group.regexp.shell string.unquoted.shell + - include: pattern-group-end + - include: pattern-group-content - zsh-pattern-flag-qualifier-body: - # Contains glob qualifiers if EXTENDED_GLOB is set - # https://zsh.sourceforge.io/Doc/Release/Expansion.html#Glob-Qualifiers - - clear_scopes: 1 - - meta_scope: meta.modifier.glob.shell.zsh - - include: zsh-pattern-flag-end - - include: string-interpolations + pattern-group-content: + - meta_prepend: true + - include: zsh-glob-flags + - include: zsh-glob-operators + - include: zsh-glob-ranges - zsh-pattern-flag-end: + pattern-group-end: - match: \) - scope: punctuation.definition.modifier.end.shell.zsh - pop: 1 - - include: line-continuations - - zsh-pattern-operators: - - match: '[~^]' - scope: keyword.operator.logical.regexp.shell.zsh - push: maybe-tilde-interpolation - - match: \#{1,2} - scope: keyword.operator.quantifier.regexp.shell.zsh - - zsh-pattern-ranges: - - match: (?=<[^<&]) - branch_point: zsh-pattern-range - branch: - - zsh-pattern-range-begin - - zsh-pattern-range-fallback - - zsh-pattern-range-begin: - - meta_include_prototype: false - - match: \< - scope: punctuation.definition.range.begin.shell.zsh - set: zsh-pattern-range-body - - zsh-pattern-range-body: - - meta_scope: meta.range.shell.zsh - - match: \> - scope: punctuation.definition.range.end.shell.zsh + scope: punctuation.definition.group.end.regexp.shell pop: 1 - include: line-continuations - - include: expansions-variables - - match: \- - scope: keyword.operator.range.shell.zsh - - match: ([-+]?)(\d+) - scope: meta.number.integer.decimal.shell - captures: - 1: keyword.operator.arithmetic.shell - 2: constant.numeric.value.shell - - match: '' - fail: zsh-pattern-range - - zsh-pattern-range-fallback: - - meta_include_prototype: false - # input redirection - - match: (\d*)(<&?) - captures: - 1: meta.file-descriptor.shell - meta.number.integer.decimal.shell - constant.numeric.value.shell - 2: keyword.operator.assignment.redirection.shell - set: redirection-descriptor ###[ ARITHMETIC EXPANSIONS ]################################################### @@ -527,9 +429,9 @@ contexts: expansion-parameter-pattern: - meta_prepend: true - - include: zsh-pattern-flags - - include: zsh-pattern-operators - - include: zsh-pattern-ranges + - include: zsh-glob-flags + - include: zsh-glob-operators + - include: zsh-glob-ranges expansion-parameter-pattern-groups: # KSH_GLOB is optional (hence not matching ? and * in favor of ZSH globs) @@ -541,9 +443,9 @@ contexts: expansion-parameter-pattern-group-body: - meta_prepend: true - - include: zsh-pattern-flags - - include: zsh-pattern-operators - - include: zsh-pattern-ranges + - include: zsh-glob-flags + - include: zsh-glob-operators + - include: zsh-glob-ranges zsh-parameter-subscription: - meta_include_prototype: false @@ -559,190 +461,501 @@ contexts: - include: immediately-pop zsh-parameter-flag-body: - - meta_scope: meta.modifier.parameter.shell.zsh - - match: \) - scope: punctuation.definition.modifier.end.shell.zsh - pop: 1 + - meta_scope: meta.modifier.expansion.shell.zsh + - include: zsh-modifier-end # bailout from unbalanced brackets - include: brace-pop # flag:expr: - - match: '[Ilr]' + - match: 'I' scope: storage.modifier.expansion.flag.shell.zsh - push: zsh-parameter-flag-expression-argument - # _:flags: - - match: (_)(\W)(.*?)(\2) - captures: - 1: storage.modifier.expansion.flag.reserved.shell.zsh - 2: punctuation.section.argument.begin.shell.zsh - 3: invalid.illegal.unsupported.shell.zsh - 4: punctuation.section.argument.end.shell.zsh + push: zsh-modifier-expression + # flag:string: + - match: '[_gjsZ]' + scope: storage.modifier.expansion.flag.shell.zsh + push: zsh-modifier-string + # flag:expr::string::string: + - match: '[lr]' + scope: storage.modifier.expansion.flag.shell.zsh + push: + - zsh-modifier-string + - zsh-modifier-string + - zsh-modifier-expression # simple single char flags - # TODO: `*` enables extended globs -> handle in syntax? - - match: '[-~#%*@0ABCDEFLMNOPQRSTUVWXZabcefgijkmnopqstuvwz]' + - match: '[-~#%*@0ABCDEFLMNOPQRSTUVWXabcefikmnopqtuvwz]' scope: storage.modifier.expansion.flag.shell.zsh - # string arguments - - match: \< - scope: punctuation.section.argument.begin.shell.zsh - push: zsh-parameter-flag-angle-string-argument - - match: \{ - scope: punctuation.section.argument.begin.shell.zsh - push: zsh-parameter-flag-brace-string-argument + +###[ TILDE EXPANSIONS ]######################################################## + + tilde-interpolation: + - meta_append: true + # 14.7.3 '=' expansion + # https://zsh.sourceforge.io/Doc/Release/Expansion.html#g_t_0060_003d_0027-expansion + - match: = + scope: punctuation.definition.expansion.shell.zsh + pop: 1 + + tilde-modifier: + - meta_prepend: true + # 14.7.1 Dynamic named directories + # https://zsh.sourceforge.io/Doc/Release/Expansion.html#Dynamic-named-directories - match: \[ - scope: punctuation.section.argument.begin.shell.zsh - push: zsh-parameter-flag-bracket-string-argument + scope: punctuation.section.brackets.begin.shell.zsh + push: tilde-modifier-function + + tilde-modifier-function: + - meta_scope: meta.brackets.shell.zsh + - meta_content_scope: meta.function-call.identifier.shell.zsh variable.function.shell.zsh + - match: \] + scope: punctuation.section.brackets.end.shell.zsh + pop: 2 + - include: literal-unquoted-content + +###[ ZSH GLOB FLAGS ]########################################################## + + zsh-glob-flags: + # 14.8.4 Globbing Flags + # https://zsh.sourceforge.io/Doc/Release/Expansion.html#Globbing-Flags + - match: \(# + scope: punctuation.definition.modifier.begin.shell.zsh + push: zsh-glob-flag-body + + zsh-glob-flag-body: + - clear_scopes: 1 # clear `string.unquoted` + - meta_scope: meta.modifier.glob.shell.zsh + - meta_content_scope: storage.modifier.mode.glob.shell.zsh + - include: zsh-modifier-end + - include: comma-separators + - include: string-interpolations + - match: q + scope: storage.modifier.mode.glob.shell.zsh + push: zsh-glob-flag-qualifier + + zsh-glob-flag-qualifier: + - clear_scopes: 1 # clear `string.unquoted` + - include: zsh-modifier-end-ahead + - include: zsh-glob-qualifier-content + +###[ ZSH GLOB OPERATORS ]###################################################### + + zsh-glob-operators: + - match: '[~^]' + scope: keyword.operator.logical.regexp.shell.zsh + push: maybe-tilde-interpolation + - match: \#{1,2} + scope: keyword.operator.quantifier.regexp.shell.zsh + +###[ ZSH GLOB QUALIFIERS ]##################################################### + + zsh-glob-qualifier: + # 14.8.7 Glob Qualifiers + # Contains glob qualifiers if EXTENDED_GLOB is set + # https://zsh.sourceforge.io/Doc/Release/Expansion.html#Glob-Qualifiers - match: \( - scope: punctuation.section.argument.begin.shell.zsh - push: zsh-parameter-flag-paren-string-argument - - match: (\W) - scope: punctuation.section.argument.begin.shell.zsh - push: zsh-parameter-flag-string-argument + scope: punctuation.definition.modifier.begin.shell.zsh + set: zsh-glob-qualifier-body + + zsh-glob-qualifier-body: + - clear_scopes: 1 # clear `string.unquoted` + - meta_include_prototype: false + - meta_scope: meta.modifier.glob.shell.zsh + - include: zsh-glob-qualifier-end + - include: zsh-glob-qualifier-content - zsh-parameter-flag-expression-argument: + zsh-glob-qualifier-end: + - match: \) + scope: punctuation.definition.modifier.end.shell.zsh + set: zsh-glob-qualifier-check + - include: line-continuations + + zsh-glob-qualifier-check: + # it's only a qualifier at the end of a pattern (word). + - meta_include_prototype: false + - match: '{{word_break}}' + pop: 1 + - match: '' + fail: pattern-group + + zsh-glob-qualifier-fail: + - match: (?=\S) + fail: pattern-group + + zsh-glob-qualifier-content: + - include: comma-separators + - include: expansions-variables + - include: zsh-glob-numbers + # begin of history expansion modifiers + - match: ':' + scope: punctuation.separator.sequence.shell.zsh + push: zsh-glob-qualifier-modifier + # restrict which matches are returned + - match: \[ + scope: punctuation.definition.range.begin.shell.zsh + push: zsh-glob-qualifier-range-body + # file credentials + - match: f + scope: storage.modifier.glob.shell.zsh + push: zsh-qualifier-fspec + # evaluation of subshell command + - match: e + scope: storage.modifier.glob.shell.zsh + push: zsh-modifier-statement + # device, group, user, prefix + - match: '[dGPU]' + scope: storage.modifier.glob.shell.zsh + push: zsh-modifier-string + - match: |- + (?x) + # device files + %[bc]? + # file size + | [Ll][GMkT]? + # access / creation / modification time + | [acm][Mwhms]? + # sort order + | [Oo][nLlamcdN]? + # other single char flags + | [*./=@ADEFIMNnprRsStTuwWxXY] + scope: storage.modifier.glob.shell.zsh + - match: '[-^]' + scope: keyword.operator.logical.shell.zsh + # anything else indicates normal pattern group + - include: zsh-glob-qualifier-fail + + zsh-glob-qualifier-modifier: + - include: zsh-modifier-end-ahead + - include: zsh-modifier-content + - include: zsh-glob-qualifier-fail + + zsh-glob-qualifier-range-body: + - meta_scope: meta.range.glob.shell.zsh + - match: \] + scope: punctuation.definition.range.end.shell.zsh + pop: 1 + - include: comma-separators + - include: expansions-variables + - include: zsh-glob-numbers + - include: zsh-glob-qualifier-fail + + zsh-qualifier-fspec: + # credentials given as octal number + - match: ([-+=]?)([?0-7]{1,3}) + captures: + 1: keyword.operator.logical.shell.zsh + 2: meta.number.integer.octal.shell constant.numeric.value.shell + pop: 1 + # credentials given as interpolation + - match: ([-+=]?){{is_interpolation}} + captures: + 1: keyword.operator.logical.shell.zsh + set: string-interpolation-body + # anything else is a glob string + - include: zsh-modifier-string + +###[ ZSH GLOB RANGES ]######################################################### + + zsh-glob-ranges: + - match: (?=<[^<&]) + branch_point: zsh-glob-range + branch: + - zsh-glob-range-begin + - zsh-glob-range-fallback + + zsh-glob-range-begin: + - meta_include_prototype: false + - match: \< + scope: punctuation.definition.range.begin.shell.zsh + set: zsh-glob-range-body + + zsh-glob-range-body: + - meta_scope: meta.range.shell.zsh + - match: \> + scope: punctuation.definition.range.end.shell.zsh + pop: 1 + - match: \- + scope: keyword.operator.range.shell.zsh + - include: line-continuations + - include: expansions-variables + - include: zsh-glob-numbers + - match: '' + fail: zsh-glob-range + + zsh-glob-range-fallback: + - meta_include_prototype: false + # input redirection + - match: < + scope: keyword.operator.assignment.redirection.shell + set: redirection-descriptor + + zsh-glob-numbers: + - match: ([-+]?)(\d+) + scope: meta.number.integer.decimal.shell + captures: + 1: keyword.operator.arithmetic.shell + 2: constant.numeric.value.shell + +###[ ZSH MODIFIERS ]########################################################### + + zsh-modifier-end: + - match: \) + scope: punctuation.definition.modifier.end.shell.zsh + pop: 1 + - include: line-continuations + + zsh-modifier-end-ahead: + - match: (?=\)) + pop: 1 + - include: line-continuations + + zsh-modifier-content: + # 14.1.4 Modifiers + # https://zsh.sourceforge.io/Doc/Release/Expansion.html#Modifiers + - include: zsh-glob-numbers + # s/pat/repl[/flag] + # valid only in modifiers or qualifiers + - match: (s)([^`'"<>()]) + captures: + 1: support.function.substitution.shell.zsh + 2: keyword.operator.substitution.shell.zsh + push: + - zsh-modifier-subst-flag + - zsh-modifier-subst-replacement + - zsh-modifier-subst-pattern + - match: 'F' + scope: storage.modifier.glob.shell.zsh + push: zsh-modifier-expression + - match: 'W' + scope: storage.modifier.glob.shell.zsh + push: zsh-modifier-string + - match: '[&aAcefhlpPqQrtuwx]' + scope: storage.modifier.glob.shell.zsh + - match: ':' + scope: punctuation.separator.sequence.shell.zsh + + zsh-modifier-subst-pattern: + - match: \2 + scope: keyword.operator.substitution.shell.zsh + pop: 1 + - include: zsh-modifier-end-ahead + - include: line-continuations + - include: string-path-pattern-content + + zsh-modifier-subst-replacement: + - meta_content_scope: meta.string.regexp.shell string.unquoted.shell + - include: zsh-modifier-subst-pattern + + zsh-modifier-subst-flag: + - meta_scope: meta.substituation.shell.zsh + - match: (:)(G) + captures: + 1: punctuation.separator.sequence.shell.zsh + 2: constant.other.flag.regexp.shell.zsh + pop: 1 + - include: immediately-pop + +###[ ZSH MODIFIER STATEMENT STRINGS ]########################################## + + zsh-modifier-statement: + # note: additional `meta.modifier.glob.shell.zsh` scope in escape due to + # issue: https://github.com/sublimehq/sublime_text/issues/4069 + - meta_include_prototype: false + - match: (<)\s*(["']?) + scope: meta.quoted.glob.shell.zsh + captures: + 1: punctuation.definition.quoted.begin.shell.zsh + 2: punctuation.definition.quoted.begin.shell + embed: statements + embed_scope: meta.quoted.glob.shell.zsh meta.interpolation.command.shell + escape: (?:(\2)\s*)?(>) + escape_captures: + 0: meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh + 1: punctuation.definition.quoted.end.shell + 2: punctuation.definition.quoted.end.shell.zsh + pop: 1 + - match: (\{)\s*(["']?) + scope: meta.quoted.glob.shell.zsh + captures: + 1: punctuation.definition.quoted.begin.shell.zsh + 2: punctuation.definition.quoted.begin.shell + embed: statements + embed_scope: meta.quoted.glob.shell.zsh meta.interpolation.command.shell + escape: (?:(\2)\s*)?(\}) + escape_captures: + 0: meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh + 1: punctuation.definition.quoted.end.shell + 2: punctuation.definition.quoted.end.shell.zsh + pop: 1 + - match: (\[)\s*(["']?) + scope: meta.quoted.glob.shell.zsh + captures: + 1: punctuation.definition.quoted.begin.shell.zsh + 2: punctuation.definition.quoted.begin.shell + embed: statements + embed_scope: meta.quoted.glob.shell.zsh meta.interpolation.command.shell + escape: (?:(\2)\s*)?(\]) + escape_captures: + 0: meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh + 1: punctuation.definition.quoted.end.shell + 2: punctuation.definition.quoted.end.shell.zsh + pop: 1 + - match: (\()\s*(["']?) + scope: meta.quoted.glob.shell.zsh + captures: + 1: punctuation.definition.quoted.begin.shell.zsh + 2: punctuation.definition.quoted.begin.shell + embed: statements + embed_scope: meta.quoted.glob.shell.zsh meta.interpolation.command.shell + escape: (?:(\2)\s*)?(\)) + escape_captures: + 0: meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh + 1: punctuation.definition.quoted.end.shell + 2: punctuation.definition.quoted.end.shell.zsh + pop: 1 + - match: '{{glob_string_quote}}\s*([''"]?)' + scope: meta.quoted.glob.shell.zsh + captures: + 1: punctuation.definition.quoted.begin.shell.zsh + 2: punctuation.definition.quoted.begin.shell + embed: statements + embed_scope: meta.quoted.glob.shell.zsh meta.interpolation.command.shell + escape: (?:(\2)\s*)?(\1) + escape_captures: + 0: meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh + 1: punctuation.definition.quoted.end.shell + 2: punctuation.definition.quoted.end.shell.zsh + pop: 1 + - include: immediately-pop + +###[ ZSH MODIFIER EXPRESSION STRINGS ]######################################### + + zsh-modifier-expression: - meta_include_prototype: false - match: \< - scope: punctuation.section.argument.begin.shell.zsh - set: zsh-parameter-flag-angle-expression-argument + scope: punctuation.definition.quoted.begin.shell.zsh + set: zsh-modifier-expression-angle-body - match: \{ - scope: punctuation.section.argument.begin.shell.zsh - set: zsh-parameter-flag-brace-expression-argument + scope: punctuation.definition.quoted.begin.shell.zsh + set: zsh-modifier-expression-brace-body - match: \[ - scope: punctuation.section.argument.begin.shell.zsh - set: zsh-parameter-flag-bracket-expression-argument + scope: punctuation.definition.quoted.begin.shell.zsh + set: zsh-modifier-expression-bracket-body - match: \( - scope: punctuation.section.argument.begin.shell.zsh - set: zsh-parameter-flag-paren-expression-argument - - match: (\W) - scope: punctuation.section.argument.begin.shell.zsh - set: zsh-parameter-flag-other-expression-argument + scope: punctuation.definition.quoted.begin.shell.zsh + set: zsh-modifier-expression-paren-body + - match: '{{glob_string_quote}}' + scope: punctuation.definition.quoted.begin.shell.zsh + set: zsh-modifier-expression-other-body - include: immediately-pop - zsh-parameter-flag-angle-expression-argument: + zsh-modifier-expression-angle-body: - meta_include_prototype: false - - meta_scope: meta.argument.shell.zsh + - meta_scope: meta.quoted.glob.shell.zsh - meta_content_scope: meta.arithmetic.shell - match: \> - scope: punctuation.section.argument.end.shell.zsh + scope: punctuation.definition.quoted.end.shell.zsh pop: 1 - - include: brace-pop - include: expression-content - zsh-parameter-flag-brace-expression-argument: + zsh-modifier-expression-brace-body: - meta_include_prototype: false - - meta_scope: meta.argument.shell.zsh + - meta_scope: meta.quoted.glob.shell.zsh - meta_content_scope: meta.arithmetic.shell - match: \} - scope: punctuation.section.argument.end.shell.zsh + scope: punctuation.definition.quoted.end.shell.zsh pop: 1 - include: expression-content - zsh-parameter-flag-bracket-expression-argument: + zsh-modifier-expression-bracket-body: - meta_include_prototype: false - - meta_scope: meta.argument.shell.zsh + - meta_scope: meta.quoted.glob.shell.zsh - meta_content_scope: meta.arithmetic.shell - match: \] - scope: punctuation.section.argument.end.shell.zsh + scope: punctuation.definition.quoted.end.shell.zsh pop: 1 - - include: brace-pop - include: expression-content - zsh-parameter-flag-paren-expression-argument: + zsh-modifier-expression-paren-body: - meta_include_prototype: false - - meta_scope: meta.argument.shell.zsh + - meta_scope: meta.quoted.glob.shell.zsh - meta_content_scope: meta.arithmetic.shell - match: \) - scope: punctuation.section.argument.end.shell.zsh + scope: punctuation.definition.quoted.end.shell.zsh pop: 1 - - include: brace-pop - include: expression-content - zsh-parameter-flag-other-expression-argument: + zsh-modifier-expression-other-body: - meta_include_prototype: false - - meta_scope: meta.argument.shell.zsh + - meta_scope: meta.quoted.glob.shell.zsh - meta_content_scope: meta.arithmetic.shell - match: \1 - scope: punctuation.section.argument.end.shell.zsh + scope: punctuation.definition.quoted.end.shell.zsh pop: 1 - - include: brace-pop - include: expression-content - zsh-parameter-flag-angle-string-argument: +###[ ZSH MODIFIER LITERAL STRINGS ]############################################ + + zsh-modifier-string: + - match: \< + scope: punctuation.definition.quoted.begin.shell.zsh + set: zsh-modifier-string-angle-body + - match: \{ + scope: punctuation.definition.quoted.begin.shell.zsh + set: zsh-modifier-string-brace-body + - match: \[ + scope: punctuation.definition.quoted.begin.shell.zsh + set: zsh-modifier-string-bracket-body + - match: \( + scope: punctuation.definition.quoted.begin.shell.zsh + set: zsh-modifier-string-paren-body + - match: '{{glob_string_quote}}' + scope: punctuation.definition.quoted.begin.shell.zsh + set: zsh-modifier-string-other-body + - include: immediately-pop + + zsh-modifier-string-angle-body: - meta_include_prototype: false - - meta_scope: meta.argument.shell.zsh - - meta_content_scope: meta.string.shell.zsh string.unquoted.shell.zsh + - meta_scope: meta.quoted.glob.shell.zsh + - meta_content_scope: string.quoted.other.shell.zsh - match: \> - scope: punctuation.section.argument.end.shell.zsh + scope: punctuation.definition.quoted.end.shell.zsh pop: 1 - - include: brace-pop - include: string-unquoted-content - zsh-parameter-flag-brace-string-argument: + zsh-modifier-string-brace-body: - meta_include_prototype: false - - meta_scope: meta.argument.shell.zsh - - meta_content_scope: meta.string.shell.zsh string.unquoted.shell.zsh + - meta_scope: meta.quoted.glob.shell.zsh + - meta_content_scope: string.quoted.other.shell.zsh - match: \} - scope: punctuation.section.argument.end.shell.zsh + scope: punctuation.definition.quoted.end.shell.zsh pop: 1 - include: string-unquoted-content - zsh-parameter-flag-bracket-string-argument: + zsh-modifier-string-bracket-body: - meta_include_prototype: false - - meta_scope: meta.argument.shell.zsh - - meta_content_scope: meta.string.shell.zsh string.unquoted.shell.zsh + - meta_scope: meta.quoted.glob.shell.zsh + - meta_content_scope: string.quoted.other.shell.zsh - match: \] - scope: punctuation.section.argument.end.shell.zsh + scope: punctuation.definition.quoted.end.shell.zsh pop: 1 - - include: brace-pop - include: string-unquoted-content - zsh-parameter-flag-paren-string-argument: + zsh-modifier-string-paren-body: - meta_include_prototype: false - - meta_scope: meta.argument.shell.zsh - - meta_content_scope: meta.string.shell.zsh string.unquoted.shell.zsh + - meta_scope: meta.quoted.glob.shell.zsh + - meta_content_scope: string.quoted.other.shell.zsh - match: \) - scope: punctuation.section.argument.end.shell.zsh + scope: punctuation.definition.quoted.end.shell.zsh pop: 1 - - include: brace-pop - include: string-unquoted-content - zsh-parameter-flag-string-argument: + zsh-modifier-string-other-body: - meta_include_prototype: false - - meta_scope: meta.argument.shell.zsh - - meta_content_scope: meta.string.shell.zsh string.unquoted.shell.zsh + - meta_scope: meta.quoted.glob.shell.zsh + - meta_content_scope: string.quoted.other.shell.zsh - match: \1 - scope: punctuation.section.argument.end.shell.zsh + scope: punctuation.definition.quoted.end.shell.zsh pop: 1 - - include: brace-pop - include: string-unquoted-content -###[ TILDE EXPANSIONS ]######################################################## - - tilde-interpolation: - - meta_append: true - - include: equals-expansion - - tilde-modifier: - - meta_prepend: true - # 14.7.1 Dynamic named directories - # https://zsh.sourceforge.io/Doc/Release/Expansion.html#Dynamic-named-directories - - match: \[ - scope: punctuation.section.brackets.begin.shell.zsh - push: tilde-modifier-function - - tilde-modifier-function: - - meta_scope: meta.brackets.shell.zsh - - meta_content_scope: meta.function-call.identifier.shell.zsh variable.function.shell.zsh - - match: \] - scope: punctuation.section.brackets.end.shell.zsh - pop: 2 - - include: literal-unquoted-content - - equals-expansion: - # 14.7.3 ‘=’ expansion - # https://zsh.sourceforge.io/Doc/Release/Expansion.html#g_t_0060_003d_0027-expansion - - match: = - scope: punctuation.definition.expansion.shell.zsh - pop: 1 - ###[ VARIABLES ]############################################################### variables: @@ -759,6 +972,8 @@ variables: # Bash ones + `{` and `}` metachar: '[\s|&;(){}<>]' + glob_string_quote: ([^])}>\s\w]) + # 9.3.1 Hook Functions hook_functions: |- (?x: chpwd | periodic | precmd | preexec | zshaddhistory | zshexit ){{cmd_break}} diff --git a/ShellScript/Zsh/tests/syntax_test_scope.zsh b/ShellScript/Zsh/tests/syntax_test_scope.zsh index 2c3de9f683..01cc290ff9 100644 --- a/ShellScript/Zsh/tests/syntax_test_scope.zsh +++ b/ShellScript/Zsh/tests/syntax_test_scope.zsh @@ -1301,7 +1301,7 @@ function { : ${(#)var} # Evaluate the resulting words as numeric expressions and interpret these as character codes. # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1313,7 +1313,7 @@ function { : ${(%)var} # Expand all % escapes in the resulting words in the same way as in prompts # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1325,7 +1325,7 @@ function { : ${(@)var} # In double quotes, array elements are put into separate words. # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1337,7 +1337,7 @@ function { : ${(A)var} # Convert the substitution into an array expression, even if it otherwise would be scalar. # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1349,7 +1349,7 @@ function { : ${(a)var} # Sort in array index order; when combined with ‘O’ sort in reverse array index order. # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1361,7 +1361,7 @@ function { : ${(b)var} # Quote with backslashes only characters that are special to pattern matching # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1373,7 +1373,7 @@ function { : ${(c)var} # With ${#name}, count the total number of characters in an array # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1385,7 +1385,7 @@ function { : ${(C)var} # Capitalize the resulting words. # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1397,7 +1397,7 @@ function { : ${(D)var} # Assume the string or array elements contain directories and attempt to substitute the leading part of these by names. # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1409,7 +1409,7 @@ function { : ${(e)var} # Perform single word shell expansions, namely parameter expansion, command substitution and arithmetic expansion, on the result. # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1421,7 +1421,7 @@ function { : ${(f)var} # Split the result of the expansion at newlines. # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1433,7 +1433,7 @@ function { : ${(F)var} # Join the words of arrays together using newline as a separator # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1445,7 +1445,7 @@ function { : ${(i)var} # Sort case-insensitively. May be combined with ‘n’ or ‘O’. # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1457,7 +1457,7 @@ function { : ${(k)var} # If name refers to an associative array, substitute the keys (element names) rather than the values of the elements. # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1469,7 +1469,7 @@ function { : ${(L)var} # Convert all letters in the result to lower case. # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1481,7 +1481,7 @@ function { : ${(n)var} # Sort decimal integers numerically # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1493,7 +1493,7 @@ function { : ${(-)var} # As n, but a leading minus sign indicates a negative decimal integer. # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1505,7 +1505,7 @@ function { : ${(o)var} # Sort the resulting words in ascending order # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1517,7 +1517,7 @@ function { : ${(O)var} # Sort the resulting words in descending order # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1529,7 +1529,7 @@ function { : ${(p)var} # This forces the value of the parameter name to be interpreted as a further parameter name # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1541,7 +1541,7 @@ function { : ${(q)var} # Quote characters that are special to the shell in the resulting words with backslashes # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1553,7 +1553,7 @@ function { : ${(Q)var} # Remove one level of quotes from the resulting words. # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1565,7 +1565,7 @@ function { : ${(t)var} # Use a string describing the type of the parameter where the value of the parameter would usually appear. # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1577,7 +1577,7 @@ function { : ${(u)var} # Expand only the first occurrence of each unique word. # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1589,7 +1589,7 @@ function { : ${(U)var} # Convert all letters in the result to upper case. # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1601,7 +1601,7 @@ function { : ${(v)var} # Used with k, substitute (as two consecutive words) both the key and the value of each associative array element. # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1613,7 +1613,7 @@ function { : ${(V)var} # Make any special characters in the resulting words visible. # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1625,7 +1625,7 @@ function { : ${(w)var} # With ${#name}, count words in arrays or strings; the s flag may be used to set a word delimiter. # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1637,7 +1637,7 @@ function { : ${(W)var} # Similar to w with the difference that empty words between repeated delimiters are also counted. # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1649,7 +1649,7 @@ function { : ${(X)var} # With this flag, parsing errors occurring with the Q, e and # flags or the pattern matching forms such as ‘${name#pattern}’ are reported. # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1661,7 +1661,7 @@ function { : ${(z)var} # Split the result of the expansion into words using shell parsing to find the words # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1673,7 +1673,7 @@ function { : ${(0)var} # Split the result of the expansion on null bytes. This is a shorthand for ‘ps:\0:’. # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1685,7 +1685,7 @@ function { : ${(~)var} # # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1697,71 +1697,71 @@ function { : ${(j<:>)var} ${(j{:})var} ${(j[:])var} ${(j(:))var} ${(j.:.)var} # Join the words of arrays together using string as a separator. # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ punctuation.definition.modifier.begin.shell.zsh # ^ storage.modifier.expansion.flag.shell.zsh -# ^ punctuation.section.argument.begin.shell.zsh -# ^ string.unquoted.shell.zsh -# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh # ^ punctuation.definition.modifier.end.shell.zsh # ^^^ variable.other.readwrite.shell # ^ punctuation.section.interpolation.end.shell # ^ - meta.interpolation # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ punctuation.definition.modifier.begin.shell.zsh # ^ storage.modifier.expansion.flag.shell.zsh -# ^ punctuation.section.argument.begin.shell.zsh -# ^ string.unquoted.shell.zsh -# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh # ^ punctuation.definition.modifier.end.shell.zsh # ^^^ variable.other.readwrite.shell # ^ punctuation.section.interpolation.end.shell # ^ - meta.interpolation # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ punctuation.definition.modifier.begin.shell.zsh # ^ storage.modifier.expansion.flag.shell.zsh -# ^ punctuation.section.argument.begin.shell.zsh -# ^ string.unquoted.shell.zsh -# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh # ^ punctuation.definition.modifier.end.shell.zsh # ^^^ variable.other.readwrite.shell # ^ punctuation.section.interpolation.end.shell # ^ - meta.interpolation # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ punctuation.definition.modifier.begin.shell.zsh # ^ storage.modifier.expansion.flag.shell.zsh -# ^ punctuation.section.argument.begin.shell.zsh -# ^ string.unquoted.shell.zsh -# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh # ^ punctuation.definition.modifier.end.shell.zsh # ^^^ variable.other.readwrite.shell # ^ punctuation.section.interpolation.end.shell # ^ - meta.interpolation # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ punctuation.definition.modifier.begin.shell.zsh # ^ storage.modifier.expansion.flag.shell.zsh -# ^ punctuation.section.argument.begin.shell.zsh -# ^ string.unquoted.shell.zsh -# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh # ^ punctuation.definition.modifier.end.shell.zsh # ^^^ variable.other.readwrite.shell # ^ punctuation.section.interpolation.end.shell @@ -1769,28 +1769,29 @@ function { : ${(l:expr::string1::string2:)var} # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh - meta.modifier.expansion.shell.zsh meta.string +# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.modifier.expansion.shell.zsh meta.quoted.glob.shell.zsh +# ^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh - meta.modifier.expansion.shell.zsh meta.string # ^^^^ meta.interpolation.parameter.shell - meta.modifer # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ punctuation.definition.modifier.begin.shell.zsh # ^ storage.modifier.expansion.flag.shell.zsh -# ^ punctuation.section.argument.begin.shell.zsh # ^^^^ variable.other.readwrite.shell -# ^ punctuation.section.argument.end.shell.zsh -# ^ punctuation.section.argument.begin.shell.zsh -# ^^^^^^^ meta.string.shell.zsh string.unquoted.shell.zsh -# ^ punctuation.section.argument.end.shell.zsh -# ^ punctuation.section.argument.begin.shell.zsh -# ^^^^^^^meta.string.shell.zsh string.unquoted.shell.zsh -# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^^^^^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^^^^^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh # ^ punctuation.definition.modifier.end.shell.zsh # ^^^ variable.other.readwrite.shell # ^ punctuation.section.interpolation.end.shell : ${(m)var} # Only useful together with one of the flags l or r or with the # length operator # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1802,189 +1803,198 @@ function { : ${(r:expr:)var} ${(r)var} # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^^^^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifer # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ punctuation.definition.modifier.begin.shell.zsh # ^ storage.modifier.expansion.flag.shell.zsh -# ^ punctuation.section.argument.begin.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh # ^^^^ variable.other.readwrite.shell -# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh # ^ punctuation.definition.modifier.end.shell.zsh # ^^^ variable.other.readwrite.shell # ^ punctuation.section.interpolation.end.shell # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^^^^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifer # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ punctuation.definition.modifier.begin.shell.zsh # ^ storage.modifier.expansion.flag.shell.zsh -# ^ punctuation.section.argument.begin.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh # ^^^^ variable.other.readwrite.shell -# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh # ^ punctuation.definition.modifier.end.shell.zsh # ^^^ variable.other.readwrite.shell # ^ punctuation.section.interpolation.end.shell : ${(r:expr::string1:)var} # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifer # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ punctuation.definition.modifier.begin.shell.zsh # ^ storage.modifier.expansion.flag.shell.zsh -# ^ punctuation.section.argument.begin.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh # ^^^^ variable.other.readwrite.shell -# ^ punctuation.section.argument.end.shell.zsh -# ^ punctuation.section.argument.begin.shell.zsh -# ^^^^^^^ meta.string.shell.zsh string.unquoted.shell.zsh -# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh +# ^^^^^^^^^ meta.quoted.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^^^^^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh # ^ punctuation.definition.modifier.end.shell.zsh # ^^^ variable.other.readwrite.shell # ^ punctuation.section.interpolation.end.shell : ${(r:expr::string1::string2:)var} # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifer # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ punctuation.definition.modifier.begin.shell.zsh # ^ storage.modifier.expansion.flag.shell.zsh -# ^ punctuation.section.argument.begin.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh # ^^^^ variable.other.readwrite.shell -# ^ punctuation.section.argument.end.shell.zsh -# ^ punctuation.section.argument.begin.shell.zsh -# ^^^^^^^ meta.string.shell.zsh string.unquoted.shell.zsh -# ^ punctuation.section.argument.end.shell.zsh -# ^ punctuation.section.argument.begin.shell.zsh -# ^^^^^^^meta.string.shell.zsh string.unquoted.shell.zsh -# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh +# ^^^^^^^^^^^^^^^^^^ meta.quoted.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^^^^^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^^^^^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh # ^ punctuation.definition.modifier.end.shell.zsh # ^^^ variable.other.readwrite.shell # ^ punctuation.section.interpolation.end.shell : ${(s.:.)var} ${(s:del$im:)var} # Force field splitting at the separator string. # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh - meta.quoted.glob +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh meta.quoted.glob.shell.zsh +# ^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh - meta.quoted.glob # ^^^^ meta.interpolation.parameter.shell - meta.modifier +# ^ - meta.interpolation +# ^^ meta.interpolation.parameter.shell - meta.modifier.expansion +# ^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh - meta.quoted.glob +# ^^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh meta.quoted.glob.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh meta.quoted.glob.shell.zsh +# ^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh - meta.quoted.glob +# ^^^^ meta.function-call.arguments.shell meta.string.shell meta.interpolation.parameter.shell - meta.modifier.expansion +# ^ - meta.interpolation # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ punctuation.definition.modifier.begin.shell.zsh # ^ storage.modifier.expansion.flag.shell.zsh -# ^ punctuation.section.argument.begin.shell.zsh -# ^ string.unquoted.shell.zsh -# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh # ^ punctuation.definition.modifier.end.shell.zsh # ^^^ variable.other.readwrite.shell # ^ punctuation.section.interpolation.end.shell -# ^ - meta.interpolation -# ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^^^^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh -# ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ punctuation.definition.modifier.begin.shell.zsh # ^ storage.modifier.expansion.flag.shell.zsh -# ^ punctuation.section.argument.begin.shell.zsh -# ^^^ string.unquoted.shell.zsh - variable +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^ string.quoted.other.shell.zsh - variable # ^^^ variable.other.readwrite.shell - string -# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh # ^ punctuation.definition.modifier.end.shell.zsh # ^^^ variable.other.readwrite.shell # ^ punctuation.section.interpolation.end.shell -# ^ - meta.interpolation : ${(Z+c+)var} ${(Z+C+)var} ${(Z+n+)var} ${(Z+Cn+)var} ${(Z+$opt+)var} # As z but takes a combination of option letters between a following pair of delimiter characters. # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ punctuation.definition.modifier.begin.shell.zsh # ^ storage.modifier.expansion.flag.shell.zsh -# ^ punctuation.section.argument.begin.shell.zsh -# ^ meta.string.shell.zsh string.unquoted.shell.zsh -# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh # ^ punctuation.definition.modifier.end.shell.zsh # ^^^ variable.other.readwrite.shell # ^ punctuation.section.interpolation.end.shell # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ punctuation.definition.modifier.begin.shell.zsh # ^ storage.modifier.expansion.flag.shell.zsh -# ^ punctuation.section.argument.begin.shell.zsh -# ^ meta.string.shell.zsh string.unquoted.shell.zsh -# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh # ^ punctuation.definition.modifier.end.shell.zsh # ^^^ variable.other.readwrite.shell # ^ punctuation.section.interpolation.end.shell # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ punctuation.definition.modifier.begin.shell.zsh # ^ storage.modifier.expansion.flag.shell.zsh -# ^ punctuation.section.argument.begin.shell.zsh -# ^ meta.string.shell.zsh string.unquoted.shell.zsh -# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh # ^ punctuation.definition.modifier.end.shell.zsh # ^^^ variable.other.readwrite.shell # ^ punctuation.section.interpolation.end.shell # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ punctuation.definition.modifier.begin.shell.zsh # ^ storage.modifier.expansion.flag.shell.zsh -# ^ punctuation.section.argument.begin.shell.zsh -# ^^ meta.string.shell.zsh string.unquoted.shell.zsh -# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh # ^ punctuation.definition.modifier.end.shell.zsh # ^^^ variable.other.readwrite.shell # ^ punctuation.section.interpolation.end.shell # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh - meta.interpolation meta.interpolation -# ^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh meta.interpolation.parameter.shell -# ^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh - meta.interpolation meta.interpolation +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh - meta.interpolation meta.interpolation +# ^^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh meta.interpolation.parameter.shell +# ^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh - meta.interpolation meta.interpolation # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ punctuation.definition.modifier.begin.shell.zsh # ^ storage.modifier.expansion.flag.shell.zsh -# ^ punctuation.section.argument.begin.shell.zsh -# ^^^^ meta.string.shell.zsh meta.interpolation.parameter.shell variable.other.readwrite.shell -# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^ punctuation.definition.quoted.end.shell.zsh # ^ punctuation.definition.modifier.end.shell.zsh # ^^^ variable.other.readwrite.shell # ^ punctuation.section.interpolation.end.shell : ${(_:expr:)var} # The underscore (_) flag is reserved for future use. # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^^^^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^^^^^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ punctuation.definition.modifier.begin.shell.zsh -# ^ storage.modifier.expansion.flag.reserved.shell.zsh -# ^ punctuation.section.argument.begin.shell.zsh -# ^^^^ invalid.illegal.unsupported.shell.zsh -# ^ punctuation.section.argument.end.shell.zsh +# ^ storage.modifier.expansion.flag.shell.zsh +# ^^^^^^ meta.quoted.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh # ^ punctuation.definition.modifier.end.shell.zsh # ^^^ variable.other.readwrite.shell # ^ punctuation.section.interpolation.end.shell : ${(S)var} # Search for the match that starts closest to the start of the string # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -1996,24 +2006,24 @@ function { : ${(I:expr:)var} # Search the `expr`th match (where `expr`` evaluates to a number). # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh - meta.arithmetic -# ^^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh meta.arithmetic.shell meta.variable.shell -# ^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh - meta.arithmetic +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh - meta.arithmetic +# ^^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh meta.arithmetic.shell meta.variable.shell +# ^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh - meta.arithmetic # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell # ^ punctuation.definition.modifier.begin.shell.zsh # ^ storage.modifier.expansion.flag.shell.zsh -# ^ punctuation.section.argument.begin.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh # ^^^^ variable.other.readwrite.shell -# ^ punctuation.section.argument.end.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh # ^ punctuation.definition.modifier.end.shell.zsh # ^^^ variable.other.readwrite.shell # ^ punctuation.section.interpolation.end.shell : ${(*)var} # Enable EXTENDED_GLOB for substitution via ${.../...} or ${...//...}. # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -2025,7 +2035,7 @@ function { : ${(B)var} # Include the index of the beginning of the match in the result. # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -2037,7 +2047,7 @@ function { : ${(E)var} # Include the index one character past the end of the match in the result (note this is inconsistent with other uses of parameter index). # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -2049,7 +2059,7 @@ function { : ${(M)var} # Include the matched portion in the result. # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -2061,7 +2071,7 @@ function { : ${(N)var} # Include the length of the match in the result. # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -2073,7 +2083,7 @@ function { : ${(R)var} # Include the unmatched portion in the result (the Rest). # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -2085,7 +2095,7 @@ function { : ${(#)#var} # Flags can be combined with leading operators # ^^ meta.interpolation.parameter.shell - meta.modifier -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^^ meta.interpolation.parameter.shell - meta.modifier # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell @@ -2646,6 +2656,311 @@ any --arg{1,2,3} ={1,2,3} # ^^^^^^^^^ meta.string.shell string.quoted.double.shell - meta.interpolation +############################################################################### +# 14.1.4 Modifiers +# https://zsh.sourceforge.io/Doc/Release/Expansion.html#Modifiers +############################################################################### + +: /(:v) # not a valid modifier, fallback to normal regexp group +# ^^^^ meta.string.shell meta.group.regexp.shell string.unquoted.shell +# ^ punctuation.definition.group.begin.regexp.shell +# ^ punctuation.definition.group.end.regexp.shell + +: /(:a) # Turn a file name into an absolute path +# ^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ punctuation.separator.sequence.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(:A) # Turn a file name into an real path (resolve symlinks) +# ^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ punctuation.separator.sequence.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(:c) # Resolve a command name into an absolute path +# ^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ punctuation.separator.sequence.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(:e) # Remove all but the part of the filename extension following the '.' +# ^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ punctuation.separator.sequence.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(:h10) # Remove a trailing pathname components +# ^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ punctuation.separator.sequence.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(:l) # Convert the words to all lowercase. +# ^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ punctuation.separator.sequence.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(:p) # Print the new command but do not execute it. +# ^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ punctuation.separator.sequence.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(:P) # Turn a file name into an absolute path, permit non-existing +# ^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ punctuation.separator.sequence.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(:q) # Quote the substituted words, escaping further substitutions. +# ^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ punctuation.separator.sequence.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(:Q) # Remove one level of quotes from the substituted words. +# ^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ punctuation.separator.sequence.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(:r) # Remove a filename extension leaving the root name. +# ^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ punctuation.separator.sequence.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: (:s/pa*t?rn/repl) (:s|pattern|repl) (:s;pattern;repl;:G) +# ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.substitution +# ^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.substituation.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.substitution +# ^ - meta.string - meta.modifier +# ^ support.function.substitution.shell.zsh +# ^ keyword.operator.substitution.shell.zsh - string +# ^^^^^^^ meta.string.regexp.shell string.unquoted.shell +# ^ keyword.operator.substitution.shell.zsh +# ^^^^ meta.string.regexp.shell string.unquoted.shell +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.substitution +# ^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.substituation.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.substitution +# ^ - meta.string - meta.modifier +# ^ support.function.substitution.shell.zsh +# ^ keyword.operator.substitution.shell.zsh - string +# ^^^^^^^ meta.string.regexp.shell string.unquoted.shell +# ^ keyword.operator.substitution.shell.zsh +# ^^^^ meta.string.regexp.shell string.unquoted.shell +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.substitution +# ^^^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.substituation.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.substitution +# ^ - meta.string - meta.modifier +# ^ support.function.substitution.shell.zsh +# ^ keyword.operator.substitution.shell.zsh - string +# ^^^^^^^ meta.string.regexp.shell string.unquoted.shell +# ^ keyword.operator.substitution.shell.zsh +# ^^^^ meta.string.regexp.shell string.unquoted.shell +# ^ keyword.operator.substitution.shell.zsh +# ^ punctuation.separator.sequence.shell.zsh +# ^ constant.other.flag.regexp.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(:&) # Repeat the previous s substitution. +# ^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ punctuation.separator.sequence.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(:t10) # Remove all leading pathname components +# ^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ punctuation.separator.sequence.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(:u) # Convert the words to all uppercase. +# ^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ punctuation.separator.sequence.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(:x) # Like q, but break into words at whitespace. +# ^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ punctuation.separator.sequence.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(:f) # Repeats the immediately (without a colon) following modifier +# ^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ punctuation.separator.sequence.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +# Like f, but repeats only n times if the expression expr evaluates to n +: /(:F"1+p") /(:F<1+p>) /(:F{1+p}) /(:F[1+p]) /(:F(1+p)) /(:F:1+p:) +# ^^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^^^^^ meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ punctuation.separator.sequence.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^ meta.arithmetic.shell +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^ - meta.string - meta.modifier +# ^^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^^^^^ meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ punctuation.separator.sequence.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^ meta.arithmetic.shell +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^ - meta.string - meta.modifier +# ^^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^^^^^ meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ punctuation.separator.sequence.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^ meta.arithmetic.shell +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^ - meta.string - meta.modifier +# ^^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^^^^^ meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ punctuation.separator.sequence.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^ meta.arithmetic.shell +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^ - meta.string - meta.modifier +# ^^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^^^^^ meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ punctuation.separator.sequence.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^ meta.arithmetic.shell +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^ - meta.string - meta.modifier +# ^^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^^^^^ meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ punctuation.separator.sequence.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^ meta.arithmetic.shell +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^ - meta.string - meta.modifier + +: /(:w) # Makes the immediately following modifier work on each word in the string. +# ^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ punctuation.separator.sequence.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +# Like w but words are considered to be the parts of the string that are separated by sep. +: /(:W"sep") /(:W) /(:W{sep}) /(:W[sep]) /(:W(sep)) /(:W:sep:) +# ^^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^^^^^ meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ punctuation.separator.sequence.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^ - meta.string - meta.modifier +# ^^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^^^^^ meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ punctuation.separator.sequence.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^ - meta.string - meta.modifier +# ^^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^^^^^ meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ punctuation.separator.sequence.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^ - meta.string - meta.modifier +# ^^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^^^^^ meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ punctuation.separator.sequence.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^ - meta.string - meta.modifier +# ^^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^^^^^ meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ punctuation.separator.sequence.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^ - meta.string - meta.modifier +# ^^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^^^^^ meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ punctuation.separator.sequence.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^ - meta.string - meta.modifier + + ############################################################################### # 14.7 Filename Expansion # https://zsh.sourceforge.io/Doc/Release/Expansion.html#Filename-Expansion @@ -3106,59 +3421,58 @@ dyn_dir_name() { # https://zsh.sourceforge.io/Doc/Release/Expansion.html#ksh_002dlike-Glob-Operators ############################################################################### -: @(...) is (...) # Match the pattern in the parentheses. (Like ‘(...)’.) -# ^ keyword.operator.quantifier.regexp.shell -# ^^^^^ meta.group.regexp.shell -# ^ punctuation.definition.group.begin.regexp.shell -# ^ punctuation.definition.group.end.regexp.shell -# ^^^^^ meta.group.regexp.shell -# ^ punctuation.definition.group.begin.regexp.shell -# ^ punctuation.definition.group.end.regexp.shell - -# note: scope * as glob instead of operator as it is more likely in ZSH -: *(...) is (...)# # Match any number of occurrences. (Like ‘(...)#’, except that recursive directory searching is not supported.) -# ^ constant.other.wildcard.asterisk.shell -# ^^^^^ meta.group.regexp.shell -# ^ punctuation.definition.group.begin.regexp.shell -# ^ punctuation.definition.group.end.regexp.shell -# ^^^^^ meta.group.regexp.shell -# ^ punctuation.definition.group.begin.regexp.shell -# ^ punctuation.definition.group.end.regexp.shell -# ^ keyword.operator.quantifier.regexp.shell - -: +(...) is (...)## # Match at least one occurrence. (Like ‘(...)##’, except that recursive directory searching is not supported.) -# ^ keyword.operator.quantifier.regexp.shell -# ^^^^^ meta.group.regexp.shell -# ^ punctuation.definition.group.begin.regexp.shell -# ^ punctuation.definition.group.end.regexp.shell -# ^^^^^ meta.group.regexp.shell -# ^ punctuation.definition.group.begin.regexp.shell -# ^ punctuation.definition.group.end.regexp.shell -# ^^ keyword.operator.quantifier.regexp.shell - -# note: scope ? as glob instead of operator as it is more likely in ZSH -: ?(...) is (|...) # Match zero or one occurrence. (Like ‘(|...)’.) -# ^ constant.other.wildcard.questionmark.shell -# ^^^^^ meta.group.regexp.shell -# ^ punctuation.definition.group.begin.regexp.shell -# ^ punctuation.definition.group.end.regexp.shell -# ^^^^^^ meta.group.regexp.shell -# ^ punctuation.definition.group.begin.regexp.shell -# ^ keyword.operator.logical.regexp.shell -# ^ punctuation.definition.group.end.regexp.shell - -: !(...) is (^(...)) # Match anything but the expression in parentheses. (Like ‘(^(...))’.) -# ^ keyword.operator.quantifier.regexp.shell -# ^^^^^ meta.group.regexp.shell -# ^ punctuation.definition.group.begin.regexp.shell -# ^ punctuation.definition.group.end.regexp.shell -# ^^ meta.group.regexp.shell - meta.group.regexp meta.group.regexp -# ^ punctuation.definition.group.begin.regexp.shell -# ^ keyword.operator.logical.regexp.shell -# ^^^^^ meta.group.regexp.shell meta.group.regexp.shell -# ^ punctuation.definition.group.begin.regexp.shell -# ^^ punctuation.definition.group.end.regexp.shell -# ^ meta.group.regexp.shell - meta.group.regexp meta.group.regexp +# : @(...) is (...) # Match the pattern in the parentheses. (Like ‘(...)’.) +# # ^^^^^ meta.group.regexp.shell +# # ^ punctuation.definition.group.begin.regexp.shell +# # ^ punctuation.definition.group.end.regexp.shell +# # ^^^^^ meta.group.regexp.shell +# # ^ punctuation.definition.group.begin.regexp.shell +# # ^ punctuation.definition.group.end.regexp.shell + +# # note: scope * as glob instead of operator as it is more likely in ZSH +# : *(...) is (...)# # Match any number of occurrences. (Like ‘(...)#’, except that recursive directory searching is not supported.) +# # ^ constant.other.wildcard.asterisk.shell +# # ^^^^^ meta.group.regexp.shell +# # ^ punctuation.definition.group.begin.regexp.shell +# # ^ punctuation.definition.group.end.regexp.shell +# # ^^^^^ meta.group.regexp.shell +# # ^ punctuation.definition.group.begin.regexp.shell +# # ^ punctuation.definition.group.end.regexp.shell +# # ^ keyword.operator.quantifier.regexp.shell + +# : +(...) is (...)## # Match at least one occurrence. (Like ‘(...)##’, except that recursive directory searching is not supported.) +# # ^ keyword.operator.quantifier.regexp.shell +# # ^^^^^ meta.group.regexp.shell +# # ^ punctuation.definition.group.begin.regexp.shell +# # ^ punctuation.definition.group.end.regexp.shell +# # ^^^^^ meta.group.regexp.shell +# # ^ punctuation.definition.group.begin.regexp.shell +# # ^ punctuation.definition.group.end.regexp.shell +# # ^^ keyword.operator.quantifier.regexp.shell + +# # note: scope ? as glob instead of operator as it is more likely in ZSH +# : ?(...) is (|...) # Match zero or one occurrence. (Like ‘(|...)’.) +# # ^ constant.other.wildcard.questionmark.shell +# # ^^^^^ meta.group.regexp.shell +# # ^ punctuation.definition.group.begin.regexp.shell +# # ^ punctuation.definition.group.end.regexp.shell +# # ^^^^^^ meta.group.regexp.shell +# # ^ punctuation.definition.group.begin.regexp.shell +# # ^ keyword.operator.logical.regexp.shell +# # ^ punctuation.definition.group.end.regexp.shell + +# : !(...) is (^(...)) # Match anything but the expression in parentheses. (Like ‘(^(...))’.) +# # ^ keyword.operator.quantifier.regexp.shell +# # ^^^^^ meta.group.regexp.shell +# # ^ punctuation.definition.group.begin.regexp.shell +# # ^ punctuation.definition.group.end.regexp.shell +# # ^^ meta.group.regexp.shell - meta.group.regexp meta.group.regexp +# # ^ punctuation.definition.group.begin.regexp.shell +# # ^ keyword.operator.logical.regexp.shell +# # ^^^^^ meta.group.regexp.shell meta.group.regexp.shell +# # ^ punctuation.definition.group.begin.regexp.shell +# # ^^ punctuation.definition.group.end.regexp.shell +# # ^ meta.group.regexp.shell - meta.group.regexp meta.group.regexp ############################################################################### @@ -3273,7 +3587,6 @@ dyn_dir_name() { # ^^^^^^^^ meta.modifier.glob.shell.zsh # ^^ punctuation.definition.modifier.begin.shell.zsh # ^ storage.modifier.mode.glob.shell.zsh -# ^^^^ - storage.modifier.mode.glob # ^ punctuation.definition.modifier.end.shell.zsh : (#u) # Respect the current locale in determining the presence of multibyte characters in a pattern @@ -3315,7 +3628,7 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}} # ^ keyword.operator.substitution.shell # ^ punctuation.definition.variable.shell # ^ punctuation.section.interpolation.begin.shell -# ^^^ meta.interpolation.parameter.shell meta.modifier.parameter.shell.zsh +# ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh # ^^^^^ variable.language.builtin.shell # ^^ punctuation.section.interpolation.end.shell @@ -3337,31 +3650,882 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}} # https://zsh.sourceforge.io/Doc/Release/Expansion.html#Glob-Qualifiers ############################################################################### -# lists all directories and symbolic links that point to directories, and +: /(/) # directories +# ^^^ meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +: /(F) # ‘full’ (i.e. non-empty) directories. Note that the opposite sense (^F) expands to empty directories and all non-directories. Use (/^F) for empty directories. +# ^^^ meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +: /(.) # plain files +# ^^^ meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +: /(@) # symbolic links +# ^^^ meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +: /(=) # sockets +# ^^^ meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +: /(p) # named pipes (FIFOs) +# ^^^ meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +: /(*) # executable plain files (0100 or 0010 or 0001) +# ^^^ meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +: /(%) # device files (character or block special) +# ^^^ meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +: /(%b) # block special files +# ^^^^ meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +: /(%c) # character special files +# ^^^ meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +: /(r) # owner-readable files (0400) +# ^^^ meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +: /(w) # owner-writable files (0200) +# ^^^ meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +: /(x) # owner-executable files (0100) +# ^^^ meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +: /(A) # group-readable files (0040) +# ^^^ meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +: /(I) # group-writable files (0020) +# ^^^ meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +: /(E) # group-executable files (0010) +# ^^^ meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +: /(R) # world-readable files (0004) +# ^^^ meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +: /(W) # world-writable files (0002) +# ^^^ meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +: /(X) # world-executable files (0001) +# ^^^ meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +: /(s) # setuid files (04000) +# ^^^ meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +: /(S) # setgid files (02000) +# ^^^ meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +: /(t) # files with the sticky bit (01000) +# ^^^ meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(f70?) (f=7?0) (f+?70) (f-703) # octal acces right specification +# ^ storage.modifier.glob.shell.zsh +# ^^^ meta.number.integer.octal.shell constant.numeric.value.shell +# ^ storage.modifier.glob.shell.zsh +# ^ keyword.operator.logical.shell.zsh +# ^^^ meta.number.integer.octal.shell constant.numeric.value.shell +# ^ storage.modifier.glob.shell.zsh +# ^ keyword.operator.logical.shell.zsh +# ^^^ meta.number.integer.octal.shell constant.numeric.value.shell +# ^ storage.modifier.glob.shell.zsh +# ^ keyword.operator.logical.shell.zsh +# ^^^ meta.number.integer.octal.shell constant.numeric.value.shell + +: /(f$mode) (f=$mode) (f+$mode) (f-$mode) # octal acces right specification +# ^ storage.modifier.glob.shell.zsh +# ^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^ storage.modifier.glob.shell.zsh +# ^ keyword.operator.logical.shell.zsh +# ^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^ storage.modifier.glob.shell.zsh +# ^ keyword.operator.logical.shell.zsh +# ^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^ storage.modifier.glob.shell.zsh +# ^ keyword.operator.logical.shell.zsh +# ^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell + +: /(f) /(f{gu+w,0-rx}) /(f[gu+w,0-rx]) /(f(gu+w,0-rx)) /(f:gu+w,0-rx:) +# ^^ meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^^^^^^^^^^^ meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^^^^^^^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ meta.modifier.glob.shell.zsh punctuation.definition.modifier.end.shell.zsh +# ^^ meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^^^^^^^^^^^ meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^^^^^^^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ meta.modifier.glob.shell.zsh punctuation.definition.modifier.end.shell.zsh +# ^^ meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^^^^^^^^^^^ meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^^^^^^^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ meta.modifier.glob.shell.zsh punctuation.definition.modifier.end.shell.zsh +# ^^ meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^^^^^^^^^^^ meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^^^^^^^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ meta.modifier.glob.shell.zsh punctuation.definition.modifier.end.shell.zsh +# ^^ meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^^^^^^^^^^^ meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^^^^^^^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ meta.modifier.glob.shell.zsh punctuation.definition.modifier.end.shell.zsh + +: /(e) /(e<"foo -a | bar $v">) /(e<'foo -a | bar $v'>) +# ^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell +# ^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^^^ - meta.modifier meta.function-call +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell +# ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^^ punctuation.definition.quoted.begin.shell +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^^^ - meta.modifier meta.function-call +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^^ punctuation.definition.quoted.end.shell +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell +# ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^^ punctuation.definition.quoted.begin.shell +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^^^ - meta.modifier meta.function-call +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^^ punctuation.definition.quoted.end.shell +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(e{foo -a | bar $v}) /(e{"foo -a | bar $v"}) /(e{'foo -a | bar $v'}) +# ^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell +# ^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^^^ - meta.modifier meta.function-call +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell +# ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^^ punctuation.definition.quoted.begin.shell +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^^^ - meta.modifier meta.function-call +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^^ punctuation.definition.quoted.end.shell +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell +# ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^^ punctuation.definition.quoted.begin.shell +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^^^ - meta.modifier meta.function-call +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^^ punctuation.definition.quoted.end.shell +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(e[foo -a | bar $v]) /(e["foo -a | bar $v"]) /(e['foo -a | bar $v']) +# ^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell +# ^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^^^ - meta.modifier meta.function-call +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell +# ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^^ punctuation.definition.quoted.begin.shell +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^^^ - meta.modifier meta.function-call +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^^ punctuation.definition.quoted.end.shell +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell +# ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^^ punctuation.definition.quoted.begin.shell +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^^^ - meta.modifier meta.function-call +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^^ punctuation.definition.quoted.end.shell +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(e(foo -a | bar $v)) /(e("foo -a | bar $v")) /(e('foo -a | bar $v')) +# ^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell +# ^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^^^ - meta.modifier meta.function-call +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell +# ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^^ punctuation.definition.quoted.begin.shell +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^^^ - meta.modifier meta.function-call +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^^ punctuation.definition.quoted.end.shell +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell +# ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^^ punctuation.definition.quoted.begin.shell +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^^^ - meta.modifier meta.function-call +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^^ punctuation.definition.quoted.end.shell +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(e:foo -a | bar $v:) /(e:"foo -a | bar $v":) /(e:'foo -a | bar $v':) +# ^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell +# ^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^^^ - meta.modifier meta.function-call +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell +# ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^^ punctuation.definition.quoted.begin.shell +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^^^ - meta.modifier meta.function-call +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^^ punctuation.definition.quoted.end.shell +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell +# ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^^ punctuation.definition.quoted.begin.shell +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^^^ - meta.modifier meta.function-call +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^^ punctuation.definition.quoted.end.shell +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(e'foo -a | bar $v') /(e'"foo -a | bar $v"') /(e"'foo -a | bar $v'") +# ^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell +# ^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^^^ - meta.modifier meta.function-call +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell +# ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^^ punctuation.definition.quoted.begin.shell +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^^^ - meta.modifier meta.function-call +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^^ punctuation.definition.quoted.end.shell +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell +# ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation +# ^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^^ punctuation.definition.quoted.begin.shell +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^^^ - meta.modifier meta.function-call +# ^^^ meta.function-call.identifier.shell meta.command.shell +# ^^^ meta.function-call.arguments.shell +# ^^ punctuation.definition.quoted.end.shell +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(G120) /(G) /(G{gid}) /(G[gid]) /(G(gid)) /(G:gid:) +# ^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^^^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.definition.modifier.end.shell.zsh +# ^ - meta.string - meta.modifier +# ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^ - meta.string - meta.modifier +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^ - meta.string - meta.modifier +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^ - meta.string - meta.modifier +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^ - meta.string - meta.modifier +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^ - meta.string - meta.modifier +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(U123) /(U) /(U{uid}) /(U[uid]) /(U(uid)) /(U:uid:) +# ^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^^^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.definition.modifier.end.shell.zsh +# ^ - meta.string - meta.modifier +# ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^ - meta.string - meta.modifier +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^ - meta.string - meta.modifier +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^ - meta.string - meta.modifier +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^ - meta.string - meta.modifier +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted +# ^ - meta.string - meta.modifier +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^^^ string.quoted.other.shell.zsh +# ^ punctuation.definition.quoted.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(aM-5) /(mm+5) /(cs100) # access time, modification time, creation time +# ^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^^ storage.modifier.glob.shell.zsh +# ^ meta.number.integer.decimal.shell keyword.operator.arithmetic.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^^ storage.modifier.glob.shell.zsh +# ^ meta.number.integer.decimal.shell keyword.operator.arithmetic.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^^ storage.modifier.glob.shell.zsh +# ^^^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(Lk-5) /(LM+5) /(LG100) # file size +# ^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^^ storage.modifier.glob.shell.zsh +# ^ meta.number.integer.decimal.shell keyword.operator.arithmetic.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^^ storage.modifier.glob.shell.zsh +# ^ meta.number.integer.decimal.shell keyword.operator.arithmetic.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^^ storage.modifier.glob.shell.zsh +# ^^^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(^) # negates all qualifiers following it +# ^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ keyword.operator.logical.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(-) # toggles between making the qualifiers work on symbolic links (the default) and the files they point to +# ^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ keyword.operator.logical.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(M) # sets the MARK_DIRS option for the current pattern +# ^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(T) # appends a trailing qualifier mark to the filenames +# ^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(N) # sets the NULL_GLOB option for the current pattern +# ^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(D) # sets the GLOB_DOTS option for the current pattern +# ^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(n) # sets the NUMERIC_GLOB_SORT option for the current pattern +# ^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(Y10) # enables short-circuit mode: the pattern will expand to at most n filenames. +# ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ storage.modifier.glob.shell.zsh +# ^^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(on) /(oL) /(ol) /(oa) /(om) /(oc) /(od) /(oN) /(oe{'cmd arg'}) # specifies how the names of the files should be sorted +# ^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^ punctuation.definition.quoted.begin.shell +# ^^^ variable.function.shell +# ^^^ string.unquoted.shell +# ^^ punctuation.definition.quoted.end.shell +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(On) /(OL) /(Ol) /(Oa) /(Om) /(Oc) /(Od) /(ON) /(Oe{'cmd arg'}) # like 'o', but sorts in descending order +# ^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^^^ meta.string.shell meta.modifier.glob.shell.zsh +# ^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^^ storage.modifier.glob.shell.zsh +# ^ punctuation.definition.quoted.begin.shell.zsh +# ^ punctuation.definition.quoted.begin.shell +# ^^^ variable.function.shell +# ^^^ string.unquoted.shell +# ^^ punctuation.definition.quoted.end.shell +# ^ punctuation.definition.modifier.end.shell.zsh + +: /([10]) /([1,20]) # specifies which of the matched filenames should be included in the returned list. +# ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.range +# ^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.range.glob.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.range +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ punctuation.definition.range.begin.shell.zsh +# ^^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.definition.range.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.range +# ^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.range.glob.shell.zsh +# ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.range +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ punctuation.definition.range.begin.shell.zsh +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.separator.sequence.shell +# ^^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.definition.range.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + +: /(P"pre") /(P
) /(P{pre}) /(P[pre]) /(P(pre)) /(P:pre:)
+#  ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#    ^^^^^ meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
+#         ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#  ^ punctuation.definition.modifier.begin.shell.zsh
+#   ^ storage.modifier.glob.shell.zsh
+#    ^ punctuation.definition.quoted.begin.shell.zsh
+#     ^^^ string.quoted.other.shell.zsh
+#        ^ punctuation.definition.quoted.end.shell.zsh
+#         ^ punctuation.definition.modifier.end.shell.zsh
+#          ^ - meta.string - meta.modifier
+#            ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#              ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
+#                   ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                    ^ - meta.string - meta.modifier
+#            ^ punctuation.definition.modifier.begin.shell.zsh
+#             ^ storage.modifier.glob.shell.zsh
+#              ^ punctuation.definition.quoted.begin.shell.zsh
+#               ^^^ string.quoted.other.shell.zsh
+#                  ^ punctuation.definition.quoted.end.shell.zsh
+#                   ^ punctuation.definition.modifier.end.shell.zsh
+#                      ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                        ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
+#                             ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                              ^ - meta.string - meta.modifier
+#                      ^ punctuation.definition.modifier.begin.shell.zsh
+#                       ^ storage.modifier.glob.shell.zsh
+#                        ^ punctuation.definition.quoted.begin.shell.zsh
+#                         ^^^ string.quoted.other.shell.zsh
+#                            ^ punctuation.definition.quoted.end.shell.zsh
+#                             ^ punctuation.definition.modifier.end.shell.zsh
+#                                ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                  ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
+#                                       ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                        ^ - meta.string - meta.modifier
+#                                ^ punctuation.definition.modifier.begin.shell.zsh
+#                                 ^ storage.modifier.glob.shell.zsh
+#                                  ^ punctuation.definition.quoted.begin.shell.zsh
+#                                   ^^^ string.quoted.other.shell.zsh
+#                                      ^ punctuation.definition.quoted.end.shell.zsh
+#                                       ^ punctuation.definition.modifier.end.shell.zsh
+#                                          ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                            ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
+#                                                 ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                                  ^ - meta.string - meta.modifier
+#                                          ^ punctuation.definition.modifier.begin.shell.zsh
+#                                           ^ storage.modifier.glob.shell.zsh
+#                                            ^ punctuation.definition.quoted.begin.shell.zsh
+#                                             ^^^ string.quoted.other.shell.zsh
+#                                                ^ punctuation.definition.quoted.end.shell.zsh
+#                                                 ^ punctuation.definition.modifier.end.shell.zsh
+#                                                    ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                                      ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
+#                                                           ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                                            ^ - meta.string - meta.modifier
+#                                                    ^ punctuation.definition.modifier.begin.shell.zsh
+#                                                     ^ storage.modifier.glob.shell.zsh
+#                                                      ^ punctuation.definition.quoted.begin.shell.zsh
+#                                                       ^^^ string.quoted.other.shell.zsh
+#                                                          ^ punctuation.definition.quoted.end.shell.zsh
+#                                                           ^ punctuation.definition.modifier.end.shell.zsh
+
+ls /(D)/  # qualifiers are always located at the end
+#  ^^^^^ meta.string.shell string.unquoted.shell
+#   ^^^ meta.group.regexp.shell - meta.modifier
+
+#  lists all directories and symbolic links that point to directories, and
 ls -ld -- *(-/)
 #         ^ meta.string.shell string.unquoted.shell constant.other.wildcard.asterisk.shell
-#          ^^^^ meta.string.shell meta.group.regexp.shell string.unquoted.shell
+#          ^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#          ^ punctuation.definition.modifier.begin.shell.zsh
+#           ^ keyword.operator.logical.shell.zsh
+#            ^ storage.modifier.glob.shell.zsh
+#             ^ punctuation.definition.modifier.end.shell.zsh
 
 # lists all broken symbolic links, and
 ls -ld -- *(-@)
 #         ^ meta.string.shell string.unquoted.shell constant.other.wildcard.asterisk.shell
-#          ^^^^ meta.string.shell meta.group.regexp.shell string.unquoted.shell
+#          ^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#          ^ punctuation.definition.modifier.begin.shell.zsh
+#           ^ keyword.operator.logical.shell.zsh
+#            ^ storage.modifier.glob.shell.zsh
+#             ^ punctuation.definition.modifier.end.shell.zsh
 
 # lists all world-writable device files in the current directory, and
 ls -ld -- *(%W)
 #         ^ meta.string.shell string.unquoted.shell constant.other.wildcard.asterisk.shell
-#          ^^^^ meta.string.shell meta.group.regexp.shell string.unquoted.shell
+#          ^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#          ^ punctuation.definition.modifier.begin.shell.zsh
+#           ^^ storage.modifier.glob.shell.zsh
+#             ^ punctuation.definition.modifier.end.shell.zsh
 
 # lists all files in the current directory that are world-writable or world-executable, and
 ls -ld -- *(W,X)
 #         ^ meta.string.shell string.unquoted.shell constant.other.wildcard.asterisk.shell
-#          ^^^^^ meta.string.shell meta.group.regexp.shell string.unquoted.shell
+#          ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#          ^ punctuation.definition.modifier.begin.shell.zsh
+#           ^ storage.modifier.glob.shell.zsh
+#            ^ punctuation.separator.sequence.shell
+#             ^ storage.modifier.glob.shell.zsh
+#              ^ punctuation.definition.modifier.end.shell.zsh
 
 # outputs the basename of all root-owned files beginning with the string ‘foo’
 # in /tmp, ignoring symlinks, and
 print -rC1 /tmp/foo*(u0^@:t)
 #          ^^^^^^^^^ meta.string.shell string.unquoted.shell
-#                   ^^^^^^^^ meta.string.shell meta.group.regexp.shell string.unquoted.shell
+#                   ^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh
 
 # lists all files having a link count of one whose names contain a dot (but
 # not those starting with a dot, since GLOB_DOTS is explicitly switched off)
@@ -3371,14 +4535,18 @@ ls -ld -- *.*~(lex|parse).[ch](^D^l1)
 #             ^^^^^^^^^^^ meta.string.shell meta.group.regexp.shell string.unquoted.shell
 #                        ^ meta.string.shell string.unquoted.shell
 #                         ^^^^ meta.string.shell string.unquoted.shell meta.set.regexp.shell
-#                             ^^^^^^^ meta.string.shell meta.group.regexp.shell string.unquoted.shell
+#                             ^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh
 
 # demonstrates how colon modifiers and other qualifiers may be chained together.
-# TODO: colon initiats history expansions' modifiers
-print -rC1 b*.pro(#q:s/pro/shmo/)(#q.:s/builtin/shmiltin/)
+print -rC1 b*.pro(#q:s/pro/shmo/)(#q.:s@builtin@"sh${mi}ltin"@)
 #          ^^^^^^ meta.string.shell string.unquoted.shell
-#                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh
-#                                                         ^ - meta.string - meta.modifier
+#                ^^^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.substituation
+#                    ^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.substituation.shell.zsh
+#                               ^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.substituation
+#                                     ^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.substituation.shell.zsh
+#                                                             ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.substituation
+#                                                              ^ - meta.string - meta.modifier
+
 
 ###[ COMMON EXPANSIONS ]#######################################################
 

From 8dbd66c1d662807fc22d559737c39e118e966e17 Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Fri, 9 Aug 2024 18:44:09 +0200
Subject: [PATCH 076/113] [ShellScript] Align pattern group scopes with RegExp
 syntax

---
 ShellScript/Bash.sublime-syntax               |  8 +--
 ShellScript/Bash/tests/syntax_test_scope.bash | 54 +++++++++---------
 ShellScript/Zsh.sublime-syntax                |  6 +-
 ShellScript/Zsh/tests/syntax_test_scope.zsh   | 56 +++++++++----------
 4 files changed, 62 insertions(+), 62 deletions(-)

diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax
index 8ba74a9641..eece2baa24 100644
--- a/ShellScript/Bash.sublime-syntax
+++ b/ShellScript/Bash.sublime-syntax
@@ -1173,7 +1173,7 @@ contexts:
     # [Bash] 3.2.4.2: Each pattern undergoes tilde expansion, parameter
     # expansion, command substitution, and arithmetic expansion.
     - match: \(  # Note: exists to support ZSH
-      scope: meta.group.regexp.shell string.unquoted.shell punctuation.definition.group.begin.regexp.shell
+      scope: meta.group.regexp.shell string.unquoted.shell punctuation.section.group.begin.regexp.shell
       push: case-clause-pattern-group-body
     - include: case-end-ahead
     - include: pattern-group-content
@@ -2277,7 +2277,7 @@ contexts:
     - match: ([?*+@!])(\()
       captures:
         1: string.unquoted.shell keyword.operator.quantifier.regexp.shell
-        2: meta.group.regexp.shell string.unquoted.shell punctuation.definition.group.begin.regexp.shell
+        2: meta.group.regexp.shell string.unquoted.shell punctuation.section.group.begin.regexp.shell
       push: pattern-group-body
 
   pattern-group-body:
@@ -2296,7 +2296,7 @@ contexts:
 
   pattern-group-end:
     - match: \)
-      scope: meta.group.regexp.shell string.unquoted.shell punctuation.definition.group.end.regexp.shell
+      scope: meta.group.regexp.shell string.unquoted.shell punctuation.section.group.end.regexp.shell
       pop: 1
     - include: line-continuations
 
@@ -2808,7 +2808,7 @@ contexts:
     - match: ([?*+@!])(\()
       captures:
         1: string.unquoted.shell keyword.operator.quantifier.regexp.shell
-        2: meta.group.regexp.shell string.unquoted.shell punctuation.definition.group.begin.regexp.shell
+        2: meta.group.regexp.shell string.unquoted.shell punctuation.section.group.begin.regexp.shell
       push: expansion-parameter-pattern-group-body
 
   expansion-parameter-pattern-group-body:
diff --git a/ShellScript/Bash/tests/syntax_test_scope.bash b/ShellScript/Bash/tests/syntax_test_scope.bash
index ef6ea292c9..df0271f959 100644
--- a/ShellScript/Bash/tests/syntax_test_scope.bash
+++ b/ShellScript/Bash/tests/syntax_test_scope.bash
@@ -2279,7 +2279,7 @@ case var in
 #        ^^ meta.clause.pattern.shell meta.string.regexp.shell meta.group.regexp.shell string.unquoted.shell
 #          ^^^^ meta.statement.conditional.case.end.shell
 # ^ punctuation.definition.pattern.begin.shell
-#        ^ punctuation.definition.group.begin.regexp.shell
+#        ^ punctuation.section.group.begin.regexp.shell
 #          ^^^^ keyword.control.conditional.endcase.shell
 #              ^ - meta.conditional
 
@@ -2450,10 +2450,10 @@ case $TERM in
         # ^ constant.other.wildcard.asterisk.shell
         #  ^ keyword.operator.logical.regexp.shell
         #       ^ keyword.operator.logical.regexp.shell
-        #        ^ punctuation.definition.group.begin.regexp.shell
+        #        ^ punctuation.section.group.begin.regexp.shell
         #           ^ keyword.operator.logical.regexp.shell
         #             ^ keyword.operator.logical.regexp.shell
-        #               ^ punctuation.definition.group.end.regexp.shell
+        #               ^ punctuation.section.group.end.regexp.shell
         #                    ^ punctuation.definition.pattern.end.shell
         update_terminal_cwd() { print -Pn "\e]2;%~\a" };;
         #                                             ^ meta.function punctuation.section.block.end.shell
@@ -2476,12 +2476,12 @@ ws-+([0-9]).host.com) echo "Web Server"
 #                   ^ meta.clause.pattern.shell - meta.string - meta.group - string
 #^^^^^^^^^^^^^^^^^^^ string.unquoted.shell
 #  ^ keyword.operator.quantifier.regexp.shell
-#   ^ punctuation.definition.group.begin.regexp.shell
+#   ^ punctuation.section.group.begin.regexp.shell
 #    ^ punctuation.definition.set.begin.regexp.shell
 #     ^^^ constant.other.range.regexp.shell
 #      ^ punctuation.separator.sequence.regexp.shell
 #        ^ punctuation.definition.set.end.regexp.shell
-#         ^ punctuation.definition.group.end.regexp.shell
+#         ^ punctuation.section.group.end.regexp.shell
 #                   ^ punctuation.definition.pattern.end.shell
 ;;
 # <- punctuation.terminator.clause.shell
@@ -2491,24 +2491,24 @@ db-+([0-9])\.host\.com) echo "DB server"
 #   ^^^^^^^ meta.clause.pattern.shell meta.string.regexp.shell meta.group.regexp.shell
 #          ^^^^^^^^^^^ meta.clause.pattern.shell meta.string.regexp.shell - meta.group
 #  ^ keyword.operator.quantifier.regexp.shell
-#   ^ punctuation.definition.group.begin.regexp.shell
+#   ^ punctuation.section.group.begin.regexp.shell
 #    ^ punctuation.definition.set.begin.regexp.shell
 #     ^^^ constant.other.range.regexp.shell
 #      ^ punctuation.separator.sequence.regexp.shell
 #        ^ punctuation.definition.set.end.regexp.shell
-#         ^ punctuation.definition.group.end.regexp.shell
+#         ^ punctuation.section.group.end.regexp.shell
 #                     ^ punctuation.definition.pattern.end.shell
 ;;
 # <- punctuation.terminator.clause.shell
 #^ punctuation.terminator.clause.shell
 bk-+([0-9])\.host\.com) echo "Backup server"
 #  ^ keyword.operator.quantifier.regexp.shell
-#   ^ punctuation.definition.group.begin.regexp.shell
+#   ^ punctuation.section.group.begin.regexp.shell
 #    ^ punctuation.definition.set.begin.regexp.shell
 #     ^^^ constant.other.range.regexp.shell
 #      ^ punctuation.separator.sequence.regexp.shell
 #        ^ punctuation.definition.set.end.regexp.shell
-#         ^ punctuation.definition.group.end.regexp.shell
+#         ^ punctuation.section.group.end.regexp.shell
 #                     ^ punctuation.definition.pattern.end.shell
 #                       ^^^^ support.function.shell
 ;;
@@ -6216,7 +6216,7 @@ a\/b/c/d}
 #   ^^^ variable.other.readwrite.shell
 #      ^^ keyword.operator.substitution.shell
 #        ^ keyword.operator.quantifier.regexp.shell
-#         ^ punctuation.definition.group.begin.regexp.shell
+#         ^ punctuation.section.group.begin.regexp.shell
 #          ^^^^^ - constant - punctuation
 #               ^^ constant.character.escape.shell
 #                 ^ punctuation.section.interpolation.end.shell
@@ -6231,10 +6231,10 @@ a\/b/c/d}
 #   ^^^ variable.other.readwrite.shell
 #      ^^ keyword.operator.substitution.shell
 #        ^ keyword.operator.quantifier.regexp.shell
-#         ^ punctuation.definition.group.begin.regexp.shell
+#         ^ punctuation.section.group.begin.regexp.shell
 #          ^^^^ - constant - punctuation
 #            ^ keyword.operator.logical.regexp.shell
-#              ^ punctuation.definition.group.end.regexp.shell
+#              ^ punctuation.section.group.end.regexp.shell
 #               ^ keyword.operator.substitution.shell
 #                ^^ constant.character.escape.shell
 #                  ^ punctuation.section.interpolation.end.shell
@@ -7804,12 +7804,12 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}}
 : @([^:]*)
 #^^^^^^^^^ meta.function-call.arguments.shell
 # ^ keyword.operator.quantifier.regexp.shell
-#  ^ punctuation.definition.group.begin.regexp.shell
+#  ^ punctuation.section.group.begin.regexp.shell
 #   ^ punctuation.definition.set.begin.regexp.shell
 #    ^ keyword.operator.logical.regexp.shell
 #      ^ punctuation.definition.set.end.regexp.shell
 #       ^ constant.other.wildcard.asterisk.shell
-#        ^ punctuation.definition.group.end.regexp.shell
+#        ^ punctuation.section.group.end.regexp.shell
 
 : @([[] []] [![] [!]] [^[] [^]])
 #   ^^^ meta.group.regexp.shell meta.set.regexp.shell
@@ -7942,7 +7942,7 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}}
 #                           ^^ meta.function-call.arguments.shell meta.string.shell meta.group.regexp.shell - meta.set
 #                             ^ - meta.function-call - meta.group
 # ^ keyword.operator.quantifier.regexp.shell
-#  ^ punctuation.definition.group.begin.regexp.shell
+#  ^ punctuation.section.group.begin.regexp.shell
 #    ^^ punctuation.definition.set.begin.regexp.shell
 #      ^ constant.other.posix-class.regexp.shell
 #       ^ punctuation.definition.variable.shell
@@ -7955,7 +7955,7 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}}
 #                        ^ constant.other.posix-class.regexp.shell
 #                         ^^ punctuation.definition.set.end.regexp.shell
 #                           ^ constant.other.wildcard.asterisk.shell
-#                            ^ punctuation.definition.group.end.regexp.shell
+#                            ^ punctuation.section.group.end.regexp.shell
 
 : ?([[:alpha:]]|[[:digit:]]|[[:unknwn:]])*
 #^^ meta.function-call.arguments.shell - meta.group
@@ -7963,7 +7963,7 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}}
 #                                        ^ meta.function-call.arguments.shell - meta.group
 #                                         ^ - meta.function-call - meta.group
 # ^ keyword.operator.quantifier.regexp.shell
-#  ^ punctuation.definition.group.begin.regexp.shell
+#  ^ punctuation.section.group.begin.regexp.shell
 #   ^^ punctuation.definition.set.begin.regexp.shell
 #     ^ constant.other.posix-class.regexp.shell punctuation.definition.class.begin.regexp.shell
 #      ^^^^^ constant.other.posix-class.regexp.shell - punctuation
@@ -7980,7 +7980,7 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}}
 #                            ^^^^^^^^^ - constant.other.posix-class
 #                                     ^ punctuation.definition.set.end.regexp.shell
 #                                      ^ - punctuation
-#                                       ^ punctuation.definition.group.end.regexp.shell
+#                                       ^ punctuation.section.group.end.regexp.shell
 #                                        ^ constant.other.wildcard.asterisk.shell
 
 : @(foo*)*
@@ -7989,9 +7989,9 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}}
 #        ^ meta.function-call.arguments.shell - meta.group
 #         ^ - meta.function-call - meta.group
 # ^ keyword.operator.quantifier.regexp.shell
-#  ^ punctuation.definition.group.begin.regexp.shell
+#  ^ punctuation.section.group.begin.regexp.shell
 #      ^ constant.other.wildcard.asterisk.shell
-#       ^ punctuation.definition.group.end.regexp.shell
+#       ^ punctuation.section.group.end.regexp.shell
 #        ^ constant.other.wildcard.asterisk.shell
 
 : +(bar|qux) | wc
@@ -7999,9 +7999,9 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}}
 #  ^^^^^^^^^ meta.function-call.arguments.shell meta.group.regexp.shell
 #           ^ - meta.function-call - meta.group
 # ^ keyword.operator.quantifier.regexp.shell
-#  ^ punctuation.definition.group.begin.regexp.shell
+#  ^ punctuation.section.group.begin.regexp.shell
 #      ^ keyword.operator.logical.regexp.shell
-#          ^ punctuation.definition.group.end.regexp.shell
+#          ^ punctuation.section.group.end.regexp.shell
 #            ^ keyword.operator.assignment.pipe.shell
 
 
@@ -8056,7 +8056,7 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}}
 #                 ^^ meta.string.regexp.shell meta.group.regexp.shell - meta.set
 #                   ^ - meta.string.regexp
 #         ^ keyword.operator.quantifier.regexp.shell
-#          ^ punctuation.definition.group.begin.regexp.shell
+#          ^ punctuation.section.group.begin.regexp.shell
 #           ^ constant.other.wildcard.questionmark.shell
 #            ^ punctuation.definition.set.begin.regexp.shell
 #             ^^^ constant.other.range.regexp.shell
@@ -8090,7 +8090,7 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}}
 #          ^ meta.string.regexp.shell
 #           ^^^^^^^^^^^^^^^^^^^^^^^ meta.string.regexp.shell meta.group.regexp.shell
 #          ^ keyword.operator.quantifier.regexp.shell
-#           ^ punctuation.definition.group.begin.regexp.shell
+#           ^ punctuation.section.group.begin.regexp.shell
 #               ^ keyword.operator.logical.regexp.shell
 #                   ^ keyword.operator.logical.regexp.shell
 #                    ^^^ constant.other.wildcard.questionmark.shell
@@ -8102,7 +8102,7 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}}
 #                             ^ keyword.operator.logical.regexp.shell
 #                              ^ punctuation.definition.string.begin.shell
 #                                ^ punctuation.definition.string.end.shell
-#                                 ^ punctuation.definition.group.end.regexp.shell
+#                                 ^ punctuation.section.group.end.regexp.shell
 #                                   ^^ punctuation.section.compound.end.shell
 
 [[ ( $foo == *
@@ -8138,7 +8138,7 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}}
 #          ^ meta.compound.conditional.shell meta.string.regexp.shell - meta.group
 #           ^^^^^ meta.compound.conditional.shell meta.string.regexp.shell meta.group.regexp.shell
 #          ^ keyword.operator.quantifier.regexp.shell
-#           ^ punctuation.definition.group.begin.regexp.shell
+#           ^ punctuation.section.group.begin.regexp.shell
 #             ^^ - punctuation
    [!0-9]+ ) ]]
 # <- meta.compound.conditional.shell meta.string.regexp.shell meta.group.regexp.shell
@@ -8151,7 +8151,7 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}}
 #    ^^^ constant.other.range.regexp.shell
 #       ^ punctuation.definition.set.end.regexp.shell
 #        ^ - constant - keyword
-#          ^ punctuation.definition.group.end.regexp.shell
+#          ^ punctuation.section.group.end.regexp.shell
 #            ^^ punctuation.section.compound.end.shell
 
 
diff --git a/ShellScript/Zsh.sublime-syntax b/ShellScript/Zsh.sublime-syntax
index ef63f047d2..8ce74a5780 100644
--- a/ShellScript/Zsh.sublime-syntax
+++ b/ShellScript/Zsh.sublime-syntax
@@ -315,7 +315,7 @@ contexts:
 
   pattern-group:
     - match: \(
-      scope: punctuation.definition.group.begin.regexp.shell
+      scope: punctuation.section.group.begin.regexp.shell
       set: pattern-group-body
 
   pattern-group-body:
@@ -333,7 +333,7 @@ contexts:
 
   pattern-group-end:
     - match: \)
-      scope: punctuation.definition.group.end.regexp.shell
+      scope: punctuation.section.group.end.regexp.shell
       pop: 1
     - include: line-continuations
 
@@ -438,7 +438,7 @@ contexts:
     - match: ([+@!]??)(\()
       captures:
         1: string.unquoted.shell keyword.operator.quantifier.regexp.shell
-        2: meta.group.regexp.shell string.unquoted.shell punctuation.definition.group.begin.regexp.shell
+        2: meta.group.regexp.shell string.unquoted.shell punctuation.section.group.begin.regexp.shell
       push: expansion-parameter-pattern-group-body
 
   expansion-parameter-pattern-group-body:
diff --git a/ShellScript/Zsh/tests/syntax_test_scope.zsh b/ShellScript/Zsh/tests/syntax_test_scope.zsh
index 01cc290ff9..a1308e561f 100644
--- a/ShellScript/Zsh/tests/syntax_test_scope.zsh
+++ b/ShellScript/Zsh/tests/syntax_test_scope.zsh
@@ -2663,8 +2663,8 @@ any --arg{1,2,3} ={1,2,3}
 
 : /(:v) # not a valid modifier, fallback to normal regexp group
 #  ^^^^ meta.string.shell meta.group.regexp.shell string.unquoted.shell
-#  ^ punctuation.definition.group.begin.regexp.shell
-#     ^ punctuation.definition.group.end.regexp.shell
+#  ^ punctuation.section.group.begin.regexp.shell
+#     ^ punctuation.section.group.end.regexp.shell
 
 : /(:a) # Turn a file name into an absolute path
 #  ^^^^ meta.string.shell meta.modifier.glob.shell.zsh
@@ -3315,16 +3315,16 @@ dyn_dir_name() {
 # ^^^^ meta.string.shell string.unquoted.shell
 #     ^^^^^ meta.string.shell meta.group.regexp.shell string.unquoted.shell
 #          ^^^^ meta.string.shell string.unquoted.shell
-#     ^ punctuation.definition.group.begin.regexp.shell
+#     ^ punctuation.section.group.begin.regexp.shell
 #       ^ constant.other.wildcard.asterisk.shell
-#         ^ punctuation.definition.group.end.regexp.shell
+#         ^ punctuation.section.group.end.regexp.shell
 #          ^  keyword.operator.quantifier.regexp.shell.zsh
 
 : (foo|bar)|baz
 # ^^^^^^^^^ meta.group.regexp.shell string.unquoted.shell
-# ^ punctuation.definition.group.begin.regexp.shell
+# ^ punctuation.section.group.begin.regexp.shell
 #     ^ keyword.operator.logical.regexp.shell
-#         ^ punctuation.definition.group.end.regexp.shell
+#         ^ punctuation.section.group.end.regexp.shell
 #          ^ keyword.operator.assignment.pipe.shell
 #           ^^^ variable.function.shell
 
@@ -3423,55 +3423,55 @@ dyn_dir_name() {
 
 # : @(...) is (...)    # Match the pattern in the parentheses. (Like ‘(...)’.)
 # #  ^^^^^ meta.group.regexp.shell
-# #  ^ punctuation.definition.group.begin.regexp.shell
-# #      ^ punctuation.definition.group.end.regexp.shell
+# #  ^ punctuation.section.group.begin.regexp.shell
+# #      ^ punctuation.section.group.end.regexp.shell
 # #           ^^^^^ meta.group.regexp.shell
-# #           ^ punctuation.definition.group.begin.regexp.shell
-# #               ^ punctuation.definition.group.end.regexp.shell
+# #           ^ punctuation.section.group.begin.regexp.shell
+# #               ^ punctuation.section.group.end.regexp.shell
 
 # # note: scope * as glob instead of operator as it is more likely in ZSH
 # : *(...) is (...)#   # Match any number of occurrences. (Like ‘(...)#’, except that recursive directory searching is not supported.)
 # # ^ constant.other.wildcard.asterisk.shell
 # #  ^^^^^ meta.group.regexp.shell
-# #  ^ punctuation.definition.group.begin.regexp.shell
-# #      ^ punctuation.definition.group.end.regexp.shell
+# #  ^ punctuation.section.group.begin.regexp.shell
+# #      ^ punctuation.section.group.end.regexp.shell
 # #           ^^^^^ meta.group.regexp.shell
-# #           ^ punctuation.definition.group.begin.regexp.shell
-# #               ^ punctuation.definition.group.end.regexp.shell
+# #           ^ punctuation.section.group.begin.regexp.shell
+# #               ^ punctuation.section.group.end.regexp.shell
 # #                ^ keyword.operator.quantifier.regexp.shell
 
 # : +(...) is (...)##  # Match at least one occurrence. (Like ‘(...)##’, except that recursive directory searching is not supported.)
 # # ^ keyword.operator.quantifier.regexp.shell
 # #  ^^^^^ meta.group.regexp.shell
-# #  ^ punctuation.definition.group.begin.regexp.shell
-# #      ^ punctuation.definition.group.end.regexp.shell
+# #  ^ punctuation.section.group.begin.regexp.shell
+# #      ^ punctuation.section.group.end.regexp.shell
 # #           ^^^^^ meta.group.regexp.shell
-# #           ^ punctuation.definition.group.begin.regexp.shell
-# #               ^ punctuation.definition.group.end.regexp.shell
+# #           ^ punctuation.section.group.begin.regexp.shell
+# #               ^ punctuation.section.group.end.regexp.shell
 # #                ^^ keyword.operator.quantifier.regexp.shell
 
 # # note: scope ? as glob instead of operator as it is more likely in ZSH
 # : ?(...) is (|...)   # Match zero or one occurrence. (Like ‘(|...)’.)
 # # ^ constant.other.wildcard.questionmark.shell
 # #  ^^^^^ meta.group.regexp.shell
-# #  ^ punctuation.definition.group.begin.regexp.shell
-# #      ^ punctuation.definition.group.end.regexp.shell
+# #  ^ punctuation.section.group.begin.regexp.shell
+# #      ^ punctuation.section.group.end.regexp.shell
 # #           ^^^^^^ meta.group.regexp.shell
-# #           ^ punctuation.definition.group.begin.regexp.shell
+# #           ^ punctuation.section.group.begin.regexp.shell
 # #            ^ keyword.operator.logical.regexp.shell
-# #                ^ punctuation.definition.group.end.regexp.shell
+# #                ^ punctuation.section.group.end.regexp.shell
 
 # : !(...) is (^(...)) # Match anything but the expression in parentheses. (Like ‘(^(...))’.)
 # # ^ keyword.operator.quantifier.regexp.shell
 # #  ^^^^^ meta.group.regexp.shell
-# #  ^ punctuation.definition.group.begin.regexp.shell
-# #      ^ punctuation.definition.group.end.regexp.shell
+# #  ^ punctuation.section.group.begin.regexp.shell
+# #      ^ punctuation.section.group.end.regexp.shell
 # #           ^^ meta.group.regexp.shell - meta.group.regexp meta.group.regexp
-# #           ^ punctuation.definition.group.begin.regexp.shell
+# #           ^ punctuation.section.group.begin.regexp.shell
 # #            ^ keyword.operator.logical.regexp.shell
 # #             ^^^^^ meta.group.regexp.shell meta.group.regexp.shell
-# #             ^ punctuation.definition.group.begin.regexp.shell
-# #                 ^^ punctuation.definition.group.end.regexp.shell
+# #             ^ punctuation.section.group.begin.regexp.shell
+# #                 ^^ punctuation.section.group.end.regexp.shell
 # #                  ^ meta.group.regexp.shell - meta.group.regexp meta.group.regexp
 
 
@@ -3609,7 +3609,7 @@ dyn_dir_name() {
 
 : ((#i)foo)bar
 # ^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell
-# ^ meta.group.regexp.shell punctuation.definition.group.begin.regexp.shell
+# ^ meta.group.regexp.shell punctuation.section.group.begin.regexp.shell
 #  ^^^^ meta.group.regexp.shell meta.modifier.glob.shell.zsh - string
 #      ^^^^ meta.group.regexp.shell string.unquoted.shell
 #          ^^^ string.unquoted.shell

From d6ae991c874be642f79c6565f6c7693a4e8ed607 Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Sat, 10 Aug 2024 10:46:07 +0200
Subject: [PATCH 077/113] [ShellScript] Tidy up and simplify cmd-args contexts

---
 ShellScript/Bash.sublime-syntax | 108 ++++++++++++++------------------
 1 file changed, 48 insertions(+), 60 deletions(-)

diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax
index eece2baa24..59ae6af073 100644
--- a/ShellScript/Bash.sublime-syntax
+++ b/ShellScript/Bash.sublime-syntax
@@ -323,16 +323,14 @@ contexts:
   cmd-alias-args-definitions:
     - include: cmd-args-end
     - match: '{{word_begin}}'
-      push:
-        - statements-value-assignment
-        - alias-name-chars
+      push: alias-name-chars
 
   alias-name-chars:
     - meta_scope: meta.command.shell entity.name.function.shell
     - include: line-continuations
     - include: literal-unquoted-content
     - match: '{{opt_break}}'
-      pop: 1
+      set: statements-value-assignment
 
 ###[ ARITHMETIC BUILTINS ]#####################################################
 
@@ -898,13 +896,6 @@ contexts:
         - cmd-args-meta
         - cmd-args
 
-  cmd-args:
-    - meta_include_prototype: false
-    - include: cmd-args-end
-    - include: cmd-args-end-of-options-then-ambigious
-    - include: cmd-args-options
-    - include: cmd-args-values
-
   cmd-args-meta:
     - meta_include_prototype: false
     - meta_content_scope: meta.function-call.arguments.shell
@@ -914,60 +905,18 @@ contexts:
     - include: redirections
     - include: eoc-pop
 
-  cmd-args-options:
-    - match: '{{opt_punctuation}}'
-      scope: punctuation.definition.parameter.shell
-      push:
-        - cmd-args-option-maybe-assignment
-        - cmd-args-option-name
-
-  cmd-args-option-name:
-    - meta_scope: meta.parameter.option.shell variable.parameter.option.shell
-    - include: line-continuations
-    - include: literal-unquoted-content
-    - match: '{{opt_break}}'
-      pop: 1
-
-  cmd-args-option-maybe-assignment:
-    # NOTE: this context is used in commands-builtin-shell-bash.sublime-syntax
-    - meta_include_prototype: false
-    - match: =
-      scope: keyword.operator.assignment.shell
-      set: cmd-args-option-value
-    - include: line-continuations
-    - include: immediately-pop
-
-  cmd-args-option-maybe-command:
-    - include: cmd-args-end
-    - include: statements-word
-    - include: else-pop
-
-  cmd-args-option-maybe-value:
-    # NOTE: this context is used in commands-builtin-shell-bash.sublime-syntax
-    - meta_include_prototype: false
-    - match: '{{wspace}}(?![-+\]}{{metachar}}])'
-      set: cmd-args-option-value
-    - include: number
-    - include: line-continuations
-    - include: immediately-pop
-
-  cmd-args-option-value:
-    - meta_include_prototype: false
-    - include: line-continuations
-    - include: boolean
-    - include: number
-    - include: string-path-pattern
-    - include: immediately-pop
+  cmd-args:
+    - include: cmd-args-end-of-options-then-ambigious
 
   cmd-args-end-of-options-then-ambigious:
     - match: --{{word_break}}
       scope: keyword.operator.end-of-options.shell
       set: cmd-args-ambigious
+    - include: cmd-args-options
+    - include: cmd-args-ambigious
 
   cmd-args-ambigious:
-    - meta_include_prototype: false
-    - include: redirections
-    - include: eoc-pop
+    - include: cmd-args-end
     - include: cmd-args-values
 
   cmd-args-end-of-options-then-function-declarations:
@@ -978,7 +927,6 @@ contexts:
     - include: cmd-args-function-declarations
 
   cmd-args-function-declarations:
-    - meta_include_prototype: false
     - include: cmd-args-end
     - match: '{{word_begin}}'
       push: function-declaration-name-chars
@@ -1069,8 +1017,47 @@ contexts:
         - variable-name-begin
     - include: illegal-words
 
-  cmd-args-values:
+  cmd-args-options:
+    - match: '{{opt_punctuation}}'
+      scope: punctuation.definition.parameter.shell
+      push: cmd-args-option-name
+
+  cmd-args-option-name:
+    - meta_scope: meta.parameter.option.shell variable.parameter.option.shell
+    - include: line-continuations
+    - include: literal-unquoted-content
+    - match: '{{opt_break}}'
+      set: cmd-args-option-maybe-assignment
+
+  cmd-args-option-maybe-assignment:
     - meta_include_prototype: false
+    - match: =
+      scope: keyword.operator.assignment.shell
+      set: cmd-args-option-assignment-value
+    - include: line-continuations
+    - include: immediately-pop
+
+  cmd-args-option-assignment-value:
+    - meta_include_prototype: false
+    - include: line-continuations
+    - include: boolean
+    - include: number
+    - include: string-path-pattern
+    - include: immediately-pop
+
+  cmd-args-option-maybe-command:
+    - meta_include_prototype: false
+    - include: eoc-pop
+    - include: statements-word
+
+  cmd-args-option-maybe-value:
+    - meta_include_prototype: false
+    - include: eoc-pop
+    - include: boolean
+    - include: number
+    - include: string-path-pattern
+
+  cmd-args-values:
     - include: booleans
     - include: numbers
     - include: string-path-patterns
@@ -1430,6 +1417,7 @@ contexts:
     - include: immediately-pop
 
   statements-value:
+    - meta_include_prototype: false
     - include: statements-word
     - include: immediately-pop
 

From f0df84e075688a9a972cbb663a8df405d9329dbe Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Sat, 10 Aug 2024 11:17:27 +0200
Subject: [PATCH 078/113] [ShellScript] Disable KSH_GLOB in ZSH

---
 ShellScript/Zsh.sublime-syntax              | 10 +--
 ShellScript/Zsh/tests/syntax_test_scope.zsh | 99 ++++++++++-----------
 2 files changed, 51 insertions(+), 58 deletions(-)

diff --git a/ShellScript/Zsh.sublime-syntax b/ShellScript/Zsh.sublime-syntax
index 8ce74a5780..ca1196ed4f 100644
--- a/ShellScript/Zsh.sublime-syntax
+++ b/ShellScript/Zsh.sublime-syntax
@@ -306,7 +306,7 @@ contexts:
     - include: zsh-glob-ranges
 
   pattern-groups:
-    # KSH_GLOB is optional (hence don't support it)
+    # prefer EXTENDED_GLOB over optional KSH_GLOB
     - match: (?=\()
       branch_point: pattern-group
       branch:
@@ -434,11 +434,9 @@ contexts:
     - include: zsh-glob-ranges
 
   expansion-parameter-pattern-groups:
-    # KSH_GLOB is optional (hence not matching ? and * in favor of ZSH globs)
-    - match: ([+@!]??)(\()
-      captures:
-        1: string.unquoted.shell keyword.operator.quantifier.regexp.shell
-        2: meta.group.regexp.shell string.unquoted.shell punctuation.section.group.begin.regexp.shell
+    # prefer EXTENDED_GLOB over optional KSH_GLOB
+    - match: \(
+      scope: meta.group.regexp.shell string.unquoted.shell punctuation.section.group.begin.regexp.shell
       push: expansion-parameter-pattern-group-body
 
   expansion-parameter-pattern-group-body:
diff --git a/ShellScript/Zsh/tests/syntax_test_scope.zsh b/ShellScript/Zsh/tests/syntax_test_scope.zsh
index a1308e561f..d238ddc2a2 100644
--- a/ShellScript/Zsh/tests/syntax_test_scope.zsh
+++ b/ShellScript/Zsh/tests/syntax_test_scope.zsh
@@ -3419,60 +3419,55 @@ dyn_dir_name() {
 ###############################################################################
 # 14.8.2 ksh-like Glob Operators
 # https://zsh.sourceforge.io/Doc/Release/Expansion.html#ksh_002dlike-Glob-Operators
+# Note: KSH_GLOB is optional and thus not scoped in favor of EXTENDED_KOB
 ###############################################################################
 
-# : @(...) is (...)    # Match the pattern in the parentheses. (Like ‘(...)’.)
-# #  ^^^^^ meta.group.regexp.shell
-# #  ^ punctuation.section.group.begin.regexp.shell
-# #      ^ punctuation.section.group.end.regexp.shell
-# #           ^^^^^ meta.group.regexp.shell
-# #           ^ punctuation.section.group.begin.regexp.shell
-# #               ^ punctuation.section.group.end.regexp.shell
-
-# # note: scope * as glob instead of operator as it is more likely in ZSH
-# : *(...) is (...)#   # Match any number of occurrences. (Like ‘(...)#’, except that recursive directory searching is not supported.)
-# # ^ constant.other.wildcard.asterisk.shell
-# #  ^^^^^ meta.group.regexp.shell
-# #  ^ punctuation.section.group.begin.regexp.shell
-# #      ^ punctuation.section.group.end.regexp.shell
-# #           ^^^^^ meta.group.regexp.shell
-# #           ^ punctuation.section.group.begin.regexp.shell
-# #               ^ punctuation.section.group.end.regexp.shell
-# #                ^ keyword.operator.quantifier.regexp.shell
-
-# : +(...) is (...)##  # Match at least one occurrence. (Like ‘(...)##’, except that recursive directory searching is not supported.)
-# # ^ keyword.operator.quantifier.regexp.shell
-# #  ^^^^^ meta.group.regexp.shell
-# #  ^ punctuation.section.group.begin.regexp.shell
-# #      ^ punctuation.section.group.end.regexp.shell
-# #           ^^^^^ meta.group.regexp.shell
-# #           ^ punctuation.section.group.begin.regexp.shell
-# #               ^ punctuation.section.group.end.regexp.shell
-# #                ^^ keyword.operator.quantifier.regexp.shell
-
-# # note: scope ? as glob instead of operator as it is more likely in ZSH
-# : ?(...) is (|...)   # Match zero or one occurrence. (Like ‘(|...)’.)
-# # ^ constant.other.wildcard.questionmark.shell
-# #  ^^^^^ meta.group.regexp.shell
-# #  ^ punctuation.section.group.begin.regexp.shell
-# #      ^ punctuation.section.group.end.regexp.shell
-# #           ^^^^^^ meta.group.regexp.shell
-# #           ^ punctuation.section.group.begin.regexp.shell
-# #            ^ keyword.operator.logical.regexp.shell
-# #                ^ punctuation.section.group.end.regexp.shell
-
-# : !(...) is (^(...)) # Match anything but the expression in parentheses. (Like ‘(^(...))’.)
-# # ^ keyword.operator.quantifier.regexp.shell
-# #  ^^^^^ meta.group.regexp.shell
-# #  ^ punctuation.section.group.begin.regexp.shell
-# #      ^ punctuation.section.group.end.regexp.shell
-# #           ^^ meta.group.regexp.shell - meta.group.regexp meta.group.regexp
-# #           ^ punctuation.section.group.begin.regexp.shell
-# #            ^ keyword.operator.logical.regexp.shell
-# #             ^^^^^ meta.group.regexp.shell meta.group.regexp.shell
-# #             ^ punctuation.section.group.begin.regexp.shell
-# #                 ^^ punctuation.section.group.end.regexp.shell
-# #                  ^ meta.group.regexp.shell - meta.group.regexp meta.group.regexp
+: @(___) is (___)    # Match the pattern in the parentheses. (Like ‘(___)’.)
+#  ^^^^^ meta.group.regexp.shell
+#  ^ punctuation.section.group.begin.regexp.shell
+#      ^ punctuation.section.group.end.regexp.shell
+#           ^^^^^ meta.group.regexp.shell
+#           ^ punctuation.section.group.begin.regexp.shell
+#               ^ punctuation.section.group.end.regexp.shell
+
+: *(___) is (___)#   # Match any number of occurrences. (Like ‘(___)#’, except that recursive directory searching is not supported.)
+#  ^^^^^ meta.group.regexp.shell
+#  ^ punctuation.section.group.begin.regexp.shell
+#      ^ punctuation.section.group.end.regexp.shell
+#           ^^^^^ meta.group.regexp.shell
+#           ^ punctuation.section.group.begin.regexp.shell
+#               ^ punctuation.section.group.end.regexp.shell
+#                ^ keyword.operator.quantifier.regexp.shell
+
+: +(___) is (___)##  # Match at least one occurrence. (Like ‘(___)##’, except that recursive directory searching is not supported.)
+#  ^^^^^ meta.group.regexp.shell
+#  ^ punctuation.section.group.begin.regexp.shell
+#      ^ punctuation.section.group.end.regexp.shell
+#           ^^^^^ meta.group.regexp.shell
+#           ^ punctuation.section.group.begin.regexp.shell
+#               ^ punctuation.section.group.end.regexp.shell
+#                ^^ keyword.operator.quantifier.regexp.shell
+
+: ?(___) is (|___)   # Match zero or one occurrence. (Like ‘(|___)’.)
+#  ^^^^^ meta.group.regexp.shell
+#  ^ punctuation.section.group.begin.regexp.shell
+#      ^ punctuation.section.group.end.regexp.shell
+#           ^^^^^^ meta.group.regexp.shell
+#           ^ punctuation.section.group.begin.regexp.shell
+#            ^ keyword.operator.logical.regexp.shell
+#                ^ punctuation.section.group.end.regexp.shell
+
+: !(___) is (^(___)) # Match anything but the expression in parentheses. (Like ‘(^(___))’.)
+#  ^^^^^ meta.group.regexp.shell
+#  ^ punctuation.section.group.begin.regexp.shell
+#      ^ punctuation.section.group.end.regexp.shell
+#           ^^ meta.group.regexp.shell - meta.group.regexp meta.group.regexp
+#           ^ punctuation.section.group.begin.regexp.shell
+#            ^ keyword.operator.logical.regexp.shell
+#             ^^^^^ meta.group.regexp.shell meta.group.regexp.shell
+#             ^ punctuation.section.group.begin.regexp.shell
+#                 ^^ punctuation.section.group.end.regexp.shell
+#                  ^ meta.group.regexp.shell - meta.group.regexp meta.group.regexp
 
 
 ###############################################################################

From 3517b9fe04031f32fc70ceb6766cc473b1bb353b Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Sat, 10 Aug 2024 14:28:27 +0200
Subject: [PATCH 079/113] [ShellScript] Refine case clause patterns

This commit...

1. enforces KSH style pattern groups in Bash's case clauses by removing simple
   parenthesized groups' support. This style is only valid in ZSH.

2. terminate case patterns at eol, if not starting with `(`.

3. handle the tricky case in ZSH of possibly unbalanced parentheses in case
   clause patterns:

    - `( group ) pattern ) statements ;;`
    - `( ( group ) pattern ) statements ;;`
---
 ShellScript/Bash.sublime-syntax               | 41 +++++-----
 ShellScript/Bash/tests/syntax_test_scope.bash | 24 +++---
 ShellScript/Zsh.sublime-syntax                | 35 +++++++++
 ShellScript/Zsh/tests/syntax_test_scope.zsh   | 75 +++++++++++++++++++
 4 files changed, 141 insertions(+), 34 deletions(-)

diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax
index 59ae6af073..e73bab2fb5 100644
--- a/ShellScript/Bash.sublime-syntax
+++ b/ShellScript/Bash.sublime-syntax
@@ -1133,20 +1133,33 @@ contexts:
     - include: case-clauses
 
   case-clauses:
-    - match: \(|(?=\S)
+    - match: \(
       scope: meta.clause.pattern.shell punctuation.definition.pattern.begin.shell
-      push: case-clause-pattern
+      push: case-clause-paren-pattern-body
+    - match: (?=\S)
+      push: case-clause-plain-pattern-body
 
-  case-clause-pattern:
+  case-clause-paren-pattern-body:
+    # patterns enclosed in parentesis may continue on next line without \
     - meta_include_prototype: false
     - meta_content_scope: meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell
     - match: \)
       scope: meta.clause.pattern.shell punctuation.definition.pattern.end.shell
       set: case-clause-after-pattern
-    # emergency bail outs if ')' is missing
-    - include: case-clause-end
     - include: line-continuations
-    - include: case-clause-pattern-content
+    - include: case-end-ahead
+    - include: pattern-group-content
+
+  case-clause-plain-pattern-body:
+    # patterns not enclosed in parentesis are terminated at eol
+    - meta_include_prototype: false
+    - meta_content_scope: meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell
+    - match: \)
+      scope: meta.clause.pattern.shell punctuation.definition.pattern.end.shell
+      set: case-clause-after-pattern
+    - include: eol-pop
+    - include: case-end-ahead
+    - include: pattern-group-content
 
   case-clause-after-pattern:
     # required to handle scope specific indentation rules
@@ -1156,22 +1169,6 @@ contexts:
     - match: ^|(?=\S)
       set: case-clause-body
 
-  case-clause-pattern-content:
-    # [Bash] 3.2.4.2: Each pattern undergoes tilde expansion, parameter
-    # expansion, command substitution, and arithmetic expansion.
-    - match: \(  # Note: exists to support ZSH
-      scope: meta.group.regexp.shell string.unquoted.shell punctuation.section.group.begin.regexp.shell
-      push: case-clause-pattern-group-body
-    - include: case-end-ahead
-    - include: pattern-group-content
-
-  case-clause-pattern-group-body:
-    - clear_scopes: 1  # clear `string.unquoted`
-    - meta_include_prototype: false
-    - meta_content_scope: meta.group.regexp.shell string.unquoted.shell
-    - include: pattern-group-end
-    - include: case-clause-pattern-content
-
   case-clause-body:
     - meta_content_scope: meta.clause.body.shell
     - include: case-clause-end
diff --git a/ShellScript/Bash/tests/syntax_test_scope.bash b/ShellScript/Bash/tests/syntax_test_scope.bash
index df0271f959..71d87cb369 100644
--- a/ShellScript/Bash/tests/syntax_test_scope.bash
+++ b/ShellScript/Bash/tests/syntax_test_scope.bash
@@ -2275,11 +2275,10 @@ case var in
   ( patt ( esac
 #^ meta.statement.conditional.case.body.shell
 # ^ meta.clause.pattern.shell - meta.string - meta.group - string
-#  ^^^^^^ meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell - meta.group
-#        ^^ meta.clause.pattern.shell meta.string.regexp.shell meta.group.regexp.shell string.unquoted.shell
+#  ^^^^^^^^ meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell - meta.group
 #          ^^^^ meta.statement.conditional.case.end.shell
 # ^ punctuation.definition.pattern.begin.shell
-#        ^ punctuation.section.group.begin.regexp.shell
+#        ^ - punctuation
 #          ^^^^ keyword.control.conditional.endcase.shell
 #              ^ - meta.conditional
 
@@ -2442,19 +2441,20 @@ case $TERM in
         update_terminal_cwd() { print -Pn "\e]l%~\e\\" };;
         #                                              ^ meta.function punctuation.section.block.end.shell
         #                                               ^^ punctuation.terminator.clause.shell
-    *xterm*|rxvt|(dt|k|E)term)
+    *xterm*|rxvt|?(dt|k|E)term)
         #^^^^^^^^ meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell
-        #        ^^^^^^^^ meta.clause.pattern.shell meta.string.regexp.shell meta.group.regexp.shell string.unquoted.shell
-        #                ^^^^ meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell
-        #                    ^ meta.clause.pattern.shell - meta.string - meta.group - string
+        #         ^^^^^^^^ meta.clause.pattern.shell meta.string.regexp.shell meta.group.regexp.shell string.unquoted.shell
+        #                 ^^^^ meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell
+        #                     ^ meta.clause.pattern.shell - meta.string - meta.group - string
         # ^ constant.other.wildcard.asterisk.shell
         #  ^ keyword.operator.logical.regexp.shell
         #       ^ keyword.operator.logical.regexp.shell
-        #        ^ punctuation.section.group.begin.regexp.shell
-        #           ^ keyword.operator.logical.regexp.shell
-        #             ^ keyword.operator.logical.regexp.shell
-        #               ^ punctuation.section.group.end.regexp.shell
-        #                    ^ punctuation.definition.pattern.end.shell
+        #        ^ keyword.operator.quantifier.regexp.shell
+        #         ^ punctuation.section.group.begin.regexp.shell
+        #            ^ keyword.operator.logical.regexp.shell
+        #              ^ keyword.operator.logical.regexp.shell
+        #                ^ punctuation.section.group.end.regexp.shell
+        #                     ^ punctuation.definition.pattern.end.shell
         update_terminal_cwd() { print -Pn "\e]2;%~\a" };;
         #                                             ^ meta.function punctuation.section.block.end.shell
         #                                              ^^ punctuation.terminator.clause.shell
diff --git a/ShellScript/Zsh.sublime-syntax b/ShellScript/Zsh.sublime-syntax
index ca1196ed4f..3710d9178b 100644
--- a/ShellScript/Zsh.sublime-syntax
+++ b/ShellScript/Zsh.sublime-syntax
@@ -156,6 +156,41 @@ contexts:
     - include: comments
     - include: case-clauses
 
+  case-clauses:
+    # This branch handles the tricky part of determining whether a case pattern
+    # is enclosed in parentheses or whether the first opening parenthesis just
+    # belongs to a normal pattern group.
+    #
+    # Examples:
+    #   a) `( group ) pattern ) statements ;;`
+    #   b) `( ( group ) pattern ) statements ;;`
+    - match: (?=\()
+      branch_point: case-clause-paren-pattern
+      branch:
+        - case-clause-plain-pattern-body
+        - case-clause-paren-pattern
+    - match: (?=\S)
+      push: case-clause-plain-pattern-body
+
+  case-clause-paren-pattern:
+    - meta_include_prototype: false
+    - match: \(
+      scope: meta.clause.pattern.shell punctuation.definition.pattern.begin.shell
+      set: case-clause-paren-pattern-body
+
+  case-clause-plain-pattern-body:
+    - meta_include_prototype: false
+    - meta_content_scope: meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell
+    # comment, end of clause or end of line
+    # indicate pattern being enclosed in balanced parentheses
+    - match: (?=(?:$|;;&?|;&)|\s+#)
+      fail: case-clause-paren-pattern
+    - include: case-clause-paren-pattern-body
+
+  case-end-ahead:
+    - meta_prepend: true
+    - include: brace-pop
+
   foreach-meta:
     - meta_include_prototype: false
     - meta_scope: meta.statement.loop.foreach.shell.zsh
diff --git a/ShellScript/Zsh/tests/syntax_test_scope.zsh b/ShellScript/Zsh/tests/syntax_test_scope.zsh
index d238ddc2a2..0a210264e9 100644
--- a/ShellScript/Zsh/tests/syntax_test_scope.zsh
+++ b/ShellScript/Zsh/tests/syntax_test_scope.zsh
@@ -523,6 +523,81 @@ case $word {
 #       ^^^ meta.function-call.identifier.shell variable.function.shell
 #          ^^^^^^^^^^^ meta.function-call.arguments.shell
 #                     ^^ punctuation.terminator.clause.shell
+
+    ws-+([0-9]).host.com)
+#   ^^^^^^^^^^^^^^^^^^^^ meta.statement.conditional.case.body.shell meta.block.shell.zsh meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell
+#       ^ meta.group.regexp.shell - meta.set
+#        ^^^^^ meta.group.regexp.shell meta.set.regexp.shell
+#             ^ meta.group.regexp.shell - meta.set
+#                       ^ meta.clause.pattern.shell - meta.group - string
+#                        ^ meta.statement.conditional.case.body.shell meta.block.shell.zsh meta.clause.shell - meta.clause.pattern
+        ;;
+#       ^^ punctuation.terminator.clause.shell
+
+    ((foo|bar)baz) cmd arg ;;
+#   ^ meta.clause.pattern.shell - meta.string - string
+#    ^^^^^^^^^ meta.clause.pattern.shell meta.string.regexp.shell meta.group.regexp.shell string.unquoted.shell
+#             ^^^ meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell
+#                ^ meta.clause.pattern.shell - meta.string - string
+#                 ^ meta.clause.shell
+#                  ^^^^^^^^ meta.clause.body.shell
+#   ^ punctuation.definition.pattern.begin.shell
+#    ^ punctuation.section.group.begin.regexp.shell
+#        ^ keyword.operator.logical.regexp.shell
+#            ^ punctuation.section.group.end.regexp.shell
+#                ^ punctuation.definition.pattern.end.shell
+#                  ^^^ variable.function.shell
+#                      ^^^ meta.string.shell string.unquoted.shell
+#                          ^^ punctuation.terminator.clause.shell
+
+    (foo|bar)baz) cmd arg ;;
+#   ^^^^^^^^^ meta.clause.pattern.shell meta.string.regexp.shell meta.group.regexp.shell string.unquoted.shell
+#            ^^^ meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell
+#               ^ meta.clause.pattern.shell - meta.string - string
+#                ^ meta.clause.shell
+#                 ^^^^^^^^ meta.clause.body.shell
+#   ^ punctuation.section.group.begin.regexp.shell
+#       ^ keyword.operator.logical.regexp.shell
+#           ^ punctuation.section.group.end.regexp.shell
+#               ^ punctuation.definition.pattern.end.shell
+#                 ^^^ variable.function.shell
+#                     ^^^ meta.string.shell string.unquoted.shell
+#                         ^^ punctuation.terminator.clause.shell
+
+    ((foo|bar)baz)
+#   ^ meta.clause.pattern.shell - meta.string - string
+#    ^^^^^^^^^ meta.clause.pattern.shell meta.string.regexp.shell meta.group.regexp.shell string.unquoted.shell
+#             ^^^ meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell
+#                ^ meta.clause.pattern.shell - meta.string - string
+#                 ^ meta.clause.shell
+#   ^ punctuation.definition.pattern.begin.shell
+#    ^ punctuation.section.group.begin.regexp.shell
+#        ^ keyword.operator.logical.regexp.shell
+#            ^ punctuation.section.group.end.regexp.shell
+#                ^ punctuation.definition.pattern.end.shell
+        cmd arg ;;
+#       ^^^^^^^^ meta.clause.body.shell
+#       ^^^ variable.function.shell
+#           ^^^ meta.string.shell string.unquoted.shell
+#               ^^ punctuation.terminator.clause.shell
+
+    (foo|bar)baz)
+#   ^^^^^^^^^ meta.clause.pattern.shell meta.string.regexp.shell meta.group.regexp.shell string.unquoted.shell
+#            ^^^ meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell
+#               ^ meta.clause.pattern.shell - meta.string - string
+#                ^ meta.clause.shell
+#   ^ punctuation.section.group.begin.regexp.shell
+#       ^ keyword.operator.logical.regexp.shell
+#           ^ punctuation.section.group.end.regexp.shell
+#               ^ punctuation.definition.pattern.end.shell
+        cmd arg ;;
+#       ^^^^^^^^ meta.clause.body.shell
+#       ^^^ variable.function.shell
+#           ^^^ meta.string.shell string.unquoted.shell
+#               ^^ punctuation.terminator.clause.shell
+
+    incomplete | pattern
+#   ^^^^^^^^^^^^^^^^^^^^ meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell
 }
 # <- meta.statement.conditional.case.body.shell punctuation.section.block.end.shell
 

From 15f1b6800bb5c9b5a13c72ddacf5fb4c34188659 Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Sat, 10 Aug 2024 15:56:42 +0200
Subject: [PATCH 080/113] [ShellScript] Refine pattern matching contexts

This commit ...

1. introduce a `pattern-common` context for common patterns,
   which are valid in all sorts and locations of patterns.

2. modifies how `meta.group.regexp` is applied to reduce requirement of
   duplicated scope names in punctuation patterns.
---
 ShellScript/Bash.sublime-syntax | 75 ++++++++++++++++++---------------
 ShellScript/Zsh.sublime-syntax  | 63 +++------------------------
 2 files changed, 49 insertions(+), 89 deletions(-)

diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax
index e73bab2fb5..194ca6918b 100644
--- a/ShellScript/Bash.sublime-syntax
+++ b/ShellScript/Bash.sublime-syntax
@@ -2052,7 +2052,9 @@ contexts:
     - include: brace-interpolations
     - include: string-interpolations
     - include: expansions-job
-    - include: expansions-patterns
+    - include: pattern-groups
+    - include: pattern-charsets
+    - include: pattern-common
     - include: string-pathlist-separators
 
   string-path-pattern-ansi-c-body:
@@ -2118,7 +2120,9 @@ contexts:
     - include: brace-interpolations
     - include: string-interpolations
     - include: expansions-job
-    - include: expansions-patterns
+    - include: pattern-groups
+    - include: pattern-charsets
+    - include: pattern-common
     - include: path-pattern-separators
 
   path-pattern-ansi-c-body:
@@ -2145,7 +2149,9 @@ contexts:
   pattern-main-content:
     # [3.5.8.1] Pattern Matching in arbitrary expressions
     - include: string-unquoted-content
-    - include: expansions-patterns
+    - include: pattern-groups
+    - include: pattern-charsets
+    - include: pattern-common
 
   pattern-charsets:
     - match: (?=\[)
@@ -2259,32 +2265,36 @@ contexts:
     - include: eol-pop
 
   pattern-groups:
-    - match: ([?*+@!])(\()
-      captures:
-        1: string.unquoted.shell keyword.operator.quantifier.regexp.shell
-        2: meta.group.regexp.shell string.unquoted.shell punctuation.section.group.begin.regexp.shell
-      push: pattern-group-body
+    - match: '[?*+@!](?=\()'
+      scope: keyword.operator.quantifier.regexp.shell
+      push: pattern-group
+
+  pattern-group:
+    - meta_include_prototype: false
+    - match: \(
+      scope: punctuation.section.group.begin.regexp.shell
+      set: pattern-group-body
 
   pattern-group-body:
     - clear_scopes: 1  # clear `string.unquoted`
     - meta_include_prototype: false
-    - meta_content_scope: meta.group.regexp.shell string.unquoted.shell
+    - meta_scope: meta.group.regexp.shell string.unquoted.shell
     - include: pattern-group-end
     - include: pattern-group-content
 
-  pattern-group-content:
-    - include: string-unquoted-content
-    - include: pattern-groups
-    - include: pattern-group-charsets
-    - include: pattern-operators
-    - include: pattern-wildcards
-
   pattern-group-end:
     - match: \)
-      scope: meta.group.regexp.shell string.unquoted.shell punctuation.section.group.end.regexp.shell
+      scope: punctuation.section.group.end.regexp.shell
       pop: 1
     - include: line-continuations
 
+  pattern-group-content:
+    - include: string-unquoted-content
+    - include: pattern-groups
+    - include: pattern-group-charsets
+    - include: pattern-group-operators
+    - include: pattern-common
+
   pattern-group-charsets:
     - match: (?=\[)
       branch_point: pattern-group-charset
@@ -2308,11 +2318,11 @@ contexts:
     - include: pattern-charset-end
     - include: pattern-charset-content
 
-  pattern-operators:
+  pattern-group-operators:
     - match: \|
       scope: keyword.operator.logical.regexp.shell
 
-  pattern-wildcards:
+  pattern-common:
     - match: \*
       scope: constant.other.wildcard.asterisk.shell
     - match: \?
@@ -2436,11 +2446,6 @@ contexts:
 
 ###[ EXPANSIONS ]##############################################################
 
-  expansions-patterns:
-    - include: pattern-groups
-    - include: pattern-charsets
-    - include: pattern-wildcards
-
   expansions-variables:
     - include: expansions-arithmetic
     - include: expansions-command
@@ -2764,7 +2769,7 @@ contexts:
     - include: string-unquoted-content
     - include: expansion-parameter-pattern-charsets
     - include: expansion-parameter-pattern-groups
-    - include: pattern-wildcards
+    - include: pattern-common
 
   expansion-parameter-pattern-charsets:
     - match: (?=\[)
@@ -2790,22 +2795,26 @@ contexts:
     - include: pattern-charset-content
 
   expansion-parameter-pattern-groups:
-    - match: ([?*+@!])(\()
-      captures:
-        1: string.unquoted.shell keyword.operator.quantifier.regexp.shell
-        2: meta.group.regexp.shell string.unquoted.shell punctuation.section.group.begin.regexp.shell
-      push: expansion-parameter-pattern-group-body
+    - match: '[?*+@!]?(?=\()'
+      scope: keyword.operator.quantifier.regexp.shell
+      push: expansion-parameter-pattern-group
+
+  expansion-parameter-pattern-group:
+    - meta_include_prototype: false
+    - match: \(
+      scope: punctuation.section.group.begin.regexp.shell
+      set: expansion-parameter-pattern-group-body
 
   expansion-parameter-pattern-group-body:
     - clear_scopes: 1  # clear `string.unquoted`
     - meta_include_prototype: false
-    - meta_content_scope: meta.group.regexp.shell string.unquoted.shell
+    - meta_scope: meta.group.regexp.shell string.unquoted.shell
     - include: pattern-group-end
     - include: string-unquoted-content
     - include: expansion-parameter-pattern-groups
     - include: expansion-parameter-pattern-group-charsets
-    - include: pattern-operators
-    - include: pattern-wildcards
+    - include: pattern-group-operators
+    - include: pattern-common
     - include: brace-pop
 
   expansion-parameter-pattern-group-charsets:
diff --git a/ShellScript/Zsh.sublime-syntax b/ShellScript/Zsh.sublime-syntax
index 3710d9178b..5852ea7bbe 100644
--- a/ShellScript/Zsh.sublime-syntax
+++ b/ShellScript/Zsh.sublime-syntax
@@ -318,60 +318,22 @@ contexts:
         - string-path-pattern-body
         - maybe-tilde-interpolation
 
-  string-path-pattern-content:
-    - meta_prepend: true
-    - include: zsh-glob-flags
-    - include: zsh-glob-operators
-    - include: zsh-glob-ranges
-
-###[ PATH PATTERN MATCHING ]###################################################
-
-  path-pattern-content:
-    - meta_prepend: true
-    - include: zsh-glob-flags
-    - include: zsh-glob-operators
-    - include: zsh-glob-ranges
-
 ###[ SHELL PATTERN MATCHING ]##################################################
 
-  pattern-main-content:
-    - meta_prepend: true
-    - include: zsh-glob-flags
-    - include: zsh-glob-operators
-    - include: zsh-glob-ranges
-
   pattern-groups:
+    - include: zsh-glob-flags
     # prefer EXTENDED_GLOB over optional KSH_GLOB
     - match: (?=\()
-      branch_point: pattern-group
+      branch_point: zsh-glob-qualifier
       branch:
         - zsh-glob-qualifier
         - pattern-group
 
-  pattern-group:
-    - match: \(
-      scope: punctuation.section.group.begin.regexp.shell
-      set: pattern-group-body
-
-  pattern-group-body:
-    - clear_scopes: 1  # clear `string.unquoted`
-    - meta_include_prototype: false
-    - meta_scope: meta.group.regexp.shell string.unquoted.shell
-    - include: pattern-group-end
-    - include: pattern-group-content
-
-  pattern-group-content:
+  pattern-common:
     - meta_prepend: true
-    - include: zsh-glob-flags
     - include: zsh-glob-operators
     - include: zsh-glob-ranges
 
-  pattern-group-end:
-    - match: \)
-      scope: punctuation.section.group.end.regexp.shell
-      pop: 1
-    - include: line-continuations
-
 ###[ ARITHMETIC EXPANSIONS ]###################################################
 
   expansions-arithmetic:
@@ -462,24 +424,13 @@ contexts:
         - expansion-parameter-pattern
         - maybe-tilde-interpolation
 
-  expansion-parameter-pattern:
-    - meta_prepend: true
-    - include: zsh-glob-flags
-    - include: zsh-glob-operators
-    - include: zsh-glob-ranges
-
   expansion-parameter-pattern-groups:
+    - include: zsh-glob-flags
     # prefer EXTENDED_GLOB over optional KSH_GLOB
     - match: \(
-      scope: meta.group.regexp.shell string.unquoted.shell punctuation.section.group.begin.regexp.shell
+      scope: punctuation.section.group.begin.regexp.shell
       push: expansion-parameter-pattern-group-body
 
-  expansion-parameter-pattern-group-body:
-    - meta_prepend: true
-    - include: zsh-glob-flags
-    - include: zsh-glob-operators
-    - include: zsh-glob-ranges
-
   zsh-parameter-subscription:
     - meta_include_prototype: false
     - meta_scope: meta.interpolation.parameter.shell
@@ -606,11 +557,11 @@ contexts:
     - match: '{{word_break}}'
       pop: 1
     - match: ''
-      fail: pattern-group
+      fail: zsh-glob-qualifier
 
   zsh-glob-qualifier-fail:
     - match: (?=\S)
-      fail: pattern-group
+      fail: zsh-glob-qualifier
 
   zsh-glob-qualifier-content:
     - include: comma-separators

From 981db4274d43b536388c127d902b25d72709240a Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Sat, 10 Aug 2024 18:23:55 +0200
Subject: [PATCH 081/113] [ShellScript] Simplify path patterns

---
 ShellScript/Bash.sublime-syntax | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax
index 194ca6918b..670bf44892 100644
--- a/ShellScript/Bash.sublime-syntax
+++ b/ShellScript/Bash.sublime-syntax
@@ -2102,10 +2102,6 @@ contexts:
     - include: immediately-pop
 
   path-pattern-content:
-    - include: path-pattern-common
-    - include: pattern-charsets
-
-  path-pattern-common:
     - match: \$?\"
       scope: punctuation.definition.quoted.begin.shell
       push: path-pattern-double-quoted-body
@@ -2123,21 +2119,21 @@ contexts:
     - include: pattern-groups
     - include: pattern-charsets
     - include: pattern-common
-    - include: path-pattern-separators
+    - include: path-separators
 
   path-pattern-ansi-c-body:
     - include: literal-ansi-c-body
-    - include: path-pattern-separators
+    - include: path-separators
 
   path-pattern-double-quoted-body:
     - include: literal-double-quoted-body
-    - include: path-pattern-separators
+    - include: path-separators
 
   path-pattern-single-quoted-body:
     - include: literal-single-quoted-body
-    - include: path-pattern-separators
+    - include: path-separators
 
-  path-pattern-separators:
+  path-separators:
     - match: (/)(?:(?:(\.\.)|(\.))(?=/))?
       captures:
         1: punctuation.separator.path.shell

From fae08a987a6b80333c373fb556a1c25d94e009c5 Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Sat, 10 Aug 2024 21:48:01 +0200
Subject: [PATCH 082/113] [ShellScript] Support interpolation in numbers

This commit add support for variable expansion in number to support
some examples illustrated in pure bash bible, which convert colors
to RGB.

        ((r=16#${_:0:2},g=16#${_:2:2},b=16#${_:4:2}))

Illegal highlighting is dropped, but that's probably even more reliable,
especially in scenarios of unknown delimiter or terminator characters.

TODO: ZSH floating points are not covered, yet.
---
 ShellScript/Bash.sublime-syntax               | 98 ++++++++++++-------
 ShellScript/Bash/tests/syntax_test_scope.bash | 22 ++++-
 ShellScript/Zsh.sublime-syntax                | 43 ++++----
 ShellScript/Zsh/tests/syntax_test_scope.zsh   | 37 +++++--
 4 files changed, 133 insertions(+), 67 deletions(-)

diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax
index 670bf44892..d0066c3432 100644
--- a/ShellScript/Bash.sublime-syntax
+++ b/ShellScript/Bash.sublime-syntax
@@ -1839,64 +1839,88 @@ contexts:
 
   numbers:
     # A leading ‘0x’ or ‘0X’ denotes hexadecimal.
-    - match: (0[xX])(\h*)({{word_char}}*)
-      scope: meta.number.integer.hexadecimal.shell
-      captures:
-        1: constant.numeric.base.shell
-        2: constant.numeric.value.shell
-        3: invalid.illegal.shell
+    - match: 0[xX]
+      scope: constant.numeric.base.shell
+      push: hex-number-body
     # Constants with a leading 0 are interpreted as octal numbers.
-    - match: (0)([0-7]+)({{word_char}}*)
-      scope: meta.number.integer.octal.shell
-      captures:
-        1: constant.numeric.base.shell
-        2: constant.numeric.value.shell
-        3: invalid.illegal.shell
+    - match: 0(?=[0-7$])
+      scope: constant.numeric.base.shell
+      push: oct-number-body
     # Otherwise, numbers take the form [base#]n, where the optional base is a
     # decimal number between 2 and 64 representing the arithmetic base, and n is
     # a number in that base. When specifying n, the digits greater than 9 are
     # represented by the lowercase letters, the uppercase letters, ‘@’, and ‘_’,
     # in that order.
-    - match: (\d{{digit}}*#)([[:alnum:]@_]+)({{word_char}}*)
-      scope: meta.number.integer.other.shell
-      captures:
-        1: constant.numeric.base.shell
-        2: constant.numeric.value.shell
-        3: invalid.illegal.shell
+    - match: \d{{dec_digit}}*#
+      scope: constant.numeric.base.shell
+      push: other-number-body
     # If base# is omitted, then base 10 is used.
-    - match: \d{{digit}}*(?![.\w])
-      scope: meta.number.integer.decimal.shell constant.numeric.value.shell
+    - match: (?=\d)
+      push: dec-number-body
 
   number:
     # Note: Leading sign is scoped as operator for consistent highlighting as
     #       we can't distinguish operators from sign for sure everywhere.
-    - match: ([-+]?)(0[xX])(\h*){{word_break}}
-      scope: meta.number.integer.hexadecimal.shell
+    # A leading ‘0x’ or ‘0X’ denotes hexadecimal.
+    - match: ([-+]?)(0[xX])
       captures:
         1: keyword.operator.arithmetic.shell
         2: constant.numeric.base.shell
-        3: constant.numeric.value.shell
-      pop: 1
-    - match: ([-+]?)(0)([0-7]+){{word_break}}
+      set: hex-number-body
+    # Constants with a leading 0 are interpreted as octal numbers.
+    - match: ([-+]?)(0)(?=[0-7$])
       scope: meta.number.integer.octal.shell
       captures:
         1: keyword.operator.arithmetic.shell
         2: constant.numeric.base.shell
-        3: constant.numeric.value.shell
-      pop: 1
-    - match: ([-+]?)(\d{{digit}}*#)([[:alnum:]@_]+){{word_break}}
+      set: oct-number-body
+    # Otherwise, numbers take the form [base#]n, where the optional base is a
+    # decimal number between 2 and 64 representing the arithmetic base, and n is
+    # a number in that base. When specifying n, the digits greater than 9 are
+    # represented by the lowercase letters, the uppercase letters, ‘@’, and ‘_’,
+    # in that order.
+    - match: ([-+]?)(\d{{dec_digit}}*#)
       scope: meta.number.integer.other.she
       captures:
         1: keyword.operator.arithmetic.shell
         2: constant.numeric.base.shell
-        3: constant.numeric.value.shell
+      set: other-number-body
     # If base# is omitted, then base 10 is used.
-    - match: ([-+]?)(\d{{digit}}*){{word_break}}
-      scope: meta.number.integer.decimal.shell
-      captures:
-        1: keyword.operator.arithmetic.shell
-        2: constant.numeric.value.shell
-      pop: 1
+    - match: '[-+]?(?=\d)'
+      scope: keyword.operator.arithmetic.shell
+      set: dec-number-body
+
+  dec-number-body:
+    - meta_include_prototype: false
+    - meta_scope: meta.number.integer.decimal.shell
+    - match: '{{dec_digit}}+'
+      scope: constant.numeric.value.shell
+    - include: expansions-variables
+    - include: immediately-pop
+
+  hex-number-body:
+    - meta_include_prototype: false
+    - meta_scope: meta.number.integer.hexadecimal.shell
+    - match: '{{hex_digit}}+'
+      scope: constant.numeric.value.shell
+    - include: expansions-variables
+    - include: immediately-pop
+
+  oct-number-body:
+    - meta_include_prototype: false
+    - meta_scope: meta.number.integer.octal.shell
+    - match: '{{oct_digit}}+'
+      scope: constant.numeric.value.shell
+    - include: expansions-variables
+    - include: immediately-pop
+
+  other-number-body:
+    - meta_include_prototype: false
+    - meta_scope: meta.number.integer.other.shell
+    - match: '[[:alnum:]@_]+'
+      scope: constant.numeric.value.shell
+    - include: expansions-variables
+    - include: immediately-pop
 
   literal-unquoted-content:
     - match: \$?\"
@@ -2998,7 +3022,9 @@ variables:
     | lower | print | punct | space | upper | word | xdigit )
 
   # Numbers
-  digit: \d
+  dec_digit: \d
+  hex_digit: \h
+  oct_digit: '[0-7]'
   varassign: '[-+]?='
 
   # 4.2 Shell Built-in Commands
diff --git a/ShellScript/Bash/tests/syntax_test_scope.bash b/ShellScript/Bash/tests/syntax_test_scope.bash
index 71d87cb369..0fd117b1dd 100644
--- a/ShellScript/Bash/tests/syntax_test_scope.bash
+++ b/ShellScript/Bash/tests/syntax_test_scope.bash
@@ -12344,7 +12344,7 @@ true false
 #^^^^^^^^^^^^^^^^^ meta.compound.arithmetic.shell
 #  ^ meta.number.integer.octal.shell constant.numeric.base.shell
 #   ^^^^^^^^ meta.number.integer.octal.shell constant.numeric.value.shell
-#           ^^^ meta.number.integer.octal.shell invalid.illegal.shell
+#           ^^^ meta.number.integer.decimal.shell constant.numeric.value.shell
 
 (( 0x ))
 # ^ - meta.number - constant
@@ -12361,13 +12361,29 @@ true false
 #                       ^ - meta.number - constant
 #                        ^^ meta.number.integer.hexadecimal.shell constant.numeric.base.shell
 #                          ^^^^^^^^^^^^^^^^ meta.number.integer.hexadecimal.shell constant.numeric.value.shell
-#                                          ^ meta.number.integer.hexadecimal.shell invalid.illegal.shell
-#                                           ^^^ - meta.number - constant
+#                                          ^^^^ - meta.number - constant
+
+(( 0x${_:0:2}Ag0 0xA${b}C ))
+#  ^^ meta.number.integer.hexadecimal.shell constant.numeric.base.shell
+#    ^^^^^^^^ meta.number.integer.hexadecimal.shell meta.interpolation.parameter.shell
+#            ^ meta.number.integer.hexadecimal.shell constant.numeric.value.shell
+#             ^^^ - meta.number - constant
+#                ^^ meta.number.integer.hexadecimal.shell constant.numeric.base.shell
+#                  ^ meta.number.integer.hexadecimal.shell constant.numeric.value.shell
+#                   ^^^^ meta.number.integer.hexadecimal.shell meta.interpolation.parameter.shell - constant
+#                       ^ meta.number.integer.hexadecimal.shell constant.numeric.value.shell
+#                        ^ - meta.number - constant
 
 (( 64#123@_ ))
 #  ^^^ meta.number.integer.other.shell constant.numeric.base.shell
 #     ^^^^^ meta.number.integer.other.shell constant.numeric.value.shell
 
+(( 16#${_:0:2}DEF ))
+#  ^^^ meta.number.integer.other.shell constant.numeric.base.shell
+#     ^^^^^^^^ meta.number.integer.other.shell meta.interpolation.parameter.shell
+#             ^^^ meta.number.integer.other.shell constant.numeric.value.shell
+#                ^ - meta.number - constant
+
 
 ###############################################################################
 # 6.5 Shell Arithmetic                                                        #
diff --git a/ShellScript/Zsh.sublime-syntax b/ShellScript/Zsh.sublime-syntax
index 5852ea7bbe..bd967e93ea 100644
--- a/ShellScript/Zsh.sublime-syntax
+++ b/ShellScript/Zsh.sublime-syntax
@@ -283,7 +283,7 @@ contexts:
 
   numbers:
     - meta_prepend: true
-    - match: (\d{{digit}}*(\.){{digit}}*(?:[eE][-+]?{{digit}}*)?)({{word_char}}*)
+    - match: (\d{{dec_digit}}*(\.){{dec_digit}}*(?:[eE][-+]?{{dec_digit}}*)?)({{word_char}}*)
       scope: meta.number.float.decimal.shell.zsh
       captures:
         1: constant.numeric.value.shell.zsh
@@ -292,7 +292,7 @@ contexts:
 
   number:
     - meta_prepend: true
-    - match: ([-+]?)(\d{{digit}}*(\.){{digit}}*(?:[eE][-+]?{{digit}}*)?){{word_break}}
+    - match: ([-+]?)(\d{{dec_digit}}*(\.){{dec_digit}}*(?:[eE][-+]?{{dec_digit}}*)?){{word_break}}
       scope: meta.number.float.decimal.shell.zsh
       captures:
         1: keyword.operator.arithmetic.shell.zsh
@@ -615,26 +615,26 @@ contexts:
     - match: \]
       scope: punctuation.definition.range.end.shell.zsh
       pop: 1
+    - include: line-continuations
     - include: comma-separators
-    - include: expansions-variables
-    - include: zsh-glob-numbers
+    - include: zsh-glob-only-numbers
     - include: zsh-glob-qualifier-fail
 
   zsh-qualifier-fspec:
-    # credentials given as octal number
-    - match: ([-+=]?)([?0-7]{1,3})
-      captures:
-        1: keyword.operator.logical.shell.zsh
-        2: meta.number.integer.octal.shell constant.numeric.value.shell
-      pop: 1
-    # credentials given as interpolation
-    - match: ([-+=]?){{is_interpolation}}
-      captures:
-        1: keyword.operator.logical.shell.zsh
-      set: string-interpolation-body
+    # credentials given as octal number without base
+    - match: '[-+=]?(?=[$?0-7])'
+      scope: keyword.operator.logical.shell.zsh
+      set: zsh-qualifier-fspec-number-body
     # anything else is a glob string
     - include: zsh-modifier-string
 
+  zsh-qualifier-fspec-number-body:
+    - meta_include_prototype: false
+    - meta_content_scope: meta.number.integer.octal.shell
+    - match: \?
+      scope: constant.other.wildcard.questionmark.shell
+    - include: oct-number-body
+
 ###[ ZSH GLOB RANGES ]#########################################################
 
   zsh-glob-ranges:
@@ -657,9 +657,8 @@ contexts:
       pop: 1
     - match: \-
       scope: keyword.operator.range.shell.zsh
+    - include: zsh-glob-only-numbers
     - include: line-continuations
-    - include: expansions-variables
-    - include: zsh-glob-numbers
     - match: ''
       fail: zsh-glob-range
 
@@ -677,6 +676,12 @@ contexts:
         1: keyword.operator.arithmetic.shell
         2: constant.numeric.value.shell
 
+  zsh-glob-only-numbers:
+    # use in contexts, which support (decimal) integers, only
+    - match: '[-+]?(?=[\d$])'
+      scope: keyword.operator.arithmetic.shell
+      push: dec-number-body
+
 ###[ ZSH MODIFIERS ]###########################################################
 
   zsh-modifier-end:
@@ -947,7 +952,9 @@ variables:
   shebang_language: \bzsh\b
 
   # Numbers
-  digit: '[\d_]'
+  dec_digit: '[\d_]'
+  hex_digit: '[\h_]'
+  oct_digit: '[0-7_]'
 
   # Parameter expansions
   is_interpolation: (?=\$[({\[{{identifier_char}}{{special_variables}}]|`)
diff --git a/ShellScript/Zsh/tests/syntax_test_scope.zsh b/ShellScript/Zsh/tests/syntax_test_scope.zsh
index 0a210264e9..24c0c47a3a 100644
--- a/ShellScript/Zsh/tests/syntax_test_scope.zsh
+++ b/ShellScript/Zsh/tests/syntax_test_scope.zsh
@@ -3831,31 +3831,37 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #   ^ storage.modifier.glob.shell.zsh
 #    ^ punctuation.definition.modifier.end.shell.zsh
 
-: /(f70?) (f=7?0) (f+?70) (f-703)  # octal acces right specification
+: /(f70?) (f=7?0) (f+?70) (f-7${g}3)  # octal acces right specification
 #   ^ storage.modifier.glob.shell.zsh
-#    ^^^ meta.number.integer.octal.shell constant.numeric.value.shell
+#    ^^ meta.number.integer.octal.shell constant.numeric.value.shell
+#      ^ meta.number.integer.octal.shell constant.other.wildcard.questionmark.shell
 #          ^ storage.modifier.glob.shell.zsh
 #           ^ keyword.operator.logical.shell.zsh
-#            ^^^ meta.number.integer.octal.shell constant.numeric.value.shell
+#            ^ meta.number.integer.octal.shell constant.numeric.value.shell
+#             ^ meta.number.integer.octal.shell constant.other.wildcard.questionmark.shell
+#              ^ meta.number.integer.octal.shell constant.numeric.value.shell
 #                  ^ storage.modifier.glob.shell.zsh
 #                   ^ keyword.operator.logical.shell.zsh
-#                    ^^^ meta.number.integer.octal.shell constant.numeric.value.shell
+#                    ^ meta.number.integer.octal.shell constant.other.wildcard.questionmark.shell
+#                     ^^ meta.number.integer.octal.shell constant.numeric.value.shell
 #                          ^ storage.modifier.glob.shell.zsh
 #                           ^ keyword.operator.logical.shell.zsh
-#                            ^^^ meta.number.integer.octal.shell constant.numeric.value.shell
+#                            ^ meta.number.integer.octal.shell constant.numeric.value.shell
+#                             ^^^^ meta.number.integer.octal.shell meta.interpolation.parameter.shell
+#                                 ^ meta.number.integer.octal.shell constant.numeric.value.shell
 
 : /(f$mode) (f=$mode) (f+$mode) (f-$mode)  # octal acces right specification
 #   ^ storage.modifier.glob.shell.zsh
-#    ^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell
+#    ^^^^^ meta.number.integer.octal.shell meta.interpolation.parameter.shell variable.other.readwrite.shell
 #            ^ storage.modifier.glob.shell.zsh
 #             ^ keyword.operator.logical.shell.zsh
-#              ^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell
+#              ^^^^^ meta.number.integer.octal.shell meta.interpolation.parameter.shell variable.other.readwrite.shell
 #                      ^ storage.modifier.glob.shell.zsh
 #                       ^ keyword.operator.logical.shell.zsh
-#                        ^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell
+#                        ^^^^^ meta.number.integer.octal.shell meta.interpolation.parameter.shell variable.other.readwrite.shell
 #                                ^ storage.modifier.glob.shell.zsh
 #                                 ^ keyword.operator.logical.shell.zsh
-#                                  ^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell
+#                                  ^^^^^ meta.number.integer.octal.shell meta.interpolation.parameter.shell variable.other.readwrite.shell
 
 : /(f) /(f{gu+w,0-rx}) /(f[gu+w,0-rx]) /(f(gu+w,0-rx)) /(f:gu+w,0-rx:)
 #  ^^ meta.modifier.glob.shell.zsh
@@ -4469,7 +4475,7 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                                                              ^^ punctuation.definition.quoted.end.shell
 #                                                                ^ punctuation.definition.modifier.end.shell.zsh
 
-: /([10]) /([1,20]) # specifies which of the matched filenames should be included in the returned list.
+: /([10]) /([1,20]) /([$start,1${end}2]) # specifies which of the matched filenames should be included in the returned list.
 #  ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.range
 #   ^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.range.glob.shell.zsh
 #       ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.range
@@ -4488,6 +4494,17 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #              ^^ meta.number.integer.decimal.shell constant.numeric.value.shell
 #                ^ punctuation.definition.range.end.shell.zsh
 #                 ^ punctuation.definition.modifier.end.shell.zsh
+#                    ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.range
+#                     ^^^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.range.glob.shell.zsh
+#                                      ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.range
+#                     ^ punctuation.definition.range.begin.shell.zsh
+#                      ^^^^^^ meta.number.integer.decimal.shell meta.interpolation.parameter.shell variable.other.readwrite.shell
+#                            ^ punctuation.separator.sequence.shell
+#                             ^ meta.number.integer.decimal.shell constant.numeric.value.shell
+#                              ^^^^^^ meta.number.integer.decimal.shell meta.interpolation.parameter.shell - constant
+#                                    ^ meta.number.integer.decimal.shell constant.numeric.value.shell
+#                                     ^ punctuation.definition.range.end.shell.zsh
+#                                      ^ meta.modifier.glob.shell.zsh punctuation.definition.modifier.end.shell.zsh
 
 : /(P"pre") /(P
) /(P{pre}) /(P[pre]) /(P(pre)) /(P:pre:)
 #  ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted

From a914281e3dd3001fa79ca141a658641877d91425 Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Sun, 11 Aug 2024 11:06:09 +0200
Subject: [PATCH 083/113] [ShellScript] Refine tilde expansions termination

This commit adds escaped slash to tilde-expansion terminators.

Actually Bash and ZSH behave different here.

Bash treats whole string literal, if escaped slash follows tilde.

    `~\/*`  =>  `~/*`

Zsh performs full filename expansion

    `~\/*`  =>  `/home//file1 /home//file2 ...`

This commit treats both equally as Bash behavior required to distinguish
all patterns in all situations for proper tilde expansion in order to decide
whether to highlight subsequent patterns.
---
 ShellScript/Bash.sublime-syntax               |  4 +-
 ShellScript/Bash/tests/syntax_test_scope.bash | 23 +++++--
 ShellScript/Zsh/tests/syntax_test_scope.zsh   | 66 +++++++++++++++++++
 3 files changed, 86 insertions(+), 7 deletions(-)

diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax
index d0066c3432..13c8388f51 100644
--- a/ShellScript/Bash.sublime-syntax
+++ b/ShellScript/Bash.sublime-syntax
@@ -2890,7 +2890,7 @@ contexts:
     - clear_scopes: 1
     - meta_include_prototype: false
     - meta_scope: meta.interpolation.tilde.shell
-    - match: (?:[-+]?\d+|[-+](?![^/{{metachar}}]))
+    - match: (?:[-+]?\d+|[-+](?=\\?/|{{metachar}}))
       scope: variable.language.tilde.shell
       pop: 1
     - match: ''
@@ -2902,7 +2902,7 @@ contexts:
     - meta_content_scope: meta.interpolation.tilde.shell constant.other.username.shell
     - include: line-continuations
     - include: string-interpolations
-    - match: (?=[/{{metachar}}])
+    - match: (?=\\?/|{{metachar}})
       pop: 1
 
 ###[ ILLEGALS ]################################################################
diff --git a/ShellScript/Bash/tests/syntax_test_scope.bash b/ShellScript/Bash/tests/syntax_test_scope.bash
index 0fd117b1dd..c4989f312d 100644
--- a/ShellScript/Bash/tests/syntax_test_scope.bash
+++ b/ShellScript/Bash/tests/syntax_test_scope.bash
@@ -6302,18 +6302,31 @@ a\/b/c/d}
 #        ^ keyword.operator.substitution.shell
 #         ^ punctuation.section.interpolation.end.shell
 
-: ${foo/~\/}
+: ${foo/~\/}   # note: bash replaces `~\/` literal, zsh expanded
 # ^^^^^^^^^^ meta.interpolation.parameter.shell
 # ^ punctuation.definition.variable.shell
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^^^ variable.other.readwrite.shell
 #      ^ keyword.operator.substitution.shell
-#       ^^ meta.string.regexp.shell
-#       ^ variable.language.tilde.shell
-#        ^ constant.other.username.shell
-#         ^ keyword.operator.substitution.shell
+#       ^ meta.interpolation.tilde.shell variable.language.tilde.shell
+#        ^^ constant.character.escape.shell - meta.interpolation.tilde
 #          ^ punctuation.section.interpolation.end.shell
 
+: ${foo/~\/**\//repl}   # note: bash replaces `~\/` literal, zsh expanded
+# ^^^^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell
+# ^ punctuation.definition.variable.shell
+#  ^ punctuation.section.interpolation.begin.shell
+#   ^^^ variable.other.readwrite.shell
+#      ^ keyword.operator.substitution.shell
+#       ^^^^^^^ meta.string.regexp.shell
+#       ^ meta.interpolation.tilde.shell variable.language.tilde.shell
+#        ^^ constant.character.escape.shell - meta.interpolation.tilde
+#          ^^ constant.other.wildcard.asterisk.shell
+#            ^^ constant.character.escape.shell
+#              ^ keyword.operator.substitution.shell - string
+#               ^^^^ meta.string.shell string.unquoted.shell
+#                   ^ punctuation.section.interpolation.end.shell
+
 : ${foo/~+/}
 # ^^^^^^^^^^ meta.interpolation.parameter.shell
 # ^ punctuation.definition.variable.shell
diff --git a/ShellScript/Zsh/tests/syntax_test_scope.zsh b/ShellScript/Zsh/tests/syntax_test_scope.zsh
index 24c0c47a3a..1bd2e580e1 100644
--- a/ShellScript/Zsh/tests/syntax_test_scope.zsh
+++ b/ShellScript/Zsh/tests/syntax_test_scope.zsh
@@ -2321,6 +2321,71 @@ function {
 #            ^ meta.string.regexp.shell string.unquoted.shell
 #             ^ punctuation.section.interpolation.end.shell
 
+################################
+# ${parameter/pattern/word}
+
+# tilde expansion in pattern
+
+: ${foo/~/}
+# ^^^^^^^^^ meta.interpolation.parameter.shell
+# ^ punctuation.definition.variable.shell
+#  ^ punctuation.section.interpolation.begin.shell
+#   ^^^ variable.other.readwrite.shell
+#      ^ keyword.operator.substitution.shell
+#       ^ meta.string.regexp.shell variable.language.tilde.shell
+#        ^ keyword.operator.substitution.shell
+#         ^ punctuation.section.interpolation.end.shell
+
+: ${foo/~\/}   # note: bash replaces `~\/` literal, zsh expanded
+# ^^^^^^^^^^ meta.interpolation.parameter.shell
+# ^ punctuation.definition.variable.shell
+#  ^ punctuation.section.interpolation.begin.shell
+#   ^^^ variable.other.readwrite.shell
+#      ^ keyword.operator.substitution.shell
+#       ^ meta.interpolation.tilde.shell variable.language.tilde.shell
+#        ^^ constant.character.escape.shell - meta.interpolation.tilde
+#          ^ punctuation.section.interpolation.end.shell
+
+: ${foo/~\/**\//repl}   # note: bash replaces `~\/` literal, zsh expanded
+# ^^^^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell
+# ^ punctuation.definition.variable.shell
+#  ^ punctuation.section.interpolation.begin.shell
+#   ^^^ variable.other.readwrite.shell
+#      ^ keyword.operator.substitution.shell
+#       ^^^^^^^ meta.string.regexp.shell
+#       ^ meta.interpolation.tilde.shell variable.language.tilde.shell
+#        ^^ constant.character.escape.shell - meta.interpolation.tilde
+#          ^^ constant.other.wildcard.asterisk.shell
+#            ^^ constant.character.escape.shell
+#              ^ keyword.operator.substitution.shell - string
+#               ^^^^ meta.string.shell string.unquoted.shell
+#                   ^ punctuation.section.interpolation.end.shell
+
+: ${foo/~+/}
+# ^^^^^^^^^^ meta.interpolation.parameter.shell
+# ^ punctuation.definition.variable.shell
+#  ^ punctuation.section.interpolation.begin.shell
+#   ^^^ variable.other.readwrite.shell
+#      ^ keyword.operator.substitution.shell
+#       ^^ meta.string.regexp.shell variable.language.tilde.shell
+#         ^ keyword.operator.substitution.shell
+#          ^ punctuation.section.interpolation.end.shell
+
+: ${foo/~name/~other}
+# ^^^^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell
+# ^ punctuation.definition.variable.shell
+#  ^ punctuation.section.interpolation.begin.shell
+#   ^^^ variable.other.readwrite.shell
+#      ^ keyword.operator.substitution.shell
+#       ^^^^^ meta.string.regexp.shell meta.interpolation.tilde.shell
+#       ^ variable.language.tilde.shell
+#        ^^^^ meta.string.shell constant.other.username.shell
+#            ^ keyword.operator.substitution.shell
+#             ^^^^^^ meta.string.shell string.unquoted.shell - variable
+#                   ^ punctuation.section.interpolation.end.shell
+
+# ZSH operator in front of parameter name
+
 : ${^foo//:/[}]
 # ^^^^^^^^^^^^ meta.interpolation.parameter.shell
 #             ^ - meta.interpolation
@@ -2341,6 +2406,7 @@ function {
 #            ^^ constant.character.escape.shell
 #               ^ punctuation.section.interpolation.end.shell
 
+
 ###############################################################################
 # 14.5 Arithmetic Expansion
 # https://zsh.sourceforge.io/Doc/Release/Expansion.html#Arithmetic-Expansion

From 49517f466679ce1bcd4c901f1ec91d5d168522d0 Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Sun, 11 Aug 2024 11:29:36 +0200
Subject: [PATCH 084/113] [ShellScript] Add a common word-end context

Handle word-termination and line continuation in common re-usable context.
---
 ShellScript/Bash.sublime-syntax             | 28 ++++++++-------------
 ShellScript/Zsh/tests/syntax_test_scope.zsh | 13 ++++++++++
 2 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax
index 13c8388f51..1a84a8bfa8 100644
--- a/ShellScript/Bash.sublime-syntax
+++ b/ShellScript/Bash.sublime-syntax
@@ -933,10 +933,8 @@ contexts:
 
   function-declaration-name-chars:
     - meta_scope: meta.command.shell entity.name.function.shell
-    - include: line-continuations
     - include: literal-unquoted-content
-    - match: '{{word_break}}'
-      pop: 1
+    - include: word-end
 
   cmd-args-end-of-options-then-function-references:
     - match: --{{word_break}}
@@ -952,10 +950,8 @@ contexts:
 
   function-reference-name-chars:
     - meta_scope: meta.command.shell variable.function.shell
-    - include: line-continuations
     - include: literal-unquoted-content
-    - match: '{{word_break}}'
-      pop: 1
+    - include: word-end
 
   cmd-args-end-of-options-then-variables-arithmetic-mappings:
     - match: --{{word_break}}
@@ -1504,8 +1500,7 @@ contexts:
       scope: punctuation.section.group.begin.shell
       push: expression-group-body
     - include: expression-common
-    - match: '{{word_break}}'
-      pop: 1
+    - include: word-end
 
   expression-content:
     # arithmetic expression content without word boundary checks
@@ -1735,10 +1730,8 @@ contexts:
   here-string-body:
     - meta_include_prototype: false
     - meta_content_scope: meta.string.herestring.shell string.unquoted.shell
-    - include: line-continuations
     - include: string-unquoted-content
-    - match: '{{word_break}}'
-      pop: 1
+    - include: word-end
 
   redirections-here-document:
     - match: (\d*)(<<-)\s*(?=["'\\]?({{heredoc}}))
@@ -2056,10 +2049,8 @@ contexts:
   string-path-pattern-body:
     - meta_include_prototype: false
     - meta_scope: meta.string.shell string.unquoted.shell
-    - include: line-continuations
     - include: string-path-pattern-content
-    - match: '{{word_break}}'
-      pop: 1
+    - include: word-end
 
   string-path-pattern-content:
     - match: \$?\"
@@ -2922,10 +2913,8 @@ contexts:
   illegal-word-chars:
     - meta_include_prototype: false
     - meta_scope: invalid.illegal.unexpected-token.shell
-    - include: line-continuations
     - include: literal-unquoted-content
-    - match: '{{word_break}}'
-      pop: 1
+    - include: word-end
 
 ###[ PROTOTYPES ]##############################################################
 
@@ -2951,6 +2940,11 @@ contexts:
     - match: ''
       pop: 1
 
+  word-end:
+    - match: '{{word_break}}'
+      pop: 1
+    - include: line-continuations
+
 ###[ VARIABLES ]###############################################################
 
 variables:
diff --git a/ShellScript/Zsh/tests/syntax_test_scope.zsh b/ShellScript/Zsh/tests/syntax_test_scope.zsh
index 1bd2e580e1..0306b703dc 100644
--- a/ShellScript/Zsh/tests/syntax_test_scope.zsh
+++ b/ShellScript/Zsh/tests/syntax_test_scope.zsh
@@ -4634,6 +4634,19 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                                                          ^ punctuation.definition.quoted.end.shell.zsh
 #                                                           ^ punctuation.definition.modifier.end.shell.zsh
 
+: (/*(/:t)) # qualifiers are valid in groups
+# ^^^ meta.string.shell meta.group.regexp.shell string.unquoted.shell - meta.modifier
+#    ^^^^^ meta.string.shell meta.group.regexp.shell meta.modifier.glob.shell.zsh
+#         ^ meta.string.shell meta.group.regexp.shell string.unquoted.shell - meta.modifier
+# ^ meta.group.regexp.shell string.unquoted.shell punctuation.section.group.begin.regexp.shell
+#   ^ constant.other.wildcard.asterisk.shell
+#    ^ punctuation.definition.modifier.begin.shell.zsh
+#     ^ storage.modifier.glob.shell.zsh
+#      ^ punctuation.separator.sequence.shell.zsh
+#       ^ storage.modifier.glob.shell.zsh
+#        ^ punctuation.definition.modifier.end.shell.zsh
+#         ^ punctuation.section.group.end.regexp.shell
+
 ls /(D)/  # qualifiers are always located at the end
 #  ^^^^^ meta.string.shell string.unquoted.shell
 #   ^^^ meta.group.regexp.shell - meta.modifier

From 6fb46fbccd2e8ea860009dee2c1d0c265abab82e Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Sun, 11 Aug 2024 12:15:33 +0200
Subject: [PATCH 085/113] [ShellScript] Fix redirection stdio file descriptor

---
 ShellScript/Bash.sublime-syntax               | 12 +++++-------
 ShellScript/Bash/tests/syntax_test_scope.bash | 14 ++++++++++----
 ShellScript/Zsh/tests/syntax_test_scope.zsh   | 11 +++++++++++
 3 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax
index 1a84a8bfa8..6aba2344f4 100644
--- a/ShellScript/Bash.sublime-syntax
+++ b/ShellScript/Bash.sublime-syntax
@@ -1707,13 +1707,11 @@ contexts:
 
   redirection-descriptor:
     - meta_include_prototype: false
-    - match: (?:(\d+)(-?)|(-)){{word_break}}
-      captures:
-        1: meta.file-descriptor.shell
-           meta.number.integer.decimal.shell
-           constant.numeric.value.shell
-        2: punctuation.terminator.file-descriptor.shell
-        3: punctuation.terminator.file-descriptor.shell
+    - match: \d+{{word_break}}
+      scope: meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell
+      pop: 1
+    - match: '[-p]{{word_break}}'
+      scope: meta.file-descriptor.shell variable.language.stdio.shell
       pop: 1
     - include: eoc-pop
     - include: string-path-pattern
diff --git a/ShellScript/Bash/tests/syntax_test_scope.bash b/ShellScript/Bash/tests/syntax_test_scope.bash
index c4989f312d..c791aa84a8 100644
--- a/ShellScript/Bash/tests/syntax_test_scope.bash
+++ b/ShellScript/Bash/tests/syntax_test_scope.bash
@@ -8939,10 +8939,16 @@ echo '([^.[:space:]]+)   Class::method()' # colon not scoped as path separator
 # ^ meta.redirection.shell keyword.operator.assignment.redirection.shell
 #  ^ - meta.redirection
 
-  >-
+  >- # standard output/input
 # ^^ meta.redirection.shell
 # ^ keyword.operator.assignment.redirection.shell
-#  ^ punctuation.terminator.file-descriptor.shell
+#  ^ variable.language.stdio.shell
+#   ^ - meta.redirection
+
+  >p # coproc output/input
+# ^^ meta.redirection.shell
+# ^ keyword.operator.assignment.redirection.shell
+#  ^ variable.language.stdio.shell
 #   ^ - meta.redirection
 
   >2
@@ -9042,7 +9048,7 @@ foo 2>&1
 
 foo 2>&-
 #   ^^^^ meta.redirection.shell
-#      ^ punctuation.terminator.file-descriptor.shell
+#      ^ variable.language.stdio.shell
 
 foo | bar 2>&1
 #         ^^^^ meta.redirection.shell
@@ -10290,7 +10296,7 @@ exec 3<&-
 #^^^ support.function.shell
 #    ^ constant.numeric.value.shell
 #     ^^ keyword.operator.assignment.redirection.shell
-#       ^ punctuation.terminator.file-descriptor.shell
+#       ^ variable.language.stdio.shell
 
 exec -- foo bar
 # <- meta.function-call.identifier.shell support.function.shell
diff --git a/ShellScript/Zsh/tests/syntax_test_scope.zsh b/ShellScript/Zsh/tests/syntax_test_scope.zsh
index 0306b703dc..48649e7533 100644
--- a/ShellScript/Zsh/tests/syntax_test_scope.zsh
+++ b/ShellScript/Zsh/tests/syntax_test_scope.zsh
@@ -650,8 +650,19 @@ case $word {
 : <& - >& -
 # ^^^^ meta.redirection.shell
 # ^^ keyword.operator.assignment.redirection.shell
+#    ^ meta.file-descriptor.shell variable.language.stdio.shell
 #      ^^^^ meta.redirection.shell
 #      ^^ keyword.operator.assignment.redirection.shell
+#         ^ meta.file-descriptor.shell variable.language.stdio.shell
+
+# The input/output from/to the coprocess is moved to the standard input/output.
+: <& p >& p
+# ^^^^ meta.redirection.shell
+# ^^ keyword.operator.assignment.redirection.shell
+#    ^ meta.file-descriptor.shell variable.language.stdio.shell
+#      ^^^^ meta.redirection.shell
+#      ^^ keyword.operator.assignment.redirection.shell
+#         ^ meta.file-descriptor.shell variable.language.stdio.shell
 
 # Redirects both standard output and standard error (file descriptor 2) in the
 # manner of ‘>| word’.

From 00c7f84055f9d0bcf16efa8efd5d63d4417f1505 Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Sun, 11 Aug 2024 12:34:55 +0200
Subject: [PATCH 086/113] [ShellScript] Special scope for /dev/null

---
 ShellScript/Bash.sublime-syntax               | 11 +++++++++++
 ShellScript/Bash/tests/syntax_test_scope.bash |  7 +++++++
 2 files changed, 18 insertions(+)

diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax
index 6aba2344f4..dcfc362ed9 100644
--- a/ShellScript/Bash.sublime-syntax
+++ b/ShellScript/Bash.sublime-syntax
@@ -2033,12 +2033,23 @@ contexts:
 ###[ STRING PATH PATTERN MATCHING ]############################################
 
   string-path-patterns:
+    - match: (/)dev(/)null{{word_break}}
+      scope: meta.path.shell constant.language.null.shell
+      captures:
+        1: punctuation.separator.path.shell
+        2: punctuation.separator.path.shell
     - match: '{{word_begin}}'
       push:
         - string-path-pattern-body
         - maybe-tilde-interpolation
 
   string-path-pattern:
+    - match: (/)dev(/)null{{word_break}}
+      scope: meta.path.shell constant.language.null.shell
+      captures:
+        1: punctuation.separator.path.shell
+        2: punctuation.separator.path.shell
+      pop: 1
     - match: '{{word_begin}}'
       set:
         - string-path-pattern-body
diff --git a/ShellScript/Bash/tests/syntax_test_scope.bash b/ShellScript/Bash/tests/syntax_test_scope.bash
index c791aa84a8..5bbcbc4844 100644
--- a/ShellScript/Bash/tests/syntax_test_scope.bash
+++ b/ShellScript/Bash/tests/syntax_test_scope.bash
@@ -8957,6 +8957,13 @@ echo '([^.[:space:]]+)   Class::method()' # colon not scoped as path separator
 #  ^ constant.numeric.value.shell
 #   ^ - meta.redirection
 
+  > /dev/null
+# ^^^^^^^^^^^ meta.redirection.shell
+# ^ keyword.operator.assignment.redirection.shell
+#   ^^^^^^^^^ meta.path.shell constant.language.null.shell
+#   ^ punctuation.separator.path.shell
+#       ^ punctuation.separator.path.shell
+
   > out~put-
 # ^^ meta.redirection.shell - meta.command
 #   ^^^^^^^^ meta.redirection.shell

From 479b7295e983bd5a8596b71ca73b243c55259cae Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Sun, 11 Aug 2024 15:56:39 +0200
Subject: [PATCH 087/113] [ShellScript] Higher priority for inout redirections

Make sure not to miss <>path over ])(\()
diff --git a/ShellScript/Bash/tests/syntax_test_scope.bash b/ShellScript/Bash/tests/syntax_test_scope.bash
index 5bbcbc4844..fa5645071e 100644
--- a/ShellScript/Bash/tests/syntax_test_scope.bash
+++ b/ShellScript/Bash/tests/syntax_test_scope.bash
@@ -8935,75 +8935,136 @@ echo '([^.[:space:]]+)   Class::method()' # colon not scoped as path separator
 # https://www.gnu.org/software/bash/manual/bash.html#Redirections             #
 ###############################################################################
 
-  >
+# Open file word for reading as standard input. It is an error to open a file
+# in this fashion if it does not exist.
+
+: <
+# ^ meta.redirection.shell keyword.operator.assignment.redirection.shell
+#  ^ - meta.redirection
+
+: <- # standard output/input
+# ^^ meta.redirection.shell
+# ^ keyword.operator.assignment.redirection.shell
+#  ^ variable.language.stdio.shell
+#   ^ - meta.redirection
+
+: 

+# ^^ meta.redirection.shell keyword.operator.assignment.redirection.shell +# ^ - meta.redirection + +: <>- # standard output/input +# ^^^ meta.redirection.shell +# ^^ keyword.operator.assignment.redirection.shell +# ^ variable.language.stdio.shell +# ^ - meta.redirection + +: <>p # coproc output/input +# ^^^ meta.redirection.shell +# ^^ keyword.operator.assignment.redirection.shell +# ^ variable.language.stdio.shell +# ^ - meta.redirection + +: <>2 +# ^^^ meta.redirection.shell +# ^^ keyword.operator.assignment.redirection.shell +# ^ constant.numeric.value.shell +# ^ - meta.redirection + +: <> word +# ^^^^^^^ meta.redirection.shell +# ^^ keyword.operator.assignment.redirection.shell +# ^^^^ meta.string.shell string.unquoted.shell + +# Open file word for writing as standard output. If the file does not exist +# then it is created. + +: > # ^ meta.redirection.shell keyword.operator.assignment.redirection.shell # ^ - meta.redirection - >- # standard output/input +: >- # standard output/input # ^^ meta.redirection.shell # ^ keyword.operator.assignment.redirection.shell # ^ variable.language.stdio.shell # ^ - meta.redirection - >p # coproc output/input +: >p # coproc output/input # ^^ meta.redirection.shell # ^ keyword.operator.assignment.redirection.shell # ^ variable.language.stdio.shell # ^ - meta.redirection - >2 +: >2 # ^^ meta.redirection.shell # ^ keyword.operator.assignment.redirection.shell # ^ constant.numeric.value.shell # ^ - meta.redirection - > /dev/null +: > word >| word >! word +# ^^^^^^ meta.redirection.shell +# ^ keyword.operator.assignment.redirection.shell +# ^^^^ meta.string.shell string.unquoted.shell +# ^ - meta.redirection +# ^^^^^^^ meta.redirection.shell +# ^^ keyword.operator.assignment.redirection.shell +# ^^^^ meta.string.shell string.unquoted.shell +# ^ - meta.redirection +# ^^^^^^^ meta.redirection.shell +# ^^ keyword.operator.assignment.redirection.shell +# ^^^^ meta.string.shell string.unquoted.shell +# ^ - meta.redirection + +: > /dev/null # ^^^^^^^^^^^ meta.redirection.shell # ^ keyword.operator.assignment.redirection.shell # ^^^^^^^^^ meta.path.shell constant.language.null.shell # ^ punctuation.separator.path.shell # ^ punctuation.separator.path.shell +# ^ - meta.redirection - > out~put- -# ^^ meta.redirection.shell - meta.command -# ^^^^^^^^ meta.redirection.shell +: > out~put- +# ^^^^^^^^^^ meta.redirection.shell # ^ keyword.operator.assignment.redirection.shell +# ^^^^^^^^ meta.string.shell string.unquoted.shell # ^ - variable # ^ - punctuation +# ^ - meta.redirection - > ~/.local/file -# ^^ meta.redirection.shell - meta.command +: > ~/.local/file +# ^^ meta.redirection.shell - meta.string # ^ meta.redirection.shell meta.string.shell meta.interpolation.tilde.shell # ^^^^^^^^^^^^ meta.redirection.shell meta.string.shell string.unquoted.shell - meta.interpolation # ^ keyword.operator.assignment.redirection.shell # ^ variable.language.tilde.shell - > "~/.local/file" -# ^^ meta.redirection.shell - meta.command +: > "~/.local/file" +# ^^ meta.redirection.shell - meta.string # ^^^^^^^^^^^^^^^ meta.redirection.shell meta.string.shell string.quoted.double.shell # ^ keyword.operator.assignment.redirection.shell # ^ punctuation.definition.string.begin.shell # ^ - variable.language # ^ punctuation.definition.string.end.shell - > "~/.local/file" -# ^^ meta.redirection.shell - meta.command -# ^^^^^^^^^^^^^^^ meta.redirection.shell meta.string.shell string.quoted.double.shell -# ^ keyword.operator.assignment.redirection.shell -# ^ punctuation.definition.string.begin.shell -# ^ - variable.language -# ^ punctuation.definition.string.end.shell - -# Open file word for writing as standard output. If the file does not exist -# then it is created. -: > word >| word >! word -# ^^^^^^ meta.redirection.shell -# ^ keyword.operator.assignment.redirection.shell -# ^^^^^^^ meta.redirection.shell -# ^^ keyword.operator.assignment.redirection.shell -# ^^^^^^^ meta.redirection.shell -# ^^ keyword.operator.assignment.redirection.shell - # Open file word for writing in append mode as standard output. If the file # does not exist, and the CLOBBER and APPEND_CREATE options are both unset, # this causes an error; otherwise, the file is created. diff --git a/ShellScript/Zsh/tests/syntax_test_scope.zsh b/ShellScript/Zsh/tests/syntax_test_scope.zsh index 48649e7533..0608432186 100644 --- a/ShellScript/Zsh/tests/syntax_test_scope.zsh +++ b/ShellScript/Zsh/tests/syntax_test_scope.zsh @@ -608,25 +608,99 @@ case $word { # Open file word for reading as standard input. It is an error to open a file # in this fashion if it does not exist. + +: < +# ^ meta.redirection.shell keyword.operator.assignment.redirection.shell +# ^ - meta.redirection + +: <- # standard output/input +# ^^ meta.redirection.shell +# ^ keyword.operator.assignment.redirection.shell +# ^ variable.language.stdio.shell +# ^ - meta.redirection + +:

+# ^^ meta.redirection.shell keyword.operator.assignment.redirection.shell +# ^ - meta.redirection + +: <>- # standard output/input +# ^^^ meta.redirection.shell +# ^^ keyword.operator.assignment.redirection.shell +# ^ variable.language.stdio.shell +# ^ - meta.redirection + +: <>p # coproc output/input +# ^^^ meta.redirection.shell +# ^^ keyword.operator.assignment.redirection.shell +# ^ variable.language.stdio.shell +# ^ - meta.redirection + +: <>2 +# ^^^ meta.redirection.shell +# ^^ keyword.operator.assignment.redirection.shell +# ^ constant.numeric.value.shell +# ^ - meta.redirection + : <> word # ^^^^^^^ meta.redirection.shell # ^^ keyword.operator.assignment.redirection.shell +# ^^^^ meta.string.shell string.unquoted.shell # Open file word for writing as standard output. If the file does not exist # then it is created. + +: > +# ^ meta.redirection.shell keyword.operator.assignment.redirection.shell +# ^ - meta.redirection + +: >- # standard output/input +# ^^ meta.redirection.shell +# ^ keyword.operator.assignment.redirection.shell +# ^ variable.language.stdio.shell +# ^ - meta.redirection + +: >p # coproc output/input +# ^^ meta.redirection.shell +# ^ keyword.operator.assignment.redirection.shell +# ^ variable.language.stdio.shell +# ^ - meta.redirection + +: >2 +# ^^ meta.redirection.shell +# ^ keyword.operator.assignment.redirection.shell +# ^ constant.numeric.value.shell +# ^ - meta.redirection + : > word >| word >! word # ^^^^^^ meta.redirection.shell # ^ keyword.operator.assignment.redirection.shell +# ^^^^ meta.string.shell string.unquoted.shell # ^^^^^^^ meta.redirection.shell # ^^ keyword.operator.assignment.redirection.shell +# ^^^^ meta.string.shell string.unquoted.shell # ^^^^^^^ meta.redirection.shell # ^^ keyword.operator.assignment.redirection.shell +# ^^^^ meta.string.shell string.unquoted.shell # Open file word for writing in append mode as standard output. If the file # does not exist, and the CLOBBER and APPEND_CREATE options are both unset, From ec1e732f26ce83c85aa43bcb190b7594ab7ee473 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 11 Aug 2024 16:03:58 +0200 Subject: [PATCH 088/113] [ShellScript] Fix range vs. redirection in parameter expansions This commit separates zsh glob range (`<1-10>`) patterns into those, which... 1. are used in contexts without redirection support, such as parameter expansion patterns. Incomplete or malformed ranges are scoped literal in parameter expansions. 2. need distinction between redirections and glob ranges. Word related contexts are popped off stack before metachar `<`. Hence each glob range starts a new word. Range detection is restricted to require exactly `< number - number >`, to avoid false positives, especially with stdio redirections like `< -`. In ambiguous situation of `<->`, a range is preferred. This change also fixes scoping of leading and trailing numbers, which are now scoped `meta.string`. --- ShellScript/Zsh.sublime-syntax | 145 ++++-- ShellScript/Zsh/tests/syntax_test_scope.zsh | 530 +++++++++++++++++++- 2 files changed, 608 insertions(+), 67 deletions(-) diff --git a/ShellScript/Zsh.sublime-syntax b/ShellScript/Zsh.sublime-syntax index bd967e93ea..a02703fb61 100644 --- a/ShellScript/Zsh.sublime-syntax +++ b/ShellScript/Zsh.sublime-syntax @@ -268,17 +268,66 @@ contexts: ###[ REDIRECTIONS AND HEREDOCS ]############################################### redirections-input: - # not looking like a number range - - match: (\d*)(<(?:&|(?!(?:\{.*?\}|\S)*>))) + # maybe a zsh glob range, starting a pattern or a input redirection + - match: (?=\d*<) + branch_point: zsh-glob-range + branch: + - zsh-glob-range-begin + - zsh-redirection-input + + zsh-redirection-input: + - meta_include_prototype: false + - match: (\d*)(<&?) captures: 1: meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell 2: keyword.operator.assignment.redirection.shell - push: + set: - redirection-meta - redirection-descriptor + zsh-glob-range-begin: + - meta_include_prototype: false + - match: \<(?!&) + scope: punctuation.definition.range.begin.shell.zsh + set: + - string-path-pattern-body + - zsh-glob-range-end + - zsh-glob-range-number + - zsh-glob-range-operator + - zsh-glob-range-number + - match: \d+ + scope: meta.string.shell string.unquoted.shell + - include: zsh-glob-range-fail + + zsh-glob-range-end: + - clear_scopes: 1 # clear string scope + - meta_scope: meta.range.shell.zsh + - match: \> + scope: punctuation.definition.range.end.shell.zsh + pop: 1 + - include: zsh-glob-range-fail + + zsh-glob-range-number: + - match: (?=[\d$]) + scope: keyword.operator.arithmetic.shell + set: dec-number-body + - include: line-continuations + - include: immediately-pop + + zsh-glob-range-operator: + # range operator is crucial + - match: \- + scope: keyword.operator.range.shell.zsh + pop: 1 + - include: zsh-glob-range-fail + + zsh-glob-range-fail: + - include: line-continuations + - match: '' + fail: zsh-glob-range + ###[ LITERALS ]################################################################ numbers: @@ -332,7 +381,6 @@ contexts: pattern-common: - meta_prepend: true - include: zsh-glob-operators - - include: zsh-glob-ranges ###[ ARITHMETIC EXPANSIONS ]################################################### @@ -430,11 +478,12 @@ contexts: - match: \( scope: punctuation.section.group.begin.regexp.shell push: expansion-parameter-pattern-group-body - - zsh-parameter-subscription: - - meta_include_prototype: false - - meta_scope: meta.interpolation.parameter.shell - - include: variable-subscription + # a pattern range `<1-20>` or literal `<`, but no redirection + - match: (?=<) + branch_point: zsh-parameter-pattern-range + branch: + - zsh-parameter-pattern-range-begin + - immediately-pop zsh-parameter-flags: # 14.3.1 Parameter Expansion Flags @@ -468,6 +517,41 @@ contexts: - match: '[-~#%*@0ABCDEFLMNOPQRSTUVWXabcefikmnopqtuvwz]' scope: storage.modifier.expansion.flag.shell.zsh + zsh-parameter-pattern-range-begin: + - clear_scopes: 1 + - meta_include_prototype: false + - match: \< + scope: punctuation.definition.range.begin.shell.zsh + push: + - zsh-parameter-pattern-range-end + - zsh-glob-range-number + - zsh-parameter-pattern-range-operator + - zsh-glob-range-number + + zsh-parameter-pattern-range-end: + - meta_scope: meta.range.shell.zsh + - match: \> + scope: punctuation.definition.range.end.shell.zsh + pop: 2 + - include: zsh-parameter-pattern-range-fail + + zsh-parameter-pattern-range-fail: + - include: line-continuations + - match: '' + fail: zsh-parameter-pattern-range + + zsh-parameter-pattern-range-operator: + # range operator is crucial + - match: \- + scope: keyword.operator.range.shell.zsh + pop: 1 + - include: zsh-parameter-pattern-range-fail + + zsh-parameter-subscription: + - meta_include_prototype: false + - meta_scope: meta.interpolation.parameter.shell + - include: variable-subscription + ###[ TILDE EXPANSIONS ]######################################################## tilde-interpolation: @@ -635,39 +719,10 @@ contexts: scope: constant.other.wildcard.questionmark.shell - include: oct-number-body -###[ ZSH GLOB RANGES ]######################################################### - - zsh-glob-ranges: - - match: (?=<[^<&]) - branch_point: zsh-glob-range - branch: - - zsh-glob-range-begin - - zsh-glob-range-fallback - - zsh-glob-range-begin: - - meta_include_prototype: false - - match: \< - scope: punctuation.definition.range.begin.shell.zsh - set: zsh-glob-range-body - - zsh-glob-range-body: - - meta_scope: meta.range.shell.zsh - - match: \> - scope: punctuation.definition.range.end.shell.zsh - pop: 1 - - match: \- - scope: keyword.operator.range.shell.zsh - - include: zsh-glob-only-numbers - - include: line-continuations - - match: '' - fail: zsh-glob-range - - zsh-glob-range-fallback: - - meta_include_prototype: false - # input redirection - - match: < - scope: keyword.operator.assignment.redirection.shell - set: redirection-descriptor + zsh-glob-only-numbers: + - match: '[-+]?(?=[\d$])' + scope: keyword.operator.arithmetic.shell + push: dec-number-body zsh-glob-numbers: - match: ([-+]?)(\d+) @@ -676,12 +731,6 @@ contexts: 1: keyword.operator.arithmetic.shell 2: constant.numeric.value.shell - zsh-glob-only-numbers: - # use in contexts, which support (decimal) integers, only - - match: '[-+]?(?=[\d$])' - scope: keyword.operator.arithmetic.shell - push: dec-number-body - ###[ ZSH MODIFIERS ]########################################################### zsh-modifier-end: diff --git a/ShellScript/Zsh/tests/syntax_test_scope.zsh b/ShellScript/Zsh/tests/syntax_test_scope.zsh index 0608432186..c628c85066 100644 --- a/ShellScript/Zsh/tests/syntax_test_scope.zsh +++ b/ShellScript/Zsh/tests/syntax_test_scope.zsh @@ -2409,6 +2409,450 @@ function { ################################ # ${parameter/pattern/word} +: ${@/bar/baz} +# ^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.special.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.regexp.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta + +: ${*/bar/baz} +# ^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.special.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.regexp.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta + +: ${#/bar/baz} +# ^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.special.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.regexp.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta + +: ${?/bar/baz} +# ^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.special.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.regexp.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta + +: ${$/bar/baz} +# ^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.special.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.regexp.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta + +: ${-/bar/baz} +# ^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.special.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.regexp.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta + +: ${!/bar/baz} +# ^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.special.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.regexp.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta + +: ${_/bar/baz} +# ^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ variable.language.builtin.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.regexp.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta + +: ${foo/bar/baz} +# ^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.regexp.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta + +: ${foo@/bar/baz} +# ^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ variable.language.special.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.regexp.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta + +: ${foo*/bar/baz} +# ^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ variable.language.special.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.regexp.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta + +: ${foo[@]/bar/baz} +# ^^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.item-access.begin.shell +# ^ variable.language.array.shell +# ^ punctuation.section.item-access.end.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.regexp.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta + +: ${foo[*]/bar/baz} +# ^^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^ punctuation.section.item-access.begin.shell +# ^ variable.language.array.shell +# ^ punctuation.section.item-access.end.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.regexp.shell +# ^ keyword.operator.substitution.shell +# ^^^ meta.string.shell string.unquoted.shell +# ^ punctuation.section.interpolation.end.shell +# ^ - meta + +# pattern switches + +: ${foo/#bar/baz} +# ^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^^ keyword.operator.substitution.shell +# ^ keyword.operator.substitution.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo/%bar/baz} +# ^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^^ keyword.operator.substitution.shell +# ^ keyword.operator.substitution.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//bar/baz} +# ^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^^ keyword.operator.substitution.shell +# ^ keyword.operator.substitution.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//@/} +# ^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ - meta.interpolation +# ^^ keyword.operator.substitution.shell +# ^ - keyword - variable +# ^ keyword.operator.substitution.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//*/} +# ^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ - meta.interpolation +# ^^ keyword.operator.substitution.shell +# ^ constant.other.wildcard.asterisk.shell +# ^ keyword.operator.substitution.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//#/} +# ^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ - meta.interpolation +# ^^ keyword.operator.substitution.shell +# ^ keyword.operator.quantifier.regexp.shell.zsh +# ^ keyword.operator.substitution.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//?/} +# ^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ - meta.interpolation +# ^^ keyword.operator.substitution.shell +# ^ constant.other.wildcard.questionmark.shell +# ^ keyword.operator.substitution.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//-/} +# ^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ - meta.interpolation +# ^^ keyword.operator.substitution.shell +# ^ - keyword - variable +# ^ keyword.operator.substitution.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//!/} +# ^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ - meta.interpolation +# ^^ keyword.operator.substitution.shell +# ^ - keyword - variable +# ^ keyword.operator.substitution.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//_/} +# ^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ - meta.interpolation +# ^^ keyword.operator.substitution.shell +# ^ - keyword - variable +# ^ keyword.operator.substitution.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//%/} +# ^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ - meta.interpolation +# ^^ keyword.operator.substitution.shell +# ^ - keyword - variable +# ^ keyword.operator.substitution.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//:/} +# ^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ - meta.interpolation +# ^^ keyword.operator.substitution.shell +# ^ - keyword +# ^ keyword.operator.substitution.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//a\/b/c/d} +# ^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^ - meta.interpolation +# ^^ keyword.operator.substitution.shell +# ^^ constant.character.escape +# ^ keyword.operator.substitution.shell +# ^ - keyword.operator +# ^ punctuation.section.interpolation.end.shell + +: ${foo//\ +a\/b/c/d} +# <- meta.interpolation.parameter.shell meta.string.regexp.shell +#^^^ meta.interpolation.parameter.shell meta.string.regexp.shell +# ^ meta.interpolation.parameter.shell - meta.interpolation.parameter.shell meta.string +# ^^^ meta.interpolation.parameter.shell meta.string.shell +# ^ meta.interpolation.parameter.shell - meta.interpolation.parameter.shell meta.string +#^^ constant.character.escape.shell +# ^ keyword.operator.substitution.shell +# ^ - keyword +# ^ punctuation.section.interpolation.end.shell + +# expansion termination within patterns or words + +: ${foo//}/foo} +# ^^^^^^^^ meta.interpolation.parameter.shell +# ^^^^^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^ keyword.operator.substitution.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//\}/foo} +# ^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^ keyword.operator.substitution.shell +# ^^ constant.character.escape.shell +# ^ keyword.operator.substitution.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//:/[}] +# ^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^^^ - meta.string.regexp - meta.set +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^^ keyword.operator.substitution.shell +# ^ keyword.operator.substitution.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//:/[\}]} +# ^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^^ keyword.operator.substitution.shell +# ^ keyword.operator.substitution.shell +# ^^^^ - meta.string.regexp - meta.set - punctuation +# ^^ constant.character.escape.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//[a-/\}} # incomplete charset +# ^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^^ keyword.operator.substitution.shell +# ^^^ - meta.set - punctuation +# ^ keyword.operator.substitution.shell +# ^^ constant.character.escape.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//+([a-:/\}} # incomplete charset in incomplete group +# ^^^^^^^^ meta.interpolation.parameter.shell - meta.group +# ^^^^^^^^ meta.interpolation.parameter.shell meta.group.regexp.shell +# ^ meta.interpolation.parameter.shell - meta.group +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^^ keyword.operator.substitution.shell +# ^ - keyword.operator +# ^ punctuation.section.group.begin.regexp.shell +# ^^^^^ - constant - punctuation +# ^^ constant.character.escape.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//+([a|&)/\}} # incomplete charset in group +# ^^^^^^^^ meta.interpolation.parameter.shell - meta.group +# ^^^^^^ meta.interpolation.parameter.shell meta.group.regexp.shell +# ^^^^ meta.interpolation.parameter.shell - meta.group +# ^ - meta.interpolation +# ^ punctuation.definition.variable.shell +# ^ punctuation.section.interpolation.begin.shell +# ^^^ variable.other.readwrite.shell +# ^^ keyword.operator.substitution.shell +# ^ - keyword.operator +# ^ punctuation.section.group.begin.regexp.shell +# ^^^^ - constant - punctuation +# ^ keyword.operator.logical.regexp.shell +# ^ punctuation.section.group.end.regexp.shell +# ^ keyword.operator.substitution.shell +# ^^ constant.character.escape.shell +# ^ punctuation.section.interpolation.end.shell + +: ${foo//[abc[]/x} # `[` has no meaing within charsets +# ^^^^^^^ meta.interpolation.parameter.shell - meta.string meta.set +# ^^^^^^ meta.interpolation.parameter.shell meta.string.regexp.shell meta.set.regexp.shell +# ^^^ meta.interpolation.parameter.shell - meta.string meta.set +# ^^ keyword.operator.substitution.shell +# ^ punctuation.definition.set.begin.regexp.shell +# ^ - keyword - punctuation +# ^ punctuation.definition.set.end.regexp.shell +# ^ keyword.operator.substitution.shell +# ^ punctuation.section.interpolation.end.shell + +: ${var//f|o/b|ar} # `|` has no meaing in patterns or replacement strings +# ^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^^ keyword.operator.substitution.shell +# ^^^ meta.string.regexp.shell string.unquoted.shell - keyword - punctuation +# ^ keyword.operator.substitution.shell +# ^^^^ meta.string.shell string.unquoted.shell - keyword - punctuation +# ^ punctuation.section.interpolation.end.shell + +: ${var//f&o/b&ar} # `&` has no meaing in patterns or replacement strings +# ^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^^ keyword.operator.substitution.shell +# ^^^ meta.string.regexp.shell string.unquoted.shell - keyword - punctuation +# ^ keyword.operator.substitution.shell +# ^^^^ meta.string.shell string.unquoted.shell - keyword - punctuation +# ^ punctuation.section.interpolation.end.shell + +: ${var//f>o/b>ar} # `>` has no meaing in patterns or replacement strings +# ^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell +# ^^ keyword.operator.substitution.shell +# ^^^ meta.string.regexp.shell string.unquoted.shell - keyword - punctuation +# ^ keyword.operator.substitution.shell +# ^^^^ meta.string.shell string.unquoted.shell - keyword - punctuation +# ^ punctuation.section.interpolation.end.shell + +: ${var//f # Matches numbers from calculated start to end -# ^ meta.range.shell.zsh punctuation.definition.range.begin.shell.zsh -# ^^^^^^^^^^^^^^^^^^^ meta.range.shell.zsh meta.interpolation.parameter.shell -# ^ meta.range.shell.zsh keyword.operator.range.shell.zsh -# ^^^^^^^^^^^^^^^^^^^^ meta.range.shell.zsh meta.interpolation.parameter.shell -# ^ meta.range.shell.zsh punctuation.definition.range.end.shell.zsh +# ^ meta.range.shell.zsh punctuation.definition.range.begin.shell.zsh - string +# ^^^^^^^^^^^^^^^^^^^ meta.range.shell.zsh meta.interpolation.parameter.shell - string +# ^ meta.range.shell.zsh keyword.operator.range.shell.zsh - string +# ^^^^^^^^^^^^^^^^^^^^ meta.range.shell.zsh meta.interpolation.parameter.shell - string +# ^ meta.range.shell.zsh punctuation.definition.range.end.shell.zsh - string -: <${start##<1-5>0}-> +: <${start##<1-5>0<1-}-> # ^ meta.range.shell.zsh - meta.interpolation - meta.range meta.range # ^^^^^^^^^ meta.range.shell.zsh meta.interpolation.parameter.shell - meta.range meta.range -# ^^^^^ meta.range.shell.zsh meta.interpolation.parameter.shell meta.string.regexp.shell meta.range.shell.zsh -# ^^ meta.range.shell.zsh meta.interpolation.parameter.shell - meta.range meta.range -# ^^ meta.range.shell.zsh -# ^ - meta.range +# ^^^^^ meta.range.shell.zsh meta.interpolation.parameter.shell meta.string.regexp.shell meta.range.shell.zsh - string +# ^^^^^ meta.range.shell.zsh meta.interpolation.parameter.shell - meta.range meta.range +# ^ - keyword - punctuation +# ^^ meta.range.shell.zsh +# ^ - meta.range + +: <-${start/fo>bar/bz}> +# ^^ meta.range.shell.zsh - meta.interpolation - meta.range meta.range +# ^^^^^^^^^^^ meta.range.shell.zsh meta.interpolation.parameter.shell - meta.range meta.range +# ^^^ meta.range.shell.zsh meta.interpolation.parameter.shell meta.string.regexp.shell meta.range.shell.zsh - string +# ^^^^ meta.range.shell.zsh meta.number.integer.decimal.shell meta.interpolation.parameter.shell meta.range.shell.zsh meta.number.integer.decimal.shell meta.interpolation.parameter.shell variable.other.readwrite.shell - string +# ^ meta.range.shell.zsh meta.number.integer.decimal.shell meta.interpolation.parameter.shell meta.string.regexp.shell meta.range.shell.zsh - string +# ^^^^^^^^^^^^ meta.range.shell.zsh meta.interpolation.parameter.shell - meta.range meta.range +# ^ meta.range.shell.zsh - meta.interpolation - meta.range meta.range +# ^ - meta.range +# ^ punctuation.definition.range.begin.shell.zsh +# ^ keyword.operator.range.shell.zsh +# ^ keyword.operator.substitution.shell +# ^ - keyword - punctuation +# ^ punctuation.definition.range.begin.shell.zsh +# ^ keyword.operator.range.shell.zsh +# ^ punctuation.definition.range.end.shell.zsh +# ^ - keyword - punctuation +# ^ keyword.operator.substitution.shell +# ^ - keyword - punctuation +# ^ - keyword - punctuation +# ^ punctuation.definition.range.end.shell.zsh : foo<5-21> foo<5-21>bar <5-21>bar -# ^^^^^^ meta.range.shell.zsh -# ^^^^^^ meta.range.shell.zsh -# ^^^^^^ meta.range.shell.zsh - -: 1<1-5> 1<1-5>0 <1-5>0 -# ^^^^^ meta.range.shell.zsh -# ^^^^^ meta.range.shell.zsh -# ^^^^^ meta.range.shell.zsh +# ^^^ meta.string.shell string.unquoted.shell +# ^^^^^^ meta.string.shell meta.range.shell.zsh - string +# ^ - meta.range meta.string - string +# ^^^ meta.string.shell string.unquoted.shell +# ^^^^^^ meta.string.shell meta.range.shell.zsh - string +# ^^^ meta.string.shell string.unquoted.shell +# ^ - meta.range meta.string - string +# ^^^^^^ meta.string.shell meta.range.shell.zsh - string +# ^^^ meta.string.shell string.unquoted.shell + +: 1<1-5> 1<1-5>0 <1-5>0 # not numbers, but a patterns +# ^ meta.string.shell string.unquoted.shell +# ^^^^^ meta.string.shell meta.range.shell.zsh - string +# ^ - meta.range meta.string - string +# ^ meta.string.shell string.unquoted.shell +# ^^^^^ meta.string.shell meta.range.shell.zsh - string +# ^ meta.string.shell string.unquoted.shell +# ^ - meta.range meta.string - string +# ^^^^^ meta.string.shell meta.range.shell.zsh - string +# ^ meta.string.shell string.unquoted.shell + +: 'foo<5-21>bar' +# ^^^^^^^^^^^^^^ meta.string.shell string.quoted.single.shell - meta.redirection - meta.range + +: "foo<5-21>bar" +# ^^^^^^^^^^^^^^ meta.string.shell string.quoted.double.shell - meta.redirection - meta.range : thisoutput -# ^^^^^^^ - meta.range +# ^^^^ meta.string.shell string.unquoted.shell +# ^^^^^^^^^^^^^ meta.redirection.shell - meta.range # ^ keyword.operator.assignment.redirection.shell # ^ keyword.operator.assignment.redirection.shell +: 'thisoutput' +# ^^^^^^^^^^^^^^^^^^^ meta.string.shell string.quoted.single.shell - meta.redirection - meta.range + +: "thisoutput" +# ^^^^^^^^^^^^^^^^^^^ meta.string.shell string.quoted.double.shell - meta.redirection - meta.range + : foo/(a*/)#bar # bar matches foo/bar, foo/any/bar, foo/any/anyother/bar, ... # ^^^^ meta.string.shell string.unquoted.shell # ^^^^^ meta.string.shell meta.group.regexp.shell string.unquoted.shell From 8937655f22e9779aa76d5d88ffafbafd8d670572 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 11 Aug 2024 18:03:50 +0200 Subject: [PATCH 089/113] [ShellScript] Align glob operator scopes with regex --- ShellScript/Bash.sublime-syntax | 2 +- ShellScript/Bash/tests/syntax_test_scope.bash | 28 +++++++++---------- ShellScript/Zsh/tests/syntax_test_scope.zsh | 16 +++++------ 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 4fede2cc56..c459c419c1 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -2340,7 +2340,7 @@ contexts: pattern-group-operators: - match: \| - scope: keyword.operator.logical.regexp.shell + scope: keyword.operator.alternation.regexp.shell pattern-common: - match: \* diff --git a/ShellScript/Bash/tests/syntax_test_scope.bash b/ShellScript/Bash/tests/syntax_test_scope.bash index fa5645071e..4beeaf7fad 100644 --- a/ShellScript/Bash/tests/syntax_test_scope.bash +++ b/ShellScript/Bash/tests/syntax_test_scope.bash @@ -2397,7 +2397,7 @@ case "${foo}" in- in_ in=10 in # ^^ meta.statement.conditional.case.body.shell meta.clause.shell # ^ meta.statement.conditional.case.body.shell - meta.clause # ^ punctuation.definition.pattern.begin.shell -# ^ keyword.operator.logical.regexp.shell +# ^ keyword.operator.alternation.regexp.shell # ^ punctuation.definition.pattern.end.shell # ^^ punctuation.terminator.clause.shell do1 ) foo1 ;& @@ -2447,12 +2447,12 @@ case $TERM in # ^^^^ meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell # ^ meta.clause.pattern.shell - meta.string - meta.group - string # ^ constant.other.wildcard.asterisk.shell - # ^ keyword.operator.logical.regexp.shell - # ^ keyword.operator.logical.regexp.shell + # ^ keyword.operator.alternation.regexp.shell + # ^ keyword.operator.alternation.regexp.shell # ^ keyword.operator.quantifier.regexp.shell # ^ punctuation.section.group.begin.regexp.shell - # ^ keyword.operator.logical.regexp.shell - # ^ keyword.operator.logical.regexp.shell + # ^ keyword.operator.alternation.regexp.shell + # ^ keyword.operator.alternation.regexp.shell # ^ punctuation.section.group.end.regexp.shell # ^ punctuation.definition.pattern.end.shell update_terminal_cwd() { print -Pn "\e]2;%~\a" };; @@ -6233,7 +6233,7 @@ a\/b/c/d} # ^ keyword.operator.quantifier.regexp.shell # ^ punctuation.section.group.begin.regexp.shell # ^^^^ - constant - punctuation -# ^ keyword.operator.logical.regexp.shell +# ^ keyword.operator.alternation.regexp.shell # ^ punctuation.section.group.end.regexp.shell # ^ keyword.operator.substitution.shell # ^^ constant.character.escape.shell @@ -7982,13 +7982,13 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^^^^^ constant.other.posix-class.regexp.shell - punctuation # ^ constant.other.posix-class.regexp.shell punctuation.definition.class.end.regexp.shell # ^^ punctuation.definition.set.end.regexp.shell -# ^ keyword.operator.logical.regexp.shell +# ^ keyword.operator.alternation.regexp.shell # ^^ punctuation.definition.set.begin.regexp.shell # ^ constant.other.posix-class.regexp.shell punctuation.definition.class.begin.regexp.shell # ^^^^^ constant.other.posix-class.regexp.shell - punctuation # ^ constant.other.posix-class.regexp.shell punctuation.definition.class.end.regexp.shell # ^^ punctuation.definition.set.end.regexp.shell -# ^ keyword.operator.logical.regexp.shell +# ^ keyword.operator.alternation.regexp.shell # ^ punctuation.definition.set.begin.regexp.shell # ^^^^^^^^^ - constant.other.posix-class # ^ punctuation.definition.set.end.regexp.shell @@ -8013,7 +8013,7 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^ - meta.function-call - meta.group # ^ keyword.operator.quantifier.regexp.shell # ^ punctuation.section.group.begin.regexp.shell -# ^ keyword.operator.logical.regexp.shell +# ^ keyword.operator.alternation.regexp.shell # ^ punctuation.section.group.end.regexp.shell # ^ keyword.operator.assignment.pipe.shell @@ -8104,15 +8104,15 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}} # ^^^^^^^^^^^^^^^^^^^^^^^ meta.string.regexp.shell meta.group.regexp.shell # ^ keyword.operator.quantifier.regexp.shell # ^ punctuation.section.group.begin.regexp.shell -# ^ keyword.operator.logical.regexp.shell -# ^ keyword.operator.logical.regexp.shell +# ^ keyword.operator.alternation.regexp.shell +# ^ keyword.operator.alternation.regexp.shell # ^^^ constant.other.wildcard.questionmark.shell -# ^ keyword.operator.logical.regexp.shell +# ^ keyword.operator.alternation.regexp.shell # ^ constant.other.wildcard.asterisk.shell -# ^ keyword.operator.logical.regexp.shell +# ^ keyword.operator.alternation.regexp.shell # ^ punctuation.definition.string.begin.shell # ^ punctuation.definition.string.end.shell -# ^ keyword.operator.logical.regexp.shell +# ^ keyword.operator.alternation.regexp.shell # ^ punctuation.definition.string.begin.shell # ^ punctuation.definition.string.end.shell # ^ punctuation.section.group.end.regexp.shell diff --git a/ShellScript/Zsh/tests/syntax_test_scope.zsh b/ShellScript/Zsh/tests/syntax_test_scope.zsh index c628c85066..ee8c2d1b6b 100644 --- a/ShellScript/Zsh/tests/syntax_test_scope.zsh +++ b/ShellScript/Zsh/tests/syntax_test_scope.zsh @@ -512,7 +512,7 @@ case $word { # ^^ meta.statement.conditional.case.body.shell # ^^^^^^^^^^^^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell meta.string.regexp.shell # ^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell - meta.string -# ^ keyword.operator.logical.regexp.shell +# ^ keyword.operator.alternation.regexp.shell # ^ constant.other.wildcard.asterisk.shell # ^ constant.other.wildcard.questionmark.shell # ^ punctuation.definition.pattern.end.shell @@ -543,7 +543,7 @@ case $word { # ^^^^^^^^ meta.clause.body.shell # ^ punctuation.definition.pattern.begin.shell # ^ punctuation.section.group.begin.regexp.shell -# ^ keyword.operator.logical.regexp.shell +# ^ keyword.operator.alternation.regexp.shell # ^ punctuation.section.group.end.regexp.shell # ^ punctuation.definition.pattern.end.shell # ^^^ variable.function.shell @@ -557,7 +557,7 @@ case $word { # ^ meta.clause.shell # ^^^^^^^^ meta.clause.body.shell # ^ punctuation.section.group.begin.regexp.shell -# ^ keyword.operator.logical.regexp.shell +# ^ keyword.operator.alternation.regexp.shell # ^ punctuation.section.group.end.regexp.shell # ^ punctuation.definition.pattern.end.shell # ^^^ variable.function.shell @@ -572,7 +572,7 @@ case $word { # ^ meta.clause.shell # ^ punctuation.definition.pattern.begin.shell # ^ punctuation.section.group.begin.regexp.shell -# ^ keyword.operator.logical.regexp.shell +# ^ keyword.operator.alternation.regexp.shell # ^ punctuation.section.group.end.regexp.shell # ^ punctuation.definition.pattern.end.shell cmd arg ;; @@ -587,7 +587,7 @@ case $word { # ^ meta.clause.pattern.shell - meta.string - string # ^ meta.clause.shell # ^ punctuation.section.group.begin.regexp.shell -# ^ keyword.operator.logical.regexp.shell +# ^ keyword.operator.alternation.regexp.shell # ^ punctuation.section.group.end.regexp.shell # ^ punctuation.definition.pattern.end.shell cmd arg ;; @@ -2796,7 +2796,7 @@ a\/b/c/d} # ^ - keyword.operator # ^ punctuation.section.group.begin.regexp.shell # ^^^^ - constant - punctuation -# ^ keyword.operator.logical.regexp.shell +# ^ keyword.operator.alternation.regexp.shell # ^ punctuation.section.group.end.regexp.shell # ^ keyword.operator.substitution.shell # ^^ constant.character.escape.shell @@ -4041,7 +4041,7 @@ dyn_dir_name() { : (foo|bar)|baz # ^^^^^^^^^ meta.group.regexp.shell string.unquoted.shell # ^ punctuation.section.group.begin.regexp.shell -# ^ keyword.operator.logical.regexp.shell +# ^ keyword.operator.alternation.regexp.shell # ^ punctuation.section.group.end.regexp.shell # ^ keyword.operator.assignment.pipe.shell # ^^^ variable.function.shell @@ -4172,7 +4172,7 @@ dyn_dir_name() { # ^ punctuation.section.group.end.regexp.shell # ^^^^^^ meta.group.regexp.shell # ^ punctuation.section.group.begin.regexp.shell -# ^ keyword.operator.logical.regexp.shell +# ^ keyword.operator.alternation.regexp.shell # ^ punctuation.section.group.end.regexp.shell : !(___) is (^(___)) # Match anything but the expression in parentheses. (Like ‘(^(___))’.) From 9b31f0a145d04d86312bb29a882d60868ce98392 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 11 Aug 2024 18:44:22 +0200 Subject: [PATCH 090/113] [ShellScript] Zsh qualifier ranges undergo arithmetic expansion --- ShellScript/Zsh.sublime-syntax | 10 ++------ ShellScript/Zsh/tests/syntax_test_scope.zsh | 26 ++++++++++++++++++++- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/ShellScript/Zsh.sublime-syntax b/ShellScript/Zsh.sublime-syntax index a02703fb61..e39758d0d3 100644 --- a/ShellScript/Zsh.sublime-syntax +++ b/ShellScript/Zsh.sublime-syntax @@ -696,13 +696,12 @@ contexts: zsh-glob-qualifier-range-body: - meta_scope: meta.range.glob.shell.zsh + - meta_content_scope: meta.arithmetic.shell - match: \] scope: punctuation.definition.range.end.shell.zsh pop: 1 - include: line-continuations - - include: comma-separators - - include: zsh-glob-only-numbers - - include: zsh-glob-qualifier-fail + - include: expression-content zsh-qualifier-fspec: # credentials given as octal number without base @@ -719,11 +718,6 @@ contexts: scope: constant.other.wildcard.questionmark.shell - include: oct-number-body - zsh-glob-only-numbers: - - match: '[-+]?(?=[\d$])' - scope: keyword.operator.arithmetic.shell - push: dec-number-body - zsh-glob-numbers: - match: ([-+]?)(\d+) scope: meta.number.integer.decimal.shell diff --git a/ShellScript/Zsh/tests/syntax_test_scope.zsh b/ShellScript/Zsh/tests/syntax_test_scope.zsh index ee8c2d1b6b..4a2069fc0f 100644 --- a/ShellScript/Zsh/tests/syntax_test_scope.zsh +++ b/ShellScript/Zsh/tests/syntax_test_scope.zsh @@ -5141,7 +5141,7 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}} # ^^^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.range.glob.shell.zsh # ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.range # ^ punctuation.definition.range.begin.shell.zsh -# ^^^^^^ meta.number.integer.decimal.shell meta.interpolation.parameter.shell variable.other.readwrite.shell +# ^^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell # ^ punctuation.separator.sequence.shell # ^ meta.number.integer.decimal.shell constant.numeric.value.shell # ^^^^^^ meta.number.integer.decimal.shell meta.interpolation.parameter.shell - constant @@ -5149,6 +5149,30 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}} # ^ punctuation.definition.range.end.shell.zsh # ^ meta.modifier.glob.shell.zsh punctuation.definition.modifier.end.shell.zsh +: /*(["1+var", foo ? 2 : 5]) +# ^^ meta.string.shell string.unquoted.shell +# ^ meta.string.shell meta.modifier.glob.shell.zsh - string +# ^ meta.string.shell meta.modifier.glob.shell.zsh meta.range.glob.shell.zsh - string +# ^^^^^^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.range.glob.shell.zsh meta.arithmetic.shell - string +# ^ meta.string.shell meta.modifier.glob.shell.zsh meta.range.glob.shell.zsh - string +# ^ meta.string.shell meta.modifier.glob.shell.zsh - string +# ^ constant.other.wildcard.asterisk.shell +# ^ punctuation.definition.modifier.begin.shell.zsh +# ^ punctuation.definition.range.begin.shell.zsh +# ^ punctuation.definition.quoted.begin.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ keyword.operator.arithmetic.shell +# ^^^ meta.variable.shell variable.other.readwrite.shell +# ^ punctuation.definition.quoted.end.shell +# ^ punctuation.separator.sequence.shell +# ^^^ meta.variable.shell variable.other.readwrite.shell +# ^ keyword.operator.ternary.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ keyword.operator.ternary.shell +# ^ meta.number.integer.decimal.shell constant.numeric.value.shell +# ^ punctuation.definition.range.end.shell.zsh +# ^ punctuation.definition.modifier.end.shell.zsh + : /(P"pre") /(P

) /(P{pre}) /(P[pre]) /(P(pre)) /(P:pre:)
 #  ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
 #    ^^^^^ meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh

From f2c84dbbb6c9dc1f9d8d9158ce1ba636bb27fc88 Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Sun, 11 Aug 2024 18:49:22 +0200
Subject: [PATCH 091/113] [ShellScript] Remove redundant pattern

---
 ShellScript/Zsh.sublime-syntax | 1 -
 1 file changed, 1 deletion(-)

diff --git a/ShellScript/Zsh.sublime-syntax b/ShellScript/Zsh.sublime-syntax
index e39758d0d3..5376858147 100644
--- a/ShellScript/Zsh.sublime-syntax
+++ b/ShellScript/Zsh.sublime-syntax
@@ -768,7 +768,6 @@ contexts:
       scope: keyword.operator.substitution.shell.zsh
       pop: 1
     - include: zsh-modifier-end-ahead
-    - include: line-continuations
     - include: string-path-pattern-content
 
   zsh-modifier-subst-replacement:

From ca8a4443b2632319164026ab3b3fdfe9cf1b584f Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Sun, 11 Aug 2024 19:48:59 +0200
Subject: [PATCH 092/113] [ShellScript] Fix Zsh glob qualifier detection in
 groups

This commit restricts zsh glob qualifiers to unquoted top-level patterns.
They are not valid in groups, but in array initialization lists.
---
 ShellScript/Zsh.sublime-syntax              | 14 +++++++++++++
 ShellScript/Zsh/tests/syntax_test_scope.zsh | 22 +++++++++++++++------
 2 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/ShellScript/Zsh.sublime-syntax b/ShellScript/Zsh.sublime-syntax
index 5376858147..a585e5e08d 100644
--- a/ShellScript/Zsh.sublime-syntax
+++ b/ShellScript/Zsh.sublime-syntax
@@ -378,6 +378,20 @@ contexts:
         - zsh-glob-qualifier
         - pattern-group
 
+  pattern-group-content:
+    - include: string-unquoted-content
+    - include: pattern-group-groups
+    - include: pattern-group-charsets
+    - include: pattern-group-operators
+    - include: pattern-common
+
+  pattern-group-groups:
+    - include: zsh-glob-flags
+    # only groups are valid in groups, no glob qualifiers
+    - match: \(
+      scope: punctuation.section.group.begin.regexp.shell
+      push: pattern-group-body
+
   pattern-common:
     - meta_prepend: true
     - include: zsh-glob-operators
diff --git a/ShellScript/Zsh/tests/syntax_test_scope.zsh b/ShellScript/Zsh/tests/syntax_test_scope.zsh
index 4a2069fc0f..d4ebe69352 100644
--- a/ShellScript/Zsh/tests/syntax_test_scope.zsh
+++ b/ShellScript/Zsh/tests/syntax_test_scope.zsh
@@ -5235,18 +5235,28 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                                                          ^ punctuation.definition.quoted.end.shell.zsh
 #                                                           ^ punctuation.definition.modifier.end.shell.zsh
 
-: (/*(/:t)) # qualifiers are valid in groups
-# ^^^ meta.string.shell meta.group.regexp.shell string.unquoted.shell - meta.modifier
-#    ^^^^^ meta.string.shell meta.group.regexp.shell meta.modifier.glob.shell.zsh
-#         ^ meta.string.shell meta.group.regexp.shell string.unquoted.shell - meta.modifier
-# ^ meta.group.regexp.shell string.unquoted.shell punctuation.section.group.begin.regexp.shell
+a=(/*(/:t)) # qualifiers are valid in arrays
+# ^ meta.sequence.list.shell - meta.string
+#  ^^ meta.sequence.list.shell meta.string.shell string.unquoted.shell
+#    ^^^^^ meta.sequence.list.shell meta.string.shell meta.modifier.glob.shell.zsh
+#         ^ meta.sequence.list.shell - meta.string
+# ^ punctuation.section.sequence.begin.shell
 #   ^ constant.other.wildcard.asterisk.shell
 #    ^ punctuation.definition.modifier.begin.shell.zsh
 #     ^ storage.modifier.glob.shell.zsh
 #      ^ punctuation.separator.sequence.shell.zsh
 #       ^ storage.modifier.glob.shell.zsh
 #        ^ punctuation.definition.modifier.end.shell.zsh
-#         ^ punctuation.section.group.end.regexp.shell
+#         ^ punctuation.section.sequence.end.shell
+
+: (/*(/:t)) # qualifiers are not valid in groups
+# ^^^ meta.string.shell meta.group.regexp.shell string.unquoted.shell - meta.modifier
+#    ^^^^^ meta.string.shell meta.group.regexp.shell meta.group.regexp.shell string.unquoted.shell - meta.modifier
+#         ^ meta.string.shell meta.group.regexp.shell string.unquoted.shell - meta.modifier
+# ^ meta.group.regexp.shell string.unquoted.shell punctuation.section.group.begin.regexp.shell
+#   ^ constant.other.wildcard.asterisk.shell
+#    ^ punctuation.section.group.begin.regexp.shell
+#        ^^ punctuation.section.group.end.regexp.shell
 
 ls /(D)/  # qualifiers are always located at the end
 #  ^^^^^ meta.string.shell string.unquoted.shell

From be6c34dc4807834171ab689d2fbfd273a7ddd000 Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Wed, 14 Aug 2024 20:39:01 +0200
Subject: [PATCH 093/113] [ShellScript] Optimize list-end context

- removes duplicate `line-continuations` includes
- moves `comments` include to `list-end` as it is commonly required
---
 ShellScript/Bash.sublime-syntax | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax
index c459c419c1..c872e3cab5 100644
--- a/ShellScript/Bash.sublime-syntax
+++ b/ShellScript/Bash.sublime-syntax
@@ -1283,8 +1283,6 @@ contexts:
   arithmetic-mapping-begin:
     - meta_scope: meta.sequence.list.shell
     - include: list-end
-    - include: line-continuations
-    - include: comments
     - match: (?=\[)
       set: arithmetic-explicit-mapping-body
     - match: (?=\S)
@@ -1293,7 +1291,6 @@ contexts:
   arithmetic-explicit-mapping-body:
     - meta_scope: meta.sequence.list.shell
     - include: list-end
-    - include: comments
     - include: explicit-mapping-keys
     - match: (?=[[:alnum:]_'"])
       push: arithmetic-word
@@ -1302,7 +1299,6 @@ contexts:
   arithmetic-implicit-mapping-body:
     - meta_scope: meta.sequence.list.shell
     - include: list-end
-    - include: comments
     - match: '{{word_begin}}'
       push: arithmetic-implicit-mapping-key-body
 
@@ -1365,8 +1361,6 @@ contexts:
   literal-mapping-begin:
     - meta_scope: meta.sequence.list.shell
     - include: list-end
-    - include: line-continuations
-    - include: comments
     - match: (?=\[)
       set: literal-explicit-mapping-body
     - match: (?=\S)
@@ -1375,7 +1369,6 @@ contexts:
   literal-explicit-mapping-body:
     - meta_scope: meta.sequence.list.shell
     - include: list-end
-    - include: comments
     - include: explicit-mapping-keys
     - include: booleans
     - include: string-path-patterns
@@ -1383,7 +1376,6 @@ contexts:
   literal-implicit-mapping-body:
     - meta_scope: meta.sequence.list.shell
     - include: list-end
-    - include: comments
     - match: '{{word_begin}}'
       push: literal-implicit-mapping-key-body
 
@@ -1472,6 +1464,7 @@ contexts:
     - match: '[(<>]+'
       scope: invalid.illegal.unexpected-token.shell
     - include: line-continuations
+    - include: comments
 
 ###[ ARITHMETIC EXPRESSIONS ]##################################################
 

From 01eb6075180f336e502a5ad08f4ada427ba3e4ea Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Mon, 12 Aug 2024 22:05:50 +0200
Subject: [PATCH 094/113] [ShellScript] Reuse variable-subscription

This commit just saves some lines of code.
---
 ShellScript/Bash.sublime-syntax | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax
index c872e3cab5..d66da48126 100644
--- a/ShellScript/Bash.sublime-syntax
+++ b/ShellScript/Bash.sublime-syntax
@@ -1246,9 +1246,7 @@ contexts:
     - match: '{{varassign}}'
       scope: keyword.operator.assignment.shell
       set: arithmetic-array-value
-    - include: variable-subscriptions
-    - include: line-continuations
-    - include: immediately-pop
+    - include: variable-subscription
 
   arithmetic-array-value:
     # maybe indexed array of or single arithmetic expression value
@@ -1266,9 +1264,7 @@ contexts:
     - match: '{{varassign}}'
       scope: keyword.operator.assignment.shell
       set: arithmetic-mapping-value
-    - include: variable-subscriptions
-    - include: line-continuations
-    - include: immediately-pop
+    - include: variable-subscription
 
   arithmetic-mapping-value:
     # maybe associative of or single arithmetic expression value
@@ -1322,9 +1318,7 @@ contexts:
     - match: '{{varassign}}'
       scope: keyword.operator.assignment.shell
       set: literal-array-value
-    - include: variable-subscriptions
-    - include: line-continuations
-    - include: immediately-pop
+    - include: variable-subscription
 
   literal-array-value:
     # maybe indexed array of or single literal/string value
@@ -1343,9 +1337,7 @@ contexts:
     - match: '{{varassign}}'
       scope: keyword.operator.assignment.shell
       set: literal-mapping-value
-    - include: variable-subscriptions
-    - include: line-continuations
-    - include: immediately-pop
+    - include: variable-subscription
 
   literal-mapping-value:
     # maybe associative array of or single literal/string value

From 917874fecec49d1e79d0b25a7aa450b990f66cdd Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Fri, 16 Aug 2024 17:41:34 +0200
Subject: [PATCH 095/113] [ShellScript] Refactor case clause pattern

This commit turns case clause patterns into a pattern list.
It means, patterns may be surrounded by whitespace.
---
 ShellScript/Bash.sublime-syntax               |  29 ++--
 ShellScript/Bash/tests/syntax_test_scope.bash | 138 +++++++++---------
 ShellScript/Shell/Fold.tmPreferences          |   2 +-
 ...Rules - Case Clause Patterns.tmPreferences |   2 +-
 ShellScript/Zsh.sublime-syntax                |  24 +--
 ShellScript/Zsh/tests/syntax_test_scope.zsh   |  92 ++++++++----
 6 files changed, 167 insertions(+), 120 deletions(-)

diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax
index d66da48126..05f09578a8 100644
--- a/ShellScript/Bash.sublime-syntax
+++ b/ShellScript/Bash.sublime-syntax
@@ -1130,7 +1130,7 @@ contexts:
 
   case-clauses:
     - match: \(
-      scope: meta.clause.pattern.shell punctuation.definition.pattern.begin.shell
+      scope: punctuation.section.patterns.begin.shell
       push: case-clause-paren-pattern-body
     - match: (?=\S)
       push: case-clause-plain-pattern-body
@@ -1138,24 +1138,27 @@ contexts:
   case-clause-paren-pattern-body:
     # patterns enclosed in parentesis may continue on next line without \
     - meta_include_prototype: false
-    - meta_content_scope: meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell
-    - match: \)
-      scope: meta.clause.pattern.shell punctuation.definition.pattern.end.shell
-      set: case-clause-after-pattern
-    - include: line-continuations
-    - include: case-end-ahead
-    - include: pattern-group-content
+    - meta_scope: meta.clause.patterns.shell
+    - include: comments
+    - include: case-clause-pattern-body
 
   case-clause-plain-pattern-body:
     # patterns not enclosed in parentesis are terminated at eol
     - meta_include_prototype: false
-    - meta_content_scope: meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell
+    - meta_scope: meta.clause.patterns.shell
+    - match: $|(?=\s+[#\n])
+      set: case-clause-after-pattern
+    - include: case-clause-pattern-body
+
+  case-clause-pattern-body:
     - match: \)
-      scope: meta.clause.pattern.shell punctuation.definition.pattern.end.shell
+      scope: punctuation.section.patterns.end.shell
       set: case-clause-after-pattern
-    - include: eol-pop
+    - match: \|
+      scope: keyword.operator.logical.shell
     - include: case-end-ahead
-    - include: pattern-group-content
+    - include: line-continuations
+    - include: string-path-patterns
 
   case-clause-after-pattern:
     # required to handle scope specific indentation rules
@@ -2926,7 +2929,7 @@ contexts:
     - include: eol-pop
 
   eol-pop:
-    - match: (?=\s*$|\s+#)
+    - match: $|(?=\s+[#\n])
       pop: 1
     - include: line-continuations
 
diff --git a/ShellScript/Bash/tests/syntax_test_scope.bash b/ShellScript/Bash/tests/syntax_test_scope.bash
index 4beeaf7fad..3fb4bf1a57 100644
--- a/ShellScript/Bash/tests/syntax_test_scope.bash
+++ b/ShellScript/Bash/tests/syntax_test_scope.bash
@@ -2274,15 +2274,17 @@ esac
 case var in
   ( patt ( esac
 #^ meta.statement.conditional.case.body.shell
-# ^ meta.clause.pattern.shell - meta.string - meta.group - string
-#  ^^^^^^^^ meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell - meta.group
+# ^^ meta.clause.patterns.shell - meta.string - meta.group - string
+#   ^^^^ meta.clause.patterns.shell meta.string.shell string.unquoted.shell - meta.groupD
+#       ^ meta.clause.patterns.shell - meta.string - meta.group - string
+#        ^ meta.clause.patterns.shell meta.string.shell string.unquoted.shell - meta.groupD
+#         ^ meta.clause.patterns.shell - meta.string - meta.group - string
 #          ^^^^ meta.statement.conditional.case.end.shell
-# ^ punctuation.definition.pattern.begin.shell
-#        ^ - punctuation
+# ^ punctuation.section.patterns.begin.shell
+#        ^ meta.string.shell string.unquoted.shell
 #          ^^^^ keyword.control.conditional.endcase.shell
 #              ^ - meta.conditional
 
-
 case   # comment
 #^^^ meta.statement.conditional.case.shell
 #   ^^^^^^^^^^^^^ meta.statement.conditional.case.word.shell
@@ -2300,9 +2302,9 @@ case   # comment
 #      ^^^^^^^^^^ comment.line.number-sign.shell
   pattern) # comment
 #^ meta.statement.conditional.case.body.shell
-# ^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell - meta.group
-#        ^ meta.clause.pattern.shell - meta.clause.body - meta.string - meta.group - string
-#         ^^^^^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.shell - meta.clause.pattern
+# ^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.shell string.unquoted.shell - meta.group
+#        ^ meta.clause.patterns.shell - meta.clause.body - meta.string - meta.group - string
+#         ^^^^^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.shell - meta.clause.patterns
 #          ^^^^^^^^^^ comment.line.number-sign.shell
 esac
 # <- meta.statement.conditional.case.end.shell keyword.control.conditional.endcase.shell
@@ -2318,11 +2320,11 @@ case "$1" in
 #       ^ meta.string.shell string.quoted.double.shell punctuation.definition.string.end.shell
 #         ^^ keyword.control.conditional.in.shell
 setup )
-# <- meta.statement.conditional.case.body.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell
-#^^^^^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell
-#     ^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell punctuation.definition.pattern.end.shell
+# <- meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.shell string.unquoted.shell
+#^^^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.shell string.unquoted.shell
+#    ^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell - meta.string - string
 # <- - variable.function - support.function - meta.function-call
-#     ^ punctuation.definition.pattern.end.shell
+#     ^ punctuation.section.patterns.end.shell
 echo Preparing the server...
 # <- meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.identifier.shell support.function.shell
 #^^^ meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.identifier.shell support.function.shell
@@ -2333,11 +2335,11 @@ echo Preparing the server...
 # ^ meta.statement.conditional.case.body.shell - meta.clause
 dep\
 loy )
-# <- meta.statement.conditional.case.body.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell
-#^^^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell
-#   ^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell punctuation.definition.pattern.end.shell
+# <- meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.shell string.unquoted.shell
+#^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.shell string.unquoted.shell
+#  ^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell - meta.string - string
 # <- - variable.function - support.function - meta.function-call
-#   ^ punctuation.definition.pattern.end.shell
+#   ^ punctuation.section.patterns.end.shell
 echo Deploying...
 # <- meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.identifier.shell support.function.shell
 #^^^ meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.identifier.shell support.function.shell
@@ -2347,9 +2349,9 @@ echo Deploying...
 #^ meta.statement.conditional.case.body.shell meta.clause.shell punctuation.terminator.clause.shell
 # ^ meta.statement.conditional.case.body.shell - meta.clause
 * )
-# <- meta.statement.conditional.case.body.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell constant.other.wildcard.asterisk.shell
-#^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell
-# ^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell punctuation.definition.pattern.end.shell
+# <- meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.shell string.unquoted.shell constant.other.wildcard.asterisk.shell
+#^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell - meta.string - string - punctuation
+# ^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell punctuation.section.patterns.end.shell
 #  ^ meta.statement.conditional.case.body.shell meta.clause.shell
 cat <<'ENDCAT' # comment
 # <- meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.identifier.shell meta.command.shell variable.function.shell
@@ -2388,48 +2390,50 @@ case "${foo}" in- in_ in=10 in
 #                     ^^ - keyword.control.conditional.in
 #                           ^^ keyword.control.conditional.in
     ( help | h ) bar ;;
-#^^^ meta.statement.conditional.case.body.shell - meta.clause.pattern
-#   ^ meta.clause.pattern.shell - meta.string - meta.group - string
-#    ^^^^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell - meta.group
-#              ^ meta.clause.pattern.shell - meta.string - meta.group - string
+#^^^ meta.statement.conditional.case.body.shell - meta.clause.patterns
+#   ^^ meta.clause.patterns.shell - meta.string - meta.group - string
+#     ^^^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.shell string.unquoted.shell - meta.group
+#         ^^^ meta.clause.patterns.shell - meta.string - meta.group - string
+#            ^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.shell string.unquoted.shell - meta.group
+#             ^^ meta.clause.patterns.shell - meta.string - meta.group - string
 #               ^ meta.statement.conditional.case.body.shell meta.clause.shell
-#                ^^^^ meta.statement.conditional.case.body.shell meta.clause.body.shell - meta.clause.pattern
+#                ^^^^ meta.statement.conditional.case.body.shell meta.clause.body.shell - meta.clause.patterns
 #                    ^^ meta.statement.conditional.case.body.shell meta.clause.shell
 #                      ^ meta.statement.conditional.case.body.shell - meta.clause
-#   ^ punctuation.definition.pattern.begin.shell
-#          ^ keyword.operator.alternation.regexp.shell
-#              ^ punctuation.definition.pattern.end.shell
+#   ^ punctuation.section.patterns.begin.shell
+#          ^ keyword.operator.logical.shell
+#              ^ punctuation.section.patterns.end.shell
 #                    ^^ punctuation.terminator.clause.shell
     do1 ) foo1 ;&
-#^^^ meta.statement.conditional.case.body.shell - meta.clause.pattern
-#   ^^^^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell - meta.group
-#       ^ meta.clause.pattern.shell - meta.string - meta.group - string
+#^^^ meta.statement.conditional.case.body.shell - meta.clause.patterns
+#   ^^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.shell string.unquoted.shell - meta.group
+#      ^^ meta.clause.patterns.shell - meta.string - meta.group - string
 #        ^ meta.statement.conditional.case.body.shell meta.clause.shell
-#         ^^^^^ meta.statement.conditional.case.body.shell meta.clause.body.shell - meta.clause.pattern
+#         ^^^^^ meta.statement.conditional.case.body.shell meta.clause.body.shell - meta.clause.patterns
 #              ^^ meta.statement.conditional.case.body.shell meta.clause.shell
 #                ^ meta.statement.conditional.case.body.shell - meta.clause
-#       ^ punctuation.definition.pattern.end.shell
+#       ^ punctuation.section.patterns.end.shell
 #              ^^ punctuation.terminator.clause.shell
     (do2 ) foo2 ;;&
-#^^^ meta.statement.conditional.case.body.shell - meta.clause.pattern
-#   ^ meta.clause.pattern.shell - meta.string - meta.group - string
-#    ^^^^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell - meta.group
-#        ^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell - meta.string - meta.group - string
+#^^^ meta.statement.conditional.case.body.shell - meta.clause.patterns
+#   ^ meta.clause.patterns.shell - meta.string - meta.group - string
+#    ^^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.shell string.unquoted.shell - meta.group
+#       ^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell - meta.string - meta.group - string
 #         ^ meta.statement.conditional.case.body.shell meta.clause.shell
 #          ^^^^^ meta.statement.conditional.case.body.shell meta.clause.body.shell
 #               ^^^ meta.statement.conditional.case.body.shell meta.clause.shell
 #                  ^ meta.statement.conditional.case.body.shell - meta.clause
-#   ^ punctuation.definition.pattern.begin.shell
-#        ^ punctuation.definition.pattern.end.shell
+#   ^ punctuation.section.patterns.begin.shell
+#        ^ punctuation.section.patterns.end.shell
 #               ^^^ punctuation.terminator.clause.shell
     *) bar
-#^^^ meta.statement.conditional.case.body.shell - meta.clause.pattern
-#   ^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell - meta.group
-#    ^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell - meta.string - meta.group - string
+#^^^ meta.statement.conditional.case.body.shell - meta.clause.patterns
+#   ^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.shell string.unquoted.shell - meta.group
+#    ^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell - meta.string - meta.group - string
 #     ^ meta.statement.conditional.case.body.shell meta.clause.shell
 #      ^^^^ meta.statement.conditional.case.body.shell meta.clause.body.shell
-#   ^ meta.string.regexp.shell string.unquoted.shell constant.other.wildcard.asterisk.shell
-#    ^ punctuation.definition.pattern.end.shell
+#   ^ constant.other.wildcard.asterisk.shell
+#    ^ punctuation.section.patterns.end.shell
 esac
 # <- meta.statement.conditional.case.end.shell keyword.control.conditional.endcase.shell
 #^^^ meta.statement.conditional.case.end.shell keyword.control.conditional.endcase.shell
@@ -2437,30 +2441,34 @@ esac
 
 case $TERM in
     sun-cmd)
-        #  ^ punctuation.definition.pattern.end.shell
+        #  ^ punctuation.section.patterns.end.shell
         update_terminal_cwd() { print -Pn "\e]l%~\e\\" };;
         #                                              ^ meta.function punctuation.section.block.end.shell
         #                                               ^^ punctuation.terminator.clause.shell
     *xterm*|rxvt|?(dt|k|E)term)
-        #^^^^^^^^ meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell
-        #         ^^^^^^^^ meta.clause.pattern.shell meta.string.regexp.shell meta.group.regexp.shell string.unquoted.shell
-        #                 ^^^^ meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell
-        #                     ^ meta.clause.pattern.shell - meta.string - meta.group - string
+        #^^ meta.clause.patterns.shell meta.string.shell string.unquoted.shell
+        #  ^ meta.clause.patterns.shell - meta.string - meta.group - string
+        #   ^^^^ meta.clause.patterns.shell meta.string.shell string.unquoted.shell
+        #       ^ meta.clause.patterns.shell - meta.string - meta.group - string
+        #        ^ meta.clause.patterns.shell meta.string.shell string.unquoted.shell
+        #         ^^^^^^^^ meta.clause.patterns.shell meta.string.shell meta.group.regexp.shell string.unquoted.shell
+        #                 ^^^^ meta.clause.patterns.shell meta.string.shell string.unquoted.shell
+        #                     ^ meta.clause.patterns.shell - meta.string - meta.group - string
         # ^ constant.other.wildcard.asterisk.shell
-        #  ^ keyword.operator.alternation.regexp.shell
-        #       ^ keyword.operator.alternation.regexp.shell
+        #  ^ keyword.operator.logical.shell
+        #       ^ keyword.operator.logical.shell
         #        ^ keyword.operator.quantifier.regexp.shell
         #         ^ punctuation.section.group.begin.regexp.shell
         #            ^ keyword.operator.alternation.regexp.shell
         #              ^ keyword.operator.alternation.regexp.shell
         #                ^ punctuation.section.group.end.regexp.shell
-        #                     ^ punctuation.definition.pattern.end.shell
+        #                     ^ punctuation.section.patterns.end.shell
         update_terminal_cwd() { print -Pn "\e]2;%~\a" };;
         #                                             ^ meta.function punctuation.section.block.end.shell
         #                                              ^^ punctuation.terminator.clause.shell
     *)
-    # <- meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell constant.other.wildcard.asterisk.shell
-    #^ punctuation.definition.pattern.end.shell
+    # <- meta.clause.patterns.shell meta.string.shell string.unquoted.shell constant.other.wildcard.asterisk.shell
+    #^ punctuation.section.patterns.end.shell
         update_terminal_cwd() {};;
         #                      ^ meta.function punctuation.section.block.end.shell
         #                       ^^ punctuation.terminator.clause.shell
@@ -2470,10 +2478,10 @@ esac
 case $SERVER in
 # <- keyword.control.conditional.case.shell
 ws-+([0-9]).host.com) echo "Web Server"
-#^^^ meta.clause.pattern.shell meta.string.regexp.shell - meta.group
-#   ^^^^^^^ meta.clause.pattern.shell meta.string.regexp.shell meta.group.regexp.shell
-#          ^^^^^^^^^ meta.clause.pattern.shell meta.string.regexp.shell - meta.group
-#                   ^ meta.clause.pattern.shell - meta.string - meta.group - string
+#^^^ meta.clause.patterns.shell meta.string.shell - meta.group
+#   ^^^^^^^ meta.clause.patterns.shell meta.string.shell meta.group.regexp.shell
+#          ^^^^^^^^^ meta.clause.patterns.shell meta.string.shell - meta.group
+#                   ^ meta.clause.patterns.shell - meta.string - meta.group - string
 #^^^^^^^^^^^^^^^^^^^ string.unquoted.shell
 #  ^ keyword.operator.quantifier.regexp.shell
 #   ^ punctuation.section.group.begin.regexp.shell
@@ -2482,14 +2490,14 @@ ws-+([0-9]).host.com) echo "Web Server"
 #      ^ punctuation.separator.sequence.regexp.shell
 #        ^ punctuation.definition.set.end.regexp.shell
 #         ^ punctuation.section.group.end.regexp.shell
-#                   ^ punctuation.definition.pattern.end.shell
+#                   ^ punctuation.section.patterns.end.shell
 ;;
 # <- punctuation.terminator.clause.shell
 #^ punctuation.terminator.clause.shell
 db-+([0-9])\.host\.com) echo "DB server"
-#^^^ meta.clause.pattern.shell meta.string.regexp.shell - meta.group
-#   ^^^^^^^ meta.clause.pattern.shell meta.string.regexp.shell meta.group.regexp.shell
-#          ^^^^^^^^^^^ meta.clause.pattern.shell meta.string.regexp.shell - meta.group
+#^^^ meta.clause.patterns.shell meta.string.shell - meta.group
+#   ^^^^^^^ meta.clause.patterns.shell meta.string.shell meta.group.regexp.shell
+#          ^^^^^^^^^^^ meta.clause.patterns.shell meta.string.shell - meta.group
 #  ^ keyword.operator.quantifier.regexp.shell
 #   ^ punctuation.section.group.begin.regexp.shell
 #    ^ punctuation.definition.set.begin.regexp.shell
@@ -2497,7 +2505,7 @@ db-+([0-9])\.host\.com) echo "DB server"
 #      ^ punctuation.separator.sequence.regexp.shell
 #        ^ punctuation.definition.set.end.regexp.shell
 #         ^ punctuation.section.group.end.regexp.shell
-#                     ^ punctuation.definition.pattern.end.shell
+#                     ^ punctuation.section.patterns.end.shell
 ;;
 # <- punctuation.terminator.clause.shell
 #^ punctuation.terminator.clause.shell
@@ -2509,14 +2517,14 @@ bk-+([0-9])\.host\.com) echo "Backup server"
 #      ^ punctuation.separator.sequence.regexp.shell
 #        ^ punctuation.definition.set.end.regexp.shell
 #         ^ punctuation.section.group.end.regexp.shell
-#                     ^ punctuation.definition.pattern.end.shell
+#                     ^ punctuation.section.patterns.end.shell
 #                       ^^^^ support.function.shell
 ;;
 # <- punctuation.terminator.clause.shell
 #^ punctuation.terminator.clause.shell
 *)echo "Unknown server"
 # <- constant.other.wildcard.asterisk.shell
-#^ punctuation.definition.pattern.end.shell
+#^ punctuation.section.patterns.end.shell
 # ^^^^ support.function.shell
 ;;
 # <- punctuation.terminator.clause.shell
@@ -3304,7 +3312,7 @@ __git_aliased_command ()
         case "$word" in
         {)  : skip start of shell helper function ;;
 #       ^ - punctuation.section.interpolation.begin
-#        ^ punctuation.definition.pattern.end.shell
+#        ^ punctuation.section.patterns.end.shell
         \'*)    : skip opening quote after sh -c ;;
         *)
             echo "$word"
diff --git a/ShellScript/Shell/Fold.tmPreferences b/ShellScript/Shell/Fold.tmPreferences
index 1e79ce128b..8fc5088923 100644
--- a/ShellScript/Shell/Fold.tmPreferences
+++ b/ShellScript/Shell/Fold.tmPreferences
@@ -59,7 +59,7 @@
             
             
                 begin
-                meta.clause.pattern punctuation.definition.pattern.end
+                meta.clause.patterns punctuation.section.patterns.end
                 end
                 punctuation.terminator.clause
                 excludeTrailingNewlines
diff --git a/ShellScript/Shell/Indentation Rules - Case Clause Patterns.tmPreferences b/ShellScript/Shell/Indentation Rules - Case Clause Patterns.tmPreferences
index c390cfde45..6571bf4ced 100644
--- a/ShellScript/Shell/Indentation Rules - Case Clause Patterns.tmPreferences	
+++ b/ShellScript/Shell/Indentation Rules - Case Clause Patterns.tmPreferences	
@@ -2,7 +2,7 @@
 
 
 	scope
-	meta.clause.pattern.shell, meta.clause.shell
+	meta.clause.patterns.shell, meta.clause.shell
 	settings
 	
 		decreaseIndentPattern
diff --git a/ShellScript/Zsh.sublime-syntax b/ShellScript/Zsh.sublime-syntax
index a585e5e08d..d892e515fb 100644
--- a/ShellScript/Zsh.sublime-syntax
+++ b/ShellScript/Zsh.sublime-syntax
@@ -167,25 +167,25 @@ contexts:
     - match: (?=\()
       branch_point: case-clause-paren-pattern
       branch:
-        - case-clause-plain-pattern-body
-        - case-clause-paren-pattern
+        - case-clause-maybe-plain-pattern
+        - case-clause-else-paren-pattern
     - match: (?=\S)
       push: case-clause-plain-pattern-body
 
-  case-clause-paren-pattern:
+  case-clause-maybe-plain-pattern:
     - meta_include_prototype: false
-    - match: \(
-      scope: meta.clause.pattern.shell punctuation.definition.pattern.begin.shell
-      set: case-clause-paren-pattern-body
-
-  case-clause-plain-pattern-body:
-    - meta_include_prototype: false
-    - meta_content_scope: meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell
+    - meta_scope: meta.clause.patterns.shell
     # comment, end of clause or end of line
     # indicate pattern being enclosed in balanced parentheses
-    - match: (?=(?:$|;;&?|;&)|\s+#)
+    - match: (?=(?:$|;;&?|;&|}|esac{{cmd_break}})|\s+#)
       fail: case-clause-paren-pattern
-    - include: case-clause-paren-pattern-body
+    - include: case-clause-pattern-body
+
+  case-clause-else-paren-pattern:
+    - meta_include_prototype: false
+    - match: \(
+      scope: punctuation.section.patterns.begin.shell
+      set: case-clause-paren-pattern-body
 
   case-end-ahead:
     - meta_prepend: true
diff --git a/ShellScript/Zsh/tests/syntax_test_scope.zsh b/ShellScript/Zsh/tests/syntax_test_scope.zsh
index d4ebe69352..bd67e9ee19 100644
--- a/ShellScript/Zsh/tests/syntax_test_scope.zsh
+++ b/ShellScript/Zsh/tests/syntax_test_scope.zsh
@@ -510,12 +510,14 @@ case $word {
 #          ^ punctuation.section.block.begin.shell
     pattern | pa*?ern )
 # ^^ meta.statement.conditional.case.body.shell
-#   ^^^^^^^^^^^^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell meta.string.regexp.shell
-#                     ^ meta.statement.conditional.case.body.shell meta.clause.pattern.shell - meta.string
-#           ^ keyword.operator.alternation.regexp.shell
+#   ^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.shell
+#          ^^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell - meta.string
+#             ^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.shell
+#                    ^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell - meta.string
+#           ^ keyword.operator.logical.shell
 #               ^ constant.other.wildcard.asterisk.shell
 #                ^ constant.other.wildcard.questionmark.shell
-#                     ^ punctuation.definition.pattern.end.shell
+#                     ^ punctuation.section.patterns.end.shell
         cmd -arg value;;
 #^^^^^^^^^^^^^^^^^^^^^ meta.statement.conditional.case.body.shell meta.block.shell.zsh meta.clause.body.shell
 #                     ^^ meta.statement.conditional.case.body.shell meta.block.shell.zsh meta.clause.shell
@@ -525,56 +527,73 @@ case $word {
 #                     ^^ punctuation.terminator.clause.shell
 
     ws-+([0-9]).host.com)
-#   ^^^^^^^^^^^^^^^^^^^^ meta.statement.conditional.case.body.shell meta.block.shell.zsh meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell
+#   ^^^^^^^^^^^^^^^^^^^^ meta.statement.conditional.case.body.shell meta.block.shell.zsh meta.clause.patterns.shell meta.string.shell string.unquoted.shell
 #       ^ meta.group.regexp.shell - meta.set
 #        ^^^^^ meta.group.regexp.shell meta.set.regexp.shell
 #             ^ meta.group.regexp.shell - meta.set
-#                       ^ meta.clause.pattern.shell - meta.group - string
-#                        ^ meta.statement.conditional.case.body.shell meta.block.shell.zsh meta.clause.shell - meta.clause.pattern
+#                       ^ meta.clause.patterns.shell - meta.group - string
+#                        ^ meta.statement.conditional.case.body.shell meta.block.shell.zsh meta.clause.shell - meta.clause.patterns
         ;;
 #       ^^ punctuation.terminator.clause.shell
 
     ((foo|bar)baz) cmd arg ;;
-#   ^ meta.clause.pattern.shell - meta.string - string
-#    ^^^^^^^^^ meta.clause.pattern.shell meta.string.regexp.shell meta.group.regexp.shell string.unquoted.shell
-#             ^^^ meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell
-#                ^ meta.clause.pattern.shell - meta.string - string
+#   ^ meta.clause.patterns.shell - meta.string - string
+#    ^^^^^^^^^ meta.clause.patterns.shell meta.string.shell meta.group.regexp.shell string.unquoted.shell
+#             ^^^ meta.clause.patterns.shell meta.string.shell string.unquoted.shell
+#                ^ meta.clause.patterns.shell - meta.string - string
 #                 ^ meta.clause.shell
 #                  ^^^^^^^^ meta.clause.body.shell
-#   ^ punctuation.definition.pattern.begin.shell
+#   ^ punctuation.section.patterns.begin.shell
 #    ^ punctuation.section.group.begin.regexp.shell
 #        ^ keyword.operator.alternation.regexp.shell
 #            ^ punctuation.section.group.end.regexp.shell
-#                ^ punctuation.definition.pattern.end.shell
+#                ^ punctuation.section.patterns.end.shell
 #                  ^^^ variable.function.shell
 #                      ^^^ meta.string.shell string.unquoted.shell
 #                          ^^ punctuation.terminator.clause.shell
 
     (foo|bar)baz) cmd arg ;;
-#   ^^^^^^^^^ meta.clause.pattern.shell meta.string.regexp.shell meta.group.regexp.shell string.unquoted.shell
-#            ^^^ meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell
-#               ^ meta.clause.pattern.shell - meta.string - string
+#   ^^^^^^^^^ meta.clause.patterns.shell meta.string.shell meta.group.regexp.shell string.unquoted.shell
+#            ^^^ meta.clause.patterns.shell meta.string.shell string.unquoted.shell
+#               ^ meta.clause.patterns.shell - meta.string - string
 #                ^ meta.clause.shell
 #                 ^^^^^^^^ meta.clause.body.shell
 #   ^ punctuation.section.group.begin.regexp.shell
 #       ^ keyword.operator.alternation.regexp.shell
 #           ^ punctuation.section.group.end.regexp.shell
-#               ^ punctuation.definition.pattern.end.shell
+#               ^ punctuation.section.patterns.end.shell
 #                 ^^^ variable.function.shell
 #                     ^^^ meta.string.shell string.unquoted.shell
 #                         ^^ punctuation.terminator.clause.shell
 
+    ( foo | bar ) | baz ) cmd arg ;;
+#   ^^^^^^^^^^^^^ meta.clause.patterns.shell meta.string.shell meta.group.regexp.shell string.unquoted.shell
+#                ^^^ meta.clause.patterns.shell - meta.string - string
+#                   ^^^ meta.clause.patterns.shell meta.string.shell string.unquoted.shell
+#                      ^^ meta.clause.patterns.shell - meta.string - string
+#                        ^ meta.clause.shell
+#                         ^^^^^^^^ meta.clause.body.shell
+#   ^ punctuation.section.group.begin.regexp.shell
+#         ^ keyword.operator.alternation.regexp.shell
+#               ^ punctuation.section.group.end.regexp.shell
+#                 ^ keyword.operator.logical.shell
+#                   ^^^ meta.string.shell string.unquoted.shell
+#                       ^ punctuation.section.patterns.end.shell
+#                         ^^^ variable.function.shell
+#                             ^^^ meta.string.shell string.unquoted.shell
+#                                 ^^ punctuation.terminator.clause.shell
+
     ((foo|bar)baz)
-#   ^ meta.clause.pattern.shell - meta.string - string
-#    ^^^^^^^^^ meta.clause.pattern.shell meta.string.regexp.shell meta.group.regexp.shell string.unquoted.shell
-#             ^^^ meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell
-#                ^ meta.clause.pattern.shell - meta.string - string
+#   ^ meta.clause.patterns.shell - meta.string - string
+#    ^^^^^^^^^ meta.clause.patterns.shell meta.string.shell meta.group.regexp.shell string.unquoted.shell
+#             ^^^ meta.clause.patterns.shell meta.string.shell string.unquoted.shell
+#                ^ meta.clause.patterns.shell - meta.string - string
 #                 ^ meta.clause.shell
-#   ^ punctuation.definition.pattern.begin.shell
+#   ^ punctuation.section.patterns.begin.shell
 #    ^ punctuation.section.group.begin.regexp.shell
 #        ^ keyword.operator.alternation.regexp.shell
 #            ^ punctuation.section.group.end.regexp.shell
-#                ^ punctuation.definition.pattern.end.shell
+#                ^ punctuation.section.patterns.end.shell
         cmd arg ;;
 #       ^^^^^^^^ meta.clause.body.shell
 #       ^^^ variable.function.shell
@@ -582,14 +601,27 @@ case $word {
 #               ^^ punctuation.terminator.clause.shell
 
     (foo|bar)baz)
-#   ^^^^^^^^^ meta.clause.pattern.shell meta.string.regexp.shell meta.group.regexp.shell string.unquoted.shell
-#            ^^^ meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell
-#               ^ meta.clause.pattern.shell - meta.string - string
+#   ^^^^^^^^^ meta.clause.patterns.shell meta.string.shell meta.group.regexp.shell string.unquoted.shell
+#            ^^^ meta.clause.patterns.shell meta.string.shell string.unquoted.shell
+#               ^ meta.clause.patterns.shell - meta.string - string
 #                ^ meta.clause.shell
 #   ^ punctuation.section.group.begin.regexp.shell
 #       ^ keyword.operator.alternation.regexp.shell
 #           ^ punctuation.section.group.end.regexp.shell
-#               ^ punctuation.definition.pattern.end.shell
+#               ^ punctuation.section.patterns.end.shell
+        cmd arg ;;
+#       ^^^^^^^^ meta.clause.body.shell
+#       ^^^ variable.function.shell
+#           ^^^ meta.string.shell string.unquoted.shell
+#               ^^ punctuation.terminator.clause.shell
+
+    ( foo | bar ) \
+        | baz )
+#      ^^^^^^^^ meta.clause.patterns.shell
+#              ^ meta.clause.shell
+#       ^ keyword.operator.logical.shell
+#         ^^^ meta.string.shell string.unquoted.shell
+#             ^ punctuation.section.patterns.end.shell
         cmd arg ;;
 #       ^^^^^^^^ meta.clause.body.shell
 #       ^^^ variable.function.shell
@@ -597,7 +629,11 @@ case $word {
 #               ^^ punctuation.terminator.clause.shell
 
     incomplete | pattern
-#   ^^^^^^^^^^^^^^^^^^^^ meta.clause.pattern.shell meta.string.regexp.shell string.unquoted.shell
+#  ^ - meta.clause - meta.string - string
+#   ^^^^^^^^^^ meta.clause.patterns.shell meta.string.shell string.unquoted.shell
+#             ^^^ meta.clause.patterns.shell - meta.string - string
+#                ^^^^^^^ meta.clause.patterns.shell meta.string.shell string.unquoted.shell
+#                       ^ meta.clause.shell - meta.string - string
 }
 # <- meta.statement.conditional.case.body.shell punctuation.section.block.end.shell
 

From f62ec032bad6fb1e28a748c1ffdedbddeb4f9804 Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Mon, 12 Aug 2024 19:40:02 +0200
Subject: [PATCH 096/113] [ShellScript] Split compound command contexts

Prepare to re-use body parts of compound commands, individually.
---
 ShellScript/Bash.sublime-syntax | 19 +++++++++++--------
 ShellScript/Zsh.sublime-syntax  |  9 +++------
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax
index 05f09578a8..df3e149ada 100644
--- a/ShellScript/Bash.sublime-syntax
+++ b/ShellScript/Bash.sublime-syntax
@@ -56,7 +56,8 @@ contexts:
     - include: cmd-alias
     - include: cmd-arithmetic
     - include: cmd-command
-    - include: cmd-compound
+    - include: cmd-compound-brace
+    - include: cmd-compound-paren
     - include: cmd-control
     - include: cmd-coproc
     - include: cmd-declare
@@ -822,22 +823,24 @@ contexts:
 
 ###[ COMMANDS ]################################################################
 
-  cmd-compound:
+  cmd-compound-brace:
     - match: \{{{cmd_break}}
       scope: punctuation.section.compound.begin.shell
-      set: cmd-compound-braces-body
-    - match: \(
-      scope: punctuation.section.compound.begin.shell
-      set: cmd-compound-parens-body
+      set: cmd-compound-brace-body
 
-  cmd-compound-braces-body:
+  cmd-compound-brace-body:
     - meta_scope: meta.compound.command.shell
     - match: \}
       scope: punctuation.section.compound.end.shell
       pop: 1
     - include: statements
 
-  cmd-compound-parens-body:
+  cmd-compound-paren:
+    - match: \(
+      scope: punctuation.section.compound.begin.shell
+      set: cmd-compound-paren-body
+
+  cmd-compound-paren-body:
     - meta_scope: meta.compound.command.shell
     - match: \)
       scope: punctuation.section.compound.end.shell
diff --git a/ShellScript/Zsh.sublime-syntax b/ShellScript/Zsh.sublime-syntax
index d892e515fb..d473d2477a 100644
--- a/ShellScript/Zsh.sublime-syntax
+++ b/ShellScript/Zsh.sublime-syntax
@@ -105,15 +105,12 @@ contexts:
 
 ###[ COMMANDS ]################################################################
 
-  cmd-compound:
+  cmd-compound-brace:
     - match: \{
       scope: punctuation.section.block.begin.shell
-      set: cmd-compound-braces-body
-    - match: \(
-      scope: punctuation.section.compound.begin.shell
-      set: cmd-compound-parens-body
+      set: cmd-compound-brace-body
 
-  cmd-compound-braces-body:
+  cmd-compound-brace-body:
     - meta_scope: meta.block.shell
     - match: \}
       scope: punctuation.section.block.end.shell

From 6e22e1505a47ed49adeeee97b7147af65e687863 Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Mon, 12 Aug 2024 19:40:35 +0200
Subject: [PATCH 097/113] [ShellScript] Refactor redirections

Redirections can appear everywhere. As for numbers or strings, a popping
version of `redirection` is needed for e.g. assignment r-values.

Herestrings are also scoped `meta.redirection` as of this commit.
---
 ShellScript/Bash.sublime-syntax               | 193 +++++++--------
 ShellScript/Bash/tests/syntax_test_scope.bash | 229 ++++++++++--------
 ShellScript/Zsh.sublime-syntax                |   7 +-
 ShellScript/Zsh/tests/syntax_test_scope.zsh   | 128 +++++-----
 4 files changed, 292 insertions(+), 265 deletions(-)

diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax
index df3e149ada..ca8c931e95 100644
--- a/ShellScript/Bash.sublime-syntax
+++ b/ShellScript/Bash.sublime-syntax
@@ -1039,6 +1039,7 @@ contexts:
   cmd-args-option-assignment-value:
     - meta_include_prototype: false
     - include: line-continuations
+    - include: redirection
     - include: boolean
     - include: number
     - include: string-path-pattern
@@ -1051,6 +1052,7 @@ contexts:
 
   cmd-args-option-maybe-value:
     - meta_include_prototype: false
+    - include: redirection
     - include: eoc-pop
     - include: boolean
     - include: number
@@ -1199,7 +1201,8 @@ contexts:
       pop: 1
 
   flow-args:
-    - include: cmd-args-end
+    - include: redirection
+    - include: eoc-pop
     - include: number
     - include: string-path-pattern
 
@@ -1333,6 +1336,7 @@ contexts:
       scope: punctuation.section.sequence.begin.shell
       set: literal-explicit-mapping-body
     - include: line-continuations
+    - include: redirection
     - include: boolean
     - include: string-path-pattern
     - include: immediately-pop
@@ -1352,6 +1356,7 @@ contexts:
       scope: punctuation.section.sequence.begin.shell
       set: literal-mapping-begin
     - include: line-continuations
+    - include: redirection
     - include: boolean
     - include: string-path-pattern
     - include: immediately-pop
@@ -1630,123 +1635,41 @@ contexts:
 ###[ REDIRECTIONS AND HEREDOCS ]###############################################
 
   redirections:
-    - include: redirections-here-string
-    - include: redirections-here-document
-    - include: redirections-process
-    - include: redirections-inout
-    - include: redirections-input
-    - include: redirections-output
-
-  redirections-process:
-    - match: (\d*)([<>])(\()
-      captures:
-        1: meta.file-descriptor.shell
-           meta.number.integer.decimal.shell
-           constant.numeric.value.shell
-        2: keyword.operator.assignment.redirection.shell
-        3: meta.compound.command.shell
-           punctuation.section.compound.begin.shell
-      push: redirections-process-body
-
-  redirections-process-body:
-    - meta_scope: meta.redirection.shell
-    - meta_content_scope: meta.compound.command.shell
-    - match: \)
-      scope:
-        meta.compound.command.shell
-        punctuation.section.compound.end.shell
-      pop: 1
-    - include: statements
-
-  redirections-output:
-    - match: (\d*)(&>>?[|!]?|>>?&?[|!]?)
-      captures:
-        1: meta.file-descriptor.shell
-           meta.number.integer.decimal.shell
-           constant.numeric.value.shell
-        2: keyword.operator.assignment.redirection.shell
-      push:
-        - redirection-meta
-        - redirection-descriptor
-
-  redirections-input:
-    - match: (\d*)(<&?)
-      captures:
-        1: meta.file-descriptor.shell
-           meta.number.integer.decimal.shell
-           constant.numeric.value.shell
-        2: keyword.operator.assignment.redirection.shell
-      push:
-        - redirection-meta
-        - redirection-descriptor
-
-  redirections-inout:
-    - match: (\d*)(<>)
-      captures:
-        1: meta.file-descriptor.shell
-           meta.number.integer.decimal.shell
-           constant.numeric.value.shell
-        2: keyword.operator.assignment.redirection.shell
-      push:
-        - redirection-meta
-        - redirection-descriptor
-
-  redirection-meta:
-    - meta_include_prototype: false
-    - meta_scope: meta.redirection.shell
-    - include: immediately-pop
-
-  redirection-descriptor:
-    - meta_include_prototype: false
-    - match: \d+{{word_break}}
-      scope: meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell
-      pop: 1
-    - match: '[-p]{{word_break}}'
-      scope: meta.file-descriptor.shell variable.language.stdio.shell
-      pop: 1
-    - include: eoc-pop
-    - include: string-path-pattern
-
-  redirections-here-string:
-    - match: (\d*)(<<<)\s*{{word_begin}}
-      captures:
-        1: meta.file-descriptor.shell
-           meta.number.integer.decimal.shell
-           constant.numeric.value.shell
-        2: keyword.operator.assignment.herestring.shell
-      push: here-string-body
-
-  here-string-body:
-    - meta_include_prototype: false
-    - meta_content_scope: meta.string.herestring.shell string.unquoted.shell
-    - include: string-unquoted-content
-    - include: word-end
-
-  redirections-here-document:
+    - match: (?=\d*&?[<>])
+      push: redirection
+
+  redirection:
+    - include: redirection-here-string
+    - include: redirection-here-document
+    - include: redirection-process
+    - include: redirection-inout
+    - include: redirection-input
+    - include: redirection-output
+
+  redirection-here-document:
     - match: (\d*)(<<-)\s*(?=["'\\]?({{heredoc}}))
       captures:
-        1: meta.file-descriptor.shell
-           meta.number.integer.decimal.shell
-           constant.numeric.value.shell
+        1: meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell
         2: keyword.operator.assignment.redirection.shell
       embed: heredoc-begin
       escape: '{{tab_indent}}(\3)$\n?'
       escape_captures:
-        0: meta.tag.heredoc.end.shell
+        0: meta.redirection.shell meta.tag.heredoc.end.shell
         1: entity.name.tag.heredoc.shell
+      pop: 1
     - match: (\d*)(<<)\s*(?=["'\\]?({{heredoc}}))
       captures:
-        1: meta.file-descriptor.shell
-           meta.number.integer.decimal.shell
-           constant.numeric.value.shell
+        1: meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell
         2: keyword.operator.assignment.redirection.shell
       embed: heredoc-begin
       escape: '{{no_indent}}(\3)$\n?'
       escape_captures:
-        0: meta.tag.heredoc.end.shell
+        0: meta.redirection.shell meta.tag.heredoc.end.shell
         1: entity.name.tag.heredoc.shell
+      pop: 1
 
   heredoc-begin:
+    - meta_scope: meta.redirection.shell
     # These are the variants that allow tabs before the end token
     - match: (')({{heredoc}})(')
       scope: meta.tag.heredoc.begin.shell
@@ -1803,6 +1726,72 @@ contexts:
   heredoc-body-no-expansion:
     - meta_scope: meta.string.heredoc.shell string.unquoted.heredoc.shell
 
+  redirection-here-string:
+    - match: (\d*)(<<<)\s*{{word_begin}}
+      captures:
+        1: meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell
+        2: keyword.operator.assignment.herestring.shell
+      set: here-string-body
+
+  here-string-body:
+    - meta_include_prototype: false
+    - meta_scope: meta.redirection.shell
+    - meta_content_scope: meta.string.herestring.shell string.unquoted.shell
+    - include: string-unquoted-content
+    - include: word-end
+
+  redirection-input:
+    - match: (\d*)(<&?)
+      captures:
+        1: meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell
+        2: keyword.operator.assignment.redirection.shell
+      set:
+        - redirection-meta
+        - redirection-descriptor
+
+  redirection-inout:
+    - match: (\d*)(<>)
+      captures:
+        1: meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell
+        2: keyword.operator.assignment.redirection.shell
+      set:
+        - redirection-meta
+        - redirection-descriptor
+
+  redirection-output:
+    - match: (\d*)((?:&>>?|>>?&?)[|!]?)
+      captures:
+        1: meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell
+        2: keyword.operator.assignment.redirection.shell
+      set:
+        - redirection-meta
+        - redirection-descriptor
+
+  redirection-process:
+    - match: (\d*)([<>])(?=\()
+      captures:
+        1: meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell
+        2: keyword.operator.assignment.redirection.shell
+      set:
+        - redirection-meta
+        - cmd-compound-paren
+
+  redirection-descriptor:
+    - meta_include_prototype: false
+    - match: \d+{{word_break}}
+      scope: meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell
+      pop: 1
+    - match: '[-p]{{word_break}}'
+      scope: meta.file-descriptor.shell variable.language.stdio.shell
+      pop: 1
+    - include: eoc-pop
+    - include: string-path-pattern
+
+  redirection-meta:
+    - meta_include_prototype: false
+    - meta_scope: meta.redirection.shell
+    - include: immediately-pop
+
 ###[ LITERALS ]################################################################
 
   booleans:
diff --git a/ShellScript/Bash/tests/syntax_test_scope.bash b/ShellScript/Bash/tests/syntax_test_scope.bash
index 3fb4bf1a57..3dc47507c4 100644
--- a/ShellScript/Bash/tests/syntax_test_scope.bash
+++ b/ShellScript/Bash/tests/syntax_test_scope.bash
@@ -2356,9 +2356,10 @@ echo Deploying...
 cat <<'ENDCAT' # comment
 # <- meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.identifier.shell meta.command.shell variable.function.shell
 #^^ meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.identifier.shell meta.command.shell variable.function.shell
-#  ^^ meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.arguments.shell - meta.string - meta.tag
-#     ^^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.arguments.shell meta.tag.heredoc.begin.shell - string.unquoted.heredoc
-#             ^^^^^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.arguments.shell - meta.tag - string.unquoted.heredoc
+#  ^ meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.arguments.shell - meta.redirection - meta.string - meta.tag
+#   ^^ meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.arguments.shell meta.redirection.shell - meta.string - meta.tag
+#     ^^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.arguments.shell meta.redirection.shell meta.tag.heredoc.begin.shell - string.unquoted.heredoc
+#             ^^^^^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.arguments.shell meta.redirection.shell - meta.tag - string.unquoted.heredoc
 #   ^^ keyword.operator.assignment.redirection.shell
 #     ^ punctuation.definition.tag.begin.shell - entity
 #      ^^^^^^ entity.name.tag.heredoc.shell
@@ -2368,7 +2369,7 @@ cat <<'ENDCAT' # comment
 foo
 # <- meta.function-call.arguments.shell meta.string.heredoc.shell string.unquoted.heredoc.shell
 ENDCAT
-# <- meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.arguments.shell meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell
+# <- meta.statement.conditional.case.body.shell meta.clause.body.shell meta.function-call.arguments.shell meta.redirection.shell meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell
 ;;
 # <- meta.statement.conditional.case.body.shell meta.clause.shell punctuation.terminator.clause.shell
 #^ meta.statement.conditional.case.body.shell meta.clause.shell punctuation.terminator.clause.shell
@@ -9237,11 +9238,12 @@ exec >&${tee[1]} 2>&1
 
 var=world!
 cat < foo.txt
-#^^^^^^ - meta.tag - meta.string - string
-#      ^^^^^^^^^^^^^^^^^^^^^^ meta.tag.heredoc.begin.shell - meta.string - string
-#                            ^^^ - meta.tag - meta.string - string
-#                               ^^^^^^^ meta.redirection.shell meta.string.shell string.unquoted.shell - meta.string.heredoc
+#^^^ - meta.redirection - meta.string - meta.tag
+#   ^^^ meta.redirection.shell - meta.string - meta.tag
+#      ^^^^^^^^^^^^^^^^^^^^^^ meta.redirection.shell meta.tag.heredoc.begin.shell - meta.string - string
+#                            ^ meta.redirection.shell - meta.tag - meta.string - string
+#                             ^^ meta.redirection.shell meta.redirection.shell - meta.string
+#                               ^^^^^^^ meta.redirection.shell meta.redirection.shell meta.string.shell string.unquoted.shell
 #   ^^ keyword.operator.assignment.redirection.shell
 #     ^ - entiy - keyword
 #      ^^^^^^^^^^^^^^^^^^^^^^ entity.name.tag.heredoc.shell
@@ -9316,14 +9322,15 @@ cat << redirection_comes_next > foo.txt
 hello
 # <- meta.function-call.arguments.shell meta.string.heredoc.shell string.unquoted.heredoc.shell
 redirection_comes_next
-#<- meta.function-call.arguments.shell meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell - meta.string - string
-#^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell - meta.string - string
-#                     ^ meta.function-call.arguments.shell meta.tag.heredoc.end.shell - entity - meta.string - string
+#<- meta.function-call.arguments.shell meta.redirection.shell meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell - meta.string - string
+#^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.redirection.shell meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell - meta.string - string
+#                     ^ meta.function-call.arguments.shell meta.redirection.shell meta.tag.heredoc.end.shell - entity - meta.string - string
 
 cat <<     FARAWAY
-#^^^^^^^^^^ - meta.tag - meta.string - string
-#          ^^^^^^^ meta.tag.heredoc.begin.shell - meta.string - string
-#                 ^ - meta.tag - meta.string - string
+#^^^ - meta.redirection - meta.string - meta.tag
+#   ^^^^^^^ meta.redirection.shell - meta.string - meta.tag
+#          ^^^^^^^ meta.redirection.shell meta.tag.heredoc.begin.shell - meta.string - string
+#                 ^ meta.redirection.shell - meta.tag - meta.string - string
 #   ^^ keyword.operator.assignment.redirection.shell
 #     ^^^^^ - entiy - keyword
 #          ^^^^^^^ entity.name.tag.heredoc.shell
@@ -9331,14 +9338,15 @@ cat <<     FARAWAY
 foo
 # <- meta.function-call.arguments.shell meta.string.heredoc.shell string.unquoted.heredoc.shell
 FARAWAY
-#<- meta.function-call.arguments.shell meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell - meta.string - string
-#^^^^^^ meta.function-call.arguments.shell meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell - meta.string - string
-#      ^ meta.function-call.arguments.shell meta.tag.heredoc.end.shell - entity - meta.string - string
+#<- meta.function-call.arguments.shell meta.redirection.shell meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell - meta.string - string
+#^^^^^^ meta.function-call.arguments.shell meta.redirection.shell meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell - meta.string - string
+#      ^ meta.function-call.arguments.shell meta.redirection.shell meta.tag.heredoc.end.shell - entity - meta.string - string
 
 cat <<- INDENTED
-#^^^^^^^ - meta.string - meta.tag
-#       ^^^^^^^^ meta.tag.heredoc.begin.shell - meta.string - string
-#               ^ - meta.tag - meta.string - string
+#^^^ - meta.redirection - meta.string - meta.tag
+#   ^^^^ meta.redirection.shell - meta.string - meta.tag
+#       ^^^^^^^^ meta.redirection.shell meta.tag.heredoc.begin.shell - meta.string - string
+#               ^ meta.redirection.shell - meta.tag - meta.string - string
 #   ^^^ keyword.operator.assignment.redirection.shell
 #      ^ - entity - keyword
 #       ^^^^^^^^ entity.name.tag.heredoc.shell
@@ -9347,14 +9355,15 @@ cat <<- INDENTED
 # ^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.heredoc.shell string.unquoted.heredoc.shell - meta.interpolation
 #              ^^^^^^ meta.function-call.arguments.shell meta.string.heredoc.shell meta.interpolation.parameter.shell - string
 	INDENTED
-# <- meta.function-call.arguments.shell meta.tag.heredoc.end.shell - entity - meta.string - string
-#^^^^^^^^ meta.function-call.arguments.shell meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell - meta.string - string
-#        ^ meta.function-call.arguments.shell meta.tag.heredoc.end.shell - entity - meta.string - string
+# <- meta.function-call.arguments.shell meta.redirection.shell meta.tag.heredoc.end.shell - entity - meta.string - string
+#^^^^^^^^ meta.function-call.arguments.shell meta.redirection.shell meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell - meta.string - string
+#        ^ meta.function-call.arguments.shell meta.redirection.shell meta.tag.heredoc.end.shell - entity - meta.string - string
 
 cat <<-  'indented_without_expansions'
-#^^^^^^^^ - meta.string - meta.tag
-#        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.tag.heredoc.begin.shell - meta.string - string
-#                                     ^ - meta.tag - meta.string - string
+#^^^ - meta.redirection - meta.string - meta.tag
+#   ^^^^^ meta.redirection.shell - meta.string - meta.tag
+#        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.redirection.shell meta.tag.heredoc.begin.shell - meta.string - string
+#                                     ^ meta.redirection.shell - meta.tag - meta.string - string
 #   ^^^ keyword.operator.assignment.redirection.shell
 #        ^ punctuation.definition.tag.begin.shell - entity
 #         ^^^^^^^^^^^^^^^^^^^^^^^^^^^ entity.name.tag.heredoc.shell
@@ -9363,23 +9372,24 @@ cat <<-  'indented_without_expansions'
 #^^^^^^^^^^ meta.function-call.arguments.shell meta.string.heredoc.shell string.unquoted.heredoc.shell - meta.interpolation
 #     ^^^ - variable.other
 		indented_without_expansions
-# <- meta.function-call.arguments.shell meta.tag.heredoc.end.shell - entity - meta.string - string
-#^ meta.function-call.arguments.shell meta.tag.heredoc.end.shell - entity - meta.string - string
-# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell - meta.string - string
-#                            ^ meta.function-call.arguments.shell meta.tag.heredoc.end.shell - entity - meta.string - string
+# <- meta.function-call.arguments.shell meta.redirection.shell meta.tag.heredoc.end.shell - entity - meta.string - string
+#^ meta.function-call.arguments.shell meta.redirection.shell meta.tag.heredoc.end.shell - entity - meta.string - string
+# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.redirection.shell meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell - meta.string - string
+#                            ^ meta.function-call.arguments.shell meta.redirection.shell meta.tag.heredoc.end.shell - entity - meta.string - string
 
 variable=$(cat <$dummy.c
 #^^ meta.function-call.identifier.shell variable.function.shell
 #  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell - string.unquoted.heredoc
 #   ^^^^^^^^^^^ meta.string.shell string.quoted.single.shell
-#              ^^^^ - meta.tag - meta.string
-#                  ^^^ meta.tag.heredoc.begin.shell - meta.string
-#                     ^ - meta.tag - meta.string.heredoc
-#                      ^^^^^^^^^ meta.redirection.shell - meta.tag - meta.string.heredoc
+#              ^ - meta.redirection - meta.tag - meta.string
+#               ^^ meta.redirection.shell - meta.tag - meta.string
+#                  ^^^ meta.redirection.shell meta.tag.heredoc.begin.shell - meta.string
+#                     ^ - meta.redirection.shell meta.tag - meta.string.heredoc
+#                      ^^^^^^^^^ meta.redirection.shell meta.redirection.shell - meta.tag - meta.string.heredoc
 #               ^^ keyword.operator.assignment.redirection.shell
 #                  ^^^ entity.name.tag.heredoc.shell
 #                      ^ keyword.operator.assignment.redirection.shell
@@ -9476,9 +9490,9 @@ sed 's/^    //' << EOF >$dummy.c
       exit (-1);
     }
 EOF
-# <- meta.function-call.arguments.shell meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell - meta.string - string
-#^^ meta.function-call.arguments.shell meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell - meta.string - string
-#  ^ meta.function-call.arguments.shell meta.tag.heredoc.end.shell - entity - meta.string - string
+# <- meta.function-call.arguments.shell meta.redirection.shell meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell - meta.string - string
+#^^ meta.function-call.arguments.shell meta.redirection.shell meta.tag.heredoc.end.shell entity.name.tag.heredoc.shell - meta.string - string
+#  ^ meta.function-call.arguments.shell meta.redirection.shell meta.tag.heredoc.end.shell - entity - meta.string - string
 
 
 ###############################################################################
@@ -9487,8 +9501,11 @@ EOF
 ###############################################################################
 
 : <<< word --opt ~/**/[Ff]oo?.bar
+# ^^^^ meta.redirection.shell - meta.string
+#     ^^^^ meta.redirection.shell meta.string.herestring.shell
+#         ^^^^^^^^^^^^^^^^^^^^^^^ - meta.redirection
 # ^^^ keyword.operator.assignment.herestring
-#     ^^^^ meta.string.herestring.shell string.unquoted.shell
+#     ^^^^ string.unquoted.shell
 #          ^^^^^ meta.parameter.option.shell variable.parameter.option.shell
 #                ^^^^^^^^^^^^^^^^ meta.string.shell
 #                ^ variable.language.tilde.shell
@@ -9497,24 +9514,30 @@ EOF
 #                           ^ constant.other.wildcard.questionmark.shell
 
 : <<< "word --opt ~/**/[Ff]oo?.bar"
-# ^^^ keyword.operator.assignment.herestring
-#     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.herestring.shell string.quoted.double.shell - constant - variable
+# ^^^ meta.redirection.shell keyword.operator.assignment.herestring
+#    ^ meta.redirection.shell - meta.string - keyword - string
+#     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.redirection.shell meta.string.herestring.shell string.quoted.double.shell - constant - variable
+#                                  ^ - meta.redirection - meta.string
 
 : 1<<< "word --opt"
-# ^  meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell
-#  ^^^ keyword.operator.assignment.herestring
-#      ^^^^^^^^^^^^ meta.string.herestring.shell string.quoted.double.shell
+# ^ meta.redirection.shell meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell
+#  ^^^ meta.redirection.shell keyword.operator.assignment.herestring.shell
+#     ^ meta.redirection.shell - meta.string - keyword - string
+#      ^^^^^^^^^^^^ meta.redirection.shell meta.string.herestring.shell string.quoted.double.shell
+#                  ^ - meta.redirection - meta.string
 
 herestring=<<<${here}string
-#          ^^^ keyword.operator.assignment.herestring
-#             ^^^^^^^ meta.string.herestring.shell meta.interpolation.parameter.shell
-#                    ^^^^^^ meta.string.herestring.shell string.unquoted.shell
-#
+#          ^^^ meta.redirection.shell keyword.operator.assignment.herestring.shell
+#             ^^^^^^^ meta.redirection.shell meta.string.herestring.shell meta.interpolation.parameter.shell
+#                    ^^^^^^ meta.redirection.shell meta.string.herestring.shell string.unquoted.shell
+#                          ^ - meta.assignment - meta.redirection - meta.string
 
 herestring=<<<"This is a \\$here \"\$string.\""
-#             ^^^^^^^^^^^^^ meta.string.herestring.shell string.quoted.double.shell - meta.interpolation
-#                          ^^^^^ meta.string.herestring.shell meta.interpolation.parameter.shell - string
-#                               ^^^^^^^^^^^^^^^ meta.string.herestring.shell string.quoted.double.shell - meta.interpolation
+#          ^^^ meta.redirection.shell keyword.operator.assignment.herestring.shell
+#             ^^^^^^^^^^^^^ meta.redirection.shell meta.string.herestring.shell string.quoted.double.shell - meta.interpolation
+#                          ^^^^^ meta.redirection.shell meta.string.herestring.shell meta.interpolation.parameter.shell - string
+#                               ^^^^^^^^^^^^^^^ meta.redirection.shell meta.string.herestring.shell string.quoted.double.shell - meta.interpolation
+#                                              ^ - meta.assignment - meta.string
 #          ^^^ keyword.operator.assignment.herestring
 #             ^ punctuation.definition.string.begin.shell
 #                        ^^ constant.character.escape.shell
@@ -9526,11 +9549,11 @@ herestring=<<<"This is a \\$here \"\$string.\""
 
 cat <<< "This is a \\$here \"\$string.\"" ; cat more stuff | bar | qux
 # <- meta.function-call.identifier.shell variable.function.shell
-#   ^^^^ meta.function-call.arguments.shell - meta.string
-#       ^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.herestring.shell string.quoted.double.shell - meta.interpolation
-#                    ^^^^^ meta.function-call.arguments.shell meta.string.herestring.shell meta.interpolation.parameter.shell - string
-#                         ^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.herestring.shell string.quoted.double.shell - meta.interpolation
-#                                        ^^^ - meta.function-call
+#   ^^^^ meta.function-call.arguments.shell meta.redirection.shell - meta.string
+#       ^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.redirection.shell meta.string.herestring.shell string.quoted.double.shell - meta.interpolation
+#                    ^^^^^ meta.function-call.arguments.shell meta.redirection.shell meta.string.herestring.shell meta.interpolation.parameter.shell - string
+#                         ^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.redirection.shell meta.string.herestring.shell string.quoted.double.shell - meta.interpolation
+#                                        ^^^ - meta.function-call - meta.redirection - string
 #                                           ^^^ meta.function-call.identifier.shell
 #                                              ^^^^^^^^^^^ meta.function-call.arguments.shell
 #                                                         ^^^ - meta.function-call
@@ -9555,15 +9578,17 @@ cat <<< "This is a \\$here \"\$string.\"" ; cat more stuff | bar | qux
 #                                                                  ^^^ variable.function.shell
 
 cat -c <<<$(echo pipephobic)
-#  ^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments
-#      ^^^ keyword.operator.assignment.herestring.shell
-#         ^^^^^^^^^^^^^^^^^^ meta.string.herestring.shell meta.interpolation.command.shell
-#           ^^^^ support.function
+#  ^^^^ meta.function-call.arguments.shell - meta.redirection
+#      ^^^ meta.function-call.arguments.shell meta.redirection.shell keyword.operator.assignment.herestring.shell
+#         ^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.redirection.shell meta.string.herestring.shell meta.interpolation.command.shell
+#                           ^ - meta.function-call - meta.redirection
+#           ^^^^ support.function.shell
+#                ^^^^^^^^^^ string.unquoted.shell
 
 if opam upgrade --check; then
     opam upgrade --dry-run <<
Date: Mon, 12 Aug 2024 21:59:38 +0200
Subject: [PATCH 098/113] [ShellScript] Add meta scope for variable assignments

May help to implement goto definition for variable bindings
---
 ShellScript/Bash.sublime-syntax               |  47 +-
 ShellScript/Bash/tests/syntax_test_scope.bash | 500 ++++++++++--------
 ShellScript/Zsh/tests/syntax_test_scope.zsh   |  36 +-
 3 files changed, 328 insertions(+), 255 deletions(-)

diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax
index ca8c931e95..1040a60713 100644
--- a/ShellScript/Bash.sublime-syntax
+++ b/ShellScript/Bash.sublime-syntax
@@ -274,7 +274,6 @@ contexts:
       pop: 1
 
   variable-subscription:
-    - meta_scope: meta.variable.shell
     - include: variable-subscriptions
     - include: line-continuations
     - include: immediately-pop
@@ -300,6 +299,11 @@ contexts:
     - include: eoc-pop
     - include: string-unquoted-content
 
+  assignment-value-meta:
+    - meta_include_prototype: false
+    - meta_content_scope: meta.assignment.r-value.shell
+    - include: immediately-pop
+
 ###[ ALIAS BUILTINS ]##########################################################
 
   cmd-alias:
@@ -327,7 +331,7 @@ contexts:
       push: alias-name-chars
 
   alias-name-chars:
-    - meta_scope: meta.command.shell entity.name.function.shell
+    - meta_scope: meta.assignment.l-value.shell meta.command.shell entity.name.function.shell
     - include: line-continuations
     - include: literal-unquoted-content
     - match: '{{opt_break}}'
@@ -1251,10 +1255,12 @@ contexts:
 
   arithmetic-array-value-assignment:
     # maybe variable subscripts followed by value assignment
-    - meta_content_scope: meta.variable.shell
+    - meta_content_scope: meta.assignment.l-value.shell
     - match: '{{varassign}}'
-      scope: keyword.operator.assignment.shell
-      set: arithmetic-array-value
+      scope: meta.assignment.shell keyword.operator.assignment.shell
+      set:
+        - assignment-value-meta
+        - arithmetic-array-value
     - include: variable-subscription
 
   arithmetic-array-value:
@@ -1269,10 +1275,12 @@ contexts:
 
   arithmetic-mapping-value-assignment:
     # maybe variable subscripts followed by value assignment
-    - meta_content_scope: meta.variable.shell
+    - meta_content_scope: meta.assignment.l-value.shell
     - match: '{{varassign}}'
-      scope: keyword.operator.assignment.shell
-      set: arithmetic-mapping-value
+      scope: meta.assignment.shell keyword.operator.assignment.shell
+      set:
+        - assignment-value-meta
+        - arithmetic-mapping-value
     - include: variable-subscription
 
   arithmetic-mapping-value:
@@ -1323,10 +1331,12 @@ contexts:
 
   literal-array-value-assignment:
     # maybe variable subscripts followed by value assignment
-    - meta_content_scope: meta.variable.shell
+    - meta_content_scope: meta.assignment.l-value.shell
     - match: '{{varassign}}'
-      scope: keyword.operator.assignment.shell
-      set: literal-array-value
+      scope: meta.assignment.shell keyword.operator.assignment.shell
+      set:
+        - assignment-value-meta
+        - literal-array-value
     - include: variable-subscription
 
   literal-array-value:
@@ -1343,10 +1353,12 @@ contexts:
 
   literal-mapping-value-assignment:
     # maybe variable subscripts followed by value assignment
-    - meta_content_scope: meta.variable.shell
+    - meta_content_scope: meta.assignment.l-value.shell
     - match: '{{varassign}}'
-      scope: keyword.operator.assignment.shell
-      set: literal-mapping-value
+      scope: meta.assignment.shell keyword.operator.assignment.shell
+      set:
+        - assignment-value-meta
+        - literal-mapping-value
     - include: variable-subscription
 
   literal-mapping-value:
@@ -1398,9 +1410,12 @@ contexts:
 ###[ STATEMENT VALUE ASSIGNMENTS ]#############################################
 
   statements-value-assignment:
+    - meta_content_scope: meta.assignment.l-value.shell
     - match: '{{varassign}}'
-      scope: keyword.operator.assignment.shell
-      set: statements-value
+      scope: meta.assignment.shell keyword.operator.assignment.shell
+      set:
+        - assignment-value-meta
+        - statements-value
     - include: line-continuations
     - include: immediately-pop
 
diff --git a/ShellScript/Bash/tests/syntax_test_scope.bash b/ShellScript/Bash/tests/syntax_test_scope.bash
index 3dc47507c4..1ac04c4ce8 100644
--- a/ShellScript/Bash/tests/syntax_test_scope.bash
+++ b/ShellScript/Bash/tests/syntax_test_scope.bash
@@ -3479,39 +3479,39 @@ false=true
 #    ^ keyword.operator.assignment.shell
 #     ^^^^ constant.language.boolean.true.shell
 charclass=\}ower
-# <- meta.variable.shell variable.other.readwrite.shell
-#^^^^^^^^ meta.variable.shell variable.other.readwrite.shell
-#        ^ keyword.operator.assignment.shell
-#         ^^^^^^ meta.string.shell
+# <- meta.assignment.l-value.shell variable.other.readwrite.shell
+#^^^^^^^^ meta.assignment.l-value.shell variable.other.readwrite.shell
+#        ^ meta.assignment.shell keyword.operator.assignment.shell
+#         ^^^^^^ meta.assignment.r-value.shell meta.string.shell string.unquoted.shell
 #         ^^ constant.character.escape.shell
 
 (foo=bar)
 # <- meta.compound.command.shell punctuation.section.compound.begin.shell
-#^^^^^^^^ meta.compound.command.shell
-#^^^ meta.variable.shell variable.other.readwrite.shell
-#   ^ keyword.operator.assignment.shell
-#    ^^^ meta.string.shell string.unquoted.shell
-#       ^ punctuation.section.compound.end.shell - string-unquoted
+#^^^ meta.compound.command.shell meta.assignment.l-value.shell variable.other.readwrite.shell
+#   ^ meta.compound.command.shell meta.assignment.shell keyword.operator.assignment.shell
+#    ^^^ meta.compound.command.shell meta.assignment.r-value.shell meta.string.shell string.unquoted.shell
+#       ^ meta.compound.command.shell punctuation.section.compound.end.shell - string
 
 { foo=bar }
 # <- meta.compound.command.shell punctuation.section.compound.begin.shell
-#^^^^^^^^^^ meta.compound.command.shell
-# ^^^ meta.variable.shell variable.other.readwrite.shell
-#    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
-#         ^ punctuation.section.compound.end.shell - string-unquoted
+#^ meta.compound.command.shell - meta.assignment
+# ^^^ meta.compound.command.shell meta.assignment.l-value.shell variable.other.readwrite.shell
+#    ^ meta.compound.command.shell meta.assignment.shell keyword.operator.assignment.shell
+#     ^^^ meta.compound.command.shell meta.assignment.r-value.shell meta.string.shell string.unquoted.shell
+#        ^ meta.compound.command.shell - meta.assignment
+#         ^ meta.compound.command.shell punctuation.section.compound.end.shell
 
 foo+=" baz"
-#<- meta.variable.shell variable.other.readwrite.shell
-#^^ meta.variable.shell variable.other.readwrite.shell
-#  ^^ keyword.operator.assignment.shell
-#    ^^^^^^ meta.string.shell string.quoted.double.shell
+#<- meta.assignment.l-value.shell variable.other.readwrite.shell
+#^^ meta.assignment.l-value.shell variable.other.readwrite.shell
+#  ^^ meta.assignment.shell keyword.operator.assignment.shell
+#    ^^^^^^ meta.assignment.r-value.shell meta.string.shell string.quoted.double.shell
 
 foo-=" baz"
-#<- meta.variable.shell variable.other.readwrite.shell
-#^^ meta.variable.shell variable.other.readwrite.shell
-#  ^^ keyword.operator.assignment.shell
-#    ^^^^^^ meta.string.shell string.quoted.double.shell
+#<- meta.assignment.l-value.shell variable.other.readwrite.shell
+#^^ meta.assignment.l-value.shell variable.other.readwrite.shell
+#  ^^ meta.assignment.shell keyword.operator.assignment.shell
+#    ^^^^^^ meta.assignment.r-value.shell meta.string.shell string.quoted.double.shell
 
 ## Arrays ##
 
@@ -3521,10 +3521,10 @@ array=()  # an empty array
 #      ^ punctuation.section.sequence.end
 
 array=(one two three four -5 (foo bar baz)
-#<- meta.variable.shell variable.other.readwrite.shell
-#^^^^ meta.variable.shell - meta.sequence
-#    ^ - meta.variable - meta.sequence
-#     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.sequence.list.shell - meta.sequence meta.sequence
+#<- meta.assignment.l-value.shell variable.other.readwrite.shell
+#^^^^ meta.assignment.l-value.shell - meta.sequence
+#    ^ meta.assignment.shell - meta.sequence
+#     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.assignment.r-value.shell meta.sequence.list.shell - meta.sequence meta.sequence
 #                                         ^ - meta
 #^^^^ variable.other.readwrite.shell
 #    ^ keyword.operator.assignment.shell
@@ -3548,12 +3548,11 @@ array=(one two three four -5 (foo bar baz)
 #                                        ^ punctuation.section.sequence.end.shell
 
 array=($one "two" ${three} 'four' $5)
-#<- meta.variable.shell variable.other.readwrite.shell
-#^^^^ meta.variable.shell
-#^^^^^ - meta.sequence
-#     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.sequence.list.shell
-#                                    ^ - meta.sequence
-# <- variable.other.readwrite.shell
+#<- meta.assignment.l-value.shell variable.other.readwrite.shell
+#^^^^ meta.assignment.l-value.shell - meta.sequence
+#    ^ meta.assignment.shell - meta.sequence
+#     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.assignment.r-value.shell meta.sequence.list.shell - meta.sequence meta.sequence
+#                                    ^ - meta
 #    ^ keyword.operator.assignment.shell
 #     ^ punctuation.section.sequence.begin.shell
 #      ^ punctuation.definition.variable.shell
@@ -3573,9 +3572,11 @@ array=($one "two" ${three} 'four' $5)
 #                                   ^ punctuation.section.sequence.end.shell
 
 array=([one]== ["two"]='what' [4+5]=qux [five]=0 [six]=0s)
-#^^^^^ - meta.sequence
-#     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.sequence.list.shell
-#                                                         ^ - meta.sequence
+#<- meta.assignment.l-value.shell variable.other.readwrite.shell
+#^^^^ meta.assignment.l-value.shell - meta.sequence
+#    ^ meta.assignment.shell - meta.sequence
+#     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.assignment.r-value.shell meta.sequence.list.shell - meta.sequence meta.sequence
+#                                                         ^ - meta
 #      ^^^^^ meta.item-access.shell
 #              ^^^^^^^ meta.item-access.shell
 #                             ^^^^^ meta.item-access.shell
@@ -3614,8 +3615,13 @@ array=([one]== ["two"]='what' [4+5]=qux [five]=0 [six]=0s)
 
 declare -a array
 array[500]=value
-#^^^^ meta.variable.shell variable.other.readwrite.shell
-#    ^^^^^ meta.variable.shell meta.item-access.shell - variable
+#<- meta.assignment.l-value.shell variable.other.readwrite.shell
+#^^^^ meta.assignment.l-value.shell - meta.sequence
+#    ^^^^^ meta.assignment.l-value.shell meta.item-access.shell
+#         ^ meta.assignment.shell - meta.sequence
+#          ^^^^^ meta.assignment.r-value.shell meta.string.shell string.unquoted.shell
+#               ^ - meta
+#^^^^ variable.other.readwrite.shell
 #    ^ punctuation.section.item-access.begin.shell
 #     ^^^ meta.string.shell string.unquoted.shell
 #        ^ punctuation.section.item-access.end.shell
@@ -3623,8 +3629,14 @@ array[500]=value
 #          ^^^^^ meta.string.shell string.unquoted.shell
 
 array["foo"]=bar
-#^^^^ meta.variable.shell variable.other.readwrite.shell
-#    ^^^^^^^ meta.variable.shell meta.item-access.shell - variable
+#<- meta.assignment.l-value.shell variable.other.readwrite.shell
+#^^^^ meta.assignment.l-value.shell - meta.sequence
+#    ^^^^^^^ meta.assignment.l-value.shell meta.item-access.shell
+#           ^ meta.assignment.shell - meta.sequence
+#            ^^^ meta.assignment.r-value.shell meta.string.shell string.unquoted.shell
+#               ^ - meta
+#^^^^ variable.other.readwrite.shell
+#    ^^^^^^^ meta.item-access.shell - variable
 #    ^ punctuation.section.item-access.begin.shell
 #     ^^^^^ string.quoted.double.shell
 #          ^ punctuation.section.item-access.end.shell
@@ -3632,8 +3644,13 @@ array["foo"]=bar
 #            ^^^ meta.string.shell string.unquoted.shell
 
 array[foo]=bar
-#^^^^ meta.variable.shell variable.other.readwrite.shell
-#    ^^^^^ meta.variable.shell meta.item-access.shell
+#<- meta.assignment.l-value.shell variable.other.readwrite.shell
+#^^^^ meta.assignment.l-value.shell - meta.sequence
+#    ^^^^^ meta.assignment.l-value.shell meta.item-access.shell
+#         ^ meta.assignment.shell - meta.sequence
+#          ^^^ meta.assignment.r-value.shell meta.string.shell string.unquoted.shell
+#             ^ - meta
+#    ^^^^^ meta.item-access.shell
 #    ^ punctuation.section.item-access.begin.shell - variable
 #     ^^^ meta.string.shell string.unquoted.shell
 #        ^ punctuation.section.item-access.end.shell - variable
@@ -3641,9 +3658,14 @@ array[foo]=bar
 #          ^^^ meta.string.shell string.unquoted.shell
 
 foo[${j}+10]="`foo`"
-#<- meta.variable.shell variable.other.readwrite.shell
-#^^ meta.variable.shell - meta.item-access
-#  ^^^^^^^^^ meta.variable.shell meta.item-access.shell
+#<- meta.assignment.l-value.shell variable.other.readwrite.shell
+#^^^ meta.assignment.l-value.shell - meta.sequence
+#  ^^^^^^^^^ meta.assignment.l-value.shell meta.item-access.shell
+#           ^ meta.assignment.shell - meta.sequence
+#            ^ meta.assignment.r-value.shell meta.string.shell - meta.interpolation
+#             ^^^^^ meta.assignment.r-value.shell meta.string.shell meta.interpolation.command.shell
+#                  ^ meta.assignment.r-value.shell meta.string.shell - meta.interpolation
+#                   ^ - meta
 #^^ variable.other.readwrite.shell
 #  ^ punctuation.section.item-access.begin.shell
 #   ^^^^ meta.string.shell meta.interpolation.parameter.shell
@@ -3654,6 +3676,11 @@ foo[${j}+10]="`foo`"
 #       ^^^ meta.string.shell string.unquoted.shell
 #          ^ punctuation.section.item-access.end.shell
 #           ^ keyword.operator.assignment.shell
+#            ^ string.quoted.double.shell punctuation.definition.string.begin.shell
+#             ^ punctuation.section.interpolation.begin.shell
+#              ^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+#                 ^ punctuation.section.interpolation.end.shell
+#                  ^ string.quoted.double.shell punctuation.definition.string.end.shell
 
 foo=`cd -L`
 #   ^ meta.string.shell meta.interpolation.command.shell
@@ -3730,7 +3757,7 @@ foo=`(uname -r) 2>/dev/null` || foo=unknown
 #                ^ keyword.operator.assignment.redirection.shell
 #                          ^ punctuation.section.interpolation.end.shell - punctuation.section.interpolation.begin
 #                            ^^ keyword.operator.logical.shell
-#                               ^^^ meta.variable.shell variable.other.readwrite.shell
+#                               ^^^ variable.other.readwrite.shell
 #                                  ^ keyword.operator.assignment.shell
 #                                   ^^^^^^^ meta.string.shell string.unquoted.shell
 
@@ -3764,17 +3791,17 @@ commits=($(git rev-list --reverse --$abbrev-commit "$latest".. -- "$prefix"))
 
 # `=` must immediately follow without whitespace
 novar =20
-# <- - meta.variable - variable.other
-#^^^^^^^^ - meta.variable - variable.other
+# <- - variable.other
+#^^^^^^^^ - variable.other
 
 # `-` is not a valid variable identifier char
 my-var=20
-# <- - meta.variable - variable.other
-#^^^^^^^^ - meta.variable - variable.other
+# <- - variable.other
+#^^^^^^^^ - variable.other
 
 5var=20
-# <- - meta.variable - variable.other
-#^^^^^^ - meta.variable - variable.other
+# <- - variable.other
+#^^^^^^ - variable.other
 
 # not a variable due to command interpolation in name
 B$(cat)OWL=$(($(cat food.txt | wc -l) + 5))
@@ -4288,9 +4315,9 @@ z..2}
 #          ^^ keyword.operator.range.shell
 #            ^ meta.interpolation.arithmetic.shell punctuation.definition.variable.shell
 #             ^^ punctuation.section.interpolation.begin.shell
-#                ^^^^^ meta.variable.shell variable.other.readwrite.shell
+#                ^^^^^ variable.other.readwrite.shell
 #                      ^ keyword.operator.arithmetic.shell
-#                        ^^^ meta.variable.shell variable.other.readwrite.shell
+#                        ^^^ variable.other.readwrite.shell
 #                            ^^ meta.interpolation.arithmetic.shell punctuation.section.interpolation.end.shell
 #                              ^^ keyword.operator.range.shell
 #                                ^ punctuation.definition.variable.shell
@@ -9527,16 +9554,16 @@ EOF
 #                  ^ - meta.redirection - meta.string
 
 herestring=<<<${here}string
-#          ^^^ meta.redirection.shell keyword.operator.assignment.herestring.shell
-#             ^^^^^^^ meta.redirection.shell meta.string.herestring.shell meta.interpolation.parameter.shell
-#                    ^^^^^^ meta.redirection.shell meta.string.herestring.shell string.unquoted.shell
+#          ^^^ meta.assignment.r-value.shell meta.redirection.shell keyword.operator.assignment.herestring.shell
+#             ^^^^^^^ meta.assignment.r-value.shell meta.redirection.shell meta.string.herestring.shell meta.interpolation.parameter.shell
+#                    ^^^^^^ meta.assignment.r-value.shell meta.redirection.shell meta.string.herestring.shell string.unquoted.shell
 #                          ^ - meta.assignment - meta.redirection - meta.string
 
 herestring=<<<"This is a \\$here \"\$string.\""
-#          ^^^ meta.redirection.shell keyword.operator.assignment.herestring.shell
-#             ^^^^^^^^^^^^^ meta.redirection.shell meta.string.herestring.shell string.quoted.double.shell - meta.interpolation
-#                          ^^^^^ meta.redirection.shell meta.string.herestring.shell meta.interpolation.parameter.shell - string
-#                               ^^^^^^^^^^^^^^^ meta.redirection.shell meta.string.herestring.shell string.quoted.double.shell - meta.interpolation
+#          ^^^ meta.assignment.r-value.shell meta.redirection.shell keyword.operator.assignment.herestring.shell
+#             ^^^^^^^^^^^^^ meta.assignment.r-value.shell meta.redirection.shell meta.string.herestring.shell string.quoted.double.shell - meta.interpolation
+#                          ^^^^^ meta.assignment.r-value.shell meta.redirection.shell meta.string.herestring.shell meta.interpolation.parameter.shell - string
+#                               ^^^^^^^^^^^^^^^ meta.assignment.r-value.shell meta.redirection.shell meta.string.herestring.shell string.quoted.double.shell - meta.interpolation
 #                                              ^ - meta.assignment - meta.string
 #          ^^^ keyword.operator.assignment.herestring
 #             ^ punctuation.definition.string.begin.shell
@@ -9820,8 +9847,10 @@ declare foo==bar baz =buz  # assignment must immediately follow a variable
 #                        ^ - variable
 
 declare foo=/dev/null)"
 # <- meta.declaration.variable.shell keyword.declaration.variable.shell
 #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.variable.shell
 #^^^^ meta.declaration.variable.shell keyword.declaration.variable.shell
-#     ^^^ meta.variable.shell variable.other.readwrite.shell
+#     ^^^ variable.other.readwrite.shell
 #        ^ keyword.operator.assignment.shell
 #         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell
 
@@ -10910,13 +10964,13 @@ f() {
     # <- keyword.declaration.variable.shell
     #^^^^ keyword.declaration.variable.shell
     #     ^^ meta.parameter.option.shell variable.parameter.option.shell
-    #        ^ meta.variable.shell variable.other.readwrite.shell punctuation.definition.quoted.begin.shell
-    #         ^^ meta.variable.shell meta.interpolation.parameter.shell variable.language.special.shell
-    #           ^ meta.variable.shell variable.other.readwrite.shell punctuation.definition.quoted.end.shell
+    #        ^ variable.other.readwrite.shell punctuation.definition.quoted.begin.shell
+    #         ^^ meta.interpolation.parameter.shell variable.language.special.shell
+    #           ^ variable.other.readwrite.shell punctuation.definition.quoted.end.shell
     local x
     # <- keyword.declaration.variable.shell
     #^^^^ keyword.declaration.variable.shell
-    #     ^ meta.variable.shell variable.other.readwrite.shell
+    #     ^ variable.other.readwrite.shell
 
     for x; do
         case $x in
@@ -10987,7 +11041,7 @@ mapfile -C "~/.bin/app -p $val arg" array
 #                     ^^^^^^^^^^^^ meta.function-call.arguments.shell meta.quoted.shell meta.function-call.arguments.shell
 #                                 ^ meta.function-call.arguments.shell meta.quoted.shell punctuation.definition.quoted.end.shell
 #                                  ^ meta.function-call.arguments.shell - meta.quoted - variable
-#                                   ^^^^^ meta.function-call.arguments.shell meta.variable.shell variable.other.readwrite.shell
+#                                   ^^^^^ meta.function-call.arguments.shell variable.other.readwrite.shell
 #                                        ^ - meta.function-call
 
 mapfile -d ";" -n 10 -O $origin -s 5 -t -u 20 -C callback -c 10 array
@@ -11010,7 +11064,7 @@ mapfile -d ";" -n 10 -O $origin -s 5 -t -u 20 -C callback -c 10 array
 #                                                ^^^^^^^^ meta.command.shell variable.function.shell
 #                                                         ^^ meta.parameter.option.shell variable.parameter.option.shell
 #                                                            ^^ meta.number.integer.decimal.shell constant.numeric.value.shell
-#                                                               ^^^^^ meta.variable.shell variable.other.readwrite.shell
+#                                                               ^^^^^ variable.other.readwrite.shell
 
 
 ###############################################################################
@@ -11051,7 +11105,7 @@ readarray -C "~/.bin/app -p $val arg" array
 #                       ^^^^^^^^^^^^ meta.function-call.arguments.shell meta.quoted.shell meta.function-call.arguments.shell
 #                                   ^ meta.function-call.arguments.shell meta.quoted.shell punctuation.definition.quoted.end.shell
 #                                    ^ meta.function-call.arguments.shell - meta.quoted - variable
-#                                     ^^^^^ meta.function-call.arguments.shell meta.variable.shell variable.other.readwrite.shell
+#                                     ^^^^^ meta.function-call.arguments.shell variable.other.readwrite.shell
 #                                          ^ - meta.function-call
 
 readarray -d ";" -n 10 -O $origin -s 5 -t -u 20 -C callback -c 10 array
@@ -11074,7 +11128,7 @@ readarray -d ";" -n 10 -O $origin -s 5 -t -u 20 -C callback -c 10 array
 #                                                  ^^^^^^^^ meta.command.shell variable.function.shell
 #                                                           ^^ meta.parameter.option.shell variable.parameter.option.shell
 #                                                              ^^ meta.number.integer.decimal.shell constant.numeric.value.shell
-#                                                                 ^^^^^ meta.variable.shell variable.other.readwrite.shell
+#                                                                 ^^^^^ variable.other.readwrite.shell
 
 
 ###############################################################################
@@ -11146,7 +11200,7 @@ readonly -a bar=\
 readonly -A var=(key1 1+2 key2 4-foo key3 val%10)
 # <- meta.declaration.variable.shell keyword.declaration.variable.shell
 #^^^^^^^^^^^^^^^ meta.declaration.variable.shell - meta.sequence
-#               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.variable.shell meta.sequence.list.shell
+#               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.variable.shell meta.assignment.r-value.shell meta.sequence.list.shell
 #                ^^^^ meta.item-access.shell entity.name.key.shell
 #                         ^^^^ meta.item-access.shell entity.name.key.shell
 #                                    ^^^^ meta.item-access.shell entity.name.key.shell
@@ -11579,18 +11633,18 @@ unalias foo
 #^^^^^^ meta.function-call.identifier.shell support.function.shell
 #      ^^^^ meta.function-call.arguments.shell
 #          ^ - meta.function
-#      ^ - meta.variable - variable
+#      ^ - variable
 #       ^^^ variable.function.shell
-#          ^ - meta.variable - variable
+#          ^ - variable
 
 unalias foo # comment
 # <- meta.function-call.identifier.shell support.function.shell
 #^^^^^^ meta.function-call.identifier.shell support.function.shell
 #      ^^^^ meta.function-call.arguments.shell
 #          ^^^^^^^^^^ - meta.function
-#      ^ - meta.variable - variable
+#      ^ - variable
 #       ^^^ variable.function.shell
-#          ^ - meta.variable - variable
+#          ^ - variable
 #           ^^^^^^^^^^ comment.line.number-sign.shell
 
 
@@ -11605,18 +11659,18 @@ unset foo b'a'r ba${z}  # 'foo' and 'bar' are variable names
 #^^^^ meta.function-call.identifier.shell
 #    ^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
 #                     ^ - meta.function-call
-#         ^^^^^ meta.variable.shell
+#         ^^^^^
 #^^^^ support.function.shell
-#    ^ - meta.variable - support - variable
-#     ^^^ meta.variable.shell variable.other.readwrite.shell
-#        ^ - meta.variable - variable
+#    ^ - support - variable
+#     ^^^ variable.other.readwrite.shell
+#        ^ - variable
 #         ^^^^^ variable.other.readwrite.shell
 #          ^ punctuation.definition.quoted.begin.shell
 #            ^ punctuation.definition.quoted.end.shell
-#              ^ - meta.variable - variable
-#               ^^ meta.variable.shell - meta.interpolation
-#                 ^^^^ meta.variable.shell meta.interpolation.parameter.shell
-#                     ^ - meta.variable - variable
+#              ^ - variable
+#               ^^ - meta.interpolation
+#                 ^^^^ meta.interpolation.parameter.shell
+#                     ^ - variable
 #                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
 
 unset -n
@@ -11661,7 +11715,7 @@ unset -f -n -v foo b'a'r; unset -vn foo 2>& /dev/null
 #                              ^ - support - variable
 #                               ^^^ meta.parameter.option.shell variable.parameter.option.shell
 #                                  ^ - variable
-#                                   ^^^ meta.variable.shell variable.other.readwrite.shell
+#                                   ^^^ variable.other.readwrite.shell
 #                                      ^ - variable
 #                                       ^ meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell
 #                                        ^^ keyword.operator.assignment.redirection.shell
@@ -11688,7 +11742,7 @@ unset -f -x +v -- foo bar; unset -vn -- foo
 #                                ^^^ meta.parameter.option.shell variable.parameter.option.shell
 #                                   ^^^^ - variable
 #                                    ^^ keyword.operator.end-of-options.shell
-#                                       ^^^ meta.variable.shell variable.other.readwrite.shell
+#                                       ^^^ variable.other.readwrite.shell
 #                                          ^ - variable
 
 unset-
diff --git a/ShellScript/Zsh/tests/syntax_test_scope.zsh b/ShellScript/Zsh/tests/syntax_test_scope.zsh
index 0d889eb81c..9e2339c69b 100644
--- a/ShellScript/Zsh/tests/syntax_test_scope.zsh
+++ b/ShellScript/Zsh/tests/syntax_test_scope.zsh
@@ -942,16 +942,16 @@ EOF
 #                  ^ - meta.redirection - meta.string
 
 herestring=<<<${here}string
-#          ^^^ meta.redirection.shell keyword.operator.assignment.herestring
-#             ^^^^^^^ meta.redirection.shell meta.string.herestring.shell meta.interpolation.parameter.shell
-#                    ^^^^^^ meta.redirection.shell meta.string.herestring.shell string.unquoted.shell
+#          ^^^ meta.assignment.r-value.shell meta.redirection.shell keyword.operator.assignment.herestring.shell
+#             ^^^^^^^ meta.assignment.r-value.shell meta.redirection.shell meta.string.herestring.shell meta.interpolation.parameter.shell
+#                    ^^^^^^ meta.assignment.r-value.shell meta.redirection.shell meta.string.herestring.shell string.unquoted.shell
 #                          ^ - meta.assignment - meta.redirection - meta.string
 
 herestring=<<<"This is a \\$here \"\$string.\""
-#          ^^^ meta.redirection.shell keyword.operator.assignment.herestring.shell
-#             ^^^^^^^^^^^^^ meta.redirection.shell meta.string.herestring.shell string.quoted.double.shell - meta.interpolation
-#                          ^^^^^ meta.redirection.shell meta.string.herestring.shell meta.interpolation.parameter.shell - string
-#                               ^^^^^^^^^^^^^^^ meta.redirection.shell meta.string.herestring.shell string.quoted.double.shell - meta.interpolation
+#          ^^^ meta.assignment.r-value.shell meta.redirection.shell keyword.operator.assignment.herestring.shell
+#             ^^^^^^^^^^^^^ meta.assignment.r-value.shell meta.redirection.shell meta.string.herestring.shell string.quoted.double.shell - meta.interpolation
+#                          ^^^^^ meta.assignment.r-value.shell meta.redirection.shell meta.string.herestring.shell meta.interpolation.parameter.shell - string
+#                               ^^^^^^^^^^^^^^^ meta.assignment.r-value.shell meta.redirection.shell meta.string.herestring.shell string.quoted.double.shell - meta.interpolation
 #                                              ^ - meta.assignment - meta.string
 #          ^^^ keyword.operator.assignment.herestring
 #             ^ punctuation.definition.string.begin.shell
@@ -1362,7 +1362,7 @@ function {
 # ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.arithmetic.shell
 #    ^^^^^^^^^^ meta.number.integer.decimal.shell constant.numeric.value.shell
 #               ^ keyword.operator.arithmetic.shell
-#                 ^^^^^^ meta.variable.shell variable.other.readwrite.shell
+#                 ^^^^^^ variable.other.readwrite.shell
 
   (( 3_162.277_660_168_379_5 ))  # numbers can contain underscores
 #    ^^^^^^^^^^^^^^^^^^^^^^^ meta.number.float.decimal.shell.zsh constant.numeric.value.shell.zsh
@@ -2217,7 +2217,7 @@ function {
 : ${(I:expr:)var}  # Search the `expr`th match (where `expr`` evaluates to a number).
 # ^^ meta.interpolation.parameter.shell - meta.modifier
 #   ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh - meta.arithmetic
-#      ^^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh meta.arithmetic.shell meta.variable.shell
+#      ^^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh meta.arithmetic.shell
 #          ^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh - meta.arithmetic
 #            ^^^^ meta.interpolation.parameter.shell - meta.modifier
 # ^ punctuation.definition.variable.shell
@@ -3304,9 +3304,9 @@ z..2}
 #          ^^ keyword.operator.range.shell
 #            ^ meta.interpolation.arithmetic.shell punctuation.definition.variable.shell
 #             ^^ punctuation.section.interpolation.begin.shell
-#                ^^^^^ meta.variable.shell variable.other.readwrite.shell
+#                ^^^^^ variable.other.readwrite.shell
 #                      ^ keyword.operator.arithmetic.shell
-#                        ^^^ meta.variable.shell variable.other.readwrite.shell
+#                        ^^^ variable.other.readwrite.shell
 #                            ^^ meta.interpolation.arithmetic.shell punctuation.section.interpolation.end.shell
 #                              ^^ keyword.operator.range.shell
 #                                ^ punctuation.definition.variable.shell
@@ -4096,6 +4096,10 @@ dyn_dir_name() {
 #          ^ keyword.operator.assignment.pipe.shell
 #           ^^^ variable.function.shell
 
+a=<1-4>others
+# ^^^^^ meta.assignment.r-value.shell meta.string.shell meta.range.shell.zsh
+#      ^^^^^^ meta.assignment.r-value.shell meta.string.shell string.unquoted.shell
+
   ^foo/bar ^foo/bar           # Matches anything except the pattern x
 # ^^^^^^^^ meta.function-call.identifier.shell meta.command.shell
 #         ^ meta.function-call.arguments.shell - variable - string
@@ -5212,10 +5216,10 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #     ^ punctuation.definition.quoted.begin.shell
 #      ^ meta.number.integer.decimal.shell constant.numeric.value.shell
 #       ^ keyword.operator.arithmetic.shell
-#        ^^^ meta.variable.shell variable.other.readwrite.shell
+#        ^^^ variable.other.readwrite.shell
 #           ^ punctuation.definition.quoted.end.shell
 #            ^ punctuation.separator.sequence.shell
-#              ^^^ meta.variable.shell variable.other.readwrite.shell
+#              ^^^ variable.other.readwrite.shell
 #                  ^ keyword.operator.ternary.shell
 #                    ^ meta.number.integer.decimal.shell constant.numeric.value.shell
 #                      ^ keyword.operator.ternary.shell
@@ -5424,9 +5428,9 @@ for a in ./**/*\ *(Dod); do mv $a ${a:h}/${a:t:gs/ /_}; done   # Remove spaces f
 ### [ ARRAY VARIABLES ] #######################################################
 
 var[1]=Hello
-# <- meta.variable.shell variable.other.readwrite.shell
-#^^ meta.variable.shell variable.other.readwrite.shell
-#  ^^^ meta.variable.shell meta.item-access.shell
+# <- variable.other.readwrite.shell
+#^^ variable.other.readwrite.shell
+#  ^^^ meta.item-access.shell
 #  ^ punctuation.section.item-access.begin.shell - meta.string - string
 #   ^ meta.string.shell string.unquoted.shell - punctuation
 #    ^ punctuation.section.item-access.end.shell - meta.string - string

From 8fa9304441d2d2b5b343b0eab92f79488174589c Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Tue, 13 Aug 2024 18:52:28 +0200
Subject: [PATCH 099/113] [ShellScript] Reorganize zsh pattern operators

---
 ShellScript/Zsh.sublime-syntax | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/ShellScript/Zsh.sublime-syntax b/ShellScript/Zsh.sublime-syntax
index 57d618d754..fbebb1523f 100644
--- a/ShellScript/Zsh.sublime-syntax
+++ b/ShellScript/Zsh.sublime-syntax
@@ -390,7 +390,11 @@ contexts:
 
   pattern-common:
     - meta_prepend: true
-    - include: zsh-glob-operators
+    - match: '[~^]'
+      scope: keyword.operator.logical.regexp.shell.zsh
+      push: maybe-tilde-interpolation
+    - match: \#{1,2}
+      scope: keyword.operator.quantifier.regexp.shell.zsh
 
 ###[ ARITHMETIC EXPANSIONS ]###################################################
 
@@ -613,15 +617,6 @@ contexts:
     - include: zsh-modifier-end-ahead
     - include: zsh-glob-qualifier-content
 
-###[ ZSH GLOB OPERATORS ]######################################################
-
-  zsh-glob-operators:
-    - match: '[~^]'
-      scope: keyword.operator.logical.regexp.shell.zsh
-      push: maybe-tilde-interpolation
-    - match: \#{1,2}
-      scope: keyword.operator.quantifier.regexp.shell.zsh
-
 ###[ ZSH GLOB QUALIFIERS ]#####################################################
 
   zsh-glob-qualifier:

From 28b062d170fd773826c4d04c5c4ad9c1d49cfac2 Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Sun, 18 Aug 2024 16:50:22 +0200
Subject: [PATCH 100/113] [ShellScript] Improve builtin "read" argument
 highlighting

---
 ShellScript/Bash.sublime-syntax               | 28 +++++-
 ShellScript/Bash/tests/syntax_test_scope.bash | 85 ++++++++++++++-----
 ShellScript/Zsh.sublime-syntax                |  1 +
 3 files changed, 90 insertions(+), 24 deletions(-)

diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax
index 1040a60713..a44c19d933 100644
--- a/ShellScript/Bash.sublime-syntax
+++ b/ShellScript/Bash.sublime-syntax
@@ -66,6 +66,7 @@ contexts:
     - include: cmd-export
     - include: cmd-historic
     - include: cmd-mapfile
+    - include: cmd-read
     - include: cmd-readonly
     - include: cmd-sudo
     - include: cmd-test
@@ -570,6 +571,27 @@ contexts:
       push: cmd-args-option-maybe-value
     - include: cmd-args-end-of-options-then-variables-literal-values
 
+###[ MAPFILE BUILTINS ]########################################################
+
+  cmd-read:
+    - match: read{{cmd_break}}
+      scope:
+        meta.function-call.identifier.shell
+        support.function.shell
+      set:
+        - cmd-args-meta
+        - cmd-read-args
+
+  cmd-read-args:
+    - match: ([-+])[cdiNnOpstu]+{{opt_break}}
+      scope:
+        meta.parameter.option.shell
+        variable.parameter.option.shell
+      captures:
+        1: punctuation.definition.parameter.shell
+      push: cmd-args-option-maybe-value
+    - include: cmd-args-end-of-options-then-variables-literal-values
+
 ###[ READONLY BUILTINS ]#######################################################
 
   cmd-readonly:
@@ -3030,9 +3052,9 @@ variables:
   # Note: Contains thosw, which are not present as dedicated context
   builtin_cmds: |-
     (?x: \. | \: | bg | bind | caller | cd | disown | enable | eval | fg
-    | getopts | hash | help | jobs | kill | logout | printf | pwd
-    | read | set | shift | shopt | source | su | suspend | times
-    | type | ulimit | umask | wait ){{cmd_break}}
+    | getopts | hash | help | jobs | kill | logout | printf | pwd | set
+    | shift | shopt | source | su | suspend | times | type | ulimit | umask
+    | wait ){{cmd_break}}
 
   modifier_cmds: |-
     (?x: builtin ){{cmd_break}}
diff --git a/ShellScript/Bash/tests/syntax_test_scope.bash b/ShellScript/Bash/tests/syntax_test_scope.bash
index 1ac04c4ce8..6f755f651e 100644
--- a/ShellScript/Bash/tests/syntax_test_scope.bash
+++ b/ShellScript/Bash/tests/syntax_test_scope.bash
@@ -519,27 +519,6 @@ set -e -- -o {str,ing}
 #         ^^ - variable.parameter.option
 #            ^^^^^^^^^ meta.interpolation.brace.shell
 
-read -d '' -sn 1 -t1 -- -t1 10
-#^^^ meta.function-call.identifier.shell
-#   ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
-#   ^ - meta.parameter
-#    ^^ meta.parameter.option.shell
-#      ^^^^ - meta.parameter
-#          ^^^ meta.parameter.option.shell
-#             ^^^ - meta.parameter
-#                ^^^ meta.parameter.option.shell
-#                   ^^^^^^^^^^ - meta.parameter
-#^^^ support.function.shell
-#    ^ variable.parameter.option.shell punctuation.definition.parameter.shell
-#     ^ variable.parameter.option.shell - punctuation
-#       ^^ string.quoted.single.shell
-#          ^^^ variable.parameter.option.shell
-#              ^ meta.number.integer.decimal.shell constant.numeric.value.shell
-#                ^^^ variable.parameter.option.shell
-#                    ^^ keyword.operator.end-of-options.shell
-#                       ^^^^ - constant - variable
-#                           ^^ constant.numeric.value.shell
-
 shift 2 -- 
 #^^^^ meta.function-call.identifier.shell support.function.shell
 #    ^^^^^ meta.function-call.arguments.shell
@@ -11067,6 +11046,70 @@ mapfile -d ";" -n 10 -O $origin -s 5 -t -u 20 -C callback -c 10 array
 #                                                               ^^^^^ variable.other.readwrite.shell
 
 
+###############################################################################
+# 4.2 Bash Builtin Commands (read)                                            #
+# https://www.gnu.org/software/bash/manual/bash.html#index-read               #
+# read [-ers] [-a aname] [-d delim] [-i text] [-n nchars]                     #
+#     [-N nchars] [-p prompt] [-t timeout] [-u fd] [name …]                   #
+###############################################################################
+
+read
+# <- meta.function-call.identifier.shell support.function.shell
+#^^^ meta.function-call.identifier.shell support.function.shell
+#   ^ - meta.function-call
+
+read data
+# <- meta.function-call.identifier.shell support.function.shell
+#^^^ meta.function-call.identifier.shell support.function.shell
+#   ^^^^^ meta.function-call.arguments.shell
+#    ^^^^ variable.other.readwrite.shell
+#        ^ - meta.function-call
+
+read -d '' -sn 1 -t1 -- -t1 10 data
+#^^^ meta.function-call.identifier.shell
+#   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
+#   ^ - meta.parameter
+#    ^^ meta.parameter.option.shell
+#      ^^^^ - meta.parameter
+#          ^^^ meta.parameter.option.shell
+#             ^^^ - meta.parameter
+#                ^^^ meta.parameter.option.shell
+#                   ^^^^^^^^^^ - meta.parameter
+#^^^ support.function.shell
+#    ^ variable.parameter.option.shell punctuation.definition.parameter.shell
+#     ^ variable.parameter.option.shell - punctuation
+#       ^^ string.quoted.single.shell
+#          ^^^ variable.parameter.option.shell
+#              ^ meta.number.integer.decimal.shell constant.numeric.value.shell
+#                ^^^ variable.parameter.option.shell
+#                    ^^ keyword.operator.end-of-options.shell
+#                       ^^^ invalid.illegal.unexpected-token.shell
+#                           ^^ invalid.illegal.unexpected-token.shell
+#                              ^^^^ variable.other.readwrite.shell
+
+read -ers -a aname -d ";" -i text -n 1 -N 2 -p prompt -t 10 -u 103 data
+# <- meta.function-call.identifier.shell support.function.shell
+#^^^ meta.function-call.identifier.shell support.function.shell
+#   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
+#    ^^^^ variable.parameter.option.shell
+#         ^^ variable.parameter.option.shell
+#            ^^^^^ variable.other.readwrite.shell
+#                  ^^ variable.parameter.option.shell
+#                     ^^^ string.quoted.double.shell
+#                         ^^ variable.parameter.option.shell
+#                            ^^^^ string.unquoted.shell
+#                                 ^^ variable.parameter.option.shell
+#                                    ^ constant.numeric.value.shell
+#                                      ^^ variable.parameter.option.shell
+#                                         ^ constant.numeric.value.shell
+#                                           ^^ variable.parameter.option.shell
+#                                              ^^^^^^ string.unquoted.shell
+#                                                     ^^ variable.parameter.option.shell
+#                                                        ^^ constant.numeric.value.shell
+#                                                           ^^ variable.parameter.option.shell
+#                                                              ^^^ constant.numeric.value.shell
+#                                                                  ^^^^ variable.other.readwrite.shell
+
 ###############################################################################
 # 4.2 Bash Builtin Commands (readarray)                                       #
 # https://www.gnu.org/software/bash/manual/bash.html#index-readarray          #
diff --git a/ShellScript/Zsh.sublime-syntax b/ShellScript/Zsh.sublime-syntax
index fbebb1523f..31c55f6335 100644
--- a/ShellScript/Zsh.sublime-syntax
+++ b/ShellScript/Zsh.sublime-syntax
@@ -102,6 +102,7 @@ contexts:
         - cmd-args-end-of-options-then-function-references
 
   cmd-mapfile: []
+  cmd-read: []
 
 ###[ COMMANDS ]################################################################
 

From 033216dbe25ee0902b5a2e2986c9f84087e698e3 Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Mon, 19 Aug 2024 21:44:39 +0200
Subject: [PATCH 101/113] [ShellScript] Restrict integer highlighting in
 literal string contexts

Numbers in command arguments are mainly guesswork. Bash/Zsh treat them string,
but this syntax scopes valid looking numbers constant.number as it is what
users might mainly expect.
---
 ShellScript/Bash.sublime-syntax               | 28 ++++++++++++++-----
 ShellScript/Bash/tests/syntax_test_scope.bash | 10 +++++++
 ShellScript/Zsh.sublime-syntax                |  5 ++--
 ShellScript/Zsh/tests/syntax_test_scope.zsh   | 11 ++++++++
 4 files changed, 44 insertions(+), 10 deletions(-)

diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax
index a44c19d933..9473350e00 100644
--- a/ShellScript/Bash.sublime-syntax
+++ b/ShellScript/Bash.sublime-syntax
@@ -1617,7 +1617,7 @@ contexts:
     # may also be referenced by name without using the parameter expansion
     # syntax.
     - include: booleans
-    - include: numbers
+    - include: expression-numbers
     - include: expression-variables
     - include: expression-illegals
 
@@ -1625,6 +1625,13 @@ contexts:
     - match: '{{word_char}}'
       scope: invalid.illegal.unexpected-token.shell
 
+  expression-numbers:
+    # lazily consume everything which looks like a number.
+    # supports interpolation in decimal integers.
+    - include: base-numbers
+    - match: (?=\d)
+      push: dec-number-body
+
   expression-variables:
     # variables within arithmetic expressions must not contain quotes
     - match: (?=[{{identifier_first_char}}$%])
@@ -1846,6 +1853,12 @@ contexts:
       pop: 1
 
   numbers:
+    # strictly consume full numbers only, for use in contexts with strings
+    - include: base-numbers
+    - match: \d+{{word_break}}
+      scope: meta.number.integer.decimal.shell constant.numeric.value.shell
+
+  base-numbers:
     # A leading ‘0x’ or ‘0X’ denotes hexadecimal.
     - match: 0[xX]
       scope: constant.numeric.base.shell
@@ -1862,9 +1875,6 @@ contexts:
     - match: \d{{dec_digit}}*#
       scope: constant.numeric.base.shell
       push: other-number-body
-    # If base# is omitted, then base 10 is used.
-    - match: (?=\d)
-      push: dec-number-body
 
   number:
     # Note: Leading sign is scoped as operator for consistent highlighting as
@@ -1894,9 +1904,13 @@ contexts:
         2: constant.numeric.base.shell
       set: other-number-body
     # If base# is omitted, then base 10 is used.
-    - match: '[-+]?(?=\d)'
-      scope: keyword.operator.arithmetic.shell
-      set: dec-number-body
+    # note: consume whole uninterpolated word only to avoid false positives.
+    - match: ([-+]?)(\d+){{word_break}}
+      scope: meta.number.integer.decimal.shell
+      captures:
+        1: keyword.operator.arithmetic.shell
+        2: constant.numeric.value.shell
+      pop: 1
 
   dec-number-body:
     - meta_include_prototype: false
diff --git a/ShellScript/Bash/tests/syntax_test_scope.bash b/ShellScript/Bash/tests/syntax_test_scope.bash
index 6f755f651e..763ffb6ab2 100644
--- a/ShellScript/Bash/tests/syntax_test_scope.bash
+++ b/ShellScript/Bash/tests/syntax_test_scope.bash
@@ -12601,6 +12601,16 @@ true false
 #             ^^^ meta.number.integer.other.shell constant.numeric.value.shell
 #                ^ - meta.number - constant
 
+: -target 20.10.2.4:8080 -port 80
+#         ^^^^^^^^^^^^^^ meta.string.shell string.unquoted.shell
+#                              ^^ meta.number.integer.decimal.shell constant.numeric.value.shell
+
+: -target=20.10.2.4:8080 -port=80
+#         ^^^^^^^^^^^^^^ meta.string.shell string.unquoted.shell
+#                              ^^ meta.number.integer.decimal.shell constant.numeric.value.shell
+
+ip=10.10.20.14
+#  ^^^^^^^^^^^ meta.string.shell string.unquoted.shell
 
 ###############################################################################
 # 6.5 Shell Arithmetic                                                        #
diff --git a/ShellScript/Zsh.sublime-syntax b/ShellScript/Zsh.sublime-syntax
index 31c55f6335..6ef9890f76 100644
--- a/ShellScript/Zsh.sublime-syntax
+++ b/ShellScript/Zsh.sublime-syntax
@@ -327,14 +327,13 @@ contexts:
 
 ###[ LITERALS ]################################################################
 
-  numbers:
+  base-numbers:
     - meta_prepend: true
-    - match: (\d{{dec_digit}}*(\.){{dec_digit}}*(?:[eE][-+]?{{dec_digit}}*)?)({{word_char}}*)
+    - match: (\d{{dec_digit}}*(\.){{dec_digit}}*(?:[eE][-+]?{{dec_digit}}*)?){{word_break}}
       scope: meta.number.float.decimal.shell.zsh
       captures:
         1: constant.numeric.value.shell.zsh
         2: punctuation.separator.decimal.shell.zsh
-        3: invalid.illegal.shell.zsh
 
   number:
     - meta_prepend: true
diff --git a/ShellScript/Zsh/tests/syntax_test_scope.zsh b/ShellScript/Zsh/tests/syntax_test_scope.zsh
index 9e2339c69b..d1c838606b 100644
--- a/ShellScript/Zsh/tests/syntax_test_scope.zsh
+++ b/ShellScript/Zsh/tests/syntax_test_scope.zsh
@@ -1430,6 +1430,17 @@ function {
 #                 ^^^^^^^ meta.string.shell meta.interpolation.parameter.shell meta.arithmetic.shell
 #                        ^ meta.string.shell meta.interpolation.parameter.shell - meta.arithmetic
 
+: -target 20.10.2.4:8080 -port 80
+#         ^^^^^^^^^^^^^^ meta.string.shell string.unquoted.shell
+#                              ^^ meta.number.integer.decimal.shell constant.numeric.value.shell
+
+: -target=20.10.2.4:8080 -port=80
+#         ^^^^^^^^^^^^^^ meta.string.shell string.unquoted.shell
+#                              ^^ meta.number.integer.decimal.shell constant.numeric.value.shell
+
+ip=10.10.20.14
+#  ^^^^^^^^^^^ meta.string.shell string.unquoted.shell
+
 
 ###############################################################################
 # 14.3 Parameter Expansion                                                    #

From 19f494c4e26b9638653609e8c6eebb7ad9bba624 Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Wed, 21 Aug 2024 21:23:29 +0200
Subject: [PATCH 102/113] [ShellScript] Scope pre-/suffix of brace extensions
 string

---
 ShellScript/Bash.sublime-syntax               | 5 +++--
 ShellScript/Bash/tests/syntax_test_scope.bash | 5 +++++
 ShellScript/Zsh.sublime-syntax                | 1 +
 ShellScript/Zsh/tests/syntax_test_scope.zsh   | 5 +++++
 4 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax
index 9473350e00..7c0065dab0 100644
--- a/ShellScript/Bash.sublime-syntax
+++ b/ShellScript/Bash.sublime-syntax
@@ -1855,7 +1855,7 @@ contexts:
   numbers:
     # strictly consume full numbers only, for use in contexts with strings
     - include: base-numbers
-    - match: \d+{{word_break}}
+    - match: \d+{{dec_break}}
       scope: meta.number.integer.decimal.shell constant.numeric.value.shell
 
   base-numbers:
@@ -1905,7 +1905,7 @@ contexts:
       set: other-number-body
     # If base# is omitted, then base 10 is used.
     # note: consume whole uninterpolated word only to avoid false positives.
-    - match: ([-+]?)(\d+){{word_break}}
+    - match: ([-+]?)(\d+){{dec_break}}
       scope: meta.number.integer.decimal.shell
       captures:
         1: keyword.operator.arithmetic.shell
@@ -3056,6 +3056,7 @@ variables:
     | lower | print | punct | space | upper | word | xdigit )
 
   # Numbers
+  dec_break: (?=[\s|&;()<>])
   dec_digit: \d
   hex_digit: \h
   oct_digit: '[0-7]'
diff --git a/ShellScript/Bash/tests/syntax_test_scope.bash b/ShellScript/Bash/tests/syntax_test_scope.bash
index 763ffb6ab2..8ccc1f7959 100644
--- a/ShellScript/Bash/tests/syntax_test_scope.bash
+++ b/ShellScript/Bash/tests/syntax_test_scope.bash
@@ -4068,6 +4068,11 @@ B$(cat)OWL=$(($(cat food.txt | wc -l) + 5))
 #             ^ meta.string.shell meta.interpolation.brace.shell punctuation.section.interpolation.end.shell
 #              ^^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation
 
+: 123{4,5,6}789
+# ^^^ meta.string.shell string.unquoted.shell - meta.interpolation
+#    ^^^^^^^ meta.string.shell meta.interpolation.brace.shell
+#           ^^^ meta.string.shell string.unquoted.shell - meta.interpolation
+
 : {a,b,~,%,!,.,\,,\{,\},*,?,-1,+2,0," ",' '}
 #^ - meta.interpolation
 # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell meta.interpolation.brace.shell - meta.interpolation.brace meta.interpolation.brace
diff --git a/ShellScript/Zsh.sublime-syntax b/ShellScript/Zsh.sublime-syntax
index 6ef9890f76..af68619bce 100644
--- a/ShellScript/Zsh.sublime-syntax
+++ b/ShellScript/Zsh.sublime-syntax
@@ -999,6 +999,7 @@ variables:
   shebang_language: \bzsh\b
 
   # Numbers
+  dec_break: (?=[\s|&;()}<>])
   dec_digit: '[\d_]'
   hex_digit: '[\h_]'
   oct_digit: '[0-7_]'
diff --git a/ShellScript/Zsh/tests/syntax_test_scope.zsh b/ShellScript/Zsh/tests/syntax_test_scope.zsh
index d1c838606b..719b0db4b9 100644
--- a/ShellScript/Zsh/tests/syntax_test_scope.zsh
+++ b/ShellScript/Zsh/tests/syntax_test_scope.zsh
@@ -3089,6 +3089,11 @@ a\/b/c/d}
 #             ^ meta.string.shell meta.interpolation.brace.shell punctuation.section.interpolation.end.shell
 #              ^^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation
 
+: 123{4,5,6}789
+# ^^^ meta.string.shell string.unquoted.shell - meta.interpolation
+#    ^^^^^^^ meta.string.shell meta.interpolation.brace.shell
+#           ^^^ meta.string.shell string.unquoted.shell - meta.interpolation
+
 : {a,b,~,%,!,.,\,,\{,\},*,?,-1,+2,0," ",' '}
 #^ - meta.interpolation
 # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell meta.interpolation.brace.shell - meta.interpolation.brace meta.interpolation.brace

From d6e147cf1bc42df882334d85e43ed2ae5eb7e9fb Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Thu, 5 Sep 2024 19:05:44 +0200
Subject: [PATCH 103/113] [ShellScript] Fix arithmetic vs. command expansions

Fixes #4033
---
 ShellScript/Bash.sublime-syntax               |  39 +++++--
 ShellScript/Bash/tests/syntax_test_scope.bash | 101 ++++++++++++++++++
 ShellScript/Zsh/tests/syntax_test_scope.zsh   |  93 ++++++++++++++++
 3 files changed, 227 insertions(+), 6 deletions(-)

diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax
index 7c0065dab0..dac688f8e2 100644
--- a/ShellScript/Bash.sublime-syntax
+++ b/ShellScript/Bash.sublime-syntax
@@ -341,19 +341,30 @@ contexts:
 ###[ ARITHMETIC BUILTINS ]#####################################################
 
   cmd-arithmetic:
-    - match: \(\(
-      scope: punctuation.section.compound.begin.shell
-      set: cmd-arithmetic-body
+    - match: (?=\(\()
+      branch_point: cmd-arithmetic
+      branch:
+        - cmd-compound-arithmetic
+        - cmd-compound-paren
+      pop: 1
     - match: let{{cmd_break}}
       scope: meta.function-call.identifier.shell support.function.shell
       set: cmd-arithmetic-args
 
+  cmd-compound-arithmetic:
+    - meta_include_prototype: false
+    - match: \(\(
+      scope: punctuation.section.compound.begin.shell
+      set: cmd-arithmetic-body
+
   cmd-arithmetic-body:
     - meta_scope: meta.compound.arithmetic.shell
     - meta_content_scope: meta.arithmetic.shell
     - match: \)\)
       scope: punctuation.section.compound.end.shell
       pop: 1
+    - match: (?=\))
+      fail: cmd-arithmetic
     - include: expression-content
 
   cmd-arithmetic-args:
@@ -2505,17 +2516,26 @@ contexts:
 ###[ ARITHMETIC EXPANSIONS ]###################################################
 
   expansions-arithmetic:
+    - match: (?=\$\(\()
+      branch_point: arithmetic-expansion
+      branch:
+        - arithmetic-expansion
+        - command-expansion
+
+  arithmetic-expansion:
     - match: (\$)(\(\()
       captures:
         1: punctuation.definition.variable.shell
         2: punctuation.section.interpolation.begin.shell
-      push: arithmetic-expansion-parens-body
+      set: arithmetic-expansion-parens-body
 
   arithmetic-expansion-parens-body:
     - meta_scope: meta.interpolation.arithmetic.shell
     - match: \)\)
       scope: punctuation.section.interpolation.end.shell
       pop: 1
+    - match: (?=\))
+      fail: arithmetic-expansion
     - include: expression-content
 
 ###[ BRACE EXPANSIONS ]########################################################
@@ -2626,7 +2646,7 @@ contexts:
       captures:
         1: punctuation.definition.variable.shell
         2: punctuation.section.interpolation.begin.shell
-      push: expansion-command-body
+      push: command-expansion-body
     - match: \`
       scope:
         meta.interpolation.command.shell
@@ -2638,7 +2658,14 @@ contexts:
         0: meta.interpolation.command.shell
            punctuation.section.interpolation.end.shell
 
-  expansion-command-body:
+  command-expansion:
+    - match: (\$)(\()
+      captures:
+        1: punctuation.definition.variable.shell
+        2: punctuation.section.interpolation.begin.shell
+      set: command-expansion-body
+
+  command-expansion-body:
     - meta_scope: meta.interpolation.command.shell
     - match: \s*(\))
       captures:
diff --git a/ShellScript/Bash/tests/syntax_test_scope.bash b/ShellScript/Bash/tests/syntax_test_scope.bash
index 8ccc1f7959..881eb20017 100644
--- a/ShellScript/Bash/tests/syntax_test_scope.bash
+++ b/ShellScript/Bash/tests/syntax_test_scope.bash
@@ -2542,12 +2542,40 @@ esac
 # https://www.gnu.org/software/bash/manual/bash.html#Command-Grouping         #
 ###############################################################################
 
+()
+# <- meta.function-call.shell meta.function.anonymous.parameters.shell punctuation.section.parameters.begin.shell
+#^ meta.function-call.shell meta.function.anonymous.parameters.shell punctuation.section.parameters.end.shell
+
 (foo)
 # <- meta.compound.command.shell punctuation.section.compound.begin.shell
 #^^^ meta.compound.command.shell meta.function-call.identifier.shell variable.function.shell
 #   ^ meta.compound.command.shell punctuation.section.compound.end.shell
 #    ^ - meta
 
+((git stash) || true)
+#^^^^^^^^^^^^^^^^^^^^ - meta.compound.arithmetic
+# <- meta.compound.command.shell punctuation.section.compound.begin.shell
+#^^^^^^^^^^^ meta.compound.command.shell meta.compound.command.shell
+#           ^^^^^^^^^ meta.compound.command.shell
+#^ punctuation.section.compound.begin.shell
+# ^^^ meta.command.shell variable.function.shell
+#     ^^^^^ meta.string.shell string.unquoted.shell
+#          ^ punctuation.section.compound.end.shell
+#            ^^ keyword.operator.logical.shell
+#               ^^^^ constant.language.boolean.true.shell
+#                   ^ punctuation.section.compound.end.shell
+
+((git \
+stash) || true)
+#^^^^^^^^^^^^^^ - meta.compound.arithmetic
+#^^^^^ meta.compound.command.shell meta.compound.command.shell
+#     ^^^^^^^^^ meta.compound.command.shell
+#^^^^ meta.string.shell string.unquoted.shell
+#    ^ punctuation.section.compound.end.shell
+#      ^^ keyword.operator.logical.shell
+#         ^^^^ constant.language.boolean.true.shell
+#             ^ punctuation.section.compound.end.shell
+
 { foo -o }
 # <- meta.compound.command.shell punctuation.section.compound.begin.shell
 #^^^^^^^^^ meta.compound.command.shell - meta.compound meta.compound
@@ -7829,6 +7857,79 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}}
 #                                                                        ^^ punctuation.section.interpolation.end.shell
 
 
+###############################################################################
+# 3.5.4 Command Expansions                                                    #
+# https://www.gnu.org/software/bash/manual/bash.html#Command-Expansion        #
+###############################################################################
+
+: $()
+# ^^^ meta.interpolation.command.shell
+# ^ punctuation.definition.variable.shell
+#  ^ punctuation.section.interpolation.begin.shell
+#   ^ punctuation.section.interpolation.end.shell
+
+: $((  ) )
+# ^^^^^^^^ meta.interpolation.command.shell
+#   ^^^^ meta.function-call.shell meta.function.anonymous.parameters.shell
+#       ^ meta.function-call.shell meta.function.anonymous.shell
+# ^ punctuation.definition.variable.shell
+#  ^ punctuation.section.interpolation.begin.shell
+#   ^ punctuation.section.parameters.begin.shell
+#      ^ punctuation.section.parameters.end.shell
+#        ^ punctuation.section.interpolation.end.shell
+
+: $( (  ))
+# ^^^^^^^^ meta.interpolation.command.shell
+#    ^^^^ meta.function-call.shell meta.function.anonymous.parameters.shell
+# ^ punctuation.definition.variable.shell
+#  ^ punctuation.section.interpolation.begin.shell
+#    ^ punctuation.section.parameters.begin.shell
+#       ^ punctuation.section.parameters.end.shell
+#        ^ punctuation.section.interpolation.end.shell
+
+
+# not an arithmetic, even if starting with ((
+: $((git stash) || true)
+#^^^^^^^^^^^^^^^^^^^^^^^ - meta.interpolation.arithmetic
+# ^^ meta.interpolation.command.shell - meta.compound
+#   ^^^^^^^^^^^ meta.interpolation.command.shell meta.compound.command.shell
+#              ^^^^^^^^^ meta.interpolation.command.shell - meta.compound
+#  ^ punctuation.section.interpolation.begin.shell
+#   ^ punctuation.section.compound.begin.shell
+#    ^^^ meta.command.shell variable.function.shell
+#        ^^^^^ meta.string.shell string.unquoted.shell
+#             ^ punctuation.section.compound.end.shell
+#               ^^ keyword.operator.logical.shell
+#                  ^^^^ constant.language.boolean.true.shell
+#                      ^ punctuation.section.interpolation.end.shell
+
+: $((git \
+stash) || true)
+#^^^^^^^^^^^^^^ - meta.interpolation.arithmetic
+#^^^^^ meta.interpolation.command.shell meta.compound.command.shell
+#     ^^^^^^^^^ meta.interpolation.command.shell - meta.compound
+#^^^^ meta.string.shell string.unquoted.shell
+#    ^ punctuation.section.compound.end.shell
+#      ^^ keyword.operator.logical.shell
+#         ^^^^ constant.language.boolean.true.shell
+#             ^ punctuation.section.interpolation.end.shell
+
+
+###############################################################################
+# 3.5.5 Arithmetic Expansions                                                 #
+# https://www.gnu.org/software/bash/manual/bash.html#Arithmetic-Expansion     #
+###############################################################################
+
+: $(())
+# ^^^^^ meta.string.shell meta.interpolation.arithmetic.shell
+
+: $((  ))
+# ^^^^^^^ meta.interpolation.arithmetic.shell
+# ^ punctuation.definition.variable.shell
+#  ^^ punctuation.section.interpolation.begin.shell
+#      ^^ punctuation.section.interpolation.end.shell
+
+
 ###############################################################################
 # 3.5.8.1 Pattern Matching                                                    #
 # https://www.gnu.org/software/bash/manual/bash.html#Pattern-Matching         #
diff --git a/ShellScript/Zsh/tests/syntax_test_scope.zsh b/ShellScript/Zsh/tests/syntax_test_scope.zsh
index 719b0db4b9..0e7f2ef2ab 100644
--- a/ShellScript/Zsh/tests/syntax_test_scope.zsh
+++ b/ShellScript/Zsh/tests/syntax_test_scope.zsh
@@ -637,6 +637,41 @@ case $word {
 }
 # <- meta.statement.conditional.case.body.shell punctuation.section.block.end.shell
 
+()
+# <- meta.function-call.shell meta.function.anonymous.parameters.shell punctuation.section.parameters.begin.shell
+#^ meta.function-call.shell meta.function.anonymous.parameters.shell punctuation.section.parameters.end.shell
+
+(foo)
+# <- meta.compound.command.shell punctuation.section.compound.begin.shell
+#^^^ meta.compound.command.shell meta.function-call.identifier.shell variable.function.shell
+#   ^ meta.compound.command.shell punctuation.section.compound.end.shell
+#    ^ - meta
+
+((git stash) || true)
+#^^^^^^^^^^^^^^^^^^^^ - meta.compound.arithmetic
+# <- meta.compound.command.shell punctuation.section.compound.begin.shell
+#^^^^^^^^^^^ meta.compound.command.shell meta.compound.command.shell
+#           ^^^^^^^^^ meta.compound.command.shell
+#^ punctuation.section.compound.begin.shell
+# ^^^ meta.command.shell variable.function.shell
+#     ^^^^^ meta.string.shell string.unquoted.shell
+#          ^ punctuation.section.compound.end.shell
+#            ^^ keyword.operator.logical.shell
+#               ^^^^ constant.language.boolean.true.shell
+#                   ^ punctuation.section.compound.end.shell
+
+((git \
+stash) || true)
+#^^^^^^^^^^^^^^ - meta.compound.arithmetic
+#^^^^^ meta.compound.command.shell meta.compound.command.shell
+#     ^^^^^^^^^ meta.compound.command.shell
+#^^^^ meta.string.shell string.unquoted.shell
+#    ^ punctuation.section.compound.end.shell
+#      ^^ keyword.operator.logical.shell
+#         ^^^^ constant.language.boolean.true.shell
+#             ^ punctuation.section.compound.end.shell
+
+
 ###############################################################################
 # 7 Redirection                                                               #
 # https://zsh.sourceforge.io/Doc/Release/Redirection.html#Redirection         #
@@ -2997,6 +3032,64 @@ a\/b/c/d}
 #               ^ punctuation.section.interpolation.end.shell
 
 
+###############################################################################
+# 14.4 Command Expansion
+# https://zsh.sourceforge.io/Doc/Release/Expansion.html#Command-Substitution
+###############################################################################
+
+: $()
+# ^^^ meta.interpolation.command.shell
+# ^ punctuation.definition.variable.shell
+#  ^ punctuation.section.interpolation.begin.shell
+#   ^ punctuation.section.interpolation.end.shell
+
+: $((  ) )
+# ^^^^^^^^ meta.interpolation.command.shell
+#   ^^^^ meta.function-call.shell meta.function.anonymous.parameters.shell
+#       ^ meta.function-call.shell meta.function.anonymous.shell
+# ^ punctuation.definition.variable.shell
+#  ^ punctuation.section.interpolation.begin.shell
+#   ^ punctuation.section.parameters.begin.shell
+#      ^ punctuation.section.parameters.end.shell
+#        ^ punctuation.section.interpolation.end.shell
+
+: $( (  ))
+# ^^^^^^^^ meta.interpolation.command.shell
+#    ^^^^ meta.function-call.shell meta.function.anonymous.parameters.shell
+# ^ punctuation.definition.variable.shell
+#  ^ punctuation.section.interpolation.begin.shell
+#    ^ punctuation.section.parameters.begin.shell
+#       ^ punctuation.section.parameters.end.shell
+#        ^ punctuation.section.interpolation.end.shell
+
+
+# not an arithmetic, even if starting with ((
+: $((git stash) || true)
+#^^^^^^^^^^^^^^^^^^^^^^^ - meta.interpolation.arithmetic
+# ^^ meta.interpolation.command.shell - meta.compound
+#   ^^^^^^^^^^^ meta.interpolation.command.shell meta.compound.command.shell
+#              ^^^^^^^^^ meta.interpolation.command.shell - meta.compound
+#  ^ punctuation.section.interpolation.begin.shell
+#   ^ punctuation.section.compound.begin.shell
+#    ^^^ meta.command.shell variable.function.shell
+#        ^^^^^ meta.string.shell string.unquoted.shell
+#             ^ punctuation.section.compound.end.shell
+#               ^^ keyword.operator.logical.shell
+#                  ^^^^ constant.language.boolean.true.shell
+#                      ^ punctuation.section.interpolation.end.shell
+
+: $((git \
+stash) || true)
+#^^^^^^^^^^^^^^ - meta.interpolation.arithmetic
+#^^^^^ meta.interpolation.command.shell meta.compound.command.shell
+#     ^^^^^^^^^ meta.interpolation.command.shell - meta.compound
+#^^^^ meta.string.shell string.unquoted.shell
+#    ^ punctuation.section.compound.end.shell
+#      ^^ keyword.operator.logical.shell
+#         ^^^^ constant.language.boolean.true.shell
+#             ^ punctuation.section.interpolation.end.shell
+
+
 ###############################################################################
 # 14.5 Arithmetic Expansion
 # https://zsh.sourceforge.io/Doc/Release/Expansion.html#Arithmetic-Expansion

From a2da39103f131104d0ff6df4a2faa274ac0aa8ad Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Thu, 15 Aug 2024 19:16:23 +0200
Subject: [PATCH 104/113] [ShellScript]: Fix illegal pipe operators

This commit ...
1. adds contexts to scope pipe operators illegal within lists, groups and tests.
2. handles the tricky part to distinguish `<1-2>` range operators at the
   beginning or within expansions, patterns or groups from redirections and
   literal scoped or illegal pipe operators, while maintaining word boundaries.
---
 ShellScript/Bash.sublime-syntax               |  81 ++--
 ShellScript/Bash/tests/syntax_test_scope.bash | 346 ++++++++++++++++--
 ShellScript/Zsh.sublime-syntax                | 265 ++++++++++----
 ShellScript/Zsh/tests/syntax_test_scope.zsh   | 279 +++++++++++++-
 4 files changed, 837 insertions(+), 134 deletions(-)

diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax
index dac688f8e2..a9bf205088 100644
--- a/ShellScript/Bash.sublime-syntax
+++ b/ShellScript/Bash.sublime-syntax
@@ -722,8 +722,6 @@ contexts:
       push: compound-test-pattern
     - match: '[<>]=?'
       scope: keyword.operator.comparison.shell
-    - match: ;
-      scope: invalid.illegal.unexpected-token.shell
     - include: line-continuations
     - include: test-expression-common
 
@@ -734,6 +732,7 @@ contexts:
       pop: 1
     - include: line-continuations
     - include: eregexp-main-content
+    - include: illegal-pipeseps
 
   compound-test-pattern:
     - meta_include_prototype: false
@@ -742,6 +741,7 @@ contexts:
       pop: 1
     - include: line-continuations
     - include: pattern-main-content
+    - include: illegal-pipeseps
 
   compound-test-group-body:
     - meta_scope: meta.group.shell
@@ -760,8 +760,6 @@ contexts:
       push: compound-test-group-pattern
     - match: '[<>]=?'
       scope: keyword.operator.comparison.shell
-    - match: ;
-      scope: invalid.illegal.unexpected-token.shell
     - include: line-continuations
     - include: test-expression-common
 
@@ -769,13 +767,15 @@ contexts:
     - meta_include_prototype: false
     - meta_content_scope: meta.string.regexp.shell string.unquoted.shell
     - include: compound-test-group-pattern-end
-    - include: eregexp-group-content
+    - include: eregexp-main-content
+    - include: illegal-pipeseps
 
   compound-test-group-pattern:
     - meta_include_prototype: false
     - meta_content_scope: meta.string.regexp.shell string.unquoted.shell
     - include: compound-test-group-pattern-end
-    - include: pattern-group-content
+    - include: pattern-main-content
+    - include: illegal-pipeseps
 
   compound-test-group-pattern-end:
     - match: '{{wspace}}(\]\])'
@@ -800,6 +800,7 @@ contexts:
       scope: keyword.operator.comparison.shell
     - match: '&&|\|\||!'
       scope: keyword.operator.logical.shell
+    - include: illegal-pipeseps
     - include: comments
     - include: cmd-args-values
 
@@ -1200,7 +1201,7 @@ contexts:
       scope: keyword.operator.logical.shell
     - include: case-end-ahead
     - include: line-continuations
-    - include: string-path-patterns
+    - include: group-path-patterns
 
   case-clause-after-pattern:
     # required to handle scope specific indentation rules
@@ -1419,7 +1420,7 @@ contexts:
     - include: list-end
     - include: explicit-mapping-keys
     - include: booleans
-    - include: string-path-patterns
+    - include: group-path-patterns
 
   literal-implicit-mapping-body:
     - meta_scope: meta.sequence.list.shell
@@ -1438,7 +1439,7 @@ contexts:
     - include: line-continuations
     - include: comments
     - include: boolean
-    - include: string-path-pattern
+    - include: group-path-pattern
 
 ###[ STATEMENT VALUE ASSIGNMENTS ]#############################################
 
@@ -1512,8 +1513,6 @@ contexts:
     - match: \)
       scope: punctuation.section.sequence.end.shell
       pop: 1
-    - match: '[(<>]+'
-      scope: invalid.illegal.unexpected-token.shell
     - include: line-continuations
     - include: comments
 
@@ -2074,17 +2073,40 @@ contexts:
 
 ###[ STRING PATH PATTERN MATCHING ]############################################
 
-  string-path-patterns:
+  group-path-patterns:
+    # This context consumes glob patterns within contexts (groups or lists)
+    # which do not support redirections or any other kind of pipelines.
+    # Operators like `&`, `;`, `|`, `<` or `>` are scoped illegal.
+    - match: (?=\S)
+      push: group-path-pattern
+
+  group-path-pattern:
     - match: (/)dev(/)null{{word_break}}
       scope: meta.path.shell constant.language.null.shell
       captures:
         1: punctuation.separator.path.shell
         2: punctuation.separator.path.shell
+      pop: 1
+    - match: '{{illegal_group_separators}}+'
+      scope: invalid.illegal.unexpected-token.shell
+      pop: 1
     - match: '{{word_begin}}'
-      push:
-        - string-path-pattern-body
+      set:
+        - group-path-pattern-body
         - maybe-tilde-interpolation
 
+  group-path-pattern-body:
+    - meta_include_prototype: false
+    - meta_scope: meta.string.shell string.unquoted.shell
+    - include: string-path-pattern-content
+    - include: word-end
+
+  string-path-patterns:
+    # This context consumes glob patterns within contexts
+    # which support redirections or pipelines.
+    - match: (?=\S)
+      push: string-path-pattern
+
   string-path-pattern:
     - match: (/)dev(/)null{{word_break}}
       scope: meta.path.shell constant.language.null.shell
@@ -2352,11 +2374,15 @@ contexts:
 
   pattern-group-content:
     - include: string-unquoted-content
-    - include: pattern-groups
+    - include: pattern-group-groups
     - include: pattern-group-charsets
     - include: pattern-group-operators
     - include: pattern-common
 
+  pattern-group-groups:
+    # required to distinguish nested groups in ZSH
+    - include: pattern-groups
+
   pattern-group-charsets:
     - match: (?=\[)
       branch_point: pattern-group-charset
@@ -2410,10 +2436,7 @@ contexts:
     - clear_scopes: 1  # clear `string.unquoted`
     - meta_include_prototype: false
     - meta_scope: meta.group.regexp.shell string.unquoted.shell
-    - match: \)
-      scope: punctuation.section.group.end.regexp.shell
-      pop: 1
-    - include: line-continuations
+    - include: pattern-group-end
     - include: eregexp-group-content
 
   eregexp-group-content:
@@ -2888,12 +2911,15 @@ contexts:
     - meta_include_prototype: false
     - meta_scope: meta.group.regexp.shell string.unquoted.shell
     - include: pattern-group-end
+    - include: expansion-parameter-pattern-group-content
+    - include: brace-pop
+
+  expansion-parameter-pattern-group-content:
     - include: string-unquoted-content
     - include: expansion-parameter-pattern-groups
     - include: expansion-parameter-pattern-group-charsets
     - include: pattern-group-operators
     - include: pattern-common
-    - include: brace-pop
 
   expansion-parameter-pattern-group-charsets:
     - match: (?=\[)
@@ -2969,6 +2995,10 @@ contexts:
     - match: (--|[-+]){{identifier}}
       scope: invalid.illegal.parameter.shell
 
+  illegal-pipeseps:
+    - match: '[{{pipe_seps}}]'
+      scope: invalid.illegal.unexpected-token.shell
+
   illegal-stray:
     - match: '[)}\]]'
       scope: invalid.illegal.stray.shell
@@ -3007,6 +3037,10 @@ contexts:
     - match: ''
       pop: 1
 
+  pipesep-pop:
+    - match: (?=[{{pipe_seps}}])
+      pop: 1
+
   word-end:
     - match: '{{word_break}}'
       pop: 1
@@ -3055,7 +3089,8 @@ variables:
   # A character that, when unquoted, separates words. A metacharacter is a
   # space, tab, newline, or one of the following characters: ‘|’, ‘&’, ‘;’,
   # ‘(’, ‘)’, ‘<’, or ‘>’.
-  metachar: '[\s|&;()<>]'
+  metachar: '[\s(){{pipe_seps}}]'
+  pipe_seps: '\|&<>;'
   wspace: (?:\s+|^)
 
   # Indentation and whitespace patterns
@@ -3073,6 +3108,8 @@ variables:
   # Filename expansions
   pathlist_separator: :(?=\$|(?:~|\.?\.)?/(?!/))
 
+  illegal_group_separators: '[({{pipe_seps}}]'
+
   # POSIX extended regexp quantifiers
   character_quantifier: '[?*+]'
   lazy_or_possessive: '[?+]?'
@@ -3083,7 +3120,7 @@ variables:
     | lower | print | punct | space | upper | word | xdigit )
 
   # Numbers
-  dec_break: (?=[\s|&;()<>])
+  dec_break: '{{word_break}}'
   dec_digit: \d
   hex_digit: \h
   oct_digit: '[0-7]'
diff --git a/ShellScript/Bash/tests/syntax_test_scope.bash b/ShellScript/Bash/tests/syntax_test_scope.bash
index 881eb20017..e2ee269de6 100644
--- a/ShellScript/Bash/tests/syntax_test_scope.bash
+++ b/ShellScript/Bash/tests/syntax_test_scope.bash
@@ -2255,12 +2255,10 @@ case var in
 #^ meta.statement.conditional.case.body.shell
 # ^^ meta.clause.patterns.shell - meta.string - meta.group - string
 #   ^^^^ meta.clause.patterns.shell meta.string.shell string.unquoted.shell - meta.groupD
-#       ^ meta.clause.patterns.shell - meta.string - meta.group - string
-#        ^ meta.clause.patterns.shell meta.string.shell string.unquoted.shell - meta.groupD
-#         ^ meta.clause.patterns.shell - meta.string - meta.group - string
+#       ^^^ meta.clause.patterns.shell - meta.string - meta.group - string
 #          ^^^^ meta.statement.conditional.case.end.shell
 # ^ punctuation.section.patterns.begin.shell
-#        ^ meta.string.shell string.unquoted.shell
+#        ^ invalid.illegal.unexpected-token.shell
 #          ^^^^ keyword.control.conditional.endcase.shell
 #              ^ - meta.conditional
 
@@ -8128,7 +8126,7 @@ stash) || true)
 #       ^ punctuation.section.group.end.regexp.shell
 #        ^ constant.other.wildcard.asterisk.shell
 
-: +(bar|qux) | wc
+: +(foo|bar)|baz
 #^^ meta.function-call.arguments.shell - meta.group
 #  ^^^^^^^^^ meta.function-call.arguments.shell meta.group.regexp.shell
 #           ^ - meta.function-call - meta.group
@@ -8136,7 +8134,44 @@ stash) || true)
 #  ^ punctuation.section.group.begin.regexp.shell
 #      ^ keyword.operator.alternation.regexp.shell
 #          ^ punctuation.section.group.end.regexp.shell
-#            ^ keyword.operator.assignment.pipe.shell
+#           ^ keyword.operator.assignment.pipe.shell
+#            ^^^ variable.function.shell
+
+: +(foo&bar)|baz  # `&` terminates group and command arguments
+#  ^^^^^^^^^ meta.group.regexp.shell string.unquoted.shell
+#           ^^^^^ - meta.group
+#  ^ punctuation.section.group.begin.regexp.shell
+#      ^ - keyword
+#          ^ punctuation.section.group.end.regexp.shell
+#           ^ keyword.operator.assignment.pipe.shell
+#            ^^^ variable.function.shell
+
+: +(foo;bar)|baz  # `;` terminates group and command arguments
+#  ^^^^^^^^^ meta.group.regexp.shell string.unquoted.shell
+#           ^^^^^ - meta.group
+#  ^ punctuation.section.group.begin.regexp.shell
+#      ^ - keyword
+#          ^ punctuation.section.group.end.regexp.shell
+#           ^ keyword.operator.assignment.pipe.shell
+#            ^^^ variable.function.shell
+
+: +(foo>bar)|baz  # `>` terminates group and command arguments
+#  ^^^^^^^^^ meta.group.regexp.shell string.unquoted.shell
+#           ^^^^^ - meta.group
+#  ^ punctuation.section.group.begin.regexp.shell
+#      ^ - keyword
+#          ^ punctuation.section.group.end.regexp.shell
+#           ^ keyword.operator.assignment.pipe.shell
+#            ^^^ variable.function.shell
+
+: +(foo ]]       # unquoted redirections are illegal
+# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell
+#^^^^^^^^^^^^^^ meta.compound.conditional.shell
+#              ^ - meta.conditional
+#       ^^ keyword.operator.comparison.shell
+#          ^ invalid.illegal.unexpected-token.shell
+#            ^^ punctuation.section.compound.end.shell
+
+[[ ( $foo =~ > ) ]]   # unquoted redirections are illegal
+# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell
+#^^ meta.compound.conditional.shell - meta.group
+#  ^^^^^^^^^^^^^ meta.compound.conditional.shell meta.group.shell
+#               ^^^ meta.compound.conditional.shell - meta.group
+#                  ^ - meta.conditional
+#         ^^ keyword.operator.comparison.shell
+#            ^ invalid.illegal.unexpected-token.shell
+#              ^ punctuation.section.group.end.shell
+#                ^^ punctuation.section.compound.end.shell
+
+[[ $foo =~ (>) ]]     # unquoted redirections allowed in pattern groups
+# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell
+#^^^^^^^^^^ meta.compound.conditional.shell - meta.group
+#          ^^^ meta.compound.conditional.shell meta.string.regexp.shell meta.group.regexp.shell string.unquoted.shell
+#             ^^^ meta.compound.conditional.shell - meta.group
+#                ^ - meta.conditional
+#       ^^ keyword.operator.comparison.shell
+#          ^ punctuation.section.group.begin.regexp.shell
+#            ^ punctuation.section.group.end.regexp.shell
+#              ^^ punctuation.section.compound.end.shell
+
+[[ ( $foo =~ (>) ) ]] # unquoted redirections allowed in pattern groups
+# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell
+#^^ meta.compound.conditional.shell - meta.group
+#  ^^^^^^^^^^ meta.compound.conditional.shell meta.group.shell - meta.group meta.group
+#            ^^^ meta.compound.conditional.shell meta.group.shell meta.string.regexp.shell meta.group.regexp.shell string.unquoted.shell
+#               ^ meta.compound.conditional.shell meta.group.shell - meta.group meta.group
+#                 ^^^ meta.compound.conditional.shell - meta.group
+#                    ^ - meta.conditional
+#         ^^ keyword.operator.comparison.shell
+#            ^ punctuation.section.group.begin.regexp.shell
+#              ^ punctuation.section.group.end.regexp.shell
+#                ^ punctuation.section.group.end.shell
+#                  ^^ punctuation.section.compound.end.shell
+
+[[ $foo =~ \> ]]      # escaped redirections are allowed
+# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell
+#^^^^^^^^^^^^^^^ meta.compound.conditional.shell
+#               ^ - meta.conditional
+#       ^^ keyword.operator.comparison.shell
+#          ^^ constant.character.escape.shell
+#             ^^ punctuation.section.compound.end.shell
+
+[[ ( $foo =~ \> ) ]]  # escaped redirections are allowed
+# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell
+#^^ meta.compound.conditional.shell - meta.group
+#  ^^^^^^^^^^^^^^ meta.compound.conditional.shell meta.group.shell
+#                ^^^ meta.compound.conditional.shell - meta.group
+#                   ^ - meta.conditional
+#         ^^ keyword.operator.comparison.shell
+#            ^^ constant.character.escape.shell
+#               ^ punctuation.section.group.end.shell
+#                 ^^ punctuation.section.compound.end.shell
+
+[[ $foo =~ ">" ]]
+# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell
+#^^^^^^^^^^^^^^^^ meta.compound.conditional.shell
+#                ^ - meta.conditional
+#       ^^ keyword.operator.comparison.shell
+#          ^^^ string
+#              ^^ punctuation.section.compound.end.shell
+
+[[ ( $foo =~ ">" ) ]]
+# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell
+#^^ meta.compound.conditional.shell - meta.group
+#  ^^^^^^^^^^ meta.compound.conditional.shell meta.group.shell - meta.string.regexp
+#            ^^^ meta.compound.conditional.shell meta.group.shell meta.string.regexp.shell
+#               ^^ meta.compound.conditional.shell meta.group.shell - meta.string
+#                 ^^^ meta.compound.conditional.shell - meta.group
+#                    ^ - meta.conditional
+#         ^^ keyword.operator.comparison.shell
+#                ^ punctuation.section.group.end.shell
+#                  ^^ punctuation.section.compound.end.shell
+
 
 ###############################################################################
 # 3.6 Redirections                                                            #
@@ -10058,10 +10357,7 @@ declare -ai bar=(foo b*$r b-20 'b?r' "b*z" [100]=val [100] =val  )
+#                     ^ invalid.illegal.unexpected-token.shell
+#                       ^ invalid.illegal.unexpected-token.shell
+#                         ^ invalid.illegal.unexpected-token.shell
+#                           ^ invalid.illegal.unexpected-token.shell
+#                             ^ invalid.illegal.unexpected-token.shell
+#                               ^ invalid.illegal.unexpected-token.shell
+
 # associative array with explicit keys and arithmetic values
 declare -iA var=(
 # <- meta.declaration.variable.shell keyword.declaration.variable.shell
@@ -10422,6 +10717,13 @@ declare -iA var=(
 #     ^ punctuation.section.item-access.end.shell
 #       ^^^^ invalid.illegal.unexpected-token.shell
 
+  | & ; ( < >
+# ^ invalid.illegal.unexpected-token.shell
+#   ^ invalid.illegal.unexpected-token.shell
+#     ^ invalid.illegal.unexpected-token.shell
+#       ^ invalid.illegal.unexpected-token.shell
+#         ^ invalid.illegal.unexpected-token.shell
+#           ^ invalid.illegal.unexpected-token.shell
 )
 # <- meta.declaration.variable.shell meta.assignment.r-value.shell meta.sequence.list.shell punctuation.section.sequence.end.shell
 #^ - meta
diff --git a/ShellScript/Zsh.sublime-syntax b/ShellScript/Zsh.sublime-syntax
index af68619bce..10306ddb5f 100644
--- a/ShellScript/Zsh.sublime-syntax
+++ b/ShellScript/Zsh.sublime-syntax
@@ -216,7 +216,7 @@ contexts:
       scope: punctuation.section.sequence.end.shell.zsh
       pop: 1
     - include: comments
-    - include: string-path-patterns
+    - include: group-path-patterns
 
 ###[ ARITHMETIC EXPRESSIONS ]##################################################
 
@@ -266,64 +266,58 @@ contexts:
 ###[ REDIRECTIONS AND HEREDOCS ]###############################################
 
   redirection-input:
-    # maybe a zsh glob range, starting a pattern or a input redirection
+    # This context consumes patterns beginning with glob ranges (e.g.: `<1-20>`)
+    # or input redirection (e.g.: <"/path/file").
     - match: (?=\d*<)
-      branch_point: zsh-glob-range
+      branch_point: zsh-redirection-glob-range
       branch:
-        - zsh-glob-range-begin
+        - zsh-redirection-glob-range-begin
         - zsh-redirection-input
       pop: 1
 
-  zsh-redirection-input:
+  zsh-redirection-glob-range-begin:
     - meta_include_prototype: false
-    - match: (\d*)(<&?)
+    - match: (\d*)(<)
       captures:
-        1: meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell
-        2: keyword.operator.assignment.redirection.shell
-      set:
-        - redirection-meta
-        - redirection-descriptor
-
-  zsh-glob-range-begin:
-    - meta_include_prototype: false
-    - match: \<(?!&)
-      scope: punctuation.definition.range.begin.shell.zsh
+        1: string.unquoted.shell
+        2: punctuation.definition.range.begin.shell.zsh
       set:
         - string-path-pattern-body
-        - zsh-glob-range-end
+        - zsh-redirection-glob-range-end
         - zsh-glob-range-number
-        - zsh-glob-range-operator
+        - zsh-redirection-glob-range-operator
         - zsh-glob-range-number
-    - match: \d+
-      scope: meta.string.shell string.unquoted.shell
-    - include: zsh-glob-range-fail
+    - include: zsh-redirection-glob-range-fail
 
-  zsh-glob-range-end:
-    - clear_scopes: 1 # clear string scope
+  zsh-redirection-glob-range-end:
+    - clear_scopes: 1  # clear `string.unquoted`
     - meta_scope: meta.range.shell.zsh
+    - meta_include_prototype: false
     - match: \>
       scope: punctuation.definition.range.end.shell.zsh
       pop: 1
-    - include: zsh-glob-range-fail
+    - include: zsh-redirection-glob-range-fail
 
-  zsh-glob-range-number:
-    - match: (?=[\d$])
-      scope: keyword.operator.arithmetic.shell
-      set: dec-number-body
-    - include: line-continuations
-    - include: immediately-pop
-
-  zsh-glob-range-operator:
+  zsh-redirection-glob-range-operator:
     # range operator is crucial
-    - match: \-
-      scope: keyword.operator.range.shell.zsh
-      pop: 1
-    - include: zsh-glob-range-fail
+    - meta_include_prototype: false
+    - include: zsh-glob-range-operator
+    - include: zsh-redirection-glob-range-fail
 
-  zsh-glob-range-fail:
+  zsh-redirection-glob-range-fail:
     - include: line-continuations
     - match: ''
-      fail: zsh-glob-range
+      fail: zsh-redirection-glob-range
+
+  zsh-redirection-input:
+    - meta_include_prototype: false
+    - match: (\d*)(<&?)
+      captures:
+        1: meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell
+        2: keyword.operator.assignment.redirection.shell
+      set:
+        - redirection-meta
+        - redirection-descriptor
 
 ###[ LITERALS ]################################################################
 
@@ -347,24 +341,26 @@ contexts:
 
 ###[ STRING PATH PATTERN MATCHING ]############################################
 
-  string-path-patterns:
+  group-path-pattern-body:
     - meta_prepend: true
-    - match: \^
-      scope: keyword.operator.logical.regexp.shell.zsh
-      push:
-        - string-path-pattern-body
-        - maybe-tilde-interpolation
+    - include: zsh-group-glob-ranges
 
-  string-path-pattern:
+  string-path-pattern-body:
     - meta_prepend: true
-    - match: \^
-      scope: keyword.operator.logical.regexp.shell.zsh
-      set:
-        - string-path-pattern-body
-        - maybe-tilde-interpolation
+    - include: zsh-string-glob-ranges
+
+###[ PATH PATTERN MATCHING ]###################################################
+
+  path-pattern-content:
+    - meta_prepend: true
+    - include: zsh-string-glob-ranges
 
 ###[ SHELL PATTERN MATCHING ]##################################################
 
+  pattern-main-content:
+    - meta_prepend: true
+    - include: zsh-string-glob-ranges
+
   pattern-groups:
     - include: zsh-glob-flags
     # prefer EXTENDED_GLOB over optional KSH_GLOB
@@ -374,20 +370,19 @@ contexts:
         - zsh-glob-qualifier
         - pattern-group
 
-  pattern-group-content:
-    - include: string-unquoted-content
-    - include: pattern-group-groups
-    - include: pattern-group-charsets
-    - include: pattern-group-operators
-    - include: pattern-common
-
   pattern-group-groups:
     - include: zsh-glob-flags
+    - include: zsh-string-glob-ranges
+    # zsh glob range with string scope cleared
     # only groups are valid in groups, no glob qualifiers
     - match: \(
       scope: punctuation.section.group.begin.regexp.shell
       push: pattern-group-body
 
+  pattern-group-body:
+    - meta_append: true
+    - include: pipesep-pop
+
   pattern-common:
     - meta_prepend: true
     - match: '[~^]'
@@ -488,16 +483,11 @@ contexts:
 
   expansion-parameter-pattern-groups:
     - include: zsh-glob-flags
+    - include: zsh-parameter-glob-ranges
     # prefer EXTENDED_GLOB over optional KSH_GLOB
     - match: \(
       scope: punctuation.section.group.begin.regexp.shell
       push: expansion-parameter-pattern-group-body
-    # a pattern range `<1-20>` or literal `<`, but no redirection
-    - match: (?=<)
-      branch_point: zsh-parameter-pattern-range
-      branch:
-        - zsh-parameter-pattern-range-begin
-        - immediately-pop
 
   zsh-parameter-flags:
     # 14.3.1 Parameter Expansion Flags
@@ -531,35 +521,48 @@ contexts:
     - match: '[-~#%*@0ABCDEFLMNOPQRSTUVWXabcefikmnopqtuvwz]'
       scope: storage.modifier.expansion.flag.shell.zsh
 
-  zsh-parameter-pattern-range-begin:
-    - clear_scopes: 1
+  zsh-parameter-glob-ranges:
+    # This context consumes glob ranges (e.g.: `<1-20>`) within expansions
+    # or scopes `<` literal string otherwise without poping owning context.
+    - match: (?=<)
+      branch_point: zsh-parameter-glob-range
+      branch:
+        - zsh-parameter-glob-range-begin
+        - zsh-parameter-glob-range-fallback
+
+  zsh-parameter-glob-range-begin:
+    - clear_scopes: 1  # clear `string.unquoted`
     - meta_include_prototype: false
     - match: \<
       scope: punctuation.definition.range.begin.shell.zsh
       push:
-        - zsh-parameter-pattern-range-end
+        - zsh-parameter-glob-range-end
         - zsh-glob-range-number
-        - zsh-parameter-pattern-range-operator
+        - zsh-parameter-glob-range-operator
         - zsh-glob-range-number
 
-  zsh-parameter-pattern-range-end:
+  zsh-parameter-glob-range-end:
+    - meta_include_prototype: false
     - meta_scope: meta.range.shell.zsh
     - match: \>
       scope: punctuation.definition.range.end.shell.zsh
       pop: 2
-    - include: zsh-parameter-pattern-range-fail
+    - include: zsh-parameter-glob-range-fail
 
-  zsh-parameter-pattern-range-fail:
+  zsh-parameter-glob-range-fail:
     - include: line-continuations
     - match: ''
-      fail: zsh-parameter-pattern-range
+      fail: zsh-parameter-glob-range
 
-  zsh-parameter-pattern-range-operator:
-    # range operator is crucial
-    - match: \-
-      scope: keyword.operator.range.shell.zsh
+  zsh-parameter-glob-range-fallback:
+    # scope incomplete glob ranges literal
+    - match: \<+
       pop: 1
-    - include: zsh-parameter-pattern-range-fail
+
+  zsh-parameter-glob-range-operator:
+    # range operator is crucial
+    - include: zsh-glob-range-operator
+    - include: zsh-parameter-glob-range-fail
 
   zsh-parameter-subscription:
     - meta_include_prototype: false
@@ -617,6 +620,112 @@ contexts:
     - include: zsh-modifier-end-ahead
     - include: zsh-glob-qualifier-content
 
+###[ ZSH GLOB RANGES ]#########################################################
+
+  zsh-group-glob-ranges:
+    # This context consumes glob ranges (e.g.: `<1-20>`) in groups or sequences
+    # or scopes `<` invalid illegal otherwise without poping owning context.
+    - match: (?=<)
+      branch_point: zsh-group-glob-range
+      branch:
+        - zsh-group-glob-range-begin
+        - zsh-group-glob-range-fallback
+
+  zsh-group-glob-range-begin:
+    - clear_scopes: 1  # clear `string.unquoted`
+    - meta_include_prototype: false
+    - match: \<
+      scope: punctuation.definition.range.begin.shell.zsh
+      push:
+        - zsh-group-glob-range-end
+        - zsh-glob-range-number
+        - zsh-group-glob-range-operator
+        - zsh-glob-range-number
+
+  zsh-group-glob-range-end:
+    - meta_include_prototype: false
+    - meta_scope: meta.range.shell.zsh
+    - match: \>
+      scope: punctuation.definition.range.end.shell.zsh
+      pop: 2
+    - include: zsh-group-glob-range-fail
+
+  zsh-group-glob-range-fail:
+    - include: line-continuations
+    - match: ''
+      fail: zsh-group-glob-range
+
+  zsh-group-glob-range-fallback:
+    - meta_include_prototype: false
+    - match: \<+
+      scope: invalid.illegal.unexpected-token.shell.zsh
+      pop: 1
+
+  zsh-group-glob-range-operator:
+    # range operator is crucial
+    - meta_include_prototype: false
+    - include: zsh-glob-range-operator
+    - include: zsh-group-glob-range-fail
+
+  zsh-string-glob-ranges:
+    # This context consumes glob ranges (e.g.: `<1-20>`)
+    # within top-level patterns or strings
+    # or pops owning context off stack to consume input redirection.
+    - match: (?=<)
+      branch_point: zsh-string-glob-range
+      branch:
+        - zsh-string-glob-range-begin
+        - zsh-string-glob-range-fallback
+
+  zsh-string-glob-range-begin:
+    - clear_scopes: 1  # clear `string.unquoted`
+    - meta_include_prototype: false
+    - match: \<
+      scope: punctuation.definition.range.begin.shell.zsh
+      push:
+        - zsh-string-glob-range-end
+        - zsh-glob-range-number
+        - zsh-string-glob-range-operator
+        - zsh-glob-range-number
+
+  zsh-string-glob-range-end:
+    - meta_include_prototype: false
+    - meta_scope: meta.range.shell.zsh
+    - match: \>
+      scope: punctuation.definition.range.end.shell.zsh
+      pop: 2
+    - include: zsh-string-glob-range-fail
+
+  zsh-string-glob-range-fail:
+    - include: line-continuations
+    - match: ''
+      fail: zsh-string-glob-range
+
+  zsh-string-glob-range-fallback:
+    # also pop parent context off stack
+    - meta_include_prototype: false
+    - match: ''
+      pop: 2
+
+  zsh-string-glob-range-operator:
+    # range operator is crucial
+    - meta_include_prototype: false
+    - include: zsh-glob-range-operator
+    - include: zsh-string-glob-range-fail
+
+  zsh-glob-range-number:
+    # range numbers are optional
+    - meta_include_prototype: false
+    - match: (?=[\d$])
+      set: dec-number-body
+    - include: line-continuations
+    - include: immediately-pop
+
+  zsh-glob-range-operator:
+    - match: \-
+      scope: keyword.operator.range.shell.zsh
+      pop: 1
+
 ###[ ZSH GLOB QUALIFIERS ]#####################################################
 
   zsh-glob-qualifier:
@@ -999,7 +1108,7 @@ variables:
   shebang_language: \bzsh\b
 
   # Numbers
-  dec_break: (?=[\s|&;()}<>])
+  dec_break: (?![^\s|&;()}<>])  # word_break without `{`
   dec_digit: '[\d_]'
   hex_digit: '[\h_]'
   oct_digit: '[0-7_]'
@@ -1013,6 +1122,8 @@ variables:
 
   glob_string_quote: ([^])}>\s\w])
 
+  illegal_group_separators: '[|&;>]'
+
   # 9.3.1 Hook Functions
   hook_functions: |-
     (?x: chpwd | periodic | precmd | preexec | zshaddhistory | zshexit ){{cmd_break}}
diff --git a/ShellScript/Zsh/tests/syntax_test_scope.zsh b/ShellScript/Zsh/tests/syntax_test_scope.zsh
index 0e7f2ef2ab..62606ac488 100644
--- a/ShellScript/Zsh/tests/syntax_test_scope.zsh
+++ b/ShellScript/Zsh/tests/syntax_test_scope.zsh
@@ -336,18 +336,23 @@ if [[ -f ~./foo ]] then { echo 'yes' } elif [[  ]] then { echo 'no' } else { ech
 #                                                                          ^^^^^^^^^^^^^^^^ meta.block.shell
 
 # for name ... ( word ... ) sublist
-for name ( word1 $word2 ) print $name
+for name ( word1 $word2 | & ; < > ) print $name
 # <- keyword.control.loop.for.shell
 #^^ keyword.control.loop.for.shell
 #   ^^^^ variable.other.readwrite.shell
-#        ^^^^^^^^^^^^^^^^ meta.sequence.list.shell
+#        ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.sequence.list.shell
 #        ^ punctuation.section.sequence.begin.shell
 #          ^^^^^ meta.string.shell string.unquoted.shell
 #                ^^^^^^ meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell
-#                       ^ punctuation.section.sequence.end.shell
-#                         ^^^^^^^^^^^ meta.function-call
-#                         ^^^^^ support.function.shell
-#                               ^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell
+#                       ^ invalid.illegal.unexpected-token.shell
+#                         ^ invalid.illegal.unexpected-token.shell
+#                           ^ invalid.illegal.unexpected-token.shell
+#                             ^ invalid.illegal.unexpected-token.shell
+#                               ^ invalid.illegal.unexpected-token.shell
+#                                 ^ punctuation.section.sequence.end.shell
+#                                   ^^^^^^^^^^^ meta.function-call
+#                                   ^^^^^ support.function.shell
+#                                         ^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell
 
 # for name ... [ in word ... ] term sublist
 for name in word1 word2; echo me;
@@ -4075,6 +4080,14 @@ dyn_dir_name() {
 #       ^^ constant.character.escape.shell
 #         ^ punctuation.definition.set.end.regexp.shell
 
+## Zsh Glob Ranges
+
+./cmd<1-2>
+# <- meta.function-call.identifier.shell meta.command.shell variable.function.shell constant.other.path.self.shell
+#^^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+#    ^^^^^ meta.function-call.identifier.shell meta.command.shell meta.range.shell.zsh
+#         ^ - meta.function-call - meta.range
+
 : <-> # Matches any number
 # ^^^ meta.range.shell.zsh
 # ^ punctuation.definition.range.begin.shell.zsh
@@ -4117,7 +4130,7 @@ dyn_dir_name() {
 #                      ^^^^^^^^^^^^^^^^^^^^ meta.range.shell.zsh meta.interpolation.parameter.shell - string
 #                                          ^ meta.range.shell.zsh punctuation.definition.range.end.shell.zsh - string
 
-: <${start##<1-5>0<1-}->
+: <${start##<1-5>0<1-}->  # optional glob range in default values, with `<` treated literal
 # ^ meta.range.shell.zsh - meta.interpolation - meta.range meta.range
 #  ^^^^^^^^^ meta.range.shell.zsh meta.interpolation.parameter.shell - meta.range meta.range
 #           ^^^^^ meta.range.shell.zsh meta.interpolation.parameter.shell meta.string.regexp.shell meta.range.shell.zsh - string
@@ -4126,7 +4139,7 @@ dyn_dir_name() {
 #                     ^^ meta.range.shell.zsh
 #                       ^ - meta.range
 
-: <-${start/fo>bar/bz}>
+: <-${start/fo>bar/bz}>  # optional glob range in replacements, with `<` treated literal
 # ^^ meta.range.shell.zsh - meta.interpolation - meta.range meta.range
 #   ^^^^^^^^^^^ meta.range.shell.zsh meta.interpolation.parameter.shell - meta.range meta.range
 #              ^^^ meta.range.shell.zsh meta.interpolation.parameter.shell meta.string.regexp.shell meta.range.shell.zsh - string
@@ -4148,7 +4161,7 @@ dyn_dir_name() {
 #                               ^ - keyword - punctuation
 #                                  ^ punctuation.definition.range.end.shell.zsh
 
-: foo<5-21> foo<5-21>bar <5-21>bar
+: foo<5-21> foo<5-21>bar <5-21>bar  1<1-5>0 <1-5>0  # not numbers, but a patterns
+: 1<1-5> 1<1-5>0 <1-5>0 <0  # not numbers, but a patterns
 # ^ meta.string.shell string.unquoted.shell
 #  ^^^^^ meta.string.shell meta.range.shell.zsh - string
 #       ^ - meta.range meta.string - string
@@ -4169,6 +4184,191 @@ dyn_dir_name() {
 #               ^ - meta.range meta.string - string
 #                ^^^^^ meta.string.shell meta.range.shell.zsh - string
 #                     ^ meta.string.shell string.unquoted.shell
+#                       ^ meta.redirection.shell keyword.operator.assignment.redirection.shell
+#                        ^ meta.redirection.shell meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell
+
+: (<1-5>foo|bar<1-)<1-5>  # glob ranges in pattern groups
+# ^ meta.string.shell meta.group.regexp.shell string.unquoted.shell punctuation.section.group.begin.regexp.shell
+#  ^^^^^ meta.string.shell meta.group.regexp.shell meta.range.shell.zsh - string
+#       ^^^^^^^ meta.string.shell meta.group.regexp.shell string.unquoted.shell
+#              ^^^ meta.redirection.shell
+#                 ^ invalid.illegal.stray.shell
+#                  ^^^^^ meta.string.shell meta.range.shell.zsh - string
+
+## glob ranges in parameter assignments
+
+a=<1-4>foo  # glob range beginning assignment value
+# <- meta.assignment.l-value.shell variable.other.readwrite.shell
+#^ meta.assignment.shell keyword.operator.assignment.shell
+# ^^^^^ meta.assignment.r-value.shell meta.string.shell meta.range.shell.zsh
+#      ^^^ meta.assignment.r-value.shell meta.string.shell string.unquoted.shell
+
+a=foo<1-4>bar  # glob range within assignment value
+# <- meta.assignment.l-value.shell variable.other.readwrite.shell
+#^ meta.assignment.shell keyword.operator.assignment.shell
+# ^^^ meta.assignment.r-value.shell meta.string.shell string.unquoted.shell
+#    ^^^^^ meta.assignment.r-value.shell meta.string.shell meta.range.shell.zsh
+#         ^^^ meta.assignment.r-value.shell meta.string.shell string.unquoted.shell
+
+a=foo<1-4>foofoo [foo]=<3-4>bar [buz]=s(<5-6>uf) <10-foo ^~or)  # glob ranges within indexed or associative arrays
+# <- meta.assignment.l-value.shell variable.other.readwrite.shell
+#^ meta.assignment.shell keyword.operator.assignment.shell
+# ^ meta.assignment.r-value.shell meta.sequence.list.shell - meta.string
+#  ^^^^^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.shell meta.range.shell.zsh
+#       ^^^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.shell string.unquoted.shell
+#          ^^^^^^^ meta.assignment.r-value.shell meta.sequence.list.shell - meta.string meta.item-access.shell
+#                 ^^^^^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.shell meta.range.shell.zsh - string
+#                      ^^^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.shell string.unquoted.shell
+#                         ^ meta.assignment.r-value.shell meta.sequence.list.shell - meta.string
+#                          ^^^^^^ meta.assignment.r-value.shell meta.sequence.list.shell
+#                                ^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.shell - meta.group
+#                                 ^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.shell meta.group.regexp.shell - meta.range
+#                                  ^^^^^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.shell meta.group.regexp.shell meta.range.shell.zsh - string
+#                                       ^^^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.shell meta.group.regexp.shell - meta.range
+#                                          ^ meta.assignment.r-value.shell meta.sequence.list.shell - meta.string
+#                                           ^ meta.assignment.r-value.shell meta.sequence.list.shell invalid.illegal.unexpected-token.shell.zsh
+#                                            ^^^^^^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.shell string.unquoted.shell
+#                                                   ^^^^^^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.shell
+#                                                   ^ keyword.operator.logical.regexp.shell.zsh
+#                                                    ^ variable.language.tilde.shell
+#                                                     ^ invalid.illegal.unexpected-token.shell.zsh
+#                                                      ^^^ string.unquoted.shell
+#                                                         ^ meta.assignment.r-value.shell meta.sequence.list.shell invalid.illegal.unexpected-token.shell
+#                                                          ^^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.shell string.unquoted.shell
+#                                                            ^ meta.assignment.r-value.shell meta.sequence.list.shell punctuation.section.sequence.end.shell
+
+declare -A a=(key <1-2>value key <1-2ill key ^~or)  # glob ranges within associative arrays
+#            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.assignment.r-value.shell meta.sequence.list.shell
+#             ^^^ entity.name.key.shell
+#                 ^^^^^ meta.string.shell meta.range.shell.zsh - string
+#                      ^^^^^ meta.string.shell string.unquoted.shell
+#                            ^^^ entity.name.key.shell
+#                                ^ invalid.illegal.unexpected-token.shell.zsh
+#                                 ^^^^^^ meta.string.shell string.unquoted.shell
+#                                        ^^^ entity.name.key.shell
+#                                            ^^^^^^ meta.string.shell
+#                                            ^ keyword.operator.logical.regexp.shell.zsh
+#                                             ^ variable.language.tilde.shell
+#                                              ^ invalid.illegal.unexpected-token.shell.zsh
+#                                               ^^^ string.unquoted.shell
+#                                                  ^ invalid.illegal.unexpected-token.shell - entity - string - keyword
+#                                                   ^^ entity.name.key.shell
+
+## glob ranges in case clause patterns
+
+case $foo in
+  <1-2>pat | pat<1-2> | <-a>ny ) ;;
+# ^^^^^^^^^^^^^^^^^^^^ meta.clause.patterns.shell
+# ^^^^^ meta.string.shell meta.range.shell.zsh - string
+#      ^^^ meta.string.shell string.unquoted.shell
+#          ^ keyword.operator.logical.shell
+#            ^^^ meta.string.shell string.unquoted.shell
+#               ^^^^^ meta.string.shell meta.range.shell.zsh - string
+#                     ^ keyword.operator.logical.shell
+#                       ^ invalid.illegal.unexpected-token.shell
+#                        ^^ meta.string.shell string.unquoted.shell
+#                          ^ invalid.illegal.unexpected-token.shell
+#                           ^^ meta.string.shell string.unquoted.shell
+
+  (<1-2>|<-) | foo<1-2> | <- ) ;;
+# ^ meta.clause.patterns.shell meta.string.shell meta.group.regexp.shell - meta.range
+#  ^^^^^ meta.clause.patterns.shell meta.string.shell meta.group.regexp.shell meta.range.shell.zsh
+#       ^ meta.clause.patterns.shell meta.string.shell meta.group.regexp.shell - meta.range
+#        ^^ meta.clause.patterns.shell meta.string.shell - meta.group
+#          ^ meta.clause.patterns.shell - meta.string
+#           ^ meta.clause.shell - meta.clause.patterns
+#            ^^^^^^^^^^^^^^^^^^ meta.clause.body.shell
+#        ^ invalid.illegal.unexpected-token.shell.zsh
+#         ^ string.unquoted.shell
+#          ^ punctuation.section.patterns.end.shell
+#            ^ keyword.operator.assignment.pipe.shell
+#              ^^^ meta.command.shell variable.function.shell
+#                 ^^^^^ meta.range.shell.zsh
+#                       ^ keyword.operator.assignment.pipe.shell
+#                         ^^ meta.redirection.shell
+#                         ^ keyword.operator.assignment.redirection.shell
+#                          ^ variable.language.stdio.shell
+#                            ^ invalid.illegal.stray.shell
+#                              ^^ punctuation.terminator.clause.shell
+esac
+
+# glob in test expressions
+
+[[ $foo == <1-2>bar || $foo == b<1-2>r || $foo == bar<1-2> || $foo == br ]]
+# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell
+#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell
+#                                                                             ^ - meta.compound
+#          ^^^^^ meta.string.regexp.shell meta.range.shell.zsh
+#               ^^^ meta.string.regexp.shell string.unquoted.shell
+#                              ^ meta.string.regexp.shell string.unquoted.shell
+#                               ^^^^^ meta.string.regexp.shell meta.range.shell.zsh
+#                                    ^ meta.string.regexp.shell string.unquoted.shell
+#                                                 ^^^ meta.string.regexp.shell string.unquoted.shell
+#                                                    ^^^^^ meta.string.regexp.shell meta.range.shell.zsh
+
+[[ ( $foo == <1-2>bar ) || ( $foo == b<1-2>r ) || ( $foo == bar<1-2> ) || ( $foo == br ) ]]
+# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell
+#^^ meta.compound.conditional.shell - meta.group
+#  ^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell meta.group.shell
+#                      ^^^^ meta.compound.conditional.shell - meta.group
+#                          ^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell meta.group.shell
+#                                             ^^^^ meta.compound.conditional.shell - meta.group
+#                                                 ^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell meta.group.shell
+#                                                                     ^^^^ meta.compound.conditional.shell - meta.group
+#                                                                         ^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell meta.group.shell
+#                                                                                          ^^^ meta.compound.conditional.shell - meta.group
+#                                                                                             ^ - meta.compound
+#            ^^^^^ meta.string.regexp.shell meta.range.shell.zsh
+#                 ^^^ meta.string.regexp.shell string.unquoted.shell
+#                                    ^ meta.string.regexp.shell string.unquoted.shell
+#                                     ^^^^^ meta.string.regexp.shell meta.range.shell.zsh
+#                                          ^ meta.string.regexp.shell string.unquoted.shell
+#                                                           ^^^ meta.string.regexp.shell string.unquoted.shell
+#                                                              ^^^^^ meta.string.regexp.shell meta.range.shell.zsh
+
+[[ $foo == (<1-2>bar) || $foo == (b<1-2>r) || $foo == (bar<1-2>) || $foo == (br) ]]
+# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell
+#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell
+#                                                                                     ^ - meta.compound
+#           ^^^^^ meta.string.regexp.shell meta.range.shell.zsh
+#                ^^^ meta.string.regexp.shell string.unquoted.shell
+#                                 ^ meta.string.regexp.shell string.unquoted.shell
+#                                  ^^^^^ meta.string.regexp.shell meta.range.shell.zsh
+#                                       ^ meta.string.regexp.shell string.unquoted.shell
+#                                                      ^^^ meta.string.regexp.shell string.unquoted.shell
+#                                                         ^^^^^ meta.string.regexp.shell meta.range.shell.zsh
+
+[[ ( $foo == (<1-2>bar) ) || ( $foo == (b<1-2>r) ) || ( $foo == (bar<1-2>) ) || ( $foo == (br) ) ]]
+# <- meta.compound.conditional.shell punctuation.section.compound.begin.shell
+#^^ meta.compound.conditional.shell - meta.group
+#  ^^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell meta.group.shell
+#                        ^^^^ meta.compound.conditional.shell - meta.group
+#                            ^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell meta.group.shell
+#                                                 ^^^^ meta.compound.conditional.shell - meta.group
+#                                                     ^^^^^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell meta.group.shell
+#                                                                           ^^^^ meta.compound.conditional.shell - meta.group
+#                                                                               ^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell meta.group.shell
+#                                                                                                ^^^^^ meta.compound.conditional.shell - meta.group
+#                                                                                                     ^ - meta.compound
+#             ^^^^^ meta.string.regexp.shell meta.range.shell.zsh
+#                  ^^^ meta.string.regexp.shell string.unquoted.shell
+#                                       ^ meta.string.regexp.shell string.unquoted.shell
+#                                        ^^^^^ meta.string.regexp.shell meta.range.shell.zsh
+#                                             ^ meta.string.regexp.shell string.unquoted.shell
+#                                                                ^^^ meta.string.regexp.shell string.unquoted.shell
+#                                                                   ^^^^^ meta.string.regexp.shell meta.range.shell.zsh
+
+
+## no glob ranges
 
 : 'foo<5-21>bar'
 # ^^^^^^^^^^^^^^ meta.string.shell string.quoted.single.shell - meta.redirection - meta.range
@@ -4188,6 +4388,8 @@ dyn_dir_name() {
 : "thisoutput"
 # ^^^^^^^^^^^^^^^^^^^ meta.string.shell string.quoted.double.shell - meta.redirection - meta.range
 
+## pattern groups
+
 : foo/(a*/)#bar               # bar matches foo/bar, foo/any/bar, foo/any/anyother/bar, ...
 # ^^^^ meta.string.shell string.unquoted.shell
 #     ^^^^^ meta.string.shell meta.group.regexp.shell string.unquoted.shell
@@ -4205,9 +4407,47 @@ dyn_dir_name() {
 #          ^ keyword.operator.assignment.pipe.shell
 #           ^^^ variable.function.shell
 
-a=<1-4>others
-# ^^^^^ meta.assignment.r-value.shell meta.string.shell meta.range.shell.zsh
-#      ^^^^^^ meta.assignment.r-value.shell meta.string.shell string.unquoted.shell
+: (foo&bar)|baz  # `&` terminates group and command arguments
+# ^^^^ meta.group.regexp.shell string.unquoted.shell
+#     ^^^^^^^^^^ - meta.group
+# ^ punctuation.section.group.begin.regexp.shell
+#     ^ keyword.operator.assignment.pipe.shell
+#      ^^^ variable.function.shell
+#         ^ invalid.illegal.stray.shell
+#          ^ keyword.operator.assignment.pipe.shell
+#           ^^^ variable.function.shell
+
+: (foo;bar)|baz  # `;` terminates group and command arguments
+# ^^^^ meta.group.regexp.shell string.unquoted.shell
+#     ^^^^^^^^^^ - meta.group
+# ^ punctuation.section.group.begin.regexp.shell
+#     ^ punctuation.terminator.statement.shell
+#      ^^^ variable.function.shell
+#         ^ invalid.illegal.stray.shell
+#          ^ keyword.operator.assignment.pipe.shell
+#           ^^^ variable.function.shell
+
+: (foo>bar)|baz  # `>` terminates group and command arguments
+# ^^^^ meta.group.regexp.shell string.unquoted.shell
+#     ^^^^ meta.redirection.shell - meta.group
+#         ^^^^^^ - meta.group - meta.redirection
+# ^ punctuation.section.group.begin.regexp.shell
+#     ^ keyword.operator.assignment.redirection.shell
+#      ^^^ string.unquoted.shell
+#         ^ invalid.illegal.stray.shell
+#          ^ keyword.operator.assignment.pipe.shell
+#           ^^^ variable.function.shell
+
+: (foo )
+#          ^ invalid.illegal.unexpected-token.shell
+#            ^ invalid.illegal.unexpected-token.shell
+#              ^ invalid.illegal.unexpected-token.shell
+#                ^ invalid.illegal.unexpected-token.shell
+#                  ^ invalid.illegal.unexpected-token.shell
+
+
 ##############################################################################
 # 15.5 Parameters Set By The Shell
 # https://zsh.sourceforge.io/Doc/Release/Parameters.html#Parameters-Set-By-The-Shell

From 8f231ba57c49bbc1c47a984ad475e35259d33083 Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Mon, 9 Sep 2024 18:07:23 +0200
Subject: [PATCH 105/113] [ShellScript] More natural expansion context names

---
 Makefile/Makefile Shell.sublime-syntax |   3 +-
 Makefile/Makefile.sublime-syntax       |   4 +-
 ShellScript/Bash.sublime-syntax        | 144 ++++++++++++-------------
 ShellScript/Zsh.sublime-syntax         |  26 ++---
 4 files changed, 88 insertions(+), 89 deletions(-)

diff --git a/Makefile/Makefile Shell.sublime-syntax b/Makefile/Makefile Shell.sublime-syntax
index 53319c1d7f..7a2c58f905 100644
--- a/Makefile/Makefile Shell.sublime-syntax	
+++ b/Makefile/Makefile Shell.sublime-syntax	
@@ -8,8 +8,7 @@ extends: Packages/ShellScript/Shell-Unix-Generic.sublime-syntax
 
 contexts:
 
-  expansions-parameter:
-    - meta_prepend: true
+  parameter-expansions:
     - include: Packages/Makefile/Makefile.sublime-syntax#variable-substitutions
 
   string-prototype:
diff --git a/Makefile/Makefile.sublime-syntax b/Makefile/Makefile.sublime-syntax
index b110573e43..3235b06b23 100644
--- a/Makefile/Makefile.sublime-syntax
+++ b/Makefile/Makefile.sublime-syntax
@@ -660,13 +660,13 @@ contexts:
     - match: \$(?=\$[{\w])
       scope: constant.character.escape.makefile
       push:
-        - include: scope:source.shell.bash#expansions-parameter
+        - include: scope:source.shell.bash#parameter-expansions
         - match: ''
           pop: 1
     - match: \$(?=\$\()
       scope: constant.character.escape.makefile
       push:
-        - include: scope:source.shell.embedded.makefile#expansions-command
+        - include: scope:source.shell.embedded.makefile#command-expansions
         - match: ''
           pop: 1
     - match: (\$)[[:alpha:]]
diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax
index a9bf205088..5b5660973b 100644
--- a/ShellScript/Bash.sublime-syntax
+++ b/ShellScript/Bash.sublime-syntax
@@ -1927,7 +1927,7 @@ contexts:
     - meta_scope: meta.number.integer.decimal.shell
     - match: '{{dec_digit}}+'
       scope: constant.numeric.value.shell
-    - include: expansions-variables
+    - include: variable-expansions
     - include: immediately-pop
 
   hex-number-body:
@@ -1935,7 +1935,7 @@ contexts:
     - meta_scope: meta.number.integer.hexadecimal.shell
     - match: '{{hex_digit}}+'
       scope: constant.numeric.value.shell
-    - include: expansions-variables
+    - include: variable-expansions
     - include: immediately-pop
 
   oct-number-body:
@@ -1943,7 +1943,7 @@ contexts:
     - meta_scope: meta.number.integer.octal.shell
     - match: '{{oct_digit}}+'
       scope: constant.numeric.value.shell
-    - include: expansions-variables
+    - include: variable-expansions
     - include: immediately-pop
 
   other-number-body:
@@ -1951,7 +1951,7 @@ contexts:
     - meta_scope: meta.number.integer.other.shell
     - match: '[[:alnum:]@_]+'
       scope: constant.numeric.value.shell
-    - include: expansions-variables
+    - include: variable-expansions
     - include: immediately-pop
 
   literal-unquoted-content:
@@ -2064,7 +2064,7 @@ contexts:
   string-interpolation-body:
     - clear_scopes: 1
     - meta_include_prototype: false
-    - include: expansions-variables
+    - include: variable-expansions
     - include: immediately-pop
 
   # for use by inheriting syntaxes to easily inject string interpolation
@@ -2139,7 +2139,7 @@ contexts:
     - include: any-escapes
     - include: brace-interpolations
     - include: string-interpolations
-    - include: expansions-job
+    - include: job-expansions
     - include: pattern-groups
     - include: pattern-charsets
     - include: pattern-common
@@ -2203,7 +2203,7 @@ contexts:
     - include: any-escapes
     - include: brace-interpolations
     - include: string-interpolations
-    - include: expansions-job
+    - include: job-expansions
     - include: pattern-groups
     - include: pattern-charsets
     - include: pattern-common
@@ -2308,7 +2308,7 @@ contexts:
         2: punctuation.separator.sequence.regexp.shell
         3: constant.character.escape.regexp.shell
     - include: any-escapes
-    - include: expansions-variables
+    - include: variable-expansions
     - include: eol-pop
 
   pattern-charset-collate-body:
@@ -2320,7 +2320,7 @@ contexts:
         2: punctuation.definition.set.end.regexp.shell
       pop: 1
     - include: any-escapes
-    - include: expansions-variables
+    - include: variable-expansions
     - include: eol-pop
 
   pattern-charset-equivalence-body:
@@ -2332,7 +2332,7 @@ contexts:
         2: punctuation.definition.set.end.regexp.shell
       pop: 1
     - include: any-escapes
-    - include: expansions-variables
+    - include: variable-expansions
     - include: eol-pop
 
   pattern-charset-posix-body:
@@ -2345,7 +2345,7 @@ contexts:
         3: punctuation.definition.set.end.regexp.shell
       pop: 1
     - include: any-escapes
-    - include: expansions-variables
+    - include: variable-expansions
     - include: eol-pop
 
   pattern-groups:
@@ -2531,14 +2531,14 @@ contexts:
 
 ###[ EXPANSIONS ]##############################################################
 
-  expansions-variables:
-    - include: expansions-arithmetic
-    - include: expansions-command
-    - include: expansions-parameter
+  variable-expansions:
+    - include: arithmetic-expansions
+    - include: command-expansions
+    - include: parameter-expansions
 
 ###[ ARITHMETIC EXPANSIONS ]###################################################
 
-  expansions-arithmetic:
+  arithmetic-expansions:
     - match: (?=\$\(\()
       branch_point: arithmetic-expansion
       branch:
@@ -2599,7 +2599,7 @@ contexts:
     - include: brace-interpolation-sequence-content
 
   brace-interpolation-sequence-content:
-    - include: expansions-variables
+    - include: variable-expansions
     - match: ([-+]?)(\d+)
       scope: meta.number.integer.decimal.shell
       captures:
@@ -2664,7 +2664,7 @@ contexts:
 
 ###[ COMMAND EXPANSIONS ]######################################################
 
-  expansions-command:
+  command-expansions:
     - match: (\$)(\()
       captures:
         1: punctuation.definition.variable.shell
@@ -2698,7 +2698,7 @@ contexts:
 
 ###[ JOB EXPANSIONS ]##########################################################
 
-  expansions-job:
+  job-expansions:
     # There are a number of ways to refer to a job in the shell.
     # The symbols ‘%%’ and ‘%+’ refer to the shell’s notion of the current job,
     # which is the last job stopped while it was in the foreground or started in
@@ -2727,16 +2727,16 @@ contexts:
 
 ###[ PARAMETER EXPANSIONS ]####################################################
 
-  expansions-parameter:
+  parameter-expansions:
     - match: (\$)(\{)
       captures:
         1: punctuation.definition.variable.shell
         2: punctuation.section.interpolation.begin.shell
       push:
-        - expansion-parameter-meta
-        - expansion-parameter-modifier
-        - expansion-parameter-name
-        - expansion-parameter-operator
+        - parameter-expansion-meta
+        - parameter-expansion-modifier
+        - parameter-expansion-name
+        - parameter-expansion-operator
     # https://www.gnu.org/software/bash/manual/bash.html#Positional-Parameters
     - match: (\$)\d
       scope: meta.interpolation.parameter.shell variable.language.positional.shell
@@ -2757,12 +2757,12 @@ contexts:
       captures:
         1: punctuation.definition.variable.shell
 
-  expansion-parameter-meta:
+  parameter-expansion-meta:
     - meta_include_prototype: false
     - meta_scope: meta.interpolation.parameter.shell
     - include: immediately-pop
 
-  expansion-parameter-operator:
+  parameter-expansion-operator:
     # Both ! and # are operators and special parameters at the same time.
     # First char is operator only if not followed by } or operator
     # Note: Matches may be wrong if line continuation follows, but it seems
@@ -2780,7 +2780,7 @@ contexts:
     - include: line-continuations
     - include: immediately-pop
 
-  expansion-parameter-name:
+  parameter-expansion-name:
     - meta_include_prototype: false
     - match: \d+
       scope: variable.language.positional.shell
@@ -2792,9 +2792,9 @@ contexts:
       scope: variable.language.special.shell
       pop: 1
     - match: ''
-      set: expansion-parameter-name-chars
+      set: parameter-expansion-name-chars
 
-  expansion-parameter-name-chars:
+  parameter-expansion-name-chars:
     - meta_content_scope: variable.other.readwrite.shell
     # note: no quoted name parts allowed within parameter expansions
     - match: '[@*](?!\w)'
@@ -2802,7 +2802,7 @@ contexts:
       pop: 1
     - include: variable-name-chars
 
-  expansion-parameter-modifier:
+  parameter-expansion-modifier:
     # ${parameter@operator}
     - match: (?:(@)({{parameter_switch}}))?(})
       captures:
@@ -2814,17 +2814,17 @@ contexts:
     - match: :?[-+=?]
       scope: keyword.operator.assignment.shell
       set:
-        - expansion-parameter-pattern
+        - parameter-expansion-pattern
         - maybe-tilde-interpolation
     # ${parameter:offset:length}
     - match: ':'
       scope: keyword.operator.substring.begin.shell
-      set: expansion-parameter-substr-start
+      set: parameter-expansion-substr-start
     # ${parameter/pattern/word}
     - match: /[/#%]?
       scope: keyword.operator.substitution.shell
       set:
-        - expansion-parameter-substitution-pattern
+        - parameter-expansion-substitution-pattern
         - maybe-tilde-interpolation
     # ${parameter#pattern}
     # ${parameter##pattern}
@@ -2837,120 +2837,120 @@ contexts:
     - match: (?:##?|%%?|\^\^?|,,?)
       scope: keyword.operator.expansion.shell
       set:
-        - expansion-parameter-pattern
+        - parameter-expansion-pattern
         - maybe-tilde-interpolation
     - include: variable-subscriptions
 
-  expansion-parameter-substr-start:
+  parameter-expansion-substr-start:
     - meta_content_scope: meta.arithmetic.shell
     - match: ':'
       scope: keyword.operator.substring.end.shell
-      set: expansion-parameter-expression
-    - include: expansion-parameter-expression
+      set: parameter-expansion-expression
+    - include: parameter-expansion-expression
 
-  expansion-parameter-expression:
+  parameter-expansion-expression:
     - meta_content_scope: meta.arithmetic.shell
-    - include: expansion-parameter-end
+    - include: parameter-expansion-end
     - include: expression-content
 
-  expansion-parameter-substitution-pattern:
+  parameter-expansion-substitution-pattern:
     # [3.5.8.1] Pattern Matching in parameter expansions' substitutions
     - meta_include_prototype: false
     - meta_content_scope: meta.string.regexp.shell string.unquoted.shell
     - match: /
       scope: keyword.operator.substitution.shell
-      set: expansion-parameter-string
-    - include: expansion-parameter-pattern
+      set: parameter-expansion-string
+    - include: parameter-expansion-pattern
 
-  expansion-parameter-pattern:
+  parameter-expansion-pattern:
     # [3.5.8.1] Pattern Matching in parameter expansions
     - meta_include_prototype: false
     - meta_content_scope: meta.string.regexp.shell string.unquoted.shell
-    - include: expansion-parameter-end
+    - include: parameter-expansion-end
     - include: string-unquoted-content
-    - include: expansion-parameter-pattern-charsets
-    - include: expansion-parameter-pattern-groups
+    - include: parameter-expansion-pattern-charsets
+    - include: parameter-expansion-pattern-groups
     - include: pattern-common
 
-  expansion-parameter-pattern-charsets:
+  parameter-expansion-pattern-charsets:
     - match: (?=\[)
-      branch_point: expansion-parameter-pattern-charset
+      branch_point: parameter-expansion-pattern-charset
       branch:
-        - expansion-parameter-pattern-charset
+        - parameter-expansion-pattern-charset
         - pattern-charset-fallback
 
-  expansion-parameter-pattern-charset:
+  parameter-expansion-pattern-charset:
     - match: (\[)([!^]?)
       captures:
         1: punctuation.definition.set.begin.regexp.shell
         2: keyword.operator.logical.regexp.shell
       set:
-        - expansion-parameter-pattern-charset-body
+        - parameter-expansion-pattern-charset-body
         - pattern-charset-begin
 
-  expansion-parameter-pattern-charset-body:
+  parameter-expansion-pattern-charset-body:
     - meta_scope: meta.set.regexp.shell
     - match: $|(?=\}) # bailout at end parameter
-      fail: expansion-parameter-pattern-charset
+      fail: parameter-expansion-pattern-charset
     - include: pattern-charset-end
     - include: pattern-charset-content
 
-  expansion-parameter-pattern-groups:
+  parameter-expansion-pattern-groups:
     - match: '[?*+@!]?(?=\()'
       scope: keyword.operator.quantifier.regexp.shell
-      push: expansion-parameter-pattern-group
+      push: parameter-expansion-pattern-group
 
-  expansion-parameter-pattern-group:
+  parameter-expansion-pattern-group:
     - meta_include_prototype: false
     - match: \(
       scope: punctuation.section.group.begin.regexp.shell
-      set: expansion-parameter-pattern-group-body
+      set: parameter-expansion-pattern-group-body
 
-  expansion-parameter-pattern-group-body:
+  parameter-expansion-pattern-group-body:
     - clear_scopes: 1  # clear `string.unquoted`
     - meta_include_prototype: false
     - meta_scope: meta.group.regexp.shell string.unquoted.shell
     - include: pattern-group-end
-    - include: expansion-parameter-pattern-group-content
+    - include: parameter-expansion-pattern-group-content
     - include: brace-pop
 
-  expansion-parameter-pattern-group-content:
+  parameter-expansion-pattern-group-content:
     - include: string-unquoted-content
-    - include: expansion-parameter-pattern-groups
-    - include: expansion-parameter-pattern-group-charsets
+    - include: parameter-expansion-pattern-groups
+    - include: parameter-expansion-pattern-group-charsets
     - include: pattern-group-operators
     - include: pattern-common
 
-  expansion-parameter-pattern-group-charsets:
+  parameter-expansion-pattern-group-charsets:
     - match: (?=\[)
-      branch_point: expansion-parameter-pattern-group-charset
+      branch_point: parameter-expansion-pattern-group-charset
       branch:
-        - expansion-parameter-pattern-group-charset
+        - parameter-expansion-pattern-group-charset
         - pattern-charset-fallback
 
-  expansion-parameter-pattern-group-charset:
+  parameter-expansion-pattern-group-charset:
     - match: (\[)([!^]?)
       captures:
         1: punctuation.definition.set.begin.regexp.shell
         2: keyword.operator.logical.regexp.shell
       set:
-        - expansion-parameter-pattern-group-charset-body
+        - parameter-expansion-pattern-group-charset-body
         - pattern-charset-begin
 
-  expansion-parameter-pattern-group-charset-body:
+  parameter-expansion-pattern-group-charset-body:
     - meta_scope: meta.set.regexp.shell
     - match: $|(?=[)}]) # bailout at end of group or parameter
-      fail: expansion-parameter-pattern-group-charset
+      fail: parameter-expansion-pattern-group-charset
     - include: pattern-charset-end
     - include: pattern-charset-content
 
-  expansion-parameter-string:
+  parameter-expansion-string:
     - meta_include_prototype: false
     - meta_content_scope: meta.string.shell string.unquoted.shell
-    - include: expansion-parameter-end
+    - include: parameter-expansion-end
     - include: string-unquoted-content
 
-  expansion-parameter-end:
+  parameter-expansion-end:
     - match: \}
       scope: punctuation.section.interpolation.end.shell
       pop: 1
diff --git a/ShellScript/Zsh.sublime-syntax b/ShellScript/Zsh.sublime-syntax
index 10306ddb5f..2544206b40 100644
--- a/ShellScript/Zsh.sublime-syntax
+++ b/ShellScript/Zsh.sublime-syntax
@@ -393,7 +393,7 @@ contexts:
 
 ###[ ARITHMETIC EXPANSIONS ]###################################################
 
-  expansions-arithmetic:
+  arithmetic-expansions:
     - meta_prepend: true
     - match: (\$)(\[)
       captures:
@@ -410,16 +410,16 @@ contexts:
 
 ###[ PARAMETER EXPANSIONS ]####################################################
 
-  expansions-parameter:
+  parameter-expansions:
     - match: (\$)(\{)
       captures:
         1: punctuation.definition.variable.shell
         2: punctuation.section.interpolation.begin.shell
       push:
-        - expansion-parameter-meta
-        - expansion-parameter-modifier
-        - expansion-parameter-name
-        - expansion-parameter-operator
+        - parameter-expansion-meta
+        - parameter-expansion-modifier
+        - parameter-expansion-name
+        - parameter-expansion-operator
         - zsh-parameter-flags
     # https://www.gnu.org/software/bash/manual/bash.html#Positional-Parameters
     - match: (\$)\d
@@ -445,7 +445,7 @@ contexts:
         1: punctuation.definition.variable.shell
       push: zsh-parameter-subscription
 
-  expansion-parameter-operator:
+  parameter-expansion-operator:
     # 14.3 Parameter Expansion
     # https://zsh.sourceforge.io/Doc/Release/Expansion.html#Parameter-Expansion
     - meta_prepend: true
@@ -466,28 +466,28 @@ contexts:
       scope: keyword.operator.expansion.valid.shell.zsh
       pop: 1
 
-  expansion-parameter-modifier:
+  parameter-expansion-modifier:
     # 14.3 Parameter Expansion
     - meta_prepend: true
     # $var if non-null, else str and set var to it
     - match: ::=
       scope: keyword.operator.assignment.shell.zsh
       set:
-        - expansion-parameter-pattern
+        - parameter-expansion-pattern
         - maybe-tilde-interpolation
     - match: :#
       scope: keyword.operator.assignment.shell.zsh
       set:
-        - expansion-parameter-pattern
+        - parameter-expansion-pattern
         - maybe-tilde-interpolation
 
-  expansion-parameter-pattern-groups:
+  parameter-expansion-pattern-groups:
     - include: zsh-glob-flags
     - include: zsh-parameter-glob-ranges
     # prefer EXTENDED_GLOB over optional KSH_GLOB
     - match: \(
       scope: punctuation.section.group.begin.regexp.shell
-      push: expansion-parameter-pattern-group-body
+      push: parameter-expansion-pattern-group-body
 
   zsh-parameter-flags:
     # 14.3.1 Parameter Expansion Flags
@@ -763,7 +763,7 @@ contexts:
 
   zsh-glob-qualifier-content:
     - include: comma-separators
-    - include: expansions-variables
+    - include: variable-expansions
     - include: zsh-glob-numbers
     # begin of history expansion modifiers
     - match: ':'

From b29ad25179a50e639cbfabc39e7917b06077d798 Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Mon, 9 Sep 2024 20:47:24 +0200
Subject: [PATCH 106/113] [ShellScript] Fix ZSH glob range meta scope extends

---
 ShellScript/Zsh.sublime-syntax              |  7 ++--
 ShellScript/Zsh/tests/syntax_test_scope.zsh | 39 +++++++++++----------
 2 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/ShellScript/Zsh.sublime-syntax b/ShellScript/Zsh.sublime-syntax
index 2544206b40..4307f4a9b7 100644
--- a/ShellScript/Zsh.sublime-syntax
+++ b/ShellScript/Zsh.sublime-syntax
@@ -280,21 +280,20 @@ contexts:
     - match: (\d*)(<)
       captures:
         1: string.unquoted.shell
-        2: punctuation.definition.range.begin.shell.zsh
+        2: meta.range.shell.zsh punctuation.definition.range.begin.shell.zsh
       set:
         - string-path-pattern-body
         - zsh-redirection-glob-range-end
         - zsh-glob-range-number
         - zsh-redirection-glob-range-operator
         - zsh-glob-range-number
-    - include: zsh-redirection-glob-range-fail
 
   zsh-redirection-glob-range-end:
     - clear_scopes: 1  # clear `string.unquoted`
-    - meta_scope: meta.range.shell.zsh
     - meta_include_prototype: false
+    - meta_content_scope: meta.range.shell.zsh
     - match: \>
-      scope: punctuation.definition.range.end.shell.zsh
+      scope: meta.range.shell.zsh punctuation.definition.range.end.shell.zsh
       pop: 1
     - include: zsh-redirection-glob-range-fail
 
diff --git a/ShellScript/Zsh/tests/syntax_test_scope.zsh b/ShellScript/Zsh/tests/syntax_test_scope.zsh
index 62606ac488..df24bd0e26 100644
--- a/ShellScript/Zsh/tests/syntax_test_scope.zsh
+++ b/ShellScript/Zsh/tests/syntax_test_scope.zsh
@@ -4162,35 +4162,35 @@ dyn_dir_name() {
 #                                  ^ punctuation.definition.range.end.shell.zsh
 
 : foo<5-21> foo<5-21>bar <5-21>bar  1<1-5>0 <1-5>0 <0  # not numbers, but a patterns
-# ^ meta.string.shell string.unquoted.shell
+# ^ meta.string.shell string.unquoted.shell - meta.range
 #  ^^^^^ meta.string.shell meta.range.shell.zsh - string
 #       ^ - meta.range meta.string - string
-#        ^ meta.string.shell string.unquoted.shell
+#        ^ meta.string.shell string.unquoted.shell - meta.range
 #         ^^^^^ meta.string.shell meta.range.shell.zsh - string
-#              ^ meta.string.shell string.unquoted.shell
+#              ^ meta.string.shell string.unquoted.shell - meta.range
 #               ^ - meta.range meta.string - string
 #                ^^^^^ meta.string.shell meta.range.shell.zsh - string
-#                     ^ meta.string.shell string.unquoted.shell
+#                     ^ meta.string.shell string.unquoted.shell - meta.range
 #                       ^ meta.redirection.shell keyword.operator.assignment.redirection.shell
 #                        ^ meta.redirection.shell meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell
 
 : (<1-5>foo|bar<1-)<1-5>  # glob ranges in pattern groups
 # ^ meta.string.shell meta.group.regexp.shell string.unquoted.shell punctuation.section.group.begin.regexp.shell
 #  ^^^^^ meta.string.shell meta.group.regexp.shell meta.range.shell.zsh - string
-#       ^^^^^^^ meta.string.shell meta.group.regexp.shell string.unquoted.shell
+#       ^^^^^^^ meta.string.shell meta.group.regexp.shell string.unquoted.shell - meta.range
 #              ^^^ meta.redirection.shell
 #                 ^ invalid.illegal.stray.shell
 #                  ^^^^^ meta.string.shell meta.range.shell.zsh - string
@@ -4200,22 +4200,22 @@ dyn_dir_name() {
 a=<1-4>foo  # glob range beginning assignment value
 # <- meta.assignment.l-value.shell variable.other.readwrite.shell
 #^ meta.assignment.shell keyword.operator.assignment.shell
-# ^^^^^ meta.assignment.r-value.shell meta.string.shell meta.range.shell.zsh
-#      ^^^ meta.assignment.r-value.shell meta.string.shell string.unquoted.shell
+# ^^^^^ meta.assignment.r-value.shell meta.string.shell meta.range.shell.zsh - string
+#      ^^^ meta.assignment.r-value.shell meta.string.shell string.unquoted.shell - meta.range
 
 a=foo<1-4>bar  # glob range within assignment value
 # <- meta.assignment.l-value.shell variable.other.readwrite.shell
 #^ meta.assignment.shell keyword.operator.assignment.shell
-# ^^^ meta.assignment.r-value.shell meta.string.shell string.unquoted.shell
-#    ^^^^^ meta.assignment.r-value.shell meta.string.shell meta.range.shell.zsh
-#         ^^^ meta.assignment.r-value.shell meta.string.shell string.unquoted.shell
+# ^^^ meta.assignment.r-value.shell meta.string.shell string.unquoted.shell - meta.range
+#    ^^^^^ meta.assignment.r-value.shell meta.string.shell meta.range.shell.zsh - string
+#         ^^^ meta.assignment.r-value.shell meta.string.shell string.unquoted.shell - meta.range
 
 a=foo<1-4>foopat | pat<1-2> | <-a>ny ) ;;
 # ^^^^^^^^^^^^^^^^^^^^ meta.clause.patterns.shell
 # ^^^^^ meta.string.shell meta.range.shell.zsh - string
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.shell string.unquoted.shell - meta.range
 #          ^ keyword.operator.logical.shell
-#            ^^^ meta.string.shell string.unquoted.shell
+#            ^^^ meta.string.shell string.unquoted.shell - meta.range
 #               ^^^^^ meta.string.shell meta.range.shell.zsh - string
 #                     ^ keyword.operator.logical.shell
+#                       ^^^^^^^^ - meta.range
 #                       ^ invalid.illegal.unexpected-token.shell
 #                        ^^ meta.string.shell string.unquoted.shell
 #                          ^ invalid.illegal.unexpected-token.shell

From d243ff2c90e99fe2ce744c49048ebb027df22b66 Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Sun, 22 Sep 2024 10:04:37 +0200
Subject: [PATCH 107/113] [ShellScript] Scope glob strings `meta.string.glob`

This commit assigns `meta.string.glob` scope to strings,
which support filename expansions.
---
 Makefile/syntax_test_makefile.mak             |    6 +-
 ShellScript/Bash.sublime-syntax               |    4 +-
 ShellScript/Bash/tests/syntax_test_scope.bash | 1292 ++++++++---------
 ShellScript/Zsh/tests/syntax_test_scope.zsh   | 1074 +++++++-------
 4 files changed, 1188 insertions(+), 1188 deletions(-)

diff --git a/Makefile/syntax_test_makefile.mak b/Makefile/syntax_test_makefile.mak
index 92b47b8037..89843f1b53 100644
--- a/Makefile/syntax_test_makefile.mak
+++ b/Makefile/syntax_test_makefile.mak
@@ -1021,7 +1021,7 @@ html:
 shell_string_interpolation:
     var1="double nquoted $(string) value"
     #    ^^^^^^^^^^^^^^^^ string.quoted.double.shell
-    #    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.body.makefile source.shell.embedded.makefile meta.string.shell
+    #    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.body.makefile source.shell.embedded.makefile meta.string.glob.shell
     #                    ^^^^^^^^^ meta.interpolation
     #                    ^^ keyword.other.block.begin.makefile
     #                      ^^^^^^ variable.parameter.makefile
@@ -1029,7 +1029,7 @@ shell_string_interpolation:
     #                             ^^^^^^^ string.quoted.double.shell
     var1='single nquoted $(string) value'
     #    ^^^^^^^^^^^^^^^^ string.quoted.single.shell
-    #    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.body.makefile source.shell.embedded.makefile meta.string.shell
+    #    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.body.makefile source.shell.embedded.makefile meta.string.glob.shell
     #                    ^^^^^^^^^ meta.interpolation
     #                    ^^ keyword.other.block.begin.makefile
     #                      ^^^^^^ variable.parameter.makefile
@@ -1037,7 +1037,7 @@ shell_string_interpolation:
     #                             ^^^^^^^ string.quoted.single.shell
     var1=unquoted\ $(string)\ value
     #    ^^^^^^^^^^ string.unquoted.shell
-    #    ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.body.makefile source.shell.embedded.makefile meta.string.shell
+    #    ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.body.makefile source.shell.embedded.makefile meta.string.glob.shell
     #              ^^^^^^^^^ meta.interpolation
     #              ^^ keyword.other.block.begin.makefile
     #                ^^^^^^ variable.parameter.makefile
diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax
index 5b5660973b..bb55cacf1a 100644
--- a/ShellScript/Bash.sublime-syntax
+++ b/ShellScript/Bash.sublime-syntax
@@ -2097,7 +2097,7 @@ contexts:
 
   group-path-pattern-body:
     - meta_include_prototype: false
-    - meta_scope: meta.string.shell string.unquoted.shell
+    - meta_scope: meta.string.glob.shell string.unquoted.shell
     - include: string-path-pattern-content
     - include: word-end
 
@@ -2121,7 +2121,7 @@ contexts:
 
   string-path-pattern-body:
     - meta_include_prototype: false
-    - meta_scope: meta.string.shell string.unquoted.shell
+    - meta_scope: meta.string.glob.shell string.unquoted.shell
     - include: string-path-pattern-content
     - include: word-end
 
diff --git a/ShellScript/Bash/tests/syntax_test_scope.bash b/ShellScript/Bash/tests/syntax_test_scope.bash
index e2ee269de6..c409b18b04 100644
--- a/ShellScript/Bash/tests/syntax_test_scope.bash
+++ b/ShellScript/Bash/tests/syntax_test_scope.bash
@@ -64,9 +64,9 @@ bar   ` # important; this and that ` "${USELESS_TEXT}" | ` # match text` \
 #                                                                      ^^^ - comment
 #     ^ punctuation.section.interpolation.begin.shell
 #                                  ^ punctuation.section.interpolation.end.shell
-#                                    ^ meta.string.shell string.quoted.double.shell punctuation.definition.string.begin.shell
-#                                     ^^^^^^^^^^^^^^^ meta.string.shell meta.interpolation.parameter.shell - string
-#                                                    ^ meta.string.shell string.quoted.double.shell punctuation.definition.string.end.shell
+#                                    ^ meta.string.glob.shell string.quoted.double.shell punctuation.definition.string.begin.shell
+#                                     ^^^^^^^^^^^^^^^ meta.string.glob.shell meta.interpolation.parameter.shell - string
+#                                                    ^ meta.string.glob.shell string.quoted.double.shell punctuation.definition.string.end.shell
 #                                                      ^ keyword.operator.assignment.pipe.shell
 #                                                        ^ punctuation.section.interpolation.begin.shell
 #                                                                        ^ punctuation.separator.continuation.line.shell
@@ -146,46 +146,46 @@ echo the q"uick" f"ox" ju"mp"ed o"ve"r t'he' 'la'zy 'dog'
 #   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
 #                                                        ^ - meta.function-call
 #         ^ punctuation.definition.string.begin.shell
-#         ^^^^^^ meta.string.shell string.quoted.double.shell
+#         ^^^^^^ meta.string.glob.shell string.quoted.double.shell
 #              ^ punctuation.definition.string.end.shell
 #                 ^ punctuation.definition.string.begin.shell
-#                 ^^^^ meta.string.shell string.quoted.double.shell
+#                 ^^^^ meta.string.glob.shell string.quoted.double.shell
 #                    ^ punctuation.definition.string.end.shell
 #                        ^ punctuation.definition.string.begin.shell
-#                        ^^^^ meta.string.shell string.quoted.double.shell
+#                        ^^^^ meta.string.glob.shell string.quoted.double.shell
 #                           ^ punctuation.definition.string.end.shell
 #                                ^ punctuation.definition.string.begin.shell
-#                                ^^^^ meta.string.shell string.quoted.double.shell
+#                                ^^^^ meta.string.glob.shell string.quoted.double.shell
 #                                   ^ punctuation.definition.string.end.shell
 #                                       ^ punctuation.definition.string.begin.shell
-#                                       ^^^^ meta.string.shell string.quoted.single.shell
+#                                       ^^^^ meta.string.glob.shell string.quoted.single.shell
 #                                          ^ punctuation.definition.string.end.shell
 #                                            ^ punctuation.definition.string.begin.shell
-#                                            ^^^^ meta.string.shell string.quoted.single.shell
+#                                            ^^^^ meta.string.glob.shell string.quoted.single.shell
 #                                               ^ punctuation.definition.string.end.shell
 #                                                   ^ punctuation.definition.string.begin.shell
-#                                                   ^^^^^ meta.string.shell string.quoted.single.shell
+#                                                   ^^^^^ meta.string.glob.shell string.quoted.single.shell
 #                                                       ^ punctuation.definition.string.end.shell
 
 echo 'no\e$capes\in\$ingle\quotes'
 #^^^ meta.function-call.identifier.shell support.function.shell
 #   ^ meta.function-call.arguments.shell - keyword - string
-#    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell string.quoted.single.shell - constant - keyword - variable
+#    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.glob.shell string.quoted.single.shell - constant - keyword - variable
 #    ^ punctuation.definition.string.begin.shell
 #                                ^ punctuation.definition.string.end.shell
 
 echo 'singe\' \\''
 #    ^^^^^^^^^^^^^ meta.function-call.arguments.shell
-#    ^^^^^^^^ meta.string.shell string.quoted.single.shell - string.unquoted
+#    ^^^^^^^^ meta.string.glob.shell string.quoted.single.shell - string.unquoted
 #    ^ punctuation.definition.string.begin.shell
 #          ^^ - constant
-#             ^^ meta.string.shell string.unquoted.shell - string.quoted
+#             ^^ meta.string.glob.shell string.unquoted.shell - string.quoted
 #             ^^ constant.character.escape.shell
-#               ^^ meta.string.shell string.quoted.single.shell - string.unquoted
+#               ^^ meta.string.glob.shell string.quoted.single.shell - string.unquoted
 #                 ^ - meta.string - string
 
 echo $'\a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z\''
-#    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell string.quoted.single.shell
+#    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.glob.shell string.quoted.single.shell
 #    ^^ punctuation.definition.string.begin.shell
 #      ^^^^ constant.character.escape.shell
 #          ^^^^^^ - constant.character.escape
@@ -210,17 +210,17 @@ echo -e -a -n <1 ! # unknown options start printed text
 #^^^ meta.function-call.identifier.shell support.function.shell
 #   ^^^^^^^^^ meta.function-call.arguments.shell
 #    ^^ variable.parameter.option.shell
-#       ^^ meta.string.shell string.unquoted.shell
-#          ^^ meta.string.shell string.unquoted.shell
+#       ^^ meta.string.glob.shell string.unquoted.shell
+#          ^^ meta.string.glob.shell string.unquoted.shell
 #             ^^ meta.redirection.shell
 #             ^ keyword.operator.assignment.redirection.shell
 #              ^ meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell
-#                ^ meta.string.shell string.unquoted.shell
+#                ^ meta.string.glob.shell string.unquoted.shell
 #                 ^ - meta.function-call - comment
 #                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
 
 echo $'Hello\' World\\'
-#    ^^^^^^^^^^^^^^^^^^ meta.string.shell string.quoted.single.shell
+#    ^^^^^^^^^^^^^^^^^^ meta.string.glob.shell string.quoted.single.shell
 #    ^^ punctuation.definition.string.begin.shell
 #           ^^ constant.character.escape.shell
 #                   ^^ constant.character.escape.shell
@@ -228,7 +228,7 @@ echo $'Hello\' World\\'
 #                      ^ - meta.string - string
 
 echo $"Hello\" World\\"
-#    ^^^^^^^^^^^^^^^^^^ meta.string.shell string.quoted.double.shell
+#    ^^^^^^^^^^^^^^^^^^ meta.string.glob.shell string.quoted.double.shell
 #    ^^ punctuation.definition.string.begin.shell
 #           ^^ constant.character.escape.shell
 #                   ^^ constant.character.escape.shell
@@ -236,30 +236,30 @@ echo $"Hello\" World\\"
 #                      ^ - meta.string - string
 
 echo $"Hello
-#    ^^^^^^^^ meta.string.shell string.quoted.double.shell
+#    ^^^^^^^^ meta.string.glob.shell string.quoted.double.shell
 #    ^^ punctuation.definition.string.begin.shell
   World\\"
-#^^^^^^^^^ meta.string.shell string.quoted.double.shell
+#^^^^^^^^^ meta.string.glob.shell string.quoted.double.shell
 #      ^^ constant.character.escape.shell
 #        ^ punctuation.definition.string.end.shell
 #         ^ - meta.string - string
 
 # Note: Line continuation causes the linefeed to be removed from the output string.
 echo $"Hello \
-#    ^^^^^^^^^^ meta.string.shell string.quoted.double.shell
+#    ^^^^^^^^^^ meta.string.glob.shell string.quoted.double.shell
 #    ^^ punctuation.definition.string.begin.shell
 #            ^ punctuation.separator.continuation.line.shell
 #             ^ - punctuation
   World\\"
-#^^^^^^^^^ meta.string.shell string.quoted.double.shell
+#^^^^^^^^^ meta.string.glob.shell string.quoted.double.shell
 #      ^^ constant.character.escape.shell
 #        ^ punctuation.definition.string.end.shell
 #         ^ - meta.string - string
 
 echo $"Hello \\\"$world\""
-#    ^^^^^^^^^^^^ meta.string.shell string.quoted.double.shell - meta.interpolation - variable
-#                ^^^^^^ meta.string.shell meta.interpolation.parameter.shell
-#                      ^^^ meta.string.shell string.quoted.double.shell - meta.interpolation - variable
+#    ^^^^^^^^^^^^ meta.string.glob.shell string.quoted.double.shell - meta.interpolation - variable
+#                ^^^^^^ meta.string.glob.shell meta.interpolation.parameter.shell
+#                      ^^^ meta.string.glob.shell string.quoted.double.shell - meta.interpolation - variable
 #    ^^ punctuation.definition.string.begin.shell
 #            ^^^^ constant.character.escape.shell
 #                ^ punctuation.definition.variable.shell
@@ -268,9 +268,9 @@ echo $"Hello \\\"$world\""
 #                        ^ punctuation.definition.string.end.shell
 
 echo $"Hello \\\"`echo World`\""
-#    ^^^^^^^^^^^^ meta.string.shell string.quoted.double.shell - meta.interpolation - variable
-#                ^^^^^^^^^^^^ meta.string.shell meta.interpolation.command.shell
-#                            ^^^ meta.string.shell string.quoted.double.shell - meta.interpolation - variable
+#    ^^^^^^^^^^^^ meta.string.glob.shell string.quoted.double.shell - meta.interpolation - variable
+#                ^^^^^^^^^^^^ meta.string.glob.shell meta.interpolation.command.shell
+#                            ^^^ meta.string.glob.shell string.quoted.double.shell - meta.interpolation - variable
 #    ^^ punctuation.definition.string.begin.shell
 #            ^^^^ constant.character.escape.shell
 #                ^ punctuation.section.interpolation.begin.shell
@@ -310,12 +310,12 @@ echo `echo \`echo hello\\\`, world\\\\\`!`
 #                                        ^ punctuation.section.interpolation.end.shell
 
 echo "`dirname -- foo/bar`"
-#    ^ meta.function-call.arguments.shell meta.string.shell - meta.interpolation
-#     ^ meta.function-call.arguments.shell meta.string.shell meta.interpolation.command.shell
-#      ^^^^^^^ meta.function-call.arguments.shell meta.string.shell meta.interpolation.command.shell meta.function-call.identifier.shell
-#             ^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell meta.interpolation.command.shell meta.function-call.arguments.shell
-#                        ^ meta.function-call.arguments.shell meta.string.shell meta.interpolation.command.shell
-#                         ^ meta.function-call.arguments.shell meta.string.shell - meta.interpolation
+#    ^ meta.function-call.arguments.shell meta.string.glob.shell - meta.interpolation
+#     ^ meta.function-call.arguments.shell meta.string.glob.shell meta.interpolation.command.shell
+#      ^^^^^^^ meta.function-call.arguments.shell meta.string.glob.shell meta.interpolation.command.shell meta.function-call.identifier.shell
+#             ^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.glob.shell meta.interpolation.command.shell meta.function-call.arguments.shell
+#                        ^ meta.function-call.arguments.shell meta.string.glob.shell meta.interpolation.command.shell
+#                         ^ meta.function-call.arguments.shell meta.string.glob.shell - meta.interpolation
 #    ^ string.quoted.double.shell punctuation.definition.string.begin.shell
 #     ^ punctuation.section.interpolation.begin.shell
 #      ^^^^^^^ variable.function.shell
@@ -324,9 +324,9 @@ echo "`dirname -- foo/bar`"
 #                         ^ string.quoted.double.shell punctuation.definition.string.end.shell
 
 echo git rev-list "$(echo --all)" | grep -P 'c354a80'
-#                 ^ meta.string.shell
-#                  ^^^^^^^^^^^^^ meta.string.shell meta.interpolation.command.shell - string.quoted.double
-#                               ^ meta.string.shell - meta.interpolation
+#                 ^ meta.string.glob.shell
+#                  ^^^^^^^^^^^^^ meta.string.glob.shell meta.interpolation.command.shell - string.quoted.double
+#                               ^ meta.string.glob.shell - meta.interpolation
 #                 ^ string.quoted.double.shell punctuation.definition.string.begin.shell
 #                  ^ punctuation.definition.variable.shell
 #                   ^ punctuation.section.interpolation.begin.shell
@@ -337,7 +337,7 @@ echo git rev-list "$(echo --all)" | grep -P 'c354a80'
 #                                 ^ keyword.operator.assignment.pipe.shell
 #                                   ^^^^ variable.function.shell
 #                                        ^^ variable.parameter.option.shell
-#                                           ^^^^^^^^^ meta.string.shell string.quoted.single.shell
+#                                           ^^^^^^^^^ meta.string.glob.shell string.quoted.single.shell
 
 ' echo '
 # <- meta.function-call.identifier.shell meta.command.shell
@@ -558,14 +558,14 @@ foo\
 -e Hello
 # <- - punctuation
 #^ - variable.parameter
-#  ^^^^^ meta.string.shell string.unquoted.shell
+#  ^^^^^ meta.string.glob.shell string.unquoted.shell
 
 foo -e =Hello
 #^^ meta.function-call.identifier.shell variable.function.shell
 #  ^^^^^^^^^^ meta.function-call.arguments.shell
 #   ^ punctuation.definition.parameter.shell
 #   ^^ meta.parameter.option.shell variable.parameter.option.shell
-#      ^^^^^^ meta.string.shell string.unquoted.shell
+#      ^^^^^^ meta.string.glob.shell string.unquoted.shell
 #      ^ - keyword.operator
 
 foo -e=Hello
@@ -575,7 +575,7 @@ foo -e=Hello
 #   ^ meta.parameter.option.shell variable.parameter.option.shell punctuation.definition.parameter.shell
 #    ^ meta.parameter.option.shell variable.parameter.option.shell - punctuation
 #     ^ keyword.operator.assignment.shell
-#      ^^^^^ meta.string.shell string.unquoted.shell
+#      ^^^^^ meta.string.glob.shell string.unquoted.shell
 
 foo -$e=Hello
 #^^ meta.function-call.identifier.shell variable.function.shell
@@ -583,7 +583,7 @@ foo -$e=Hello
 #   ^ meta.parameter.option.shell variable.parameter.option.shell punctuation.definition.parameter.shell
 #    ^^ meta.parameter.option.shell meta.interpolation.parameter.shell variable.other.readwrite.shell - variable variable
 #      ^ keyword.operator.assignment.shell
-#       ^^^^^ meta.string.shell string.unquoted.shell
+#       ^^^^^ meta.string.glob.shell string.unquoted.shell
 
 any --h\elp
 #   ^^^^^^^ meta.parameter.option.shell variable.parameter.option.shell
@@ -693,7 +693,7 @@ git log --format="%h git has this pattern, too"
 #       ^^ meta.parameter.option.shell variable.parameter.option.shell punctuation.definition.parameter.shell
 #         ^^^^^^ meta.parameter.option.shell variable.parameter.option.shell - punctuation
 #               ^ keyword.operator.assignment.shell
-#                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell string.quoted.double.shell
+#                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.glob.shell string.quoted.double.shell
 
 7za x -a -9r -= -] -!
 # <- meta.function-call.identifier.shell variable.function.shell
@@ -1059,8 +1059,8 @@ for in in in in
 #^^ keyword.control.loop.for.shell
 #   ^^ variable.other.readwrite.shell - keyword
 #      ^^ keyword.operator.iterator.in.shell
-#         ^^ meta.string.shell string.unquoted.shell
-#            ^^ meta.string.shell string.unquoted.shell
+#         ^^ meta.string.glob.shell string.unquoted.shell
+#            ^^ meta.string.glob.shell string.unquoted.shell
 
 for do do do do
 # <- meta.statement.loop.for.shell keyword.control.loop.for.shell
@@ -1097,15 +1097,15 @@ for i in for in do echo done; do echo $i; done;
 #^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.statement.loop.for.shell
 #     ^^ keyword.operator.iterator.in.shell
 #       ^ - meta.string
-#        ^^^ meta.string.shell string.unquoted.shell
+#        ^^^ meta.string.glob.shell string.unquoted.shell
 #           ^ - meta.string
-#            ^^ meta.string.shell string.unquoted.shell
+#            ^^ meta.string.glob.shell string.unquoted.shell
 #              ^ - meta.string
-#               ^^ meta.string.shell string.unquoted.shell
+#               ^^ meta.string.glob.shell string.unquoted.shell
 #                 ^ - meta.string
-#                  ^^^^ meta.string.shell string.unquoted.shell
+#                  ^^^^ meta.string.glob.shell string.unquoted.shell
 #                      ^ - meta.string
-#                       ^^^^ meta.string.shell string.unquoted.shell
+#                       ^^^^ meta.string.glob.shell string.unquoted.shell
 #                           ^ punctuation.terminator.statement.shell
 #                             ^^ keyword.control.loop.do.shell
 #                                ^^^^ support.function.shell
@@ -1120,11 +1120,11 @@ for i in { [ \( ; do echo $i; done;
 #   ^ variable.other.readwrite.shell
 #     ^^ keyword.operator.iterator.in.shell
 #       ^ - meta.string
-#        ^ meta.string.shell string.unquoted.shell
+#        ^ meta.string.glob.shell string.unquoted.shell
 #         ^ - meta.string
-#          ^ meta.string.shell string.unquoted.shell
+#          ^ meta.string.glob.shell string.unquoted.shell
 #           ^ - meta.string
-#            ^^ meta.string.shell string.unquoted.shell constant.character.escape.shell
+#            ^^ meta.string.glob.shell string.unquoted.shell constant.character.escape.shell
 #              ^ - meta.string
 #               ^ punctuation.terminator.statement.shell
 #                 ^^ keyword.control.loop.do.shell
@@ -1139,12 +1139,12 @@ for i in str1 $str2 "str3" 'str4' st$r5; do echo $i; done;
 #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.statement.loop.for.shell
 #   ^ variable.other.readwrite.shell
 #     ^^ keyword.operator.iterator.in.shell
-#        ^^^^ meta.string.shell string.unquoted.shell
+#        ^^^^ meta.string.glob.shell string.unquoted.shell
 #             ^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell
-#                   ^^^^^^ meta.string.shell string.quoted.double.shell
-#                          ^^^^^^ meta.string.shell string.quoted.single.shell
-#                                 ^^ meta.string.shell string.unquoted.shell
-#                                   ^^^ meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell
+#                   ^^^^^^ meta.string.glob.shell string.quoted.double.shell
+#                          ^^^^^^ meta.string.glob.shell string.quoted.single.shell
+#                                 ^^ meta.string.glob.shell string.unquoted.shell
+#                                   ^^^ meta.string.glob.shell meta.interpolation.parameter.shell variable.other.readwrite.shell
 #                                      ^ punctuation.terminator.statement.shell
 #                                        ^^ keyword.control.loop.do.shell
 #                                           ^^^^ meta.function-call.identifier.shell support.function.shell
@@ -1174,13 +1174,13 @@ for i in {foo,bar,baz}; do echo $i; done;
 #^^^^^^^^^^^^^^^^^^^^^ meta.statement.loop.for.shell
 #   ^ variable.other.readwrite.shell
 #     ^^ keyword.operator.iterator.in.shell
-#        ^ meta.string.shell meta.interpolation.brace.shell punctuation.section.interpolation.begin.shell - string
-#         ^^^ meta.string.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell
-#            ^ meta.string.shell meta.interpolation.brace.shell punctuation.separator.sequence.shell - string
-#             ^^^ meta.string.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell
-#                ^ meta.string.shell meta.interpolation.brace.shell punctuation.separator.sequence.shell - string
-#                 ^^^ meta.string.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell
-#                    ^ meta.string.shell meta.interpolation.brace.shell punctuation.section.interpolation.end.shell - string
+#        ^ meta.string.glob.shell meta.interpolation.brace.shell punctuation.section.interpolation.begin.shell - string
+#         ^^^ meta.string.glob.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell
+#            ^ meta.string.glob.shell meta.interpolation.brace.shell punctuation.separator.sequence.shell - string
+#             ^^^ meta.string.glob.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell
+#                ^ meta.string.glob.shell meta.interpolation.brace.shell punctuation.separator.sequence.shell - string
+#                 ^^^ meta.string.glob.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell
+#                    ^ meta.string.glob.shell meta.interpolation.brace.shell punctuation.section.interpolation.end.shell - string
 #                     ^ punctuation.terminator.statement.shell
 
 for i in for pre{foo,bar,baz}suf; do echo $i; done;
@@ -1188,17 +1188,17 @@ for i in for pre{foo,bar,baz}suf; do echo $i; done;
 #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.statement.loop.for.shell
 #   ^ variable.other.readwrite.shell
 #     ^^ keyword.operator.iterator.in.shell
-#        ^^^ meta.string.shell string.unquoted.shell
+#        ^^^ meta.string.glob.shell string.unquoted.shell
 #           ^ - meta.string
-#            ^^^ meta.string.shell string.unquoted.shell - meta.interpolation
-#               ^ meta.string.shell meta.interpolation.brace.shell punctuation.section.interpolation.begin.shell - string
-#                ^^^ meta.string.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell
-#                   ^ meta.string.shell meta.interpolation.brace.shell punctuation.separator.sequence.shell - string
-#                    ^^^ meta.string.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell
-#                       ^ meta.string.shell meta.interpolation.brace.shell punctuation.separator.sequence.shell - string
-#                        ^^^ meta.string.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell
-#                           ^ meta.string.shell meta.interpolation.brace.shell punctuation.section.interpolation.end.shell - string
-#                            ^^^ meta.string.shell string.unquoted.shell - meta.interpolation
+#            ^^^ meta.string.glob.shell string.unquoted.shell - meta.interpolation
+#               ^ meta.string.glob.shell meta.interpolation.brace.shell punctuation.section.interpolation.begin.shell - string
+#                ^^^ meta.string.glob.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell
+#                   ^ meta.string.glob.shell meta.interpolation.brace.shell punctuation.separator.sequence.shell - string
+#                    ^^^ meta.string.glob.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell
+#                       ^ meta.string.glob.shell meta.interpolation.brace.shell punctuation.separator.sequence.shell - string
+#                        ^^^ meta.string.glob.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell
+#                           ^ meta.string.glob.shell meta.interpolation.brace.shell punctuation.section.interpolation.end.shell - string
+#                            ^^^ meta.string.glob.shell string.unquoted.shell - meta.interpolation
 #                               ^ punctuation.terminator.statement.shell
 
 for i in {1..10}; do echo $i; done;
@@ -1274,11 +1274,11 @@ for i in (foo bar baz); do echo $i; done;
 #   ^ variable.other.readwrite.shell
 #     ^^ keyword.operator.iterator.in.shell
 #        ^ meta.statement.loop.for.shell invalid.illegal.unexpected-token.shell
-#         ^^^ meta.statement.loop.for.shell meta.string.shell string.unquoted.shell
+#         ^^^ meta.statement.loop.for.shell meta.string.glob.shell string.unquoted.shell
 #            ^ - meta.string
-#             ^^^ meta.statement.loop.for.shell meta.string.shell string.unquoted.shell
+#             ^^^ meta.statement.loop.for.shell meta.string.glob.shell string.unquoted.shell
 #                ^ - meta.string
-#                 ^^^ meta.statement.loop.for.shell meta.string.shell string.unquoted.shell
+#                 ^^^ meta.statement.loop.for.shell meta.string.glob.shell string.unquoted.shell
 #                    ^ invalid.illegal.stray.shell
 #                    ^ invalid.illegal.stray.shell
 #                     ^ punctuation.terminator.statement.shell
@@ -1330,9 +1330,9 @@ for \
 #^^^^^^^^^^^^^^^^^^^ meta.statement.loop.for.shell
 # ^^^ variable.other.readwrite.shell
 #     ^^ keyword.operator.iterator.in.shell
-#        ^^^ meta.string.shell string.unquoted.shell
-#            ^^^ meta.string.shell string.unquoted.shell
-#                ^^^ meta.string.shell string.unquoted.shell
+#        ^^^ meta.string.glob.shell string.unquoted.shell
+#            ^^^ meta.string.glob.shell string.unquoted.shell
+#                ^^^ meta.string.glob.shell string.unquoted.shell
 #                   ^ punctuation.terminator.statement.shell
 
 for \
@@ -1341,9 +1341,9 @@ in foo bar baz;
 #<- meta.statement.loop.for.shell keyword.operator.iterator.in.shell
 #^^^^^^^^^^^^^ meta.statement.loop.for.shell
 #^ meta.statement.loop.for.shell keyword.operator.iterator.in.shell
-#  ^^^ meta.string.shell string.unquoted.shell
-#      ^^^ meta.string.shell string.unquoted.shell
-#          ^^^ meta.string.shell string.unquoted.shell
+#  ^^^ meta.string.glob.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
+#          ^^^ meta.string.glob.shell string.unquoted.shell
 #             ^ punctuation.terminator.statement.shell
 
 `for i in $(seq 100); do echo $i; done`
@@ -1431,13 +1431,13 @@ select in in in select do done; do echo $in; done;
 #      ^^ variable.other.readwrite.shell
 #         ^^ keyword.operator.iterator.in.shell
 #           ^ - meta.string - string
-#            ^^ meta.string.shell string.unquoted.shell
+#            ^^ meta.string.glob.shell string.unquoted.shell
 #              ^ - meta.string - string
-#               ^^^^^^ meta.string.shell string.unquoted.shell
+#               ^^^^^^ meta.string.glob.shell string.unquoted.shell
 #                     ^ - meta.string - string
-#                      ^^ meta.string.shell string.unquoted.shell
+#                      ^^ meta.string.glob.shell string.unquoted.shell
 #                        ^ - meta.string - string
-#                         ^^^^ meta.string.shell string.unquoted.shell
+#                         ^^^^ meta.string.glob.shell string.unquoted.shell
 #                             ^ punctuation.terminator.statement.shell
 #                               ^^ keyword.control.loop.do.shell
 #                                  ^^^^ support.function.shell
@@ -1451,7 +1451,7 @@ select \
 # <- meta.statement.loop.select.shell
 #^^^^^^^^^ meta.statement.loop.select.shell - meta.sequence
 #         ^ meta.statement.loop.select.shell meta.sequence.list.shell - meta.string
-#          ^^^^^^^^^^^^^ meta.statement.loop.select.shell meta.sequence.list.shell meta.string.shell
+#          ^^^^^^^^^^^^^ meta.statement.loop.select.shell meta.sequence.list.shell meta.string.glob.shell
 #                       ^^ - meta.statement.loop - meta.sequence
 # ^^^^^ variable.other.readwrite.shell
 #       ^^ keyword.operator.iterator.in.shell
@@ -1467,7 +1467,7 @@ select \
 # <- meta.statement.loop.select.shell
 #^^^ meta.statement.loop.select.shell - meta.sequence
 #   ^ meta.statement.loop.select.shell meta.sequence.list.shell - meta.string
-#    ^^^^^^^^^^^^^ meta.statement.loop.select.shell meta.sequence.list.shell meta.string.shell
+#    ^^^^^^^^^^^^^ meta.statement.loop.select.shell meta.sequence.list.shell meta.string.glob.shell
 #                 ^^ - meta.statement.loop - meta.sequence
 # ^^ keyword.operator.iterator.in.shell
 #    ^ meta.interpolation.tilde.shell variable.language.tilde.shell - string
@@ -1482,7 +1482,7 @@ select \
   ~/**/*.~\$tmp; do rm -f $fname; done;
 # <- meta.statement.loop.select.shell
 #^ meta.statement.loop.select.shell meta.sequence.list.shell - meta.string
-# ^^^^^^^^^^^^^ meta.statement.loop.select.shell meta.sequence.list.shell meta.string.shell
+# ^^^^^^^^^^^^^ meta.statement.loop.select.shell meta.sequence.list.shell meta.string.glob.shell
 #              ^^ - meta.statement.loop - meta.sequence
 # ^ meta.interpolation.tilde.shell variable.language.tilde.shell - string
 #  ^^^^^^^^^^^^ string.unquoted.shell
@@ -1494,7 +1494,7 @@ select fname in *;
 # <- keyword.control.loop.select.shell
 #^^^^^ keyword.control.loop.select.shell
 #            ^^ keyword.operator.iterator.in.shell
-#               ^ meta.string.shell string.unquoted.shell
+#               ^ meta.string.glob.shell string.unquoted.shell
 #                ^ punctuation.terminator.statement.shell
 do
 # <- keyword.control.loop.do.shell
@@ -1937,12 +1937,12 @@ if !cmd
 #
 
 [[ '-e' == -e ]]   # -e undergoes pattern matching on the right
-#  ^^^^ meta.string.shell string.quoted.single.shell
+#  ^^^^ meta.string.glob.shell string.quoted.single.shell
 #       ^^ keyword.operator.comparison.shell
 #          ^^ meta.compound.conditional.shell meta.string.regexp.shell string.unquoted.shell - variable
 
 [[ -e == -e ]]     # a syntax error in bash but allowed in zsh
-#  ^^ meta.string.shell string.unquoted.shell - variable
+#  ^^ meta.string.glob.shell string.unquoted.shell - variable
 #     ^^ keyword.operator.comparison.shell
 #        ^^ meta.compound.conditional.shell meta.string.regexp.shell string.unquoted.shell - variable
 
@@ -2177,7 +2177,7 @@ asdf foo && FOO=some-value pwd
 #        ^^ keyword.operator.logical.shell
 #           ^^^ variable.other.readwrite.shell
 #              ^ keyword.operator.assignment.shell
-#               ^^^^^^^^^^ meta.string.shell string.unquoted.shell
+#               ^^^^^^^^^^ meta.string.glob.shell string.unquoted.shell
 #                          ^^^ meta.function-call.identifier.shell support.function.shell
 
 (cd Layer1-linux  && PLATFORM=${PLATFORM} ./build ) &&
@@ -2186,7 +2186,7 @@ asdf foo && FOO=some-value pwd
 #                 ^^ keyword.operator.logical.shell
 #                           ^ variable.other.readwrite.shell
 #                            ^ keyword.operator.assignment.shell
-#                             ^ meta.string.shell meta.interpolation.parameter.shell - string
+#                             ^ meta.string.glob.shell meta.interpolation.parameter.shell - string
 #                                         ^^^^^^^ variable.function.shell
 #                                                 ^ punctuation.section.compound.end.shell
 #                                                   ^^ keyword.operator.logical.shell
@@ -2196,7 +2196,7 @@ asdf foo && FOO=some-value pwd
 #                 ^^ keyword.operator.logical.shell
 #                           ^ variable.other.readwrite.shell
 #                            ^ keyword.operator.assignment.shell
-#                             ^ meta.string.shell meta.interpolation.parameter.shell - string
+#                             ^ meta.string.glob.shell meta.interpolation.parameter.shell - string
 #                                         ^^^^^^^ variable.function.shell
 #                                                 ^ punctuation.section.compound.end.shell
 #                                                   ^^ keyword.operator.logical.shell
@@ -2206,7 +2206,7 @@ asdf foo && FOO=some-value pwd
 #                 ^^ keyword.operator.logical.shell
 #                           ^ variable.other.readwrite.shell
 #                            ^ keyword.operator.assignment.shell
-#                             ^ meta.string.shell meta.interpolation.parameter.shell - string
+#                             ^ meta.string.glob.shell meta.interpolation.parameter.shell - string
 #                                         ^^^^^^^ variable.function.shell
 #                                                 ^ punctuation.section.compound.end.shell
 #                                                   ^^ keyword.operator.logical.shell
@@ -2216,10 +2216,10 @@ asdf foo && FOO=some-value pwd
 #                 ^^ keyword.operator.logical.shell
 #                           ^ variable.other.readwrite.shell
 #                            ^ keyword.operator.assignment.shell
-#                             ^^^^^^^^^^^ meta.string.shell meta.interpolation.parameter.shell - string
+#                             ^^^^^^^^^^^ meta.string.glob.shell meta.interpolation.parameter.shell - string
 #                                         ^^^^ variable.other.readwrite.shell
 #                                             ^ keyword.operator.assignment.shell
-#                                              ^^^^^^^ meta.string.shell meta.interpolation.parameter.shell - string
+#                                              ^^^^^^^ meta.string.glob.shell meta.interpolation.parameter.shell - string
 #                                                      ^^^^^^^ variable.function.shell
 #                                                              ^ punctuation.section.compound.end.shell
 #                                                                ^^ keyword.operator.logical.shell
@@ -2254,7 +2254,7 @@ case var in
   ( patt ( esac
 #^ meta.statement.conditional.case.body.shell
 # ^^ meta.clause.patterns.shell - meta.string - meta.group - string
-#   ^^^^ meta.clause.patterns.shell meta.string.shell string.unquoted.shell - meta.groupD
+#   ^^^^ meta.clause.patterns.shell meta.string.glob.shell string.unquoted.shell - meta.groupD
 #       ^^^ meta.clause.patterns.shell - meta.string - meta.group - string
 #          ^^^^ meta.statement.conditional.case.end.shell
 # ^ punctuation.section.patterns.begin.shell
@@ -2279,7 +2279,7 @@ case   # comment
 #      ^^^^^^^^^^ comment.line.number-sign.shell
   pattern) # comment
 #^ meta.statement.conditional.case.body.shell
-# ^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.shell string.unquoted.shell - meta.group
+# ^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.glob.shell string.unquoted.shell - meta.group
 #        ^ meta.clause.patterns.shell - meta.clause.body - meta.string - meta.group - string
 #         ^^^^^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.shell - meta.clause.patterns
 #          ^^^^^^^^^^ comment.line.number-sign.shell
@@ -2291,14 +2291,14 @@ esac
 case "$1" in
 # <- keyword.control.conditional.case.shell
 #^^^ keyword.control.conditional.case.shell
-#    ^ meta.string.shell string.quoted.double.shell punctuation.definition.string.begin.shell
-#     ^ meta.string.shell meta.interpolation.parameter.shell variable.language.positional.shell punctuation.definition.variable.shell
-#      ^ meta.string.shell meta.interpolation.parameter.shell variable.language.positional.shell
-#       ^ meta.string.shell string.quoted.double.shell punctuation.definition.string.end.shell
+#    ^ meta.string.glob.shell string.quoted.double.shell punctuation.definition.string.begin.shell
+#     ^ meta.string.glob.shell meta.interpolation.parameter.shell variable.language.positional.shell punctuation.definition.variable.shell
+#      ^ meta.string.glob.shell meta.interpolation.parameter.shell variable.language.positional.shell
+#       ^ meta.string.glob.shell string.quoted.double.shell punctuation.definition.string.end.shell
 #         ^^ keyword.control.conditional.in.shell
 setup )
-# <- meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.shell string.unquoted.shell
-#^^^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.shell string.unquoted.shell
+# <- meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.glob.shell string.unquoted.shell
+#^^^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.glob.shell string.unquoted.shell
 #    ^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell - meta.string - string
 # <- - variable.function - support.function - meta.function-call
 #     ^ punctuation.section.patterns.end.shell
@@ -2312,8 +2312,8 @@ echo Preparing the server...
 # ^ meta.statement.conditional.case.body.shell - meta.clause
 dep\
 loy )
-# <- meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.shell string.unquoted.shell
-#^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.shell string.unquoted.shell
+# <- meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.glob.shell string.unquoted.shell
+#^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.glob.shell string.unquoted.shell
 #  ^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell - meta.string - string
 # <- - variable.function - support.function - meta.function-call
 #   ^ punctuation.section.patterns.end.shell
@@ -2326,7 +2326,7 @@ echo Deploying...
 #^ meta.statement.conditional.case.body.shell meta.clause.shell punctuation.terminator.clause.shell
 # ^ meta.statement.conditional.case.body.shell - meta.clause
 * )
-# <- meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.shell string.unquoted.shell constant.other.wildcard.asterisk.shell
+# <- meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.glob.shell string.unquoted.shell constant.other.wildcard.asterisk.shell
 #^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell - meta.string - string - punctuation
 # ^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell punctuation.section.patterns.end.shell
 #  ^ meta.statement.conditional.case.body.shell meta.clause.shell
@@ -2370,9 +2370,9 @@ case "${foo}" in- in_ in=10 in
     ( help | h ) bar ;;
 #^^^ meta.statement.conditional.case.body.shell - meta.clause.patterns
 #   ^^ meta.clause.patterns.shell - meta.string - meta.group - string
-#     ^^^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.shell string.unquoted.shell - meta.group
+#     ^^^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.glob.shell string.unquoted.shell - meta.group
 #         ^^^ meta.clause.patterns.shell - meta.string - meta.group - string
-#            ^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.shell string.unquoted.shell - meta.group
+#            ^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.glob.shell string.unquoted.shell - meta.group
 #             ^^ meta.clause.patterns.shell - meta.string - meta.group - string
 #               ^ meta.statement.conditional.case.body.shell meta.clause.shell
 #                ^^^^ meta.statement.conditional.case.body.shell meta.clause.body.shell - meta.clause.patterns
@@ -2384,7 +2384,7 @@ case "${foo}" in- in_ in=10 in
 #                    ^^ punctuation.terminator.clause.shell
     do1 ) foo1 ;&
 #^^^ meta.statement.conditional.case.body.shell - meta.clause.patterns
-#   ^^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.shell string.unquoted.shell - meta.group
+#   ^^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.glob.shell string.unquoted.shell - meta.group
 #      ^^ meta.clause.patterns.shell - meta.string - meta.group - string
 #        ^ meta.statement.conditional.case.body.shell meta.clause.shell
 #         ^^^^^ meta.statement.conditional.case.body.shell meta.clause.body.shell - meta.clause.patterns
@@ -2395,7 +2395,7 @@ case "${foo}" in- in_ in=10 in
     (do2 ) foo2 ;;&
 #^^^ meta.statement.conditional.case.body.shell - meta.clause.patterns
 #   ^ meta.clause.patterns.shell - meta.string - meta.group - string
-#    ^^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.shell string.unquoted.shell - meta.group
+#    ^^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.glob.shell string.unquoted.shell - meta.group
 #       ^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell - meta.string - meta.group - string
 #         ^ meta.statement.conditional.case.body.shell meta.clause.shell
 #          ^^^^^ meta.statement.conditional.case.body.shell meta.clause.body.shell
@@ -2406,7 +2406,7 @@ case "${foo}" in- in_ in=10 in
 #               ^^^ punctuation.terminator.clause.shell
     *) bar
 #^^^ meta.statement.conditional.case.body.shell - meta.clause.patterns
-#   ^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.shell string.unquoted.shell - meta.group
+#   ^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.glob.shell string.unquoted.shell - meta.group
 #    ^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell - meta.string - meta.group - string
 #     ^ meta.statement.conditional.case.body.shell meta.clause.shell
 #      ^^^^ meta.statement.conditional.case.body.shell meta.clause.body.shell
@@ -2424,13 +2424,13 @@ case $TERM in
         #                                              ^ meta.function punctuation.section.block.end.shell
         #                                               ^^ punctuation.terminator.clause.shell
     *xterm*|rxvt|?(dt|k|E)term)
-        #^^ meta.clause.patterns.shell meta.string.shell string.unquoted.shell
+        #^^ meta.clause.patterns.shell meta.string.glob.shell string.unquoted.shell
         #  ^ meta.clause.patterns.shell - meta.string - meta.group - string
-        #   ^^^^ meta.clause.patterns.shell meta.string.shell string.unquoted.shell
+        #   ^^^^ meta.clause.patterns.shell meta.string.glob.shell string.unquoted.shell
         #       ^ meta.clause.patterns.shell - meta.string - meta.group - string
-        #        ^ meta.clause.patterns.shell meta.string.shell string.unquoted.shell
-        #         ^^^^^^^^ meta.clause.patterns.shell meta.string.shell meta.group.regexp.shell string.unquoted.shell
-        #                 ^^^^ meta.clause.patterns.shell meta.string.shell string.unquoted.shell
+        #        ^ meta.clause.patterns.shell meta.string.glob.shell string.unquoted.shell
+        #         ^^^^^^^^ meta.clause.patterns.shell meta.string.glob.shell meta.group.regexp.shell string.unquoted.shell
+        #                 ^^^^ meta.clause.patterns.shell meta.string.glob.shell string.unquoted.shell
         #                     ^ meta.clause.patterns.shell - meta.string - meta.group - string
         # ^ constant.other.wildcard.asterisk.shell
         #  ^ keyword.operator.logical.shell
@@ -2445,7 +2445,7 @@ case $TERM in
         #                                             ^ meta.function punctuation.section.block.end.shell
         #                                              ^^ punctuation.terminator.clause.shell
     *)
-    # <- meta.clause.patterns.shell meta.string.shell string.unquoted.shell constant.other.wildcard.asterisk.shell
+    # <- meta.clause.patterns.shell meta.string.glob.shell string.unquoted.shell constant.other.wildcard.asterisk.shell
     #^ punctuation.section.patterns.end.shell
         update_terminal_cwd() {};;
         #                      ^ meta.function punctuation.section.block.end.shell
@@ -2456,9 +2456,9 @@ esac
 case $SERVER in
 # <- keyword.control.conditional.case.shell
 ws-+([0-9]).host.com) echo "Web Server"
-#^^^ meta.clause.patterns.shell meta.string.shell - meta.group
-#   ^^^^^^^ meta.clause.patterns.shell meta.string.shell meta.group.regexp.shell
-#          ^^^^^^^^^ meta.clause.patterns.shell meta.string.shell - meta.group
+#^^^ meta.clause.patterns.shell meta.string.glob.shell - meta.group
+#   ^^^^^^^ meta.clause.patterns.shell meta.string.glob.shell meta.group.regexp.shell
+#          ^^^^^^^^^ meta.clause.patterns.shell meta.string.glob.shell - meta.group
 #                   ^ meta.clause.patterns.shell - meta.string - meta.group - string
 #^^^^^^^^^^^^^^^^^^^ string.unquoted.shell
 #  ^ keyword.operator.quantifier.regexp.shell
@@ -2473,9 +2473,9 @@ ws-+([0-9]).host.com) echo "Web Server"
 # <- punctuation.terminator.clause.shell
 #^ punctuation.terminator.clause.shell
 db-+([0-9])\.host\.com) echo "DB server"
-#^^^ meta.clause.patterns.shell meta.string.shell - meta.group
-#   ^^^^^^^ meta.clause.patterns.shell meta.string.shell meta.group.regexp.shell
-#          ^^^^^^^^^^^ meta.clause.patterns.shell meta.string.shell - meta.group
+#^^^ meta.clause.patterns.shell meta.string.glob.shell - meta.group
+#   ^^^^^^^ meta.clause.patterns.shell meta.string.glob.shell meta.group.regexp.shell
+#          ^^^^^^^^^^^ meta.clause.patterns.shell meta.string.glob.shell - meta.group
 #  ^ keyword.operator.quantifier.regexp.shell
 #   ^ punctuation.section.group.begin.regexp.shell
 #    ^ punctuation.definition.set.begin.regexp.shell
@@ -2557,7 +2557,7 @@ esac
 #           ^^^^^^^^^ meta.compound.command.shell
 #^ punctuation.section.compound.begin.shell
 # ^^^ meta.command.shell variable.function.shell
-#     ^^^^^ meta.string.shell string.unquoted.shell
+#     ^^^^^ meta.string.glob.shell string.unquoted.shell
 #          ^ punctuation.section.compound.end.shell
 #            ^^ keyword.operator.logical.shell
 #               ^^^^ constant.language.boolean.true.shell
@@ -2568,7 +2568,7 @@ stash) || true)
 #^^^^^^^^^^^^^^ - meta.compound.arithmetic
 #^^^^^ meta.compound.command.shell meta.compound.command.shell
 #     ^^^^^^^^^ meta.compound.command.shell
-#^^^^ meta.string.shell string.unquoted.shell
+#^^^^ meta.string.glob.shell string.unquoted.shell
 #    ^ punctuation.section.compound.end.shell
 #      ^^ keyword.operator.logical.shell
 #         ^^^^ constant.language.boolean.true.shell
@@ -2667,7 +2667,7 @@ coproc awk '{print "foo" $0;fflush()}'
 #                                     ^ - meta.coproc - meta.function-call
 #^^^^^ keyword.declaration.coproc.shell
 #      ^^^ variable.function.shell
-#          ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell string.quoted.single.shell - meta.interpolation
+#          ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.glob.shell string.quoted.single.shell - meta.interpolation
 #          ^ punctuation.definition.string.begin.shell
 #                                    ^ punctuation.definition.string.end.shell
 
@@ -2731,7 +2731,7 @@ coproc myls { ls thisfiledoesntexist; read; 2>&1 } | foo
 #        ^^^ entity.name.function.shell
 #            ^ punctuation.section.compound.begin.shell
 #              ^^^ variable.function.shell
-#                  ^^^^^^^ meta.string.shell string.unquoted.shell
+#                  ^^^^^^^ meta.string.glob.shell string.unquoted.shell
 #                          ^ punctuation.terminator.statement.shell
 #                           ^ punctuation.section.compound.end.shell
 #                             ^^ keyword.operator.assignment.redirection
@@ -2809,8 +2809,8 @@ coproc foobar {
 #                  ^^ punctuation.section.compound.end
 #                     ^^ keyword.operator.logical
 #                                                                                    ^ punctuation.section.block.end.shell
-#                                                                                      ^^^^ meta.string.shell string.unquoted.shell
-#                                                                                           ^^^^ meta.string.shell string.unquoted.shell
+#                                                                                      ^^^^ meta.string.glob.shell string.unquoted.shell
+#                                                                                           ^^^^ meta.string.glob.shell string.unquoted.shell
 
 function ; {} arg
 # <- meta.function-call.shell meta.function.anonymous.shell keyword.declaration.function.shell
@@ -2821,7 +2821,7 @@ function ; {} arg
 #^^^^^^^ keyword.declaration.function.shell
 #        ^ punctuation.terminator.statement.shell
 #          ^^ variable.function.shell
-#             ^^^ meta.string.shell string.unquoted.shell
+#             ^^^ meta.string.glob.shell string.unquoted.shell
 
 function () {} arg
 # <- meta.function-call.shell meta.function.anonymous.shell keyword.declaration.function.shell
@@ -2836,7 +2836,7 @@ function () {} arg
 #         ^ punctuation.section.parameters.end.shell
 #           ^ punctuation.section.block.begin.shell
 #            ^ punctuation.section.block.end.shell
-#              ^^^ meta.string.shell string.unquoted.shell
+#              ^^^ meta.string.glob.shell string.unquoted.shell
 
 function () ; {} arg
 # <- meta.function-call.shell meta.function.anonymous.shell keyword.declaration.function.shell
@@ -2852,7 +2852,7 @@ function () ; {} arg
 #         ^ punctuation.section.parameters.end.shell
 #           ^ punctuation.terminator.statement.shell
 #             ^^ variable.function.shell
-#                ^^^ meta.string.shell string.unquoted.shell
+#                ^^^ meta.string.glob.shell string.unquoted.shell
 
 # Posix Functions
 
@@ -2900,7 +2900,7 @@ function () ; {} arg
 #            ^^^^ invalid.illegal.unexpected-token.shell
 #                 ^ punctuation.terminator.statement.shell
 #                   ^^^^ support.function.shell
-#                        ^^^^ meta.string.shell string.unquoted.shell
+#                        ^^^^ meta.string.glob.shell string.unquoted.shell
 
   func () {} rest && echo done
 #^ source.shell - meta.function
@@ -2911,7 +2911,7 @@ function () ; {} arg
 #            ^^^^ invalid.illegal.unexpected-token.shell
 #                 ^^ keyword.operator.logical.shell
 #                    ^^^^ support.function.shell
-#                         ^^^^ meta.string.shell string.unquoted.shell
+#                         ^^^^ meta.string.glob.shell string.unquoted.shell
 
   logC () { [[ $# == 2 ]] && tput setaf $2 || tput setaf 3; echo -e "$1"; tput setaf 15; }
 #^ source.shell - meta.function
@@ -3344,7 +3344,7 @@ x= # some comment
 x=a
 # <- variable.other.readwrite
 #^ keyword.operator.assignment.shell
-# ^ meta.string.shell string.unquoted.shell
+# ^ meta.string.glob.shell string.unquoted.shell
 x=a # some comment
 #^ keyword.operator.assignment.shell
 #  ^ - string.unquoted
@@ -3352,17 +3352,17 @@ x=a#not-a-comment
 #^ keyword.operator.assignment.shell
 #  ^ meta.string string.unquoted - comment
 foo=bar baz=qux
-#   ^^^ meta.string.shell string.unquoted.shell
-#           ^^^ meta.string.shell string.unquoted.shell
+#   ^^^ meta.string.glob.shell string.unquoted.shell
+#           ^^^ meta.string.glob.shell string.unquoted.shell
 foo=bar\
 qux
-#<- meta.string.shell string.unquoted.shell
-#^^ meta.string.shell string.unquoted.shell
+#<- meta.string.glob.shell string.unquoted.shell
+#^^ meta.string.glob.shell string.unquoted.shell
 foo=bar"baz"qux
 #<- variable.other.readwrite.shell
 #^^ variable.other.readwrite.shell
 #  ^ keyword.operator.assignment.shell
-#   ^^^^^^^^^^^ meta.string.shell - string string
+#   ^^^^^^^^^^^ meta.string.glob.shell - string string
 #   ^^^ string.unquoted.shell
 #      ^^^^^ string.quoted.double.shell
 #           ^^^ string.unquoted.shell
@@ -3370,7 +3370,7 @@ foo='bar'
 #<- variable.other.readwrite.shell
 #^^ variable.other.readwrite.shell
 #  ^ keyword.operator.assignment.shell
-#   ^^^^^ meta.string.shell string.quoted.single.shell
+#   ^^^^^ meta.string.glob.shell string.quoted.single.shell
 x=0.19.8.1
 # <- variable.other.readwrite.shell
 #^ keyword.operator.assignment.shell
@@ -3378,7 +3378,7 @@ x=0.19.8.1
 x=10
 # <- variable.other.readwrite.shell
 #^ keyword.operator.assignment.shell
-# ^^ meta.string.shell string.unquoted.shell
+# ^^ meta.string.glob.shell string.unquoted.shell
 
 # Spaces following an assignment token means an empty string value!
 x= pwd
@@ -3404,18 +3404,18 @@ x="a b" pwd
 #       ^^^ meta.function-call support.function
 x=a y=b pwd
 #^ keyword.operator.assignment.shell
-# ^ meta.string.shell string.unquoted.shell
+# ^ meta.string.glob.shell string.unquoted.shell
 #  ^ - string.unquoted
 #    ^ keyword.operator.assignment.shell
-#     ^ meta.string.shell string.unquoted.shell
+#     ^ meta.string.glob.shell string.unquoted.shell
 #      ^ - string.unquoted
 #       ^^^ meta.function-call support.function
 x=${foo} y=${baz}"asdf" pwd
 #^ keyword.operator.assignment.shell
-# ^^^^^^ meta.string.shell meta.interpolation.parameter.shell - string
+# ^^^^^^ meta.string.glob.shell meta.interpolation.parameter.shell - string
 #       ^^^ - meta.string - mete.interpolation - string
-#          ^^^^^^ meta.string.shell meta.interpolation.parameter.shell - string
-#                ^^^^^^ meta.string.shell string.quoted.double.shell - meta.interpolation
+#          ^^^^^^ meta.string.glob.shell meta.interpolation.parameter.shell - string
+#                ^^^^^^ meta.string.glob.shell string.quoted.double.shell - meta.interpolation
 #                      ^^^^ - meta.string - mete.interpolation - string
 # ^ punctuation.definition.variable.shell
 #  ^ punctuation.section.interpolation.begin.shell
@@ -3487,14 +3487,14 @@ charclass=\}ower
 # <- meta.assignment.l-value.shell variable.other.readwrite.shell
 #^^^^^^^^ meta.assignment.l-value.shell variable.other.readwrite.shell
 #        ^ meta.assignment.shell keyword.operator.assignment.shell
-#         ^^^^^^ meta.assignment.r-value.shell meta.string.shell string.unquoted.shell
+#         ^^^^^^ meta.assignment.r-value.shell meta.string.glob.shell string.unquoted.shell
 #         ^^ constant.character.escape.shell
 
 (foo=bar)
 # <- meta.compound.command.shell punctuation.section.compound.begin.shell
 #^^^ meta.compound.command.shell meta.assignment.l-value.shell variable.other.readwrite.shell
 #   ^ meta.compound.command.shell meta.assignment.shell keyword.operator.assignment.shell
-#    ^^^ meta.compound.command.shell meta.assignment.r-value.shell meta.string.shell string.unquoted.shell
+#    ^^^ meta.compound.command.shell meta.assignment.r-value.shell meta.string.glob.shell string.unquoted.shell
 #       ^ meta.compound.command.shell punctuation.section.compound.end.shell - string
 
 { foo=bar }
@@ -3502,7 +3502,7 @@ charclass=\}ower
 #^ meta.compound.command.shell - meta.assignment
 # ^^^ meta.compound.command.shell meta.assignment.l-value.shell variable.other.readwrite.shell
 #    ^ meta.compound.command.shell meta.assignment.shell keyword.operator.assignment.shell
-#     ^^^ meta.compound.command.shell meta.assignment.r-value.shell meta.string.shell string.unquoted.shell
+#     ^^^ meta.compound.command.shell meta.assignment.r-value.shell meta.string.glob.shell string.unquoted.shell
 #        ^ meta.compound.command.shell - meta.assignment
 #         ^ meta.compound.command.shell punctuation.section.compound.end.shell
 
@@ -3510,13 +3510,13 @@ foo+=" baz"
 #<- meta.assignment.l-value.shell variable.other.readwrite.shell
 #^^ meta.assignment.l-value.shell variable.other.readwrite.shell
 #  ^^ meta.assignment.shell keyword.operator.assignment.shell
-#    ^^^^^^ meta.assignment.r-value.shell meta.string.shell string.quoted.double.shell
+#    ^^^^^^ meta.assignment.r-value.shell meta.string.glob.shell string.quoted.double.shell
 
 foo-=" baz"
 #<- meta.assignment.l-value.shell variable.other.readwrite.shell
 #^^ meta.assignment.l-value.shell variable.other.readwrite.shell
 #  ^^ meta.assignment.shell keyword.operator.assignment.shell
-#    ^^^^^^ meta.assignment.r-value.shell meta.string.shell string.quoted.double.shell
+#    ^^^^^^ meta.assignment.r-value.shell meta.string.glob.shell string.quoted.double.shell
 
 ## Arrays ##
 
@@ -3534,22 +3534,22 @@ array=(one two three four -5 (foo bar baz)
 #^^^^ variable.other.readwrite.shell
 #    ^ keyword.operator.assignment.shell
 #     ^ punctuation.section.sequence.begin.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ - meta.string - string
-#          ^^^ meta.string.shell string.unquoted.shell
+#          ^^^ meta.string.glob.shell string.unquoted.shell
 #             ^ - meta.string - string
-#              ^^^^^ meta.string.shell string.unquoted.shell
+#              ^^^^^ meta.string.glob.shell string.unquoted.shell
 #                   ^ - meta.string - string
-#                    ^^^^ meta.string.shell string.unquoted.shell
+#                    ^^^^ meta.string.glob.shell string.unquoted.shell
 #                        ^ - meta.string - string
-#                         ^^ meta.string.shell string.unquoted.shell
+#                         ^^ meta.string.glob.shell string.unquoted.shell
 #                           ^^ - meta.string - string
 #                            ^ invalid.illegal.unexpected-token.shell
-#                             ^^^ meta.string.shell string.unquoted.shell
+#                             ^^^ meta.string.glob.shell string.unquoted.shell
 #                                ^ - meta.string - string
-#                                 ^^^ meta.string.shell string.unquoted.shell
+#                                 ^^^ meta.string.glob.shell string.unquoted.shell
 #                                    ^ - meta.string - string
-#                                     ^^^ meta.string.shell string.unquoted.shell
+#                                     ^^^ meta.string.glob.shell string.unquoted.shell
 #                                        ^ punctuation.section.sequence.end.shell
 
 array=($one "two" ${three} 'four' $5)
@@ -3593,7 +3593,7 @@ array=([one]== ["two"]='what' [4+5]=qux [five]=0 [six]=0s)
 #       ^^^ entity.name.key.shell
 #          ^ punctuation.section.item-access.end.shell
 #           ^ keyword.operator.assignment.shell
-#            ^ meta.string.shell string.unquoted.shell - keyword
+#            ^ meta.string.glob.shell string.unquoted.shell - keyword
 #              ^ punctuation.section.item-access.begin.shell
 #               ^^^^^ entity.name.key.shell
 #               ^ punctuation.definition.quoted.begin.shell
@@ -3605,17 +3605,17 @@ array=([one]== ["two"]='what' [4+5]=qux [five]=0 [six]=0s)
 #                              ^^^ entity.name.key.shell - constant - keyword
 #                                 ^ punctuation.section.item-access.end.shell
 #                                  ^ keyword.operator.assignment.shell
-#                                   ^^^ meta.string.shell string.unquoted.shell
+#                                   ^^^ meta.string.glob.shell string.unquoted.shell
 #                                       ^ punctuation.section.item-access.begin.shell
 #                                        ^^^^ entity.name.key.shell
 #                                            ^ punctuation.section.item-access.end.shell
 #                                             ^ keyword.operator.assignment.shell
-#                                              ^ meta.string.shell string.unquoted.shell
+#                                              ^ meta.string.glob.shell string.unquoted.shell
 #                                                ^ punctuation.section.item-access.begin.shell
 #                                                 ^^^ entity.name.key.shell
 #                                                    ^ punctuation.section.item-access.end.shell
 #                                                     ^ keyword.operator.assignment.shell
-#                                                      ^^ meta.string.shell string.unquoted.shell
+#                                                      ^^ meta.string.glob.shell string.unquoted.shell
 #                                                        ^ punctuation.section.sequence.end.shell
 
 declare -a array
@@ -3624,21 +3624,21 @@ array[500]=value
 #^^^^ meta.assignment.l-value.shell - meta.sequence
 #    ^^^^^ meta.assignment.l-value.shell meta.item-access.shell
 #         ^ meta.assignment.shell - meta.sequence
-#          ^^^^^ meta.assignment.r-value.shell meta.string.shell string.unquoted.shell
+#          ^^^^^ meta.assignment.r-value.shell meta.string.glob.shell string.unquoted.shell
 #               ^ - meta
 #^^^^ variable.other.readwrite.shell
 #    ^ punctuation.section.item-access.begin.shell
 #     ^^^ meta.string.shell string.unquoted.shell
 #        ^ punctuation.section.item-access.end.shell
 #         ^ keyword.operator.assignment
-#          ^^^^^ meta.string.shell string.unquoted.shell
+#          ^^^^^ meta.string.glob.shell string.unquoted.shell
 
 array["foo"]=bar
 #<- meta.assignment.l-value.shell variable.other.readwrite.shell
 #^^^^ meta.assignment.l-value.shell - meta.sequence
 #    ^^^^^^^ meta.assignment.l-value.shell meta.item-access.shell
 #           ^ meta.assignment.shell - meta.sequence
-#            ^^^ meta.assignment.r-value.shell meta.string.shell string.unquoted.shell
+#            ^^^ meta.assignment.r-value.shell meta.string.glob.shell string.unquoted.shell
 #               ^ - meta
 #^^^^ variable.other.readwrite.shell
 #    ^^^^^^^ meta.item-access.shell - variable
@@ -3646,30 +3646,30 @@ array["foo"]=bar
 #     ^^^^^ string.quoted.double.shell
 #          ^ punctuation.section.item-access.end.shell
 #           ^ keyword.operator.assignment.shell
-#            ^^^ meta.string.shell string.unquoted.shell
+#            ^^^ meta.string.glob.shell string.unquoted.shell
 
 array[foo]=bar
 #<- meta.assignment.l-value.shell variable.other.readwrite.shell
 #^^^^ meta.assignment.l-value.shell - meta.sequence
 #    ^^^^^ meta.assignment.l-value.shell meta.item-access.shell
 #         ^ meta.assignment.shell - meta.sequence
-#          ^^^ meta.assignment.r-value.shell meta.string.shell string.unquoted.shell
+#          ^^^ meta.assignment.r-value.shell meta.string.glob.shell string.unquoted.shell
 #             ^ - meta
 #    ^^^^^ meta.item-access.shell
 #    ^ punctuation.section.item-access.begin.shell - variable
 #     ^^^ meta.string.shell string.unquoted.shell
 #        ^ punctuation.section.item-access.end.shell - variable
 #         ^ keyword.operator.assignment.shell
-#          ^^^ meta.string.shell string.unquoted.shell
+#          ^^^ meta.string.glob.shell string.unquoted.shell
 
 foo[${j}+10]="`foo`"
 #<- meta.assignment.l-value.shell variable.other.readwrite.shell
 #^^^ meta.assignment.l-value.shell - meta.sequence
 #  ^^^^^^^^^ meta.assignment.l-value.shell meta.item-access.shell
 #           ^ meta.assignment.shell - meta.sequence
-#            ^ meta.assignment.r-value.shell meta.string.shell - meta.interpolation
-#             ^^^^^ meta.assignment.r-value.shell meta.string.shell meta.interpolation.command.shell
-#                  ^ meta.assignment.r-value.shell meta.string.shell - meta.interpolation
+#            ^ meta.assignment.r-value.shell meta.string.glob.shell - meta.interpolation
+#             ^^^^^ meta.assignment.r-value.shell meta.string.glob.shell meta.interpolation.command.shell
+#                  ^ meta.assignment.r-value.shell meta.string.glob.shell - meta.interpolation
 #                   ^ - meta
 #^^ variable.other.readwrite.shell
 #  ^ punctuation.section.item-access.begin.shell
@@ -3688,30 +3688,30 @@ foo[${j}+10]="`foo`"
 #                  ^ string.quoted.double.shell punctuation.definition.string.end.shell
 
 foo=`cd -L`
-#   ^ meta.string.shell meta.interpolation.command.shell
-#    ^^ meta.string.shell meta.interpolation.command.shell meta.function-call.identifier.shell
-#      ^^^ meta.string.shell meta.interpolation.command.shell meta.function-call.arguments.shell
-#         ^ meta.string.shell meta.interpolation.command.shell
+#   ^ meta.string.glob.shell meta.interpolation.command.shell
+#    ^^ meta.string.glob.shell meta.interpolation.command.shell meta.function-call.identifier.shell
+#      ^^^ meta.string.glob.shell meta.interpolation.command.shell meta.function-call.arguments.shell
+#         ^ meta.string.glob.shell meta.interpolation.command.shell
 #   ^ punctuation.section.interpolation.begin.shell
 #    ^^ support.function.shell
 #       ^^ meta.parameter.option.shell variable.parameter.option.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 foo=`echo -e`
-#   ^ meta.string.shell meta.interpolation.command.shell
-#    ^^^^ meta.string.shell meta.interpolation.command.shell meta.function-call.identifier.shell
-#        ^^^ meta.string.shell meta.interpolation.command.shell meta.function-call.arguments.shell
-#           ^ meta.string.shell meta.interpolation.command.shell
+#   ^ meta.string.glob.shell meta.interpolation.command.shell
+#    ^^^^ meta.string.glob.shell meta.interpolation.command.shell meta.function-call.identifier.shell
+#        ^^^ meta.string.glob.shell meta.interpolation.command.shell meta.function-call.arguments.shell
+#           ^ meta.string.glob.shell meta.interpolation.command.shell
 #   ^ punctuation.section.interpolation.begin.shell
 #    ^^^^ support.function.shell
 #         ^^ meta.parameter.option.shell variable.parameter.option.shell
 #           ^ punctuation.section.interpolation.end.shell
 
 foo=`let 5+5`
-#   ^ meta.string.shell meta.interpolation.command.shell
-#    ^^^ meta.string.shell meta.interpolation.command.shell meta.function-call.identifier.shell
-#       ^^^^ meta.string.shell meta.interpolation.command.shell meta.function-call.arguments.shell meta.arithmetic.shell
-#           ^ meta.string.shell meta.interpolation.command.shell
+#   ^ meta.string.glob.shell meta.interpolation.command.shell
+#    ^^^ meta.string.glob.shell meta.interpolation.command.shell meta.function-call.identifier.shell
+#       ^^^^ meta.string.glob.shell meta.interpolation.command.shell meta.function-call.arguments.shell meta.arithmetic.shell
+#           ^ meta.string.glob.shell meta.interpolation.command.shell
 #   ^ punctuation.section.interpolation.begin.shell
 #    ^^^ support.function.shell
 #        ^ meta.number.integer.decimal.shell constant.numeric.value.shell
@@ -3720,27 +3720,27 @@ foo=`let 5+5`
 #           ^ punctuation.section.interpolation.end.shell
 
 foo=`some-command --long1`
-#   ^ meta.string.shell meta.interpolation.command.shell
-#    ^^^^^^^^^^^^ meta.string.shell meta.interpolation.command.shell meta.function-call.identifier.shell
-#                ^^^^^^^^ meta.string.shell meta.interpolation.command.shell meta.function-call.arguments.shell
-#                        ^ meta.string.shell meta.interpolation.command.shell
+#   ^ meta.string.glob.shell meta.interpolation.command.shell
+#    ^^^^^^^^^^^^ meta.string.glob.shell meta.interpolation.command.shell meta.function-call.identifier.shell
+#                ^^^^^^^^ meta.string.glob.shell meta.interpolation.command.shell meta.function-call.arguments.shell
+#                        ^ meta.string.glob.shell meta.interpolation.command.shell
 #   ^ punctuation.section.interpolation.begin.shell
 #    ^^^^^^^^^^^^ variable.function.shell
 #                 ^^^^^^^ meta.parameter.option.shell variable.parameter.option.shell
 #                        ^ punctuation.section.interpolation.end.shell
 
 foo=`some-command -x`
-#   ^ meta.string.shell meta.interpolation.command.shell
-#    ^^^^^^^^^^^^ meta.string.shell meta.interpolation.command.shell meta.function-call.identifier.shell
-#                ^^^ meta.string.shell meta.interpolation.command.shell meta.function-call.arguments.shell
-#                   ^ meta.string.shell meta.interpolation.command.shell
+#   ^ meta.string.glob.shell meta.interpolation.command.shell
+#    ^^^^^^^^^^^^ meta.string.glob.shell meta.interpolation.command.shell meta.function-call.identifier.shell
+#                ^^^ meta.string.glob.shell meta.interpolation.command.shell meta.function-call.arguments.shell
+#                   ^ meta.string.glob.shell meta.interpolation.command.shell
 #   ^ punctuation.section.interpolation.begin.shell
 #    ^^^^^^^^^^^^ variable.function.shell
 #                 ^^ meta.parameter.option.shell variable.parameter.option.shell
 #                   ^ punctuation.section.interpolation.end.shell
 
 foo=`(uname -r --) 2>/dev/null`
-#   ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell meta.interpolation.command.shell
+#   ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.glob.shell meta.interpolation.command.shell
 #    ^^^^^^^^^^^^^ meta.compound.command.shell
 #   ^ punctuation.section.interpolation.begin.shell
 #     ^^^^^ variable.function.shell
@@ -3752,7 +3752,7 @@ foo=`(uname -r --) 2>/dev/null`
 #                             ^ punctuation.section.interpolation.end.shell - punctuation.section.interpolation.begin
 
 foo=`(uname -r) 2>/dev/null` || foo=unknown
-#   ^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell meta.interpolation.command.shell
+#   ^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.glob.shell meta.interpolation.command.shell
 #    ^^^^^^^^^^ meta.compound.command.shell
 #   ^ punctuation.section.interpolation.begin.shell
 #     ^^^^^ variable.function.shell
@@ -3764,19 +3764,19 @@ foo=`(uname -r) 2>/dev/null` || foo=unknown
 #                            ^^ keyword.operator.logical.shell
 #                               ^^^ variable.other.readwrite.shell
 #                                  ^ keyword.operator.assignment.shell
-#                                   ^^^^^^^ meta.string.shell string.unquoted.shell
+#                                   ^^^^^^^ meta.string.glob.shell string.unquoted.shell
 
 commits=($(git rev-list --reverse --$abbrev-commit "$latest".. -- "$prefix"))
 #       ^ meta.sequence.list.shell - meta.interpolation
-#        ^^ meta.sequence.list.shell meta.string.shell meta.interpolation.command.shell - meta.function
-#          ^^^ meta.sequence.list.shell meta.string.shell meta.interpolation.command.shell meta.function-call.identifier.shell - meta.function meta.function
-#             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.sequence.list.shell meta.string.shell meta.interpolation.command.shell meta.function-call.arguments.shell  - meta.function meta.function
+#        ^^ meta.sequence.list.shell meta.string.glob.shell meta.interpolation.command.shell - meta.function
+#          ^^^ meta.sequence.list.shell meta.string.glob.shell meta.interpolation.command.shell meta.function-call.identifier.shell - meta.function meta.function
+#             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.sequence.list.shell meta.string.glob.shell meta.interpolation.command.shell meta.function-call.arguments.shell  - meta.function meta.function
 #                                 ^^ meta.parameter.option.shell - meta.parameter.option.shell meta.interpolation
 #                                   ^^^^^^^ meta.parameter.option.shell meta.interpolation.parameter.shell
 #                                          ^^^^^^^ meta.parameter.option.shell - meta.parameter.option.shell meta.interpolation
-#                                                  ^^^^^^^^^ meta.string.shell
-#                                                                 ^^^^^^^^^ meta.string.shell
-#                                                                          ^ meta.sequence.list.shell meta.string.shell meta.interpolation.command.shell - meta.function
+#                                                  ^^^^^^^^^ meta.string.glob.shell
+#                                                                 ^^^^^^^^^ meta.string.glob.shell
+#                                                                          ^ meta.sequence.list.shell meta.string.glob.shell meta.interpolation.command.shell - meta.function
 #                                                                           ^ meta.sequence.list.shell - meta.interpolation
 #       ^ punctuation.section.sequence.begin.shell
 #        ^ punctuation.definition.variable.shell
@@ -3880,9 +3880,9 @@ B$(cat)OWL=$(($(cat food.txt | wc -l) + 5))
 #                 ^ keyword.operator.expansion.length.shell
 #                  ^ variable.language.special.shell
 #                   ^ punctuation.section.interpolation.end.shell
-#                     ^ meta.string.shell string.unquoted.shell
-#                      ^^ meta.string.shell meta.interpolation.parameter.shell variable.language.special.shell
-#                        ^ meta.string.shell string.unquoted.shell
+#                     ^ meta.string.glob.shell string.unquoted.shell
+#                      ^^ meta.string.glob.shell meta.interpolation.parameter.shell variable.language.special.shell
+#                        ^ meta.string.glob.shell string.unquoted.shell
 
 # Expands to the positional parameters, starting from one. When the expansion
 # occurs within double quotes, each parameter expands to a separate word. That
@@ -3911,9 +3911,9 @@ B$(cat)OWL=$(($(cat food.txt | wc -l) + 5))
 #                 ^ keyword.operator.expansion.length.shell
 #                  ^ variable.language.special.shell
 #                   ^ punctuation.section.interpolation.end.shell
-#                     ^ meta.string.shell string.unquoted.shell
-#                      ^^ meta.string.shell meta.interpolation.parameter.shell variable.language.special.shell
-#                        ^ meta.string.shell string.unquoted.shell
+#                     ^ meta.string.glob.shell string.unquoted.shell
+#                      ^^ meta.string.glob.shell meta.interpolation.parameter.shell variable.language.special.shell
+#                        ^ meta.string.glob.shell string.unquoted.shell
 
 # Expands to the number of positional parameters in decimal.
 : $# ${#} ${!#} ${##} _$#_
@@ -3936,9 +3936,9 @@ B$(cat)OWL=$(($(cat food.txt | wc -l) + 5))
 #                 ^ keyword.operator.expansion.length.shell
 #                  ^ variable.language.special.shell
 #                   ^ punctuation.section.interpolation.end.shell
-#                     ^ meta.string.shell string.unquoted.shell
-#                      ^^ meta.string.shell meta.interpolation.parameter.shell variable.language.special.shell
-#                        ^ meta.string.shell string.unquoted.shell
+#                     ^ meta.string.glob.shell string.unquoted.shell
+#                      ^^ meta.string.glob.shell meta.interpolation.parameter.shell variable.language.special.shell
+#                        ^ meta.string.glob.shell string.unquoted.shell
 
 # Expands to the exit status of the most recently executed foreground pipeline.
 : $? ${?} ${!?} ${#?} _$?_
@@ -3961,9 +3961,9 @@ B$(cat)OWL=$(($(cat food.txt | wc -l) + 5))
 #                 ^ keyword.operator.expansion.length.shell
 #                  ^ variable.language.special.shell
 #                   ^ punctuation.section.interpolation.end.shell
-#                     ^ meta.string.shell string.unquoted.shell
-#                      ^^ meta.string.shell meta.interpolation.parameter.shell variable.language.special.shell
-#                        ^ meta.string.shell string.unquoted.shell
+#                     ^ meta.string.glob.shell string.unquoted.shell
+#                      ^^ meta.string.glob.shell meta.interpolation.parameter.shell variable.language.special.shell
+#                        ^ meta.string.glob.shell string.unquoted.shell
 
 # Expands to the current option flags as specified upon invocation, by the set
 # builtin command, or those set by the shell itself (such as the -i option).
@@ -3987,9 +3987,9 @@ B$(cat)OWL=$(($(cat food.txt | wc -l) + 5))
 #                 ^ keyword.operator.expansion.length.shell
 #                  ^ variable.language.special.shell
 #                   ^ punctuation.section.interpolation.end.shell
-#                     ^ meta.string.shell string.unquoted.shell
-#                      ^^ meta.string.shell meta.interpolation.parameter.shell variable.language.special.shell
-#                        ^ meta.string.shell string.unquoted.shell
+#                     ^ meta.string.glob.shell string.unquoted.shell
+#                      ^^ meta.string.glob.shell meta.interpolation.parameter.shell variable.language.special.shell
+#                        ^ meta.string.glob.shell string.unquoted.shell
 
 # Expands to the process ID of the shell. In a () subshell, it expands to the
 # process ID of the invoking shell, not the subshell.
@@ -4013,9 +4013,9 @@ B$(cat)OWL=$(($(cat food.txt | wc -l) + 5))
 #                 ^ keyword.operator.expansion.length.shell
 #                  ^ variable.language.special.shell
 #                   ^ punctuation.section.interpolation.end.shell
-#                     ^ meta.string.shell string.unquoted.shell
-#                      ^^ meta.string.shell meta.interpolation.parameter.shell variable.language.special.shell
-#                        ^ meta.string.shell string.unquoted.shell
+#                     ^ meta.string.glob.shell string.unquoted.shell
+#                      ^^ meta.string.glob.shell meta.interpolation.parameter.shell variable.language.special.shell
+#                        ^ meta.string.glob.shell string.unquoted.shell
 
 # Expands to the process ID of the job most recently placed into the background,
 # whether executed as an asynchronous command or using the bg builtin
@@ -4039,9 +4039,9 @@ B$(cat)OWL=$(($(cat food.txt | wc -l) + 5))
 #                 ^ keyword.operator.expansion.length.shell
 #                  ^ variable.language.special.shell
 #                   ^ punctuation.section.interpolation.end.shell
-#                     ^ meta.string.shell string.unquoted.shell
-#                      ^^ meta.string.shell meta.interpolation.parameter.shell variable.language.special.shell
-#                        ^ meta.string.shell string.unquoted.shell
+#                     ^ meta.string.glob.shell string.unquoted.shell
+#                      ^^ meta.string.glob.shell meta.interpolation.parameter.shell variable.language.special.shell
+#                        ^ meta.string.glob.shell string.unquoted.shell
 
 # Expands to the name of the shell or shell script. This is set at shell
 # initialization. If Bash is invoked with a file of commands (see Shell
@@ -4069,9 +4069,9 @@ B$(cat)OWL=$(($(cat food.txt | wc -l) + 5))
 #                 ^ keyword.operator.expansion.length.shell
 #                  ^ variable.language.positional.shell
 #                   ^ punctuation.section.interpolation.end.shell
-#                     ^ meta.string.shell string.unquoted.shell
-#                      ^^ meta.string.shell meta.interpolation.parameter.shell variable.language.positional.shell
-#                        ^ meta.string.shell string.unquoted.shell
+#                     ^ meta.string.glob.shell string.unquoted.shell
+#                      ^^ meta.string.glob.shell meta.interpolation.parameter.shell variable.language.positional.shell
+#                        ^ meta.string.glob.shell string.unquoted.shell
 
 
 ###############################################################################
@@ -4084,79 +4084,79 @@ B$(cat)OWL=$(($(cat food.txt | wc -l) + 5))
 # followed by an optional postscript.
 
 : prefix{a,b,c}suffix
-# ^^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation
-#       ^ meta.string.shell meta.interpolation.brace.shell punctuation.section.interpolation.begin.shell
-#        ^ meta.string.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell
-#         ^ meta.string.shell meta.interpolation.brace.shell punctuation.separator.sequence.shell
-#          ^ meta.string.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell
-#           ^ meta.string.shell meta.interpolation.brace.shell punctuation.separator.sequence.shell
-#            ^ meta.string.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell
-#             ^ meta.string.shell meta.interpolation.brace.shell punctuation.section.interpolation.end.shell
-#              ^^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation
+# ^^^^^^ meta.string.glob.shell string.unquoted.shell - meta.interpolation
+#       ^ meta.string.glob.shell meta.interpolation.brace.shell punctuation.section.interpolation.begin.shell
+#        ^ meta.string.glob.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell
+#         ^ meta.string.glob.shell meta.interpolation.brace.shell punctuation.separator.sequence.shell
+#          ^ meta.string.glob.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell
+#           ^ meta.string.glob.shell meta.interpolation.brace.shell punctuation.separator.sequence.shell
+#            ^ meta.string.glob.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell
+#             ^ meta.string.glob.shell meta.interpolation.brace.shell punctuation.section.interpolation.end.shell
+#              ^^^^^^ meta.string.glob.shell string.unquoted.shell - meta.interpolation
 
 : 123{4,5,6}789
-# ^^^ meta.string.shell string.unquoted.shell - meta.interpolation
-#    ^^^^^^^ meta.string.shell meta.interpolation.brace.shell
-#           ^^^ meta.string.shell string.unquoted.shell - meta.interpolation
+# ^^^ meta.string.glob.shell string.unquoted.shell - meta.interpolation
+#    ^^^^^^^ meta.string.glob.shell meta.interpolation.brace.shell
+#           ^^^ meta.string.glob.shell string.unquoted.shell - meta.interpolation
 
 : {a,b,~,%,!,.,\,,\{,\},*,?,-1,+2,0," ",' '}
 #^ - meta.interpolation
-# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell meta.interpolation.brace.shell - meta.interpolation.brace meta.interpolation.brace
+# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.glob.shell meta.interpolation.brace.shell - meta.interpolation.brace meta.interpolation.brace
 # ^ punctuation.section.interpolation.begin.shell
-#  ^ meta.string.shell string.unquoted.shell
+#  ^ meta.string.glob.shell string.unquoted.shell
 #   ^ punctuation.separator.sequence.shell
-#    ^ meta.string.shell string.unquoted.shell
+#    ^ meta.string.glob.shell string.unquoted.shell
 #     ^ punctuation.separator.sequence.shell
-#      ^ meta.string.shell string.unquoted.shell - keyword - punctuation - variable
+#      ^ meta.string.glob.shell string.unquoted.shell - keyword - punctuation - variable
 #       ^ punctuation.separator.sequence.shell
-#        ^ meta.string.shell string.unquoted.shell - keyword - punctuation - variable
+#        ^ meta.string.glob.shell string.unquoted.shell - keyword - punctuation - variable
 #         ^ punctuation.separator.sequence.shell
-#          ^ meta.string.shell string.unquoted.shell - keyword - punctuation - variable
+#          ^ meta.string.glob.shell string.unquoted.shell - keyword - punctuation - variable
 #           ^ punctuation.separator.sequence.shell
-#            ^ meta.string.shell string.unquoted.shell - keyword - punctuation - variable
+#            ^ meta.string.glob.shell string.unquoted.shell - keyword - punctuation - variable
 #             ^ punctuation.separator.sequence.shell
-#              ^^ meta.string.shell string.unquoted.shell constant.character.escape.shell
+#              ^^ meta.string.glob.shell string.unquoted.shell constant.character.escape.shell
 #                ^ punctuation.separator.sequence.shell
-#                 ^^ meta.string.shell string.unquoted.shell constant.character.escape.shell
+#                 ^^ meta.string.glob.shell string.unquoted.shell constant.character.escape.shell
 #                   ^ punctuation.separator.sequence.shell
-#                    ^^ meta.string.shell string.unquoted.shell constant.character.escape.shell
+#                    ^^ meta.string.glob.shell string.unquoted.shell constant.character.escape.shell
 #                      ^ punctuation.separator.sequence.shell
-#                       ^ meta.string.shell string.unquoted.shell constant.other.wildcard.asterisk.shell
+#                       ^ meta.string.glob.shell string.unquoted.shell constant.other.wildcard.asterisk.shell
 #                        ^ punctuation.separator.sequence.shell
-#                         ^ meta.string.shell string.unquoted.shell constant.other.wildcard.questionmark.shell
+#                         ^ meta.string.glob.shell string.unquoted.shell constant.other.wildcard.questionmark.shell
 #                          ^ punctuation.separator.sequence.shell
-#                           ^^ meta.string.shell string.unquoted.shell
+#                           ^^ meta.string.glob.shell string.unquoted.shell
 #                             ^ punctuation.separator.sequence.shell
-#                              ^^ meta.string.shell string.unquoted.shell
+#                              ^^ meta.string.glob.shell string.unquoted.shell
 #                                ^ punctuation.separator.sequence.shell
-#                                 ^ meta.string.shell string.unquoted.shell
+#                                 ^ meta.string.glob.shell string.unquoted.shell
 #                                  ^ punctuation.separator.sequence.shell
-#                                   ^^^ meta.string.shell string.quoted.double.shell
+#                                   ^^^ meta.string.glob.shell string.quoted.double.shell
 #                                      ^ punctuation.separator.sequence.shell
-#                                       ^^^ meta.string.shell string.quoted.single.shell
+#                                       ^^^ meta.string.glob.shell string.quoted.single.shell
 #                                          ^ punctuation.section.interpolation.end.shell
 #                                           ^ - meta.interpolation
 
 : {${foo},${bar},$(ls ~),foo${bar}buz,a{a,b,c}d}
-# ^ meta.string.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation
-#  ^^^^^^ meta.string.shell meta.interpolation.brace.shell meta.interpolation.parameter.shell
-#        ^ meta.string.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation
-#         ^^^^^^ meta.string.shell meta.interpolation.brace.shell meta.interpolation.parameter.shell
-#               ^ meta.string.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation
-#                ^^^^^^^ meta.string.shell meta.interpolation.brace.shell meta.interpolation.command.shell
-#                       ^ meta.string.shell meta.interpolation.brace.shell punctuation.separator.sequence.shell
-#                        ^^^ meta.string.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell
-#                           ^^^^^^ meta.string.shell meta.interpolation.brace.shell meta.string.shell meta.interpolation.parameter.shell
-#                                 ^^^ meta.string.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell
-#                                    ^ meta.string.shell meta.interpolation.brace.shell punctuation.separator.sequence.shell
-#                                     ^ meta.string.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell
-#                                      ^^^^^^^ meta.string.shell meta.interpolation.brace.shell meta.string.shell meta.interpolation.brace.shell
+# ^ meta.string.glob.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation
+#  ^^^^^^ meta.string.glob.shell meta.interpolation.brace.shell meta.interpolation.parameter.shell
+#        ^ meta.string.glob.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation
+#         ^^^^^^ meta.string.glob.shell meta.interpolation.brace.shell meta.interpolation.parameter.shell
+#               ^ meta.string.glob.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation
+#                ^^^^^^^ meta.string.glob.shell meta.interpolation.brace.shell meta.interpolation.command.shell
+#                       ^ meta.string.glob.shell meta.interpolation.brace.shell punctuation.separator.sequence.shell
+#                        ^^^ meta.string.glob.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell
+#                           ^^^^^^ meta.string.glob.shell meta.interpolation.brace.shell meta.string.shell meta.interpolation.parameter.shell
+#                                 ^^^ meta.string.glob.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell
+#                                    ^ meta.string.glob.shell meta.interpolation.brace.shell punctuation.separator.sequence.shell
+#                                     ^ meta.string.glob.shell meta.interpolation.brace.shell meta.string.shell string.unquoted.shell
+#                                      ^^^^^^^ meta.string.glob.shell meta.interpolation.brace.shell meta.string.shell meta.interpolation.brace.shell
 #                                      ^ punctuation.section.interpolation.begin.shell
-#                                       ^ meta.string.shell string.unquoted.shell
+#                                       ^ meta.string.glob.shell string.unquoted.shell
 #                                        ^ punctuation.separator.sequence.shell
-#                                         ^ meta.string.shell string.unquoted.shell
+#                                         ^ meta.string.glob.shell string.unquoted.shell
 #                                          ^ punctuation.separator.sequence.shell
-#                                           ^ meta.string.shell string.unquoted.shell
+#                                           ^ meta.string.glob.shell string.unquoted.shell
 #                                            ^ punctuation.section.interpolation.end.shell
 #                                             ^ meta.interpolation.brace.shell meta.string.shell string.unquoted.shell
 #                                              ^ meta.interpolation.brace.shell - meta.interpolation meta.interpolation
@@ -4177,13 +4177,13 @@ bar,baz}
 #        ^ punctuation.section.interpolation.end.shell
 
 : {{foo,{bar,baz},foo},bar,{1..10}}
-# ^ meta.string.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation
-#  ^^^^^ meta.string.shell meta.interpolation.brace.shell meta.string.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation meta.interpolation
-#       ^^^^^^^^^ meta.string.shell meta.interpolation.brace.shell meta.string.shell meta.interpolation.brace.shell meta.string.shell meta.interpolation.brace.shell
-#                ^^^^^ meta.string.shell meta.interpolation.brace.shell meta.string.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation meta.interpolation
-#                     ^^^^^ meta.string.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation
-#                          ^^^^^^^ meta.string.shell meta.interpolation.brace.shell meta.string.shell meta.interpolation.brace.shell
-#                                 ^ meta.string.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation
+# ^ meta.string.glob.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation
+#  ^^^^^ meta.string.glob.shell meta.interpolation.brace.shell meta.string.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation meta.interpolation
+#       ^^^^^^^^^ meta.string.glob.shell meta.interpolation.brace.shell meta.string.shell meta.interpolation.brace.shell meta.string.shell meta.interpolation.brace.shell
+#                ^^^^^ meta.string.glob.shell meta.interpolation.brace.shell meta.string.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation meta.interpolation
+#                     ^^^^^ meta.string.glob.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation
+#                          ^^^^^^^ meta.string.glob.shell meta.interpolation.brace.shell meta.string.shell meta.interpolation.brace.shell
+#                                 ^ meta.string.glob.shell meta.interpolation.brace.shell - meta.interpolation meta.interpolation
 #                                  ^ - meta.string - meta.interpolation
 # ^^ punctuation.section.interpolation.begin.shell
 #   ^^^ string.unquoted.shell
@@ -4349,25 +4349,25 @@ any --arg{1..4}={1..4}
 #   ^^^^^ meta.parameter.option.shell variable.parameter.option.shell - meta.interpolation
 #        ^^^^^^ meta.function-call.arguments.shell meta.parameter.option.shell meta.interpolation.brace.shell - variable.parameter
 #              ^ keyword.operator.assignment.shell
-#               ^^^^^^ meta.string.shell meta.interpolation.brace.shell
+#               ^^^^^^ meta.string.glob.shell meta.interpolation.brace.shell
 
 any --arg{1..4} ={1..4}
 #   ^^^^^ meta.parameter.option.shell variable.parameter.option.shell - meta.interpolation
 #        ^^^^^^ meta.function-call.arguments.shell meta.parameter.option.shell meta.interpolation.brace.shell - variable.parameter
-#               ^ meta.string.shell string.unquoted.shell - meta.interpolation
-#                ^^^^^^ meta.string.shell meta.interpolation.brace.shell
+#               ^ meta.string.glob.shell string.unquoted.shell - meta.interpolation
+#                ^^^^^^ meta.string.glob.shell meta.interpolation.brace.shell
 
 any --arg{1,2,3}={1,2,3}
 #   ^^^^^ meta.parameter.option.shell variable.parameter.option.shell - meta.interpolation
 #        ^^^^^^^ meta.function-call.arguments.shell meta.parameter.option.shell meta.interpolation.brace.shell - variable.parameter
 #               ^ keyword.operator.assignment.shell
-#                ^^^^^^^ meta.string.shell meta.interpolation.brace.shell
+#                ^^^^^^^ meta.string.glob.shell meta.interpolation.brace.shell
 
 any --arg{1,2,3} ={1,2,3}
 #   ^^^^^ meta.parameter.option.shell variable.parameter.option.shell - meta.interpolation
 #        ^^^^^^^ meta.function-call.arguments.shell meta.parameter.option.shell meta.interpolation.brace.shell - variable.parameter
-#                ^ meta.string.shell string.unquoted.shell - meta.interpolation
-#                 ^^^^^^^ meta.string.shell meta.interpolation.brace.shell
+#                ^ meta.string.glob.shell string.unquoted.shell - meta.interpolation
+#                 ^^^^^^^ meta.string.glob.shell meta.interpolation.brace.shell
 
 # invalid brace expansions due to whitespace
 
@@ -4389,12 +4389,12 @@ any --arg{1,2,3} ={1,2,3}
 #^^^^^^^^^^ - meta.interpolation
 
 : '{foo,bar,baz}' '{1..10}'
-# ^^^^^^^^^^^^^^^ meta.string.shell string.quoted.single.shell - meta.interpolation
-#                 ^^^^^^^^^ meta.string.shell string.quoted.single.shell - meta.interpolation
+# ^^^^^^^^^^^^^^^ meta.string.glob.shell string.quoted.single.shell - meta.interpolation
+#                 ^^^^^^^^^ meta.string.glob.shell string.quoted.single.shell - meta.interpolation
 
 : "{foo,bar,baz}" "{1..10}"
-# ^^^^^^^^^^^^^^^ meta.string.shell string.quoted.double.shell - meta.interpolation
-#                 ^^^^^^^^^ meta.string.shell string.quoted.double.shell - meta.interpolation
+# ^^^^^^^^^^^^^^^ meta.string.glob.shell string.quoted.double.shell - meta.interpolation
+#                 ^^^^^^^^^ meta.string.glob.shell string.quoted.double.shell - meta.interpolation
 
 
 ###############################################################################
@@ -4497,9 +4497,9 @@ foo=~/~
 #    ^^ string.unquoted.shell - variable
 
 foo=~/~${bar}
-#   ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
-#    ^^ meta.string.shell string.unquoted.shell - meta.interpolation
-#      ^^^^^^ meta.string.shell meta.interpolation.parameter.shell - string
+#   ^ meta.string.glob.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
+#    ^^ meta.string.glob.shell string.unquoted.shell - meta.interpolation
+#      ^^^^^^ meta.string.glob.shell meta.interpolation.parameter.shell - string
 #            ^ - meta.string - meta.interpolation
 #   ^ variable.language.tilde.shell
 #    ^^ string.unquoted.shell
@@ -4511,38 +4511,38 @@ foo=~/~${bar}
 
 foo=(~/~foo ~/~bar)
 #   ^^^^^^^^^^^^^^^ meta.sequence.list.shell
-#    ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
-#     ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation - variable
-#           ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
-#            ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation - variable
+#    ^ meta.string.glob.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
+#     ^^^^^ meta.string.glob.shell string.unquoted.shell - meta.interpolation - variable
+#           ^ meta.string.glob.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
+#            ^^^^^ meta.string.glob.shell string.unquoted.shell - meta.interpolation - variable
 
 cmd --foo=~/~bar --baz =~/~buz
 #        ^ keyword.operator.assignment.shell
-#         ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
-#          ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation - variable
-#                      ^^^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation - keyword - variable
+#         ^ meta.string.glob.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
+#          ^^^^^ meta.string.glob.shell string.unquoted.shell - meta.interpolation - variable
+#                      ^^^^^^^ meta.string.glob.shell string.unquoted.shell - meta.interpolation - keyword - variable
 
 cmd ~/f~oo b~ar -- ~/f~oo b~ar
-#   ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
-#    ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation - variable
-#          ^^^^ meta.string.shell string.unquoted.shell - meta.interpolation - variable
+#   ^ meta.string.glob.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
+#    ^^^^^ meta.string.glob.shell string.unquoted.shell - meta.interpolation - variable
+#          ^^^^ meta.string.glob.shell string.unquoted.shell - meta.interpolation - variable
 #               ^^ keyword.operator.end-of-options.shell
-#                  ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
-#                   ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation - variable
-#                         ^^^^ meta.string.shell string.unquoted.shell - meta.interpolation - variable
+#                  ^ meta.string.glob.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
+#                   ^^^^^ meta.string.glob.shell string.unquoted.shell - meta.interpolation - variable
+#                         ^^^^ meta.string.glob.shell string.unquoted.shell - meta.interpolation - variable
 
 echo ~/~foo ~/~foo  # tilde expansions, but no path pattern support
-#    ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
-#     ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation - variable
-#           ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
-#            ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation - variable
+#    ^ meta.string.glob.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
+#     ^^^^^ meta.string.glob.shell string.unquoted.shell - meta.interpolation - variable
+#           ^ meta.string.glob.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
+#            ^^^^^ meta.string.glob.shell string.unquoted.shell - meta.interpolation - variable
 
 echo "~/~foo" # literal quoted string
-#    ^^^^^^^^ meta.function-call.arguments.shell meta.string.shell string.quoted.double.shell - meta.interpolation - variable
+#    ^^^^^^^^ meta.function-call.arguments.shell meta.string.glob.shell string.quoted.double.shell - meta.interpolation - variable
 
 test $me -eq ~/~foo
-#            ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell
-#             ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation - variable
+#            ^ meta.string.glob.shell meta.interpolation.tilde.shell variable.language.tilde.shell
+#             ^^^^^ meta.string.glob.shell string.unquoted.shell - meta.interpolation - variable
 
 ~/.bin/~app
 # <- meta.function-call.identifier.shell meta.interpolation.tilde.shell variable.language.tilde.shell - variable.function
@@ -4569,7 +4569,7 @@ $__ $__
 # <- meta.function-call.identifier.shell meta.command.shell meta.interpolation.parameter.shell variable.other.readwrite.shell punctuation.definition.variable.shell
 #^^ meta.function-call.identifier.shell meta.command.shell meta.interpolation.parameter.shell variable.other.readwrite.shell - variable variable
 #  ^ meta.function-call.arguments.shell - meta.string - meta.interpolation - variable
-#   ^^^ meta.function-call.arguments.shell meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell
+#   ^^^ meta.function-call.arguments.shell meta.string.glob.shell meta.interpolation.parameter.shell variable.other.readwrite.shell
 #   ^ punctuation.definition.variable.shell
 #      ^ - meta.function-call - meta.string - meta.interpolation - variable
 
@@ -4577,7 +4577,7 @@ $var_0 $var_0
 # <- meta.function-call.identifier.shell meta.command.shell meta.interpolation.parameter.shell variable.other.readwrite.shell punctuation.definition.variable.shell
 #^^^^^ meta.function-call.identifier.shell meta.command.shell meta.interpolation.parameter.shell variable.other.readwrite.shell - variable variable
 #     ^ meta.function-call.arguments.shell - meta.string - meta.interpolation - variable
-#      ^^^^^^ meta.function-call.arguments.shell meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell
+#      ^^^^^^ meta.function-call.arguments.shell meta.string.glob.shell meta.interpolation.parameter.shell variable.other.readwrite.shell
 #      ^ punctuation.definition.variable.shell
 #            ^ - meta.function-call - meta.string - meta.interpolation - variable
 
@@ -4585,7 +4585,7 @@ $_var0 $_var0
 # <- meta.function-call.identifier.shell meta.command.shell meta.interpolation.parameter.shell variable.other.readwrite.shell punctuation.definition.variable.shell
 #^^^^^ meta.function-call.identifier.shell meta.command.shell meta.interpolation.parameter.shell variable.other.readwrite.shell - variable variable
 #     ^ meta.function-call.arguments.shell - meta.string - meta.interpolation - variable
-#      ^^^^^^ meta.function-call.arguments.shell meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell
+#      ^^^^^^ meta.function-call.arguments.shell meta.string.glob.shell meta.interpolation.parameter.shell variable.other.readwrite.shell
 #      ^ punctuation.definition.variable.shell
 #            ^ - meta.function-call - meta.string - meta.interpolation - variable
 
@@ -4593,7 +4593,7 @@ $_0var_ $_0var_
 # <- meta.function-call.identifier.shell meta.command.shell meta.interpolation.parameter.shell variable.other.readwrite.shell punctuation.definition.variable.shell
 #^^^^^^ meta.function-call.identifier.shell meta.command.shell meta.interpolation.parameter.shell variable.other.readwrite.shell - variable variable
 #      ^ meta.function-call.arguments.shell - meta.string - meta.interpolation - variable
-#       ^^^^^^^ meta.function-call.arguments.shell meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell
+#       ^^^^^^^ meta.function-call.arguments.shell meta.string.glob.shell meta.interpolation.parameter.shell variable.other.readwrite.shell
 #       ^ punctuation.definition.variable.shell
 #              ^ - meta.function-call - meta.string - meta.interpolation - variable
 
@@ -4853,7 +4853,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.section.interpolation.end.shell
 
 : ${*-bar}
@@ -4863,7 +4863,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.section.interpolation.end.shell
 
 : ${?-bar}
@@ -4873,7 +4873,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.section.interpolation.end.shell
 
 : ${#-bar}
@@ -4883,7 +4883,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.section.interpolation.end.shell
 
 : ${$-bar}
@@ -4893,7 +4893,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.section.interpolation.end.shell
 
 : ${--bar}
@@ -4903,7 +4903,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.section.interpolation.end.shell
 
 : ${!-bar}
@@ -4913,7 +4913,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.section.interpolation.end.shell
 
 : ${_-bar}
@@ -4923,7 +4923,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.builtin.shell
 #    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.section.interpolation.end.shell
 
 : ${foo-bar}
@@ -4933,32 +4933,32 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^^^ variable.other.readwrite.shell
 #      ^ keyword.operator.assignment.shell
-#       ^^^ meta.string.shell string.unquoted.shell
+#       ^^^ meta.string.glob.shell string.unquoted.shell
 #          ^ punctuation.section.interpolation.end.shell
 
 : ${foo-~+/*bar}
 # ^^^^^^^^^^^^^^ meta.interpolation.parameter.shell
 #      ^ keyword.operator.assignment.shell
-#       ^^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
-#         ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation.tilde
+#       ^^ meta.string.glob.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
+#         ^^^^^ meta.string.glob.shell string.unquoted.shell - meta.interpolation.tilde
 #          ^ constant.other.wildcard.asterisk.shell
 #              ^ punctuation.section.interpolation.end.shell
 
 : ${foo-m~+/*bar}
 # ^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell
 #      ^ keyword.operator.assignment.shell
-#       ^^^^^^^^ meta.string.shell string.unquoted.shell
+#       ^^^^^^^^ meta.string.glob.shell string.unquoted.shell
 #        ^^ - constant - variable
 #           ^ constant.other.wildcard.asterisk.shell
 
 : ${foo-~u${se}r/*bar}
 # ^^^^^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell
 #      ^ keyword.operator.assignment.shell
-#       ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
-#        ^ meta.string.shell meta.interpolation.tilde.shell constant.other.username.shell - string string
-#         ^^^^^ meta.string.shell meta.interpolation.tilde.shell meta.interpolation.parameter.shell - string
-#              ^ meta.string.shell meta.interpolation.tilde.shell constant.other.username.shell - string string
-#               ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation.tilde
+#       ^ meta.string.glob.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
+#        ^ meta.string.glob.shell meta.interpolation.tilde.shell constant.other.username.shell - string string
+#         ^^^^^ meta.string.glob.shell meta.interpolation.tilde.shell meta.interpolation.parameter.shell - string
+#              ^ meta.string.glob.shell meta.interpolation.tilde.shell constant.other.username.shell - string string
+#               ^^^^^ meta.string.glob.shell string.unquoted.shell - meta.interpolation.tilde
 #                ^ constant.other.wildcard.asterisk.shell
 #                    ^ punctuation.section.interpolation.end.shell
 
@@ -4971,7 +4971,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^^ keyword.operator.assignment.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 : ${*:-bar}
@@ -4981,7 +4981,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^^ keyword.operator.assignment.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 : ${?:-bar}
@@ -4991,7 +4991,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^^ keyword.operator.assignment.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 : ${#:-bar}
@@ -5001,7 +5001,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^^ keyword.operator.assignment.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 : ${$:-bar}
@@ -5011,7 +5011,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^^ keyword.operator.assignment.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 : ${-:-bar}
@@ -5021,7 +5021,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^^ keyword.operator.assignment.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 : ${!:-bar}
@@ -5031,7 +5031,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^^ keyword.operator.assignment.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 : ${_:-bar}
@@ -5041,7 +5041,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.builtin.shell
 #    ^^ keyword.operator.assignment.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 : ${foo:-bar}
@@ -5051,32 +5051,32 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^^^ variable.other.readwrite.shell
 #      ^^ keyword.operator.assignment.shell
-#        ^^^ meta.string.shell string.unquoted.shell
+#        ^^^ meta.string.glob.shell string.unquoted.shell
 #           ^ punctuation.section.interpolation.end.shell
 
 : ${foo:-~+/*bar}
 # ^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell
 #      ^^ keyword.operator.assignment.shell
-#        ^^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
-#          ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation.tilde
+#        ^^ meta.string.glob.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
+#          ^^^^^ meta.string.glob.shell string.unquoted.shell - meta.interpolation.tilde
 #           ^ constant.other.wildcard.asterisk.shell
 #               ^ punctuation.section.interpolation.end.shell
 
 : ${foo:-m~+/*bar}
 # ^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell
 #      ^^ keyword.operator.assignment.shell
-#        ^^^^^^^^ meta.string.shell string.unquoted.shell
+#        ^^^^^^^^ meta.string.glob.shell string.unquoted.shell
 #         ^^ - constant - variable
 #            ^ constant.other.wildcard.asterisk.shell
 
 : ${foo:-~u${se}r/*bar}
 # ^^^^^^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell
 #      ^^ keyword.operator.assignment.shell
-#        ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
-#         ^ meta.string.shell meta.interpolation.tilde.shell constant.other.username.shell - string string
-#          ^^^^^ meta.string.shell meta.interpolation.tilde.shell meta.interpolation.parameter.shell - string
-#               ^ meta.string.shell meta.interpolation.tilde.shell constant.other.username.shell - string string
-#                ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation.tilde
+#        ^ meta.string.glob.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
+#         ^ meta.string.glob.shell meta.interpolation.tilde.shell constant.other.username.shell - string string
+#          ^^^^^ meta.string.glob.shell meta.interpolation.tilde.shell meta.interpolation.parameter.shell - string
+#               ^ meta.string.glob.shell meta.interpolation.tilde.shell constant.other.username.shell - string string
+#                ^^^^^ meta.string.glob.shell string.unquoted.shell - meta.interpolation.tilde
 #                 ^ constant.other.wildcard.asterisk.shell
 #                     ^ punctuation.section.interpolation.end.shell
 
@@ -5093,7 +5093,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.section.interpolation.end.shell
 
 : ${*=bar}
@@ -5103,7 +5103,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.section.interpolation.end.shell
 
 : ${#=bar}
@@ -5113,7 +5113,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.section.interpolation.end.shell
 
 : ${?=bar}
@@ -5123,7 +5123,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.section.interpolation.end.shell
 
 : ${$=bar}
@@ -5133,7 +5133,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.section.interpolation.end.shell
 
 : ${-=bar}
@@ -5143,7 +5143,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.section.interpolation.end.shell
 
 : ${!=bar}
@@ -5153,7 +5153,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.section.interpolation.end.shell
 
 : ${_=bar}
@@ -5163,7 +5163,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.builtin.shell
 #    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.section.interpolation.end.shell
 
 : ${foo=bar}
@@ -5173,21 +5173,21 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^^^ variable.other.readwrite.shell
 #      ^ keyword.operator.assignment.shell
-#       ^^^ meta.string.shell string.unquoted.shell
+#       ^^^ meta.string.glob.shell string.unquoted.shell
 #          ^ punctuation.section.interpolation.end.shell
 
 : ${foo=~+/*bar}
 # ^^^^^^^^^^^^^^ meta.interpolation.parameter.shell
 #      ^ keyword.operator.assignment.shell
-#       ^^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
-#         ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation.tilde
+#       ^^ meta.string.glob.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
+#         ^^^^^ meta.string.glob.shell string.unquoted.shell - meta.interpolation.tilde
 #          ^ constant.other.wildcard.asterisk.shell
 #              ^ punctuation.section.interpolation.end.shell
 
 : ${foo=m~+/*bar}
 # ^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell
 #      ^ keyword.operator.assignment.shell
-#       ^^^^^^^^ meta.string.shell string.unquoted.shell
+#       ^^^^^^^^ meta.string.glob.shell string.unquoted.shell
 #        ^^ - constant - variable
 #           ^ constant.other.wildcard.asterisk.shell
 
@@ -5200,7 +5200,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^^ keyword.operator.assignment.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 : ${*:=bar}
@@ -5210,7 +5210,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^^ keyword.operator.assignment.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 : ${#:=bar}
@@ -5220,7 +5220,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^^ keyword.operator.assignment.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 : ${?:=bar}
@@ -5230,7 +5230,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^^ keyword.operator.assignment.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 : ${$:=bar}
@@ -5240,7 +5240,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^^ keyword.operator.assignment.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 : ${-:=bar}
@@ -5250,7 +5250,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^^ keyword.operator.assignment.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 : ${!:=bar}
@@ -5260,7 +5260,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^^ keyword.operator.assignment.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 : ${_:=bar}
@@ -5270,7 +5270,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.builtin.shell
 #    ^^ keyword.operator.assignment.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 : ${foo:=bar}
@@ -5280,21 +5280,21 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^^^ variable.other.readwrite.shell
 #      ^^ keyword.operator.assignment.shell
-#        ^^^ meta.string.shell string.unquoted.shell
+#        ^^^ meta.string.glob.shell string.unquoted.shell
 #           ^ punctuation.section.interpolation.end.shell
 
 : ${foo:=~+/*bar}
 # ^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell
 #      ^^ keyword.operator.assignment.shell
-#        ^^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
-#          ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation.tilde
+#        ^^ meta.string.glob.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
+#          ^^^^^ meta.string.glob.shell string.unquoted.shell - meta.interpolation.tilde
 #           ^ constant.other.wildcard.asterisk.shell
 #               ^ punctuation.section.interpolation.end.shell
 
 : ${foo:=m~+/*bar}
 # ^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell
 #      ^^ keyword.operator.assignment.shell
-#        ^^^^^^^^ meta.string.shell string.unquoted.shell
+#        ^^^^^^^^ meta.string.glob.shell string.unquoted.shell
 #         ^^ - constant - variable
 #            ^ constant.other.wildcard.asterisk.shell
 
@@ -5312,7 +5312,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.section.interpolation.end.shell
 
 : ${*?bar}
@@ -5322,7 +5322,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.section.interpolation.end.shell
 
 : ${#?bar}
@@ -5332,7 +5332,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.section.interpolation.end.shell
 
 : ${??bar}
@@ -5342,7 +5342,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.section.interpolation.end.shell
 
 : ${$?bar}
@@ -5352,7 +5352,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.section.interpolation.end.shell
 
 : ${-?bar}
@@ -5362,7 +5362,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.section.interpolation.end.shell
 
 : ${!?bar}
@@ -5372,7 +5372,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.section.interpolation.end.shell
 
 : ${_?bar}
@@ -5382,7 +5382,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.builtin.shell
 #    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.section.interpolation.end.shell
 
 : ${foo?bar}
@@ -5392,21 +5392,21 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^^^ variable.other.readwrite.shell
 #      ^ keyword.operator.assignment.shell
-#       ^^^ meta.string.shell string.unquoted.shell
+#       ^^^ meta.string.glob.shell string.unquoted.shell
 #          ^ punctuation.section.interpolation.end.shell
 
 : ${foo?~+/?bar}
 # ^^^^^^^^^^^^^^ meta.interpolation.parameter.shell
 #      ^ keyword.operator.assignment.shell
-#       ^^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
-#         ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation.tilde
+#       ^^ meta.string.glob.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
+#         ^^^^^ meta.string.glob.shell string.unquoted.shell - meta.interpolation.tilde
 #          ^ constant.other.wildcard.questionmark.shell
 #              ^ punctuation.section.interpolation.end.shell
 
 : ${foo?m~+/?bar}
 # ^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell
 #      ^ keyword.operator.assignment.shell
-#       ^^^^^^^^ meta.string.shell string.unquoted.shell
+#       ^^^^^^^^ meta.string.glob.shell string.unquoted.shell
 #        ^^ - constant - variable
 #           ^ constant.other.wildcard.questionmark.shell
 
@@ -5419,7 +5419,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^^ keyword.operator.assignment.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 : ${*:?bar}
@@ -5429,7 +5429,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^^ keyword.operator.assignment.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 : ${#:?bar}
@@ -5439,7 +5439,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^^ keyword.operator.assignment.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 : ${?:?bar}
@@ -5449,7 +5449,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^^ keyword.operator.assignment.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 : ${$:?bar}
@@ -5459,7 +5459,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^^ keyword.operator.assignment.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 : ${-:?bar}
@@ -5469,7 +5469,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^^ keyword.operator.assignment.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 : ${!:?bar}
@@ -5479,7 +5479,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^^ keyword.operator.assignment.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 : ${_:?bar}
@@ -5489,7 +5489,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.builtin.shell
 #    ^^ keyword.operator.assignment.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 : ${foo:?bar}
@@ -5499,21 +5499,21 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^^^ variable.other.readwrite.shell
 #      ^^ keyword.operator.assignment.shell
-#        ^^^ meta.string.shell string.unquoted.shell
+#        ^^^ meta.string.glob.shell string.unquoted.shell
 #           ^ punctuation.section.interpolation.end.shell
 
 : ${foo:?~+/*bar}
 # ^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell
 #      ^^ keyword.operator.assignment.shell
-#        ^^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
-#          ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation.tilde
+#        ^^ meta.string.glob.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
+#          ^^^^^ meta.string.glob.shell string.unquoted.shell - meta.interpolation.tilde
 #           ^ constant.other.wildcard.asterisk.shell
 #               ^ punctuation.section.interpolation.end.shell
 
 : ${foo:?m~+/*bar}
 # ^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell
 #      ^^ keyword.operator.assignment.shell
-#        ^^^^^^^^ meta.string.shell string.unquoted.shell
+#        ^^^^^^^^ meta.string.glob.shell string.unquoted.shell
 #         ^^ - constant - variable
 #            ^ constant.other.wildcard.asterisk.shell
 
@@ -5529,7 +5529,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.section.interpolation.end.shell
 
 : ${*+bar}
@@ -5539,7 +5539,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.section.interpolation.end.shell
 
 : ${#+bar}
@@ -5549,7 +5549,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.section.interpolation.end.shell
 
 : ${?+bar}
@@ -5559,7 +5559,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.section.interpolation.end.shell
 
 : ${$+bar}
@@ -5569,7 +5569,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.section.interpolation.end.shell
 
 : ${-+bar}
@@ -5579,7 +5579,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.section.interpolation.end.shell
 
 : ${!+bar}
@@ -5589,7 +5589,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.section.interpolation.end.shell
 
 : ${_+bar}
@@ -5599,7 +5599,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.builtin.shell
 #    ^ keyword.operator.assignment.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.section.interpolation.end.shell
 
 : ${foo+bar}
@@ -5609,21 +5609,21 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^^^ variable.other.readwrite.shell
 #      ^ keyword.operator.assignment.shell
-#       ^^^ meta.string.shell string.unquoted.shell
+#       ^^^ meta.string.glob.shell string.unquoted.shell
 #          ^ punctuation.section.interpolation.end.shell
 
 : ${foo+~+/*bar}
 # ^^^^^^^^^^^^^^ meta.interpolation.parameter.shell
 #      ^ keyword.operator.assignment.shell
-#       ^^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
-#         ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation.tilde
+#       ^^ meta.string.glob.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
+#         ^^^^^ meta.string.glob.shell string.unquoted.shell - meta.interpolation.tilde
 #          ^ constant.other.wildcard.asterisk.shell
 #              ^ punctuation.section.interpolation.end.shell
 
 : ${foo+m~+/*bar}
 # ^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell
 #      ^ keyword.operator.assignment.shell
-#       ^^^^^^^^ meta.string.shell string.unquoted.shell
+#       ^^^^^^^^ meta.string.glob.shell string.unquoted.shell
 #        ^^ - constant - variable
 #           ^ constant.other.wildcard.asterisk.shell
 
@@ -5636,7 +5636,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^^ keyword.operator.assignment.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 : ${*:+bar}
@@ -5646,7 +5646,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^^ keyword.operator.assignment.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 : ${#:+bar}
@@ -5656,7 +5656,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^^ keyword.operator.assignment.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 : ${?:+bar}
@@ -5666,7 +5666,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^^ keyword.operator.assignment.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 : ${$:+bar}
@@ -5676,7 +5676,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^^ keyword.operator.assignment.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 : ${-:+bar}
@@ -5686,7 +5686,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^^ keyword.operator.assignment.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 : ${!:+bar}
@@ -5696,7 +5696,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.special.shell
 #    ^^ keyword.operator.assignment.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 : ${_:+bar}
@@ -5706,7 +5706,7 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^ variable.language.builtin.shell
 #    ^^ keyword.operator.assignment.shell
-#      ^^^ meta.string.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
 #         ^ punctuation.section.interpolation.end.shell
 
 : ${foo:+bar}
@@ -5716,21 +5716,21 @@ foo}
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^^^ variable.other.readwrite.shell
 #      ^^ keyword.operator.assignment.shell
-#        ^^^ meta.string.shell string.unquoted.shell
+#        ^^^ meta.string.glob.shell string.unquoted.shell
 #           ^ punctuation.section.interpolation.end.shell
 
 : ${foo:+~+/*bar}
 # ^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell
 #      ^^ keyword.operator.assignment.shell
-#        ^^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
-#          ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation.tilde
+#        ^^ meta.string.glob.shell meta.interpolation.tilde.shell variable.language.tilde.shell - string
+#          ^^^^^ meta.string.glob.shell string.unquoted.shell - meta.interpolation.tilde
 #           ^ constant.other.wildcard.asterisk.shell
 #               ^ punctuation.section.interpolation.end.shell
 
 : ${foo:+m~+/*bar}
 # ^^^^^^^^^^^^^^^^ meta.interpolation.parameter.shell
 #      ^^ keyword.operator.assignment.shell
-#        ^^^^^^^^ meta.string.shell string.unquoted.shell
+#        ^^^^^^^^ meta.string.glob.shell string.unquoted.shell
 #         ^^ - constant - variable
 #            ^ constant.other.wildcard.asterisk.shell
 
@@ -5900,7 +5900,7 @@ foo}
 #    ^ keyword.operator.substitution.shell
 #     ^^^ meta.string.regexp.shell
 #        ^ keyword.operator.substitution.shell
-#         ^^^ meta.string.shell string.unquoted.shell
+#         ^^^ meta.string.glob.shell string.unquoted.shell
 #            ^ punctuation.section.interpolation.end.shell
 #             ^ - meta
 
@@ -5912,7 +5912,7 @@ foo}
 #    ^ keyword.operator.substitution.shell
 #     ^^^ meta.string.regexp.shell
 #        ^ keyword.operator.substitution.shell
-#         ^^^ meta.string.shell string.unquoted.shell
+#         ^^^ meta.string.glob.shell string.unquoted.shell
 #            ^ punctuation.section.interpolation.end.shell
 #             ^ - meta
 
@@ -5924,7 +5924,7 @@ foo}
 #    ^ keyword.operator.substitution.shell
 #     ^^^ meta.string.regexp.shell
 #        ^ keyword.operator.substitution.shell
-#         ^^^ meta.string.shell string.unquoted.shell
+#         ^^^ meta.string.glob.shell string.unquoted.shell
 #            ^ punctuation.section.interpolation.end.shell
 #             ^ - meta
 
@@ -5936,7 +5936,7 @@ foo}
 #    ^ keyword.operator.substitution.shell
 #     ^^^ meta.string.regexp.shell
 #        ^ keyword.operator.substitution.shell
-#         ^^^ meta.string.shell string.unquoted.shell
+#         ^^^ meta.string.glob.shell string.unquoted.shell
 #            ^ punctuation.section.interpolation.end.shell
 #             ^ - meta
 
@@ -5948,7 +5948,7 @@ foo}
 #    ^ keyword.operator.substitution.shell
 #     ^^^ meta.string.regexp.shell
 #        ^ keyword.operator.substitution.shell
-#         ^^^ meta.string.shell string.unquoted.shell
+#         ^^^ meta.string.glob.shell string.unquoted.shell
 #            ^ punctuation.section.interpolation.end.shell
 #             ^ - meta
 
@@ -5960,7 +5960,7 @@ foo}
 #    ^ keyword.operator.substitution.shell
 #     ^^^ meta.string.regexp.shell
 #        ^ keyword.operator.substitution.shell
-#         ^^^ meta.string.shell string.unquoted.shell
+#         ^^^ meta.string.glob.shell string.unquoted.shell
 #            ^ punctuation.section.interpolation.end.shell
 #             ^ - meta
 
@@ -5972,7 +5972,7 @@ foo}
 #    ^ keyword.operator.substitution.shell
 #     ^^^ meta.string.regexp.shell
 #        ^ keyword.operator.substitution.shell
-#         ^^^ meta.string.shell string.unquoted.shell
+#         ^^^ meta.string.glob.shell string.unquoted.shell
 #            ^ punctuation.section.interpolation.end.shell
 #             ^ - meta
 
@@ -5984,7 +5984,7 @@ foo}
 #    ^ keyword.operator.substitution.shell
 #     ^^^ meta.string.regexp.shell
 #        ^ keyword.operator.substitution.shell
-#         ^^^ meta.string.shell string.unquoted.shell
+#         ^^^ meta.string.glob.shell string.unquoted.shell
 #            ^ punctuation.section.interpolation.end.shell
 #             ^ - meta
 
@@ -5996,7 +5996,7 @@ foo}
 #      ^ keyword.operator.substitution.shell
 #       ^^^ meta.string.regexp.shell
 #          ^ keyword.operator.substitution.shell
-#           ^^^ meta.string.shell string.unquoted.shell
+#           ^^^ meta.string.glob.shell string.unquoted.shell
 #              ^ punctuation.section.interpolation.end.shell
 #               ^ - meta
 
@@ -6009,7 +6009,7 @@ foo}
 #       ^ keyword.operator.substitution.shell
 #        ^^^ meta.string.regexp.shell
 #           ^ keyword.operator.substitution.shell
-#            ^^^ meta.string.shell string.unquoted.shell
+#            ^^^ meta.string.glob.shell string.unquoted.shell
 #               ^ punctuation.section.interpolation.end.shell
 #                ^ - meta
 
@@ -6022,7 +6022,7 @@ foo}
 #       ^ keyword.operator.substitution.shell
 #        ^^^ meta.string.regexp.shell
 #           ^ keyword.operator.substitution.shell
-#            ^^^ meta.string.shell string.unquoted.shell
+#            ^^^ meta.string.glob.shell string.unquoted.shell
 #               ^ punctuation.section.interpolation.end.shell
 #                ^ - meta
 
@@ -6037,7 +6037,7 @@ foo}
 #         ^ keyword.operator.substitution.shell
 #          ^^^ meta.string.regexp.shell
 #             ^ keyword.operator.substitution.shell
-#              ^^^ meta.string.shell string.unquoted.shell
+#              ^^^ meta.string.glob.shell string.unquoted.shell
 #                 ^ punctuation.section.interpolation.end.shell
 #                  ^ - meta
 
@@ -6052,7 +6052,7 @@ foo}
 #         ^ keyword.operator.substitution.shell
 #          ^^^ meta.string.regexp.shell
 #             ^ keyword.operator.substitution.shell
-#              ^^^ meta.string.shell string.unquoted.shell
+#              ^^^ meta.string.glob.shell string.unquoted.shell
 #                 ^ punctuation.section.interpolation.end.shell
 #                  ^ - meta
 
@@ -6301,7 +6301,7 @@ a\/b/c/d}
 #      ^^ keyword.operator.substitution.shell
 #        ^^^ meta.string.regexp.shell string.unquoted.shell - keyword - punctuation
 #           ^ keyword.operator.substitution.shell
-#            ^^^^ meta.string.shell string.unquoted.shell - keyword - punctuation
+#            ^^^^ meta.string.glob.shell string.unquoted.shell - keyword - punctuation
 #                ^ punctuation.section.interpolation.end.shell
 
 : ${var//f&o/b&ar}  # `&` has no meaing in patterns or replacement strings
@@ -6309,7 +6309,7 @@ a\/b/c/d}
 #      ^^ keyword.operator.substitution.shell
 #        ^^^ meta.string.regexp.shell string.unquoted.shell - keyword - punctuation
 #           ^ keyword.operator.substitution.shell
-#            ^^^^ meta.string.shell string.unquoted.shell - keyword - punctuation
+#            ^^^^ meta.string.glob.shell string.unquoted.shell - keyword - punctuation
 #                ^ punctuation.section.interpolation.end.shell
 
 : ${var//f>o/b>ar}  # `>` has no meaing in patterns or replacement strings
@@ -6317,7 +6317,7 @@ a\/b/c/d}
 #      ^^ keyword.operator.substitution.shell
 #        ^^^ meta.string.regexp.shell string.unquoted.shell - keyword - punctuation
 #           ^ keyword.operator.substitution.shell
-#            ^^^^ meta.string.shell string.unquoted.shell - keyword - punctuation
+#            ^^^^ meta.string.glob.shell string.unquoted.shell - keyword - punctuation
 #                ^ punctuation.section.interpolation.end.shell
 
 : ${var//f word
 # ^^^^^^^ meta.redirection.shell
 # ^^ keyword.operator.assignment.redirection.shell
-#    ^^^^ meta.string.shell string.unquoted.shell
+#    ^^^^ meta.string.glob.shell string.unquoted.shell
 
 # Open file word for writing as standard output. If the file does not exist
 # then it is created.
@@ -9443,15 +9443,15 @@ echo '([^.[:space:]]+)   Class::method()' # colon not scoped as path separator
 : > word >| word >! word
 # ^^^^^^ meta.redirection.shell
 # ^ keyword.operator.assignment.redirection.shell
-#   ^^^^ meta.string.shell string.unquoted.shell
+#   ^^^^ meta.string.glob.shell string.unquoted.shell
 #       ^ - meta.redirection
 #        ^^^^^^^ meta.redirection.shell
 #        ^^ keyword.operator.assignment.redirection.shell
-#           ^^^^ meta.string.shell string.unquoted.shell
+#           ^^^^ meta.string.glob.shell string.unquoted.shell
 #               ^ - meta.redirection
 #                ^^^^^^^ meta.redirection.shell
 #                ^^ keyword.operator.assignment.redirection.shell
-#                   ^^^^ meta.string.shell string.unquoted.shell
+#                   ^^^^ meta.string.glob.shell string.unquoted.shell
 #                       ^ - meta.redirection
 
 : > /dev/null
@@ -9465,21 +9465,21 @@ echo '([^.[:space:]]+)   Class::method()' # colon not scoped as path separator
 : > out~put-
 # ^^^^^^^^^^ meta.redirection.shell
 # ^ keyword.operator.assignment.redirection.shell
-#   ^^^^^^^^ meta.string.shell string.unquoted.shell
+#   ^^^^^^^^ meta.string.glob.shell string.unquoted.shell
 #    ^ - variable
 #          ^ - punctuation
 #           ^ - meta.redirection
 
 : > ~/.local/file
 # ^^ meta.redirection.shell - meta.string
-#   ^ meta.redirection.shell meta.string.shell meta.interpolation.tilde.shell
-#    ^^^^^^^^^^^^ meta.redirection.shell meta.string.shell string.unquoted.shell - meta.interpolation
+#   ^ meta.redirection.shell meta.string.glob.shell meta.interpolation.tilde.shell
+#    ^^^^^^^^^^^^ meta.redirection.shell meta.string.glob.shell string.unquoted.shell - meta.interpolation
 # ^ keyword.operator.assignment.redirection.shell
 #   ^ variable.language.tilde.shell
 
 : > "~/.local/file"
 # ^^ meta.redirection.shell - meta.string
-#   ^^^^^^^^^^^^^^^ meta.redirection.shell meta.string.shell string.quoted.double.shell
+#   ^^^^^^^^^^^^^^^ meta.redirection.shell meta.string.glob.shell string.quoted.double.shell
 # ^ keyword.operator.assignment.redirection.shell
 #   ^ punctuation.definition.string.begin.shell
 #    ^ - variable.language
@@ -9723,7 +9723,7 @@ cat << redirection_comes_next > foo.txt
 #      ^^^^^^^^^^^^^^^^^^^^^^ meta.redirection.shell meta.tag.heredoc.begin.shell - meta.string - string
 #                            ^ meta.redirection.shell - meta.tag - meta.string - string
 #                             ^^ meta.redirection.shell meta.redirection.shell - meta.string
-#                               ^^^^^^^ meta.redirection.shell meta.redirection.shell meta.string.shell string.unquoted.shell
+#                               ^^^^^^^ meta.redirection.shell meta.redirection.shell meta.string.glob.shell string.unquoted.shell
 #   ^^ keyword.operator.assignment.redirection.shell
 #     ^ - entiy - keyword
 #      ^^^^^^^^^^^^^^^^^^^^^^ entity.name.tag.heredoc.shell
@@ -9792,9 +9792,9 @@ variable=$(cat <$dummy.c
 #^^ meta.function-call.identifier.shell variable.function.shell
 #  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell - string.unquoted.heredoc
-#   ^^^^^^^^^^^ meta.string.shell string.quoted.single.shell
+#   ^^^^^^^^^^^ meta.string.glob.shell string.quoted.single.shell
 #              ^ - meta.redirection - meta.tag - meta.string
 #               ^^ meta.redirection.shell - meta.tag - meta.string
 #                  ^^^ meta.redirection.shell meta.tag.heredoc.begin.shell - meta.string
@@ -9918,7 +9918,7 @@ EOF
 # ^^^ keyword.operator.assignment.herestring
 #     ^^^^ string.unquoted.shell
 #          ^^^^^ meta.parameter.option.shell variable.parameter.option.shell
-#                ^^^^^^^^^^^^^^^^ meta.string.shell
+#                ^^^^^^^^^^^^^^^^ meta.string.glob.shell
 #                ^ variable.language.tilde.shell
 #                  ^^ constant.other.wildcard.asterisk.shell
 #                     ^^^^ meta.set.regexp.shell
@@ -9981,8 +9981,8 @@ cat <<< "This is a \\$here \"\$string.\"" ; cat more stuff | bar | qux
 #                                       ^ punctuation.definition.string.end.shell
 #                                         ^ punctuation.terminator.statement.shell
 #                                           ^^^ variable.function.shell
-#                                               ^^^^ meta.string.shell string.unquoted.shell
-#                                                    ^^^^^ meta.string.shell string.unquoted.shell
+#                                               ^^^^ meta.string.glob.shell string.unquoted.shell
+#                                                    ^^^^^ meta.string.glob.shell string.unquoted.shell
 #                                                          ^ keyword.operator.assignment.pipe.shell
 #                                                            ^^^ variable.function.shell
 #                                                                ^ keyword.operator.assignment.pipe.shell
@@ -10079,7 +10079,7 @@ alias ..='cd ..'
 #        ^ meta.quoted.shell punctuation.definition.quoted.begin.shell
 #         ^^ meta.quoted.shell meta.function-call.identifier.shell meta.command.shell support.function.shell - string
 #           ^ meta.quoted.shell meta.function-call.arguments.shell - string
-#            ^^ meta.quoted.shell meta.function-call.arguments.shell meta.string.shell string.unquoted.shell
+#            ^^ meta.quoted.shell meta.function-call.arguments.shell meta.string.glob.shell string.unquoted.shell
 #              ^ meta.quoted.shell punctuation.definition.quoted.end.shell
 
 alias -p ..='cd ..'
@@ -10092,7 +10092,7 @@ alias -p ..='cd ..'
 #           ^ meta.quoted.shell punctuation.definition.quoted.begin.shell
 #            ^^ meta.quoted.shell meta.function-call.identifier.shell meta.command.shell support.function.shell - string
 #              ^ meta.quoted.shell meta.function-call.arguments.shell - string
-#               ^^ meta.quoted.shell meta.function-call.arguments.shell meta.string.shell string.unquoted.shell
+#               ^^ meta.quoted.shell meta.function-call.arguments.shell meta.string.glob.shell string.unquoted.shell
 #                 ^ meta.quoted.shell punctuation.definition.quoted.end.shell
 
 alias -- -='cd -'
@@ -10105,7 +10105,7 @@ alias -- -='cd -'
 #          ^ meta.quoted.shell punctuation.definition.quoted.begin.shell
 #           ^^ meta.quoted.shell meta.function-call.identifier.shell meta.command.shell support.function.shell - string
 #             ^ meta.quoted.shell meta.function-call.arguments.shell - string
-#              ^ meta.quoted.shell meta.function-call.arguments.shell meta.string.shell string.unquoted.shell
+#              ^ meta.quoted.shell meta.function-call.arguments.shell meta.string.glob.shell string.unquoted.shell
 #               ^ meta.quoted.shell punctuation.definition.quoted.end.shell
 
 
@@ -10126,9 +10126,9 @@ builtin -pV -v cmd -a val
 #          ^^^^^^^^^^^^^^ meta.function-call.arguments.shell
 #       ^^^ variable.function.shell
 #           ^^ meta.parameter.option.shell variable.parameter.option.shell
-#              ^^^ meta.string.shell string.unquoted.shell
+#              ^^^ meta.string.glob.shell string.unquoted.shell
 #                  ^^ meta.parameter.option.shell variable.parameter.option.shell
-#                     ^^^ meta.string.shell string.unquoted.shell
+#                     ^^^ meta.string.glob.shell string.unquoted.shell
 
 
 ###############################################################################
@@ -10151,7 +10151,7 @@ command -pV -v cmd -a val
 #           ^^ meta.parameter.option.shell variable.parameter.option.shell
 #              ^^^ variable.function.shell
 #                  ^^ meta.parameter.option.shell variable.parameter.option.shell
-#                     ^^^ meta.string.shell string.unquoted.shell
+#                     ^^^ meta.string.glob.shell string.unquoted.shell
 
 
 ###############################################################################
@@ -10212,7 +10212,7 @@ declare foo; bar=baz # 2nd statement after ';'
 #          ^ punctuation.terminator.statement.shell
 #            ^^^ variable.other.readwrite.shell
 #               ^ keyword.operator.assignment.shell
-#                ^^^ meta.string.shell string.unquoted.shell
+#                ^^^ meta.string.glob.shell string.unquoted.shell
 #                   ^ - meta.string - string - comment
 #                    ^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
 
@@ -10223,7 +10223,7 @@ declare foo==bar baz =buz  # assignment must immediately follow a variable
 #      ^ - variable
 #       ^^^ variable.other.readwrite.shell
 #          ^ keyword.operator.assignment.shell
-#           ^^^^ meta.string.shell string.unquoted.shell
+#           ^^^^ meta.string.glob.shell string.unquoted.shell
 #               ^ - variable
 #                ^^^ variable.other.readwrite.shell
 #                   ^ - variable
@@ -10240,14 +10240,14 @@ declare foo= )
@@ -10762,12 +10762,12 @@ declare -f _init_completion > /dev/null && complete -F _upto upto
 # declare called in command substituations
 
 printFunction "$variableString1" "$(declare -p variableArray)"
-#             ^ meta.string.shell string.quoted.double.shell punctuation.definition.string.begin.shell
-#              ^^^^^^^^^^^^^^^^ meta.string.shell meta.interpolation.parameter.shell - string
-#                              ^ meta.string.shell string.quoted.double.shell punctuation.definition.string.end.shell
-#                                ^ meta.string.shell string.quoted.double.shell punctuation.definition.string.begin.shell
-#                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell meta.interpolation.command.shell - string
-#                                                            ^ meta.string.shell string.quoted.double.shell punctuation.definition.string.end.shell
+#             ^ meta.string.glob.shell string.quoted.double.shell punctuation.definition.string.begin.shell
+#              ^^^^^^^^^^^^^^^^ meta.string.glob.shell meta.interpolation.parameter.shell - string
+#                              ^ meta.string.glob.shell string.quoted.double.shell punctuation.definition.string.end.shell
+#                                ^ meta.string.glob.shell string.quoted.double.shell punctuation.definition.string.begin.shell
+#                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.glob.shell meta.interpolation.command.shell - string
+#                                                            ^ meta.string.glob.shell string.quoted.double.shell punctuation.definition.string.end.shell
 #                                  ^ punctuation.section.interpolation.begin.shell
 #                                   ^^^^^^^ keyword.declaration.variable.shell
 #                                           ^^ variable.parameter.option
@@ -10776,12 +10776,12 @@ printFunction "$variableString1" "$(declare -p variableArray)"
 
 # <- - variable.other
 printFunction "$variableString1" "`declare -p variableArray`"
-#             ^ meta.string.shell string.quoted.double.shell punctuation.definition.string.begin.shell
-#              ^^^^^^^^^^^^^^^^ meta.string.shell meta.interpolation.parameter.shell - string
-#                              ^ meta.string.shell string.quoted.double.shell punctuation.definition.string.end.shell
-#                                ^ meta.string.shell string.quoted.double.shell punctuation.definition.string.begin.shell
-#                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell meta.interpolation.command.shell - string
-#                                                           ^ meta.string.shell string.quoted.double.shell punctuation.definition.string.end.shell
+#             ^ meta.string.glob.shell string.quoted.double.shell punctuation.definition.string.begin.shell
+#              ^^^^^^^^^^^^^^^^ meta.string.glob.shell meta.interpolation.parameter.shell - string
+#                              ^ meta.string.glob.shell string.quoted.double.shell punctuation.definition.string.end.shell
+#                                ^ meta.string.glob.shell string.quoted.double.shell punctuation.definition.string.begin.shell
+#                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.glob.shell meta.interpolation.command.shell - string
+#                                                           ^ meta.string.glob.shell string.quoted.double.shell punctuation.definition.string.end.shell
 #                                 ^ punctuation.section.interpolation.begin.shell
 #                                  ^^^^^^^ keyword.declaration.variable.shell
 #                                          ^^ variable.parameter.option
@@ -10802,17 +10802,17 @@ eval ls .
 # <- meta.function-call.identifier.shell support.function.shell
 #^^^ meta.function-call.identifier.shell support.function.shell
 #   ^^^^^ meta.function-call.arguments.shell
-#    ^^ meta.string.shell string.unquoted.shell
-#       ^ meta.string.shell string.unquoted.shell
+#    ^^ meta.string.glob.shell string.unquoted.shell
+#       ^ meta.string.glob.shell string.unquoted.shell
 
 eval "echo Helo ${name:a " + 2":$len}" !
 # <- meta.function-call.identifier.shell support.function.shell
 #^^^ meta.function-call.identifier.shell support.function.shell
 #   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
-#    ^^^^^^^^^^^ meta.string.shell string.quoted.double.shell
-#               ^^^^^^^^^^^^^^^^^^^^^ meta.string.shell meta.interpolation.parameter.shell
-#                                    ^ meta.string.shell string.quoted.double.shell punctuation.definition.string.end.shell
-#                                      ^ meta.string.shell string.unquoted.shell
+#    ^^^^^^^^^^^ meta.string.glob.shell string.quoted.double.shell
+#               ^^^^^^^^^^^^^^^^^^^^^ meta.string.glob.shell meta.interpolation.parameter.shell
+#                                    ^ meta.string.glob.shell string.quoted.double.shell punctuation.definition.string.end.shell
+#                                      ^ meta.string.glob.shell string.unquoted.shell
 
 
 ###############################################################################
@@ -10862,7 +10862,7 @@ exec -c -l -a name git status
 #    ^^ variable.parameter.option.shell
 #       ^^ variable.parameter.option.shell
 #          ^^ variable.parameter.option.shell
-#             ^^^^ meta.string.shell string.unquoted.shell
+#             ^^^^ meta.string.glob.shell string.unquoted.shell
 #                  ^^^ variable.function.shell
 
 exec -la name -i --bar -- foo bar
@@ -10926,7 +10926,7 @@ exec \
   -la name \
 #^^^^^^^^^^^^ meta.function-call.arguments.shell
 # ^^^ meta.parameter.option.shell variable.parameter.option.shell
-#     ^^^^ meta.string.shell string.unquoted.shell
+#     ^^^^ meta.string.glob.shell string.unquoted.shell
 #          ^ punctuation.separator.continuation.line.shell
 #           ^ - punctuation
 
@@ -10992,7 +10992,7 @@ export foo='bar'    # 'foo' is a variable name
 #               ^ - meta.function-call
 #      ^^^ variable.other.readwrite.shell
 #         ^ keyword.operator.assignment.shell
-#          ^^^^^ meta.string.shell string.quoted.single.shell
+#          ^^^^^ meta.string.glob.shell string.quoted.single.shell
 #          ^ punctuation.definition.string.begin.shell
 #              ^ punctuation.definition.string.end.shell
 #                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
@@ -11001,13 +11001,13 @@ export PGPASSWORD=$(cat "$DOKKU_ROOT/.postgresql/pwd_$APP")
 # <- meta.function-call.identifier.shell support.function.shell
 #^^^^^ meta.function-call.identifier.shell support.function.shell
 #     ^^^^^^^^^^^^ meta.function-call.arguments.shell - meta.string - meta.interpolation
-#                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell meta.interpolation.command.shell
+#                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.glob.shell meta.interpolation.command.shell
 #      ^^^^^^^^^^ variable.other.readwrite.shell
 #                ^ keyword.operator.assignment.shell
 #                 ^ punctuation.definition.variable.shell
 #                  ^ punctuation.section.interpolation.begin.shell
 #                   ^^^ variable.function.shell
-#                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell meta.interpolation.command.shell meta.string.shell
+#                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.glob.shell meta.interpolation.command.shell meta.string.glob.shell
 
 export -f foo
 # <- meta.function-call.identifier.shell support.function.shell
@@ -11051,7 +11051,7 @@ export PATH=$PATH:~/.local/bin
 #     ^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
 #      ^^^^ variable.language.builtin.shell
 #          ^ keyword.operator.assignment
-#           ^^^^^^^^^^^^^^^^^^ meta.string.shell
+#           ^^^^^^^^^^^^^^^^^^ meta.string.glob.shell
 #           ^^^^^ meta.interpolation.parameter.shell variable.language.builtin.shell
 #                 ^ meta.interpolation.tilde.shell variable.language.tilde.shell
 
@@ -11061,7 +11061,7 @@ export PATH="$PATH:~/.local/bin"
 #     ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
 #      ^^^^ variable.language.builtin.shell
 #          ^ keyword.operator.assignment.shell
-#           ^^^^^^^^^^^^^^^^^^^^ meta.string.shell
+#           ^^^^^^^^^^^^^^^^^^^^ meta.string.glob.shell
 #           ^ punctuation.definition.string.begin.shell
 #            ^^^^^ meta.interpolation.parameter.shell variable.language.builtin.shell
 #                 ^ punctuation.separator.sequence.shell
@@ -11073,7 +11073,7 @@ export SOMETHING='/etc/test:/var/test:../foo:./foo'
 #      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
 #      ^^^^^^^^^ variable.other.readwrite.shell
 #               ^ keyword.operator.assignment.shell
-#                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell string.quoted.single.shell
+#                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.glob.shell string.quoted.single.shell
 #                ^ punctuation.definition.string.begin.shell
 #                          ^ punctuation.separator.sequence.shell
 #                                    ^ punctuation.separator.sequence.shell
@@ -11085,7 +11085,7 @@ export SOMETHING=/etc/test:/var/test
 #      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
 #      ^^^^^^^^^ variable.other.readwrite.shell
 #               ^ keyword.operator.assignment.shell
-#                ^^^^^^^^^^^^^^^^^^^ meta.string.shell string.unquoted.shell
+#                ^^^^^^^^^^^^^^^^^^^ meta.string.glob.shell string.unquoted.shell
 #                         ^ punctuation.separator.sequence
 
 msg="Count: ${count}"
@@ -11315,7 +11315,7 @@ local foo bar='baz' # 'foo' and 'bar' are variable names
 #        ^ - variable
 #         ^^^ variable.other.readwrite.shell
 #            ^ keyword.operator.assignment.shell
-#             ^^^^^ meta.string.shell string.quoted.single.shell
+#             ^^^^^ meta.string.glob.shell string.quoted.single.shell
 #                  ^ - comment - string
 #                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
 
@@ -11325,7 +11325,7 @@ local foo+=10 bar-=true
 #^^^^ keyword.declaration.variable.shell
 #     ^^^ variable.other.readwrite.shell
 #        ^^ keyword.operator.assignment.shell
-#          ^^ meta.string.shell string.unquoted.shell
+#          ^^ meta.string.glob.shell string.unquoted.shell
 #             ^^^ variable.other.readwrite.shell
 #                ^^ keyword.operator.assignment.shell
 #                  ^^^^ constant.language.boolean.true.shell
@@ -11336,7 +11336,7 @@ local pid="$(cat "$PIDFILE" 2>/dev/null)"
 #^^^^ meta.declaration.variable.shell keyword.declaration.variable.shell
 #     ^^^ variable.other.readwrite.shell
 #        ^ keyword.operator.assignment.shell
-#         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell
+#         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.glob.shell
 
 local -fn foo
 # <- meta.declaration.variable.shell keyword.declaration.variable.shell
@@ -11382,7 +11382,7 @@ f() {
         IFS=, local -a "$x"'=("${x}: ${'"$x"'[*]}")'
         # ^ variable.language.builtin.shell
         #  ^ keyword.operator.assignment.shell
-        #   ^ meta.string.shell string.unquoted.shell
+        #   ^ meta.string.glob.shell string.unquoted.shell
         #     ^ keyword.declaration.variable.shell
     done
     # <- keyword.control.loop.end.shell
@@ -11437,11 +11437,11 @@ mapfile -d ";" -n 10 -O $origin -s 5 -t -u 20 -C callback -c 10 array
 #      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
 #                                                                    ^ - meta.function-call
 #       ^^ meta.parameter.option.shell variable.parameter.option.shell
-#          ^^^ meta.string.shell string.quoted.double.shell
+#          ^^^ meta.string.glob.shell string.quoted.double.shell
 #              ^^ meta.parameter.option.shell variable.parameter.option.shell
 #                 ^^ meta.number.integer.decimal.shell constant.numeric.value.shell
 #                    ^^ meta.parameter.option.shell variable.parameter.option.shell
-#                       ^^^^^^^ meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell
+#                       ^^^^^^^ meta.string.glob.shell meta.interpolation.parameter.shell variable.other.readwrite.shell
 #                               ^^ meta.parameter.option.shell variable.parameter.option.shell
 #                                  ^ meta.number.integer.decimal.shell constant.numeric.value.shell
 #                                    ^^ meta.parameter.option.shell variable.parameter.option.shell
@@ -11565,11 +11565,11 @@ readarray -d ";" -n 10 -O $origin -s 5 -t -u 20 -C callback -c 10 array
 #        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
 #                                                                      ^ - meta.function-call
 #         ^^ meta.parameter.option.shell variable.parameter.option.shell
-#            ^^^ meta.string.shell string.quoted.double.shell
+#            ^^^ meta.string.glob.shell string.quoted.double.shell
 #                ^^ meta.parameter.option.shell variable.parameter.option.shell
 #                   ^^ meta.number.integer.decimal.shell constant.numeric.value.shell
 #                      ^^ meta.parameter.option.shell variable.parameter.option.shell
-#                         ^^^^^^^ meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell
+#                         ^^^^^^^ meta.string.glob.shell meta.interpolation.parameter.shell variable.other.readwrite.shell
 #                                 ^^ meta.parameter.option.shell variable.parameter.option.shell
 #                                    ^ meta.number.integer.decimal.shell constant.numeric.value.shell
 #                                      ^^ meta.parameter.option.shell variable.parameter.option.shell
@@ -11603,22 +11603,22 @@ readonly bar=\
 #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.variable.shell
 #                                               ^ - meta.declaration
 # <- punctuation.section.sequence.begin.shell
-#^^^ meta.string.shell string.unquoted.shell
+#^^^ meta.string.glob.shell string.unquoted.shell
 #   ^ - meta.string - string
-#    ^^ meta.string.shell string.unquoted.shell
+#    ^^ meta.string.glob.shell string.unquoted.shell
 #     ^ constant.other.wildcard.asterisk.shell
-#      ^^ meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell
+#      ^^ meta.string.glob.shell meta.interpolation.parameter.shell variable.other.readwrite.shell
 #        ^ - meta.string - string
-#         ^^^^ meta.string.shell string.unquoted.shell
+#         ^^^^ meta.string.glob.shell string.unquoted.shell
 #             ^ - meta.string - string
-#              ^^^^^ meta.string.shell string.quoted.single.shell
+#              ^^^^^ meta.string.glob.shell string.quoted.single.shell
 #                   ^ - meta.string - string
-#                    ^^^^^ meta.string.shell string.quoted.double.shell
+#                    ^^^^^ meta.string.glob.shell string.quoted.double.shell
 #                          ^^^^^ meta.item-access.shell
 #                               ^ keyword.operator.assignment.shell
-#                                ^^^ meta.string.shell string.unquoted.shell
+#                                ^^^ meta.string.glob.shell string.unquoted.shell
 #                                    ^ invalid.illegal.unexpected-token.shell - meta.redirection
-#                                     ^^^^^^^^^ meta.string.shell string.unquoted.shell - meta.redirection
+#                                     ^^^^^^^^^ meta.string.glob.shell string.unquoted.shell - meta.redirection
 #                                              ^ punctuation.section.sequence.end.shell
 #                                                ^^^^^^^^^^ comment.line.number-sign.shell
 
@@ -11628,22 +11628,22 @@ readonly -a bar=\
 #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.declaration.variable.shell
 #                                               ^ - meta.declaration
 # <- punctuation.section.sequence.begin.shell
-#^^^ meta.string.shell string.unquoted.shell
+#^^^ meta.string.glob.shell string.unquoted.shell
 #   ^ - meta.string - string
-#    ^^ meta.string.shell string.unquoted.shell
+#    ^^ meta.string.glob.shell string.unquoted.shell
 #     ^ constant.other.wildcard.asterisk.shell
-#      ^^ meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell
+#      ^^ meta.string.glob.shell meta.interpolation.parameter.shell variable.other.readwrite.shell
 #        ^ - meta.string - string
-#         ^^^^ meta.string.shell string.unquoted.shell
+#         ^^^^ meta.string.glob.shell string.unquoted.shell
 #             ^ - meta.string - string
-#              ^^^^^ meta.string.shell string.quoted.single.shell
+#              ^^^^^ meta.string.glob.shell string.quoted.single.shell
 #                   ^ - meta.string - string
-#                    ^^^^^ meta.string.shell string.quoted.double.shell
+#                    ^^^^^ meta.string.glob.shell string.quoted.double.shell
 #                          ^^^^^ meta.item-access.shell
 #                               ^ keyword.operator.assignment.shell
-#                                ^^^ meta.string.shell string.unquoted.shell
+#                                ^^^ meta.string.glob.shell string.unquoted.shell
 #                                    ^ invalid.illegal.unexpected-token.shell - meta.redirection
-#                                     ^^^^^^^^^ meta.string.shell string.unquoted.shell - meta.redirection
+#                                     ^^^^^^^^^ meta.string.glob.shell string.unquoted.shell - meta.redirection
 #                                              ^ punctuation.section.sequence.end.shell
 #                                                ^^^^^^^^^^ comment.line.number-sign.shell
 
@@ -11657,12 +11657,12 @@ readonly -A var=(key1 1+2 key2 4-foo key3 val%10)
 #                                    ^^^^ meta.item-access.shell entity.name.key.shell
 #               ^ punctuation.section.sequence.begin.shell
 #                ^^^^ entity.name.key.shell
-#                     ^^^ meta.string.shell string.unquoted.shell
+#                     ^^^ meta.string.glob.shell string.unquoted.shell
 #                         ^^^^ entity.name.key.shell
-#                              ^^^^^ meta.string.shell string.unquoted.shell
+#                              ^^^^^ meta.string.glob.shell string.unquoted.shell
 #                                    ^^^^ entity.name.key.shell
-#                                         ^^^ meta.string.shell string.unquoted.shell
-#                                            ^^^ meta.string.shell meta.interpolation.job.shell variable.language.job.shell
+#                                         ^^^ meta.string.glob.shell string.unquoted.shell
+#                                            ^^^ meta.string.glob.shell meta.interpolation.job.shell variable.language.job.shell
 #                                               ^ punctuation.section.sequence.end.shell
 
 readonly -A -f foo   # 'foo' is a variable name
@@ -11730,7 +11730,7 @@ foo=`readonly x=5`
 #    ^^^^^^^^ meta.interpolation.command.shell keyword.declaration.variable.shell
 #             ^ meta.interpolation.command.shell variable.other.readwrite.shell
 #              ^ meta.interpolation.command.shell keyword.operator.assignment.shell
-#               ^ meta.interpolation.command.shell meta.string.shell string.unquoted.shell
+#               ^ meta.interpolation.command.shell meta.string.glob.shell string.unquoted.shell
 #                ^ meta.interpolation.command.shell punctuation.section.interpolation.end.shell
 
 
@@ -11828,44 +11828,44 @@ test str == "str"
 #<- meta.function-call.identifier.shell support.function.shell
 #^^^ meta.function-call.identifier.shell support.function.shell
 #   ^^^^^^^^^^^^^ meta.function-call.arguments.shell
-#    ^^^ meta.string.shell string.unquoted.shell
+#    ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^^ keyword.operator.comparison.shell
-#           ^^^^^ meta.string.shell string.quoted.double.shell
+#           ^^^^^ meta.string.glob.shell string.quoted.double.shell
 
 test str != "str"
 #<- meta.function-call.identifier.shell support.function.shell
 #^^^ meta.function-call.identifier.shell support.function.shell
 #   ^^^^^^^^^^^^^ meta.function-call.arguments.shell
-#    ^^^ meta.string.shell string.unquoted.shell
+#    ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^^ keyword.operator.comparison.shell
-#           ^^^^^ meta.string.shell string.quoted.double.shell
+#           ^^^^^ meta.string.glob.shell string.quoted.double.shell
 
 test str < 'str'
 # <- meta.function-call.identifier.shell support.function.shell
 #^^^ meta.function-call.identifier.shell support.function.shell
 #   ^^^^^^^^^^^^ meta.function-call.arguments.shell
 #               ^ - meta.function-call
-#    ^^^ meta.string.shell string.unquoted.shell
+#    ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ keyword.operator.comparison.shell
-#          ^^^^^ meta.string.shell string.quoted.single.shell
+#          ^^^^^ meta.string.glob.shell string.quoted.single.shell
 
 test str > str
 # <- meta.function-call.identifier.shell support.function.shell
 #^^^ meta.function-call.identifier.shell support.function.shell
 #   ^^^^^^^^^^ meta.function-call.arguments.shell
 #             ^ - meta.function-call
-#    ^^^ meta.string.shell string.unquoted.shell
+#    ^^^ meta.string.glob.shell string.unquoted.shell
 #        ^ keyword.operator.comparison.shell
-#          ^^^ meta.string.shell string.unquoted.shell
+#          ^^^ meta.string.glob.shell string.unquoted.shell
 
 test var[0] != var[^0-9]*$
 #<- meta.function-call.identifier.shell support.function.shell
 #^^^ meta.function-call.identifier.shell support.function.shell
 #   ^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
-#    ^^^^^^ meta.string.shell string.unquoted.shell
+#    ^^^^^^ meta.string.glob.shell string.unquoted.shell
 #       ^^^ meta.set.regexp.shell
 #           ^^ keyword.operator.comparison.shell
-#              ^^^^^^^^^^^ meta.string.shell string.unquoted.shell - meta.string.regexp
+#              ^^^^^^^^^^^ meta.string.glob.shell string.unquoted.shell - meta.string.regexp
 
 test $var[0] != var[^0-9]*$
 #<- meta.function-call.identifier.shell support.function.shell
@@ -11874,7 +11874,7 @@ test $var[0] != var[^0-9]*$
 #    ^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell
 #        ^^^ meta.set.regexp.shell
 #            ^^ keyword.operator.comparison.shell
-#               ^^^^^^^^^^^ meta.string.shell string.unquoted.shell - meta.string.regexp
+#               ^^^^^^^^^^^ meta.string.glob.shell string.unquoted.shell - meta.string.regexp
 
 test ${var[0]} != var[^0-9]*$
 #<- meta.function-call.identifier.shell support.function.shell
@@ -11884,7 +11884,7 @@ test ${var[0]} != var[^0-9]*$
 #      ^^^ variable.other.readwrite.shell
 #         ^^^ meta.item-access.shell
 #              ^^ keyword.operator.comparison.shell
-#                 ^^^^^^^^^^^ meta.string.shell string.unquoted.shell - meta.string.regexp
+#                 ^^^^^^^^^^^ meta.string.glob.shell string.unquoted.shell - meta.string.regexp
 
 test expr -a expr -o expr -- | cmd |& cmd
 # <- meta.function-call.identifier.shell support.function.shell
@@ -11907,7 +11907,7 @@ test ! $line == ^[0-9]+$
 #    ^ keyword.operator.logical.shell
 #      ^^^^^ variable.other.readwrite.shell
 #            ^^ keyword.operator.comparison.shell
-#               ^^^^^^^^ meta.string.shell string.unquoted.shell
+#               ^^^^^^^^ meta.string.glob.shell string.unquoted.shell
 
 test ! $line =~ ^[0-9]+$ >> /file
 # <- meta.function-call.identifier.shell support.function.shell
@@ -11918,7 +11918,7 @@ test ! $line =~ ^[0-9]+$ >> /file
 #    ^ keyword.operator.logical.shell
 #      ^^^^^ variable.other.readwrite.shell
 #            ^^ invalid.illegal.operator.shell
-#               ^^^^^^^^ meta.string.shell string.unquoted.shell
+#               ^^^^^^^^ meta.string.glob.shell string.unquoted.shell
 #                        ^^ keyword.operator.assignment.redirection.shell
 
 if test expr -a expr ; then echo "success"; fi
@@ -11937,9 +11937,9 @@ if test "$VAR" != ";";then;fi
 # ^ - meta.function-call
 #  ^^^^ meta.function-call.identifier.shell support.function.shell
 #      ^^^^^^^^^^^^^^ meta.function-call.arguments.shell
-#       ^^^^^^ meta.string.shell
+#       ^^^^^^ meta.string.glob.shell
 #              ^^ keyword.operator.comparison.shell
-#                 ^^^ meta.string.shell string.quoted.double.shell
+#                 ^^^ meta.string.glob.shell string.quoted.double.shell
 #                    ^^^^^^^^ - meta.function-call
 #                    ^ punctuation.terminator.statement.shell
 #                     ^^^^ keyword.control.conditional.then.shell
@@ -11960,7 +11960,7 @@ time cmd1 --arg val | cmd2 -n |& cmd3
 #    ^^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
 #        ^^^^^^^^^^ meta.function-call.arguments.shell
 #         ^^^^^ meta.parameter.option.shell variable.parameter.option.shell
-#               ^^^ meta.string.shell string.unquoted.shell
+#               ^^^ meta.string.glob.shell string.unquoted.shell
 #                   ^ keyword.operator.assignment.pipe.shell
 #                     ^^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
 #                         ^^^ meta.function-call.arguments.shell
@@ -12020,7 +12020,7 @@ trap 'cmd --args="value"' SIGINT
 #     ^^^ variable.function.shell
 #         ^^^^^^ meta.parameter.option.shell variable.parameter.option.shell
 #               ^ keyword.operator.assignment.shell
-#                ^^^^^^^ meta.string.shell string.quoted.double.shell
+#                ^^^^^^^ meta.string.glob.shell string.quoted.double.shell
 #                       ^ punctuation.definition.quoted.end.shell
 #                         ^^^^^^ constant.language.signal.shell
 
@@ -12037,7 +12037,7 @@ trap "cmd --args='value'" SIGKILL
 #     ^^^ variable.function.shell
 #         ^^^^^^ meta.parameter.option.shell variable.parameter.option.shell
 #               ^ keyword.operator.assignment.shell
-#                ^^^^^^^ meta.string.shell string.quoted.single.shell
+#                ^^^^^^^ meta.string.glob.shell string.quoted.single.shell
 #                       ^ punctuation.definition.quoted.end.shell
 #                         ^^^^^^^ constant.language.signal.shell
 
@@ -12056,9 +12056,9 @@ trap "\"cmd\" --args=\"val${ue}\"" SIGKILL
 #          ^^ constant.character.escape.shell
 #             ^^^^^^ meta.parameter.option.shell variable.parameter.option.shell
 #                   ^ keyword.operator.assignment.shell
-#                    ^^^^^ meta.string.shell string.unquoted.shell
+#                    ^^^^^ meta.string.glob.shell string.unquoted.shell
 #                    ^^ constant.character.escape.shell
-#                         ^^^^^ meta.string.shell meta.interpolation.parameter.shell
+#                         ^^^^^ meta.string.glob.shell meta.interpolation.parameter.shell
 #                              ^^ constant.character.escape.shell
 #                                ^ punctuation.definition.quoted.end.shell
 #                                  ^^^^^^^ constant.language.signal.shell
@@ -12237,11 +12237,11 @@ sudo -b -g network --host=$foo rm -rf
 #    ^ punctuation.definition.parameter.shell
 #       ^^ meta.parameter.option.shell variable.parameter.option.shell
 #       ^ punctuation.definition.parameter.shell
-#          ^^^^^^^ meta.string.shell string.unquoted.shell
+#          ^^^^^^^ meta.string.glob.shell string.unquoted.shell
 #                  ^^^^^^ meta.parameter.option.shell variable.parameter.option.shell
 #                  ^^ punctuation.definition.parameter.shell
 #                        ^ keyword.operator.assignment.shell
-#                         ^^^^ meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell
+#                         ^^^^ meta.string.glob.shell meta.interpolation.parameter.shell variable.other.readwrite.shell
 #                              ^^ variable.function.shell
 #                                 ^^^ meta.parameter.option.shell variable.parameter.option.shell
 #                                 ^ punctuation.definition.parameter.shell
@@ -12798,99 +12798,99 @@ cmd
 [ file1 -ef file2 ]
 # <- meta.compound.conditional.shell punctuation.section.compound.begin.shell
 #^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell
-# ^^^^^ meta.string.shell string.unquoted.shell
+# ^^^^^ meta.string.glob.shell string.unquoted.shell
 #       ^^^ keyword.operator.comparison.shell
-#           ^^^^^ meta.string.shell string.unquoted.shell
+#           ^^^^^ meta.string.glob.shell string.unquoted.shell
 #                 ^ punctuation.section.compound.end.shell
 
 [ file1 -nt file2 ]
 # <- meta.compound.conditional.shell punctuation.section.compound.begin.shell
 #^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell
-# ^^^^^ meta.string.shell string.unquoted.shell
+# ^^^^^ meta.string.glob.shell string.unquoted.shell
 #       ^^^ keyword.operator.comparison.shell
-#           ^^^^^ meta.string.shell string.unquoted.shell
+#           ^^^^^ meta.string.glob.shell string.unquoted.shell
 #                 ^ punctuation.section.compound.end.shell
 
 [ file1 -ot file2 ]
 # <- meta.compound.conditional.shell punctuation.section.compound.begin.shell
 #^^^^^^^^^^^^^^^^^^ meta.compound.conditional.shell
-# ^^^^^ meta.string.shell string.unquoted.shell
+# ^^^^^ meta.string.glob.shell string.unquoted.shell
 #       ^^^ keyword.operator.comparison.shell
-#           ^^^^^ meta.string.shell string.unquoted.shell
+#           ^^^^^ meta.string.glob.shell string.unquoted.shell
 #                 ^ punctuation.section.compound.end.shell
 
 [ ! str != str ]
 # <- meta.compound.conditional.shell punctuation.section.compound.begin.shell
 #^^^^^^^^^^^^^^^ meta.compound.conditional.shell
 # ^ keyword.operator.logical.shell
-#   ^^^ meta.string.shell string.unquoted.shell
+#   ^^^ meta.string.glob.shell string.unquoted.shell
 #       ^^ keyword.operator.comparison.shell
-#          ^^^ meta.string.shell string.unquoted.shell
+#          ^^^ meta.string.glob.shell string.unquoted.shell
 #              ^ punctuation.section.compound.end.shell
 
 [ str != str ]
 # <- meta.compound.conditional.shell punctuation.section.compound.begin.shell
 #^^^^^^^^^^^^^ meta.compound.conditional.shell
-# ^^^ meta.string.shell string.unquoted.shell
+# ^^^ meta.string.glob.shell string.unquoted.shell
 #     ^^ keyword.operator.comparison.shell
-#        ^^^ meta.string.shell string.unquoted.shell
+#        ^^^ meta.string.glob.shell string.unquoted.shell
 #            ^ punctuation.section.compound.end.shell
 
 [ str == str ]
 # <- meta.compound.conditional.shell punctuation.section.compound.begin.shell
 #^^^^^^^^^^^^^ meta.compound.conditional.shell
-# ^^^ meta.string.shell string.unquoted.shell
+# ^^^ meta.string.glob.shell string.unquoted.shell
 #     ^^ keyword.operator.comparison.shell
-#        ^^^ meta.string.shell string.unquoted.shell
+#        ^^^ meta.string.glob.shell string.unquoted.shell
 #            ^ punctuation.section.compound.end.shell
 
 [ str =~ str ]
 # <- meta.compound.conditional.shell punctuation.section.compound.begin.shell
 #^^^^^^^^^^^^^ meta.compound.conditional.shell
-# ^^^ meta.string.shell string.unquoted.shell
+# ^^^ meta.string.glob.shell string.unquoted.shell
 #     ^^ invalid.illegal.operator.shell
-#        ^^^ meta.string.shell string.unquoted.shell
+#        ^^^ meta.string.glob.shell string.unquoted.shell
 #            ^ punctuation.section.compound.end.shell
 
 [ str >= str ]
 # <- meta.compound.conditional.shell punctuation.section.compound.begin.shell
 #^^^^^^^^^^^^^ meta.compound.conditional.shell
-# ^^^ meta.string.shell string.unquoted.shell
+# ^^^ meta.string.glob.shell string.unquoted.shell
 #     ^^ invalid.illegal.operator.shell
-#        ^^^ meta.string.shell string.unquoted.shell
+#        ^^^ meta.string.glob.shell string.unquoted.shell
 #            ^ punctuation.section.compound.end.shell
 
 [ str <= str ]
 # <- meta.compound.conditional.shell punctuation.section.compound.begin.shell
 #^^^^^^^^^^^^^ meta.compound.conditional.shell
-# ^^^ meta.string.shell string.unquoted.shell
+# ^^^ meta.string.glob.shell string.unquoted.shell
 #     ^^ invalid.illegal.operator.shell
-#        ^^^ meta.string.shell string.unquoted.shell
+#        ^^^ meta.string.glob.shell string.unquoted.shell
 #            ^ punctuation.section.compound.end.shell
 
 [ str = str ]
 # <- meta.compound.conditional.shell punctuation.section.compound.begin.shell
 #^^^^^^^^^^^^ meta.compound.conditional.shell
-# ^^^ meta.string.shell string.unquoted.shell
+# ^^^ meta.string.glob.shell string.unquoted.shell
 #     ^ keyword.operator.comparison.shell
-#       ^^^ meta.string.shell string.unquoted.shell
+#       ^^^ meta.string.glob.shell string.unquoted.shell
 #           ^ punctuation.section.compound.end.shell
 
 
 [ str < str ]
 # <- meta.compound.conditional.shell punctuation.section.compound.begin.shell
 #^^^^^^^^^^^^ meta.compound.conditional.shell
-# ^^^ meta.string.shell string.unquoted.shell
+# ^^^ meta.string.glob.shell string.unquoted.shell
 #     ^ keyword.operator.comparison.shell
-#       ^^^ meta.string.shell string.unquoted.shell
+#       ^^^ meta.string.glob.shell string.unquoted.shell
 #           ^ punctuation.section.compound.end.shell
 
 [ str > str ]
 # <- meta.compound.conditional.shell punctuation.section.compound.begin.shell
 #^^^^^^^^^^^^ meta.compound.conditional.shell
-# ^^^ meta.string.shell string.unquoted.shell
+# ^^^ meta.string.glob.shell string.unquoted.shell
 #     ^ keyword.operator.comparison.shell
-#       ^^^ meta.string.shell string.unquoted.shell
+#       ^^^ meta.string.glob.shell string.unquoted.shell
 #           ^ punctuation.section.compound.end.shell
 
 [ $arg -lt 2 ]
@@ -13010,15 +13010,15 @@ true false
 #                ^ - meta.number - constant
 
 : -target 20.10.2.4:8080 -port 80
-#         ^^^^^^^^^^^^^^ meta.string.shell string.unquoted.shell
+#         ^^^^^^^^^^^^^^ meta.string.glob.shell string.unquoted.shell
 #                              ^^ meta.number.integer.decimal.shell constant.numeric.value.shell
 
 : -target=20.10.2.4:8080 -port=80
-#         ^^^^^^^^^^^^^^ meta.string.shell string.unquoted.shell
+#         ^^^^^^^^^^^^^^ meta.string.glob.shell string.unquoted.shell
 #                              ^^ meta.number.integer.decimal.shell constant.numeric.value.shell
 
 ip=10.10.20.14
-#  ^^^^^^^^^^^ meta.string.shell string.unquoted.shell
+#  ^^^^^^^^^^^ meta.string.glob.shell string.unquoted.shell
 
 ###############################################################################
 # 6.5 Shell Arithmetic                                                        #
@@ -13272,7 +13272,7 @@ wait -fn -p varname
 #   ^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
 #    ^^^ meta.parameter.option.shell variable.parameter.option.shell
 #        ^^ meta.parameter.option.shell variable.parameter.option.shell
-#           ^^^^^^^ meta.string.shell string.unquoted.shell
+#           ^^^^^^^ meta.string.glob.shell string.unquoted.shell
 
 disown -ar
 # <- meta.function-call.identifier.shell support.function.shell
@@ -13296,7 +13296,7 @@ function clk {
     #<- keyword.declaration.variable.shell
     #       ^^^^ variable.other.readwrite.shell
     #           ^ keyword.operator.assignment.shell
-    #            ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell string.unquoted.shell
+    #            ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.glob.shell string.unquoted.shell
     [[ -r ${base}/hwmon/hwmon0/temp1_input && -r ${base}/power_profile ]] || return 1
     # <- punctuation.section.compound.begin.shell
     #                                                                  ^^ punctuation.section.compound.end.shell
@@ -13320,20 +13320,20 @@ then remotefilter="cat"
 #                ^ keyword.operator.assignment.shell
 else remotefilter="grep"
 #               ^ variable.other.readwrite.shell
-#                 ^ meta.string.shell string.quoted.double.shell punctuation.definition.string.begin.shell
+#                 ^ meta.string.glob.shell string.quoted.double.shell punctuation.definition.string.begin.shell
      for glob in "$@"
      do  glob=$(
      # ^^^^^^^ - meta.string - meta.interpolation
-     #        ^^^ meta.string.shell meta.interpolation.command.shell
+     #        ^^^ meta.string.glob.shell meta.interpolation.command.shell
      #      ^ variable.other.readwrite.shell
      #       ^ keyword.operator.assignment.shell
      #        ^ punctuation.definition.variable.shell
      #         ^ punctuation.section.interpolation.begin.shell
            echo "$glob" |
            sed -e 's@\*@[^ ]*@g' -e 's/\?/[^ ]/g'
-           # <- meta.string.shell meta.interpolation.command.shell meta.function-call.identifier.shell variable.function.shell - string
+           # <- meta.string.glob.shell meta.interpolation.command.shell meta.function-call.identifier.shell variable.function.shell - string
          )
-         # <- meta.string.shell meta.interpolation.command.shell punctuation.section.interpolation.end.shell - string
+         # <- meta.string.glob.shell meta.interpolation.command.shell punctuation.section.interpolation.end.shell - string
          remotefilter="$remotefilter -e '^$glob ' -e ' $glob\$'"
          #          ^ variable.other.readwrite.shell
          #           ^ keyword.operator.assignment.shell
@@ -13343,4 +13343,4 @@ fi
 # <- keyword.control.conditional.endif.shell
 
 curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | POETRY_PREVIEW=1 python
-#         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell string.unquoted.shell
+#         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.glob.shell string.unquoted.shell
diff --git a/ShellScript/Zsh/tests/syntax_test_scope.zsh b/ShellScript/Zsh/tests/syntax_test_scope.zsh
index df24bd0e26..ce0c6748d4 100644
--- a/ShellScript/Zsh/tests/syntax_test_scope.zsh
+++ b/ShellScript/Zsh/tests/syntax_test_scope.zsh
@@ -18,7 +18,7 @@ echo foo | sed 's/foo/bar/'
 #        ^ keyword.operator.assignment.pipe.shell
 #          ^^^^^^^^^^^^^^^^ meta.function-call
 #          ^^^ variable.function.shell
-#              ^^^^^^^^^^^^ meta.string.shell string.quoted.single.shell
+#              ^^^^^^^^^^^^ meta.string.glob.shell string.quoted.single.shell
 
 dmesg &| grep panic &! print yes
 # <- meta.function-call.identifier.shell variable.function.shell
@@ -42,7 +42,7 @@ exec -cl -a argv0
 #   ^^^^^^^^^^^^^ meta.function-call.arguments.shell
 #    ^^^ meta.parameter.option.shell variable.parameter.option.shell
 #        ^^ meta.parameter.option.shell variable.parameter.option.shell
-#           ^^^^^ meta.string.shell string.unquoted.shell
+#           ^^^^^ meta.string.glob.shell string.unquoted.shell
 
 nocorrect cmd
 # <- meta.function-call.identifier.shell support.function.shell
@@ -91,8 +91,8 @@ for name in word1 word2; do echo me; done
 #^^ keyword.control.loop.for.shell
 #   ^^^^ variable.other.readwrite.shell
 #        ^^ keyword.operator.iterator.in.shell
-#           ^^^^^ meta.string.shell string.unquoted.shell
-#                 ^^^^^ meta.string.shell string.unquoted.shell
+#           ^^^^^ meta.string.glob.shell string.unquoted.shell
+#                 ^^^^^ meta.string.glob.shell string.unquoted.shell
 #                      ^ punctuation.terminator.statement.shell
 #                        ^^ keyword.control.loop.do.shell
 #                           ^^^^ meta.function-call.identifier.shell support.function.shell
@@ -168,8 +168,8 @@ select name in word1 word2; do echo $name; done
 #^^^^^ keyword.control.loop.select.shell
 #      ^^^^ variable.other.readwrite.shell
 #           ^^ keyword.operator.iterator.in.shell
-#              ^^^^^ meta.string.shell string.unquoted.shell
-#                    ^^^^^ meta.string.shell string.unquoted.shell
+#              ^^^^^ meta.string.glob.shell string.unquoted.shell
+#                    ^^^^^ meta.string.glob.shell string.unquoted.shell
 #                         ^ punctuation.terminator.statement.shell
 #                           ^^ keyword.control.loop.do.shell
 #                              ^^^^^^^^^^ meta.function-call
@@ -304,7 +304,7 @@ time cmd1 arg | cmd2 -t >1
 #               ^^^^ meta.function-call.identifier.shell
 #                   ^^^^^^ meta.function-call.arguments.shell
 #    ^^^^ variable.function.shell
-#         ^^^ meta.string.shell string.unquoted.shell
+#         ^^^ meta.string.glob.shell string.unquoted.shell
 #             ^ keyword.operator.assignment.pipe.shell
 #               ^^^^ variable.function.shell
 #                    ^^ meta.parameter.option.shell variable.parameter.option.shell
@@ -342,8 +342,8 @@ for name ( word1 $word2 | & ; < > ) print $name
 #   ^^^^ variable.other.readwrite.shell
 #        ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.sequence.list.shell
 #        ^ punctuation.section.sequence.begin.shell
-#          ^^^^^ meta.string.shell string.unquoted.shell
-#                ^^^^^^ meta.string.shell meta.interpolation.parameter.shell variable.other.readwrite.shell
+#          ^^^^^ meta.string.glob.shell string.unquoted.shell
+#                ^^^^^^ meta.string.glob.shell meta.interpolation.parameter.shell variable.other.readwrite.shell
 #                       ^ invalid.illegal.unexpected-token.shell
 #                         ^ invalid.illegal.unexpected-token.shell
 #                           ^ invalid.illegal.unexpected-token.shell
@@ -360,8 +360,8 @@ for name in word1 word2; echo me;
 #^^ keyword.control.loop.for.shell
 #   ^^^^ variable.other.readwrite.shell
 #        ^^ keyword.operator.iterator.in.shell
-#           ^^^^^ meta.string.shell string.unquoted.shell
-#                 ^^^^^ meta.string.shell string.unquoted.shell
+#           ^^^^^ meta.string.glob.shell string.unquoted.shell
+#                 ^^^^^ meta.string.glob.shell string.unquoted.shell
 #                      ^ punctuation.terminator.statement.shell
 #                        ^^^^ meta.function-call.identifier.shell support.function.shell
 #                             ^^ meta.function-call.arguments.shell
@@ -397,8 +397,8 @@ foreach name ( word1 word2 ) echo $name; end
 #       ^^^^ variable.other.readwrite.shell
 #            ^^^^^^^^^^^^^^^ meta.sequence.list.shell.zsh
 #            ^ punctuation.section.sequence.begin.shell.zsh
-#              ^^^^^ meta.string.shell string.unquoted.shell
-#                    ^^^^^ meta.string.shell string.unquoted.shell
+#              ^^^^^ meta.string.glob.shell string.unquoted.shell
+#                    ^^^^^ meta.string.glob.shell string.unquoted.shell
 #                          ^ punctuation.section.sequence.end.shell.zsh
 #                            ^^^^^^^^^^ meta.function-call
 #                            ^^^^ support.function.shell
@@ -417,8 +417,8 @@ foreach \
 #        ^^^^^^^^^^^^^^^ meta.statement.loop.foreach.shell.zsh meta.sequence.list.shell.zsh
 #   ^^^^ variable.other.readwrite.shell
 #        ^ punctuation.section.sequence.begin.shell.zsh
-#          ^^^^^ meta.string.shell string.unquoted.shell
-#                ^^^^^ meta.string.shell string.unquoted.shell
+#          ^^^^^ meta.string.glob.shell string.unquoted.shell
+#                ^^^^^ meta.string.glob.shell string.unquoted.shell
 #                      ^ punctuation.section.sequence.end.shell.zsh
 
 foreach \
@@ -426,8 +426,8 @@ foreach \
     ( word1 word2 ) echo $name; end
 #   ^^^^^^^^^^^^^^^ meta.statement.loop.foreach.shell.zsh meta.sequence.list.shell.zsh
 #   ^ punctuation.section.sequence.begin.shell.zsh
-#     ^^^^^ meta.string.shell string.unquoted.shell
-#           ^^^^^ meta.string.shell string.unquoted.shell
+#     ^^^^^ meta.string.glob.shell string.unquoted.shell
+#           ^^^^^ meta.string.glob.shell string.unquoted.shell
 #                 ^ punctuation.section.sequence.end.shell.zsh
 #                   ^^^^^^^^^^ meta.function-call
 #                   ^^^^ support.function.shell
@@ -441,9 +441,9 @@ foreach \
 #   ^^ meta.statement.loop.foreach.shell.zsh meta.sequence.list.shell.zsh
 #   ^ punctuation.section.sequence.begin.shell.zsh
         word1
-#       ^^^^^ meta.string.shell string.unquoted.shell
+#       ^^^^^ meta.string.glob.shell string.unquoted.shell
         word2
-#       ^^^^^ meta.string.shell string.unquoted.shell
+#       ^^^^^ meta.string.glob.shell string.unquoted.shell
     ) echo $name; end
 #   ^ meta.statement.loop.foreach.shell.zsh meta.sequence.list.shell.zsh punctuation.section.sequence.end.shell.zsh
 #     ^^^^^^^^^^ meta.function-call
@@ -495,8 +495,8 @@ select name in word1 word2; do echo $name; done;
 #^^^^^ keyword.control.loop.select.shell
 #      ^^^^ variable.other.readwrite.shell
 #           ^^ keyword.operator.iterator.in.shell
-#              ^^^^^ meta.string.shell string.unquoted.shell
-#                    ^^^^^ meta.string.shell string.unquoted.shell
+#              ^^^^^ meta.string.glob.shell string.unquoted.shell
+#                    ^^^^^ meta.string.glob.shell string.unquoted.shell
 #                         ^ punctuation.terminator.statement.shell
 #                           ^^ keyword.control.loop.do.shell
 #                              ^^^^^^^^^^ meta.function-call
@@ -515,9 +515,9 @@ case $word {
 #          ^ punctuation.section.block.begin.shell
     pattern | pa*?ern )
 # ^^ meta.statement.conditional.case.body.shell
-#   ^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.shell
+#   ^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.glob.shell
 #          ^^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell - meta.string
-#             ^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.shell
+#             ^^^^^^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell meta.string.glob.shell
 #                    ^^ meta.statement.conditional.case.body.shell meta.clause.patterns.shell - meta.string
 #           ^ keyword.operator.logical.shell
 #               ^ constant.other.wildcard.asterisk.shell
@@ -532,7 +532,7 @@ case $word {
 #                     ^^ punctuation.terminator.clause.shell
 
     ws-+([0-9]).host.com)
-#   ^^^^^^^^^^^^^^^^^^^^ meta.statement.conditional.case.body.shell meta.block.shell.zsh meta.clause.patterns.shell meta.string.shell string.unquoted.shell
+#   ^^^^^^^^^^^^^^^^^^^^ meta.statement.conditional.case.body.shell meta.block.shell.zsh meta.clause.patterns.shell meta.string.glob.shell string.unquoted.shell
 #       ^ meta.group.regexp.shell - meta.set
 #        ^^^^^ meta.group.regexp.shell meta.set.regexp.shell
 #             ^ meta.group.regexp.shell - meta.set
@@ -543,8 +543,8 @@ case $word {
 
     ((foo|bar)baz) cmd arg ;;
 #   ^ meta.clause.patterns.shell - meta.string - string
-#    ^^^^^^^^^ meta.clause.patterns.shell meta.string.shell meta.group.regexp.shell string.unquoted.shell
-#             ^^^ meta.clause.patterns.shell meta.string.shell string.unquoted.shell
+#    ^^^^^^^^^ meta.clause.patterns.shell meta.string.glob.shell meta.group.regexp.shell string.unquoted.shell
+#             ^^^ meta.clause.patterns.shell meta.string.glob.shell string.unquoted.shell
 #                ^ meta.clause.patterns.shell - meta.string - string
 #                 ^ meta.clause.shell
 #                  ^^^^^^^^ meta.clause.body.shell
@@ -554,12 +554,12 @@ case $word {
 #            ^ punctuation.section.group.end.regexp.shell
 #                ^ punctuation.section.patterns.end.shell
 #                  ^^^ variable.function.shell
-#                      ^^^ meta.string.shell string.unquoted.shell
+#                      ^^^ meta.string.glob.shell string.unquoted.shell
 #                          ^^ punctuation.terminator.clause.shell
 
     (foo|bar)baz) cmd arg ;;
-#   ^^^^^^^^^ meta.clause.patterns.shell meta.string.shell meta.group.regexp.shell string.unquoted.shell
-#            ^^^ meta.clause.patterns.shell meta.string.shell string.unquoted.shell
+#   ^^^^^^^^^ meta.clause.patterns.shell meta.string.glob.shell meta.group.regexp.shell string.unquoted.shell
+#            ^^^ meta.clause.patterns.shell meta.string.glob.shell string.unquoted.shell
 #               ^ meta.clause.patterns.shell - meta.string - string
 #                ^ meta.clause.shell
 #                 ^^^^^^^^ meta.clause.body.shell
@@ -568,13 +568,13 @@ case $word {
 #           ^ punctuation.section.group.end.regexp.shell
 #               ^ punctuation.section.patterns.end.shell
 #                 ^^^ variable.function.shell
-#                     ^^^ meta.string.shell string.unquoted.shell
+#                     ^^^ meta.string.glob.shell string.unquoted.shell
 #                         ^^ punctuation.terminator.clause.shell
 
     ( foo | bar ) | baz ) cmd arg ;;
-#   ^^^^^^^^^^^^^ meta.clause.patterns.shell meta.string.shell meta.group.regexp.shell string.unquoted.shell
+#   ^^^^^^^^^^^^^ meta.clause.patterns.shell meta.string.glob.shell meta.group.regexp.shell string.unquoted.shell
 #                ^^^ meta.clause.patterns.shell - meta.string - string
-#                   ^^^ meta.clause.patterns.shell meta.string.shell string.unquoted.shell
+#                   ^^^ meta.clause.patterns.shell meta.string.glob.shell string.unquoted.shell
 #                      ^^ meta.clause.patterns.shell - meta.string - string
 #                        ^ meta.clause.shell
 #                         ^^^^^^^^ meta.clause.body.shell
@@ -582,16 +582,16 @@ case $word {
 #         ^ keyword.operator.alternation.regexp.shell
 #               ^ punctuation.section.group.end.regexp.shell
 #                 ^ keyword.operator.logical.shell
-#                   ^^^ meta.string.shell string.unquoted.shell
+#                   ^^^ meta.string.glob.shell string.unquoted.shell
 #                       ^ punctuation.section.patterns.end.shell
 #                         ^^^ variable.function.shell
-#                             ^^^ meta.string.shell string.unquoted.shell
+#                             ^^^ meta.string.glob.shell string.unquoted.shell
 #                                 ^^ punctuation.terminator.clause.shell
 
     ((foo|bar)baz)
 #   ^ meta.clause.patterns.shell - meta.string - string
-#    ^^^^^^^^^ meta.clause.patterns.shell meta.string.shell meta.group.regexp.shell string.unquoted.shell
-#             ^^^ meta.clause.patterns.shell meta.string.shell string.unquoted.shell
+#    ^^^^^^^^^ meta.clause.patterns.shell meta.string.glob.shell meta.group.regexp.shell string.unquoted.shell
+#             ^^^ meta.clause.patterns.shell meta.string.glob.shell string.unquoted.shell
 #                ^ meta.clause.patterns.shell - meta.string - string
 #                 ^ meta.clause.shell
 #   ^ punctuation.section.patterns.begin.shell
@@ -602,12 +602,12 @@ case $word {
         cmd arg ;;
 #       ^^^^^^^^ meta.clause.body.shell
 #       ^^^ variable.function.shell
-#           ^^^ meta.string.shell string.unquoted.shell
+#           ^^^ meta.string.glob.shell string.unquoted.shell
 #               ^^ punctuation.terminator.clause.shell
 
     (foo|bar)baz)
-#   ^^^^^^^^^ meta.clause.patterns.shell meta.string.shell meta.group.regexp.shell string.unquoted.shell
-#            ^^^ meta.clause.patterns.shell meta.string.shell string.unquoted.shell
+#   ^^^^^^^^^ meta.clause.patterns.shell meta.string.glob.shell meta.group.regexp.shell string.unquoted.shell
+#            ^^^ meta.clause.patterns.shell meta.string.glob.shell string.unquoted.shell
 #               ^ meta.clause.patterns.shell - meta.string - string
 #                ^ meta.clause.shell
 #   ^ punctuation.section.group.begin.regexp.shell
@@ -617,7 +617,7 @@ case $word {
         cmd arg ;;
 #       ^^^^^^^^ meta.clause.body.shell
 #       ^^^ variable.function.shell
-#           ^^^ meta.string.shell string.unquoted.shell
+#           ^^^ meta.string.glob.shell string.unquoted.shell
 #               ^^ punctuation.terminator.clause.shell
 
     ( foo | bar ) \
@@ -625,19 +625,19 @@ case $word {
 #      ^^^^^^^^ meta.clause.patterns.shell
 #              ^ meta.clause.shell
 #       ^ keyword.operator.logical.shell
-#         ^^^ meta.string.shell string.unquoted.shell
+#         ^^^ meta.string.glob.shell string.unquoted.shell
 #             ^ punctuation.section.patterns.end.shell
         cmd arg ;;
 #       ^^^^^^^^ meta.clause.body.shell
 #       ^^^ variable.function.shell
-#           ^^^ meta.string.shell string.unquoted.shell
+#           ^^^ meta.string.glob.shell string.unquoted.shell
 #               ^^ punctuation.terminator.clause.shell
 
     incomplete | pattern
 #  ^ - meta.clause - meta.string - string
-#   ^^^^^^^^^^ meta.clause.patterns.shell meta.string.shell string.unquoted.shell
+#   ^^^^^^^^^^ meta.clause.patterns.shell meta.string.glob.shell string.unquoted.shell
 #             ^^^ meta.clause.patterns.shell - meta.string - string
-#                ^^^^^^^ meta.clause.patterns.shell meta.string.shell string.unquoted.shell
+#                ^^^^^^^ meta.clause.patterns.shell meta.string.glob.shell string.unquoted.shell
 #                       ^ meta.clause.shell - meta.string - string
 }
 # <- meta.statement.conditional.case.body.shell punctuation.section.block.end.shell
@@ -659,7 +659,7 @@ case $word {
 #           ^^^^^^^^^ meta.compound.command.shell
 #^ punctuation.section.compound.begin.shell
 # ^^^ meta.command.shell variable.function.shell
-#     ^^^^^ meta.string.shell string.unquoted.shell
+#     ^^^^^ meta.string.glob.shell string.unquoted.shell
 #          ^ punctuation.section.compound.end.shell
 #            ^^ keyword.operator.logical.shell
 #               ^^^^ constant.language.boolean.true.shell
@@ -670,7 +670,7 @@ stash) || true)
 #^^^^^^^^^^^^^^ - meta.compound.arithmetic
 #^^^^^ meta.compound.command.shell meta.compound.command.shell
 #     ^^^^^^^^^ meta.compound.command.shell
-#^^^^ meta.string.shell string.unquoted.shell
+#^^^^ meta.string.glob.shell string.unquoted.shell
 #    ^ punctuation.section.compound.end.shell
 #      ^^ keyword.operator.logical.shell
 #         ^^^^ constant.language.boolean.true.shell
@@ -710,7 +710,7 @@ stash) || true)
 : < word
 # ^^^^^^ meta.redirection.shell
 # ^ keyword.operator.assignment.redirection.shell
-#   ^^^^ meta.string.shell string.unquoted.shell
+#   ^^^^ meta.string.glob.shell string.unquoted.shell
 
 # Open file word for reading and writing as standard input. If the file does
 # not exist then it is created.
@@ -740,7 +740,7 @@ stash) || true)
 : <> word
 # ^^^^^^^ meta.redirection.shell
 # ^^ keyword.operator.assignment.redirection.shell
-#    ^^^^ meta.string.shell string.unquoted.shell
+#    ^^^^ meta.string.glob.shell string.unquoted.shell
 
 # Open file word for writing as standard output. If the file does not exist
 # then it is created.
@@ -770,13 +770,13 @@ stash) || true)
 : > word >| word >! word
 # ^^^^^^ meta.redirection.shell
 # ^ keyword.operator.assignment.redirection.shell
-#   ^^^^ meta.string.shell string.unquoted.shell
+#   ^^^^ meta.string.glob.shell string.unquoted.shell
 #        ^^^^^^^ meta.redirection.shell
 #        ^^ keyword.operator.assignment.redirection.shell
-#           ^^^^ meta.string.shell string.unquoted.shell
+#           ^^^^ meta.string.glob.shell string.unquoted.shell
 #                ^^^^^^^ meta.redirection.shell
 #                ^^ keyword.operator.assignment.redirection.shell
-#                   ^^^^ meta.string.shell string.unquoted.shell
+#                   ^^^^ meta.string.glob.shell string.unquoted.shell
 
 # Open file word for writing in append mode as standard output. If the file
 # does not exist, and the CLOBBER and APPEND_CREATE options are both unset,
@@ -962,7 +962,7 @@ EOF
 # ^^^ keyword.operator.assignment.herestring
 #     ^^^^ string.unquoted.shell
 #          ^^^^^ meta.parameter.option.shell variable.parameter.option.shell
-#                ^^^^^^^^^^^^^^^^ meta.string.shell
+#                ^^^^^^^^^^^^^^^^ meta.string.glob.shell
 #                ^ variable.language.tilde.shell
 #                  ^^ constant.other.wildcard.asterisk.shell
 #                     ^^^^ meta.set.regexp.shell
@@ -1025,8 +1025,8 @@ cat <<< "This is a \\$here \"\$string.\"" ; cat more stuff | bar | qux
 #                                       ^ punctuation.definition.string.end.shell
 #                                         ^ punctuation.terminator.statement.shell
 #                                           ^^^ variable.function.shell
-#                                               ^^^^ meta.string.shell string.unquoted.shell
-#                                                    ^^^^^ meta.string.shell string.unquoted.shell
+#                                               ^^^^ meta.string.glob.shell string.unquoted.shell
+#                                                    ^^^^^ meta.string.glob.shell string.unquoted.shell
 #                                                          ^ keyword.operator.assignment.pipe.shell
 #                                                            ^^^ variable.function.shell
 #                                                                ^ keyword.operator.assignment.pipe.shell
@@ -1091,7 +1091,7 @@ function name () echo "$0 called with $*!"
 #               ^ meta.function.shell
 #                ^^^^ meta.function.body.shell meta.function-call.identifier.shell
 #                    ^ meta.function.body.shell meta.function-call.arguments.shell
-#                     ^^^^^^^^^^^^^^^^^^^^ meta.function.body.shell meta.function-call.arguments.shell meta.string.shell
+#                     ^^^^^^^^^^^^^^^^^^^^ meta.function.body.shell meta.function-call.arguments.shell meta.string.glob.shell
 #^^^^^^^ keyword.declaration.function.shell
 #        ^^^^ entity.name.function.shell
 #             ^ punctuation.section.parameters.begin.shell
@@ -1177,9 +1177,9 @@ autoload myfunc1 myfunc2
 } this and that
 # <- meta.function-call.shell meta.function.anonymous.body.shell meta.block.shell punctuation.section.block.end.shell
 #^^^^^^^^^^^^^^ meta.function-call.arguments.shell
-# ^^^^ meta.string.shell string.unquoted.shell
-#      ^^^ meta.string.shell string.unquoted.shell
-#          ^^^^ meta.string.shell string.unquoted.shell
+# ^^^^ meta.string.glob.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
+#          ^^^^ meta.string.glob.shell string.unquoted.shell
 
 function {} arg
 # <- meta.function-call.shell meta.function.anonymous.shell keyword.declaration.function.shell
@@ -1190,7 +1190,7 @@ function {} arg
 #^^^^^^^ keyword.declaration.function.shell
 #        ^ punctuation.section.block.begin.shell
 #         ^ punctuation.section.block.end.shell
-#           ^^^ meta.string.shell string.unquoted.shell
+#           ^^^ meta.string.glob.shell string.unquoted.shell
 
 function -U {} arg
 # <- meta.function-call.shell meta.function.anonymous.shell keyword.declaration.function.shell
@@ -1202,7 +1202,7 @@ function -U {} arg
 #        ^^ invalid.illegal.parameter.shell
 #           ^ punctuation.section.block.begin.shell
 #            ^ punctuation.section.block.end.shell
-#              ^^^ meta.string.shell string.unquoted.shell
+#              ^^^ meta.string.glob.shell string.unquoted.shell
 
 function ; {} arg
 # <- meta.function-call.shell meta.function.anonymous.shell keyword.declaration.function.shell
@@ -1214,7 +1214,7 @@ function ; {} arg
 #        ^ punctuation.terminator.statement.shell
 #          ^ punctuation.section.block.begin.shell
 #           ^ punctuation.section.block.end.shell
-#             ^^^ meta.string.shell string.unquoted.shell
+#             ^^^ meta.string.glob.shell string.unquoted.shell
 
 function () {} arg
 # <- meta.function-call.shell meta.function.anonymous.shell keyword.declaration.function.shell
@@ -1229,7 +1229,7 @@ function () {} arg
 #         ^ punctuation.section.parameters.end.shell
 #           ^ punctuation.section.block.begin.shell
 #            ^ punctuation.section.block.end.shell
-#              ^^^ meta.string.shell string.unquoted.shell
+#              ^^^ meta.string.glob.shell string.unquoted.shell
 
 function () ; {} arg
 # <- meta.function-call.shell meta.function.anonymous.shell keyword.declaration.function.shell
@@ -1245,7 +1245,7 @@ function () ; {} arg
 #           ^ punctuation.terminator.statement.shell
 #             ^ punctuation.section.block.begin.shell
 #              ^ punctuation.section.block.end.shell
-#                ^^^ meta.string.shell string.unquoted.shell
+#                ^^^ meta.string.glob.shell string.unquoted.shell
 
 function {
 # <- meta.function-call.shell meta.function.anonymous.shell keyword.declaration.function.shell
@@ -1260,9 +1260,9 @@ function {
 } this and that
 # <- meta.function-call.shell meta.function.anonymous.body.shell meta.block.shell punctuation.section.block.end.shell
 #^^^^^^^^^^^^^^ meta.function-call.arguments.shell
-# ^^^^ meta.string.shell string.unquoted.shell
-#      ^^^ meta.string.shell string.unquoted.shell
-#          ^^^^ meta.string.shell string.unquoted.shell
+# ^^^^ meta.string.glob.shell string.unquoted.shell
+#      ^^^ meta.string.glob.shell string.unquoted.shell
+#          ^^^^ meta.string.glob.shell string.unquoted.shell
 
 
 ###############################################################################
@@ -1453,7 +1453,7 @@ function {
 #                      ^ meta.number.integer.decimal.shell constant.numeric.value.shell
 
 : $(( val = 1 + 2 ))  # aritmetic expansions
-# ^^^^^^^^^^^^^^^^^^ meta.string.shell meta.interpolation.arithmetic.shell
+# ^^^^^^^^^^^^^^^^^^ meta.string.glob.shell meta.interpolation.arithmetic.shell
 # ^ punctuation.definition.variable.shell
 #  ^^ punctuation.section.interpolation.begin.shell
 #     ^^^ variable.other.readwrite.shell
@@ -1464,22 +1464,22 @@ function {
 #                 ^^ punctuation.section.interpolation.end.shell
 
 : ${val:start + 3:len % 5}  # aritmetic evaluation in substitutions
-# ^^^^^^ meta.string.shell meta.interpolation.parameter.shell - meta.arithmetic
-#       ^^^^^^^^^ meta.string.shell meta.interpolation.parameter.shell meta.arithmetic.shell
-#                ^ meta.string.shell meta.interpolation.parameter.shell - meta.arithmetic
-#                 ^^^^^^^ meta.string.shell meta.interpolation.parameter.shell meta.arithmetic.shell
-#                        ^ meta.string.shell meta.interpolation.parameter.shell - meta.arithmetic
+# ^^^^^^ meta.string.glob.shell meta.interpolation.parameter.shell - meta.arithmetic
+#       ^^^^^^^^^ meta.string.glob.shell meta.interpolation.parameter.shell meta.arithmetic.shell
+#                ^ meta.string.glob.shell meta.interpolation.parameter.shell - meta.arithmetic
+#                 ^^^^^^^ meta.string.glob.shell meta.interpolation.parameter.shell meta.arithmetic.shell
+#                        ^ meta.string.glob.shell meta.interpolation.parameter.shell - meta.arithmetic
 
 : -target 20.10.2.4:8080 -port 80
-#         ^^^^^^^^^^^^^^ meta.string.shell string.unquoted.shell
+#         ^^^^^^^^^^^^^^ meta.string.glob.shell string.unquoted.shell
 #                              ^^ meta.number.integer.decimal.shell constant.numeric.value.shell
 
 : -target=20.10.2.4:8080 -port=80
-#         ^^^^^^^^^^^^^^ meta.string.shell string.unquoted.shell
+#         ^^^^^^^^^^^^^^ meta.string.glob.shell string.unquoted.shell
 #                              ^^ meta.number.integer.decimal.shell constant.numeric.value.shell
 
 ip=10.10.20.14
-#  ^^^^^^^^^^^ meta.string.shell string.unquoted.shell
+#  ^^^^^^^^^^^ meta.string.glob.shell string.unquoted.shell
 
 
 ###############################################################################
@@ -2144,7 +2144,7 @@ ip=10.10.20.14
 #                      ^^^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.parameter.shell variable.other.readwrite.shell
 #                         ^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh meta.quoted.glob.shell.zsh
 #                          ^ meta.interpolation.parameter.shell meta.modifier.expansion.shell.zsh - meta.quoted.glob
-#                           ^^^^ meta.function-call.arguments.shell meta.string.shell meta.interpolation.parameter.shell - meta.modifier.expansion
+#                           ^^^^ meta.function-call.arguments.shell meta.string.glob.shell meta.interpolation.parameter.shell - meta.modifier.expansion
 #                               ^ - meta.interpolation
 # ^ punctuation.definition.variable.shell
 #  ^ punctuation.section.interpolation.begin.shell
@@ -2466,7 +2466,7 @@ ip=10.10.20.14
 #  ^ punctuation.section.interpolation.begin.shell
 #   ^^^ variable.other.readwrite.shell
 #      ^^ keyword.operator.assignment.shell
-#        ^^^ meta.string.shell string.unquoted.shell
+#        ^^^ meta.string.glob.shell string.unquoted.shell
 #           ^ punctuation.section.interpolation.end.shell
 
 : ${var/p/r}     # One occurrence of p replaced by r
@@ -2477,7 +2477,7 @@ ip=10.10.20.14
 #      ^ keyword.operator.substitution.shell
 #       ^ meta.string.regexp.shell string.unquoted.shell
 #        ^ keyword.operator.substitution.shell
-#         ^ meta.string.shell string.unquoted.shell
+#         ^ meta.string.glob.shell string.unquoted.shell
 #          ^ punctuation.section.interpolation.end.shell
 
 : ${var//p/r}    # All occurrences of p replaced by r
@@ -2488,7 +2488,7 @@ ip=10.10.20.14
 #      ^^ keyword.operator.substitution.shell
 #        ^ meta.string.regexp.shell string.unquoted.shell
 #         ^ keyword.operator.substitution.shell
-#          ^ meta.string.shell string.unquoted.shell
+#          ^ meta.string.glob.shell string.unquoted.shell
 #           ^ punctuation.section.interpolation.end.shell
 
 : ${${var%p}#q}  # Apply %p then #q to $var
@@ -2518,7 +2518,7 @@ ip=10.10.20.14
 #    ^ keyword.operator.substitution.shell
 #     ^^^ meta.string.regexp.shell
 #        ^ keyword.operator.substitution.shell
-#         ^^^ meta.string.shell string.unquoted.shell
+#         ^^^ meta.string.glob.shell string.unquoted.shell
 #            ^ punctuation.section.interpolation.end.shell
 #             ^ - meta
 
@@ -2530,7 +2530,7 @@ ip=10.10.20.14
 #    ^ keyword.operator.substitution.shell
 #     ^^^ meta.string.regexp.shell
 #        ^ keyword.operator.substitution.shell
-#         ^^^ meta.string.shell string.unquoted.shell
+#         ^^^ meta.string.glob.shell string.unquoted.shell
 #            ^ punctuation.section.interpolation.end.shell
 #             ^ - meta
 
@@ -2542,7 +2542,7 @@ ip=10.10.20.14
 #    ^ keyword.operator.substitution.shell
 #     ^^^ meta.string.regexp.shell
 #        ^ keyword.operator.substitution.shell
-#         ^^^ meta.string.shell string.unquoted.shell
+#         ^^^ meta.string.glob.shell string.unquoted.shell
 #            ^ punctuation.section.interpolation.end.shell
 #             ^ - meta
 
@@ -2554,7 +2554,7 @@ ip=10.10.20.14
 #    ^ keyword.operator.substitution.shell
 #     ^^^ meta.string.regexp.shell
 #        ^ keyword.operator.substitution.shell
-#         ^^^ meta.string.shell string.unquoted.shell
+#         ^^^ meta.string.glob.shell string.unquoted.shell
 #            ^ punctuation.section.interpolation.end.shell
 #             ^ - meta
 
@@ -2566,7 +2566,7 @@ ip=10.10.20.14
 #    ^ keyword.operator.substitution.shell
 #     ^^^ meta.string.regexp.shell
 #        ^ keyword.operator.substitution.shell
-#         ^^^ meta.string.shell string.unquoted.shell
+#         ^^^ meta.string.glob.shell string.unquoted.shell
 #            ^ punctuation.section.interpolation.end.shell
 #             ^ - meta
 
@@ -2578,7 +2578,7 @@ ip=10.10.20.14
 #    ^ keyword.operator.substitution.shell
 #     ^^^ meta.string.regexp.shell
 #        ^ keyword.operator.substitution.shell
-#         ^^^ meta.string.shell string.unquoted.shell
+#         ^^^ meta.string.glob.shell string.unquoted.shell
 #            ^ punctuation.section.interpolation.end.shell
 #             ^ - meta
 
@@ -2590,7 +2590,7 @@ ip=10.10.20.14
 #    ^ keyword.operator.substitution.shell
 #     ^^^ meta.string.regexp.shell
 #        ^ keyword.operator.substitution.shell
-#         ^^^ meta.string.shell string.unquoted.shell
+#         ^^^ meta.string.glob.shell string.unquoted.shell
 #            ^ punctuation.section.interpolation.end.shell
 #             ^ - meta
 
@@ -2602,7 +2602,7 @@ ip=10.10.20.14
 #    ^ keyword.operator.substitution.shell
 #     ^^^ meta.string.regexp.shell
 #        ^ keyword.operator.substitution.shell
-#         ^^^ meta.string.shell string.unquoted.shell
+#         ^^^ meta.string.glob.shell string.unquoted.shell
 #            ^ punctuation.section.interpolation.end.shell
 #             ^ - meta
 
@@ -2614,7 +2614,7 @@ ip=10.10.20.14
 #      ^ keyword.operator.substitution.shell
 #       ^^^ meta.string.regexp.shell
 #          ^ keyword.operator.substitution.shell
-#           ^^^ meta.string.shell string.unquoted.shell
+#           ^^^ meta.string.glob.shell string.unquoted.shell
 #              ^ punctuation.section.interpolation.end.shell
 #               ^ - meta
 
@@ -2627,7 +2627,7 @@ ip=10.10.20.14
 #       ^ keyword.operator.substitution.shell
 #        ^^^ meta.string.regexp.shell
 #           ^ keyword.operator.substitution.shell
-#            ^^^ meta.string.shell string.unquoted.shell
+#            ^^^ meta.string.glob.shell string.unquoted.shell
 #               ^ punctuation.section.interpolation.end.shell
 #                ^ - meta
 
@@ -2640,7 +2640,7 @@ ip=10.10.20.14
 #       ^ keyword.operator.substitution.shell
 #        ^^^ meta.string.regexp.shell
 #           ^ keyword.operator.substitution.shell
-#            ^^^ meta.string.shell string.unquoted.shell
+#            ^^^ meta.string.glob.shell string.unquoted.shell
 #               ^ punctuation.section.interpolation.end.shell
 #                ^ - meta
 
@@ -2655,7 +2655,7 @@ ip=10.10.20.14
 #         ^ keyword.operator.substitution.shell
 #          ^^^ meta.string.regexp.shell
 #             ^ keyword.operator.substitution.shell
-#              ^^^ meta.string.shell string.unquoted.shell
+#              ^^^ meta.string.glob.shell string.unquoted.shell
 #                 ^ punctuation.section.interpolation.end.shell
 #                  ^ - meta
 
@@ -2670,7 +2670,7 @@ ip=10.10.20.14
 #         ^ keyword.operator.substitution.shell
 #          ^^^ meta.string.regexp.shell
 #             ^ keyword.operator.substitution.shell
-#              ^^^ meta.string.shell string.unquoted.shell
+#              ^^^ meta.string.glob.shell string.unquoted.shell
 #                 ^ punctuation.section.interpolation.end.shell
 #                  ^ - meta
 
@@ -2919,7 +2919,7 @@ a\/b/c/d}
 #      ^^ keyword.operator.substitution.shell
 #        ^^^ meta.string.regexp.shell string.unquoted.shell - keyword - punctuation
 #           ^ keyword.operator.substitution.shell
-#            ^^^^ meta.string.shell string.unquoted.shell - keyword - punctuation
+#            ^^^^ meta.string.glob.shell string.unquoted.shell - keyword - punctuation
 #                ^ punctuation.section.interpolation.end.shell
 
 : ${var//f&o/b&ar}  # `&` has no meaing in patterns or replacement strings
@@ -2927,7 +2927,7 @@ a\/b/c/d}
 #      ^^ keyword.operator.substitution.shell
 #        ^^^ meta.string.regexp.shell string.unquoted.shell - keyword - punctuation
 #           ^ keyword.operator.substitution.shell
-#            ^^^^ meta.string.shell string.unquoted.shell - keyword - punctuation
+#            ^^^^ meta.string.glob.shell string.unquoted.shell - keyword - punctuation
 #                ^ punctuation.section.interpolation.end.shell
 
 : ${var//f>o/b>ar}  # `>` has no meaing in patterns or replacement strings
@@ -2935,7 +2935,7 @@ a\/b/c/d}
 #      ^^ keyword.operator.substitution.shell
 #        ^^^ meta.string.regexp.shell string.unquoted.shell - keyword - punctuation
 #           ^ keyword.operator.substitution.shell
-#            ^^^^ meta.string.shell string.unquoted.shell - keyword - punctuation
+#            ^^^^ meta.string.glob.shell string.unquoted.shell - keyword - punctuation
 #                ^ punctuation.section.interpolation.end.shell
 
 : ${var//f) /(:F{1+p}) /(:F[1+p]) /(:F(1+p)) /(:F:1+p:)
-#  ^^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#  ^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #     ^^^^^ meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
-#          ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#          ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #  ^ punctuation.definition.modifier.begin.shell.zsh
 #   ^ punctuation.separator.sequence.shell.zsh
 #    ^ storage.modifier.glob.shell.zsh
@@ -3662,9 +3662,9 @@ any --arg{1,2,3} ={1,2,3}
 #         ^ punctuation.definition.quoted.end.shell.zsh
 #          ^ punctuation.definition.modifier.end.shell.zsh
 #           ^ - meta.string - meta.modifier
-#             ^^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#             ^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                ^^^^^ meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
-#                     ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                     ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #             ^ punctuation.definition.modifier.begin.shell.zsh
 #              ^ punctuation.separator.sequence.shell.zsh
 #               ^ storage.modifier.glob.shell.zsh
@@ -3673,9 +3673,9 @@ any --arg{1,2,3} ={1,2,3}
 #                    ^ punctuation.definition.quoted.end.shell.zsh
 #                     ^ punctuation.definition.modifier.end.shell.zsh
 #                      ^ - meta.string - meta.modifier
-#                        ^^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                        ^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                           ^^^^^ meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
-#                                ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                        ^ punctuation.definition.modifier.begin.shell.zsh
 #                         ^ punctuation.separator.sequence.shell.zsh
 #                          ^ storage.modifier.glob.shell.zsh
@@ -3684,9 +3684,9 @@ any --arg{1,2,3} ={1,2,3}
 #                               ^ punctuation.definition.quoted.end.shell.zsh
 #                                ^ punctuation.definition.modifier.end.shell.zsh
 #                                 ^ - meta.string - meta.modifier
-#                                   ^^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                   ^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                                      ^^^^^ meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
-#                                           ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                           ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                                   ^ punctuation.definition.modifier.begin.shell.zsh
 #                                    ^ punctuation.separator.sequence.shell.zsh
 #                                     ^ storage.modifier.glob.shell.zsh
@@ -3695,9 +3695,9 @@ any --arg{1,2,3} ={1,2,3}
 #                                          ^ punctuation.definition.quoted.end.shell.zsh
 #                                           ^ punctuation.definition.modifier.end.shell.zsh
 #                                            ^ - meta.string - meta.modifier
-#                                              ^^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                              ^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                                                 ^^^^^ meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
-#                                                      ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                                      ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                                              ^ punctuation.definition.modifier.begin.shell.zsh
 #                                               ^ punctuation.separator.sequence.shell.zsh
 #                                                ^ storage.modifier.glob.shell.zsh
@@ -3706,9 +3706,9 @@ any --arg{1,2,3} ={1,2,3}
 #                                                     ^ punctuation.definition.quoted.end.shell.zsh
 #                                                      ^ punctuation.definition.modifier.end.shell.zsh
 #                                                       ^ - meta.string - meta.modifier
-#                                                         ^^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                                         ^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                                                            ^^^^^ meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
-#                                                                 ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                                                 ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                                                         ^ punctuation.definition.modifier.begin.shell.zsh
 #                                                          ^ punctuation.separator.sequence.shell.zsh
 #                                                           ^ storage.modifier.glob.shell.zsh
@@ -3719,7 +3719,7 @@ any --arg{1,2,3} ={1,2,3}
 #                                                                  ^ - meta.string - meta.modifier
 
 : /(:w) # Makes the immediately following modifier work on each word in the string.
-#  ^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#  ^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #  ^ punctuation.definition.modifier.begin.shell.zsh
 #   ^ punctuation.separator.sequence.shell.zsh
 #    ^ storage.modifier.glob.shell.zsh
@@ -3727,9 +3727,9 @@ any --arg{1,2,3} ={1,2,3}
 
 # Like w but words are considered to be the parts of the string that are separated by sep.
 : /(:W"sep") /(:W) /(:W{sep}) /(:W[sep]) /(:W(sep)) /(:W:sep:)
-#  ^^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#  ^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #     ^^^^^ meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
-#          ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#          ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #  ^ punctuation.definition.modifier.begin.shell.zsh
 #   ^ punctuation.separator.sequence.shell.zsh
 #    ^ storage.modifier.glob.shell.zsh
@@ -3738,9 +3738,9 @@ any --arg{1,2,3} ={1,2,3}
 #         ^ punctuation.definition.quoted.end.shell.zsh
 #          ^ punctuation.definition.modifier.end.shell.zsh
 #           ^ - meta.string - meta.modifier
-#             ^^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#             ^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                ^^^^^ meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
-#                     ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                     ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #             ^ punctuation.definition.modifier.begin.shell.zsh
 #              ^ punctuation.separator.sequence.shell.zsh
 #               ^ storage.modifier.glob.shell.zsh
@@ -3749,9 +3749,9 @@ any --arg{1,2,3} ={1,2,3}
 #                    ^ punctuation.definition.quoted.end.shell.zsh
 #                     ^ punctuation.definition.modifier.end.shell.zsh
 #                      ^ - meta.string - meta.modifier
-#                        ^^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                        ^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                           ^^^^^ meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
-#                                ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                        ^ punctuation.definition.modifier.begin.shell.zsh
 #                         ^ punctuation.separator.sequence.shell.zsh
 #                          ^ storage.modifier.glob.shell.zsh
@@ -3760,9 +3760,9 @@ any --arg{1,2,3} ={1,2,3}
 #                               ^ punctuation.definition.quoted.end.shell.zsh
 #                                ^ punctuation.definition.modifier.end.shell.zsh
 #                                 ^ - meta.string - meta.modifier
-#                                   ^^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                   ^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                                      ^^^^^ meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
-#                                           ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                           ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                                   ^ punctuation.definition.modifier.begin.shell.zsh
 #                                    ^ punctuation.separator.sequence.shell.zsh
 #                                     ^ storage.modifier.glob.shell.zsh
@@ -3771,9 +3771,9 @@ any --arg{1,2,3} ={1,2,3}
 #                                          ^ punctuation.definition.quoted.end.shell.zsh
 #                                           ^ punctuation.definition.modifier.end.shell.zsh
 #                                            ^ - meta.string - meta.modifier
-#                                              ^^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                              ^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                                                 ^^^^^ meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
-#                                                      ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                                      ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                                              ^ punctuation.definition.modifier.begin.shell.zsh
 #                                               ^ punctuation.separator.sequence.shell.zsh
 #                                                ^ storage.modifier.glob.shell.zsh
@@ -3782,9 +3782,9 @@ any --arg{1,2,3} ={1,2,3}
 #                                                     ^ punctuation.definition.quoted.end.shell.zsh
 #                                                      ^ punctuation.definition.modifier.end.shell.zsh
 #                                                       ^ - meta.string - meta.modifier
-#                                                         ^^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                                         ^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                                                            ^^^^^ meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
-#                                                                 ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                                                 ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                                                         ^ punctuation.definition.modifier.begin.shell.zsh
 #                                                          ^ punctuation.separator.sequence.shell.zsh
 #                                                           ^ storage.modifier.glob.shell.zsh
@@ -3859,23 +3859,23 @@ any --arg{1,2,3} ={1,2,3}
 # 14.7.1 Dynamic named directories
 
 : ~[...]/
-# ^ meta.string.shell meta.interpolation.tilde.shell - meta.brackets - meta.interpolation meta.function-call
-#  ^ meta.string.shell meta.interpolation.tilde.shell meta.brackets - meta.interpolation meta.function-call
-#   ^^^ meta.string.shell meta.interpolation.tilde.shell meta.brackets.shell.zsh meta.function-call.identifier.shell.zsh variable.function.shell.zsh
-#      ^ meta.string.shell meta.interpolation.tilde.shell meta.brackets - meta.interpolation meta.function-call
+# ^ meta.string.glob.shell meta.interpolation.tilde.shell - meta.brackets - meta.interpolation meta.function-call
+#  ^ meta.string.glob.shell meta.interpolation.tilde.shell meta.brackets - meta.interpolation meta.function-call
+#   ^^^ meta.string.glob.shell meta.interpolation.tilde.shell meta.brackets.shell.zsh meta.function-call.identifier.shell.zsh variable.function.shell.zsh
+#      ^ meta.string.glob.shell meta.interpolation.tilde.shell meta.brackets - meta.interpolation meta.function-call
 # ^ variable.language.tilde.shell
 #  ^ punctuation.section.brackets.begin.shell.zsh - variable variable
 #   ^^^ variable.function.shell.zsh - variable variable
 #      ^ punctuation.section.brackets.end.shell.zsh - variable variable
 
 : ~[dyn_${dir}_name]/
-# ^ meta.string.shell meta.interpolation.tilde.shell - meta.interpolation meta.function-call
-#  ^ meta.string.shell meta.interpolation.tilde.shell meta.brackets - meta.interpolation meta.function-call
-#   ^^^^ meta.function-call.arguments.shell meta.string.shell meta.interpolation.tilde.shell meta.brackets.shell.zsh meta.function-call.identifier.shell.zsh - meta.interpolation.parameter
-#       ^^^^^^ meta.string.shell meta.interpolation.tilde.shell meta.brackets.shell.zsh meta.function-call.identifier.shell.zsh meta.interpolation.parameter.shell
-#             ^^^^^ meta.function-call.arguments.shell meta.string.shell meta.interpolation.tilde.shell meta.brackets.shell.zsh meta.function-call.identifier.shell.zsh - meta.interpolation.parameter
-#                  ^ meta.string.shell meta.interpolation.tilde.shell meta.brackets - meta.interpolation meta.function-call
-#                   ^ meta.string.shell string.unquoted.shell - meta.interpolation
+# ^ meta.string.glob.shell meta.interpolation.tilde.shell - meta.interpolation meta.function-call
+#  ^ meta.string.glob.shell meta.interpolation.tilde.shell meta.brackets - meta.interpolation meta.function-call
+#   ^^^^ meta.function-call.arguments.shell meta.string.glob.shell meta.interpolation.tilde.shell meta.brackets.shell.zsh meta.function-call.identifier.shell.zsh - meta.interpolation.parameter
+#       ^^^^^^ meta.string.glob.shell meta.interpolation.tilde.shell meta.brackets.shell.zsh meta.function-call.identifier.shell.zsh meta.interpolation.parameter.shell
+#             ^^^^^ meta.function-call.arguments.shell meta.string.glob.shell meta.interpolation.tilde.shell meta.brackets.shell.zsh meta.function-call.identifier.shell.zsh - meta.interpolation.parameter
+#                  ^ meta.string.glob.shell meta.interpolation.tilde.shell meta.brackets - meta.interpolation meta.function-call
+#                   ^ meta.string.glob.shell string.unquoted.shell - meta.interpolation
 # ^ variable.language.tilde.shell
 #  ^ punctuation.section.brackets.begin.shell.zsh - variable variable
 #   ^^^^ variable.function.shell.zsh - variable variable
@@ -3923,9 +3923,9 @@ dyn_dir_name() {
 # <- meta.function-call.identifier.shell meta.command.shell meta.interpolation.tilde.shell variable.language.tilde.shell
 #^^^^^^^ meta.function-call.identifier.shell meta.command.shell meta.interpolation.tilde.shell constant.other.username.shell
 #       ^ meta.function-call.identifier.shell meta.command.shell variable.function.shell punctuation.separator.path.shell
-#         ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell
-#          ^^^^^^^ meta.string.shell meta.interpolation.tilde.shell constant.other.username.shell - variable
-#                 ^ meta.string.shell - meta.interpolation
+#         ^ meta.string.glob.shell meta.interpolation.tilde.shell variable.language.tilde.shell
+#          ^^^^^^^ meta.string.glob.shell meta.interpolation.tilde.shell constant.other.username.shell - variable
+#                 ^ meta.string.glob.shell - meta.interpolation
 
 ~n_${a-m}.e/ ~n_${a-m}.e/
 # <- meta.function-call.identifier.shell meta.command.shell meta.interpolation.tilde.shell variable.language.tilde.shell - variable.function
@@ -3933,18 +3933,18 @@ dyn_dir_name() {
 #  ^^^^^^ meta.function-call.identifier.shell meta.command.shell meta.interpolation.tilde.shell meta.interpolation.parameter.shell
 #        ^^ meta.function-call.identifier.shell meta.command.shell meta.interpolation.tilde.shell constant.other.username.shell
 #          ^ meta.function-call.identifier.shell meta.command.shell variable.function.shell punctuation.separator.path.shell
-#            ^ meta.string.shell meta.interpolation.tilde.shell variable.language.tilde.shell
-#             ^^ meta.string.shell meta.interpolation.tilde.shell constant.other.username.shell - variable
-#               ^^^^^^ meta.string.shell meta.interpolation.tilde.shell meta.interpolation.parameter.shell
-#                     ^^ meta.string.shell meta.interpolation.tilde.shell constant.other.username.shell - variable
-#                       ^ meta.string.shell - meta.interpolation
+#            ^ meta.string.glob.shell meta.interpolation.tilde.shell variable.language.tilde.shell
+#             ^^ meta.string.glob.shell meta.interpolation.tilde.shell constant.other.username.shell - variable
+#               ^^^^^^ meta.string.glob.shell meta.interpolation.tilde.shell meta.interpolation.parameter.shell
+#                     ^^ meta.string.glob.shell meta.interpolation.tilde.shell constant.other.username.shell - variable
+#                       ^ meta.string.glob.shell - meta.interpolation
 
 # 14.7.3 ‘=’ expansion
 
 =command =command
 # <- meta.function-call.identifier.shell meta.command.shell variable.function.shell punctuation.definition.expansion.shell.zsh
 #^^^^^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
-#        ^^^^^^^^ meta.function-call.arguments.shell meta.string.shell string.unquoted.shell
+#        ^^^^^^^^ meta.function-call.arguments.shell meta.string.glob.shell string.unquoted.shell
 #        ^ punctuation.definition.expansion.shell
 
 
@@ -4071,7 +4071,7 @@ dyn_dir_name() {
 #         ^^ punctuation.definition.set.end.regexp.shell
 
 : [^.][!\ ] # Like [...], except that it matches any character which is not in the given set.
-# ^^^^^^^^^ meta.string.shell string.unquoted.shell meta.set.regexp.shell
+# ^^^^^^^^^ meta.string.glob.shell string.unquoted.shell meta.set.regexp.shell
 # ^ punctuation.definition.set.begin.regexp.shell
 #  ^ keyword.operator.logical.regexp.shell
 #    ^ punctuation.definition.set.end.regexp.shell
@@ -4162,100 +4162,100 @@ dyn_dir_name() {
 #                                  ^ punctuation.definition.range.end.shell.zsh
 
 : foo<5-21> foo<5-21>bar <5-21>bar  1<1-5>0 <1-5>0 <0  # not numbers, but a patterns
-# ^ meta.string.shell string.unquoted.shell - meta.range
-#  ^^^^^ meta.string.shell meta.range.shell.zsh - string
+# ^ meta.string.glob.shell string.unquoted.shell - meta.range
+#  ^^^^^ meta.string.glob.shell meta.range.shell.zsh - string
 #       ^ - meta.range meta.string - string
-#        ^ meta.string.shell string.unquoted.shell - meta.range
-#         ^^^^^ meta.string.shell meta.range.shell.zsh - string
-#              ^ meta.string.shell string.unquoted.shell - meta.range
+#        ^ meta.string.glob.shell string.unquoted.shell - meta.range
+#         ^^^^^ meta.string.glob.shell meta.range.shell.zsh - string
+#              ^ meta.string.glob.shell string.unquoted.shell - meta.range
 #               ^ - meta.range meta.string - string
-#                ^^^^^ meta.string.shell meta.range.shell.zsh - string
-#                     ^ meta.string.shell string.unquoted.shell - meta.range
+#                ^^^^^ meta.string.glob.shell meta.range.shell.zsh - string
+#                     ^ meta.string.glob.shell string.unquoted.shell - meta.range
 #                       ^ meta.redirection.shell keyword.operator.assignment.redirection.shell
 #                        ^ meta.redirection.shell meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell
 
 : (<1-5>foo|bar<1-)<1-5>  # glob ranges in pattern groups
-# ^ meta.string.shell meta.group.regexp.shell string.unquoted.shell punctuation.section.group.begin.regexp.shell
-#  ^^^^^ meta.string.shell meta.group.regexp.shell meta.range.shell.zsh - string
-#       ^^^^^^^ meta.string.shell meta.group.regexp.shell string.unquoted.shell - meta.range
+# ^ meta.string.glob.shell meta.group.regexp.shell string.unquoted.shell punctuation.section.group.begin.regexp.shell
+#  ^^^^^ meta.string.glob.shell meta.group.regexp.shell meta.range.shell.zsh - string
+#       ^^^^^^^ meta.string.glob.shell meta.group.regexp.shell string.unquoted.shell - meta.range
 #              ^^^ meta.redirection.shell
 #                 ^ invalid.illegal.stray.shell
-#                  ^^^^^ meta.string.shell meta.range.shell.zsh - string
+#                  ^^^^^ meta.string.glob.shell meta.range.shell.zsh - string
 
 ## glob ranges in parameter assignments
 
 a=<1-4>foo  # glob range beginning assignment value
 # <- meta.assignment.l-value.shell variable.other.readwrite.shell
 #^ meta.assignment.shell keyword.operator.assignment.shell
-# ^^^^^ meta.assignment.r-value.shell meta.string.shell meta.range.shell.zsh - string
-#      ^^^ meta.assignment.r-value.shell meta.string.shell string.unquoted.shell - meta.range
+# ^^^^^ meta.assignment.r-value.shell meta.string.glob.shell meta.range.shell.zsh - string
+#      ^^^ meta.assignment.r-value.shell meta.string.glob.shell string.unquoted.shell - meta.range
 
 a=foo<1-4>bar  # glob range within assignment value
 # <- meta.assignment.l-value.shell variable.other.readwrite.shell
 #^ meta.assignment.shell keyword.operator.assignment.shell
-# ^^^ meta.assignment.r-value.shell meta.string.shell string.unquoted.shell - meta.range
-#    ^^^^^ meta.assignment.r-value.shell meta.string.shell meta.range.shell.zsh - string
-#         ^^^ meta.assignment.r-value.shell meta.string.shell string.unquoted.shell - meta.range
+# ^^^ meta.assignment.r-value.shell meta.string.glob.shell string.unquoted.shell - meta.range
+#    ^^^^^ meta.assignment.r-value.shell meta.string.glob.shell meta.range.shell.zsh - string
+#         ^^^ meta.assignment.r-value.shell meta.string.glob.shell string.unquoted.shell - meta.range
 
 a=foo<1-4>foofoo [foo]=<3-4>bar [buz]=s(<5-6>uf) <10-foo ^~or)  # glob ranges within indexed or associative arrays
 # <- meta.assignment.l-value.shell variable.other.readwrite.shell
 #^ meta.assignment.shell keyword.operator.assignment.shell
 # ^ meta.assignment.r-value.shell meta.sequence.list.shell - meta.string
-#  ^^^^^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.shell meta.range.shell.zsh
-#       ^^^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.shell string.unquoted.shell
+#  ^^^^^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.glob.shell meta.range.shell.zsh
+#       ^^^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.glob.shell string.unquoted.shell
 #          ^^^^^^^ meta.assignment.r-value.shell meta.sequence.list.shell - meta.string meta.item-access.shell
-#                 ^^^^^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.shell meta.range.shell.zsh - string
-#                      ^^^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.shell string.unquoted.shell
+#                 ^^^^^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.glob.shell meta.range.shell.zsh - string
+#                      ^^^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.glob.shell string.unquoted.shell
 #                         ^ meta.assignment.r-value.shell meta.sequence.list.shell - meta.string
 #                          ^^^^^^ meta.assignment.r-value.shell meta.sequence.list.shell
-#                                ^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.shell - meta.group
-#                                 ^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.shell meta.group.regexp.shell - meta.range
-#                                  ^^^^^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.shell meta.group.regexp.shell meta.range.shell.zsh - string
-#                                       ^^^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.shell meta.group.regexp.shell - meta.range
+#                                ^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.glob.shell - meta.group
+#                                 ^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.glob.shell meta.group.regexp.shell - meta.range
+#                                  ^^^^^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.glob.shell meta.group.regexp.shell meta.range.shell.zsh - string
+#                                       ^^^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.glob.shell meta.group.regexp.shell - meta.range
 #                                          ^ meta.assignment.r-value.shell meta.sequence.list.shell - meta.string
 #                                           ^ meta.assignment.r-value.shell meta.sequence.list.shell invalid.illegal.unexpected-token.shell.zsh
-#                                            ^^^^^^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.shell string.unquoted.shell
-#                                                   ^^^^^^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.shell
+#                                            ^^^^^^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.glob.shell string.unquoted.shell
+#                                                   ^^^^^^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.glob.shell
 #                                                   ^ keyword.operator.logical.regexp.shell.zsh
 #                                                    ^ variable.language.tilde.shell
 #                                                     ^ invalid.illegal.unexpected-token.shell.zsh
 #                                                      ^^^ string.unquoted.shell
 #                                                         ^ meta.assignment.r-value.shell meta.sequence.list.shell invalid.illegal.unexpected-token.shell
-#                                                          ^^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.shell string.unquoted.shell
+#                                                          ^^ meta.assignment.r-value.shell meta.sequence.list.shell meta.string.glob.shell string.unquoted.shell
 #                                                            ^ meta.assignment.r-value.shell meta.sequence.list.shell punctuation.section.sequence.end.shell
 
 declare -A a=(key <1-2>value key <1-2ill key ^~or)  # glob ranges within associative arrays
 #            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.assignment.r-value.shell meta.sequence.list.shell
 #             ^^^ entity.name.key.shell
-#                 ^^^^^ meta.string.shell meta.range.shell.zsh - string
-#                      ^^^^^ meta.string.shell string.unquoted.shell
+#                 ^^^^^ meta.string.glob.shell meta.range.shell.zsh - string
+#                      ^^^^^ meta.string.glob.shell string.unquoted.shell
 #                            ^^^ entity.name.key.shell
 #                                ^ invalid.illegal.unexpected-token.shell.zsh
-#                                 ^^^^^^ meta.string.shell string.unquoted.shell
+#                                 ^^^^^^ meta.string.glob.shell string.unquoted.shell
 #                                        ^^^ entity.name.key.shell
-#                                            ^^^^^^ meta.string.shell
+#                                            ^^^^^^ meta.string.glob.shell
 #                                            ^ keyword.operator.logical.regexp.shell.zsh
 #                                             ^ variable.language.tilde.shell
 #                                              ^ invalid.illegal.unexpected-token.shell.zsh
@@ -4268,23 +4268,23 @@ declare -A a=(key <1-2>value key <1-2ill key ^~or)  # glob ranges within as
 case $foo in
   <1-2>pat | pat<1-2> | <-a>ny ) ;;
 # ^^^^^^^^^^^^^^^^^^^^ meta.clause.patterns.shell
-# ^^^^^ meta.string.shell meta.range.shell.zsh - string
-#      ^^^ meta.string.shell string.unquoted.shell - meta.range
+# ^^^^^ meta.string.glob.shell meta.range.shell.zsh - string
+#      ^^^ meta.string.glob.shell string.unquoted.shell - meta.range
 #          ^ keyword.operator.logical.shell
-#            ^^^ meta.string.shell string.unquoted.shell - meta.range
-#               ^^^^^ meta.string.shell meta.range.shell.zsh - string
+#            ^^^ meta.string.glob.shell string.unquoted.shell - meta.range
+#               ^^^^^ meta.string.glob.shell meta.range.shell.zsh - string
 #                     ^ keyword.operator.logical.shell
 #                       ^^^^^^^^ - meta.range
 #                       ^ invalid.illegal.unexpected-token.shell
-#                        ^^ meta.string.shell string.unquoted.shell
+#                        ^^ meta.string.glob.shell string.unquoted.shell
 #                          ^ invalid.illegal.unexpected-token.shell
-#                           ^^ meta.string.shell string.unquoted.shell
+#                           ^^ meta.string.glob.shell string.unquoted.shell
 
   (<1-2>|<-) | foo<1-2> | <- ) ;;
-# ^ meta.clause.patterns.shell meta.string.shell meta.group.regexp.shell - meta.range
-#  ^^^^^ meta.clause.patterns.shell meta.string.shell meta.group.regexp.shell meta.range.shell.zsh
-#       ^ meta.clause.patterns.shell meta.string.shell meta.group.regexp.shell - meta.range
-#        ^^ meta.clause.patterns.shell meta.string.shell - meta.group
+# ^ meta.clause.patterns.shell meta.string.glob.shell meta.group.regexp.shell - meta.range
+#  ^^^^^ meta.clause.patterns.shell meta.string.glob.shell meta.group.regexp.shell meta.range.shell.zsh
+#       ^ meta.clause.patterns.shell meta.string.glob.shell meta.group.regexp.shell - meta.range
+#        ^^ meta.clause.patterns.shell meta.string.glob.shell - meta.group
 #          ^ meta.clause.patterns.shell - meta.string
 #           ^ meta.clause.shell - meta.clause.patterns
 #            ^^^^^^^^^^^^^^^^^^ meta.clause.body.shell
@@ -4372,29 +4372,29 @@ esac
 ## no glob ranges
 
 : 'foo<5-21>bar'
-# ^^^^^^^^^^^^^^ meta.string.shell string.quoted.single.shell - meta.redirection - meta.range
+# ^^^^^^^^^^^^^^ meta.string.glob.shell string.quoted.single.shell - meta.redirection - meta.range
 
 : "foo<5-21>bar"
-# ^^^^^^^^^^^^^^ meta.string.shell string.quoted.double.shell - meta.redirection - meta.range
+# ^^^^^^^^^^^^^^ meta.string.glob.shell string.quoted.double.shell - meta.redirection - meta.range
 
 : thisoutput
-# ^^^^ meta.string.shell string.unquoted.shell
+# ^^^^ meta.string.glob.shell string.unquoted.shell
 #     ^^^^^^^^^^^^^ meta.redirection.shell - meta.range
 #     ^ keyword.operator.assignment.redirection.shell
 #           ^ keyword.operator.assignment.redirection.shell
 
 : 'thisoutput'
-# ^^^^^^^^^^^^^^^^^^^ meta.string.shell string.quoted.single.shell - meta.redirection - meta.range
+# ^^^^^^^^^^^^^^^^^^^ meta.string.glob.shell string.quoted.single.shell - meta.redirection - meta.range
 
 : "thisoutput"
-# ^^^^^^^^^^^^^^^^^^^ meta.string.shell string.quoted.double.shell - meta.redirection - meta.range
+# ^^^^^^^^^^^^^^^^^^^ meta.string.glob.shell string.quoted.double.shell - meta.redirection - meta.range
 
 ## pattern groups
 
 : foo/(a*/)#bar               # bar matches foo/bar, foo/any/bar, foo/any/anyother/bar, ...
-# ^^^^ meta.string.shell string.unquoted.shell
-#     ^^^^^ meta.string.shell meta.group.regexp.shell string.unquoted.shell
-#          ^^^^ meta.string.shell string.unquoted.shell
+# ^^^^ meta.string.glob.shell string.unquoted.shell
+#     ^^^^^ meta.string.glob.shell meta.group.regexp.shell string.unquoted.shell
+#          ^^^^ meta.string.glob.shell string.unquoted.shell
 #     ^ punctuation.section.group.begin.regexp.shell
 #       ^ constant.other.wildcard.asterisk.shell
 #         ^ punctuation.section.group.end.regexp.shell
@@ -4453,7 +4453,7 @@ esac
   ^foo/bar ^foo/bar           # Matches anything except the pattern x
 # ^^^^^^^^ meta.function-call.identifier.shell meta.command.shell
 #         ^ meta.function-call.arguments.shell - variable - string
-#          ^^^^^^^^ meta.function-call.arguments.shell meta.string.shell
+#          ^^^^^^^^ meta.function-call.arguments.shell meta.string.glob.shell
 #                  ^ - meta
 # ^^^^^^^^ variable.function.shell
 # ^ keyword.operator.logical.regexp.shell.zsh
@@ -4464,7 +4464,7 @@ esac
   ^~/foo/bar ^~/foo/bar      # Matches anything except the pattern x
 # ^^^^^^^^^^ meta.function-call.identifier.shell meta.command.shell
 #           ^ meta.function-call.arguments.shell - variable - string
-#            ^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell
+#            ^^^^^^^^^^ meta.function-call.arguments.shell meta.string.glob.shell
 #                      ^ - meta
 # ^ keyword.operator.logical.regexp.shell.zsh
 #  ^ variable.language.tilde.shell
@@ -4478,7 +4478,7 @@ esac
   /foo~/bar /foo~/bar        # Match anything that matches the pattern x but does not match y
 # ^^^^^^^^^ meta.function-call.identifier.shell meta.command.shell
 #          ^ meta.function-call.arguments.shell - variable - string
-#           ^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell
+#           ^^^^^^^^^ meta.function-call.arguments.shell meta.string.glob.shell
 #                    ^ - meta
 # ^^^^^^^^^ variable.function.shell
 # ^ punctuation.separator.path.shell
@@ -4490,7 +4490,7 @@ esac
   ^/foo~^/bar ^/foo~^/bar
 # ^^^^^^^^^^^ meta.function-call.identifier.shell meta.command.shell
 #            ^ meta.function-call.arguments.shell - variable - string
-#             ^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell
+#             ^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.glob.shell
 #                        ^ - meta
 # ^^^^^^^^^^^ variable.function.shell
 # ^ keyword.operator.logical.regexp.shell.zsh
@@ -4504,7 +4504,7 @@ esac
   ~/foo~~/bar ~/foo~~/bar
 # ^^^^^^^^^^^ meta.function-call.identifier.shell meta.command.shell
 #            ^ meta.function-call.arguments.shell - variable - string
-#             ^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell
+#             ^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.glob.shell
 #                        ^ - meta
 # ^ variable.language.tilde.shell
 #  ^^^^^ variable.function.shell
@@ -4522,7 +4522,7 @@ esac
   ^~/foo~^~/bar ^~/foo~^~/bar
 # ^^^^^^^^^^^^^ meta.function-call.identifier.shell meta.command.shell
 #              ^ meta.function-call.arguments.shell - variable - string
-#               ^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell
+#               ^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.glob.shell
 #                            ^ - meta
 #  ^ variable.language.tilde.shell
 #   ^^^^ variable.function.shell
@@ -4721,11 +4721,11 @@ esac
 # examples
 
 : (#ia2)readme # case-insensitive matching of readme with up to two errors.
-# ^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh - string
-#       ^^^^^^ meta.string.shell string.unquoted.shell
+# ^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh - string
+#       ^^^^^^ meta.string.glob.shell string.unquoted.shell
 
 : ((#i)foo)bar
-# ^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell
+# ^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.glob.shell
 # ^ meta.group.regexp.shell punctuation.section.group.begin.regexp.shell
 #  ^^^^ meta.group.regexp.shell meta.modifier.glob.shell.zsh - string
 #      ^^^^ meta.group.regexp.shell string.unquoted.shell
@@ -4733,9 +4733,9 @@ esac
 
 arr=(veldt jynx grimps waqf zho buck)
 print ${arr//(#m)[aeiou]/${(U)MATCH}}
-#     ^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell meta.interpolation.parameter.shell - meta.interpolation.parameter meta.interpolation.parameter
-#                        ^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.shell meta.interpolation.parameter.shell meta.string.shell meta.interpolation.parameter.shell
-#                                   ^ meta.function-call.arguments.shell meta.string.shell meta.interpolation.parameter.shell - meta.interpolation.parameter meta.interpolation.parameter
+#     ^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.glob.shell meta.interpolation.parameter.shell - meta.interpolation.parameter meta.interpolation.parameter
+#                        ^^^^^^^^^^^ meta.function-call.arguments.shell meta.string.glob.shell meta.interpolation.parameter.shell meta.string.shell meta.interpolation.parameter.shell
+#                                   ^ meta.function-call.arguments.shell meta.string.glob.shell meta.interpolation.parameter.shell - meta.interpolation.parameter meta.interpolation.parameter
 #     ^ meta.interpolation.parameter.shell punctuation.definition.variable.shell
 #      ^ meta.interpolation.parameter.shell punctuation.section.interpolation.begin.shell
 #       ^^^ variable.other.readwrite.shell
@@ -4750,7 +4750,7 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                                  ^^ punctuation.section.interpolation.end.shell
 
 : *((#s)|/)test((#e)|/)*
-# ^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell
+# ^^^^^^^^^^^^^^^^^^^^^^ meta.string.glob.shell
 # ^ constant.other.wildcard.asterisk.shell
 #  ^ meta.group.regexp.shell - meta.modifier
 #   ^^^^ meta.group.regexp.shell meta.modifier.glob.shell.zsh - string
@@ -4948,11 +4948,11 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                                                                               ^ meta.modifier.glob.shell.zsh punctuation.definition.modifier.end.shell.zsh
 
 : /(e) /(e<"foo -a | bar $v">) /(e<'foo -a | bar $v'>)
-#  ^^ meta.string.shell meta.modifier.glob.shell.zsh
-#    ^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#     ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
-#                    ^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#                     ^ meta.string.shell meta.modifier.glob.shell.zsh
+#  ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
+#    ^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#     ^^^^^^^^^^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
+#                    ^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#                     ^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #  ^ punctuation.definition.modifier.begin.shell.zsh
 #   ^ storage.modifier.glob.shell.zsh
 #    ^ punctuation.definition.quoted.begin.shell.zsh
@@ -4963,11 +4963,11 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                 ^^^ meta.function-call.arguments.shell
 #                    ^ punctuation.definition.quoted.end.shell.zsh
 #                     ^ punctuation.definition.modifier.end.shell.zsh
-#                        ^^ meta.string.shell meta.modifier.glob.shell.zsh
-#                          ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#                            ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
-#                                           ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#                                             ^ meta.string.shell meta.modifier.glob.shell.zsh
+#                        ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
+#                          ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#                            ^^^^^^^^^^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
+#                                           ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#                                             ^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #                        ^ punctuation.definition.modifier.begin.shell.zsh
 #                         ^ storage.modifier.glob.shell.zsh
 #                          ^^ punctuation.definition.quoted.begin.shell
@@ -4978,11 +4978,11 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                                        ^^^ meta.function-call.arguments.shell
 #                                           ^^ punctuation.definition.quoted.end.shell
 #                                             ^ punctuation.definition.modifier.end.shell.zsh
-#                                                ^^ meta.string.shell meta.modifier.glob.shell.zsh
-#                                                  ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#                                                    ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
-#                                                                   ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#                                                                     ^ meta.string.shell meta.modifier.glob.shell.zsh
+#                                                ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
+#                                                  ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#                                                    ^^^^^^^^^^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
+#                                                                   ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#                                                                     ^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #                                                ^ punctuation.definition.modifier.begin.shell.zsh
 #                                                 ^ storage.modifier.glob.shell.zsh
 #                                                  ^^ punctuation.definition.quoted.begin.shell
@@ -4995,11 +4995,11 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                                                                     ^ punctuation.definition.modifier.end.shell.zsh
 
 : /(e{foo -a | bar $v}) /(e{"foo -a | bar $v"}) /(e{'foo -a | bar $v'})
-#  ^^ meta.string.shell meta.modifier.glob.shell.zsh
-#    ^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#     ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
-#                    ^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#                     ^ meta.string.shell meta.modifier.glob.shell.zsh
+#  ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
+#    ^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#     ^^^^^^^^^^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
+#                    ^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#                     ^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #  ^ punctuation.definition.modifier.begin.shell.zsh
 #   ^ storage.modifier.glob.shell.zsh
 #    ^ punctuation.definition.quoted.begin.shell.zsh
@@ -5010,11 +5010,11 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                 ^^^ meta.function-call.arguments.shell
 #                    ^ punctuation.definition.quoted.end.shell.zsh
 #                     ^ punctuation.definition.modifier.end.shell.zsh
-#                        ^^ meta.string.shell meta.modifier.glob.shell.zsh
-#                          ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#                            ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
-#                                           ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#                                             ^ meta.string.shell meta.modifier.glob.shell.zsh
+#                        ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
+#                          ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#                            ^^^^^^^^^^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
+#                                           ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#                                             ^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #                        ^ punctuation.definition.modifier.begin.shell.zsh
 #                         ^ storage.modifier.glob.shell.zsh
 #                          ^^ punctuation.definition.quoted.begin.shell
@@ -5025,11 +5025,11 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                                        ^^^ meta.function-call.arguments.shell
 #                                           ^^ punctuation.definition.quoted.end.shell
 #                                             ^ punctuation.definition.modifier.end.shell.zsh
-#                                                ^^ meta.string.shell meta.modifier.glob.shell.zsh
-#                                                  ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#                                                    ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
-#                                                                   ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#                                                                     ^ meta.string.shell meta.modifier.glob.shell.zsh
+#                                                ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
+#                                                  ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#                                                    ^^^^^^^^^^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
+#                                                                   ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#                                                                     ^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #                                                ^ punctuation.definition.modifier.begin.shell.zsh
 #                                                 ^ storage.modifier.glob.shell.zsh
 #                                                  ^^ punctuation.definition.quoted.begin.shell
@@ -5042,11 +5042,11 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                                                                     ^ punctuation.definition.modifier.end.shell.zsh
 
 : /(e[foo -a | bar $v]) /(e["foo -a | bar $v"]) /(e['foo -a | bar $v'])
-#  ^^ meta.string.shell meta.modifier.glob.shell.zsh
-#    ^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#     ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
-#                    ^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#                     ^ meta.string.shell meta.modifier.glob.shell.zsh
+#  ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
+#    ^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#     ^^^^^^^^^^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
+#                    ^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#                     ^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #  ^ punctuation.definition.modifier.begin.shell.zsh
 #   ^ storage.modifier.glob.shell.zsh
 #    ^ punctuation.definition.quoted.begin.shell.zsh
@@ -5057,11 +5057,11 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                 ^^^ meta.function-call.arguments.shell
 #                    ^ punctuation.definition.quoted.end.shell.zsh
 #                     ^ punctuation.definition.modifier.end.shell.zsh
-#                        ^^ meta.string.shell meta.modifier.glob.shell.zsh
-#                          ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#                            ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
-#                                           ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#                                             ^ meta.string.shell meta.modifier.glob.shell.zsh
+#                        ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
+#                          ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#                            ^^^^^^^^^^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
+#                                           ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#                                             ^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #                        ^ punctuation.definition.modifier.begin.shell.zsh
 #                         ^ storage.modifier.glob.shell.zsh
 #                          ^^ punctuation.definition.quoted.begin.shell
@@ -5072,11 +5072,11 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                                        ^^^ meta.function-call.arguments.shell
 #                                           ^^ punctuation.definition.quoted.end.shell
 #                                             ^ punctuation.definition.modifier.end.shell.zsh
-#                                                ^^ meta.string.shell meta.modifier.glob.shell.zsh
-#                                                  ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#                                                    ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
-#                                                                   ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#                                                                     ^ meta.string.shell meta.modifier.glob.shell.zsh
+#                                                ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
+#                                                  ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#                                                    ^^^^^^^^^^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
+#                                                                   ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#                                                                     ^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #                                                ^ punctuation.definition.modifier.begin.shell.zsh
 #                                                 ^ storage.modifier.glob.shell.zsh
 #                                                  ^^ punctuation.definition.quoted.begin.shell
@@ -5089,11 +5089,11 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                                                                     ^ punctuation.definition.modifier.end.shell.zsh
 
 : /(e(foo -a | bar $v)) /(e("foo -a | bar $v")) /(e('foo -a | bar $v'))
-#  ^^ meta.string.shell meta.modifier.glob.shell.zsh
-#    ^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#     ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
-#                    ^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#                     ^ meta.string.shell meta.modifier.glob.shell.zsh
+#  ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
+#    ^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#     ^^^^^^^^^^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
+#                    ^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#                     ^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #  ^ punctuation.definition.modifier.begin.shell.zsh
 #   ^ storage.modifier.glob.shell.zsh
 #    ^ punctuation.definition.quoted.begin.shell.zsh
@@ -5104,11 +5104,11 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                 ^^^ meta.function-call.arguments.shell
 #                    ^ punctuation.definition.quoted.end.shell.zsh
 #                     ^ punctuation.definition.modifier.end.shell.zsh
-#                        ^^ meta.string.shell meta.modifier.glob.shell.zsh
-#                          ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#                            ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
-#                                           ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#                                             ^ meta.string.shell meta.modifier.glob.shell.zsh
+#                        ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
+#                          ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#                            ^^^^^^^^^^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
+#                                           ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#                                             ^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #                        ^ punctuation.definition.modifier.begin.shell.zsh
 #                         ^ storage.modifier.glob.shell.zsh
 #                          ^^ punctuation.definition.quoted.begin.shell
@@ -5119,11 +5119,11 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                                        ^^^ meta.function-call.arguments.shell
 #                                           ^^ punctuation.definition.quoted.end.shell
 #                                             ^ punctuation.definition.modifier.end.shell.zsh
-#                                                ^^ meta.string.shell meta.modifier.glob.shell.zsh
-#                                                  ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#                                                    ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
-#                                                                   ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#                                                                     ^ meta.string.shell meta.modifier.glob.shell.zsh
+#                                                ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
+#                                                  ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#                                                    ^^^^^^^^^^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
+#                                                                   ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#                                                                     ^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #                                                ^ punctuation.definition.modifier.begin.shell.zsh
 #                                                 ^ storage.modifier.glob.shell.zsh
 #                                                  ^^ punctuation.definition.quoted.begin.shell
@@ -5136,11 +5136,11 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                                                                     ^ punctuation.definition.modifier.end.shell.zsh
 
 : /(e:foo -a | bar $v:) /(e:"foo -a | bar $v":) /(e:'foo -a | bar $v':)
-#  ^^ meta.string.shell meta.modifier.glob.shell.zsh
-#    ^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#     ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
-#                    ^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#                     ^ meta.string.shell meta.modifier.glob.shell.zsh
+#  ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
+#    ^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#     ^^^^^^^^^^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
+#                    ^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#                     ^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #  ^ punctuation.definition.modifier.begin.shell.zsh
 #   ^ storage.modifier.glob.shell.zsh
 #    ^ punctuation.definition.quoted.begin.shell.zsh
@@ -5151,11 +5151,11 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                 ^^^ meta.function-call.arguments.shell
 #                    ^ punctuation.definition.quoted.end.shell.zsh
 #                     ^ punctuation.definition.modifier.end.shell.zsh
-#                        ^^ meta.string.shell meta.modifier.glob.shell.zsh
-#                          ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#                            ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
-#                                           ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#                                             ^ meta.string.shell meta.modifier.glob.shell.zsh
+#                        ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
+#                          ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#                            ^^^^^^^^^^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
+#                                           ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#                                             ^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #                        ^ punctuation.definition.modifier.begin.shell.zsh
 #                         ^ storage.modifier.glob.shell.zsh
 #                          ^^ punctuation.definition.quoted.begin.shell
@@ -5166,11 +5166,11 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                                        ^^^ meta.function-call.arguments.shell
 #                                           ^^ punctuation.definition.quoted.end.shell
 #                                             ^ punctuation.definition.modifier.end.shell.zsh
-#                                                ^^ meta.string.shell meta.modifier.glob.shell.zsh
-#                                                  ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#                                                    ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
-#                                                                   ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#                                                                     ^ meta.string.shell meta.modifier.glob.shell.zsh
+#                                                ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
+#                                                  ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#                                                    ^^^^^^^^^^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
+#                                                                   ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#                                                                     ^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #                                                ^ punctuation.definition.modifier.begin.shell.zsh
 #                                                 ^ storage.modifier.glob.shell.zsh
 #                                                  ^^ punctuation.definition.quoted.begin.shell
@@ -5183,11 +5183,11 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                                                                     ^ punctuation.definition.modifier.end.shell.zsh
 
 : /(e'foo -a | bar $v') /(e'"foo -a | bar $v"') /(e"'foo -a | bar $v'")
-#  ^^ meta.string.shell meta.modifier.glob.shell.zsh
-#    ^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#     ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
-#                    ^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#                     ^ meta.string.shell meta.modifier.glob.shell.zsh
+#  ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
+#    ^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#     ^^^^^^^^^^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
+#                    ^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#                     ^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #  ^ punctuation.definition.modifier.begin.shell.zsh
 #   ^ storage.modifier.glob.shell.zsh
 #    ^ punctuation.definition.quoted.begin.shell.zsh
@@ -5198,11 +5198,11 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                 ^^^ meta.function-call.arguments.shell
 #                    ^ punctuation.definition.quoted.end.shell.zsh
 #                     ^ punctuation.definition.modifier.end.shell.zsh
-#                        ^^ meta.string.shell meta.modifier.glob.shell.zsh
-#                          ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#                            ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
-#                                           ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#                                             ^ meta.string.shell meta.modifier.glob.shell.zsh
+#                        ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
+#                          ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#                            ^^^^^^^^^^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
+#                                           ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#                                             ^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #                        ^ punctuation.definition.modifier.begin.shell.zsh
 #                         ^ storage.modifier.glob.shell.zsh
 #                          ^^ punctuation.definition.quoted.begin.shell
@@ -5213,11 +5213,11 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                                        ^^^ meta.function-call.arguments.shell
 #                                           ^^ punctuation.definition.quoted.end.shell
 #                                             ^ punctuation.definition.modifier.end.shell.zsh
-#                                                ^^ meta.string.shell meta.modifier.glob.shell.zsh
-#                                                  ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#                                                    ^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
-#                                                                   ^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
-#                                                                     ^ meta.string.shell meta.modifier.glob.shell.zsh
+#                                                ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
+#                                                  ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#                                                    ^^^^^^^^^^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh meta.interpolation.command.shell
+#                                                                   ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh - meta.interpolation
+#                                                                     ^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #                                                ^ punctuation.definition.modifier.begin.shell.zsh
 #                                                 ^ storage.modifier.glob.shell.zsh
 #                                                  ^^ punctuation.definition.quoted.begin.shell
@@ -5230,15 +5230,15 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                                                                     ^ punctuation.definition.modifier.end.shell.zsh
 
 : /(G120) /(G) /(G{gid}) /(G[gid]) /(G(gid)) /(G:gid:)
-#  ^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#  ^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #  ^ punctuation.definition.modifier.begin.shell.zsh
 #   ^ storage.modifier.glob.shell.zsh
 #    ^^^ meta.number.integer.decimal.shell constant.numeric.value.shell
 #       ^ punctuation.definition.modifier.end.shell.zsh
 #        ^ - meta.string - meta.modifier
-#          ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
-#            ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
-#                 ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#          ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
+#            ^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
+#                 ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                  ^ - meta.string - meta.modifier
 #          ^ punctuation.definition.modifier.begin.shell.zsh
 #           ^ storage.modifier.glob.shell.zsh
@@ -5246,9 +5246,9 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #             ^^^ string.quoted.other.shell.zsh
 #                ^ punctuation.definition.quoted.end.shell.zsh
 #                 ^ punctuation.definition.modifier.end.shell.zsh
-#                    ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
-#                      ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
-#                           ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                    ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                      ^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
+#                           ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                            ^ - meta.string - meta.modifier
 #                    ^ punctuation.definition.modifier.begin.shell.zsh
 #                     ^ storage.modifier.glob.shell.zsh
@@ -5256,9 +5256,9 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                       ^^^ string.quoted.other.shell.zsh
 #                          ^ punctuation.definition.quoted.end.shell.zsh
 #                           ^ punctuation.definition.modifier.end.shell.zsh
-#                              ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
-#                                ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
-#                                     ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                              ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                ^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
+#                                     ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                                      ^ - meta.string - meta.modifier
 #                              ^ punctuation.definition.modifier.begin.shell.zsh
 #                               ^ storage.modifier.glob.shell.zsh
@@ -5266,9 +5266,9 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                                 ^^^ string.quoted.other.shell.zsh
 #                                    ^ punctuation.definition.quoted.end.shell.zsh
 #                                     ^ punctuation.definition.modifier.end.shell.zsh
-#                                        ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
-#                                          ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
-#                                               ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                        ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                          ^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
+#                                               ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                                                ^ - meta.string - meta.modifier
 #                                        ^ punctuation.definition.modifier.begin.shell.zsh
 #                                         ^ storage.modifier.glob.shell.zsh
@@ -5276,9 +5276,9 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                                           ^^^ string.quoted.other.shell.zsh
 #                                              ^ punctuation.definition.quoted.end.shell.zsh
 #                                               ^ punctuation.definition.modifier.end.shell.zsh
-#                                                  ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
-#                                                    ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
-#                                                         ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                                  ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                                    ^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
+#                                                         ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                                                          ^ - meta.string - meta.modifier
 #                                                  ^ punctuation.definition.modifier.begin.shell.zsh
 #                                                   ^ storage.modifier.glob.shell.zsh
@@ -5288,15 +5288,15 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                                                         ^ punctuation.definition.modifier.end.shell.zsh
 
 : /(U123) /(U) /(U{uid}) /(U[uid]) /(U(uid)) /(U:uid:)
-#  ^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#  ^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #  ^ punctuation.definition.modifier.begin.shell.zsh
 #   ^ storage.modifier.glob.shell.zsh
 #    ^^^ meta.number.integer.decimal.shell constant.numeric.value.shell
 #       ^ punctuation.definition.modifier.end.shell.zsh
 #        ^ - meta.string - meta.modifier
-#          ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
-#            ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
-#                 ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#          ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
+#            ^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
+#                 ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                  ^ - meta.string - meta.modifier
 #          ^ punctuation.definition.modifier.begin.shell.zsh
 #           ^ storage.modifier.glob.shell.zsh
@@ -5304,9 +5304,9 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #             ^^^ string.quoted.other.shell.zsh
 #                ^ punctuation.definition.quoted.end.shell.zsh
 #                 ^ punctuation.definition.modifier.end.shell.zsh
-#                    ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
-#                      ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
-#                           ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                    ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                      ^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
+#                           ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                            ^ - meta.string - meta.modifier
 #                    ^ punctuation.definition.modifier.begin.shell.zsh
 #                     ^ storage.modifier.glob.shell.zsh
@@ -5314,9 +5314,9 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                       ^^^ string.quoted.other.shell.zsh
 #                          ^ punctuation.definition.quoted.end.shell.zsh
 #                           ^ punctuation.definition.modifier.end.shell.zsh
-#                              ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
-#                                ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
-#                                     ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                              ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                ^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
+#                                     ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                                      ^ - meta.string - meta.modifier
 #                              ^ punctuation.definition.modifier.begin.shell.zsh
 #                               ^ storage.modifier.glob.shell.zsh
@@ -5324,9 +5324,9 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                                 ^^^ string.quoted.other.shell.zsh
 #                                    ^ punctuation.definition.quoted.end.shell.zsh
 #                                     ^ punctuation.definition.modifier.end.shell.zsh
-#                                        ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
-#                                          ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
-#                                               ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                        ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                          ^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
+#                                               ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                                                ^ - meta.string - meta.modifier
 #                                        ^ punctuation.definition.modifier.begin.shell.zsh
 #                                         ^ storage.modifier.glob.shell.zsh
@@ -5334,9 +5334,9 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                                           ^^^ string.quoted.other.shell.zsh
 #                                              ^ punctuation.definition.quoted.end.shell.zsh
 #                                               ^ punctuation.definition.modifier.end.shell.zsh
-#                                                  ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
-#                                                    ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
-#                                                         ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                                  ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                                    ^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
+#                                                         ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                                                          ^ - meta.string - meta.modifier
 #                                                  ^ punctuation.definition.modifier.begin.shell.zsh
 #                                                   ^ storage.modifier.glob.shell.zsh
@@ -5346,128 +5346,128 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                                                         ^ punctuation.definition.modifier.end.shell.zsh
 
 : /(aM-5) /(mm+5) /(cs100) # access time, modification time, creation time
-#  ^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#  ^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #  ^ punctuation.definition.modifier.begin.shell.zsh
 #   ^^ storage.modifier.glob.shell.zsh
 #     ^ meta.number.integer.decimal.shell keyword.operator.arithmetic.shell
 #      ^ meta.number.integer.decimal.shell constant.numeric.value.shell
 #       ^ punctuation.definition.modifier.end.shell.zsh
-#          ^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#          ^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #          ^ punctuation.definition.modifier.begin.shell.zsh
 #           ^^ storage.modifier.glob.shell.zsh
 #             ^ meta.number.integer.decimal.shell keyword.operator.arithmetic.shell
 #              ^ meta.number.integer.decimal.shell constant.numeric.value.shell
 #               ^ punctuation.definition.modifier.end.shell.zsh
-#                  ^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#                  ^^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #                  ^ punctuation.definition.modifier.begin.shell.zsh
 #                   ^^ storage.modifier.glob.shell.zsh
 #                     ^^^ meta.number.integer.decimal.shell constant.numeric.value.shell
 #                        ^ punctuation.definition.modifier.end.shell.zsh
 
 : /(Lk-5) /(LM+5) /(LG100) # file size
-#  ^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#  ^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #  ^ punctuation.definition.modifier.begin.shell.zsh
 #   ^^ storage.modifier.glob.shell.zsh
 #     ^ meta.number.integer.decimal.shell keyword.operator.arithmetic.shell
 #      ^ meta.number.integer.decimal.shell constant.numeric.value.shell
 #       ^ punctuation.definition.modifier.end.shell.zsh
-#          ^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#          ^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #          ^ punctuation.definition.modifier.begin.shell.zsh
 #           ^^ storage.modifier.glob.shell.zsh
 #             ^ meta.number.integer.decimal.shell keyword.operator.arithmetic.shell
 #              ^ meta.number.integer.decimal.shell constant.numeric.value.shell
 #               ^ punctuation.definition.modifier.end.shell.zsh
-#                  ^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#                  ^^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #                  ^ punctuation.definition.modifier.begin.shell.zsh
 #                   ^^ storage.modifier.glob.shell.zsh
 #                     ^^^ meta.number.integer.decimal.shell constant.numeric.value.shell
 #                        ^ punctuation.definition.modifier.end.shell.zsh
 
 : /(^)   # negates all qualifiers following it
-#  ^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#  ^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #  ^ punctuation.definition.modifier.begin.shell.zsh
 #   ^ keyword.operator.logical.shell.zsh
 #    ^ punctuation.definition.modifier.end.shell.zsh
 
 : /(-)   # toggles between making the qualifiers work on symbolic links (the default) and the files they point to
-#  ^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#  ^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #  ^ punctuation.definition.modifier.begin.shell.zsh
 #   ^ keyword.operator.logical.shell.zsh
 #    ^ punctuation.definition.modifier.end.shell.zsh
 
 : /(M)   # sets the MARK_DIRS option for the current pattern
-#  ^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#  ^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #  ^ punctuation.definition.modifier.begin.shell.zsh
 #   ^ storage.modifier.glob.shell.zsh
 #    ^ punctuation.definition.modifier.end.shell.zsh
 
 : /(T)   # appends a trailing qualifier mark to the filenames
-#  ^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#  ^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #  ^ punctuation.definition.modifier.begin.shell.zsh
 #   ^ storage.modifier.glob.shell.zsh
 #    ^ punctuation.definition.modifier.end.shell.zsh
 
 : /(N)   # sets the NULL_GLOB option for the current pattern
-#  ^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#  ^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #  ^ punctuation.definition.modifier.begin.shell.zsh
 #   ^ storage.modifier.glob.shell.zsh
 #    ^ punctuation.definition.modifier.end.shell.zsh
 
 : /(D)   # sets the GLOB_DOTS option for the current pattern
-#  ^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#  ^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #  ^ punctuation.definition.modifier.begin.shell.zsh
 #   ^ storage.modifier.glob.shell.zsh
 #    ^ punctuation.definition.modifier.end.shell.zsh
 
 : /(n)   # sets the NUMERIC_GLOB_SORT option for the current pattern
-#  ^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#  ^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #  ^ punctuation.definition.modifier.begin.shell.zsh
 #   ^ storage.modifier.glob.shell.zsh
 #    ^ punctuation.definition.modifier.end.shell.zsh
 
 : /(Y10) # enables short-circuit mode: the pattern will expand to at most n filenames.
-#  ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#  ^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #  ^ punctuation.definition.modifier.begin.shell.zsh
 #   ^ storage.modifier.glob.shell.zsh
 #    ^^ meta.number.integer.decimal.shell constant.numeric.value.shell
 #      ^ punctuation.definition.modifier.end.shell.zsh
 
 : /(on) /(oL) /(ol) /(oa) /(om) /(oc) /(od) /(oN) /(oe{'cmd arg'}) # specifies how the names of the files should be sorted
-#  ^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#  ^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #  ^ punctuation.definition.modifier.begin.shell.zsh
 #   ^^ storage.modifier.glob.shell.zsh
 #     ^ punctuation.definition.modifier.end.shell.zsh
-#        ^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#        ^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #        ^ punctuation.definition.modifier.begin.shell.zsh
 #         ^^ storage.modifier.glob.shell.zsh
 #           ^ punctuation.definition.modifier.end.shell.zsh
-#              ^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#              ^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #              ^ punctuation.definition.modifier.begin.shell.zsh
 #               ^^ storage.modifier.glob.shell.zsh
 #                 ^ punctuation.definition.modifier.end.shell.zsh
-#                    ^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#                    ^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #                    ^ punctuation.definition.modifier.begin.shell.zsh
 #                     ^^ storage.modifier.glob.shell.zsh
 #                       ^ punctuation.definition.modifier.end.shell.zsh
-#                          ^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#                          ^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #                          ^ punctuation.definition.modifier.begin.shell.zsh
 #                           ^^ storage.modifier.glob.shell.zsh
 #                             ^ punctuation.definition.modifier.end.shell.zsh
-#                                ^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#                                ^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #                                ^ punctuation.definition.modifier.begin.shell.zsh
 #                                 ^^ storage.modifier.glob.shell.zsh
 #                                   ^ punctuation.definition.modifier.end.shell.zsh
-#                                      ^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#                                      ^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #                                      ^ punctuation.definition.modifier.begin.shell.zsh
 #                                       ^^ storage.modifier.glob.shell.zsh
 #                                         ^ punctuation.definition.modifier.end.shell.zsh
-#                                            ^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#                                            ^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #                                            ^ punctuation.definition.modifier.begin.shell.zsh
 #                                             ^^ storage.modifier.glob.shell.zsh
 #                                               ^ punctuation.definition.modifier.end.shell.zsh
-#                                                  ^^^ meta.string.shell meta.modifier.glob.shell.zsh
-#                                                     ^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
-#                                                                ^ meta.string.shell meta.modifier.glob.shell.zsh
+#                                                  ^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
+#                                                     ^^^^^^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
+#                                                                ^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #                                                  ^ punctuation.definition.modifier.begin.shell.zsh
 #                                                   ^^ storage.modifier.glob.shell.zsh
 #                                                     ^ punctuation.definition.quoted.begin.shell.zsh
@@ -5478,41 +5478,41 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                                                                ^ punctuation.definition.modifier.end.shell.zsh
 
 : /(On) /(OL) /(Ol) /(Oa) /(Om) /(Oc) /(Od) /(ON) /(Oe{'cmd arg'}) # like 'o', but sorts in descending order
-#  ^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#  ^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #  ^ punctuation.definition.modifier.begin.shell.zsh
 #   ^^ storage.modifier.glob.shell.zsh
 #     ^ punctuation.definition.modifier.end.shell.zsh
-#        ^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#        ^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #        ^ punctuation.definition.modifier.begin.shell.zsh
 #         ^^ storage.modifier.glob.shell.zsh
 #           ^ punctuation.definition.modifier.end.shell.zsh
-#              ^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#              ^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #              ^ punctuation.definition.modifier.begin.shell.zsh
 #               ^^ storage.modifier.glob.shell.zsh
 #                 ^ punctuation.definition.modifier.end.shell.zsh
-#                    ^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#                    ^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #                    ^ punctuation.definition.modifier.begin.shell.zsh
 #                     ^^ storage.modifier.glob.shell.zsh
 #                       ^ punctuation.definition.modifier.end.shell.zsh
-#                          ^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#                          ^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #                          ^ punctuation.definition.modifier.begin.shell.zsh
 #                           ^^ storage.modifier.glob.shell.zsh
 #                             ^ punctuation.definition.modifier.end.shell.zsh
-#                                ^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#                                ^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #                                ^ punctuation.definition.modifier.begin.shell.zsh
 #                                 ^^ storage.modifier.glob.shell.zsh
 #                                   ^ punctuation.definition.modifier.end.shell.zsh
-#                                      ^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#                                      ^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #                                      ^ punctuation.definition.modifier.begin.shell.zsh
 #                                       ^^ storage.modifier.glob.shell.zsh
 #                                         ^ punctuation.definition.modifier.end.shell.zsh
-#                                            ^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#                                            ^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #                                            ^ punctuation.definition.modifier.begin.shell.zsh
 #                                             ^^ storage.modifier.glob.shell.zsh
 #                                               ^ punctuation.definition.modifier.end.shell.zsh
-#                                                  ^^^ meta.string.shell meta.modifier.glob.shell.zsh
-#                                                     ^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
-#                                                                ^ meta.string.shell meta.modifier.glob.shell.zsh
+#                                                  ^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
+#                                                     ^^^^^^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
+#                                                                ^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #                                                  ^ punctuation.definition.modifier.begin.shell.zsh
 #                                                   ^^ storage.modifier.glob.shell.zsh
 #                                                     ^ punctuation.definition.quoted.begin.shell.zsh
@@ -5523,17 +5523,17 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                                                                ^ punctuation.definition.modifier.end.shell.zsh
 
 : /([10]) /([1,20]) /([$start,1${end}2]) # specifies which of the matched filenames should be included in the returned list.
-#  ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.range
-#   ^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.range.glob.shell.zsh
-#       ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.range
+#  ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.range
+#   ^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.range.glob.shell.zsh
+#       ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.range
 #  ^ punctuation.definition.modifier.begin.shell.zsh
 #   ^ punctuation.definition.range.begin.shell.zsh
 #    ^^ meta.number.integer.decimal.shell constant.numeric.value.shell
 #      ^ punctuation.definition.range.end.shell.zsh
 #       ^ punctuation.definition.modifier.end.shell.zsh
-#          ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.range
-#           ^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.range.glob.shell.zsh
-#                 ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.range
+#          ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.range
+#           ^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.range.glob.shell.zsh
+#                 ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.range
 #          ^ punctuation.definition.modifier.begin.shell.zsh
 #           ^ punctuation.definition.range.begin.shell.zsh
 #            ^ meta.number.integer.decimal.shell constant.numeric.value.shell
@@ -5541,9 +5541,9 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #              ^^ meta.number.integer.decimal.shell constant.numeric.value.shell
 #                ^ punctuation.definition.range.end.shell.zsh
 #                 ^ punctuation.definition.modifier.end.shell.zsh
-#                    ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.range
-#                     ^^^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.range.glob.shell.zsh
-#                                      ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.range
+#                    ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.range
+#                     ^^^^^^^^^^^^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.range.glob.shell.zsh
+#                                      ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.range
 #                     ^ punctuation.definition.range.begin.shell.zsh
 #                      ^^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell
 #                            ^ punctuation.separator.sequence.shell
@@ -5554,12 +5554,12 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                                      ^ meta.modifier.glob.shell.zsh punctuation.definition.modifier.end.shell.zsh
 
 : /*(["1+var", foo ? 2 : 5])
-# ^^ meta.string.shell string.unquoted.shell
-#   ^ meta.string.shell meta.modifier.glob.shell.zsh - string
-#    ^ meta.string.shell meta.modifier.glob.shell.zsh meta.range.glob.shell.zsh - string
-#     ^^^^^^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.range.glob.shell.zsh meta.arithmetic.shell - string
-#                         ^ meta.string.shell meta.modifier.glob.shell.zsh meta.range.glob.shell.zsh - string
-#                          ^ meta.string.shell meta.modifier.glob.shell.zsh - string
+# ^^ meta.string.glob.shell string.unquoted.shell
+#   ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - string
+#    ^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.range.glob.shell.zsh - string
+#     ^^^^^^^^^^^^^^^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.range.glob.shell.zsh meta.arithmetic.shell - string
+#                         ^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.range.glob.shell.zsh - string
+#                          ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - string
 #  ^ constant.other.wildcard.asterisk.shell
 #   ^ punctuation.definition.modifier.begin.shell.zsh
 #    ^ punctuation.definition.range.begin.shell.zsh
@@ -5578,9 +5578,9 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                          ^ punctuation.definition.modifier.end.shell.zsh
 
 : /(P"pre") /(P
) /(P{pre}) /(P[pre]) /(P(pre)) /(P:pre:)
-#  ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#  ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #    ^^^^^ meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
-#         ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#         ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #  ^ punctuation.definition.modifier.begin.shell.zsh
 #   ^ storage.modifier.glob.shell.zsh
 #    ^ punctuation.definition.quoted.begin.shell.zsh
@@ -5588,9 +5588,9 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #        ^ punctuation.definition.quoted.end.shell.zsh
 #         ^ punctuation.definition.modifier.end.shell.zsh
 #          ^ - meta.string - meta.modifier
-#            ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
-#              ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
-#                   ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#            ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
+#              ^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
+#                   ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                    ^ - meta.string - meta.modifier
 #            ^ punctuation.definition.modifier.begin.shell.zsh
 #             ^ storage.modifier.glob.shell.zsh
@@ -5598,9 +5598,9 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #               ^^^ string.quoted.other.shell.zsh
 #                  ^ punctuation.definition.quoted.end.shell.zsh
 #                   ^ punctuation.definition.modifier.end.shell.zsh
-#                      ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
-#                        ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
-#                             ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                      ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                        ^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
+#                             ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                              ^ - meta.string - meta.modifier
 #                      ^ punctuation.definition.modifier.begin.shell.zsh
 #                       ^ storage.modifier.glob.shell.zsh
@@ -5608,9 +5608,9 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                         ^^^ string.quoted.other.shell.zsh
 #                            ^ punctuation.definition.quoted.end.shell.zsh
 #                             ^ punctuation.definition.modifier.end.shell.zsh
-#                                ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
-#                                  ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
-#                                       ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                  ^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
+#                                       ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                                        ^ - meta.string - meta.modifier
 #                                ^ punctuation.definition.modifier.begin.shell.zsh
 #                                 ^ storage.modifier.glob.shell.zsh
@@ -5618,9 +5618,9 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                                   ^^^ string.quoted.other.shell.zsh
 #                                      ^ punctuation.definition.quoted.end.shell.zsh
 #                                       ^ punctuation.definition.modifier.end.shell.zsh
-#                                          ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
-#                                            ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
-#                                                 ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                          ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                            ^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
+#                                                 ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                                                  ^ - meta.string - meta.modifier
 #                                          ^ punctuation.definition.modifier.begin.shell.zsh
 #                                           ^ storage.modifier.glob.shell.zsh
@@ -5628,9 +5628,9 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 #                                             ^^^ string.quoted.other.shell.zsh
 #                                                ^ punctuation.definition.quoted.end.shell.zsh
 #                                                 ^ punctuation.definition.modifier.end.shell.zsh
-#                                                    ^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
-#                                                      ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
-#                                                           ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                                    ^^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
+#                                                      ^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.quoted.glob.shell.zsh
+#                                                           ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.quoted
 #                                                            ^ - meta.string - meta.modifier
 #                                                    ^ punctuation.definition.modifier.begin.shell.zsh
 #                                                     ^ storage.modifier.glob.shell.zsh
@@ -5641,8 +5641,8 @@ print ${arr//(#m)[aeiou]/${(U)MATCH}}
 
 a=(/*(/:t)) # qualifiers are valid in arrays
 # ^ meta.sequence.list.shell - meta.string
-#  ^^ meta.sequence.list.shell meta.string.shell string.unquoted.shell
-#    ^^^^^ meta.sequence.list.shell meta.string.shell meta.modifier.glob.shell.zsh
+#  ^^ meta.sequence.list.shell meta.string.glob.shell string.unquoted.shell
+#    ^^^^^ meta.sequence.list.shell meta.string.glob.shell meta.modifier.glob.shell.zsh
 #         ^ meta.sequence.list.shell - meta.string
 # ^ punctuation.section.sequence.begin.shell
 #   ^ constant.other.wildcard.asterisk.shell
@@ -5654,22 +5654,22 @@ a=(/*(/:t)) # qualifiers are valid in arrays
 #         ^ punctuation.section.sequence.end.shell
 
 : (/*(/:t)) # qualifiers are not valid in groups
-# ^^^ meta.string.shell meta.group.regexp.shell string.unquoted.shell - meta.modifier
-#    ^^^^^ meta.string.shell meta.group.regexp.shell meta.group.regexp.shell string.unquoted.shell - meta.modifier
-#         ^ meta.string.shell meta.group.regexp.shell string.unquoted.shell - meta.modifier
+# ^^^ meta.string.glob.shell meta.group.regexp.shell string.unquoted.shell - meta.modifier
+#    ^^^^^ meta.string.glob.shell meta.group.regexp.shell meta.group.regexp.shell string.unquoted.shell - meta.modifier
+#         ^ meta.string.glob.shell meta.group.regexp.shell string.unquoted.shell - meta.modifier
 # ^ meta.group.regexp.shell string.unquoted.shell punctuation.section.group.begin.regexp.shell
 #   ^ constant.other.wildcard.asterisk.shell
 #    ^ punctuation.section.group.begin.regexp.shell
 #        ^^ punctuation.section.group.end.regexp.shell
 
 ls /(D)/  # qualifiers are always located at the end
-#  ^^^^^ meta.string.shell string.unquoted.shell
+#  ^^^^^ meta.string.glob.shell string.unquoted.shell
 #   ^^^ meta.group.regexp.shell - meta.modifier
 
 #  lists all directories and symbolic links that point to directories, and
 ls -ld -- *(-/)
-#         ^ meta.string.shell string.unquoted.shell constant.other.wildcard.asterisk.shell
-#          ^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#         ^ meta.string.glob.shell string.unquoted.shell constant.other.wildcard.asterisk.shell
+#          ^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #          ^ punctuation.definition.modifier.begin.shell.zsh
 #           ^ keyword.operator.logical.shell.zsh
 #            ^ storage.modifier.glob.shell.zsh
@@ -5677,8 +5677,8 @@ ls -ld -- *(-/)
 
 # lists all broken symbolic links, and
 ls -ld -- *(-@)
-#         ^ meta.string.shell string.unquoted.shell constant.other.wildcard.asterisk.shell
-#          ^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#         ^ meta.string.glob.shell string.unquoted.shell constant.other.wildcard.asterisk.shell
+#          ^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #          ^ punctuation.definition.modifier.begin.shell.zsh
 #           ^ keyword.operator.logical.shell.zsh
 #            ^ storage.modifier.glob.shell.zsh
@@ -5686,16 +5686,16 @@ ls -ld -- *(-@)
 
 # lists all world-writable device files in the current directory, and
 ls -ld -- *(%W)
-#         ^ meta.string.shell string.unquoted.shell constant.other.wildcard.asterisk.shell
-#          ^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#         ^ meta.string.glob.shell string.unquoted.shell constant.other.wildcard.asterisk.shell
+#          ^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #          ^ punctuation.definition.modifier.begin.shell.zsh
 #           ^^ storage.modifier.glob.shell.zsh
 #             ^ punctuation.definition.modifier.end.shell.zsh
 
 # lists all files in the current directory that are world-writable or world-executable, and
 ls -ld -- *(W,X)
-#         ^ meta.string.shell string.unquoted.shell constant.other.wildcard.asterisk.shell
-#          ^^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#         ^ meta.string.glob.shell string.unquoted.shell constant.other.wildcard.asterisk.shell
+#          ^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 #          ^ punctuation.definition.modifier.begin.shell.zsh
 #           ^ storage.modifier.glob.shell.zsh
 #            ^ punctuation.separator.sequence.shell
@@ -5705,27 +5705,27 @@ ls -ld -- *(W,X)
 # outputs the basename of all root-owned files beginning with the string ‘foo’
 # in /tmp, ignoring symlinks, and
 print -rC1 /tmp/foo*(u0^@:t)
-#          ^^^^^^^^^ meta.string.shell string.unquoted.shell
-#                   ^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#          ^^^^^^^^^ meta.string.glob.shell string.unquoted.shell
+#                   ^^^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 
 # lists all files having a link count of one whose names contain a dot (but
 # not those starting with a dot, since GLOB_DOTS is explicitly switched off)
 # except for lex.c, lex.h, parse.c and parse.h.
 ls -ld -- *.*~(lex|parse).[ch](^D^l1)
-#         ^^^^ meta.string.shell string.unquoted.shell
-#             ^^^^^^^^^^^ meta.string.shell meta.group.regexp.shell string.unquoted.shell
-#                        ^ meta.string.shell string.unquoted.shell
-#                         ^^^^ meta.string.shell string.unquoted.shell meta.set.regexp.shell
-#                             ^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh
+#         ^^^^ meta.string.glob.shell string.unquoted.shell
+#             ^^^^^^^^^^^ meta.string.glob.shell meta.group.regexp.shell string.unquoted.shell
+#                        ^ meta.string.glob.shell string.unquoted.shell
+#                         ^^^^ meta.string.glob.shell string.unquoted.shell meta.set.regexp.shell
+#                             ^^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh
 
 # demonstrates how colon modifiers and other qualifiers may be chained together.
 print -rC1 b*.pro(#q:s/pro/shmo/)(#q.:s@builtin@"sh${mi}ltin"@)
-#          ^^^^^^ meta.string.shell string.unquoted.shell
-#                ^^^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.substituation
-#                    ^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.substituation.shell.zsh
-#                               ^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh - meta.substituation
-#                                     ^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.shell meta.modifier.glob.shell.zsh meta.substituation.shell.zsh
-#                                                             ^ meta.string.shell meta.modifier.glob.shell.zsh - meta.substituation
+#          ^^^^^^ meta.string.glob.shell string.unquoted.shell
+#                ^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.substituation
+#                    ^^^^^^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.substituation.shell.zsh
+#                               ^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.substituation
+#                                     ^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.glob.shell meta.modifier.glob.shell.zsh meta.substituation.shell.zsh
+#                                                             ^ meta.string.glob.shell meta.modifier.glob.shell.zsh - meta.substituation
 #                                                              ^ - meta.string - meta.modifier
 
 
@@ -5785,18 +5785,18 @@ var[1]=Hello
 #   ^ meta.string.shell string.unquoted.shell - punctuation
 #    ^ punctuation.section.item-access.end.shell - meta.string - string
 #     ^ keyword.operator.assignment.shell
-#      ^^^^^ meta.string.shell string.unquoted.shell
+#      ^^^^^ meta.string.glob.shell string.unquoted.shell
 
 echo $var[1] World
 #<- meta.function-call.identifier.shell support.function.shell
 #^^^ meta.function-call.identifier.shell support.function.shell
 #   ^^^^^^^^^^^^^^ meta.function-call.arguments.shell
-#    ^^^^^^^ meta.string.shell meta.interpolation.parameter.shell
+#    ^^^^^^^ meta.string.glob.shell meta.interpolation.parameter.shell
 #        ^^^ meta.item-access.shell - variable
 #        ^ punctuation.section.item-access.begin.shell - string
-#         ^ meta.string.shell string.unquoted.shell
+#         ^ meta.string.glob.shell string.unquoted.shell
 #          ^ punctuation.section.item-access.end.shell - string
-#            ^^^^^ meta.string.shell string.unquoted.shell - meta.interpolation
+#            ^^^^^ meta.string.glob.shell string.unquoted.shell - meta.interpolation
 
 
 ##############################################################################

From ab67b7db9cb2786b698825f345a2fb34a1dfa0f0 Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Sun, 22 Sep 2024 10:18:36 +0200
Subject: [PATCH 108/113] [ShellScript] Arithmetic expansions in subscriptions

Variable subscriptions undergo arithmetic expansion.
---
 ShellScript/Bash.sublime-syntax               |  4 +-
 ShellScript/Bash/tests/syntax_test_scope.bash | 41 +++++++++++--------
 ShellScript/Zsh/tests/syntax_test_scope.zsh   | 12 +++---
 3 files changed, 31 insertions(+), 26 deletions(-)

diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax
index bb55cacf1a..f0de0e3b7b 100644
--- a/ShellScript/Bash.sublime-syntax
+++ b/ShellScript/Bash.sublime-syntax
@@ -293,12 +293,12 @@ contexts:
   variable-subscription-body:
     - meta_include_prototype: false
     - meta_scope: meta.item-access.shell
-    - meta_content_scope: meta.string.shell string.unquoted.shell
+    - meta_content_scope: meta.arithmetic.shell
     - match: \]
       scope: punctuation.section.item-access.end.shell
       pop: 1
     - include: eoc-pop
-    - include: string-unquoted-content
+    - include: expression-content
 
   assignment-value-meta:
     - meta_include_prototype: false
diff --git a/ShellScript/Bash/tests/syntax_test_scope.bash b/ShellScript/Bash/tests/syntax_test_scope.bash
index c409b18b04..845c9f85b9 100644
--- a/ShellScript/Bash/tests/syntax_test_scope.bash
+++ b/ShellScript/Bash/tests/syntax_test_scope.bash
@@ -3621,64 +3621,69 @@ array=([one]== ["two"]='what' [4+5]=qux [five]=0 [six]=0s)
 declare -a array
 array[500]=value
 #<- meta.assignment.l-value.shell variable.other.readwrite.shell
-#^^^^ meta.assignment.l-value.shell - meta.sequence
+#^^^^ meta.assignment.l-value.shell - meta.item-access
 #    ^^^^^ meta.assignment.l-value.shell meta.item-access.shell
-#         ^ meta.assignment.shell - meta.sequence
+#         ^ meta.assignment.shell - meta.item-access
 #          ^^^^^ meta.assignment.r-value.shell meta.string.glob.shell string.unquoted.shell
 #               ^ - meta
 #^^^^ variable.other.readwrite.shell
 #    ^ punctuation.section.item-access.begin.shell
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.number.integer.decimal.shell constant.numeric.value.shell
 #        ^ punctuation.section.item-access.end.shell
 #         ^ keyword.operator.assignment
 #          ^^^^^ meta.string.glob.shell string.unquoted.shell
 
 array["foo"]=bar
 #<- meta.assignment.l-value.shell variable.other.readwrite.shell
-#^^^^ meta.assignment.l-value.shell - meta.sequence
-#    ^^^^^^^ meta.assignment.l-value.shell meta.item-access.shell
-#           ^ meta.assignment.shell - meta.sequence
+#^^^^ meta.assignment.l-value.shell - meta.item-access
+#    ^ meta.assignment.l-value.shell meta.item-access.shell - meta.arithmetic
+#     ^^^^^ meta.assignment.l-value.shell meta.item-access.shell meta.arithmetic.shell
+#          ^ meta.assignment.l-value.shell meta.item-access.shell - meta.arithmetic
+#           ^ meta.assignment.shell - meta.item-access
 #            ^^^ meta.assignment.r-value.shell meta.string.glob.shell string.unquoted.shell
 #               ^ - meta
 #^^^^ variable.other.readwrite.shell
-#    ^^^^^^^ meta.item-access.shell - variable
 #    ^ punctuation.section.item-access.begin.shell
-#     ^^^^^ string.quoted.double.shell
+#     ^ punctuation.definition.quoted.begin.shell
+#      ^^^ variable.other.readwrite.shell
+#         ^ punctuation.definition.quoted.end.shell
 #          ^ punctuation.section.item-access.end.shell
 #           ^ keyword.operator.assignment.shell
 #            ^^^ meta.string.glob.shell string.unquoted.shell
 
 array[foo]=bar
 #<- meta.assignment.l-value.shell variable.other.readwrite.shell
-#^^^^ meta.assignment.l-value.shell - meta.sequence
+#^^^^ meta.assignment.l-value.shell - meta.item-access
 #    ^^^^^ meta.assignment.l-value.shell meta.item-access.shell
-#         ^ meta.assignment.shell - meta.sequence
+#         ^ meta.assignment.shell - meta.item-access
 #          ^^^ meta.assignment.r-value.shell meta.string.glob.shell string.unquoted.shell
 #             ^ - meta
-#    ^^^^^ meta.item-access.shell
 #    ^ punctuation.section.item-access.begin.shell - variable
-#     ^^^ meta.string.shell string.unquoted.shell
+#     ^^^ meta.arithmetic.shell variable.other.readwrite.shell
 #        ^ punctuation.section.item-access.end.shell - variable
 #         ^ keyword.operator.assignment.shell
 #          ^^^ meta.string.glob.shell string.unquoted.shell
 
 foo[${j}+10]="`foo`"
 #<- meta.assignment.l-value.shell variable.other.readwrite.shell
-#^^^ meta.assignment.l-value.shell - meta.sequence
-#  ^^^^^^^^^ meta.assignment.l-value.shell meta.item-access.shell
-#           ^ meta.assignment.shell - meta.sequence
+#^^ meta.assignment.l-value.shell - meta.item-access
+#  ^ meta.assignment.l-value.shell meta.item-access.shell - meta.arithmetic
+#   ^^^^^^^ meta.assignment.l-value.shell meta.item-access.shell meta.arithmetic.shell
+#          ^ meta.assignment.l-value.shell meta.item-access.shell - meta.arithmetic
+#           ^ meta.assignment.shell - meta.item-access
 #            ^ meta.assignment.r-value.shell meta.string.glob.shell - meta.interpolation
 #             ^^^^^ meta.assignment.r-value.shell meta.string.glob.shell meta.interpolation.command.shell
 #                  ^ meta.assignment.r-value.shell meta.string.glob.shell - meta.interpolation
 #                   ^ - meta
 #^^ variable.other.readwrite.shell
 #  ^ punctuation.section.item-access.begin.shell
-#   ^^^^ meta.string.shell meta.interpolation.parameter.shell
+#   ^^^^ meta.interpolation.parameter.shell
 #   ^ punctuation.definition.variable.shell
 #    ^ punctuation.section.interpolation.begin.shell
 #     ^ variable.other.readwrite.shell
 #      ^ punctuation.section.interpolation.end.shell
-#       ^^^ meta.string.shell string.unquoted.shell
+#       ^ keyword.operator.arithmetic.shell
+#        ^^ meta.number.integer.decimal.shell constant.numeric.value.shell
 #          ^ punctuation.section.item-access.end.shell
 #           ^ keyword.operator.assignment.shell
 #            ^ string.quoted.double.shell punctuation.definition.string.begin.shell
@@ -11175,7 +11180,7 @@ let var[10]=5*(20+$idx)
 #   ^^^ variable.other.readwrite.shell
 #      ^^^^ meta.item-access.shell
 #      ^ punctuation.section.item-access.begin.shell
-#       ^^ meta.string.shell string.unquoted.shell
+#       ^^ constant.numeric.value.shell
 #         ^ punctuation.section.item-access.end.shell
 #          ^ keyword.operator.assignment.shell
 #           ^ meta.number.integer.decimal.shell constant.numeric.value.shell
diff --git a/ShellScript/Zsh/tests/syntax_test_scope.zsh b/ShellScript/Zsh/tests/syntax_test_scope.zsh
index ce0c6748d4..1b75cb14bb 100644
--- a/ShellScript/Zsh/tests/syntax_test_scope.zsh
+++ b/ShellScript/Zsh/tests/syntax_test_scope.zsh
@@ -5781,9 +5781,9 @@ var[1]=Hello
 # <- variable.other.readwrite.shell
 #^^ variable.other.readwrite.shell
 #  ^^^ meta.item-access.shell
-#  ^ punctuation.section.item-access.begin.shell - meta.string - string
-#   ^ meta.string.shell string.unquoted.shell - punctuation
-#    ^ punctuation.section.item-access.end.shell - meta.string - string
+#  ^ punctuation.section.item-access.begin.shell
+#   ^ meta.arithmetic.shell meta.number.integer.decimal.shell constant.numeric.value.shell
+#    ^ punctuation.section.item-access.end.shell
 #     ^ keyword.operator.assignment.shell
 #      ^^^^^ meta.string.glob.shell string.unquoted.shell
 
@@ -5793,9 +5793,9 @@ echo $var[1] World
 #   ^^^^^^^^^^^^^^ meta.function-call.arguments.shell
 #    ^^^^^^^ meta.string.glob.shell meta.interpolation.parameter.shell
 #        ^^^ meta.item-access.shell - variable
-#        ^ punctuation.section.item-access.begin.shell - string
-#         ^ meta.string.glob.shell string.unquoted.shell
-#          ^ punctuation.section.item-access.end.shell - string
+#        ^ punctuation.section.item-access.begin.shell
+#         ^ meta.arithmetic.shell meta.number.integer.decimal.shell constant.numeric.value.shell
+#          ^ punctuation.section.item-access.end.shell
 #            ^^^^^ meta.string.glob.shell string.unquoted.shell - meta.interpolation
 
 

From 87b2a78bf8a8e1c4c28e919612bc6be03bc5c231 Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Sun, 22 Sep 2024 10:30:11 +0200
Subject: [PATCH 109/113] [Makefile] Move extended ShellScript syntax

---
 .../Shell (for Makefile).sublime-syntax}                        | 0
 Makefile/Makefile.sublime-syntax                                | 2 +-
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename Makefile/{Makefile Shell.sublime-syntax => Embeddings/Shell (for Makefile).sublime-syntax} (100%)

diff --git a/Makefile/Makefile Shell.sublime-syntax b/Makefile/Embeddings/Shell (for Makefile).sublime-syntax
similarity index 100%
rename from Makefile/Makefile Shell.sublime-syntax
rename to Makefile/Embeddings/Shell (for Makefile).sublime-syntax
diff --git a/Makefile/Makefile.sublime-syntax b/Makefile/Makefile.sublime-syntax
index 3235b06b23..5c7ab9b8c3 100644
--- a/Makefile/Makefile.sublime-syntax
+++ b/Makefile/Makefile.sublime-syntax
@@ -314,7 +314,7 @@ contexts:
     - include: shell-content
 
   shell-content:
-    - include: Packages/Makefile/Makefile Shell.sublime-syntax
+    - include: Packages/Makefile/Embeddings/Shell (for Makefile).sublime-syntax
       apply_prototype: true
 
   line-continuation:

From fdf73d49ab6bfcf332b7d0250e90f84b452b65f2 Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Sun, 22 Sep 2024 11:00:03 +0200
Subject: [PATCH 110/113] [ShellScript] Add test patterns to common ZSH
 examples

---
 ShellScript/Zsh/tests/syntax_test_scope.zsh | 709 ++++++++++++++++++++
 1 file changed, 709 insertions(+)

diff --git a/ShellScript/Zsh/tests/syntax_test_scope.zsh b/ShellScript/Zsh/tests/syntax_test_scope.zsh
index 1b75cb14bb..e32726573d 100644
--- a/ShellScript/Zsh/tests/syntax_test_scope.zsh
+++ b/ShellScript/Zsh/tests/syntax_test_scope.zsh
@@ -5733,46 +5733,755 @@ print -rC1 b*.pro(#q:s/pro/shmo/)(#q.:s@builtin@"sh${mi}ltin"@)
 
 # https://wiki.zshell.dev/community/zsh_guide/roadmap/expansion
 ls *(.)                              # List just regular files
+#^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+# ^^^^^ meta.function-call.arguments.shell
+#  ^^^^ meta.string.glob.shell
+#  ^ string.unquoted.shell constant.other.wildcard.asterisk.shell
+#   ^^^ meta.modifier.glob.shell.zsh
+#   ^ punctuation.definition.modifier.begin.shell.zsh
+#    ^ storage.modifier.glob.shell.zsh
+#     ^ punctuation.definition.modifier.end.shell.zsh
+#                                    ^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 ls -ld *(/om[1,3])                   # Show three newest directories, "om" orders by modification. "[1,3]" works like Python slice
+#^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+# ^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
+#  ^^^ meta.parameter.option.shell variable.parameter.option.shell
+#  ^ punctuation.definition.parameter.shell
+#      ^^^^^^^^^^^ meta.string.glob.shell
+#      ^ string.unquoted.shell constant.other.wildcard.asterisk.shell
+#       ^^^^^^^^^^ meta.modifier.glob.shell.zsh
+#       ^ punctuation.definition.modifier.begin.shell.zsh
+#        ^^^ storage.modifier.glob.shell.zsh
+#           ^^^^^ meta.range.glob.shell.zsh
+#           ^ punctuation.definition.range.begin.shell.zsh
+#            ^^^ meta.arithmetic.shell
+#            ^ meta.number.integer.decimal.shell constant.numeric.value.shell
+#             ^ punctuation.separator.sequence.shell
+#              ^ meta.number.integer.decimal.shell constant.numeric.value.shell
+#               ^ punctuation.definition.range.end.shell.zsh
+#                ^ punctuation.definition.modifier.end.shell.zsh
+#                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 rm -i *(.L0)                         # Remove zero length files, prompt for each file
+#^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+# ^^^^^^^^^^ meta.function-call.arguments.shell
+#  ^^ meta.parameter.option.shell variable.parameter.option.shell
+#  ^ punctuation.definition.parameter.shell
+#     ^^^^^^ meta.string.glob.shell
+#     ^ string.unquoted.shell constant.other.wildcard.asterisk.shell
+#      ^^^^^ meta.modifier.glob.shell.zsh
+#      ^ punctuation.definition.modifier.begin.shell.zsh
+#       ^^ storage.modifier.glob.shell.zsh
+#         ^ meta.number.integer.decimal.shell constant.numeric.value.shell
+#          ^ punctuation.definition.modifier.end.shell.zsh
+#                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 ls *(^m0)                            # Files not modified today
+#^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+# ^^^^^^^ meta.function-call.arguments.shell
+#  ^^^^^^ meta.string.glob.shell
+#  ^ string.unquoted.shell constant.other.wildcard.asterisk.shell
+#   ^^^^^ meta.modifier.glob.shell.zsh
+#   ^ punctuation.definition.modifier.begin.shell.zsh
+#    ^ keyword.operator.logical.shell.zsh
+#     ^ storage.modifier.glob.shell.zsh
+#      ^ meta.number.integer.decimal.shell constant.numeric.value.shell
+#       ^ punctuation.definition.modifier.end.shell.zsh
+#                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 ls **/*(.x)                          # List all executable files in this tree
+#^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+# ^^^^^^^^^ meta.function-call.arguments.shell
+#  ^^^^^^^^ meta.string.glob.shell
+#  ^^ constant.other.wildcard.asterisk.shell
+#     ^ constant.other.wildcard.asterisk.shell
+#      ^^^^ meta.modifier.glob.shell.zsh
+#      ^ punctuation.definition.modifier.begin.shell.zsh
+#       ^^ storage.modifier.glob.shell.zsh
+#         ^ punctuation.definition.modifier.end.shell.zsh
+#                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 ls *~*.*(.)                          # List all files that does not have a dot in the filename
+#^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+# ^^^^^^^^^ meta.function-call.arguments.shell
+#  ^^^^^^^^ meta.string.glob.shell
+#  ^^^^^ string.unquoted.shell
+#  ^ constant.other.wildcard.asterisk.shell
+#   ^ keyword.operator.logical.regexp.shell.zsh
+#    ^ constant.other.wildcard.asterisk.shell
+#      ^ constant.other.wildcard.asterisk.shell
+#       ^^^ meta.modifier.glob.shell.zsh
+#       ^ punctuation.definition.modifier.begin.shell.zsh
+#        ^ storage.modifier.glob.shell.zsh
+#         ^ punctuation.definition.modifier.end.shell.zsh
+#                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 ls -l */**(Lk+100)                   # List all files larger than 100kb in this tree
+#^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+# ^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
+#  ^^ meta.parameter.option.shell variable.parameter.option.shell
+#  ^ punctuation.definition.parameter.shell
+#     ^^^^^^^^^^^^ meta.string.glob.shell
+#     ^^^^ string.unquoted.shell
+#     ^ constant.other.wildcard.asterisk.shell
+#       ^^ constant.other.wildcard.asterisk.shell
+#         ^^^^^^^^ meta.modifier.glob.shell.zsh
+#         ^ punctuation.definition.modifier.begin.shell.zsh
+#          ^^ storage.modifier.glob.shell.zsh
+#            ^^^^ meta.number.integer.decimal.shell
+#            ^ keyword.operator.arithmetic.shell
+#             ^^^ constant.numeric.value.shell
+#                ^ punctuation.definition.modifier.end.shell.zsh
+#                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 ls DATA_[0-9](#c4,7).csv             # List DATA_nnnn.csv to DATA_nnnnnnn.csv
+#^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+# ^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
+#  ^^^^^^^^^^^^^^^^^^^^^ meta.string.glob.shell
+#  ^^^^^^^^^^ string.unquoted.shell
+#       ^^^^^ meta.set.regexp.shell
+#       ^ punctuation.definition.set.begin.regexp.shell
+#        ^^^ constant.other.range.regexp.shell
+#         ^ punctuation.separator.sequence.regexp.shell
+#           ^ punctuation.definition.set.end.regexp.shell
+#            ^^^^^^^ meta.modifier.glob.shell.zsh
+#            ^^ punctuation.definition.modifier.begin.shell.zsh
+#              ^^^^ storage.modifier.mode.glob.shell.zsh
+#                ^ punctuation.separator.sequence.shell
+#                  ^ punctuation.definition.modifier.end.shell.zsh
+#                   ^^^^ string.unquoted.shell
+#                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 rm ../debianpackage(.)               # Remove files only
+#^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+# ^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
+#  ^^^^^^^^^^^^^^^^^^^ meta.string.glob.shell
+#  ^^^^^^^^^^^^^^^^ string.unquoted.shell
+#                  ^^^ meta.modifier.glob.shell.zsh
+#                  ^ punctuation.definition.modifier.begin.shell.zsh
+#                   ^ storage.modifier.glob.shell.zsh
+#                    ^ punctuation.definition.modifier.end.shell.zsh
+#                                    ^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 ls -d *(/)                           # List directories only
+#^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+# ^^^^^^^^ meta.function-call.arguments.shell
+#  ^^ meta.parameter.option.shell variable.parameter.option.shell
+#  ^ punctuation.definition.parameter.shell
+#     ^^^^ meta.string.glob.shell
+#     ^ string.unquoted.shell constant.other.wildcard.asterisk.shell
+#      ^^^ meta.modifier.glob.shell.zsh
+#      ^ punctuation.definition.modifier.begin.shell.zsh
+#       ^ storage.modifier.glob.shell.zsh
+#        ^ punctuation.definition.modifier.end.shell.zsh
+#                                    ^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 ls /etc/*(@)                         # List symlinks only
+#^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+# ^^^^^^^^^^ meta.function-call.arguments.shell
+#  ^^^^^^^^^ meta.string.glob.shell
+#  ^^^^^^ string.unquoted.shell
+#       ^ constant.other.wildcard.asterisk.shell
+#        ^^^ meta.modifier.glob.shell.zsh
+#        ^ punctuation.definition.modifier.begin.shell.zsh
+#         ^ storage.modifier.glob.shell.zsh
+#          ^ punctuation.definition.modifier.end.shell.zsh
+#                                    ^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 ls -l *.(png|jpg|gif)                # List pictures only
+#^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+# ^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
+#  ^^ meta.parameter.option.shell variable.parameter.option.shell
+#  ^ punctuation.definition.parameter.shell
+#     ^^^^^^^^^^^^^^^ meta.string.glob.shell
+#     ^^ string.unquoted.shell
+#     ^ constant.other.wildcard.asterisk.shell
+#       ^^^^^^^^^^^^^ meta.group.regexp.shell string.unquoted.shell
+#       ^ punctuation.section.group.begin.regexp.shell
+#           ^ keyword.operator.alternation.regexp.shell
+#               ^ keyword.operator.alternation.regexp.shell
+#                   ^ punctuation.section.group.end.regexp.shell
+#                                    ^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 ls *(*)                              # List executables only
+#^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+# ^^^^^ meta.function-call.arguments.shell
+#  ^^^^ meta.string.glob.shell
+#  ^ string.unquoted.shell constant.other.wildcard.asterisk.shell
+#   ^^^ meta.modifier.glob.shell.zsh
+#   ^ punctuation.definition.modifier.begin.shell.zsh
+#    ^ storage.modifier.glob.shell.zsh
+#     ^ punctuation.definition.modifier.end.shell.zsh
+#                                    ^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 ls /etc/**/zsh                       # Which directories contain zsh?
+#^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+# ^^^^^^^^^^^^ meta.function-call.arguments.shell
+#  ^^^^^^^^^^^ meta.string.glob.shell string.unquoted.shell
+#       ^^ constant.other.wildcard.asterisk.shell
+#                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 ls **/*(-@)                          # List dangling symlinks (** recurses down directory trees)
+#^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+# ^^^^^^^^^ meta.function-call.arguments.shell
+#  ^^^^^^^^ meta.string.glob.shell
+#  ^^^^ string.unquoted.shell
+#  ^^ constant.other.wildcard.asterisk.shell
+#     ^ constant.other.wildcard.asterisk.shell
+#      ^^^^ meta.modifier.glob.shell.zsh
+#      ^ punctuation.definition.modifier.begin.shell.zsh
+#       ^ keyword.operator.logical.shell.zsh
+#        ^ storage.modifier.glob.shell.zsh
+#         ^ punctuation.definition.modifier.end.shell.zsh
+#                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 ls foo*~*bar*                        # Match everything that starts with foo but doesn't contain bar
+#^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+# ^^^^^^^^^^^ meta.function-call.arguments.shell
+#  ^^^^^^^^^^ meta.string.glob.shell string.unquoted.shell
+#     ^ constant.other.wildcard.asterisk.shell
+#      ^ keyword.operator.logical.regexp.shell.zsh
+#       ^ constant.other.wildcard.asterisk.shell
+#           ^ constant.other.wildcard.asterisk.shell
+#                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 ls *(e:'file $REPLY | grep -q JPEG':) # Match all files of which file says that they are JPEGs
+#^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
+#  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.glob.shell
+#  ^ string.unquoted.shell constant.other.wildcard.asterisk.shell
+#   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.modifier.glob.shell.zsh
+#   ^ punctuation.definition.modifier.begin.shell.zsh
+#    ^ storage.modifier.glob.shell.zsh
+#     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.quoted.glob.shell.zsh
+#     ^ punctuation.definition.quoted.begin.shell.zsh
+#      ^ punctuation.definition.quoted.begin.shell
+#       ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interpolation.command.shell
+#       ^^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+#           ^^^^^^^ meta.function-call.arguments.shell
+#            ^^^^^^ meta.string.glob.shell meta.interpolation.parameter.shell variable.language.builtin.shell
+#            ^ punctuation.definition.variable.shell
+#                   ^ keyword.operator.assignment.pipe.shell
+#                     ^^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+#                         ^^^^^^^^ meta.function-call.arguments.shell
+#                          ^^ meta.parameter.option.shell variable.parameter.option.shell
+#                          ^ punctuation.definition.parameter.shell
+#                             ^^^^ meta.string.glob.shell string.unquoted.shell
+#                                 ^ punctuation.definition.quoted.end.shell
+#                                  ^ punctuation.definition.quoted.end.shell.zsh
+#                                   ^ punctuation.definition.modifier.end.shell.zsh
+#                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                     ^ punctuation.definition.comment.shell
+
 ls -ldrt -- *(mm+15)                 # List all files older than 15mins
+#^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+# ^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
+#  ^^^^^ meta.parameter.option.shell variable.parameter.option.shell
+#  ^ punctuation.definition.parameter.shell
+#        ^^ keyword.operator.end-of-options.shell
+#           ^^^^^^^^ meta.string.glob.shell
+#           ^ string.unquoted.shell constant.other.wildcard.asterisk.shell
+#            ^^^^^^^ meta.modifier.glob.shell.zsh
+#            ^ punctuation.definition.modifier.begin.shell.zsh
+#             ^^ storage.modifier.glob.shell.zsh
+#               ^^^ meta.number.integer.decimal.shell
+#               ^ keyword.operator.arithmetic.shell
+#                ^^ constant.numeric.value.shell
+#                  ^ punctuation.definition.modifier.end.shell.zsh
+#                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 ls -ldrt -- *(.mm+15)                # List just regular files
+#^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+# ^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
+#  ^^^^^ meta.parameter.option.shell variable.parameter.option.shell
+#  ^ punctuation.definition.parameter.shell
+#        ^^ keyword.operator.end-of-options.shell
+#           ^^^^^^^^^ meta.string.glob.shell
+#           ^ string.unquoted.shell constant.other.wildcard.asterisk.shell
+#            ^^^^^^^^ meta.modifier.glob.shell.zsh
+#            ^ punctuation.definition.modifier.begin.shell.zsh
+#             ^^^ storage.modifier.glob.shell.zsh
+#                ^^^ meta.number.integer.decimal.shell
+#                ^ keyword.operator.arithmetic.shell
+#                 ^^ constant.numeric.value.shell
+#                   ^ punctuation.definition.modifier.end.shell.zsh
+#                                    ^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 ls -ld /my/path/**/*(D@-^@)          # List the unbroken symlinks under a directory
+#^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+# ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
+#  ^^^ meta.parameter.option.shell variable.parameter.option.shell
+#  ^ punctuation.definition.parameter.shell
+#      ^^^^^^^^^^^^^^^^^^^^ meta.string.glob.shell
+#      ^^^^^^^^^^^^^ string.unquoted.shell
+#               ^^ constant.other.wildcard.asterisk.shell
+#                  ^ constant.other.wildcard.asterisk.shell
+#                   ^^^^^^^ meta.modifier.glob.shell.zsh
+#                   ^ punctuation.definition.modifier.begin.shell.zsh
+#                    ^^ storage.modifier.glob.shell.zsh
+#                      ^^ keyword.operator.logical.shell.zsh
+#                        ^ storage.modifier.glob.shell.zsh
+#                         ^ punctuation.definition.modifier.end.shell.zsh
+#                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 ls -Lldrt -- *(-mm+15)               # List the age of the pointed-to file for symlinks
+#^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+# ^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
+#  ^^^^^^ meta.parameter.option.shell variable.parameter.option.shell
+#  ^ punctuation.definition.parameter.shell
+#         ^^ keyword.operator.end-of-options.shell
+#            ^^^^^^^^^ meta.string.glob.shell
+#            ^ string.unquoted.shell constant.other.wildcard.asterisk.shell
+#             ^^^^^^^^ meta.modifier.glob.shell.zsh
+#             ^ punctuation.definition.modifier.begin.shell.zsh
+#              ^ keyword.operator.logical.shell.zsh
+#               ^^ storage.modifier.glob.shell.zsh
+#                 ^^^ meta.number.integer.decimal.shell
+#                 ^ keyword.operator.arithmetic.shell
+#                  ^^ constant.numeric.value.shell
+#                    ^ punctuation.definition.modifier.end.shell.zsh
+#                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 ls -l **/README                      # Search for README in all Subdirectories
+#^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+# ^^^^^^^^^^^^^ meta.function-call.arguments.shell
+#  ^^ meta.parameter.option.shell variable.parameter.option.shell
+#  ^ punctuation.definition.parameter.shell
+#     ^^^^^^^^^ meta.string.glob.shell string.unquoted.shell
+#     ^^ constant.other.wildcard.asterisk.shell
+#                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 ls -l foo<23->                       # List files beginning at foo23 upwards (foo23, foo24, foo25, ..)
+#^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+# ^^^^^^^^^^^^ meta.function-call.arguments.shell
+#  ^^ meta.parameter.option.shell variable.parameter.option.shell
+#  ^ punctuation.definition.parameter.shell
+#     ^^^^^^^^ meta.string.glob.shell
+#     ^^^ string.unquoted.shell
+#        ^^^^^ meta.range.shell.zsh
+#        ^ punctuation.definition.range.begin.shell.zsh
+#         ^^ meta.number.integer.decimal.shell constant.numeric.value.shell
+#           ^ keyword.operator.range.shell.zsh
+#            ^ punctuation.definition.range.end.shell.zsh
+#                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 ls -l 200406{04..10}*(N)             # List all files that begin with the date strings from June 4 through June 9 of 2004
+#^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+# ^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
+#  ^^ meta.parameter.option.shell variable.parameter.option.shell
+#  ^ punctuation.definition.parameter.shell
+#     ^^^^^^^^^^^^^^^^^^ meta.string.glob.shell
+#     ^^^^^^ string.unquoted.shell
+#           ^^^^^^^^ meta.interpolation.brace.shell
+#           ^ punctuation.section.interpolation.begin.shell
+#            ^^ meta.number.integer.decimal.shell constant.numeric.value.shell
+#              ^^ keyword.operator.range.shell
+#                ^^ meta.number.integer.decimal.shell constant.numeric.value.shell
+#                  ^ punctuation.section.interpolation.end.shell
+#                   ^ string.unquoted.shell constant.other.wildcard.asterisk.shell
+#                    ^^^ meta.modifier.glob.shell.zsh
+#                    ^ punctuation.definition.modifier.begin.shell.zsh
+#                     ^ storage.modifier.glob.shell.zsh
+#                      ^ punctuation.definition.modifier.end.shell.zsh
+#                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 ls -l 200406<4-10>.*                 # List will match the form of 200406XX
+#^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+# ^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
+#  ^^ meta.parameter.option.shell variable.parameter.option.shell
+#  ^ punctuation.definition.parameter.shell
+#     ^^^^^^^^^^^^^^ meta.string.glob.shell
+#     ^^^^^^ string.unquoted.shell
+#           ^^^^^^ meta.range.shell.zsh
+#           ^ punctuation.definition.range.begin.shell.zsh
+#            ^ meta.number.integer.decimal.shell constant.numeric.value.shell
+#             ^ keyword.operator.range.shell.zsh
+#              ^^ meta.number.integer.decimal.shell constant.numeric.value.shell
+#                ^ punctuation.definition.range.end.shell.zsh
+#                 ^^ string.unquoted.shell
+#                  ^ constant.other.wildcard.asterisk.shell
+#                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 ls -l *.(c|h)                        # Show only all *.c and *.h files
+#^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+# ^^^^^^^^^^^ meta.function-call.arguments.shell
+#  ^^ meta.parameter.option.shell variable.parameter.option.shell
+#  ^ punctuation.definition.parameter.shell
+#     ^^^^^^^ meta.string.glob.shell
+#     ^^ string.unquoted.shell
+#     ^ constant.other.wildcard.asterisk.shell
+#       ^^^^^ meta.group.regexp.shell string.unquoted.shell
+#       ^ punctuation.section.group.begin.regexp.shell
+#         ^ keyword.operator.alternation.regexp.shell
+#           ^ punctuation.section.group.end.regexp.shell
+#                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 ls -l *(R)                           # Show only world-readable files
+#^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+# ^^^^^^^^ meta.function-call.arguments.shell
+#  ^^ meta.parameter.option.shell variable.parameter.option.shell
+#  ^ punctuation.definition.parameter.shell
+#     ^^^^ meta.string.glob.shell
+#     ^ string.unquoted.shell constant.other.wildcard.asterisk.shell
+#      ^^^ meta.modifier.glob.shell.zsh
+#      ^ punctuation.definition.modifier.begin.shell.zsh
+#       ^ storage.modifier.glob.shell.zsh
+#        ^ punctuation.definition.modifier.end.shell.zsh
+#                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 ls -fld *(OL)                        # Sort the output from ls -l by file size
+#^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+# ^^^^^^^^^^^ meta.function-call.arguments.shell
+#  ^^^^ meta.parameter.option.shell variable.parameter.option.shell
+#  ^ punctuation.definition.parameter.shell
+#       ^^^^^ meta.string.glob.shell
+#       ^ string.unquoted.shell constant.other.wildcard.asterisk.shell
+#        ^^^^ meta.modifier.glob.shell.zsh
+#        ^ punctuation.definition.modifier.begin.shell.zsh
+#         ^^ storage.modifier.glob.shell.zsh
+#           ^ punctuation.definition.modifier.end.shell.zsh
+#                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 ls -fl *(DOL[1,5])                   # Print only 5 lines by the ls command (is equal to: ls -laS | head -n 5)
+#^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+# ^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
+#  ^^^ meta.parameter.option.shell variable.parameter.option.shell
+#  ^ punctuation.definition.parameter.shell
+#      ^^^^^^^^^^^ meta.string.glob.shell
+#      ^ string.unquoted.shell constant.other.wildcard.asterisk.shell
+#       ^^^^^^^^^^ meta.modifier.glob.shell.zsh
+#       ^ punctuation.definition.modifier.begin.shell.zsh
+#        ^^^ storage.modifier.glob.shell.zsh
+#           ^^^^^ meta.range.glob.shell.zsh
+#           ^ punctuation.definition.range.begin.shell.zsh
+#            ^^^ meta.arithmetic.shell
+#            ^ meta.number.integer.decimal.shell constant.numeric.value.shell
+#             ^ punctuation.separator.sequence.shell
+#              ^ meta.number.integer.decimal.shell constant.numeric.value.shell
+#               ^ punctuation.definition.range.end.shell.zsh
+#                ^ punctuation.definition.modifier.end.shell.zsh
+#                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 ls -l *(G[users])                    # Show only files are owned from group users
+#^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+# ^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
+#  ^^ meta.parameter.option.shell variable.parameter.option.shell
+#  ^ punctuation.definition.parameter.shell
+#     ^^^^^^^^^^^ meta.string.glob.shell
+#     ^ string.unquoted.shell constant.other.wildcard.asterisk.shell
+#      ^^^^^^^^^^ meta.modifier.glob.shell.zsh
+#      ^ punctuation.definition.modifier.begin.shell.zsh
+#       ^ storage.modifier.glob.shell.zsh
+#        ^^^^^^^ meta.quoted.glob.shell.zsh
+#        ^ punctuation.definition.quoted.begin.shell.zsh
+#         ^^^^^ string.quoted.other.shell.zsh
+#              ^ punctuation.definition.quoted.end.shell.zsh
+#               ^ punctuation.definition.modifier.end.shell.zsh
+#                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 ls *(L0f.go-w.)                      # Show only empty files which nor group or world writable
+#^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+# ^^^^^^^^^^^^^ meta.function-call.arguments.shell
+#  ^^^^^^^^^^^^ meta.string.glob.shell
+#  ^ string.unquoted.shell constant.other.wildcard.asterisk.shell
+#   ^^^^^^^^^^^ meta.modifier.glob.shell.zsh
+#   ^ punctuation.definition.modifier.begin.shell.zsh
+#    ^ storage.modifier.glob.shell.zsh
+#     ^ meta.number.integer.decimal.shell constant.numeric.value.shell
+#      ^ storage.modifier.glob.shell.zsh
+#       ^^^^^^ meta.quoted.glob.shell.zsh
+#       ^ punctuation.definition.quoted.begin.shell.zsh
+#        ^^^^ string.quoted.other.shell.zsh
+#            ^ punctuation.definition.quoted.end.shell.zsh
+#             ^ punctuation.definition.modifier.end.shell.zsh
+#                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 ls *.c~foo.c                         # Show only all *.c files and ignore foo.c
+#^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+# ^^^^^^^^^^ meta.function-call.arguments.shell
+#  ^^^^^^^^^ meta.string.glob.shell string.unquoted.shell
+#  ^ constant.other.wildcard.asterisk.shell
+#     ^ keyword.operator.logical.regexp.shell.zsh
+#                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 print -rl /home/me/**/*(D/e{'reply=($REPLY/*(N[-1]:t))'})  # Find all directories, list their contents, and output the first item in the above list
+#^^^^ meta.function-call.identifier.shell meta.command.shell support.function.shell
+#    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
+#     ^^^ meta.parameter.option.shell variable.parameter.option.shell
+#     ^ punctuation.definition.parameter.shell
+#         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.glob.shell
+#         ^^^^^^^^^^^^^ string.unquoted.shell
+#                  ^^ constant.other.wildcard.asterisk.shell
+#                     ^ constant.other.wildcard.asterisk.shell
+#                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.modifier.glob.shell.zsh
+#                      ^ punctuation.definition.modifier.begin.shell.zsh
+#                       ^^^ storage.modifier.glob.shell.zsh
+#                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.quoted.glob.shell.zsh
+#                          ^ punctuation.definition.quoted.begin.shell.zsh
+#                           ^ punctuation.definition.quoted.begin.shell
+#                            ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.interpolation.command.shell
+#                            ^^^^^ meta.assignment.l-value.shell variable.language.builtin.shell
+#                                 ^ meta.assignment.shell keyword.operator.assignment.shell
+#                                  ^^^^^^^^^^^^^^^^^^^ meta.assignment.r-value.shell meta.sequence.list.shell
+#                                  ^ punctuation.section.sequence.begin.shell
+#                                   ^^^^^^^^^^^^^^^^^ meta.string.glob.shell
+#                                   ^^^^^^ meta.interpolation.parameter.shell variable.language.builtin.shell
+#                                   ^ punctuation.definition.variable.shell
+#                                         ^^ string.unquoted.shell
+#                                          ^ constant.other.wildcard.asterisk.shell
+#                                           ^^^^^^^^^ meta.modifier.glob.shell.zsh
+#                                           ^ punctuation.definition.modifier.begin.shell.zsh
+#                                            ^ storage.modifier.glob.shell.zsh
+#                                             ^^^^ meta.range.glob.shell.zsh
+#                                             ^ punctuation.definition.range.begin.shell.zsh
+#                                              ^^ meta.arithmetic.shell
+#                                              ^ keyword.operator.arithmetic.shell
+#                                               ^ meta.number.integer.decimal.shell constant.numeric.value.shell
+#                                                ^ punctuation.definition.range.end.shell.zsh
+#                                                 ^ punctuation.separator.sequence.shell.zsh
+#                                                  ^ storage.modifier.glob.shell.zsh
+#                                                   ^ punctuation.definition.modifier.end.shell.zsh
+#                                                    ^ punctuation.section.sequence.end.shell
+#                                                     ^ punctuation.definition.quoted.end.shell
+#                                                      ^ punctuation.definition.quoted.end.shell.zsh
+#                                                       ^ punctuation.definition.modifier.end.shell.zsh
+#                                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                                          ^ punctuation.definition.comment.shell
+
 print -rl /**/*~^*/path(|/*)         # Find command to search for directory name instead of basename
+#^^^^ meta.function-call.identifier.shell meta.command.shell support.function.shell
+#    ^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
+#     ^^^ meta.parameter.option.shell variable.parameter.option.shell
+#     ^ punctuation.definition.parameter.shell
+#         ^^^^^^^^^^^^^^^^^^ meta.string.glob.shell
+#         ^^^^^^^^^^^^^ string.unquoted.shell
+#          ^^ constant.other.wildcard.asterisk.shell
+#             ^ constant.other.wildcard.asterisk.shell
+#              ^^ keyword.operator.logical.regexp.shell.zsh
+#                ^ constant.other.wildcard.asterisk.shell
+#                      ^^^^^ meta.group.regexp.shell string.unquoted.shell
+#                      ^ punctuation.section.group.begin.regexp.shell
+#                       ^ keyword.operator.alternation.regexp.shell
+#                         ^ constant.other.wildcard.asterisk.shell
+#                          ^ punctuation.section.group.end.regexp.shell
+#                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 print -l ~/*(ND.^w)                  # List files in the current directory that are not writable by the owner
+#^^^^ meta.function-call.identifier.shell meta.command.shell support.function.shell
+#    ^^^^^^^^^^^^^^ meta.function-call.arguments.shell
+#     ^^ meta.parameter.option.shell variable.parameter.option.shell
+#     ^ punctuation.definition.parameter.shell
+#        ^^^^^^^^^^ meta.string.glob.shell
+#        ^ meta.interpolation.tilde.shell variable.language.tilde.shell
+#         ^^ string.unquoted.shell
+#          ^ constant.other.wildcard.asterisk.shell
+#           ^^^^^^^ meta.modifier.glob.shell.zsh
+#           ^ punctuation.definition.modifier.begin.shell.zsh
+#            ^^^ storage.modifier.glob.shell.zsh
+#               ^ keyword.operator.logical.shell.zsh
+#                ^ storage.modifier.glob.shell.zsh
+#                 ^ punctuation.definition.modifier.end.shell.zsh
+#                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 print -rl -- *(Dmh+10^/)             # List all files which have not been updated in the last 10 hours
+#^^^^ meta.function-call.identifier.shell meta.command.shell support.function.shell
+#    ^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
+#     ^^^ meta.parameter.option.shell variable.parameter.option.shell
+#     ^ punctuation.definition.parameter.shell
+#         ^^ keyword.operator.end-of-options.shell
+#            ^^^^^^^^^^^ meta.string.glob.shell
+#            ^ string.unquoted.shell constant.other.wildcard.asterisk.shell
+#             ^^^^^^^^^^ meta.modifier.glob.shell.zsh
+#             ^ punctuation.definition.modifier.begin.shell.zsh
+#              ^^^ storage.modifier.glob.shell.zsh
+#                 ^^^ meta.number.integer.decimal.shell
+#                 ^ keyword.operator.arithmetic.shell
+#                  ^^ constant.numeric.value.shell
+#                    ^ keyword.operator.logical.shell.zsh
+#                     ^ storage.modifier.glob.shell.zsh
+#                      ^ punctuation.definition.modifier.end.shell.zsh
+#                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 print -rl -- **/*(Dom[1,10])         # List the ten newest files in directories and subdirectories (recursive)
+#^^^^ meta.function-call.identifier.shell meta.command.shell support.function.shell
+#    ^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
+#     ^^^ meta.parameter.option.shell variable.parameter.option.shell
+#     ^ punctuation.definition.parameter.shell
+#         ^^ keyword.operator.end-of-options.shell
+#            ^^^^^^^^^^^^^^^ meta.string.glob.shell
+#            ^^^^ string.unquoted.shell
+#            ^^ constant.other.wildcard.asterisk.shell
+#               ^ constant.other.wildcard.asterisk.shell
+#                ^^^^^^^^^^^ meta.modifier.glob.shell.zsh
+#                ^ punctuation.definition.modifier.begin.shell.zsh
+#                 ^^^ storage.modifier.glob.shell.zsh
+#                    ^^^^^^ meta.range.glob.shell.zsh
+#                    ^ punctuation.definition.range.begin.shell.zsh
+#                     ^^^^ meta.arithmetic.shell
+#                     ^ meta.number.integer.decimal.shell constant.numeric.value.shell
+#                      ^ punctuation.separator.sequence.shell
+#                       ^^ meta.number.integer.decimal.shell constant.numeric.value.shell
+#                         ^ punctuation.definition.range.end.shell.zsh
+#                          ^ punctuation.definition.modifier.end.shell.zsh
+#                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                    ^ punctuation.definition.comment.shell
+
 print -rl -- /path/to/dir/**/*(D.om[5,10])  # Display the 5-10 last modified files
+#^^^^ meta.function-call.identifier.shell meta.command.shell support.function.shell
+#    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
+#     ^^^ meta.parameter.option.shell variable.parameter.option.shell
+#     ^ punctuation.definition.parameter.shell
+#         ^^ keyword.operator.end-of-options.shell
+#            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.glob.shell
+#            ^^^^^^^^^^^^^^^^^ string.unquoted.shell
+#                         ^^ constant.other.wildcard.asterisk.shell
+#                            ^ constant.other.wildcard.asterisk.shell
+#                             ^^^^^^^^^^^^ meta.modifier.glob.shell.zsh
+#                             ^ punctuation.definition.modifier.begin.shell.zsh
+#                              ^^^^ storage.modifier.glob.shell.zsh
+#                                  ^^^^^^ meta.range.glob.shell.zsh
+#                                  ^ punctuation.definition.range.begin.shell.zsh
+#                                   ^^^^ meta.arithmetic.shell
+#                                   ^ meta.number.integer.decimal.shell constant.numeric.value.shell
+#                                    ^ punctuation.separator.sequence.shell
+#                                     ^^ meta.number.integer.decimal.shell constant.numeric.value.shell
+#                                       ^ punctuation.definition.range.end.shell.zsh
+#                                        ^ punctuation.definition.modifier.end.shell.zsh
+#                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                           ^ punctuation.definition.comment.shell
+
 print -rl -- **/*.c(D.OL[1,10]:h) | sort -u # Print the path of the directories holding the ten biggest C regular files in the current directory and subdirectories
+#^^^^ meta.function-call.identifier.shell meta.command.shell support.function.shell
+#    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
+#     ^^^ meta.parameter.option.shell variable.parameter.option.shell
+#     ^ punctuation.definition.parameter.shell
+#         ^^ keyword.operator.end-of-options.shell
+#            ^^^^^^^^^^^^^^^^^^^^ meta.string.glob.shell
+#            ^^^^^^ string.unquoted.shell
+#            ^^ constant.other.wildcard.asterisk.shell
+#               ^ constant.other.wildcard.asterisk.shell
+#                  ^^^^^^^^^^^^^^ meta.modifier.glob.shell.zsh
+#                  ^ punctuation.definition.modifier.begin.shell.zsh
+#                   ^^^^ storage.modifier.glob.shell.zsh
+#                       ^^^^^^ meta.range.glob.shell.zsh
+#                       ^ punctuation.definition.range.begin.shell.zsh
+#                        ^^^^ meta.arithmetic.shell
+#                        ^ meta.number.integer.decimal.shell constant.numeric.value.shell
+#                         ^ punctuation.separator.sequence.shell
+#                          ^^ meta.number.integer.decimal.shell constant.numeric.value.shell
+#                            ^ punctuation.definition.range.end.shell.zsh
+#                             ^ punctuation.separator.sequence.shell.zsh
+#                              ^ storage.modifier.glob.shell.zsh
+#                               ^ punctuation.definition.modifier.end.shell.zsh
+#                                 ^ keyword.operator.assignment.pipe.shell
+#                                   ^^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+#                                       ^^^ meta.function-call.arguments.shell
+#                                        ^^ meta.parameter.option.shell variable.parameter.option.shell
+#                                        ^ punctuation.definition.parameter.shell
+#                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                           ^ punctuation.definition.comment.shell
+
 print directory/**/*(om[1])                 # Find most recent file in a directory
+#^^^^ meta.function-call.identifier.shell meta.command.shell support.function.shell
+#    ^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
+#     ^^^^^^^^^^^^^^^^^^^^^ meta.string.glob.shell
+#     ^^^^^^^^^^^^^^ string.unquoted.shell
+#               ^^ constant.other.wildcard.asterisk.shell
+#                  ^ constant.other.wildcard.asterisk.shell
+#                   ^^^^^^^ meta.modifier.glob.shell.zsh
+#                   ^ punctuation.definition.modifier.begin.shell.zsh
+#                    ^^ storage.modifier.glob.shell.zsh
+#                      ^^^ meta.range.glob.shell.zsh
+#                      ^ punctuation.definition.range.begin.shell.zsh
+#                       ^ meta.arithmetic.shell meta.number.integer.decimal.shell constant.numeric.value.shell
+#                        ^ punctuation.definition.range.end.shell.zsh
+#                         ^ punctuation.definition.modifier.end.shell.zsh
+#                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                           ^ punctuation.definition.comment.shell
+
 for a in ./**/*\ *(Dod); do mv $a ${a:h}/${a:t:gs/ /_}; done   # Remove spaces from filenames
+#^^^^^^^^^^^^^^^^^^^^^^ meta.statement.loop.for.shell
+#^^ keyword.control.loop.for.shell
+#   ^ variable.other.readwrite.shell
+#     ^^ keyword.operator.iterator.in.shell
+#       ^^^^^^^^^^^^^^^ meta.sequence.list.shell
+#        ^^^^^^^^^^^^^^ meta.string.glob.shell
+#        ^^^^^^^^^ string.unquoted.shell
+#          ^^ constant.other.wildcard.asterisk.shell
+#             ^ constant.other.wildcard.asterisk.shell
+#              ^^ constant.character.escape.shell
+#                ^ constant.other.wildcard.asterisk.shell
+#                 ^^^^^ meta.modifier.glob.shell.zsh
+#                 ^ punctuation.definition.modifier.begin.shell.zsh
+#                  ^^^ storage.modifier.glob.shell.zsh
+#                     ^ punctuation.definition.modifier.end.shell.zsh
+#                      ^ punctuation.terminator.statement.shell
+#                        ^^ keyword.control.loop.do.shell
+#                           ^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
+#                             ^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.shell
+#                              ^^ meta.string.glob.shell meta.interpolation.parameter.shell variable.other.readwrite.shell
+#                              ^ punctuation.definition.variable.shell
+#                                 ^^^^^^^^^^^^^^^^^^^^ meta.string.glob.shell
+#                                 ^^^^^^ meta.interpolation.parameter.shell
+#                                 ^ punctuation.definition.variable.shell
+#                                  ^ punctuation.section.interpolation.begin.shell
+#                                   ^ variable.other.readwrite.shell
+#                                    ^ keyword.operator.substring.begin.shell
+#                                     ^ meta.arithmetic.shell variable.other.readwrite.shell
+#                                      ^ punctuation.section.interpolation.end.shell
+#                                       ^ string.unquoted.shell
+#                                        ^^^^^^^^^^^^^ meta.interpolation.parameter.shell
+#                                        ^ punctuation.definition.variable.shell
+#                                         ^ punctuation.section.interpolation.begin.shell
+#                                          ^ variable.other.readwrite.shell
+#                                           ^ keyword.operator.substring.begin.shell
+#                                            ^ meta.arithmetic.shell variable.other.readwrite.shell
+#                                             ^ keyword.operator.substring.end.shell
+#                                              ^^^^^^ meta.arithmetic.shell
+#                                              ^^ variable.other.readwrite.shell
+#                                                ^ keyword.operator.arithmetic.shell
+#                                                  ^ keyword.operator.arithmetic.shell
+#                                                   ^ variable.other.readwrite.shell
+#                                                    ^ punctuation.section.interpolation.end.shell
+#                                                     ^ punctuation.terminator.statement.shell
+#                                                       ^^^^ keyword.control.loop.end.shell
+#                                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.number-sign.shell
+#                                                              ^ punctuation.definition.comment.shell
 
 
 ### [ ARRAY VARIABLES ] #######################################################

From d76a6898caabd0ca73af8766ebb39de77eda62a0 Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Sat, 12 Oct 2024 19:56:23 +0200
Subject: [PATCH 111/113] [ShellScript] Fix redirection after function
 definition body

---
 ShellScript/Bash.sublime-syntax               | 1 +
 ShellScript/Bash/tests/syntax_test_scope.bash | 9 +++++++++
 2 files changed, 10 insertions(+)

diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax
index f0de0e3b7b..bda7d3747a 100644
--- a/ShellScript/Bash.sublime-syntax
+++ b/ShellScript/Bash.sublime-syntax
@@ -249,6 +249,7 @@ contexts:
 
   def-function-end:
     - include: eoc-pop
+    - include: redirections
     - include: illegal-words
 
 ###[ VARIABLE DEFINITIONS ]####################################################
diff --git a/ShellScript/Bash/tests/syntax_test_scope.bash b/ShellScript/Bash/tests/syntax_test_scope.bash
index 845c9f85b9..ef2a6e8e7e 100644
--- a/ShellScript/Bash/tests/syntax_test_scope.bash
+++ b/ShellScript/Bash/tests/syntax_test_scope.bash
@@ -2882,6 +2882,15 @@ function () ; {} arg
 #        ^ meta.function.shell
 #         ^^ meta.function.body.shell meta.block.shell
 
+  func () {} >&2 # comment
+#^ source.shell - meta.function
+# ^^^^^ meta.function.identifier.shell
+#      ^^ meta.function.parameters.shell
+#        ^ meta.function.shell
+#         ^^ meta.function.body.shell meta.block.shell
+#            ^^^ meta.redirection.shell
+#                 ^^^^^^^^^^ comment.line.number-sign.shell
+
   func () {} rest # comment
 #^ source.shell - meta.function
 # ^^^^^ meta.function.identifier.shell

From 5574d934d0f550cac6de7d4801504661f87a727a Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Sun, 13 Oct 2024 14:43:12 +0200
Subject: [PATCH 112/113] [ShellScript] Fix Groovy syntax tests

---
 Groovy/tests/syntax_test_jenkins.Jenkinsfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Groovy/tests/syntax_test_jenkins.Jenkinsfile b/Groovy/tests/syntax_test_jenkins.Jenkinsfile
index 29754615a1..1b7e51d494 100644
--- a/Groovy/tests/syntax_test_jenkins.Jenkinsfile
+++ b/Groovy/tests/syntax_test_jenkins.Jenkinsfile
@@ -27,7 +27,7 @@ def call() {
 //     ^^^ meta.block.groovy meta.string.embedded-shell.groovy punctuation.definition.string.begin.groovy
 //        ^ meta.block.groovy meta.string.embedded-shell.groovy string.quoted.single.block.groovy source.shell.bash comment.line.number-sign.shell punctuation.definition.comment.shell
           echo "hello ${world}"
-//        ^^^^ meta.block.groovy meta.string.embedded-shell.groovy string.quoted.single.block.groovy source.shell.bash meta.function-call.identifier.shell support.function.echo.shell
+//        ^^^^ meta.block.groovy meta.string.embedded-shell.groovy string.quoted.single.block.groovy source.shell.bash meta.function-call.identifier.shell support.function.shell
 //                    ^ meta.interpolation.parameter.shell punctuation.definition.variable.shell
 //                     ^ meta.interpolation.parameter.shell punctuation.section.interpolation.begin.shell
 //                      ^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell

From 8e2aa5f2b4e4e0be6d837ec712929c8e7e33320b Mon Sep 17 00:00:00 2001
From: deathaxe 
Date: Wed, 23 Oct 2024 18:11:18 +0200
Subject: [PATCH 113/113] [ShellScript] Fix built-in overrides

This commit reorganizes statement contexts for built-in commands to be
augment-able by local function definitions, while keeping higher priority
of reserved words.

Reserved words, like `if`, `case`, ... can not be used as identifier for
local function definitions, but all other built-in commands can be.

As a result `def-anonymous` and `def-function` contexts can be merged.

`cmd-coproc` is re-defined as kind of function definition under `def-coproc`.

The token `time` is moved to `cmd-control` context
and scoped `keyword.control` as it is a reserved word.
---
 ShellScript/Bash.sublime-syntax               | 110 ++++++++++--------
 ShellScript/Bash/tests/syntax_test_scope.bash |  37 ++++--
 ShellScript/Zsh/tests/syntax_test_scope.zsh   |  22 +++-
 3 files changed, 105 insertions(+), 64 deletions(-)

diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax
index bda7d3747a..05e9408d4b 100644
--- a/ShellScript/Bash.sublime-syntax
+++ b/ShellScript/Bash.sublime-syntax
@@ -50,16 +50,23 @@ contexts:
       push: statement
 
   statement:
+    # reserved words
     - include: redirections
+    - include: eoc-pop
     - include: operators
-    - include: def-anonymous
+    - include: cmd-control
+    # definitions
+    - include: def-variable
+    - include: def-coproc
+    - include: def-function
+    # builtin commands
+    #  can be augmented by function definitions
+    - include: boolean
     - include: cmd-alias
     - include: cmd-arithmetic
     - include: cmd-command
     - include: cmd-compound-brace
     - include: cmd-compound-paren
-    - include: cmd-control
-    - include: cmd-coproc
     - include: cmd-declare
     - include: cmd-echo
     - include: cmd-exec
@@ -74,10 +81,7 @@ contexts:
     - include: cmd-unalias
     - include: cmd-unset
     - include: cmd-builtin
-    - include: def-variable
-    - include: def-function
-    - include: boolean
-    - include: eoc-pop
+    # user defined commands
     - include: cmd-basic
     - include: illegal-stray
 
@@ -119,9 +123,46 @@ contexts:
     - match: \n
       pop: 1
 
-###[ ANONYMOUS FUNCTION DEFINITIONS ]##########################################
+###[ COPROC DEFINITIONS ]######################################################
 
-  def-anonymous:
+  def-coproc:
+    - match: coproc{{cmd_break}}
+      scope:
+        meta.coproc.shell
+        keyword.declaration.coproc.shell
+      set: def-coproc-identifier
+
+  def-coproc-identifier:
+    - match: (?:(\s*)(({{cmd_literal}})\s*)?(?=\{))?
+      captures:
+        1: meta.coproc.shell
+        2: meta.coproc.identifier.shell
+        3: entity.name.function.shell
+      set:
+        - def-coproc-command-meta
+        - statement
+
+  def-coproc-command-meta:
+    - meta_include_prototype: false
+    - meta_content_scope: meta.coproc.command.shell
+    - include: immediately-pop
+
+###[ FUNCTION DEFINITIONS ]####################################################
+
+  def-function:
+    # [Bash] 3.3 Shell Functions
+    - match: function{{cmd_break}}
+      scope: keyword.declaration.function.shell
+      branch_point: function
+      branch:
+        - def-function-begin
+        - def-anonymous-begin
+      pop: 1
+    - match: (?={{cmd_literal}}\s*\(\s*\))
+      set:
+        - def-function-body
+        - def-function-params
+        - def-function-name
     # anonymous functions are immediatelly called
     # hence scoping as meta.function-call meta.function
     - match: (\()\s*(\))
@@ -159,23 +200,6 @@ contexts:
         - cmd-args
     - include: statements
 
-###[ FUNCTION DEFINITIONS ]####################################################
-
-  def-function:
-    # [Bash] 3.3 Shell Functions
-    - match: function{{cmd_break}}
-      scope: keyword.declaration.function.shell
-      branch_point: function
-      branch:
-        - def-function-begin
-        - def-anonymous-begin
-      pop: 1
-    - match: (?={{cmd_literal}}\s*\(\s*\))
-      set:
-        - def-function-body
-        - def-function-params
-        - def-function-name
-
   def-function-begin:
     - meta_include_prototype: false
     - meta_scope: meta.function.shell
@@ -376,7 +400,7 @@ contexts:
 ###[ COMMAND BUILTINS ]########################################################
 
   cmd-command:
-    - match: (?:command|time){{cmd_break}}
+    - match: command{{cmd_break}}
       scope:
         meta.function-call.identifier.shell
         support.function.shell
@@ -388,30 +412,6 @@ contexts:
     - include: cmd-args-options
     - include: else-pop
 
-###[ COPROC BUILTINS ]#########################################################
-
-  cmd-coproc:
-    - match: coproc{{cmd_break}}
-      scope:
-        meta.coproc.shell
-        keyword.declaration.coproc.shell
-      set: cmd-coproc-identifier
-
-  cmd-coproc-identifier:
-    - match: (?:(\s*)(({{cmd_literal}})\s*)?(?=\{))?
-      captures:
-        1: meta.coproc.shell
-        2: meta.coproc.identifier.shell
-        3: entity.name.function.shell
-      set:
-        - cmd-coproc-command-meta
-        - statement
-
-  cmd-coproc-command-meta:
-    - meta_include_prototype: false
-    - meta_content_scope: meta.coproc.command.shell
-    - include: immediately-pop
-
 ###[ DECLARE BUILTINS ]########################################################
 
   cmd-declare:
@@ -1154,6 +1154,9 @@ contexts:
     - match: return{{cmd_break}}
       scope: keyword.control.flow.return.shell
       set: flow-args
+    - match: time{{cmd_break}}
+      scope: keyword.control.flow.time.shell
+      set: time-args
 
   case-word:
     - meta_include_prototype: false
@@ -1286,6 +1289,11 @@ contexts:
     - include: cmd-args-end
     - include: string-path-patterns
 
+  time-args:
+    - include: cmd-args-end
+    - include: cmd-args-options
+    - include: else-pop
+
 ###[ ARITHMETIC VALUE ASSIGNMENTS ]############################################
 
   arithmetic-array-value-assignment:
diff --git a/ShellScript/Bash/tests/syntax_test_scope.bash b/ShellScript/Bash/tests/syntax_test_scope.bash
index ef2a6e8e7e..297fa04be4 100644
--- a/ShellScript/Bash/tests/syntax_test_scope.bash
+++ b/ShellScript/Bash/tests/syntax_test_scope.bash
@@ -2992,6 +2992,24 @@ logExit $? $WEIRD
 #          ^^^^^^ meta.interpolation.parameter.shell variable.other.readwrite.shell
 #                ^ - meta.function-call - meta.interpolation - variable
 
+time () {  }   # reserved words can not be overwritten by local function definitions
+# <- - meta.function
+#^^^^ - meta.function
+#    ^^ meta.function-call.shell meta.function.anonymous.parameters.shell
+#      ^ meta.function-call.shell meta.function.anonymous.shell
+#       ^^^^ meta.function-call.shell meta.function.anonymous.body.shell meta.block.shell
+
+alias () {  }  # built-in functions/commands can be overwritten
+#^^^^^ meta.function.identifier.shell
+#     ^^ meta.function.parameters.shell
+#       ^ meta.function.shell
+#        ^^^^ meta.function.body.shell meta.block.shell
+#^^^^ entity.name.function.shell
+#     ^ punctuation.section.parameters.begin.shell
+#      ^ punctuation.section.parameters.end.shell
+#        ^ punctuation.section.block.begin.shell
+#           ^ punctuation.section.block.end.shell
+
 function foo
 #^^^^^^^^^^^^ source.shell - meta.function meta.function
 # <- source.shell meta.function.shell keyword.declaration.function.shell
@@ -11130,7 +11148,7 @@ let>/dev/null
 let -
 #^^ support.function.shell
 let()
-#^^ support.function.shell
+#^^^^ - storage - keyword.declaration
 let[]
 #^^^^ - storage - keyword.declaration
 let{}
@@ -11286,7 +11304,7 @@ local>/dev/null
 local -
 #^^^^ keyword.declaration.variable.shell
 local()
-#^^^^ keyword.declaration.variable.shell
+#^^^^^^ - storage - keyword.declaration
 local[]
 #^^^^^^ - storage - keyword.declaration
 local{}
@@ -11801,7 +11819,7 @@ test>/dev/null
 test -
 #^^^ support.function.shell
 test()
-#^^^ support.function.shell
+#^^^^^ - support.function
 test[]
 #^^^^^ - support.function
 test{}
@@ -11968,9 +11986,8 @@ if test "$VAR" != ";";then;fi
 ###############################################################################
 
 time cmd1 --arg val | cmd2 -n |& cmd3
-# <- meta.function-call.identifier.shell support.function.shell
-#^^^ meta.function-call.identifier.shell support.function.shell
-#   ^ meta.function-call.arguments.shell
+# <- keyword.control.flow.time.shell
+#^^^ keyword.control.flow.time.shell
 #    ^^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
 #        ^^^^^^^^^^ meta.function-call.arguments.shell
 #         ^^^^^ meta.parameter.option.shell variable.parameter.option.shell
@@ -11983,9 +12000,9 @@ time cmd1 --arg val | cmd2 -n |& cmd3
 #                                ^^^^ meta.function-call.identifier.shell meta.command.shell variable.function.shell
 
 time -p cmd -p
-# <- meta.function-call.identifier.shell support.function.shell
-#^^^ meta.function-call.identifier.shell
-#   ^^^^ meta.function-call.arguments.shell
+# <- keyword.control.flow.time.shell
+#^^^ keyword.control.flow.time.shell
+#    ^^ variable.parameter.option.shell
 #       ^^^ meta.function-call.identifier.shell
 #          ^^^ meta.function-call.arguments.shell
 
@@ -12215,7 +12232,7 @@ unset-
 unset+
 # <- - support.function
 unset()
-# <- support.function.shell
+# <- - support.function
 unset[]
 # <- - support.function
 unset{}
diff --git a/ShellScript/Zsh/tests/syntax_test_scope.zsh b/ShellScript/Zsh/tests/syntax_test_scope.zsh
index e32726573d..a796544a02 100644
--- a/ShellScript/Zsh/tests/syntax_test_scope.zsh
+++ b/ShellScript/Zsh/tests/syntax_test_scope.zsh
@@ -295,9 +295,8 @@ func() { ... } 2>&1
 #                 ^ meta.file-descriptor.shell meta.number.integer.decimal.shell constant.numeric.value.shell
 
 time cmd1 arg | cmd2 -t >1
-# <- meta.function-call.identifier.shell support.function.shell
-#^^^ meta.function-call.identifier.shell support.function.shell
-#   ^ meta.function-call.arguments.shell
+# <- keyword.control.flow.time.shell
+#^^^ keyword.control.flow.time.shell
 #    ^^^^ meta.function-call.identifier.shell
 #        ^^^^ meta.function-call.arguments.shell
 #            ^^^ - meta.function-call
@@ -1098,6 +1097,23 @@ function name () echo "$0 called with $*!"
 #              ^ punctuation.section.parameters.end.shell
 #                ^^^^ support.function.shell
 
+time () {  }   # reserved words can not be overwritten by local function definitions
+# <- - meta.function
+#^^^^ - meta.function
+#    ^^ meta.function-call.shell meta.function.anonymous.parameters.shell
+#      ^ meta.function-call.shell meta.function.anonymous.shell
+#       ^^^^ meta.function-call.shell meta.function.anonymous.body.shell meta.block.shell
+
+alias () {  }  # built-in functions/commands can be overwritten
+#^^^^^ meta.function.identifier.shell
+#     ^^ meta.function.parameters.shell
+#       ^ meta.function.shell
+#        ^^^^ meta.function.body.shell meta.block.shell
+#^^^^ entity.name.function.shell
+#     ^ punctuation.section.parameters.begin.shell
+#      ^ punctuation.section.parameters.end.shell
+#        ^ punctuation.section.block.begin.shell
+#           ^ punctuation.section.block.end.shell
 
 ###############################################################################
 # 9.1 Autoloading Functions                                                   #