mirror of
https://github.com/neovim/neovim.git
synced 2026-05-24 05:40:08 +00:00
vim-patch:23c77d8: runtime(sh): Do not conflate empty array and function declarations in Bash
Although the "=" character is permitted in function names,
a construct that parses as a variable assignment is
preferred to it parsing as a function declaration. See the
updated test file "sh_functions_bash.sh" for details.
fixes: vim/vim#20183
closes: vim/vim#20205
23c77d8ec8
Co-authored-by: Aliaksei Budavei <0x000c70@gmail.com>
Co-authored-by: Doug Kearns <dougkearns@gmail.com>
This commit is contained in:
@@ -3,30 +3,7 @@
|
||||
" Maintainer: This runtime file is looking for a new maintainer.
|
||||
" Previous Maintainers: Charles E. Campbell
|
||||
" Lennart Schultz <Lennart.Schultz@ecmwf.int>
|
||||
" Last Change: 2024 Mar 04 by Vim Project {{{1
|
||||
" 2024 Nov 03 by Aliaksei Budavei <0x000c70 AT gmail DOT com> improved bracket expressions, #15941
|
||||
" 2025 Jan 06 add $PS0 to bashSpecialVariables #16394
|
||||
" 2025 Jan 18 add bash coproc, remove duplicate syn keywords #16467
|
||||
" 2025 Mar 21 update shell capability detection #16939
|
||||
" 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
|
||||
" 2025 May 06 match KornShell compound arrays
|
||||
" 2025 May 10 improve wildcard character class lists
|
||||
" 2025 May 21 improve supported KornShell features
|
||||
" 2025 Jun 16 change how sh_fold_enabled is reset #17557
|
||||
" 2025 Jul 18 properly delete :commands #17785
|
||||
" 2025 Aug 23 bash: add support for ${ cmd;} and ${|cmd;} #18084
|
||||
" 2025 Sep 23 simplify ksh logic, update sh statements #18355
|
||||
" 2026 Jan 15 highlight command switches that contain a digit
|
||||
" 2026 Feb 11 improve support for KornShell function names and variables
|
||||
" 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
|
||||
" 2026 May 14 don't highlight parens as part of the function name #20219
|
||||
" }}}
|
||||
" Last Change: 2026 May 17 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
|
||||
@@ -281,7 +258,7 @@ syn cluster shDerefList contains=shDeref,shDerefSimple,shDerefVar,shDerefSpecial
|
||||
syn cluster shDerefVarList contains=shDerefOffset,shDerefOp,shDerefVarArray,shDerefOpError
|
||||
syn cluster shEchoList contains=shArithmetic,shBracketExpr,shCommandSub,shCommandSubBQ,shDerefVarArray,shSubshare,shValsub,shDeref,shDerefSimple,shEscape,shExSingleQuote,shExDoubleQuote,shSingleQuote,shDoubleQuote,shCtrlSeq,shEchoQuote
|
||||
syn cluster shExprList1 contains=shBracketExpr,shNumber,shOperator,shExSingleQuote,shExDoubleQuote,shSingleQuote,shDoubleQuote,shExpr,shDblBrace,shDeref,shDerefSimple,shCtrlSeq
|
||||
syn cluster shExprList2 contains=@shExprList1,@shCaseList,shTest
|
||||
syn cluster shExprList2 contains=@shExprList1,@shCaseList,shTest,shFunctionNameError
|
||||
syn cluster shFunctionCmds contains=shFor,shCaseEsac,shIf,shRepeat,shDblBrace,shDblParen
|
||||
if exists("b:is_ksh88") || exists("b:is_mksh")
|
||||
" Offer "shFunctionCmds" as is.
|
||||
@@ -307,7 +284,7 @@ if exists("b:is_kornshell") || exists("b:is_bash")
|
||||
endif
|
||||
syn cluster shPPSLeftList contains=shAlias,shArithmetic,shBracketExpr,shCmdParenRegion,shCommandSub,shSubshare,shValsub,shCtrlSeq,shDeref,shDerefSimple,shDoubleQuote,shEcho,shEscape,shExDoubleQuote,shExpr,shExSingleQuote,shHereDoc,shNumber,shOperator,shOption,shPosnParm,shHereString,shRedir,shSingleQuote,shSpecial,shStatement,shSubSh,shTest,shVariable
|
||||
syn cluster shPPSRightList contains=shDeref,shDerefSimple,shEscape,shPosnParm
|
||||
syn cluster shSubShList contains=shBracketExpr,@shCommandSubList,shCommandSubBQ,shSubshare,shValsub,shCaseEsac,shColon,shCommandSub,shComment,shDo,shEcho,shExpr,shFor,shIf,shHereString,shRedir,shSetList,shSource,shStatement,shVariable,shCtrlSeq,shOperator
|
||||
syn cluster shSubShList contains=shBracketExpr,@shCommandSubList,shCommandSubBQ,shSubshare,shValsub,shCaseEsac,shColon,shCommandSub,shComment,shDo,shEcho,shExpr,shFor,shIf,shHereString,shRedir,shSetList,shSource,shStatement,shVariable,shCtrlSeq,shOperator,shFunctionNameError
|
||||
syn cluster shTestList contains=shArithmetic,shBracketExpr,shCommandSub,shCommandSubBQ,shSubshare,shValsub,shCtrlSeq,shDeref,shDerefSimple,shDoubleQuote,shSpecialDQ,shExDoubleQuote,shExpr,shExSingleQuote,shNumber,shOperator,shSingleQuote,shTest,shTestOpr
|
||||
syn cluster shNoZSList contains=shSpecialNoZS
|
||||
syn cluster shForList contains=shTestOpr,shNumber,shDerefSimple,shDeref,shCommandSub,shCommandSubBQ,shSubshare,shValsub,shArithmetic
|
||||
@@ -676,6 +653,12 @@ if exists("b:is_bash")
|
||||
syn match shFunctionTwo "\%#=1\%(\%(\<\k\+\|[^()<>|&$;\t ]\+\)\+\)\@>\ze\s*\%(()\ze\)\=\_s*{" contained skipwhite skipnl nextgroup=shFunctionExpr contains=shFunctionParens
|
||||
syn match shFunctionThree "\%#=1^\s*\zs\%(\%(\<\k\+\|[^()<>|&$;\t ]\+\)\+\)\@>\s*()\ze\_s*((\@!" skipwhite skipnl nextgroup=shFunctionSubSh contains=shFunctionParens
|
||||
syn match shFunctionFour "\%#=1\%(\%(\<\k\+\|[^()<>|&$;\t ]\+\)\+\)\@>\ze\s*\%(\%(()\ze\)\=\)\@>\_s*((\@!" contained skipwhite skipnl nextgroup=shFunctionSubSh contains=shFunctionParens
|
||||
" Claim empty array assignments.
|
||||
syn match shArrayEmptyDecl "\%#=1\ze\%(\<\h\w*=\)\@>()" transparent nextgroup=shVariable
|
||||
|
||||
if !exists("g:sh_no_error")
|
||||
syn match shFunctionNameError "\%#=1\%(\%(\<\h\w*\)\@>=\)\%(\%(\w\+\)\@>=\=\)\+()" skipwhite skipnl nextgroup=shExpr,shSubSh
|
||||
endif
|
||||
elseif exists("b:is_ksh88")
|
||||
" AT&T ksh88
|
||||
syn match shFunctionCmdOne "^\s*\zs\h\w*\s*()\ze\_s*\%(\%(for\|case\|select\|if\|while\|until\)\>\|\[\[\s\|((\)" skipwhite skipnl nextgroup=@shFunctionCmds contains=shFunctionParens
|
||||
@@ -970,6 +953,9 @@ if !exists("skip_sh_syntax_inits")
|
||||
hi def link shInError Error
|
||||
hi def link shParenError Error
|
||||
hi def link shTestError Error
|
||||
if exists("b:is_bash")
|
||||
hi def link shFunctionNameError Error
|
||||
endif
|
||||
if exists("b:is_kornshell") || exists("b:is_posix")
|
||||
hi def link shDTestError Error
|
||||
endif
|
||||
|
||||
Reference in New Issue
Block a user