]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
runtime(sh): Do not conflate comments and function declarations in Bash
authorAliaksei Budavei <0x000c70@gmail.com>
Thu, 6 Aug 2026 18:56:02 +0000 (18:56 +0000)
committerChristian Brabandt <cb@256bit.org>
Thu, 6 Aug 2026 18:56:02 +0000 (18:56 +0000)
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 <dezzadk@gmail.com>
Co-authored-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/syntax/sh.vim
runtime/syntax/testdir/dumps/sh_functions_bash_00.dump
runtime/syntax/testdir/dumps/sh_functions_bash_01.dump
runtime/syntax/testdir/dumps/sh_functions_bash_02.dump
runtime/syntax/testdir/dumps/sh_functions_bash_03.dump
runtime/syntax/testdir/dumps/sh_functions_bash_04.dump
runtime/syntax/testdir/dumps/sh_functions_bash_05.dump
runtime/syntax/testdir/dumps/sh_functions_bash_06.dump [new file with mode: 0644]
runtime/syntax/testdir/dumps/sh_functions_bash_07.dump [new file with mode: 0644]
runtime/syntax/testdir/input/sh_functions_bash.sh

index 52d50df85300af35ddd540df39c2b62808f0e77c..90a712a00a3158d0bb291ed9174a4fcec399b62b 100644 (file)
@@ -3,7 +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:         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 "\<function\s\@="  nextgroup=shFunctionKeyDelim
 endif
 
 ShFoldFunctions syn region shFunctionExpr      matchgroup=shFunctionExprRegion start="{"       end="}" contains=@shFunctionList         contained skipwhite skipnl nextgroup=shQuickComment
@@ -655,9 +656,12 @@ if exists("b:is_bash")
     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
+    " 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
index e78273f4f3b4d23ab286b85823f81af6ee1a4345..0eab07508d2d96c404deb96be2f1125145c2930c 100644 (file)
@@ -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
index aba361e65eea7e20e128567be6c8eea13ed19134..cb780d087edf69efe0895b0a8f7b8db4add56515 100644 (file)
@@ -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|%| 
index 8901e58ac323f5f3878e06a27fb3b3a7056c398d..349680a55875798f425bfac46fd76c3f493cf8d7 100644 (file)
 | +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|%| 
index 98fcc942e8487aed958f51a5878072d6f194bc43..c81798152ab9c54976e4b7ef97e6c800f7314b31 100644 (file)
@@ -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|%| 
index d1be88c7d3a3ff5f1251d8061f3c75184e744bd9..73488d28aab3dab43e7ffc59e1e7676e750664e6 100644 (file)
@@ -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|%| 
index 9b805c1891879ae7a9c9146a14a880cee2375a85..bf354f4741a9e7783b3a82336cfcbec6f6a077fc 100644 (file)
@@ -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 (file)
index 0000000..7fb4a39
--- /dev/null
@@ -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 (file)
index 0000000..7dea3a4
--- /dev/null
@@ -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| 
index 714d2a74b37480bae45b7a5c9bc38fe4e9653eff..2a1c4ec616f764b1a8a95b54a573a23c79f790de 100644 (file)
@@ -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"
+}