Skip to content

Commit

Permalink
[ShellScript] Fix grouped test r-value termination (#3875)
Browse files Browse the repository at this point in the history
  • Loading branch information
deathaxe authored Nov 20, 2023
1 parent ac11c3e commit 37df50e
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ShellScript/Bash.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,8 @@ contexts:
- match: $\n?
scope: invalid.illegal.unexpected-token.shell
pop: 3
- match: (?=&&|\|\|)
pop: 1

test-expression-common:
- match: ([-+])[aobcdefghknoprstuvwxzGLNORS]{{opt_break}}(?!\s*(=~|!=|==?))
Expand Down
72 changes: 72 additions & 0 deletions ShellScript/test/syntax_test_bash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4205,6 +4205,42 @@ 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.group.end.regexp.shell
# ^^ support.function.test.end.shell
[[ $foo == 'bar' || $foo == "baz" && $bar == baz ]]
# <- meta.conditional.shell support.function.test.begin.shell
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.conditional.shell
# ^^^^ variable.other.readwrite.shell
# ^^ keyword.operator.comparison.shell
# ^^^^^ meta.string.regexp.shell
# ^^ keyword.operator.logical.shell
# ^^^^ variable.other.readwrite.shell
# ^^ keyword.operator.comparison.shell
# ^^^^^ meta.string.regexp.shell
# ^^ keyword.operator.logical.shell
# ^^^^ variable.other.readwrite.shell
# ^^ keyword.operator.comparison.shell
# ^^^ meta.string.regexp.shell
# ^^ support.function.test.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
# ^ punctuation.section.group.begin.shell
# ^^^^ variable.other.readwrite.shell
# ^^ keyword.operator.comparison.shell
# ^^^^^ meta.string.regexp.shell
# ^^ keyword.operator.logical.shell
# ^^^^ variable.other.readwrite.shell
# ^^ keyword.operator.comparison.shell
# ^^^^^ meta.string.regexp.shell
# ^ punctuation.section.group.end.shell
# ^^ keyword.operator.logical.shell
# ^^^^ variable.other.readwrite.shell
# ^^ keyword.operator.comparison.shell
# ^^^ meta.string.regexp.shell
# ^^ support.function.test.end.shell
####################################################################
# POSIX extended regular expression pattern matching #
####################################################################
Expand Down Expand Up @@ -4828,6 +4864,42 @@ echo ca{${x/z/t}" "{legs,f${o//a/o}d,f${o:0:1}t},r" "{tires,wh${o//a/e}ls}}
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
# ^^^^ variable.other.readwrite.shell
# ^^ keyword.operator.comparison.shell
# ^^^^^ meta.string.regexp.shell
# ^^ keyword.operator.logical.shell
# ^^^^ variable.other.readwrite.shell
# ^^ keyword.operator.comparison.shell
# ^^^^^ meta.string.regexp.shell
# ^^ keyword.operator.logical.shell
# ^^^^ variable.other.readwrite.shell
# ^^ keyword.operator.comparison.shell
# ^^^ meta.string.regexp.shell
# ^^ support.function.test.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
# ^ punctuation.section.group.begin.shell
# ^^^^ variable.other.readwrite.shell
# ^^ keyword.operator.comparison.shell
# ^^^^^ meta.string.regexp.shell
# ^^ keyword.operator.logical.shell
# ^^^^ variable.other.readwrite.shell
# ^^ keyword.operator.comparison.shell
# ^^^^^ meta.string.regexp.shell
# ^ punctuation.section.group.end.shell
# ^^ keyword.operator.logical.shell
# ^^^^ variable.other.readwrite.shell
# ^^ keyword.operator.comparison.shell
# ^^^ meta.string.regexp.shell
# ^^ support.function.test.end.shell
####################################################################
# 6.4 Bash Conditional Expressions #
####################################################################
Expand Down

0 comments on commit 37df50e

Please sign in to comment.