From: Aliaksei Budavei <0x000c70@gmail.com> Date: Thu, 6 Aug 2026 18:56:02 +0000 (+0000) Subject: runtime(sh): Do not conflate comments and function declarations in Bash X-Git-Tag: v9.2.0917~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bfc760467864846b5091c5c5768c53b97cc8b5a7;p=thirdparty%2Fvim.git runtime(sh): Do not conflate comments and function declarations in Bash Bash identifiers declared in scripts cannot have a leading "#" in their names. And neither "namespace" nor "function" can be followed by a newline before an identifier. related: #20878 Co-authored-by: Christoffer Aasted Co-authored-by: Doug Kearns Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com> Signed-off-by: Christian Brabandt --- diff --git a/runtime/syntax/sh.vim b/runtime/syntax/sh.vim index 52d50df853..90a712a00a 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 Jul 25 by Vim Project +" Last Change: 2026 Aug 06 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 @@ -258,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,shFunctionNameError +syn cluster shExprList2 contains=@shExprList1,@shCaseList,shTest,shFunctionNameAssignError syn cluster shFunctionCmds contains=shFor,shCaseEsac,shIf,shRepeat,shDblBrace,shDblParen if exists("b:is_ksh88") || exists("b:is_mksh") " Offer "shFunctionCmds" as is. @@ -284,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,shFunctionNameError +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,shFunctionNameAssignError 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 @@ -632,12 +632,13 @@ endif " KornShell namespace: {{{1 if exists("b:is_kornshell") && !exists("b:is_ksh88") && !exists("b:is_mksh") - syn keyword shFunctionKey namespace skipwhite skipnl nextgroup=shNamespaceOne + syn keyword shFunctionKey namespace skipwhite nextgroup=shNamespaceOne endif " Functions: {{{1 if !exists("b:is_posix") - syn keyword shFunctionKey function skipwhite skipnl nextgroup=shDoError,shIfError,shFunctionTwo,shFunctionFour,shFunctionCmdTwo + syn match shFunctionKeyDelim "\s\+" contained transparent nextgroup=shDoError,shIfError,shFunctionNameCommentError,shFunctionTwo,shFunctionFour,shFunctionCmdTwo + syn match shFunctionKey "\|&$;\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 + " Claim commented out function declaration headers. + syn match shFunctionComment "^\s*\zs\ze#" transparent nextgroup=shComment if !exists("g:sh_no_error") - syn match shFunctionNameError "\%#=1\%(\%(\<\h\w*\)\@>=\)\%(\%(\w\+\)\@>=\=\)\+()" skipwhite skipnl nextgroup=shExpr,shSubSh + syn match shFunctionNameAssignError "\%#=1\%(\%(\<\h\w*\)\@>=\)\%(\%(\w\+\)\@>=\=\)\+()" skipwhite skipnl nextgroup=shExpr,shSubSh + syn match shFunctionNameCommentError "#" contained endif elseif exists("b:is_ksh88") " AT&T ksh88 @@ -954,7 +958,8 @@ if !exists("skip_sh_syntax_inits") hi def link shParenError Error hi def link shTestError Error if exists("b:is_bash") - hi def link shFunctionNameError Error + hi def link shFunctionNameAssignError Error + hi def link shFunctionNameCommentError Error endif if exists("b:is_kornshell") || exists("b:is_posix") hi def link shDTestError Error diff --git a/runtime/syntax/testdir/dumps/sh_functions_bash_00.dump b/runtime/syntax/testdir/dumps/sh_functions_bash_00.dump index e78273f4f3..0eab07508d 100644 --- a/runtime/syntax/testdir/dumps/sh_functions_bash_00.dump +++ b/runtime/syntax/testdir/dumps/sh_functions_bash_00.dump @@ -1,8 +1,8 @@ | +0#0000e05#a8a8a8255@1>#+0&#ffffff0|!|/|b|i|n|/|b|a|s|h| +0#0000000&@61 | +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |s|e|t|l|o|c|a|l| |f|e|n| |f|d|c|=|2| |f|d|l|=|8| |f|d|m|=|s|y|n|t|a|x| +0#0000000&@20 | +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |l|e|t| |g|:|s|h|_|f|o|l|d|_|e|n|a|b|l|e|d| |=| |1| |+| |2| |+| |4| +0#0000000&@22 -| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72 -| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72 +| +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |h|i|g|h|l|i|g|h|t| |l|i|n|k| |s|h|F|u|n|c|t|i|o|n|E|x|p|r|R|e|g|i|o|n| |T|o|d|o| +0#0000000&@15 +| +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |h|i|g|h|l|i|g|h|t| |l|i|n|k| |s|h|F|u|n|c|t|i|o|n|S|u|b|S|h|R|e|g|i|o|n| |T|o|d|o| +0#0000000&@14 | +0#0000e05#a8a8a8255@1|t+0#af5f00255#ffffff0|y|p|e|s|e|t| +0#0000000&|-+0#e000e06&|i| +0#0000000&|n+0#00e0e07&|=+0#0000000&|0+0#e000002&| +0#0000000&@58 | +0#0000e05#a8a8a8255@1|d+0#00e0e07#ffffff0|o@1|s|i|e|(+0#e000e06&|)| +0#0000000&|(+0#e000e06&@1|n+0#0000000&|++0#af5f00255&|=|1+0#e000002&|)+0#e000e06&@1|;+0#0000000&| |d|o@1|s|i|e| @47 | +0#0000e05#a8a8a8255@1|d+0#00e0e07#ffffff0|o|n|e@1|(+0#e000e06&|)| +0#0000000&|[+0#e000e06&@1| +0#0000000&|-+0#af5f00255&|n| +0#0000000&|$+0#e000e06&|#| +0#0000000&|]+0#e000e06&@1|;+0#0000000&| |d|o|n|e@1| @46 diff --git a/runtime/syntax/testdir/dumps/sh_functions_bash_01.dump b/runtime/syntax/testdir/dumps/sh_functions_bash_01.dump index aba361e65e..cb780d087e 100644 --- a/runtime/syntax/testdir/dumps/sh_functions_bash_01.dump +++ b/runtime/syntax/testdir/dumps/sh_functions_bash_01.dump @@ -17,4 +17,4 @@ | +0#0000e05#a8a8a8255@1|f+0#af5f00255#ffffff0|o|r| +0#0000000&|x| |i+0#af5f00255&|n| +0#0000000&|1+0#e000002&| +0#0000000&|2+0#e000002&| +0#0000000&@60 |-+0#0000e05#a8a8a8255| |d+0#af5f00255#ffffff0|o| +0#0000000&@70 ||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|:| @67 -@57|1|9|,|1| @9|1|6|%| +@57|1|9|,|1| @9|1@1|%| diff --git a/runtime/syntax/testdir/dumps/sh_functions_bash_02.dump b/runtime/syntax/testdir/dumps/sh_functions_bash_02.dump index 8901e58ac3..349680a558 100644 --- a/runtime/syntax/testdir/dumps/sh_functions_bash_02.dump +++ b/runtime/syntax/testdir/dumps/sh_functions_bash_02.dump @@ -10,11 +10,11 @@ | +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72 |-+0#0000e05#a8a8a8255| |i+0#af5f00255#ffffff0|f| |:+0#0000000&|;+0#af5f00255&| +0#0000000&|t+0#af5f00255&|h|e|n| +0#0000000&@62 ||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|f+0#af5f00255&|u|n|c|t|i|o|n| +0#0000000&|!+0#00e0e07&|?|#|(+0#e000e06&|)| +0#0000000&@54 -|-+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|(+0#af5f00255&| +0#0000000&@67 -|-+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@7|f+0#af5f00255&|u|n|c|t|i|o|n| +0#0000000&|@+0#00e0e07&|α|!| +0#0000000&|{+0#e000e06&| +0#0000000&@50 +|-+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|(+0#0000001#ffff4012| +0#0000000#ffffff0@67 +|-+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@7|f+0#af5f00255&|u|n|c|t|i|o|n| +0#0000000&|@+0#00e0e07&|α|!| +0#0000000&|{+0#0000001#ffff4012| +0#0000000#ffffff0@50 |3+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@11|e+0#af5f00255&|c|h|o| +0#e000002&|"+0#af5f00255&|$+0#e000e06&|1|"+0#af5f00255&| +0#0000000&@51 -|3+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@7|}+0#e000e06&| +0#0000000&@63 +|3+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@7|}+0#0000001#ffff4012| +0#0000000#ffffff0@63 |2+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@7|@|α|!+0#af5f00255&| +0#0000000&|"+0#af5f00255&|$+0#e000e06&|1|"+0#af5f00255&| +0#0000000&@56 -|2+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|)+0#af5f00255&| +0#0000000&@67 +|2+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|)+0#0000001#ffff4012| +0#0000000#ffffff0@67 ||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|e+0#af5f00255&|v|a|l| +0#0000000&|!+0#af5f00255&|?+0#0000000&|\+0#e000e06&|#| +0#0000000&|"+0#af5f00255&|\+0#e000e06&|"|$|1|\|"|"+0#af5f00255&| +0#0000000&@50 -@57|3|7|,|1| @9|4|0|%| +@57|3|7|,|1| @9|2|8|%| diff --git a/runtime/syntax/testdir/dumps/sh_functions_bash_03.dump b/runtime/syntax/testdir/dumps/sh_functions_bash_03.dump index 98fcc942e8..c81798152a 100644 --- a/runtime/syntax/testdir/dumps/sh_functions_bash_03.dump +++ b/runtime/syntax/testdir/dumps/sh_functions_bash_03.dump @@ -2,8 +2,8 @@ ||+0#0000e05#a8a8a8255| |f+0#af5f00255#ffffff0|i| +0#0000000&@70 | +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72 | +0#0000e05#a8a8a8255@1|n+0#00e0e07#ffffff0|a|m|e|s|p|a|c|e| |(+0#e000e06&|)| +0#0000000&@60 -|-+0#0000e05#a8a8a8255| |{+0#e000e06#ffffff0| +0#0000000&|e+0#af5f00255&|c|h|o| +0#e000002&|$+0#e000e06&|#|;+0#af5f00255&| +0#0000000&@62 -||+0#0000e05#a8a8a8255| >}+0#e000e06#ffffff0|;+0#0000000&| |n|a|m|e|s|p|a|c|e| |$+0#e000e06&|@| +0#0000000&@57 +|-+0#0000e05#a8a8a8255| |{+0#0000001#ffff4012| +0#0000000#ffffff0|e+0#af5f00255&|c|h|o| +0#e000002&|$+0#e000e06&|#|;+0#af5f00255&| +0#0000000&@62 +||+0#0000e05#a8a8a8255| >}+0#0000001#ffff4012|;+0#0000000#ffffff0| |n|a|m|e|s|p|a|c|e| |$+0#e000e06&|@| +0#0000000&@57 | +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72 | +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |W|h|e|t|h|e|r| |"|=|"| |b|e|l|o|n|g|s| |t|o| |a| |n|a|m|e| |o|r| |d|e|l|i|m|i|t|s| |a| |n|a|m|e| |d|e|p|e|n|d|s| |o|n| |w|h|e|t|h|e|r| +0#0000000&@3 | +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |t|h|e| |r|e|s|e|r|v|e|d| |w|o|r|d| |"|f|u|n|c|t|i|o|n|"| |i|s| |p|r|e|s|e|n|t|,| |i|f| |s|o|,| |t|h|e|n| |"|=|"| |i|s| |p|a|r|t| |o|f| +0#0000000&@3 @@ -17,4 +17,4 @@ | +0#0000e05#a8a8a8255@1| +0#e000e06#ffffff0@3|x+0#00e0e07&|s|=+0#0000000&|(+0#e000e06&|)| +0#0000000&@63 | +0#0000e05#a8a8a8255@1| +0#e000e06#ffffff0@3|{| +0#0000000&@67 | +0#0000e05#a8a8a8255@1| +0#e000e06#ffffff0@7|e+0#af5f00255&|c|h|o| +0#e000002&|$+0#e000e06&|(@1| |2+0#e000002&| +0#e000e06&|+| |$|{|#|x|s|[|*+0#0000000&|]+0#e000e06&|}| |)@1| +0#0000000&@39 -@57|5@1|,|1| @9|6|3|%| +@57|5@1|,|1| @9|4@1|%| diff --git a/runtime/syntax/testdir/dumps/sh_functions_bash_04.dump b/runtime/syntax/testdir/dumps/sh_functions_bash_04.dump index d1be88c7d3..73488d28aa 100644 --- a/runtime/syntax/testdir/dumps/sh_functions_bash_04.dump +++ b/runtime/syntax/testdir/dumps/sh_functions_bash_04.dump @@ -4,17 +4,17 @@ | +0#0000e05#a8a8a8255@1| +0#e000e06#ffffff0@3|}| +0#0000000&@67 | +0#0000e05#a8a8a8255@1|)+0#e000e06#ffffff0| +0#0000000&@71 | +0#0000e05#a8a8a8255@1> +0#0000000#ffffff0@72 -|-+0#0000e05#a8a8a8255| |i+0#00e0e07#ffffff0|δ|=|(+0#e000e06&|)| +0#0000000&|(+0#af5f00255&| +0#0000000&@65 -|-+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|=+0#00e0e07&|i|d|=|(+0#e000e06&|)| +0#0000000&|{+0#e000e06&| +0#0000000&@60 +|-+0#0000e05#a8a8a8255| |i+0#00e0e07#ffffff0|δ|=|(+0#e000e06&|)| +0#0000000&|(+0#0000001#ffff4012| +0#0000000#ffffff0@65 +|-+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|=+0#00e0e07&|i|d|=|(+0#e000e06&|)| +0#0000000&|{+0#0000001#ffff4012| +0#0000000#ffffff0@60 |2+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@7|=+0#00e0e07&@2|(+0#e000e06&|)| +0#0000000&@59 |2+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@7|i+0#af5f00255&|f| |:+0#0000000&|;+0#af5f00255&| +0#0000000&|t+0#af5f00255&|h|e|n| +0#0000000&|e+0#af5f00255&|c|h|o| +0#e000002&|$+0#e000e06&|*|;+0#af5f00255&| +0#0000000&|f+0#af5f00255&|i|;| +0#0000000&|=+0#af5f00255&@2| +0#0000000&|$+0#e000e06&|*| +0#0000000&@34 -|2+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|}+0#e000e06&|;+0#af5f00255&| +0#0000000&|=+0#af5f00255&|i|d|=| +0#0000000&|$+0#e000e06&|*| +0#0000000&@58 -||+0#0000e05#a8a8a8255| |)+0#af5f00255#ffffff0|;+0#0000000&| |i+0#af5f00255&|d|=| +0#0000000&|i|δ|=+0#af5f00255&| +0#0000000&|i|δ|=+0#af5f00255&| +0#0000000&|i|δ|=+0#af5f00255&| +0#0000000&@54 +|2+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|}+0#0000001#ffff4012|;+0#af5f00255#ffffff0| +0#0000000&|=+0#af5f00255&|i|d|=| +0#0000000&|$+0#e000e06&|*| +0#0000000&@58 +||+0#0000e05#a8a8a8255| |)+0#0000001#ffff4012|;+0#0000000#ffffff0| |i+0#af5f00255&|d|=| +0#0000000&|i|δ|=+0#af5f00255&| +0#0000000&|i|δ|=+0#af5f00255&| +0#0000000&|i|δ|=+0#af5f00255&| +0#0000000&@54 | +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72 -|-+0#0000e05#a8a8a8255| |f+0#af5f00255#ffffff0|u|n|c|t|i|o|n| +0#0000000&|f+0#00e0e07&|=|(+0#e000e06&|)| +0#0000000&|(+0#af5f00255&| +0#0000000&@57 -|-+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|f+0#af5f00255&|u|n|c|t|i|o|n| +0#0000000&|f+0#00e0e07&|=|f| +0#0000000&|{+0#e000e06&| +0#0000000&@54 +|-+0#0000e05#a8a8a8255| |f+0#af5f00255#ffffff0|u|n|c|t|i|o|n| +0#0000000&|f+0#00e0e07&|=|(+0#e000e06&|)| +0#0000000&|(+0#0000001#ffff4012| +0#0000000#ffffff0@57 +|-+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|f+0#af5f00255&|u|n|c|t|i|o|n| +0#0000000&|f+0#00e0e07&|=|f| +0#0000000&|{+0#0000001#ffff4012| +0#0000000#ffffff0@54 |2+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@7|f+0#af5f00255&|u|n|c|t|i|o|n| +0#0000000&|f+0#00e0e07&|=|f|=| +0#0000000&@51 |2+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@7|i+0#af5f00255&|f| |:+0#0000000&|;+0#af5f00255&| +0#0000000&|t+0#af5f00255&|h|e|n| +0#0000000&|e+0#af5f00255&|c|h|o| +0#e000002&|$+0#e000e06&|*|;+0#af5f00255&| +0#0000000&|f+0#af5f00255&|i|;| +0#0000000&|f|\+0#e000e06&|=|f+0#0000000&|\+0#e000e06&|=| +0#0000000&|$+0#e000e06&|*| +0#0000000&@31 -|2+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|}+0#e000e06&|;+0#af5f00255&| +0#0000000&|f|\+0#e000e06&|=|f+0#0000000&| |$+0#e000e06&|*| +0#0000000&@58 -||+0#0000e05#a8a8a8255| |)+0#af5f00255#ffffff0|;+0#0000000&| |f+0#00e0e07&|=+0#0000000&| |f|\|=+0#af5f00255&| +0#0000000&|f+0#00e0e07&|=+0#0000000&| |f+0#00e0e07&|=+0#0000000&| @57 -@57|7|3|,|0|-|1| @7|8|7|%| +|2+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|}+0#0000001#ffff4012|;+0#af5f00255#ffffff0| +0#0000000&|f|\+0#e000e06&|=|f+0#0000000&| |$+0#e000e06&|*| +0#0000000&@58 +||+0#0000e05#a8a8a8255| |)+0#0000001#ffff4012|;+0#0000000#ffffff0| |f+0#00e0e07&|=+0#0000000&| |f|\|=+0#af5f00255&| +0#0000000&|f+0#00e0e07&|=+0#0000000&| |f+0#00e0e07&|=+0#0000000&| @57 +@57|7|3|,|0|-|1| @7|6|1|%| diff --git a/runtime/syntax/testdir/dumps/sh_functions_bash_05.dump b/runtime/syntax/testdir/dumps/sh_functions_bash_05.dump index 9b805c1891..bf354f4741 100644 --- a/runtime/syntax/testdir/dumps/sh_functions_bash_05.dump +++ b/runtime/syntax/testdir/dumps/sh_functions_bash_05.dump @@ -1,20 +1,20 @@ -||+0#0000e05#a8a8a8255| |)+0#af5f00255#ffffff0|;+0#0000000&| |f+0#00e0e07&|=+0#0000000&| |f|\|=+0#af5f00255&| +0#0000000&|f+0#00e0e07&|=+0#0000000&| |f+0#00e0e07&|=+0#0000000&| @57 +||+0#0000e05#a8a8a8255| |)+0#0000001#ffff4012|;+0#0000000#ffffff0| |f+0#00e0e07&|=+0#0000000&| |f|\|=+0#af5f00255&| +0#0000000&|f+0#00e0e07&|=+0#0000000&| |f+0#00e0e07&|=+0#0000000&| @57 | +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72 -| +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |P|a|r|e|n|s| |a|r|e| |n|o|t| |e|s|c|a|p|e|d|,| |h|e|n|c|e| |t|h|i|s| |i|s| |i|n|v|a|l|i|d| |v|a|r|i|a|b|l|e| |a|s@1|i|g|n|m|e|n|t|.| +0#0000000&@4 -| +0#0000e05#a8a8a8255@1|f+0#ffffff16#ff404010|=|f|(|)| +0#0000000#ffffff0@67 -| +0#0000e05#a8a8a8255@1|{+0#e000e06#ffffff0| +0#0000000&@71 -| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@3>f+0#ffffff16#ff404010|=|f|=|(|)| +0#0000000#ffffff0@62 -| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@3|(+0#af5f00255&| +0#0000000&@67 -| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@7|f+0#ffffff16#ff404010|=|f|=|f|(|)| +0#0000000#ffffff0@57 -| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@7|i+0#af5f00255&|f| |:+0#0000000&|;+0#af5f00255&| +0#0000000&|t+0#af5f00255&|h|e|n| +0#0000000&|:|;+0#af5f00255&| +0#0000000&|f+0#af5f00255&|i| +0#0000000&@48 -| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@3|)+0#af5f00255&| +0#0000000&@67 -| +0#0000e05#a8a8a8255@1|}+0#e000e06#ffffff0| +0#0000000&@71 -|~+0#4040ff13&| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -|~| @73 -| +0#0000000&@56|9|1|,|5| @9|B|o|t| +| +0#0000e05#a8a8a8255@1|#+0&#ffffff0|f|u|n|c|t|i|o|n|(|)| |{| +0#0000000&@59 +| +0#0000e05#a8a8a8255@1|#+0&#ffffff0| @2|e|c|h|o| |"|$|1|"| +0#0000000&@59 +| +0#0000e05#a8a8a8255@1|#+0&#ffffff0|}| +0#0000000&@70 +| +0#0000e05#a8a8a8255@1> +0#0000000#ffffff0@72 +|-+0#0000e05#a8a8a8255| |f+0#af5f00255#ffffff0|u|n|c|t|i|o|n| +0#0000000&|f+0#00e0e07&|u|n|c|t|i|o|n| +0#0000000&|{+0#0000001#ffff4012| +0#0000000#ffffff0@53 +||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|s+0#af5f00255&|e|t| +0#00e0e07&|-@1| |$+0#e000e06&|{|*|/+0#af5f00255&|\+0#0000000&| @56 +||+0#0000e05#a8a8a8255| |#+0#0000000#ffffff0|.|/+0#af5f00255&|}+0#e000e06&| +0#0000000&@68 +||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|s+0#af5f00255&|e|t| +0#00e0e07&|-@1| |`+0#e000e06&|p+0#af5f00255&|r|i|n|t|f| +0#e000e06&|%|\| +0#0000000&@51 +||+0#0000e05#a8a8a8255| |#+0&#ffffff0|.|f|\| @1|$|*| |2|>|/|d|e|v|/|n|u|l@1|`+0#e000e06&|;+0#af5f00255&|:+0#0000000&| |#+0#0000e05&| |F+0#0000001#ffff4012|I|X|M|E|:+0#0000e05#ffffff0| |N|o|t| |a| |c|o|m@1|e|n|t| |(|%|\|)| +0#0000000&@21 +||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|s+0#af5f00255&|e|t| +0#00e0e07&|-@1| |$+0#e000e06&|{|*|%+0#af5f00255&|.+0#0000000&|}+0#e000e06&| +0#0000000&@55 +||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|l+0#af5f00255&|o|c|a|l| +0#0000000&|I+0#e000e06&|F|S|=+0#af5f00255&|++0#0000000&| @57 +||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|e+0#af5f00255&|c|h|o| +0#e000002&|$+0#e000e06&|(@2|"+0#af5f00255&|$+0#e000e06&|{|*|\+0#ffffff16#ff404010| +0#0000000#ffffff0@54 +||+0#0000e05#a8a8a8255| |#+0#ffffff16#ff404010|f|u|n|c|t|i|o|n|(|)|}+0#e000e06#ffffff0|"+0#af5f00255&|)+0#e000e06&| |/| |$|{|\+0#ffffff16#ff404010| +0#0000000#ffffff0@52 +||+0#0000e05#a8a8a8255| |#+0#ffffff16#ff404010|}+0#e000e06#ffffff0| |+| |1+0#e000002&|6|\+0#e000e06&| +0#0000000&@64 +||+0#0000e05#a8a8a8255| |#+0&#ffffff0|0|\| +0#0000000&@69 +||+0#0000e05#a8a8a8255| |)+0#e000e06#ffffff0@1|;+0#af5f00255&|:+0#0000000&| |#+0#0000e05&| |F+0#0000001#ffff4012|I|X|M|E|:+0#0000e05#ffffff0| |N|o|t| |a| |c|o|m@1|e|n|t| |(|1|6|\|)| +0#0000000&@39 +||+0#0000e05#a8a8a8255| |}+0#0000001#ffff4012|;+0#0000000#ffffff0| |e+0#af5f00255&|v|a|l| +0#0000000&|"+0#af5f00255&|\+0#e000e06&|f|u+0#e000002&|n|c|t|i|o|n|"+0#af5f00255&| +0#0000000&|$+0#e000e06&|@| +0#0000000&@50 +@57|9|1|,|0|-|1| @7|7@1|%| diff --git a/runtime/syntax/testdir/dumps/sh_functions_bash_06.dump b/runtime/syntax/testdir/dumps/sh_functions_bash_06.dump new file mode 100644 index 0000000000..7fb4a39704 --- /dev/null +++ b/runtime/syntax/testdir/dumps/sh_functions_bash_06.dump @@ -0,0 +1,20 @@ +||+0#0000e05#a8a8a8255| |}+0#0000001#ffff4012|;+0#0000000#ffffff0| |e+0#af5f00255&|v|a|l| +0#0000000&|"+0#af5f00255&|\+0#e000e06&|f|u+0#e000002&|n|c|t|i|o|n|"+0#af5f00255&| +0#0000000&|$+0#e000e06&|@| +0#0000000&@50 +| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72 +| +0#0000e05#a8a8a8255@1|f+0#af5f00255#ffffff0|u|n|c|t|i|o|n| +0#0000000&|f+0#00e0e07&|u|n|c|t|i|o|n|#|f|u|n|c|t|i|o|n| |(+0#e000e06&|)| +0#0000000&|{+0#e000e06&| +0#0000000&@41 +| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@3|e+0#af5f00255&|c|h|o| +0#e000002&|"+0#af5f00255&|$+0#e000e06&|1|"+0#af5f00255&| +0#0000000&@59 +| +0#0000e05#a8a8a8255@1|}+0#e000e06#ffffff0|;+0#0000000&| |e+0#af5f00255&|v|a|l| +0#0000000&|"+0#af5f00255&|f+0#e000002&|u|n|c|t|i|o|n|#|f|u|n|c|t|i|o|n|"+0#af5f00255&| +0#0000000&|"+0#af5f00255&|$+0#e000e06&|1|"+0#af5f00255&| +0#0000000&@40 +| +0#0000e05#a8a8a8255@1> +0#0000000#ffffff0@72 +|-+0#0000e05#a8a8a8255| |f+0#00e0e07#ffffff0|u|n|c|t|i|o|n|#| |(+0#e000e06&|)| +0#0000000&|{+0#0000001#ffff4012| +0#0000000#ffffff0@58 +||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|e+0#af5f00255&|c|h|o| +0#e000002&|"+0#af5f00255&|$+0#e000e06&|1|"+0#af5f00255&| +0#0000000&@59 +||+0#0000e05#a8a8a8255| |}+0#0000001#ffff4012|;+0#0000000#ffffff0| |f|u|n|c|t|i|o|n|#| |"+0#af5f00255&|$+0#e000e06&|1|"+0#af5f00255&| +0#0000000&@55 +| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72 +| +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |P|a|r|e|n|s| |a|r|e| |n|o|t| |e|s|c|a|p|e|d|,| |h|e|n|c|e| |t|h|i|s| |i|s| |i|n|v|a|l|i|d| |v|a|r|i|a|b|l|e| |a|s@1|i|g|n|m|e|n|t|.| +0#0000000&@4 +| +0#0000e05#a8a8a8255@1|f+0#ffffff16#ff404010|=|f|(|)| +0#0000000#ffffff0@67 +| +0#0000e05#a8a8a8255@1|{+0#e000e06#ffffff0| +0#0000000&@71 +| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@3|f+0#ffffff16#ff404010|=|f|=|(|)| +0#0000000#ffffff0@62 +| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@3|(+0#af5f00255&| +0#0000000&@67 +| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@7|f+0#ffffff16#ff404010|=|f|=|f|(|)| +0#0000000#ffffff0@57 +| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@7|i+0#af5f00255&|f| |:+0#0000000&|;+0#af5f00255&| +0#0000000&|t+0#af5f00255&|h|e|n| +0#0000000&|:|;+0#af5f00255&| +0#0000000&|f+0#af5f00255&|i| +0#0000000&@48 +| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@3|)+0#af5f00255&| +0#0000000&@67 +| +0#0000e05#a8a8a8255@1|}+0#e000e06#ffffff0| +0#0000000&@71 +@57|1|0|9|,|0|-|1| @6|9|4|%| diff --git a/runtime/syntax/testdir/dumps/sh_functions_bash_07.dump b/runtime/syntax/testdir/dumps/sh_functions_bash_07.dump new file mode 100644 index 0000000000..7dea3a44df --- /dev/null +++ b/runtime/syntax/testdir/dumps/sh_functions_bash_07.dump @@ -0,0 +1,20 @@ +| +0#0000e05#a8a8a8255@1|}+0#e000e06#ffffff0| +0#0000000&@71 +| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72 +| +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |I|d|e|n|t|i|f|i|e|r|s| |c|a|n@1|o|t| |h|a|v|e| |a| |l|e|a|d|i|n|g| |"|#|"| |i|n| |t|h|e|i|r| |n|a|m|e|s| |u|n|l|e|s@1| |t|h|e| |s|h|e|l@1| +0#0000000&@1 +| +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |o|p|t|i|o|n| |"|i|n|t|e|r|a|c|t|i|v|e|_|c|o|m@1|e|n|t|s|"| |i|s| |u|n|s|e|t| |a|n|d| |i|s| |i|n| |e|f@1|e|c|t|.| +0#0000000&@14 +| +0#0000e05#a8a8a8255@1|f+0#af5f00255#ffffff0|u|n|c|t|i|o|n| +0#0000000&|#+0#ffffff16#ff404010|f+0#0000000#ffffff0|u|n|c|t|i|o|n|(+0#e000e06&|)| +0#0000000&|{+0#e000e06&| +0#0000000&@50 +| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@3>e+0#af5f00255&|c|h|o| +0#e000002&|"+0#af5f00255&|$+0#e000e06&|1|"+0#af5f00255&| +0#0000000&@59 +| +0#0000e05#a8a8a8255@1|}+0#e000e06#ffffff0| +0#0000000&@71 +|~+0#4040ff13&| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +| +0#0000000&@56|1|2|7|,|5| @8|B|o|t| diff --git a/runtime/syntax/testdir/input/sh_functions_bash.sh b/runtime/syntax/testdir/input/sh_functions_bash.sh index 714d2a74b3..2a1c4ec616 100644 --- a/runtime/syntax/testdir/input/sh_functions_bash.sh +++ b/runtime/syntax/testdir/input/sh_functions_bash.sh @@ -1,8 +1,8 @@ #!/bin/bash # VIM_TEST_SETUP setlocal fen fdc=2 fdl=8 fdm=syntax # VIM_TEST_SETUP let g:sh_fold_enabled = 1 + 2 + 4 - - +# VIM_TEST_SETUP highlight link shFunctionExprRegion Todo +# VIM_TEST_SETUP highlight link shFunctionSubShRegion Todo typeset -i n=0 doosie() ((n+=1)); doosie donee() [[ -n $# ]]; donee @@ -85,6 +85,32 @@ function f=() ( }; f\=f $* ); f= f\= f= f= +#function() { +# echo "$1" +#} + +function function { + set -- ${*/\ +#./} + set -- `printf %\ +#.f\ $* 2>/dev/null`;: # FIXME: Not a comment (%\) + set -- ${*%.} + local IFS=+ + echo $((("${*\ +#function()}") / ${\ +#} + 16\ +#0\ +));: # FIXME: Not a comment (16\) +}; eval "\function" $@ + +function function#function () { + echo "$1" +}; eval "function#function" "$1" + +function# () { + echo "$1" +}; function# "$1" + # Parens are not escaped, hence this is invalid variable assignment. f=f() { @@ -94,3 +120,9 @@ f=f() if :; then :; fi ) } + +# Identifiers cannot have a leading "#" in their names unless the shell +# option "interactive_comments" is unset and is in effect. +function #function() { + echo "$1" +}