1071d4279SBram Moolenaar" Vim syntax file 2071d4279SBram Moolenaar" Language: shell (sh) Korn shell (ksh) bash (sh) 31d9215b9SBram Moolenaar" Maintainer: Charles E. Campbell <[email protected]> 4071d4279SBram Moolenaar" Previous Maintainer: Lennart Schultz <[email protected]> 5*113cb513SBram Moolenaar" Last Change: Oct 26, 2021 6*113cb513SBram Moolenaar" Version: 199 7e2719096SBram Moolenaar" URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_SH 8c236c16dSBram Moolenaar" For options and settings, please use: :help ft-sh-syntax 923515b4eSBram Moolenaar" This file includes many ideas from Eric Brunet ([email protected]) and heredoc fixes from Felipe Contreras 10071d4279SBram Moolenaar 11f37506f6SBram Moolenaar" quit when a syntax file was already loaded {{{1 1289bcfda6SBram Moolenaarif exists("b:current_syntax") 13071d4279SBram Moolenaar finish 14071d4279SBram Moolenaarendif 15071d4279SBram Moolenaar 16d2ea7cf1SBram Moolenaar" If the shell script itself specifies which shell to use, use it 17d2ea7cf1SBram Moolenaarif getline(1) =~ '\<ksh\>' 1891c4937bSBram Moolenaar let b:is_kornshell = 1 19d2ea7cf1SBram Moolenaarelseif getline(1) =~ '\<bash\>' 2091c4937bSBram Moolenaar let b:is_bash = 1 21d2ea7cf1SBram Moolenaarelseif getline(1) =~ '\<dash\>' 22d58a3bf7SBram Moolenaar let b:is_dash = 1 23d58a3bf7SBram Moolenaarelseif !exists("g:is_kornshell") && !exists("g:is_bash") && !exists("g:is_posix") && !exists("g:is_sh") && !exists("g:is_dash") 24d2ea7cf1SBram Moolenaar " user did not specify which shell to use, and 25d2ea7cf1SBram Moolenaar " the script itself does not specify which shell to use. FYI: /bin/sh is ambiguous. 26d2ea7cf1SBram Moolenaar " Assuming /bin/sh is executable, and if its a link, find out what it links to. 27bc488a76SBram Moolenaar let s:shell = "" 28d960d76dSBram Moolenaar if executable("/bin/sh") 29bc488a76SBram Moolenaar let s:shell = resolve("/bin/sh") 30d960d76dSBram Moolenaar elseif executable("/usr/bin/sh") 31bc488a76SBram Moolenaar let s:shell = resolve("/usr/bin/sh") 32bc488a76SBram Moolenaar endif 33d2ea7cf1SBram Moolenaar if s:shell =~ '\<ksh\>' 3491c4937bSBram Moolenaar let b:is_kornshell= 1 35d2ea7cf1SBram Moolenaar elseif s:shell =~ '\<bash\>' 3691c4937bSBram Moolenaar let b:is_bash = 1 37d2ea7cf1SBram Moolenaar elseif s:shell =~ '\<dash\>' 38d58a3bf7SBram Moolenaar let b:is_dash = 1 39d960d76dSBram Moolenaar endif 40bc488a76SBram Moolenaar unlet s:shell 41d960d76dSBram Moolenaarendif 42d960d76dSBram Moolenaar 43d4755bb0SBram Moolenaar" handling /bin/sh with is_kornshell/is_sh {{{1 44d2ea7cf1SBram Moolenaar" b:is_sh will be set when "#! /bin/sh" is found; 45071d4279SBram Moolenaar" However, it often is just a masquerade by bash (typically Linux) 46071d4279SBram Moolenaar" or kornshell (typically workstations with Posix "sh"). 47d960d76dSBram Moolenaar" So, when the user sets "g:is_bash", "g:is_kornshell", 48d960d76dSBram Moolenaar" or "g:is_posix", a b:is_sh is converted into b:is_bash/b:is_kornshell, 49071d4279SBram Moolenaar" respectively. 50d58a3bf7SBram Moolenaarif !exists("b:is_kornshell") && !exists("b:is_bash") && !exists("b:is_dash") 517fc904b6SBram Moolenaar if exists("g:is_posix") && !exists("g:is_kornshell") 527fc904b6SBram Moolenaar let g:is_kornshell= g:is_posix 537fc904b6SBram Moolenaar endif 547fc904b6SBram Moolenaar if exists("g:is_kornshell") 55071d4279SBram Moolenaar let b:is_kornshell= 1 56071d4279SBram Moolenaar if exists("b:is_sh") 57071d4279SBram Moolenaar unlet b:is_sh 58071d4279SBram Moolenaar endif 597fc904b6SBram Moolenaar elseif exists("g:is_bash") 60071d4279SBram Moolenaar let b:is_bash= 1 61071d4279SBram Moolenaar if exists("b:is_sh") 62071d4279SBram Moolenaar unlet b:is_sh 63071d4279SBram Moolenaar endif 64d58a3bf7SBram Moolenaar elseif exists("g:is_dash") 65d58a3bf7SBram Moolenaar let b:is_dash= 1 66d58a3bf7SBram Moolenaar if exists("b:is_sh") 67d58a3bf7SBram Moolenaar unlet b:is_sh 68d58a3bf7SBram Moolenaar endif 69071d4279SBram Moolenaar else 70071d4279SBram Moolenaar let b:is_sh= 1 71071d4279SBram Moolenaar endif 72071d4279SBram Moolenaarendif 73071d4279SBram Moolenaar 74d58a3bf7SBram Moolenaar" if b:is_dash, set b:is_posix too 75d58a3bf7SBram Moolenaarif exists("b:is_dash") 76d58a3bf7SBram Moolenaar let b:is_posix= 1 77d58a3bf7SBram Moolenaarendif 78d58a3bf7SBram Moolenaar 79cd71fa3cSBram Moolenaar" set up default g:sh_fold_enabled {{{1 80b4ff518dSBram Moolenaar" ================================ 81071d4279SBram Moolenaarif !exists("g:sh_fold_enabled") 82071d4279SBram Moolenaar let g:sh_fold_enabled= 0 83293ee4d4SBram Moolenaarelseif g:sh_fold_enabled != 0 && !has("folding") 84293ee4d4SBram Moolenaar let g:sh_fold_enabled= 0 85cd71fa3cSBram Moolenaar echomsg "Ignoring g:sh_fold_enabled=".g:sh_fold_enabled."; need to re-compile vim for +fold support" 86cd71fa3cSBram Moolenaarendif 87c236c16dSBram Moolenaarif !exists("s:sh_fold_functions") 8897d62497SBram Moolenaar let s:sh_fold_functions= and(g:sh_fold_enabled,1) 89c236c16dSBram Moolenaarendif 90c236c16dSBram Moolenaarif !exists("s:sh_fold_heredoc") 9197d62497SBram Moolenaar let s:sh_fold_heredoc = and(g:sh_fold_enabled,2) 92c236c16dSBram Moolenaarendif 93c236c16dSBram Moolenaarif !exists("s:sh_fold_ifdofor") 9497d62497SBram Moolenaar let s:sh_fold_ifdofor = and(g:sh_fold_enabled,4) 95c236c16dSBram Moolenaarendif 96cd71fa3cSBram Moolenaarif g:sh_fold_enabled && &fdm == "manual" 9797d62497SBram Moolenaar " Given that the user provided g:sh_fold_enabled 9897d62497SBram Moolenaar " AND g:sh_fold_enabled is manual (usual default) 9997d62497SBram Moolenaar " implies a desire for syntax-based folding 10097d62497SBram Moolenaar setl fdm=syntax 101071d4279SBram Moolenaarendif 102071d4279SBram Moolenaar 103d2ea7cf1SBram Moolenaar" set up the syntax-highlighting for iskeyword 104723dd946SBram Moolenaarif (v:version == 704 && has("patch-7.4.1142")) || v:version > 704 105d2ea7cf1SBram Moolenaar if !exists("g:sh_syntax_isk") || (exists("g:sh_syntax_isk") && g:sh_syntax_isk) 10691c4937bSBram Moolenaar if exists("b:is_bash") 10791c4937bSBram Moolenaar exe "syn iskeyword ".&iskeyword.",-,:" 10891c4937bSBram Moolenaar else 109e0fa3742SBram Moolenaar exe "syn iskeyword ".&iskeyword.",-" 110e0fa3742SBram Moolenaar endif 11191c4937bSBram Moolenaar endif 112d2ea7cf1SBram Moolenaarendif 113e0fa3742SBram Moolenaar 114b4ff518dSBram Moolenaar" Set up folding commands for shell {{{1 115b4ff518dSBram Moolenaar" ================================= 116b4ff518dSBram Moolenaarif s:sh_fold_functions 117b4ff518dSBram Moolenaar com! -nargs=* ShFoldFunctions <args> fold 118b4ff518dSBram Moolenaarelse 119b4ff518dSBram Moolenaar com! -nargs=* ShFoldFunctions <args> 120b4ff518dSBram Moolenaarendif 121b4ff518dSBram Moolenaarif s:sh_fold_heredoc 122b4ff518dSBram Moolenaar com! -nargs=* ShFoldHereDoc <args> fold 123b4ff518dSBram Moolenaarelse 124b4ff518dSBram Moolenaar com! -nargs=* ShFoldHereDoc <args> 125b4ff518dSBram Moolenaarendif 126b4ff518dSBram Moolenaarif s:sh_fold_ifdofor 127b4ff518dSBram Moolenaar com! -nargs=* ShFoldIfDoFor <args> fold 128b4ff518dSBram Moolenaarelse 129b4ff518dSBram Moolenaar com! -nargs=* ShFoldIfDoFor <args> 130b4ff518dSBram Moolenaarendif 131b4ff518dSBram Moolenaar 132cd71fa3cSBram Moolenaar" sh syntax is case sensitive {{{1 133071d4279SBram Moolenaarsyn case match 134071d4279SBram Moolenaar 135d4755bb0SBram Moolenaar" Clusters: contains=@... clusters {{{1 136071d4279SBram Moolenaar"================================== 1375c73622aSBram Moolenaarsyn cluster shErrorList contains=shDoError,shIfError,shInError,shCaseError,shEsacError,shCurlyError,shParenError,shTestError,shOK 13851ad4eaaSBram Moolenaarif exists("b:is_kornshell") || exists("b:is_bash") 139c236c16dSBram Moolenaar syn cluster ErrorList add=shDTestError 140c236c16dSBram Moolenaarendif 1411d9215b9SBram Moolenaarsyn cluster shArithParenList contains=shArithmetic,shCaseEsac,shComment,shDeref,shDo,shDerefSimple,shEcho,shEscape,shNumber,shOperator,shPosnParm,shExSingleQuote,shExDoubleQuote,shHereString,shRedir,shSingleQuote,shDoubleQuote,shStatement,shVariable,shAlias,shTest,shCtrlSeq,shSpecial,shParen,bashSpecialVariables,bashStatement,shIf,shFor,shFunctionKey,shFunctionOne,shFunctionTwo 142c236c16dSBram Moolenaarsyn cluster shArithList contains=@shArithParenList,shParenError 143d2855f54SBram Moolenaarsyn cluster shCaseEsacList contains=shCaseStart,shCaseLabel,shCase,shCaseBar,shCaseIn,shComment,shDeref,shDerefSimple,shCaseCommandSub,shCaseExSingleQuote,shCaseSingleQuote,shCaseDoubleQuote,shCtrlSeq,@shErrorList,shStringSpecial,shCaseRange 14423515b4eSBram Moolenaarsyn cluster shCaseList contains=@shCommandSubList,shCaseEsac,shColon,shCommandSub,shCommandSubBQ,shComment,shDo,shEcho,shExpr,shFor,shHereDoc,shIf,shHereString,shRedir,shSetList,shSource,shStatement,shVariable,shCtrlSeq 14523515b4eSBram Moolenaarif exists("b:is_kornshell") || exists("b:is_bash") 14623515b4eSBram Moolenaar syn cluster shCaseList add=shForPP 14723515b4eSBram Moolenaarendif 148d2855f54SBram Moolenaarsyn cluster shCommandSubList contains=shAlias,shArithmetic,shCmdParenRegion,shCommandSub,shComment,shCtrlSeq,shDeref,shDerefSimple,shDoubleQuote,shEcho,shEscape,shExDoubleQuote,shExpr,shExSingleQuote,shHereDoc,shNumber,shOperator,shOption,shPosnParm,shHereString,shRedir,shSingleQuote,shSpecial,shStatement,shSubSh,shTest,shVariable 149572cb561SBram Moolenaarsyn cluster shCurlyList contains=shNumber,shComma,shDeref,shDerefSimple,shDerefSpecial 1501d9215b9SBram Moolenaar" COMBAK: removing shEscape from shDblQuoteList fails ksh04:43 1511d9215b9SBram Moolenaarsyn cluster shDblQuoteList contains=shArithmetic,shCommandSub,shCommandSubBQ,shDeref,shDerefSimple,shPosnParm,shCtrlSeq,shSpecial,shSpecialDQ 152acb4f221SBram Moolenaarsyn cluster shDerefList contains=shDeref,shDerefSimple,shDerefVar,shDerefSpecial,shDerefWordError,shDerefPSR,shDerefPPS 153d58a3bf7SBram Moolenaarsyn cluster shDerefVarList contains=shDerefOffset,shDerefOp,shDerefVarArray,shDerefOpError 154d2855f54SBram Moolenaarsyn cluster shEchoList contains=shArithmetic,shCommandSub,shCommandSubBQ,shDeref,shDerefSimple,shEscape,shExSingleQuote,shExDoubleQuote,shSingleQuote,shDoubleQuote,shCtrlSeq,shEchoQuote 155e90ee31cSBram Moolenaarsyn cluster shExprList1 contains=shCharClass,shNumber,shOperator,shExSingleQuote,shExDoubleQuote,shSingleQuote,shDoubleQuote,shExpr,shDblBrace,shDeref,shDerefSimple,shCtrlSeq 156383f9bc3SBram Moolenaarsyn cluster shExprList2 contains=@shExprList1,@shCaseList,shTest 157d2855f54SBram Moolenaarsyn cluster shFunctionList contains=@shCommandSubList,shCaseEsac,shColon,shComment,shDo,shEcho,shExpr,shFor,shHereDoc,shIf,shOption,shHereString,shRedir,shSetList,shSource,shStatement,shVariable,shOperator,shCtrlSeq 1587263a77bSBram Moolenaarif exists("b:is_kornshell") || exists("b:is_bash") 15923515b4eSBram Moolenaar syn cluster shFunctionList add=shRepeat,shDblBrace,shDblParen,shForPP 1607263a77bSBram Moolenaarendif 161071d4279SBram Moolenaarsyn cluster shHereBeginList contains=@shCommandSubList 162071d4279SBram Moolenaarsyn cluster shHereList contains=shBeginHere,shHerePayload 163071d4279SBram Moolenaarsyn cluster shHereListDQ contains=shBeginHere,@shDblQuoteList,shHerePayload 164b730f0c7SBram Moolenaarsyn cluster shIdList contains=shCommandSub,shCommandSubBQ,shWrapLineOperator,shSetOption,shComment,shDeref,shDerefSimple,shHereString,shNumber,shOperator,shRedir,shExSingleQuote,shExDoubleQuote,shSingleQuote,shDoubleQuote,shExpr,shCtrlSeq,shStringSpecial,shAtExpr 165f37506f6SBram Moolenaarsyn cluster shIfList contains=@shLoopList,shDblBrace,shDblParen,shFunctionKey,shFunctionOne,shFunctionTwo 16623515b4eSBram Moolenaarsyn cluster shLoopList contains=@shCaseList,@shErrorList,shCaseEsac,shConditional,shDblBrace,shExpr,shFor,shIf,shOption,shSet,shTest,shTestOpr,shTouch 16723515b4eSBram Moolenaarif exists("b:is_kornshell") || exists("b:is_bash") 16823515b4eSBram Moolenaar syn cluster shLoopoList add=shForPP 16923515b4eSBram Moolenaarendif 1701d9215b9SBram Moolenaarsyn cluster shPPSLeftList contains=shAlias,shArithmetic,shCmdParenRegion,shCommandSub,shCtrlSeq,shDeref,shDerefSimple,shDoubleQuote,shEcho,shEscape,shExDoubleQuote,shExpr,shExSingleQuote,shHereDoc,shNumber,shOperator,shOption,shPosnParm,shHereString,shRedir,shSingleQuote,shSpecial,shStatement,shSubSh,shTest,shVariable 17191c4937bSBram Moolenaarsyn cluster shPPSRightList contains=shComment,shDeref,shDerefSimple,shEscape,shPosnParm 172d2855f54SBram Moolenaarsyn cluster shSubShList contains=@shCommandSubList,shCommandSubBQ,shCaseEsac,shColon,shCommandSub,shComment,shDo,shEcho,shExpr,shFor,shIf,shHereString,shRedir,shSetList,shSource,shStatement,shVariable,shCtrlSeq,shOperator 173b730f0c7SBram Moolenaarsyn cluster shTestList contains=shArithmetic,shCharClass,shCommandSub,shCommandSubBQ,shCtrlSeq,shDeref,shDerefSimple,shDoubleQuote,shSpecialDQ,shExDoubleQuote,shExpr,shExSingleQuote,shNumber,shOperator,shSingleQuote,shTest,shTestOpr 174b0d45e7fSBram Moolenaarsyn cluster shNoZSList contains=shSpecialNoZS 17593a1df2cSBram Moolenaarsyn cluster shForList contains=shTestOpr,shNumber,shDerefSimple,shDeref,shCommandSub,shCommandSubBQ,shArithmetic 176b4ff518dSBram Moolenaar 177d4755bb0SBram Moolenaar" Echo: {{{1 178071d4279SBram Moolenaar" ==== 179071d4279SBram Moolenaar" This one is needed INSIDE a CommandSub, so that `echo bla` be correct 1801d9215b9SBram Moolenaarsyn region shEcho matchgroup=shStatement start="\<echo\>" skip="\\$" matchgroup=shEchoDelim end="$" matchgroup=NONE end="[<>;&|()`]"me=e-1 end="\d[<>]"me=e-2 end="#"me=e-1 contains=@shEchoList skipwhite nextgroup=shQuickComment 1811d9215b9SBram Moolenaarsyn region shEcho matchgroup=shStatement start="\<print\>" skip="\\$" matchgroup=shEchoDelim end="$" matchgroup=NONE end="[<>;&|()`]"me=e-1 end="\d[<>]"me=e-2 end="#"me=e-1 contains=@shEchoList skipwhite nextgroup=shQuickComment 1825c73622aSBram Moolenaarsyn match shEchoQuote contained '\%(\\\\\)*\\["`'()]' 183071d4279SBram Moolenaar 184c236c16dSBram Moolenaar" This must be after the strings, so that ... \" will be correct 185e90ee31cSBram Moolenaarsyn region shEmbeddedEcho contained matchgroup=shStatement start="\<print\>" skip="\\$" matchgroup=shEchoDelim end="$" matchgroup=NONE end="[<>;&|`)]"me=e-1 end="\d[<>]"me=e-2 end="\s#"me=e-2 contains=shNumber,shExSingleQuote,shSingleQuote,shDeref,shDerefSimple,shSpecialVar,shOperator,shExDoubleQuote,shDoubleQuote,shCharClass,shCtrlSeq 186071d4279SBram Moolenaar 187d4755bb0SBram Moolenaar" Alias: {{{1 188071d4279SBram Moolenaar" ===== 18951ad4eaaSBram Moolenaarif exists("b:is_kornshell") || exists("b:is_bash") || exists("b:is_posix") 190071d4279SBram Moolenaar syn match shStatement "\<alias\>" 191d960d76dSBram Moolenaar syn region shAlias matchgroup=shStatement start="\<alias\>\s\+\(\h[-._[:alnum:]]\+\)\@=" skip="\\$" end="\>\|`" 192d960d76dSBram Moolenaar syn region shAlias matchgroup=shStatement start="\<alias\>\s\+\(\h[-._[:alnum:]]\+=\)\@=" skip="\\$" end="=" 193b4ff518dSBram Moolenaar 194b4ff518dSBram Moolenaar " Touch: {{{1 195b4ff518dSBram Moolenaar " ===== 1966d5ad4c4SBram Moolenaar syn match shTouch '\<touch\>[^;#]*' skipwhite nextgroup=shComment contains=shTouchCmd,shDoubleQuote,shSingleQuote,shDeref,shDerefSimple 197b4ff518dSBram Moolenaar syn match shTouchCmd '\<touch\>' contained 198071d4279SBram Moolenaarendif 199071d4279SBram Moolenaar 200d4755bb0SBram Moolenaar" Error Codes: {{{1 201d4755bb0SBram Moolenaar" ============ 2026be7f873SBram Moolenaarif !exists("g:sh_no_error") 203071d4279SBram Moolenaar syn match shDoError "\<done\>" 204071d4279SBram Moolenaar syn match shIfError "\<fi\>" 205071d4279SBram Moolenaar syn match shInError "\<in\>" 206071d4279SBram Moolenaar syn match shCaseError ";;" 207071d4279SBram Moolenaar syn match shEsacError "\<esac\>" 208071d4279SBram Moolenaar syn match shCurlyError "}" 209071d4279SBram Moolenaar syn match shParenError ")" 2105c73622aSBram Moolenaar syn match shOK '\.\(done\|fi\|in\|esac\)' 21151ad4eaaSBram Moolenaar if exists("b:is_kornshell") || exists("b:is_bash") 212071d4279SBram Moolenaar syn match shDTestError "]]" 213071d4279SBram Moolenaar endif 214071d4279SBram Moolenaar syn match shTestError "]" 2156be7f873SBram Moolenaarendif 216071d4279SBram Moolenaar 217c236c16dSBram Moolenaar" Options: {{{1 218d4755bb0SBram Moolenaar" ==================== 2197db8f6f4SBram Moolenaarsyn match shOption "\s\zs[-+][-_a-zA-Z#@]\+" 2201d9215b9SBram Moolenaarsyn match shOption "\s\zs--[^ \t$=`'"|);]\+" 221071d4279SBram Moolenaar 2227263a77bSBram Moolenaar" File Redirection Highlighted As Operators: {{{1 2237263a77bSBram Moolenaar"=========================================== 2247263a77bSBram Moolenaarsyn match shRedir "\d\=>\(&[-0-9]\)\=" 2257263a77bSBram Moolenaarsyn match shRedir "\d\=>>-\=" 2267263a77bSBram Moolenaarsyn match shRedir "\d\=<\(&[-0-9]\)\=" 2277263a77bSBram Moolenaarsyn match shRedir "\d<<-\=" 2287263a77bSBram Moolenaar 229d4755bb0SBram Moolenaar" Operators: {{{1 230d4755bb0SBram Moolenaar" ========== 2317263a77bSBram Moolenaarsyn match shOperator "<<\|>>" contained 232c236c16dSBram Moolenaarsyn match shOperator "[!&;|]" contained 233c236c16dSBram Moolenaarsyn match shOperator "\[[[^:]\|\]]" contained 234541f92d6SBram Moolenaarsyn match shOperator "[-=/*+%]\==" skipwhite nextgroup=shPattern 235e90ee31cSBram Moolenaarsyn match shPattern "\<\S\+\())\)\@=" contained contains=shExSingleQuote,shSingleQuote,shExDoubleQuote,shDoubleQuote,shDeref 236071d4279SBram Moolenaar 237d4755bb0SBram Moolenaar" Subshells: {{{1 238d4755bb0SBram Moolenaar" ========== 239e4a3bcf2SBram Moolenaarsyn region shExpr transparent matchgroup=shExprRegion start="{" end="}" contains=@shExprList2 nextgroup=shSpecialNxt 240e4a3bcf2SBram Moolenaarsyn region shSubSh transparent matchgroup=shSubShRegion start="[^(]\zs(" end=")" contains=@shSubShList nextgroup=shSpecialNxt 241071d4279SBram Moolenaar 242d4755bb0SBram Moolenaar" Tests: {{{1 243d4755bb0SBram Moolenaar"======= 24400a927d6SBram Moolenaarsyn region shExpr matchgroup=shRange start="\[" skip=+\\\\\|\\$\|\[+ end="\]" contains=@shTestList,shSpecial 2455c73622aSBram Moolenaarsyn region shTest transparent matchgroup=shStatement start="\<test\s" skip=+\\\\\|\\$+ matchgroup=NONE end="[;&|]"me=e-1 end="$" contains=@shExprList1 246b0d45e7fSBram Moolenaarsyn region shNoQuote start='\S' skip='\%(\\\\\)*\\.' end='\ze\s' end="\ze['"]" contained contains=shDerefSimple,shDeref 24791c4937bSBram Moolenaarsyn match shAstQuote contained '\*\ze"' nextgroup=shString 248541f92d6SBram Moolenaarsyn match shTestOpr contained '[^-+/%]\zs=' skipwhite nextgroup=shTestDoubleQuote,shTestSingleQuote,shTestPattern 249b4ff518dSBram Moolenaarsyn match shTestOpr contained "<=\|>=\|!=\|==\|=\~\|-.\>\|-\(nt\|ot\|ef\|eq\|ne\|lt\|le\|gt\|ge\)\>\|[!<>]" 2509964e468SBram Moolenaarsyn match shTestPattern contained '\w\+' 25191c4937bSBram Moolenaarsyn region shTestDoubleQuote contained start='\%(\%(\\\\\)*\\\)\@<!"' skip=+\\\\\|\\"+ end='"' contains=shDeref,shDerefSimple,shDerefSpecial 252b0d45e7fSBram Moolenaarsyn match shTestSingleQuote contained '\\.' nextgroup=shTestSingleQuote 2539964e468SBram Moolenaarsyn match shTestSingleQuote contained "'[^']*'" 254071d4279SBram Moolenaarif exists("b:is_kornshell") || exists("b:is_bash") 25591c4937bSBram Moolenaar syn region shDblBrace matchgroup=Delimiter start="\[\[" skip=+\%(\\\\\)*\\$+ end="\]\]" contains=@shTestList,shAstQuote,shNoQuote,shComment 256b4ff518dSBram Moolenaar syn region shDblParen matchgroup=Delimiter start="((" skip=+\%(\\\\\)*\\$+ end="))" contains=@shTestList,shComment 257071d4279SBram Moolenaarendif 258071d4279SBram Moolenaar 259d4755bb0SBram Moolenaar" Character Class In Range: {{{1 260d4755bb0SBram Moolenaar" ========================= 261071d4279SBram Moolenaarsyn match shCharClass contained "\[:\(backspace\|escape\|return\|xdigit\|alnum\|alpha\|blank\|cntrl\|digit\|graph\|lower\|print\|punct\|space\|upper\|tab\):\]" 262071d4279SBram Moolenaar 263d4755bb0SBram Moolenaar" Loops: do, if, while, until {{{1 264d4755bb0SBram Moolenaar" ====== 265b4ff518dSBram MoolenaarShFoldIfDoFor syn region shDo transparent matchgroup=shConditional start="\<do\>" matchgroup=shConditional end="\<done\>" contains=@shLoopList 266b4ff518dSBram MoolenaarShFoldIfDoFor syn region shIf transparent matchgroup=shConditional start="\<if\_s" matchgroup=shConditional skip=+-fi\>+ end="\<;\_s*then\>" end="\<fi\>" contains=@shIfList 267b4ff518dSBram MoolenaarShFoldIfDoFor syn region shFor matchgroup=shLoop start="\<for\ze\_s\s*\%(((\)\@!" end="\<in\>" end="\<do\>"me=e-2 contains=@shLoopList,shDblParen skipwhite nextgroup=shCurlyIn 26823515b4eSBram Moolenaarif exists("b:is_kornshell") || exists("b:is_bash") 26993a1df2cSBram Moolenaar ShFoldIfDoFor syn region shForPP matchgroup=shLoop start='\<for\>\_s*((' end='))' contains=@shForList 27023515b4eSBram Moolenaarendif 271b4ff518dSBram Moolenaar 27251ad4eaaSBram Moolenaarif exists("b:is_kornshell") || exists("b:is_bash") || exists("b:is_posix") 273071d4279SBram Moolenaar syn cluster shCaseList add=shRepeat 274c236c16dSBram Moolenaar syn cluster shFunctionList add=shRepeat 27551ad4eaaSBram Moolenaar syn region shRepeat matchgroup=shLoop start="\<while\_s" end="\<do\>"me=e-2 contains=@shLoopList,shDblParen,shDblBrace 27651ad4eaaSBram Moolenaar syn region shRepeat matchgroup=shLoop start="\<until\_s" end="\<do\>"me=e-2 contains=@shLoopList,shDblParen,shDblBrace 27751ad4eaaSBram Moolenaar if !exists("b:is_posix") 278c236c16dSBram Moolenaar syn region shCaseEsac matchgroup=shConditional start="\<select\s" matchgroup=shConditional end="\<in\>" end="\<do\>" contains=@shLoopList 27951ad4eaaSBram Moolenaar endif 280071d4279SBram Moolenaarelse 281c236c16dSBram Moolenaar syn region shRepeat matchgroup=shLoop start="\<while\_s" end="\<do\>"me=e-2 contains=@shLoopList 282c236c16dSBram Moolenaar syn region shRepeat matchgroup=shLoop start="\<until\_s" end="\<do\>"me=e-2 contains=@shLoopList 283071d4279SBram Moolenaarendif 284572cb561SBram Moolenaarsyn region shCurlyIn contained matchgroup=Delimiter start="{" end="}" contains=@shCurlyList 285572cb561SBram Moolenaarsyn match shComma contained "," 286071d4279SBram Moolenaar 287d4755bb0SBram Moolenaar" Case: case...esac {{{1 288071d4279SBram Moolenaar" ==== 289c236c16dSBram Moolenaarsyn match shCaseBar contained skipwhite "\(^\|[^\\]\)\(\\\\\)*\zs|" nextgroup=shCase,shCaseStart,shCaseBar,shComment,shCaseExSingleQuote,shCaseSingleQuote,shCaseDoubleQuote 290071d4279SBram Moolenaarsyn match shCaseStart contained skipwhite skipnl "(" nextgroup=shCase,shCaseBar 291d2855f54SBram Moolenaarsyn match shCaseLabel contained skipwhite "\%(\\.\|[-a-zA-Z0-9_*.]\)\+" contains=shCharClass 292b0d45e7fSBram Moolenaarif exists("b:is_bash") 293b0d45e7fSBram Moolenaar ShFoldIfDoFor syn region shCase contained skipwhite skipnl matchgroup=shSnglCase start="\%(\\.\|[^#$()'" \t]\)\{-}\zs)" end=";;" end=";&" end=";;&" end="esac"me=s-1 contains=@shCaseList nextgroup=shCaseStart,shCase,shComment 294b0d45e7fSBram Moolenaarelse 295b4ff518dSBram Moolenaar ShFoldIfDoFor syn region shCase contained skipwhite skipnl matchgroup=shSnglCase start="\%(\\.\|[^#$()'" \t]\)\{-}\zs)" end=";;" end="esac"me=s-1 contains=@shCaseList nextgroup=shCaseStart,shCase,shComment 296b0d45e7fSBram Moolenaarendif 297b4ff518dSBram MoolenaarShFoldIfDoFor syn region shCaseEsac matchgroup=shConditional start="\<case\>" end="\<esac\>" contains=@shCaseEsacList 298b4ff518dSBram Moolenaar 299df177f67SBram Moolenaarsyn keyword shCaseIn contained skipwhite skipnl in nextgroup=shCase,shCaseStart,shCaseBar,shComment,shCaseExSingleQuote,shCaseSingleQuote,shCaseDoubleQuote 300df177f67SBram Moolenaarif exists("b:is_bash") 3014b22cdb0SBram Moolenaar syn region shCaseExSingleQuote matchgroup=shQuote start=+\$'+ skip=+\\\\\|\\.+ end=+'+ contains=shStringSpecial,shSpecial skipwhite skipnl nextgroup=shCaseBar contained 3026be7f873SBram Moolenaarelseif !exists("g:sh_no_error") 303df177f67SBram Moolenaar syn region shCaseExSingleQuote matchgroup=Error start=+\$'+ skip=+\\\\\|\\.+ end=+'+ contains=shStringSpecial skipwhite skipnl nextgroup=shCaseBar contained 304df177f67SBram Moolenaarendif 3054b22cdb0SBram Moolenaarsyn region shCaseSingleQuote matchgroup=shQuote start=+'+ end=+'+ contains=shStringSpecial skipwhite skipnl nextgroup=shCaseBar contained 3064b22cdb0SBram Moolenaarsyn region shCaseDoubleQuote matchgroup=shQuote start=+"+ skip=+\\\\\|\\.+ end=+"+ contains=@shDblQuoteList,shStringSpecial skipwhite skipnl nextgroup=shCaseBar contained 307071d4279SBram Moolenaarsyn region shCaseCommandSub start=+`+ skip=+\\\\\|\\.+ end=+`+ contains=@shCommandSubList skipwhite skipnl nextgroup=shCaseBar contained 30897d62497SBram Moolenaarif exists("b:is_bash") 30997d62497SBram Moolenaar syn region shCaseRange matchgroup=Delimiter start=+\[+ skip=+\\\\+ end=+\]+ contained contains=shCharClass 31097d62497SBram Moolenaar syn match shCharClass '\[:\%(alnum\|alpha\|ascii\|blank\|cntrl\|digit\|graph\|lower\|print\|punct\|space\|upper\|word\|or\|xdigit\):\]' contained 31197d62497SBram Moolenaarelse 31297d62497SBram Moolenaar syn region shCaseRange matchgroup=Delimiter start=+\[+ skip=+\\\\+ end=+\]+ contained 31397d62497SBram Moolenaarendif 314d4755bb0SBram Moolenaar" Misc: {{{1 315d4755bb0SBram Moolenaar"====== 316071d4279SBram Moolenaarsyn match shWrapLineOperator "\\$" 31793a1df2cSBram Moolenaarsyn region shCommandSubBQ start="`" skip="\\\\\|\\." end="`" contains=shBQComment,@shCommandSubList 3181d9215b9SBram Moolenaar"COMBAK: see ksh13:50 319b730f0c7SBram Moolenaar"syn match shEscape contained '\%(^\)\@!\%(\\\\\)*\\.' nextgroup=shSingleQuote,shDoubleQuote,shComment 3201d9215b9SBram Moolenaar"COMBAK: see sh11:27 321b730f0c7SBram Moolenaarsyn match shEscape contained '\%(^\)\@!\%(\\\\\)*\\.' nextgroup=shComment 3221d9215b9SBram Moolenaar"COMBAK: see ksh13:53 3231d9215b9SBram Moolenaar"syn match shEscape contained '\%(^\)\@!\%(\\\\\)*\\.' 324071d4279SBram Moolenaar 325d4755bb0SBram Moolenaar" $() and $(()): {{{1 326071d4279SBram Moolenaar" $(..) is not supported by sh (Bourne shell). However, apparently 327071d4279SBram Moolenaar" some systems (HP?) have as their /bin/sh a (link to) Korn shell 328071d4279SBram Moolenaar" (ie. Posix compliant shell). /bin/ksh should work for those 329071d4279SBram Moolenaar" systems too, however, so the following syntax will flag $(..) as 330071d4279SBram Moolenaar" an Error under /bin/sh. By consensus of vimdev'ers! 331b0d45e7fSBram Moolenaarif exists("b:is_kornshell") || exists("b:is_bash") || exists("b:is_posix") 332071d4279SBram Moolenaar syn region shCommandSub matchgroup=shCmdSubRegion start="\$(" skip='\\\\\|\\.' end=")" contains=@shCommandSubList 333c236c16dSBram Moolenaar syn region shArithmetic matchgroup=shArithRegion start="\$((" skip='\\\\\|\\.' end="))" contains=@shArithList 33461d35bd0SBram Moolenaar syn region shArithmetic matchgroup=shArithRegion start="\$\[" skip='\\\\\|\\.' end="\]" contains=@shArithList 335071d4279SBram Moolenaar syn match shSkipInitWS contained "^\s\+" 3366be7f873SBram Moolenaarelseif !exists("g:sh_no_error") 337df177f67SBram Moolenaar syn region shCommandSub matchgroup=Error start="\$(" end=")" contains=@shCommandSubList 338071d4279SBram Moolenaarendif 339e2719096SBram Moolenaarsyn region shCmdParenRegion matchgroup=shCmdSubRegion start="(\ze[^(]" skip='\\\\\|\\.' end=")" contains=@shCommandSubList 340071d4279SBram Moolenaar 341071d4279SBram Moolenaarif exists("b:is_bash") 342071d4279SBram Moolenaar syn cluster shCommandSubList add=bashSpecialVariables,bashStatement 343071d4279SBram Moolenaar syn cluster shCaseList add=bashAdminStatement,bashStatement 344d960d76dSBram Moolenaar syn keyword bashSpecialVariables contained auto_resume BASH BASH_ALIASES BASH_ALIASES BASH_ARGC BASH_ARGC BASH_ARGV BASH_ARGV BASH_CMDS BASH_CMDS BASH_COMMAND BASH_COMMAND BASH_ENV BASH_EXECUTION_STRING BASH_EXECUTION_STRING BASH_LINENO BASH_LINENO BASHOPTS BASHOPTS BASHPID BASHPID BASH_REMATCH BASH_REMATCH BASH_SOURCE BASH_SOURCE BASH_SUBSHELL BASH_SUBSHELL BASH_VERSINFO BASH_VERSION BASH_XTRACEFD BASH_XTRACEFD CDPATH COLUMNS COLUMNS COMP_CWORD COMP_CWORD COMP_KEY COMP_KEY COMP_LINE COMP_LINE COMP_POINT COMP_POINT COMPREPLY COMPREPLY COMP_TYPE COMP_TYPE COMP_WORDBREAKS COMP_WORDBREAKS COMP_WORDS COMP_WORDS COPROC COPROC DIRSTACK EMACS EMACS ENV ENV EUID FCEDIT FIGNORE FUNCNAME FUNCNAME FUNCNEST FUNCNEST GLOBIGNORE GROUPS histchars HISTCMD HISTCONTROL HISTFILE HISTFILESIZE HISTIGNORE HISTSIZE HISTTIMEFORMAT HISTTIMEFORMAT HOME HOSTFILE HOSTNAME HOSTTYPE IFS IGNOREEOF INPUTRC LANG LC_ALL LC_COLLATE LC_CTYPE LC_CTYPE LC_MESSAGES LC_NUMERIC LC_NUMERIC LINENO LINES LINES MACHTYPE MAIL MAILCHECK MAILPATH MAPFILE MAPFILE OLDPWD OPTARG OPTERR OPTIND OSTYPE PATH PIPESTATUS POSIXLY_CORRECT POSIXLY_CORRECT PPID PROMPT_COMMAND PS1 PS2 PS3 PS4 PWD RANDOM READLINE_LINE READLINE_LINE READLINE_POINT READLINE_POINT REPLY SECONDS SHELL SHELL SHELLOPTS SHLVL TIMEFORMAT TIMEOUT TMPDIR TMPDIR UID 345b4ff518dSBram Moolenaar syn keyword bashStatement chmod clear complete du egrep expr fgrep find gnufind gnugrep grep less ls mkdir mv rm rmdir rpm sed sleep sort strip tail 346071d4279SBram Moolenaar syn keyword bashAdminStatement daemon killall killproc nice reload restart start status stop 34797d62497SBram Moolenaar syn keyword bashStatement command compgen 348071d4279SBram Moolenaarendif 349071d4279SBram Moolenaar 35051ad4eaaSBram Moolenaarif exists("b:is_kornshell") || exists("b:is_posix") 351071d4279SBram Moolenaar syn cluster shCommandSubList add=kshSpecialVariables,kshStatement 352071d4279SBram Moolenaar syn cluster shCaseList add=kshStatement 353071d4279SBram Moolenaar syn keyword kshSpecialVariables contained CDPATH COLUMNS EDITOR ENV ERRNO FCEDIT FPATH HISTFILE HISTSIZE HOME IFS LINENO LINES MAIL MAILCHECK MAILPATH OLDPWD OPTARG OPTIND PATH PPID PS1 PS2 PS3 PS4 PWD RANDOM REPLY SECONDS SHELL TMOUT VISUAL 354b4ff518dSBram Moolenaar syn keyword kshStatement cat chmod clear cp du egrep expr fgrep find grep killall less ls mkdir mv nice printenv rm rmdir sed sort strip stty tail tput 35597d62497SBram Moolenaar syn keyword kshStatement command setgroups setsenv 356071d4279SBram Moolenaarendif 357071d4279SBram Moolenaar 358071d4279SBram Moolenaarsyn match shSource "^\.\s" 359071d4279SBram Moolenaarsyn match shSource "\s\.\s" 3605c73622aSBram Moolenaar"syn region shColon start="^\s*:" end="$" end="\s#"me=e-2 contains=@shColonList 3616be7f873SBram Moolenaar"syn region shColon start="^\s*\zs:" end="$" end="\s#"me=e-2 36251ad4eaaSBram Moolenaarif exists("b:is_kornshell") || exists("b:is_posix") 3636be7f873SBram Moolenaar syn match shColon '^\s*\zs:' 36491c4937bSBram Moolenaarendif 365071d4279SBram Moolenaar 366d4755bb0SBram Moolenaar" String And Character Constants: {{{1 367d4755bb0SBram Moolenaar"================================ 3687db8f6f4SBram Moolenaarsyn match shNumber "\<\d\+\>#\=" 369bc8801c9SBram Moolenaarsyn match shNumber "\<-\=\.\=\d\+\>#\=" 3709964e468SBram Moolenaarsyn match shCtrlSeq "\\\d\d\d\|\\[abcfnrtv0]" contained 371df177f67SBram Moolenaarif exists("b:is_bash") 372802a0d90SBram Moolenaar syn match shSpecial "[^\\]\(\\\\\)*\zs\\\o\o\o\|\\x\x\x\|\\c[^"]\|\\[abefnrtv]" contained 373802a0d90SBram Moolenaar syn match shSpecial "^\(\\\\\)*\zs\\\o\o\o\|\\x\x\x\|\\c[^"]\|\\[abefnrtv]" contained 374e4a3bcf2SBram Moolenaar syn region shExSingleQuote matchgroup=shQuote start=+\$'+ skip=+\\\\\|\\.+ end=+'+ contains=shStringSpecial,shSpecial nextgroup=shSpecialNxt 375e4a3bcf2SBram Moolenaar syn region shExDoubleQuote matchgroup=shQuote start=+\$"+ skip=+\\\\\|\\.\|\\"+ end=+"+ contains=@shDblQuoteList,shStringSpecial,shSpecial nextgroup=shSpecialNxt 3766be7f873SBram Moolenaarelseif !exists("g:sh_no_error") 3779964e468SBram Moolenaar syn region shExSingleQuote matchGroup=Error start=+\$'+ skip=+\\\\\|\\.+ end=+'+ contains=shStringSpecial 378e90ee31cSBram Moolenaar syn region shExDoubleQuote matchGroup=Error start=+\$"+ skip=+\\\\\|\\.+ end=+"+ contains=shStringSpecial 379df177f67SBram Moolenaarendif 380d2855f54SBram Moolenaarsyn region shSingleQuote matchgroup=shQuote start=+'+ end=+'+ contains=@Spell nextgroup=shSpecialStart,shSpecialSQ 38147e13953SBram Moolenaarsyn region shDoubleQuote matchgroup=shQuote start=+\%(\%(\\\\\)*\\\)\@<!"+ skip=+\\.+ end=+"+ contains=@shDblQuoteList,shStringSpecial,@Spell nextgroup=shSpecialStart 382e37d50a5SBram Moolenaarsyn match shStringSpecial "[^[:print:] \t]" contained 383d2ea7cf1SBram Moolenaarsyn match shStringSpecial "[^\\]\zs\%(\\\\\)*\(\\[\\"'`$()#]\)\+" nextgroup=shComment 384d2ea7cf1SBram Moolenaarsyn match shSpecialSQ "[^\\]\zs\%(\\\\\)*\(\\[\\"'`$()#]\)\+" contained nextgroup=shBkslshSnglQuote,@shNoZSList 385d2ea7cf1SBram Moolenaarsyn match shSpecialDQ "[^\\]\zs\%(\\\\\)*\(\\[\\"'`$()#]\)\+" contained nextgroup=shBkslshDblQuote,@shNoZSList 38651ad4eaaSBram Moolenaarsyn match shSpecialStart "\%(\\\\\)*\\[\\"'`$()#]" contained nextgroup=shBkslshSnglQuote,shBkslshDblQuote,@shNoZSList 38760cce2fbSBram Moolenaarsyn match shSpecial "^\%(\\\\\)*\\[\\"'`$()#]" 388b0d45e7fSBram Moolenaarsyn match shSpecialNoZS contained "\%(\\\\\)*\\[\\"'`$()#]" 389e4a3bcf2SBram Moolenaarsyn match shSpecialNxt contained "\\[\\"'`$()#]" 39047e13953SBram Moolenaar"syn region shBkslshSnglQuote contained matchgroup=shQuote start=+'+ end=+'+ contains=@Spell nextgroup=shSpecialStart 39147e13953SBram Moolenaar"syn region shBkslshDblQuote contained matchgroup=shQuote start=+"+ skip=+\\"+ end=+"+ contains=@shDblQuoteList,shStringSpecial,@Spell nextgroup=shSpecialStart 392071d4279SBram Moolenaar 393d4755bb0SBram Moolenaar" Comments: {{{1 394d4755bb0SBram Moolenaar"========== 395071d4279SBram Moolenaarsyn cluster shCommentGroup contains=shTodo,@Spell 3966d5ad4c4SBram Moolenaarif exists("b:is_bash") 3976d5ad4c4SBram Moolenaar syn match shTodo contained "\<\%(COMBAK\|FIXME\|TODO\|XXX\)\ze:\=\>" 3986d5ad4c4SBram Moolenaarelse 39918144c84SBram Moolenaar syn keyword shTodo contained COMBAK FIXME TODO XXX 4006d5ad4c4SBram Moolenaarendif 4017263a77bSBram Moolenaarsyn match shComment "^\s*\zs#.*$" contains=@shCommentGroup 402c236c16dSBram Moolenaarsyn match shComment "\s\zs#.*$" contains=@shCommentGroup 40397d62497SBram Moolenaarsyn match shComment contained "#.*$" contains=@shCommentGroup 404*113cb513SBram Moolenaarsyn match shQuickComment contained "#.*$" contains=@shCommentGroup 40593a1df2cSBram Moolenaarsyn match shBQComment contained "#.\{-}\ze`" contains=@shCommentGroup 406071d4279SBram Moolenaar 407d4755bb0SBram Moolenaar" Here Documents: {{{1 408d2ea7cf1SBram Moolenaar" (modified by Felipe Contreras) 409d4755bb0SBram Moolenaar" ========================================= 41023515b4eSBram MoolenaarShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc01 start="<<\s*\z([^ \t|>]\+\)" matchgroup=shHereDoc01 end="^\z1\s*$" contains=@shDblQuoteList 41123515b4eSBram MoolenaarShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc02 start="<<-\s*\z([^ \t|>]\+\)" matchgroup=shHereDoc02 end="^\s*\z1\s*$" contains=@shDblQuoteList 41223515b4eSBram MoolenaarShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc03 start="<<\s*\\\z([^ \t|>]\+\)" matchgroup=shHereDoc03 end="^\z1\s*$" 41323515b4eSBram MoolenaarShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc04 start="<<-\s*\\\z([^ \t|>]\+\)" matchgroup=shHereDoc04 end="^\s*\z1\s*$" 414d2855f54SBram MoolenaarShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc05 start="<<\s*'\z([^']\+\)'" matchgroup=shHereDoc05 end="^\z1\s*$" 41523515b4eSBram MoolenaarShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc06 start="<<-\s*'\z([^']\+\)'" matchgroup=shHereDoc06 end="^\s*\z1\s*$" 41623515b4eSBram MoolenaarShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc07 start="<<\s*\"\z([^"]\+\)\"" matchgroup=shHereDoc07 end="^\z1\s*$" 41723515b4eSBram MoolenaarShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc08 start="<<-\s*\"\z([^"]\+\)\"" matchgroup=shHereDoc08 end="^\s*\z1\s*$" 41823515b4eSBram MoolenaarShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc09 start="<<\s*\\\_$\_s*\z([^ \t|>]\+\)" matchgroup=shHereDoc09 end="^\z1\s*$" contains=@shDblQuoteList 41923515b4eSBram MoolenaarShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc10 start="<<-\s*\\\_$\_s*\z([^ \t|>]\+\)" matchgroup=shHereDoc10 end="^\s*\z1\s*$" contains=@shDblQuoteList 42023515b4eSBram MoolenaarShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc11 start="<<\s*\\\_$\_s*\\\z([^ \t|>]\+\)" matchgroup=shHereDoc11 end="^\z1\s*$" 42123515b4eSBram MoolenaarShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc12 start="<<-\s*\\\_$\_s*\\\z([^ \t|>]\+\)" matchgroup=shHereDoc12 end="^\s*\z1\s*$" 42223515b4eSBram MoolenaarShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc13 start="<<\s*\\\_$\_s*'\z([^']\+\)'" matchgroup=shHereDoc13 end="^\z1\s*$" 42323515b4eSBram MoolenaarShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc14 start="<<-\s*\\\_$\_s*'\z([^']\+\)'" matchgroup=shHereDoc14 end="^\s*\z1\s*$" 42423515b4eSBram MoolenaarShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc15 start="<<\s*\\\_$\_s*\"\z([^"]\+\)\"" matchgroup=shHereDoc15 end="^\z1\s*$" 42523515b4eSBram MoolenaarShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc16 start="<<-\s*\\\_$\_s*\"\z([^"]\+\)\"" matchgroup=shHereDoc16 end="^\s*\z1\s*$" 42623515b4eSBram Moolenaar 427d4755bb0SBram Moolenaar 428d4755bb0SBram Moolenaar" Here Strings: {{{1 429d4755bb0SBram Moolenaar" ============= 4306d5ad4c4SBram Moolenaar" available for: bash; ksh (really should be ksh93 only) but not if its a posix 431690afe1fSBram Moolenaarif exists("b:is_bash") || (exists("b:is_kornshell") && !exists("b:is_posix")) 432e4a3bcf2SBram Moolenaar syn match shHereString "<<<" skipwhite nextgroup=shCmdParenRegion 433071d4279SBram Moolenaarendif 434071d4279SBram Moolenaar 435d4755bb0SBram Moolenaar" Identifiers: {{{1 436d4755bb0SBram Moolenaar"============= 437c236c16dSBram Moolenaarsyn match shSetOption "\s\zs[-+][a-zA-Z0-9]\+\>" contained 43823515b4eSBram Moolenaarsyn match shVariable "\<\h\w*\ze=" nextgroup=shVarAssign 439b730f0c7SBram Moolenaarsyn match shVarAssign "=" contained nextgroup=shCmdParenRegion,shPattern,shDeref,shDerefSimple,shDoubleQuote,shExDoubleQuote,shSingleQuote,shExSingleQuote,shVar 440b730f0c7SBram Moolenaarsyn match shVar contained "\h\w*" 441bc488a76SBram Moolenaarsyn region shAtExpr contained start="@(" end=")" contains=@shIdList 442071d4279SBram Moolenaarif exists("b:is_bash") 443b730f0c7SBram Moolenaar syn match shSet "^\s*set\ze\s\+$" 444b730f0c7SBram Moolenaar syn region shSetList oneline matchgroup=shSet start="\<\%(declare\|local\|export\)\>\ze[/a-zA-Z_]\@!" end="$" matchgroup=shSetListDelim end="\ze[}|);&]" matchgroup=NONE end="\ze\s\+#\|=" contains=@shIdList 445b730f0c7SBram Moolenaar syn region shSetList oneline matchgroup=shSet start="\<\%(set\|unset\)\>[/a-zA-Z_]\@!" end="\ze[;|#)]\|$" matchgroup=shSetListDelim end="\ze[}|);&]" matchgroup=NONE end="\ze\s\+=" contains=@shIdList nextgroup=shComment 44651ad4eaaSBram Moolenaarelseif exists("b:is_kornshell") || exists("b:is_posix") 447b730f0c7SBram Moolenaar syn match shSet "^\s*set\ze\s\+$" 448d58a3bf7SBram Moolenaar if exists("b:is_dash") 449d58a3bf7SBram Moolenaar syn region shSetList oneline matchgroup=shSet start="\<\%(local\)\>\ze[/]\@!" end="$" matchgroup=shSetListDelim end="\ze[}|);&]" matchgroup=NONE end="\ze\s\+[#=]" contains=@shIdList 450d58a3bf7SBram Moolenaar endif 451b730f0c7SBram Moolenaar syn region shSetList oneline matchgroup=shSet start="\<\(export\)\>\ze[/]\@!" end="$" matchgroup=shSetListDelim end="\ze[}|);&]" matchgroup=NONE end="\ze\s\+[#=]" contains=@shIdList 452b730f0c7SBram Moolenaar syn region shSetList oneline matchgroup=shSet start="\<\%(set\|unset\>\)\ze[/a-zA-Z_]\@!" end="\ze[;|#)]\|$" matchgroup=shSetListDelim end="\ze[}|);&]" matchgroup=NONE end="\ze\s\+[#=]" contains=@shIdList nextgroup=shComment 453071d4279SBram Moolenaarelse 454b730f0c7SBram Moolenaar syn region shSetList oneline matchgroup=shSet start="\<\(set\|export\|unset\)\>\ze[/a-zA-Z_]\@!" end="\ze[;|#)]\|$" matchgroup=shSetListDelim end="\ze[}|);&]" matchgroup=NONE end="\ze\s\+[#=]" contains=@shIdList 455071d4279SBram Moolenaarendif 456071d4279SBram Moolenaar 457d4755bb0SBram Moolenaar" Functions: {{{1 458690afe1fSBram Moolenaarif !exists("b:is_posix") 459cd71fa3cSBram Moolenaar syn keyword shFunctionKey function skipwhite skipnl nextgroup=shFunctionTwo 460c236c16dSBram Moolenaarendif 461c236c16dSBram Moolenaar 462c236c16dSBram Moolenaarif exists("b:is_bash") 46391c4937bSBram Moolenaar ShFoldFunctions syn region shFunctionOne matchgroup=shFunction start="^\s*[A-Za-z_0-9:][-a-zA-Z_0-9:]*\s*()\_s*{" end="}" contains=@shFunctionList skipwhite skipnl nextgroup=shFunctionStart,shQuickComment 46491c4937bSBram Moolenaar ShFoldFunctions syn region shFunctionTwo matchgroup=shFunction start="\%(do\)\@!\&\<[A-Za-z_0-9:][-a-zA-Z_0-9:]*\>\s*\%(()\)\=\_s*{" end="}" contains=shFunctionKey,@shFunctionList contained skipwhite skipnl nextgroup=shFunctionStart,shQuickComment 46591c4937bSBram Moolenaar ShFoldFunctions syn region shFunctionThree matchgroup=shFunction start="^\s*[A-Za-z_0-9:][-a-zA-Z_0-9:]*\s*()\_s*(" end=")" contains=@shFunctionList skipwhite skipnl nextgroup=shFunctionStart,shQuickComment 46691c4937bSBram Moolenaar ShFoldFunctions syn region shFunctionFour matchgroup=shFunction start="\%(do\)\@!\&\<[A-Za-z_0-9:][-a-zA-Z_0-9:]*\>\s*\%(()\)\=\_s*)" end=")" contains=shFunctionKey,@shFunctionList contained skipwhite skipnl nextgroup=shFunctionStart,shQuickComment 467071d4279SBram Moolenaarelse 468b4ff518dSBram Moolenaar ShFoldFunctions syn region shFunctionOne matchgroup=shFunction start="^\s*\h\w*\s*()\_s*{" end="}" contains=@shFunctionList skipwhite skipnl nextgroup=shFunctionStart,shQuickComment 46991c4937bSBram Moolenaar ShFoldFunctions syn region shFunctionTwo matchgroup=shFunction start="\%(do\)\@!\&\<\h\w*\>\s*\%(()\)\=\_s*{" end="}" contains=shFunctionKey,@shFunctionList contained skipwhite skipnl nextgroup=shFunctionStart,shQuickComment 470b4ff518dSBram Moolenaar ShFoldFunctions syn region shFunctionThree matchgroup=shFunction start="^\s*\h\w*\s*()\_s*(" end=")" contains=@shFunctionList skipwhite skipnl nextgroup=shFunctionStart,shQuickComment 47191c4937bSBram Moolenaar ShFoldFunctions syn region shFunctionFour matchgroup=shFunction start="\%(do\)\@!\&\<\h\w*\>\s*\%(()\)\=\_s*(" end=")" contains=shFunctionKey,@shFunctionList contained skipwhite skipnl nextgroup=shFunctionStart,shQuickComment 472071d4279SBram Moolenaarendif 473071d4279SBram Moolenaar 474d4755bb0SBram Moolenaar" Parameter Dereferencing: {{{1 475d4755bb0SBram Moolenaar" ======================== 4766be7f873SBram Moolenaarif !exists("g:sh_no_error") 47791c4937bSBram Moolenaar syn match shDerefWordError "[^}$[~]" contained 4786be7f873SBram Moolenaarendif 479b0d45e7fSBram Moolenaarsyn match shDerefSimple "\$\%(\h\w*\|\d\)" nextgroup=@shNoZSList 48047e13953SBram Moolenaarsyn region shDeref matchgroup=PreProc start="\${" end="}" contains=@shDerefList,shDerefVarArray nextgroup=shSpecialStart 481b0d45e7fSBram Moolenaarsyn match shDerefSimple "\$[-#*@!?]" nextgroup=@shNoZSList 482b0d45e7fSBram Moolenaarsyn match shDerefSimple "\$\$" nextgroup=@shNoZSList 48347e13953SBram Moolenaarsyn match shDerefSimple "\${\d}" nextgroup=@shNoZSList nextgroup=shSpecialStart 48451ad4eaaSBram Moolenaarif exists("b:is_bash") || exists("b:is_kornshell") || exists("b:is_posix") 48547e13953SBram Moolenaar syn region shDeref matchgroup=PreProc start="\${##\=" end="}" contains=@shDerefList nextgroup=@shSpecialNoZS,shSpecialStart 48647e13953SBram Moolenaar syn region shDeref matchgroup=PreProc start="\${\$\$" end="}" contains=@shDerefList nextgroup=@shSpecialNoZS,shSpecialStart 487071d4279SBram Moolenaarendif 488071d4279SBram Moolenaar 489b4ff518dSBram Moolenaar" ksh: ${!var[*]} array index list syntax: {{{1 490b4ff518dSBram Moolenaar" ======================================== 49151ad4eaaSBram Moolenaarif exists("b:is_kornshell") || exists("b:is_posix") 492b4ff518dSBram Moolenaar syn region shDeref matchgroup=PreProc start="\${!" end="}" contains=@shDerefVarArray 493b4ff518dSBram Moolenaarendif 494b4ff518dSBram Moolenaar 495d4755bb0SBram Moolenaar" bash: ${!prefix*} and ${#parameter}: {{{1 496d4755bb0SBram Moolenaar" ==================================== 497071d4279SBram Moolenaarif exists("b:is_bash") 498d58a3bf7SBram Moolenaar syn region shDeref matchgroup=PreProc start="\${!" end="\*\=}" contains=@shDerefList,shDerefOffset 499bc8801c9SBram Moolenaar syn match shDerefVar contained "{\@<=!\h\w*" nextgroup=@shDerefVarList 500071d4279SBram Moolenaarendif 501b4ff518dSBram Moolenaarif exists("b:is_kornshell") 502bc8801c9SBram Moolenaar syn match shDerefVar contained "{\@<=!\h\w*[[:alnum:]_.]*" nextgroup=@shDerefVarList 503b4ff518dSBram Moolenaarendif 504071d4279SBram Moolenaar 505d58a3bf7SBram Moolenaarsyn match shDerefSpecial contained "{\@<=[-*@?0]" nextgroup=shDerefOp,shDerefOffset,shDerefOpError 506071d4279SBram Moolenaarsyn match shDerefSpecial contained "\({[#!]\)\@<=[[:alnum:]*@_]\+" nextgroup=@shDerefVarList,shDerefOp 507bc8801c9SBram Moolenaarsyn match shDerefVar contained "{\@<=\h\w*" nextgroup=@shDerefVarList 508e4a3bcf2SBram Moolenaarsyn match shDerefVar contained '\d' nextgroup=@shDerefVarList 50951ad4eaaSBram Moolenaarif exists("b:is_kornshell") || exists("b:is_posix") 510bc8801c9SBram Moolenaar syn match shDerefVar contained "{\@<=\h\w*[[:alnum:]_.]*" nextgroup=@shDerefVarList 511b4ff518dSBram Moolenaarendif 512071d4279SBram Moolenaar 513d4755bb0SBram Moolenaar" sh ksh bash : ${var[... ]...} array reference: {{{1 514071d4279SBram Moolenaarsyn region shDerefVarArray contained matchgroup=shDeref start="\[" end="]" contains=@shCommandSubList nextgroup=shDerefOp,shDerefOpError 515071d4279SBram Moolenaar 516d4755bb0SBram Moolenaar" Special ${parameter OPERATOR word} handling: {{{1 517071d4279SBram Moolenaar" sh ksh bash : ${parameter:-word} word is default value 518071d4279SBram Moolenaar" sh ksh bash : ${parameter:=word} assign word as default value 519071d4279SBram Moolenaar" sh ksh bash : ${parameter:?word} display word if parameter is null 520071d4279SBram Moolenaar" sh ksh bash : ${parameter:+word} use word if parameter is not null, otherwise nothing 521071d4279SBram Moolenaar" ksh bash : ${parameter#pattern} remove small left pattern 522071d4279SBram Moolenaar" ksh bash : ${parameter##pattern} remove large left pattern 523071d4279SBram Moolenaar" ksh bash : ${parameter%pattern} remove small right pattern 524071d4279SBram Moolenaar" ksh bash : ${parameter%%pattern} remove large right pattern 525d960d76dSBram Moolenaar" bash : ${parameter^pattern} Case modification 526d960d76dSBram Moolenaar" bash : ${parameter^^pattern} Case modification 527d960d76dSBram Moolenaar" bash : ${parameter,pattern} Case modification 528d960d76dSBram Moolenaar" bash : ${parameter,,pattern} Case modification 529d58a3bf7SBram Moolenaar" bash : ${@:start:qty} display command line arguments from start to start+qty-1 (inferred) 530071d4279SBram Moolenaarsyn cluster shDerefPatternList contains=shDerefPattern,shDerefString 5316be7f873SBram Moolenaarif !exists("g:sh_no_error") 532071d4279SBram Moolenaar syn match shDerefOpError contained ":[[:punct:]]" 5336be7f873SBram Moolenaarendif 534071d4279SBram Moolenaarsyn match shDerefOp contained ":\=[-=?]" nextgroup=@shDerefPatternList 535071d4279SBram Moolenaarsyn match shDerefOp contained ":\=+" nextgroup=@shDerefPatternList 53651ad4eaaSBram Moolenaarif exists("b:is_bash") || exists("b:is_kornshell") || exists("b:is_posix") 537071d4279SBram Moolenaar syn match shDerefOp contained "#\{1,2}" nextgroup=@shDerefPatternList 538071d4279SBram Moolenaar syn match shDerefOp contained "%\{1,2}" nextgroup=@shDerefPatternList 5395b8d8fdbSBram Moolenaar syn match shDerefPattern contained "[^{}]\+" contains=shDeref,shDerefSimple,shDerefPattern,shDerefString,shCommandSub,shDerefEscape nextgroup=shDerefPattern 540071d4279SBram Moolenaar syn region shDerefPattern contained start="{" end="}" contains=shDeref,shDerefSimple,shDerefString,shCommandSub nextgroup=shDerefPattern 5415b8d8fdbSBram Moolenaar syn match shDerefEscape contained '\%(\\\\\)*\\.' 542071d4279SBram Moolenaarendif 543d960d76dSBram Moolenaarif exists("b:is_bash") 544d960d76dSBram Moolenaar syn match shDerefOp contained "[,^]\{1,2}" nextgroup=@shDerefPatternList 545d960d76dSBram Moolenaarendif 5464b22cdb0SBram Moolenaarsyn region shDerefString contained matchgroup=shDerefDelim start=+\%(\\\)\@<!'+ end=+'+ contains=shStringSpecial 5474b22cdb0SBram Moolenaarsyn region shDerefString contained matchgroup=shDerefDelim start=+\%(\\\)\@<!"+ skip=+\\"+ end=+"+ contains=@shDblQuoteList,shStringSpecial 548c236c16dSBram Moolenaarsyn match shDerefString contained "\\["']" nextgroup=shDerefPattern 549071d4279SBram Moolenaar 550d58a3bf7SBram Moolenaarif exists("b:is_bash") || exists("b:is_kornshell") || exists("b:is_posix") 551d58a3bf7SBram Moolenaar " bash ksh posix : ${parameter:offset} 552d58a3bf7SBram Moolenaar " bash ksh posix : ${parameter:offset:length} 553d58a3bf7SBram Moolenaar syn region shDerefOffset contained start=':[^-=?+]' end='\ze:' end='\ze}' contains=shDeref,shDerefSimple,shDerefEscape nextgroup=shDerefLen,shDeref,shDerefSimple 554d58a3bf7SBram Moolenaar syn region shDerefOffset contained start=':\s-' end='\ze:' end='\ze}' contains=shDeref,shDerefSimple,shDerefEscape nextgroup=shDerefLen,shDeref,shDerefSimple 555d2855f54SBram Moolenaar syn match shDerefLen contained ":[^}]\+" contains=shDeref,shDerefSimple,shArithmetic 556d58a3bf7SBram Moolenaarendif 5575b8d8fdbSBram Moolenaar 558d58a3bf7SBram Moolenaarif exists("b:is_bash") 559071d4279SBram Moolenaar " bash : ${parameter//pattern/string} 560071d4279SBram Moolenaar " bash : ${parameter//pattern} 5615b8d8fdbSBram Moolenaar syn match shDerefPPS contained '/\{1,2}' nextgroup=shDerefPPSleft 562d58a3bf7SBram Moolenaar syn region shDerefPPSleft contained start='.' skip=@\%(\\\\\)*\\/@ matchgroup=shDerefOp end='/' end='\ze}' end='"' nextgroup=shDerefPPSright contains=@shPPSLeftList 56391c4937bSBram Moolenaar syn region shDerefPPSright contained start='.' skip=@\%(\\\\\)\+@ end='\ze}' contains=@shPPSRightList 564acb4f221SBram Moolenaar 565acb4f221SBram Moolenaar " bash : ${parameter/#substring/replacement} 56693a1df2cSBram Moolenaar syn match shDerefPSR contained '/#' nextgroup=shDerefPSRleft,shDoubleQuote,shSingleQuote 56793a1df2cSBram Moolenaar syn region shDerefPSRleft contained start='[^"']' skip=@\%(\\\\\)*\\/@ matchgroup=shDerefOp end='/' end='\ze}' nextgroup=shDerefPSRright 568acb4f221SBram Moolenaar syn region shDerefPSRright contained start='.' skip=@\%(\\\\\)\+@ end='\ze}' 569071d4279SBram Moolenaarendif 570071d4279SBram Moolenaar 571c236c16dSBram Moolenaar" Arithmetic Parenthesized Expressions: {{{1 572bc488a76SBram Moolenaar"syn region shParen matchgroup=shArithRegion start='[^$]\zs(\%(\ze[^(]\|$\)' end=')' contains=@shArithParenList 573bc488a76SBram Moolenaarsyn region shParen matchgroup=shArithRegion start='\$\@!(\%(\ze[^(]\|$\)' end=')' contains=@shArithParenList 574c236c16dSBram Moolenaar 57593a1df2cSBram Moolenaar" Additional sh Keywords: {{{1 576d4755bb0SBram Moolenaar" =================== 577071d4279SBram Moolenaarsyn keyword shStatement break cd chdir continue eval exec exit kill newgrp pwd read readonly return shift test trap ulimit umask wait 578071d4279SBram Moolenaarsyn keyword shConditional contained elif else then 5796be7f873SBram Moolenaarif !exists("g:sh_no_error") 580071d4279SBram Moolenaar syn keyword shCondError elif else then 5816be7f873SBram Moolenaarendif 582071d4279SBram Moolenaar 58393a1df2cSBram Moolenaar" Additional ksh Keywords and Aliases: {{{1 58493a1df2cSBram Moolenaar" =================================== 585b730f0c7SBram Moolenaarif exists("b:is_kornshell") || exists("b:is_posix") 586b730f0c7SBram Moolenaar syn keyword shStatement bg builtin disown enum export false fg getconf getopts hist jobs let printf sleep true unalias whence 587b730f0c7SBram Moolenaar syn keyword shStatement typeset skipwhite nextgroup=shSetOption 58893a1df2cSBram Moolenaar syn keyword shStatement autoload compound fc float functions hash history integer nameref nohup r redirect source stop suspend times type 589690afe1fSBram Moolenaar if exists("b:is_posix") 590c236c16dSBram Moolenaar syn keyword shStatement command 591c236c16dSBram Moolenaar else 592c236c16dSBram Moolenaar syn keyword shStatement time 593c236c16dSBram Moolenaar endif 594071d4279SBram Moolenaar 59593a1df2cSBram Moolenaar" Additional bash Keywords: {{{1 596d4755bb0SBram Moolenaar" ===================== 597b730f0c7SBram Moolenaarelseif exists("b:is_bash") 598b730f0c7SBram Moolenaar syn keyword shStatement bg builtin disown export false fg getopts jobs let printf sleep true unalias 599b730f0c7SBram Moolenaar syn keyword shStatement typeset nextgroup=shSetOption 600b730f0c7SBram Moolenaar syn keyword shStatement fc hash history source suspend times type 601b730f0c7SBram Moolenaar syn keyword shStatement bind builtin caller compopt declare dirs disown enable export help logout mapfile popd pushd readarray shopt source typeset 602071d4279SBram Moolenaarelse 603071d4279SBram Moolenaar syn keyword shStatement login newgrp 604071d4279SBram Moolenaarendif 605071d4279SBram Moolenaar 606d4755bb0SBram Moolenaar" Synchronization: {{{1 607d4755bb0SBram Moolenaar" ================ 60803413f44SBram Moolenaarif !exists("g:sh_minlines") 60903413f44SBram Moolenaar let s:sh_minlines = 200 61003413f44SBram Moolenaarelse 61103413f44SBram Moolenaar let s:sh_minlines= g:sh_minlines 612071d4279SBram Moolenaarendif 61303413f44SBram Moolenaarif !exists("g:sh_maxlines") 61403413f44SBram Moolenaar let s:sh_maxlines = 2*s:sh_minlines 61503413f44SBram Moolenaar if s:sh_maxlines < 25 61603413f44SBram Moolenaar let s:sh_maxlines= 25 617071d4279SBram Moolenaar endif 61803413f44SBram Moolenaarelse 61903413f44SBram Moolenaar let s:sh_maxlines= g:sh_maxlines 62003413f44SBram Moolenaarendif 62103413f44SBram Moolenaarexec "syn sync minlines=" . s:sh_minlines . " maxlines=" . s:sh_maxlines 622071d4279SBram Moolenaarsyn sync match shCaseEsacSync grouphere shCaseEsac "\<case\>" 623071d4279SBram Moolenaarsyn sync match shCaseEsacSync groupthere shCaseEsac "\<esac\>" 624071d4279SBram Moolenaarsyn sync match shDoSync grouphere shDo "\<do\>" 625071d4279SBram Moolenaarsyn sync match shDoSync groupthere shDo "\<done\>" 626071d4279SBram Moolenaarsyn sync match shForSync grouphere shFor "\<for\>" 627071d4279SBram Moolenaarsyn sync match shForSync groupthere shFor "\<in\>" 628071d4279SBram Moolenaarsyn sync match shIfSync grouphere shIf "\<if\>" 629071d4279SBram Moolenaarsyn sync match shIfSync groupthere shIf "\<fi\>" 630071d4279SBram Moolenaarsyn sync match shUntilSync grouphere shRepeat "\<until\>" 631071d4279SBram Moolenaarsyn sync match shWhileSync grouphere shRepeat "\<while\>" 632071d4279SBram Moolenaar 633d4755bb0SBram Moolenaar" Default Highlighting: {{{1 634d4755bb0SBram Moolenaar" ===================== 635f37506f6SBram Moolenaarif !exists("skip_sh_syntax_inits") 636071d4279SBram Moolenaar hi def link shArithRegion shShellVariables 63791c4937bSBram Moolenaar hi def link shAstQuote shDoubleQuote 638bc488a76SBram Moolenaar hi def link shAtExpr shSetList 639d2855f54SBram Moolenaar hi def link shBkslshSnglQuote shSingleQuote 640d2855f54SBram Moolenaar hi def link shBkslshDblQuote shDOubleQuote 641df177f67SBram Moolenaar hi def link shBeginHere shRedir 642071d4279SBram Moolenaar hi def link shCaseBar shConditional 643071d4279SBram Moolenaar hi def link shCaseCommandSub shCommandSub 644071d4279SBram Moolenaar hi def link shCaseDoubleQuote shDoubleQuote 645df177f67SBram Moolenaar hi def link shCaseIn shConditional 6464b22cdb0SBram Moolenaar hi def link shQuote shOperator 647071d4279SBram Moolenaar hi def link shCaseSingleQuote shSingleQuote 648071d4279SBram Moolenaar hi def link shCaseStart shConditional 649071d4279SBram Moolenaar hi def link shCmdSubRegion shShellVariables 6505c73622aSBram Moolenaar hi def link shColon shComment 651071d4279SBram Moolenaar hi def link shDerefOp shOperator 652df177f67SBram Moolenaar hi def link shDerefPOL shDerefOp 6535b8d8fdbSBram Moolenaar hi def link shDerefPPS shDerefOp 654acb4f221SBram Moolenaar hi def link shDerefPSR shDerefOp 655df177f67SBram Moolenaar hi def link shDeref shShellVariables 6564b22cdb0SBram Moolenaar hi def link shDerefDelim shOperator 657071d4279SBram Moolenaar hi def link shDerefSimple shDeref 658071d4279SBram Moolenaar hi def link shDerefSpecial shDeref 659071d4279SBram Moolenaar hi def link shDerefString shDoubleQuote 660df177f67SBram Moolenaar hi def link shDerefVar shDeref 661071d4279SBram Moolenaar hi def link shDoubleQuote shString 662071d4279SBram Moolenaar hi def link shEcho shString 6634b22cdb0SBram Moolenaar hi def link shEchoDelim shOperator 664c236c16dSBram Moolenaar hi def link shEchoQuote shString 66583d1b190SBram Moolenaar hi def link shForPP shLoop 666e4a3bcf2SBram Moolenaar hi def link shFunction Function 667071d4279SBram Moolenaar hi def link shEmbeddedEcho shString 668c236c16dSBram Moolenaar hi def link shEscape shCommandSub 669e90ee31cSBram Moolenaar hi def link shExDoubleQuote shDoubleQuote 670df177f67SBram Moolenaar hi def link shExSingleQuote shSingleQuote 671071d4279SBram Moolenaar hi def link shHereDoc shString 672e4a3bcf2SBram Moolenaar hi def link shHereString shRedir 673df177f67SBram Moolenaar hi def link shHerePayload shHereDoc 674071d4279SBram Moolenaar hi def link shLoop shStatement 675e4a3bcf2SBram Moolenaar hi def link shSpecialNxt shSpecial 676b4ff518dSBram Moolenaar hi def link shNoQuote shDoubleQuote 677071d4279SBram Moolenaar hi def link shOption shCommandSub 678071d4279SBram Moolenaar hi def link shPattern shString 679c236c16dSBram Moolenaar hi def link shParen shArithmetic 680071d4279SBram Moolenaar hi def link shPosnParm shShellVariables 681c236c16dSBram Moolenaar hi def link shQuickComment shComment 68293a1df2cSBram Moolenaar hi def link shBQComment shComment 683071d4279SBram Moolenaar hi def link shRange shOperator 684071d4279SBram Moolenaar hi def link shRedir shOperator 6854b22cdb0SBram Moolenaar hi def link shSetListDelim shOperator 686c236c16dSBram Moolenaar hi def link shSetOption shOption 687071d4279SBram Moolenaar hi def link shSingleQuote shString 688071d4279SBram Moolenaar hi def link shSource shOperator 689071d4279SBram Moolenaar hi def link shStringSpecial shSpecial 69051ad4eaaSBram Moolenaar hi def link shSpecialStart shSpecial 691071d4279SBram Moolenaar hi def link shSubShRegion shOperator 692071d4279SBram Moolenaar hi def link shTestOpr shConditional 6939964e468SBram Moolenaar hi def link shTestPattern shString 6949964e468SBram Moolenaar hi def link shTestDoubleQuote shString 6959964e468SBram Moolenaar hi def link shTestSingleQuote shString 696b4ff518dSBram Moolenaar hi def link shTouchCmd shStatement 697071d4279SBram Moolenaar hi def link shVariable shSetList 698071d4279SBram Moolenaar hi def link shWrapLineOperator shOperator 699071d4279SBram Moolenaar 700071d4279SBram Moolenaar if exists("b:is_bash") 701071d4279SBram Moolenaar hi def link bashAdminStatement shStatement 702071d4279SBram Moolenaar hi def link bashSpecialVariables shShellVariables 703071d4279SBram Moolenaar hi def link bashStatement shStatement 70497d62497SBram Moolenaar hi def link shCharClass shSpecial 705d58a3bf7SBram Moolenaar hi def link shDerefOffset shDerefOp 706d58a3bf7SBram Moolenaar hi def link shDerefLen shDerefOffset 707071d4279SBram Moolenaar endif 70851ad4eaaSBram Moolenaar if exists("b:is_kornshell") || exists("b:is_posix") 709071d4279SBram Moolenaar hi def link kshSpecialVariables shShellVariables 710071d4279SBram Moolenaar hi def link kshStatement shStatement 711071d4279SBram Moolenaar endif 712071d4279SBram Moolenaar 7136be7f873SBram Moolenaar if !exists("g:sh_no_error") 714071d4279SBram Moolenaar hi def link shCaseError Error 715071d4279SBram Moolenaar hi def link shCondError Error 716071d4279SBram Moolenaar hi def link shCurlyError Error 717071d4279SBram Moolenaar hi def link shDerefOpError Error 718071d4279SBram Moolenaar hi def link shDerefWordError Error 719071d4279SBram Moolenaar hi def link shDoError Error 720071d4279SBram Moolenaar hi def link shEsacError Error 721071d4279SBram Moolenaar hi def link shIfError Error 722071d4279SBram Moolenaar hi def link shInError Error 723071d4279SBram Moolenaar hi def link shParenError Error 724071d4279SBram Moolenaar hi def link shTestError Error 72551ad4eaaSBram Moolenaar if exists("b:is_kornshell") || exists("b:is_posix") 726071d4279SBram Moolenaar hi def link shDTestError Error 727071d4279SBram Moolenaar endif 7286be7f873SBram Moolenaar endif 729071d4279SBram Moolenaar 730071d4279SBram Moolenaar hi def link shArithmetic Special 731071d4279SBram Moolenaar hi def link shCharClass Identifier 732071d4279SBram Moolenaar hi def link shSnglCase Statement 733071d4279SBram Moolenaar hi def link shCommandSub Special 734d2855f54SBram Moolenaar hi def link shCommandSubBQ shCommandSub 735071d4279SBram Moolenaar hi def link shComment Comment 736071d4279SBram Moolenaar hi def link shConditional Conditional 7379964e468SBram Moolenaar hi def link shCtrlSeq Special 738071d4279SBram Moolenaar hi def link shExprRegion Delimiter 739cd71fa3cSBram Moolenaar hi def link shFunctionKey Function 740071d4279SBram Moolenaar hi def link shFunctionName Function 741071d4279SBram Moolenaar hi def link shNumber Number 742071d4279SBram Moolenaar hi def link shOperator Operator 743071d4279SBram Moolenaar hi def link shRepeat Repeat 744071d4279SBram Moolenaar hi def link shSet Statement 745071d4279SBram Moolenaar hi def link shSetList Identifier 746071d4279SBram Moolenaar hi def link shShellVariables PreProc 747071d4279SBram Moolenaar hi def link shSpecial Special 748d2855f54SBram Moolenaar hi def link shSpecialDQ Special 749d2855f54SBram Moolenaar hi def link shSpecialSQ Special 750b0d45e7fSBram Moolenaar hi def link shSpecialNoZS shSpecial 751071d4279SBram Moolenaar hi def link shStatement Statement 752071d4279SBram Moolenaar hi def link shString String 753071d4279SBram Moolenaar hi def link shTodo Todo 754071d4279SBram Moolenaar hi def link shAlias Identifier 755541f92d6SBram Moolenaar hi def link shHereDoc01 shRedir 756541f92d6SBram Moolenaar hi def link shHereDoc02 shRedir 757541f92d6SBram Moolenaar hi def link shHereDoc03 shRedir 758541f92d6SBram Moolenaar hi def link shHereDoc04 shRedir 759541f92d6SBram Moolenaar hi def link shHereDoc05 shRedir 760541f92d6SBram Moolenaar hi def link shHereDoc06 shRedir 761541f92d6SBram Moolenaar hi def link shHereDoc07 shRedir 762541f92d6SBram Moolenaar hi def link shHereDoc08 shRedir 763541f92d6SBram Moolenaar hi def link shHereDoc09 shRedir 764541f92d6SBram Moolenaar hi def link shHereDoc10 shRedir 765541f92d6SBram Moolenaar hi def link shHereDoc11 shRedir 766541f92d6SBram Moolenaar hi def link shHereDoc12 shRedir 767541f92d6SBram Moolenaar hi def link shHereDoc13 shRedir 768541f92d6SBram Moolenaar hi def link shHereDoc14 shRedir 769541f92d6SBram Moolenaar hi def link shHereDoc15 shRedir 77023515b4eSBram Moolenaar hi def link shHereDoc16 shRedir 771f37506f6SBram Moolenaarendif 772b4ff518dSBram Moolenaar 773b4ff518dSBram Moolenaar" Delete shell folding commands {{{1 774b4ff518dSBram Moolenaar" ============================= 775b4ff518dSBram Moolenaardelc ShFoldFunctions 776b4ff518dSBram Moolenaardelc ShFoldHereDoc 777b4ff518dSBram Moolenaardelc ShFoldIfDoFor 778071d4279SBram Moolenaar 779d4755bb0SBram Moolenaar" Set Current Syntax: {{{1 780d4755bb0SBram Moolenaar" =================== 781071d4279SBram Moolenaarif exists("b:is_bash") 782071d4279SBram Moolenaar let b:current_syntax = "bash" 783071d4279SBram Moolenaarelseif exists("b:is_kornshell") 784071d4279SBram Moolenaar let b:current_syntax = "ksh" 78551ad4eaaSBram Moolenaarelseif exists("b:is_posix") 78651ad4eaaSBram Moolenaar let b:current_syntax = "posix" 787071d4279SBram Moolenaarelse 788071d4279SBram Moolenaar let b:current_syntax = "sh" 789071d4279SBram Moolenaarendif 790071d4279SBram Moolenaar 791d4755bb0SBram Moolenaar" vim: ts=16 fdm=marker 792