From: frapank Date: Sat, 25 Jul 2026 17:03:08 +0000 (+0000) Subject: runtime(sh): fix Bash/Ksh array highlighting after an escaped paren X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=fb1a2e9d13f21fadec7ef4aef2fb6e760036daf0;p=thirdparty%2Fvim.git runtime(sh): fix Bash/Ksh array highlighting after an escaped paren fixes: #18712 closes: #20705 Signed-off-by: frapank Signed-off-by: Christian Brabandt --- diff --git a/runtime/syntax/sh.vim b/runtime/syntax/sh.vim index 044f2a9e3e..52d50df853 100644 --- a/runtime/syntax/sh.vim +++ b/runtime/syntax/sh.vim @@ -3,7 +3,7 @@ " Maintainer: This runtime file is looking for a new maintainer. " Previous Maintainers: Charles E. Campbell " Lennart Schultz -" Last Change: 2026 May 17 by Vim Project +" Last Change: 2026 Jul 25 by Vim Project " Version: 208 " Former URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_SH " For options and settings, please use: :help ft-sh-syntax @@ -598,12 +598,12 @@ syn match shVariable "\<\h\w*\ze=" nextgroup=shVarAssign if exists("b:is_bash") " The subscript form for array values, e.g. "foo=([2]=10 [4]=100)". syn region shArrayValue contained start="\[\%(..\{-}\]=\)\@=" end="\]=\@=" contains=@shArrayValueList nextgroup=shVarAssign - syn cluster shArrayValueList contains=shArithmetic,shArithParen,shCommandSub,shDeref,shDerefSimple,shExpr,shNumber,shExSingleQuote,shExDoubleQuote,shSingleQuote,shDoubleQuote,shSpecial,shParen,bashSpecialVariables,shParenError + syn cluster shArrayValueList contains=shArithmetic,shArithParen,shCommandSub,shDeref,shDerefSimple,shEscape,shExpr,shNumber,shExSingleQuote,shExDoubleQuote,shSingleQuote,shDoubleQuote,shSpecial,shParen,bashSpecialVariables,shParenError syn region shArrayRegion contained matchgroup=shShellVariables start="(" skip='\\\\\|\\.' end=")" contains=@shArrayValueList,shArrayValue,shComment elseif (exists("b:is_kornshell") && !exists("b:is_ksh88")) " The subscript form for array values, e.g. "foo=([2]=10 [4]=100)". syn region shArrayValue contained start="\[\%(..\{-}\]=\)\@=" end="\]=\@=" contains=@shArrayValueList nextgroup=shVarAssign - syn cluster shArrayValueList contains=shArithmetic,shArithParen,shCommandSub,shDeref,shDerefSimple,shExpr,shNumber,shExSingleQuote,shExDoubleQuote,shSingleQuote,shDoubleQuote,shSpecial,shParen,kshSpecialVariables,shParenError + syn cluster shArrayValueList contains=shArithmetic,shArithParen,shCommandSub,shDeref,shDerefSimple,shEscape,shExpr,shNumber,shExSingleQuote,shExDoubleQuote,shSingleQuote,shDoubleQuote,shSpecial,shParen,kshSpecialVariables,shParenError syn region shArrayRegion contained matchgroup=shShellVariables start="(" skip='\\\\\|\\.' end=")" contains=@shArrayValueList,shArrayValue,shComment,shArrayRegion endif if exists("b:is_bash") || exists("b:is_kornshell") diff --git a/runtime/syntax/testdir/dumps/sh_12_11.dump b/runtime/syntax/testdir/dumps/sh_12_11.dump index 21edbc825e..de2ecca5be 100644 --- a/runtime/syntax/testdir/dumps/sh_12_11.dump +++ b/runtime/syntax/testdir/dumps/sh_12_11.dump @@ -6,7 +6,7 @@ >e+0#af5f00255&|c|h|o| +0#e000002&|"+0#af5f00255&|$+0#e000e06&|{|1|#+0#af5f00255&|$+0#e000e06&|{|1|%+0#af5f00255&@1|[+0#00e0003&|!+8#e000e06&|$+0#0000000&|{|n|l|}|\|"|]+0#00e0003&|*+0#0000000&|}+0#e000e06&@1|"+0#af5f00255&|;+0#0000000&| |e+0#af5f00255&|c|h|o| +0#e000002&|"+0#af5f00255&|$+0#e000e06&|{|1|#+0#af5f00255&|$+0#e000e06&|{|1|%+0#af5f00255&@1|[+0#00e0003&|!+8#e000e06&|$+0#0000000&|{|n|l|}|\|'|]+0#00e0003&|*+0#0000000&|}+0#e000e06&@1|"+0#af5f00255&| +0#0000000&@14 @75 |b+0#00e0e07&|i|n|s|=+0#0000000&|(+0#e000e06&|)|;+0#0000000&| |b+0#00e0e07&|i|n|s|=+0#0000000&|(+0#e000e06&|0+0#e000002&| +0#0000000&|1+0#e000002&|)+0#e000e06&|;+0#0000000&| |e+0#af5f00255&|v|a|l| +0#0000000&|b+0#00e0e07&|i|n|s|++0#0000000&|=|(+0#e000e06&|{|0+0#e000002&|.+0#0000000&@1|1+0#e000002&|}+0#e000e06&|)| +0#0000000&@34 -|b+0#00e0e07&|i|n|s|[+0#e000e06&|0+0#e000002&|]+0#e000e06&|=+0#0000000&|0+0#e000002&|;+0#0000000&| |b+0#00e0e07&|i|n|s|[+0#e000e06&|1+0#e000002&|]+0#e000e06&|=+0#0000000&|1+0#e000002&|;+0#0000000&| |e+0#af5f00255&|v|a|l| +0#0000000&|b+0#00e0e07&|i|n|s|++0#0000000&|=|(+0#e000e06&|\+0#0000000&|$+0#e000e06&|{|b|i|n|s|[|{|1+0#e000002&|.+0#0000000&@1|0+0#e000002&|}+0#e000e06&|]|}|)|;+0#0000000&| |u+0#af5f00255&|n|s|e|t| +0#00e0e07&|b|i|n|s|[+0#e000e06&|3+0#e000002&|]+0#e000e06&| +0#00e0e07&|b|i|n|s|[+0#e000e06&|2+0#e000002&|]+0#e000e06&| +0#0000000& +|b+0#00e0e07&|i|n|s|[+0#e000e06&|0+0#e000002&|]+0#e000e06&|=+0#0000000&|0+0#e000002&|;+0#0000000&| |b+0#00e0e07&|i|n|s|[+0#e000e06&|1+0#e000002&|]+0#e000e06&|=+0#0000000&|1+0#e000002&|;+0#0000000&| |e+0#af5f00255&|v|a|l| +0#0000000&|b+0#00e0e07&|i|n|s|++0#0000000&|=|(+0#e000e06&|\|$|{|b+0#0000000&|i|n|s|[+0#00e0003&|{+0#0000000&|1|.@1|0|}|]+0#00e0003&|}+0#e000e06&|)|;+0#0000000&| |u+0#af5f00255&|n|s|e|t| +0#00e0e07&|b|i|n|s|[+0#e000e06&|3+0#e000002&|]+0#e000e06&| +0#00e0e07&|b|i|n|s|[+0#e000e06&|2+0#e000002&|]+0#e000e06&| +0#0000000& |b+0#00e0e07&|i|n|s|=+0#0000000&|(+0#e000e06&|[+0#00e0e07&|8+0#e000002&|#|0|]+0#00e0e07&|=+0#0000000&|$+0#e000e06&|(@1|2+0#e000002&|#|1|0@1|)+0#e000e06&@1| +0#0000000&|[+0#00e0e07&|$+0#e000e06&|(@1|8+0#e000002&|#|1|)+0#e000e06&@1|]+0#00e0e07&|=+0#0000000&|$+0#e000e06&|(@1|2+0#e000002&|#|1|0|)+0#e000e06&@1| +0#0000000&|[+0#00e0e07&|3+0#e000002&|]+0#00e0e07&|=+0#0000000&|$+0#e000e06&|{|b|i|n|s|[|2+0#e000002&|#|1|]+0#e000e06&|}| +0#0000000&|$+0#e000e06&|{|b|i|n|s|[|0+0#e000002&|]+0#e000e06&|}|)| +0#0000000&@2 |(+0#e000e06&|e+0#af5f00255&|c|h|o| +0#e000002&|s|u|m|[+0#e000e06&|$|(@1|b|i|n|s|[|1+0#e000002&|6|#|3|]+0#e000e06&| |+| |b|i|n|s|[|8+0#e000002&|#|2|]+0#e000e06&| |+| |b|i|n|s|[|2+0#e000002&|#|1|]+0#e000e06&| |+| |b|i|n|s|[|0+0#e000002&|]+0#e000e06&|)@1|]|)| +0#0000000&@13 |e+0#af5f00255&|v|a|l| +0#0000000&|u+0#af5f00255&|n|s|e|t| +0#00e0e07&|b|i|n|s|[+0#e000e06&|{|0+0#e000002&|.+0#0000000&@1|$+0#e000e06&|(@1|$|{|#|b|i|n|s|[|*+0#0000000&|]+0#e000e06&|}| |-| |1+0#e000002&|)+0#e000e06&@1|}|]| +0#0000000&@32 diff --git a/runtime/syntax/testdir/dumps/sh_bash_array_00.dump b/runtime/syntax/testdir/dumps/sh_bash_array_00.dump new file mode 100644 index 0000000000..a62438c13a --- /dev/null +++ b/runtime/syntax/testdir/dumps/sh_bash_array_00.dump @@ -0,0 +1,20 @@ +>#+0#0000e05#ffffff0|!|/|b|i|n|/|b|a|s|h| +0#0000000&@63 +@75 +|#+0#0000e05&| |I|s@1|u|e| |#|1|8|7|1|2| +0#0000000&@60 +@75 +|d+0#af5f00255&|e|c|l|a|r|e| +0#0000000&|-+0#e000e06&|A| +0#0000000&|b+0#00e0e07&|a|r|=+0#0000000&|(+0#e000e06&| +0#0000000&@58 +@2|[+0#e000e06&|\|(|\|)|]|=+0#0000000&|"+0#af5f00255&|b+0#e000002&|a|z|"+0#af5f00255&| +0#0000000&@60 +|)+0#e000e06&| +0#0000000&@73 +|e+0#af5f00255&|c|h|o| +0#e000002&|$+0#e000e06&|{|b|a|r|[|\|(|\|)|]|}| +0#0000000&@57 +@75 +|f+0#00e0e07&|o@1|=+0#0000000&|(+0#e000e06&|a+0#0000000&| |\+0#e000e06&|(| +0#0000000&|b|)+0#e000e06&| +0#0000000&@62 +|f+0#00e0e07&|o@1|=+0#0000000&|(+0#e000e06&|\|$|{|f+0#0000000&|o@1|[+0#e000e06&|1+0#0000000&|]+0#e000e06&|}|)| +0#0000000&@58 +@75 +|f+0#00e0e07&|o@1|=+0#0000000&|(+0#e000e06&|[|2+0#e000002&|]+0#e000e06&|=+0#0000000&|1+0#e000002&|0| +0#0000000&|[+0#e000e06&|4+0#e000002&|]+0#e000e06&|=+0#0000000&|1+0#e000002&|0@1|)+0#e000e06&| +0#0000000&@54 +|e+0#af5f00255&|c|h|o| +0#e000002&|$+0#e000e06&|{|f|o@1|[|4+0#e000002&|]+0#e000e06&|}| +0#0000000&@60 +|~+0#4040ff13&| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|i+0#0000000&|s|_|b|a|s|h|:| |1|,| @45|1|,|1| @10|A|l@1| diff --git a/runtime/syntax/testdir/input/sh_bash_array.bash b/runtime/syntax/testdir/input/sh_bash_array.bash new file mode 100644 index 0000000000..59c4d7d7d4 --- /dev/null +++ b/runtime/syntax/testdir/input/sh_bash_array.bash @@ -0,0 +1,14 @@ +#!/bin/bash + +# Issue #18712 + +declare -A bar=( + [\(\)]="baz" +) +echo ${bar[\(\)]} + +foo=(a \( b) +foo=(\${foo[1]}) + +foo=([2]=10 [4]=100) +echo ${foo[4]}