diff --git a/ShellScript/Bash.sublime-syntax b/ShellScript/Bash.sublime-syntax index 1343166b1a..6c6289c9e7 100644 --- a/ShellScript/Bash.sublime-syntax +++ b/ShellScript/Bash.sublime-syntax @@ -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*(=~|!=|==?)) diff --git a/ShellScript/test/syntax_test_bash.sh b/ShellScript/test/syntax_test_bash.sh index f9fd25f47e..03b1ca00ef 100755 --- a/ShellScript/test/syntax_test_bash.sh +++ b/ShellScript/test/syntax_test_bash.sh @@ -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 # #################################################################### @@ -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 # ####################################################################