mirror of
https://github.com/neovim/neovim.git
synced 2026-05-06 08:26:45 -04:00
vim-patch:10040bc: runtime(sh): allow "#" in special derefs
Code like ${!#} flags the "#" as shDerefWordError [1]; the "!prefix"
syntax region delegates to one of the shDerefSpecial handlers via
@shDerefList, but it misses the "#" case as valid for ${##} and ${!#}.
[1]: https://vi.stackexchange.com/q/48617/10604
Correct that. Indirection is only valid in Bash in Ksh, so rearrange the
"!" handling to be conditional.
closes: vim/vim#20016
Helped-by: Christian Brabandt <cb@256bit.org>
https://github.com/vim/vim/commit/10040bc9cde340c52b5093cacb1d60fd2e621883
Co-authored-by: D. Ben Knoble <ben.knoble+github@gmail.com>
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
" 2026 Feb 15 improve comment handling #19414
|
||||
" 2026 Mar 23 improve matching of function definitions #19638
|
||||
" 2026 Apr 02 improve matching of function definitions #19849
|
||||
" 2026 Apr 19 improve detection of special variables #20016
|
||||
" }}}
|
||||
" Version: 208
|
||||
" Former URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_SH
|
||||
@@ -751,13 +752,15 @@ endif
|
||||
if exists("b:is_bash")
|
||||
syn region shDeref matchgroup=PreProc start="\${!" end="\*\=}" contains=@shDerefList,shDerefOffset
|
||||
syn match shDerefVar contained "{\@<=!\h\w*" nextgroup=@shDerefVarList
|
||||
syn match shDerefSpecial contained "\({!\)\@<=[[:alnum:]*#@_]\+" nextgroup=@shDerefVarList,shDerefOp
|
||||
endif
|
||||
if (exists("b:is_kornshell") && !exists("b:is_ksh88"))
|
||||
syn match shDerefVar contained "{\@<=!\h\w*[[:alnum:]_.]*" nextgroup=@shDerefVarList
|
||||
syn match shDerefSpecial contained "\({!\)\@<=[[:alnum:]*#@_]\+" nextgroup=@shDerefVarList,shDerefOp
|
||||
endif
|
||||
|
||||
syn match shDerefSpecial contained "{\@<=[-*@?0]" nextgroup=shDerefOp,shDerefOffset,shDerefOpError
|
||||
syn match shDerefSpecial contained "\({[#!]\)\@<=[[:alnum:]*@_]\+" nextgroup=@shDerefVarList,shDerefOp
|
||||
syn match shDerefSpecial contained "\({[#]\)\@<=[[:alnum:]*@_]\+" nextgroup=@shDerefVarList,shDerefOp
|
||||
syn match shDerefVar contained "{\@<=\h\w*" nextgroup=@shDerefVarList
|
||||
syn match shDerefVar contained '\d' nextgroup=@shDerefVarList
|
||||
if exists("b:is_kornshell") || exists("b:is_posix")
|
||||
|
||||
Reference in New Issue
Block a user