Commit: runtime(sh): fix Bash/Ksh array highlighting after an escaped paren

Christian Brabandt <[email protected]>
Newsgroups gmane.editors.vim.devel
Message-ID <[email protected]>
runtime(sh): fix Bash/Ksh array highlighting after an escaped paren

Commit: https://github.com/vim/vim/commit/fb1a2e9d13f21fadec7ef4aef2fb6e760036daf0
Author: frapank <[email protected]>
Date:   Sat Jul 25 17:03:08 2026 +0000

    runtime(sh): fix Bash/Ksh array highlighting after an escaped paren
    
    fixes:  https://github.com/vim/vim/issues/18712
    closes: https://github.com/vim/vim/issues/20705
    
    Signed-off-by: frapank <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/runtime/syntax/sh.vim b/runtime/syntax/sh.vim
index 044f2a9e3..52d50df85 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 <[email protected]>
-" 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 21edbc825..de2ecca5b 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 000000000..a62438c13
--- /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 000000000..59c4d7d7d
--- /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]}

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1wnfxp-00DZlq-ES%40256bit.org.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.