Commit: runtime(sh): Update syntax, fix single-quoted strings in parameter expansions

1 view
Skip to first unread message

Christian Brabandt

unread,
May 5, 2025, 2:15:21 PM5/5/25
to vim...@googlegroups.com
runtime(sh): Update syntax, fix single-quoted strings in parameter expansions

Commit: https://github.com/vim/vim/commit/fe22867ef564ea78cafaabe0c784222638399cb9
Author: Doug Kearns <dougk...@gmail.com>
Date: Mon May 5 20:10:11 2025 +0200

runtime(sh): Update syntax, fix single-quoted strings in parameter expansions

Ignore single-quoted backslash escape sequences in parameter expansions.

\' is not an escaped single quote in ${foo:-'word\'}.

closes: #17261

Signed-off-by: Doug Kearns <dougk...@gmail.com>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/runtime/syntax/sh.vim b/runtime/syntax/sh.vim
index f0a6685b6..4add7921f 100644
--- a/runtime/syntax/sh.vim
+++ b/runtime/syntax/sh.vim
@@ -11,6 +11,7 @@
" 2025 Apr 03 command substitution opening paren at EOL (#17026)
" 2025 Apr 10 improve shell detection (#17084)
" 2025 Apr 29 match escaped chars in test operands (#17221)
+" 2025 May 06 improve single-quote string matching in parameter expansions
" Version: 208
" Former URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_SH
" For options and settings, please use: :help ft-sh-syntax
@@ -649,7 +650,7 @@ if exists("b:is_bash")
syn match shDerefOp contained "[,^]\{1,2}" nextgroup=@shDerefPatternList
syn match shDerefOp contained "@[uULQEPAKa]"
endif
-syn region shDerefString contained matchgroup=shDerefDelim start=+\%(\\)\@<!'+ end=+'+ contains=shStringSpecial
+syn region shDerefString contained matchgroup=shDerefDelim start=+\%(\\)\@<!'+ end=+'+
syn region shDerefString contained matchgroup=shDerefDelim start=+\%(\\)\@<!"+ skip=+\"+ end=+"+ contains=@shDblQuoteList,shStringSpecial
syn match shDerefString contained "\["']" nextgroup=shDerefPattern

diff --git a/runtime/syntax/testdir/dumps/sh_quoting_00.dump b/runtime/syntax/testdir/dumps/sh_quoting_00.dump
new file mode 100644
index 000000000..a1beb8f4d
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/sh_quoting_00.dump
@@ -0,0 +1,20 @@
+>#+0#0000e05#ffffff0|!|/|b|i|n|/|d|a|s|h| +0#0000000&@63
+@75
+|e+0#af5f00255&|c|h|o| +0#e000002&|$+0#e000e06&|{|f|o@1|:+0#af5f00255&|-|'|s+0#e000002&|t|r|i|n|g| |\|'+0#af5f00255&|}+0#e000e06&| +0#0000000&@51
+@75
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|i+0#0000000&|s|_|d|a|s|h|:| |1|,| |i|s|_|p|o|s|i|x|:| |1|,| |i|s|_|s|h|:| |1|,| @22|1|,|1| @10|A|l@1|
diff --git a/runtime/syntax/testdir/input/sh_quoting.sh b/runtime/syntax/testdir/input/sh_quoting.sh
new file mode 100644
index 000000000..dc6a5152f
--- /dev/null
+++ b/runtime/syntax/testdir/input/sh_quoting.sh
@@ -0,0 +1,4 @@
+#!/bin/dash
+
+echo ${foo:-'string \'}
+
Reply all
Reply to author
Forward
0 new messages