blob: 60f23d2d83d82b0097a51ba9e1bea6bb4eb17a16 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: shell (sh) Korn shell (ksh) bash (sh)
Bram Moolenaar97d62492012-11-15 21:28:22 +01003" Maintainer: Charles E. Campbell <NdrOchipS@PcampbellAfamily.Mbiz>
Bram Moolenaar071d4272004-06-13 20:20:40 +00004" Previous Maintainer: Lennart Schultz <Lennart.Schultz@ecmwf.int>
Bram Moolenaar60cce2f2015-10-13 23:21:27 +02005" Last Change: Oct 09, 2015
6" Version: 139
Bram Moolenaare2719092015-01-10 15:09:25 +01007" URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_SH
8" For options and settings, please use: :help ft-sh-syntax
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +02009" This file includes many ideas from ?ric Brunet (eric.brunet@ens.fr)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010
Bram Moolenaard4755bb2004-09-02 19:12:26 +000011" For version 5.x: Clear all syntax items {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +000012" For version 6.x: Quit when a syntax file was already loaded
13if version < 600
14 syntax clear
15elseif exists("b:current_syntax")
16 finish
17endif
18
Bram Moolenaar60cce2f2015-10-13 23:21:27 +020019" AFAICT "." should be considered part of the iskeyword for ksh. Using iskeywords
20" in syntax is dicey, so the following code permits the user to prevent/override
Bram Moolenaar97d62492012-11-15 21:28:22 +010021" g:sh_isk set to a string : specify iskeyword.
22" g:sh_noisk exists : don't change iskeyword
Bram Moolenaar60cce2f2015-10-13 23:21:27 +020023" g:sh_noisk does not exist : (default) append "." to iskeyword for kornshell
Bram Moolenaar97d62492012-11-15 21:28:22 +010024if exists("g:sh_isk") && type(g:sh_isk) == 1 " user specifying iskeyword
25 exe "setl isk=".g:sh_isk
Bram Moolenaar60cce2f2015-10-13 23:21:27 +020026elseif !exists("g:sh_noisk") && exists("b:is_kornshell") " append '.' to iskeyword
Bram Moolenaar97d62492012-11-15 21:28:22 +010027 setl isk+=.
Bram Moolenaard960d762011-09-21 19:22:10 +020028endif
29
30" trying to answer the question: which shell is /bin/sh, really?
Bram Moolenaar97d62492012-11-15 21:28:22 +010031" If the user has not specified any of g:is_kornshell, g:is_bash, g:is_posix, g:is_sh, then guess.
Bram Moolenaard960d762011-09-21 19:22:10 +020032if !exists("g:is_kornshell") && !exists("g:is_bash") && !exists("g:is_posix") && !exists("g:is_sh")
Bram Moolenaarbc488a72013-07-05 21:01:22 +020033 let s:shell = ""
Bram Moolenaard960d762011-09-21 19:22:10 +020034 if executable("/bin/sh")
Bram Moolenaarbc488a72013-07-05 21:01:22 +020035 let s:shell = resolve("/bin/sh")
Bram Moolenaard960d762011-09-21 19:22:10 +020036 elseif executable("/usr/bin/sh")
Bram Moolenaarbc488a72013-07-05 21:01:22 +020037 let s:shell = resolve("/usr/bin/sh")
Bram Moolenaard960d762011-09-21 19:22:10 +020038 endif
Bram Moolenaarbc488a72013-07-05 21:01:22 +020039 if s:shell =~ 'bash$'
40 let g:is_bash= 1
41 elseif s:shell =~ 'ksh$'
42 let g:is_kornshell = 1
43 elseif s:shell =~ 'dash$'
44 let g:is_posix = 1
45 endif
46 unlet s:shell
Bram Moolenaard960d762011-09-21 19:22:10 +020047endif
48
Bram Moolenaard4755bb2004-09-02 19:12:26 +000049" handling /bin/sh with is_kornshell/is_sh {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +000050" b:is_sh is set when "#! /bin/sh" is found;
51" However, it often is just a masquerade by bash (typically Linux)
52" or kornshell (typically workstations with Posix "sh").
Bram Moolenaard960d762011-09-21 19:22:10 +020053" So, when the user sets "g:is_bash", "g:is_kornshell",
54" or "g:is_posix", a b:is_sh is converted into b:is_bash/b:is_kornshell,
Bram Moolenaar071d4272004-06-13 20:20:40 +000055" respectively.
56if !exists("b:is_kornshell") && !exists("b:is_bash")
Bram Moolenaar7fc904b2006-04-13 20:37:35 +000057 if exists("g:is_posix") && !exists("g:is_kornshell")
58 let g:is_kornshell= g:is_posix
59 endif
60 if exists("g:is_kornshell")
Bram Moolenaar071d4272004-06-13 20:20:40 +000061 let b:is_kornshell= 1
62 if exists("b:is_sh")
63 unlet b:is_sh
64 endif
Bram Moolenaar7fc904b2006-04-13 20:37:35 +000065 elseif exists("g:is_bash")
Bram Moolenaar071d4272004-06-13 20:20:40 +000066 let b:is_bash= 1
67 if exists("b:is_sh")
68 unlet b:is_sh
69 endif
70 else
71 let b:is_sh= 1
72 endif
73endif
74
Bram Moolenaarcd71fa32005-03-11 22:46:48 +000075" set up default g:sh_fold_enabled {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +000076if !exists("g:sh_fold_enabled")
77 let g:sh_fold_enabled= 0
Bram Moolenaar293ee4d2004-12-09 21:34:53 +000078elseif g:sh_fold_enabled != 0 && !has("folding")
79 let g:sh_fold_enabled= 0
Bram Moolenaarcd71fa32005-03-11 22:46:48 +000080 echomsg "Ignoring g:sh_fold_enabled=".g:sh_fold_enabled."; need to re-compile vim for +fold support"
81endif
Bram Moolenaarc236c162008-07-13 17:41:49 +000082if !exists("s:sh_fold_functions")
Bram Moolenaar97d62492012-11-15 21:28:22 +010083 let s:sh_fold_functions= and(g:sh_fold_enabled,1)
Bram Moolenaarc236c162008-07-13 17:41:49 +000084endif
85if !exists("s:sh_fold_heredoc")
Bram Moolenaar97d62492012-11-15 21:28:22 +010086 let s:sh_fold_heredoc = and(g:sh_fold_enabled,2)
Bram Moolenaarc236c162008-07-13 17:41:49 +000087endif
88if !exists("s:sh_fold_ifdofor")
Bram Moolenaar97d62492012-11-15 21:28:22 +010089 let s:sh_fold_ifdofor = and(g:sh_fold_enabled,4)
Bram Moolenaarc236c162008-07-13 17:41:49 +000090endif
Bram Moolenaarcd71fa32005-03-11 22:46:48 +000091if g:sh_fold_enabled && &fdm == "manual"
Bram Moolenaar97d62492012-11-15 21:28:22 +010092 " Given that the user provided g:sh_fold_enabled
93 " AND g:sh_fold_enabled is manual (usual default)
94 " implies a desire for syntax-based folding
95 setl fdm=syntax
Bram Moolenaar071d4272004-06-13 20:20:40 +000096endif
97
Bram Moolenaarcd71fa32005-03-11 22:46:48 +000098" sh syntax is case sensitive {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +000099syn case match
100
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000101" Clusters: contains=@... clusters {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000102"==================================
Bram Moolenaar5c736222010-01-06 20:54:52 +0100103syn cluster shErrorList contains=shDoError,shIfError,shInError,shCaseError,shEsacError,shCurlyError,shParenError,shTestError,shOK
Bram Moolenaarc236c162008-07-13 17:41:49 +0000104if exists("b:is_kornshell")
105 syn cluster ErrorList add=shDTestError
106endif
Bram Moolenaar83d1b192015-04-13 14:22:40 +0200107syn cluster shArithParenList contains=shArithmetic,shCaseEsac,shComment,shDeref,shDo,shDerefSimple,shEcho,shEscape,shNumber,shOperator,shPosnParm,shExSingleQuote,shExDoubleQuote,shRedir,shSingleQuote,shDoubleQuote,shStatement,shVariable,shAlias,shTest,shCtrlSeq,shSpecial,shParen,bashSpecialVariables,bashStatement,shIf,shFor
Bram Moolenaarc236c162008-07-13 17:41:49 +0000108syn cluster shArithList contains=@shArithParenList,shParenError
Bram Moolenaar5c736222010-01-06 20:54:52 +0100109syn cluster shCaseEsacList contains=shCaseStart,shCase,shCaseBar,shCaseIn,shComment,shDeref,shDerefSimple,shCaseCommandSub,shCaseExSingleQuote,shCaseSingleQuote,shCaseDoubleQuote,shCtrlSeq,@shErrorList,shStringSpecial,shCaseRange
Bram Moolenaard960d762011-09-21 19:22:10 +0200110syn cluster shCaseList contains=@shCommandSubList,shCaseEsac,shColon,shCommandSub,shComment,shDo,shEcho,shExpr,shFor,shHereDoc,shIf,shRedir,shSetList,shSource,shStatement,shVariable,shCtrlSeq
Bram Moolenaar541f92d2015-06-19 13:27:23 +0200111syn cluster shCommandSubList contains=shAlias,shArithmetic,shCmdParenRegion,shCtrlSeq,shDeref,shDerefSimple,shDoubleQuote,shEcho,shEscape,shExDoubleQuote,shExpr,shExSingleQuote,shNumber,shOperator,shOption,shPosnParm,shSingleQuote,shSpecial,shStatement,shSubSh,shTest,shVariable
Bram Moolenaar572cb562005-08-05 21:35:02 +0000112syn cluster shCurlyList contains=shNumber,shComma,shDeref,shDerefSimple,shDerefSpecial
Bram Moolenaar97d62492012-11-15 21:28:22 +0100113syn cluster shDblQuoteList contains=shCommandSub,shDeref,shDerefSimple,shEscape,shPosnParm,shCtrlSeq,shSpecial
Bram Moolenaar5b8d8fd2005-08-16 23:01:50 +0000114syn cluster shDerefList contains=shDeref,shDerefSimple,shDerefVar,shDerefSpecial,shDerefWordError,shDerefPPS
Bram Moolenaar071d4272004-06-13 20:20:40 +0000115syn cluster shDerefVarList contains=shDerefOp,shDerefVarArray,shDerefOpError
Bram Moolenaar97d62492012-11-15 21:28:22 +0100116syn cluster shEchoList contains=shArithmetic,shCommandSub,shDeref,shDerefSimple,shEscape,shExpr,shExSingleQuote,shExDoubleQuote,shSingleQuote,shDoubleQuote,shCtrlSeq,shEchoQuote
Bram Moolenaare90ee312010-08-05 22:08:47 +0200117syn cluster shExprList1 contains=shCharClass,shNumber,shOperator,shExSingleQuote,shExDoubleQuote,shSingleQuote,shDoubleQuote,shExpr,shDblBrace,shDeref,shDerefSimple,shCtrlSeq
Bram Moolenaar383f9bc2005-01-19 22:18:32 +0000118syn cluster shExprList2 contains=@shExprList1,@shCaseList,shTest
Bram Moolenaard960d762011-09-21 19:22:10 +0200119syn cluster shFunctionList contains=@shCommandSubList,shCaseEsac,shColon,shCommandSub,shComment,shDo,shEcho,shExpr,shFor,shHereDoc,shIf,shOption,shRedir,shSetList,shSource,shStatement,shVariable,shOperator,shCtrlSeq
Bram Moolenaar7263a772007-05-10 17:35:54 +0000120if exists("b:is_kornshell") || exists("b:is_bash")
Bram Moolenaarc236c162008-07-13 17:41:49 +0000121 syn cluster shFunctionList add=shRepeat
Bram Moolenaar7263a772007-05-10 17:35:54 +0000122 syn cluster shFunctionList add=shDblBrace,shDblParen
123endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000124syn cluster shHereBeginList contains=@shCommandSubList
125syn cluster shHereList contains=shBeginHere,shHerePayload
126syn cluster shHereListDQ contains=shBeginHere,@shDblQuoteList,shHerePayload
Bram Moolenaarbc488a72013-07-05 21:01:22 +0200127syn cluster shIdList contains=shCommandSub,shWrapLineOperator,shSetOption,shDeref,shDerefSimple,shRedir,shExSingleQuote,shExDoubleQuote,shSingleQuote,shDoubleQuote,shExpr,shCtrlSeq,shStringSpecial,shAtExpr
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100128syn cluster shIfList contains=@shLoopList,shDblBrace,shDblParen,shFunctionKey,shFunctionOne,shFunctionTwo
Bram Moolenaar0a63ded2015-04-15 13:31:24 +0200129syn cluster shLoopList contains=@shCaseList,@shErrorList,shCaseEsac,shConditional,shDblBrace,shExpr,shFor,shForPP,shIf,shOption,shSet,shTest,shTestOpr
Bram Moolenaard960d762011-09-21 19:22:10 +0200130syn cluster shSubShList contains=@shCommandSubList,shCaseEsac,shColon,shCommandSub,shComment,shDo,shEcho,shExpr,shFor,shIf,shRedir,shSetList,shSource,shStatement,shVariable,shCtrlSeq,shOperator
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200131syn cluster shTestList contains=shCharClass,shCommandSub,shCtrlSeq,shDeref,shDerefSimple,shDoubleQuote,shExDoubleQuote,shExpr,shExSingleQuote,shNumber,shOperator,shSingleQuote,shTest,shTestOpr
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000132" Echo: {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000133" ====
134" This one is needed INSIDE a CommandSub, so that `echo bla` be correct
Bram Moolenaarbc488a72013-07-05 21:01:22 +0200135syn region shEcho matchgroup=shStatement start="\<echo\>" skip="\\$" matchgroup=shEchoDelim end="$" matchgroup=NONE end="[<>;&|()`]"me=e-1 end="\d[<>]"me=e-2 end="\s#"me=e-2 contains=@shEchoList skipwhite nextgroup=shQuickComment
136syn region shEcho 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=@shEchoList skipwhite nextgroup=shQuickComment
Bram Moolenaar5c736222010-01-06 20:54:52 +0100137syn match shEchoQuote contained '\%(\\\\\)*\\["`'()]'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000138
Bram Moolenaarc236c162008-07-13 17:41:49 +0000139" This must be after the strings, so that ... \" will be correct
Bram Moolenaare90ee312010-08-05 22:08:47 +0200140syn 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
Bram Moolenaar071d4272004-06-13 20:20:40 +0000141
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000142" Alias: {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000143" =====
144if exists("b:is_kornshell") || exists("b:is_bash")
145 syn match shStatement "\<alias\>"
Bram Moolenaard960d762011-09-21 19:22:10 +0200146 syn region shAlias matchgroup=shStatement start="\<alias\>\s\+\(\h[-._[:alnum:]]\+\)\@=" skip="\\$" end="\>\|`"
147 syn region shAlias matchgroup=shStatement start="\<alias\>\s\+\(\h[-._[:alnum:]]\+=\)\@=" skip="\\$" end="="
Bram Moolenaar071d4272004-06-13 20:20:40 +0000148endif
149
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000150" Error Codes: {{{1
151" ============
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100152if !exists("g:sh_no_error")
Bram Moolenaare2719092015-01-10 15:09:25 +0100153 syn match shDoError "\<done\>"
154 syn match shIfError "\<fi\>"
155 syn match shInError "\<in\>"
156 syn match shCaseError ";;"
157 syn match shEsacError "\<esac\>"
158 syn match shCurlyError "}"
159 syn match shParenError ")"
160 syn match shOK '\.\(done\|fi\|in\|esac\)'
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100161 if exists("b:is_kornshell")
Bram Moolenaare2719092015-01-10 15:09:25 +0100162 syn match shDTestError "]]"
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100163 endif
Bram Moolenaare2719092015-01-10 15:09:25 +0100164 syn match shTestError "]"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000165endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000166
Bram Moolenaarc236c162008-07-13 17:41:49 +0000167" Options: {{{1
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000168" ====================
Bram Moolenaar97d62492012-11-15 21:28:22 +0100169syn match shOption "\s\zs[-+][-_a-zA-Z0-9#]\+"
Bram Moolenaarbc488a72013-07-05 21:01:22 +0200170syn match shOption "\s\zs--[^ \t$`'"|);]\+"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000171
Bram Moolenaar7263a772007-05-10 17:35:54 +0000172" File Redirection Highlighted As Operators: {{{1
173"===========================================
174syn match shRedir "\d\=>\(&[-0-9]\)\="
175syn match shRedir "\d\=>>-\="
176syn match shRedir "\d\=<\(&[-0-9]\)\="
177syn match shRedir "\d<<-\="
178
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000179" Operators: {{{1
180" ==========
Bram Moolenaar7263a772007-05-10 17:35:54 +0000181syn match shOperator "<<\|>>" contained
Bram Moolenaarc236c162008-07-13 17:41:49 +0000182syn match shOperator "[!&;|]" contained
183syn match shOperator "\[[[^:]\|\]]" contained
Bram Moolenaar541f92d2015-06-19 13:27:23 +0200184syn match shOperator "[-=/*+%]\==" skipwhite nextgroup=shPattern
Bram Moolenaare90ee312010-08-05 22:08:47 +0200185syn match shPattern "\<\S\+\())\)\@=" contained contains=shExSingleQuote,shSingleQuote,shExDoubleQuote,shDoubleQuote,shDeref
Bram Moolenaar071d4272004-06-13 20:20:40 +0000186
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000187" Subshells: {{{1
188" ==========
Bram Moolenaard960d762011-09-21 19:22:10 +0200189syn region shExpr transparent matchgroup=shExprRegion start="{" end="}" contains=@shExprList2 nextgroup=shMoreSpecial
190syn region shSubSh transparent matchgroup=shSubShRegion start="[^(]\zs(" end=")" contains=@shSubShList nextgroup=shMoreSpecial
Bram Moolenaar071d4272004-06-13 20:20:40 +0000191
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000192" Tests: {{{1
193"=======
Bram Moolenaar00a927d2010-05-14 23:24:24 +0200194syn region shExpr matchgroup=shRange start="\[" skip=+\\\\\|\\$\|\[+ end="\]" contains=@shTestList,shSpecial
Bram Moolenaar5c736222010-01-06 20:54:52 +0100195syn region shTest transparent matchgroup=shStatement start="\<test\s" skip=+\\\\\|\\$+ matchgroup=NONE end="[;&|]"me=e-1 end="$" contains=@shExprList1
Bram Moolenaar541f92d2015-06-19 13:27:23 +0200196syn match shTestOpr contained '[^-+/%]\zs=' skipwhite nextgroup=shTestDoubleQuote,shTestSingleQuote,shTestPattern
Bram Moolenaar9964e462007-05-05 17:54:07 +0000197syn match shTestOpr contained "<=\|>=\|!=\|==\|-.\>\|-\(nt\|ot\|ef\|eq\|ne\|lt\|le\|gt\|ge\)\>\|[!<>]"
Bram Moolenaar9964e462007-05-05 17:54:07 +0000198syn match shTestPattern contained '\w\+'
Bram Moolenaar83d1b192015-04-13 14:22:40 +0200199syn region shTestDoubleQuote contained start='\%(\%(\\\\\)*\\\)\@<!"' skip=+\\\\\|\\"+ end='"'
Bram Moolenaar9964e462007-05-05 17:54:07 +0000200syn match shTestSingleQuote contained '\\.'
201syn match shTestSingleQuote contained "'[^']*'"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000202if exists("b:is_kornshell") || exists("b:is_bash")
Bram Moolenaar83d1b192015-04-13 14:22:40 +0200203 syn region shDblBrace matchgroup=Delimiter start="\[\[" skip=+\\\\\|\\$+ end="\]\]" contains=@shTestList,shComment
204 syn region shDblParen matchgroup=Delimiter start="((" skip=+\\\\\|\\$+ end="))" contains=@shTestList,shComment
Bram Moolenaar071d4272004-06-13 20:20:40 +0000205endif
206
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000207" Character Class In Range: {{{1
208" =========================
Bram Moolenaar071d4272004-06-13 20:20:40 +0000209syn match shCharClass contained "\[:\(backspace\|escape\|return\|xdigit\|alnum\|alpha\|blank\|cntrl\|digit\|graph\|lower\|print\|punct\|space\|upper\|tab\):\]"
210
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000211" Loops: do, if, while, until {{{1
212" ======
Bram Moolenaar97d62492012-11-15 21:28:22 +0100213if s:sh_fold_ifdofor
Bram Moolenaar83d1b192015-04-13 14:22:40 +0200214 syn region shDo fold transparent matchgroup=shConditional start="\<do\>" matchgroup=shConditional end="\<done\>" contains=@shLoopList
215 syn region shIf fold transparent matchgroup=shConditional start="\<if\_s" matchgroup=shConditional skip=+-fi\>+ end="\<;\_s*then\>" end="\<fi\>" contains=@shIfList
216 syn region shFor fold matchgroup=shLoop start="\<for\ze\_s\s*\%(((\)\@!" end="\<in\_s" end="\<do\>"me=e-2 contains=@shLoopList,shDblParen skipwhite nextgroup=shCurlyIn
217 syn region shForPP fold matchgroup=shLoop start='\<for\>\_s*((' end='))' contains=shTestOpr
Bram Moolenaar8dff8182006-04-06 20:18:50 +0000218else
Bram Moolenaar83d1b192015-04-13 14:22:40 +0200219 syn region shDo transparent matchgroup=shConditional start="\<do\>" matchgroup=shConditional end="\<done\>" contains=@shLoopList
220 syn region shIf transparent matchgroup=shConditional start="\<if\_s" matchgroup=shConditional skip=+-fi\>+ end="\<;\_s*then\>" end="\<fi\>" contains=@shIfList
221 syn region shFor matchgroup=shLoop start="\<for\ze\_s\s*\%(((\)\@!" end="\<in\>" end="\<do\>"me=e-2 contains=@shLoopList,shDblParen skipwhite nextgroup=shCurlyIn
222 syn region shForPP matchgroup=shLoop start='\<for\>\_s*((' end='))' contains=shTestOpr
Bram Moolenaar8dff8182006-04-06 20:18:50 +0000223endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000224if exists("b:is_kornshell") || exists("b:is_bash")
Bram Moolenaarc236c162008-07-13 17:41:49 +0000225 syn cluster shCaseList add=shRepeat
226 syn cluster shFunctionList add=shRepeat
227 syn region shRepeat matchgroup=shLoop start="\<while\_s" end="\<in\_s" end="\<do\>"me=e-2 contains=@shLoopList,shDblParen,shDblBrace
228 syn region shRepeat matchgroup=shLoop start="\<until\_s" end="\<in\_s" end="\<do\>"me=e-2 contains=@shLoopList,shDblParen,shDblBrace
229 syn region shCaseEsac matchgroup=shConditional start="\<select\s" matchgroup=shConditional end="\<in\>" end="\<do\>" contains=@shLoopList
Bram Moolenaar071d4272004-06-13 20:20:40 +0000230else
Bram Moolenaarc236c162008-07-13 17:41:49 +0000231 syn region shRepeat matchgroup=shLoop start="\<while\_s" end="\<do\>"me=e-2 contains=@shLoopList
232 syn region shRepeat matchgroup=shLoop start="\<until\_s" end="\<do\>"me=e-2 contains=@shLoopList
Bram Moolenaar071d4272004-06-13 20:20:40 +0000233endif
Bram Moolenaar572cb562005-08-05 21:35:02 +0000234syn region shCurlyIn contained matchgroup=Delimiter start="{" end="}" contains=@shCurlyList
235syn match shComma contained ","
Bram Moolenaar071d4272004-06-13 20:20:40 +0000236
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000237" Case: case...esac {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000238" ====
Bram Moolenaarc236c162008-07-13 17:41:49 +0000239syn match shCaseBar contained skipwhite "\(^\|[^\\]\)\(\\\\\)*\zs|" nextgroup=shCase,shCaseStart,shCaseBar,shComment,shCaseExSingleQuote,shCaseSingleQuote,shCaseDoubleQuote
Bram Moolenaar071d4272004-06-13 20:20:40 +0000240syn match shCaseStart contained skipwhite skipnl "(" nextgroup=shCase,shCaseBar
Bram Moolenaar97d62492012-11-15 21:28:22 +0100241if s:sh_fold_ifdofor
Bram Moolenaar5c736222010-01-06 20:54:52 +0100242 syn region shCase fold contained skipwhite skipnl matchgroup=shSnglCase start="\%(\\.\|[^#$()'" \t]\)\{-}\zs)" end=";;" end="esac"me=s-1 contains=@shCaseList nextgroup=shCaseStart,shCase,shComment
Bram Moolenaar8dff8182006-04-06 20:18:50 +0000243 syn region shCaseEsac fold matchgroup=shConditional start="\<case\>" end="\<esac\>" contains=@shCaseEsacList
244else
Bram Moolenaar5c736222010-01-06 20:54:52 +0100245 syn region shCase contained skipwhite skipnl matchgroup=shSnglCase start="\%(\\.\|[^#$()'" \t]\)\{-}\zs)" end=";;" end="esac"me=s-1 contains=@shCaseList nextgroup=shCaseStart,shCase,shComment
Bram Moolenaar8dff8182006-04-06 20:18:50 +0000246 syn region shCaseEsac matchgroup=shConditional start="\<case\>" end="\<esac\>" contains=@shCaseEsacList
247endif
Bram Moolenaardf177f62005-02-22 08:39:57 +0000248syn keyword shCaseIn contained skipwhite skipnl in nextgroup=shCase,shCaseStart,shCaseBar,shComment,shCaseExSingleQuote,shCaseSingleQuote,shCaseDoubleQuote
249if exists("b:is_bash")
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200250 syn region shCaseExSingleQuote matchgroup=shQuote start=+\$'+ skip=+\\\\\|\\.+ end=+'+ contains=shStringSpecial,shSpecial skipwhite skipnl nextgroup=shCaseBar contained
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100251elseif !exists("g:sh_no_error")
Bram Moolenaardf177f62005-02-22 08:39:57 +0000252 syn region shCaseExSingleQuote matchgroup=Error start=+\$'+ skip=+\\\\\|\\.+ end=+'+ contains=shStringSpecial skipwhite skipnl nextgroup=shCaseBar contained
253endif
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200254syn region shCaseSingleQuote matchgroup=shQuote start=+'+ end=+'+ contains=shStringSpecial skipwhite skipnl nextgroup=shCaseBar contained
255syn region shCaseDoubleQuote matchgroup=shQuote start=+"+ skip=+\\\\\|\\.+ end=+"+ contains=@shDblQuoteList,shStringSpecial skipwhite skipnl nextgroup=shCaseBar contained
Bram Moolenaar071d4272004-06-13 20:20:40 +0000256syn region shCaseCommandSub start=+`+ skip=+\\\\\|\\.+ end=+`+ contains=@shCommandSubList skipwhite skipnl nextgroup=shCaseBar contained
Bram Moolenaar97d62492012-11-15 21:28:22 +0100257if exists("b:is_bash")
258 syn region shCaseRange matchgroup=Delimiter start=+\[+ skip=+\\\\+ end=+\]+ contained contains=shCharClass
259 syn match shCharClass '\[:\%(alnum\|alpha\|ascii\|blank\|cntrl\|digit\|graph\|lower\|print\|punct\|space\|upper\|word\|or\|xdigit\):\]' contained
260else
261 syn region shCaseRange matchgroup=Delimiter start=+\[+ skip=+\\\\+ end=+\]+ contained
262endif
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000263" Misc: {{{1
264"======
Bram Moolenaar071d4272004-06-13 20:20:40 +0000265syn match shWrapLineOperator "\\$"
Bram Moolenaar97d62492012-11-15 21:28:22 +0100266syn region shCommandSub start="`" skip="\\\\\|\\." end="`" contains=@shCommandSubList
Bram Moolenaarbc488a72013-07-05 21:01:22 +0200267syn match shEscape contained '\%(^\)\@!\%(\\\\\)*\\.'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000268
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000269" $() and $(()): {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000270" $(..) is not supported by sh (Bourne shell). However, apparently
271" some systems (HP?) have as their /bin/sh a (link to) Korn shell
272" (ie. Posix compliant shell). /bin/ksh should work for those
273" systems too, however, so the following syntax will flag $(..) as
274" an Error under /bin/sh. By consensus of vimdev'ers!
275if exists("b:is_kornshell") || exists("b:is_bash")
276 syn region shCommandSub matchgroup=shCmdSubRegion start="\$(" skip='\\\\\|\\.' end=")" contains=@shCommandSubList
Bram Moolenaarc236c162008-07-13 17:41:49 +0000277 syn region shArithmetic matchgroup=shArithRegion start="\$((" skip='\\\\\|\\.' end="))" contains=@shArithList
Bram Moolenaar61d35bd2012-03-28 20:51:51 +0200278 syn region shArithmetic matchgroup=shArithRegion start="\$\[" skip='\\\\\|\\.' end="\]" contains=@shArithList
Bram Moolenaar071d4272004-06-13 20:20:40 +0000279 syn match shSkipInitWS contained "^\s\+"
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100280elseif !exists("g:sh_no_error")
Bram Moolenaardf177f62005-02-22 08:39:57 +0000281 syn region shCommandSub matchgroup=Error start="\$(" end=")" contains=@shCommandSubList
Bram Moolenaar071d4272004-06-13 20:20:40 +0000282endif
Bram Moolenaare2719092015-01-10 15:09:25 +0100283syn region shCmdParenRegion matchgroup=shCmdSubRegion start="(\ze[^(]" skip='\\\\\|\\.' end=")" contains=@shCommandSubList
Bram Moolenaar071d4272004-06-13 20:20:40 +0000284
285if exists("b:is_bash")
286 syn cluster shCommandSubList add=bashSpecialVariables,bashStatement
287 syn cluster shCaseList add=bashAdminStatement,bashStatement
Bram Moolenaard960d762011-09-21 19:22:10 +0200288 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
Bram Moolenaar97d62492012-11-15 21:28:22 +0100289 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 touch
Bram Moolenaar071d4272004-06-13 20:20:40 +0000290 syn keyword bashAdminStatement daemon killall killproc nice reload restart start status stop
Bram Moolenaar97d62492012-11-15 21:28:22 +0100291 syn keyword bashStatement command compgen
Bram Moolenaar071d4272004-06-13 20:20:40 +0000292endif
293
294if exists("b:is_kornshell")
295 syn cluster shCommandSubList add=kshSpecialVariables,kshStatement
296 syn cluster shCaseList add=kshStatement
297 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
Bram Moolenaar97d62492012-11-15 21:28:22 +0100298 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 touch tput
299 syn keyword kshStatement command setgroups setsenv
Bram Moolenaar071d4272004-06-13 20:20:40 +0000300endif
301
302syn match shSource "^\.\s"
303syn match shSource "\s\.\s"
Bram Moolenaar5c736222010-01-06 20:54:52 +0100304"syn region shColon start="^\s*:" end="$" end="\s#"me=e-2 contains=@shColonList
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100305"syn region shColon start="^\s*\zs:" end="$" end="\s#"me=e-2
306syn match shColon '^\s*\zs:'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000307
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000308" String And Character Constants: {{{1
309"================================
Bram Moolenaar9964e462007-05-05 17:54:07 +0000310syn match shNumber "-\=\<\d\+\>#\="
311syn match shCtrlSeq "\\\d\d\d\|\\[abcfnrtv0]" contained
Bram Moolenaardf177f62005-02-22 08:39:57 +0000312if exists("b:is_bash")
Bram Moolenaar5c736222010-01-06 20:54:52 +0100313 syn match shSpecial "\\\o\o\o\|\\x\x\x\|\\c[^"]\|\\[abefnrtv]" contained
Bram Moolenaardf177f62005-02-22 08:39:57 +0000314endif
315if exists("b:is_bash")
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200316 syn region shExSingleQuote matchgroup=shQuote start=+\$'+ skip=+\\\\\|\\.+ end=+'+ contains=shStringSpecial,shSpecial
Bram Moolenaare90ee312010-08-05 22:08:47 +0200317 syn region shExDoubleQuote matchgroup=shQuote start=+\$"+ skip=+\\\\\|\\.\|\\"+ end=+"+ contains=@shDblQuoteList,shStringSpecial,shSpecial
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100318elseif !exists("g:sh_no_error")
Bram Moolenaar9964e462007-05-05 17:54:07 +0000319 syn region shExSingleQuote matchGroup=Error start=+\$'+ skip=+\\\\\|\\.+ end=+'+ contains=shStringSpecial
Bram Moolenaare90ee312010-08-05 22:08:47 +0200320 syn region shExDoubleQuote matchGroup=Error start=+\$"+ skip=+\\\\\|\\.+ end=+"+ contains=shStringSpecial
Bram Moolenaardf177f62005-02-22 08:39:57 +0000321endif
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200322syn region shSingleQuote matchgroup=shQuote start=+'+ end=+'+ contains=@Spell
Bram Moolenaard960d762011-09-21 19:22:10 +0200323syn region shDoubleQuote matchgroup=shQuote start=+\%(\%(\\\\\)*\\\)\@<!"+ skip=+\\"+ end=+"+ contains=@shDblQuoteList,shStringSpecial,@Spell
Bram Moolenaar541f92d2015-06-19 13:27:23 +0200324syn match shStringSpecial "[^[:print:] \t]" contained
Bram Moolenaar7263a772007-05-10 17:35:54 +0000325syn match shStringSpecial "\%(\\\\\)*\\[\\"'`$()#]"
Bram Moolenaar541f92d2015-06-19 13:27:23 +0200326" COMBAK: why is ,shComment on next line???
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200327syn match shSpecial "[^\\]\zs\%(\\\\\)*\\[\\"'`$()#]"
328syn match shSpecial "^\%(\\\\\)*\\[\\"'`$()#]"
Bram Moolenaar541f92d2015-06-19 13:27:23 +0200329syn match shMoreSpecial "\%(\\\\\)*\\[\\"'`$()#]" nextgroup=shMoreSpecial contained
Bram Moolenaar071d4272004-06-13 20:20:40 +0000330
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000331" Comments: {{{1
332"==========
Bram Moolenaar5c736222010-01-06 20:54:52 +0100333syn cluster shCommentGroup contains=shTodo,@Spell
334syn keyword shTodo contained COMBAK FIXME TODO XXX
335syn match shComment "^\s*\zs#.*$" contains=@shCommentGroup
336syn match shComment "\s\zs#.*$" contains=@shCommentGroup
Bram Moolenaar97d62492012-11-15 21:28:22 +0100337syn match shComment contained "#.*$" contains=@shCommentGroup
Bram Moolenaar5c736222010-01-06 20:54:52 +0100338syn match shQuickComment contained "#.*$"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000339
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000340" Here Documents: {{{1
341" =========================================
Bram Moolenaar071d4272004-06-13 20:20:40 +0000342if version < 600
Bram Moolenaar541f92d2015-06-19 13:27:23 +0200343 syn region shHereDoc matchgroup=shHereDoc01 start="<<\s*\**END[a-zA-Z_0-9]*\**" matchgroup=shHereDoc01 end="^END[a-zA-Z_0-9]*$" contains=@shDblQuoteList
344 syn region shHereDoc matchgroup=shHereDoc02 start="<<-\s*\**END[a-zA-Z_0-9]*\**" matchgroup=shHereDoc02 end="^\s*END[a-zA-Z_0-9]*$" contains=@shDblQuoteList
345 syn region shHereDoc matchgroup=shHereDoc03 start="<<\s*\**EOF\**" matchgroup=shHereDoc03 end="^EOF$" contains=@shDblQuoteList
346 syn region shHereDoc matchgroup=shHereDoc04 start="<<-\s*\**EOF\**" matchgroup=shHereDoc04 end="^\s*EOF$" contains=@shDblQuoteList
347 syn region shHereDoc matchgroup=shHereDoc05 start="<<\s*\**\.\**" matchgroup=shHereDoc05 end="^\.$" contains=@shDblQuoteList
348 syn region shHereDoc matchgroup=shHereDoc06 start="<<-\s*\**\.\**" matchgroup=shHereDoc06 end="^\s*\.$" contains=@shDblQuoteList
Bram Moolenaar071d4272004-06-13 20:20:40 +0000349
Bram Moolenaar97d62492012-11-15 21:28:22 +0100350elseif s:sh_fold_heredoc
Bram Moolenaar541f92d2015-06-19 13:27:23 +0200351 syn region shHereDoc matchgroup=shHereDoc07 fold start="<<\s*\z([^ \t|]*\)" matchgroup=shHereDoc07 end="^\z1\s*$" contains=@shDblQuoteList
352 syn region shHereDoc matchgroup=shHereDoc08 fold start="<<\s*\"\z([^ \t|]*\)\"" matchgroup=shHereDoc08 end="^\z1\s*$"
353 syn region shHereDoc matchgroup=shHereDoc09 fold start="<<\s*'\z([^ \t|]*\)'" matchgroup=shHereDoc09 end="^\z1\s*$"
354 syn region shHereDoc matchgroup=shHereDoc10 fold start="<<-\s*\z([^ \t|]*\)" matchgroup=shHereDoc10 end="^\s*\z1\s*$" contains=@shDblQuoteList
355 syn region shHereDoc matchgroup=shHereDoc11 fold start="<<-\s*\"\z([^ \t|]*\)\"" matchgroup=shHereDoc11 end="^\s*\z1\s*$"
356 syn region shHereDoc matchgroup=shHereDoc12 fold start="<<-\s*'\z([^ \t|]*\)'" matchgroup=shHereDoc12 end="^\s*\z1\s*$"
357 syn region shHereDoc matchgroup=shHereDoc13 fold start="<<\s*\\\_$\_s*\z([^ \t|]*\)" matchgroup=shHereDoc13 end="^\z1\s*$"
358 syn region shHereDoc matchgroup=shHereDoc14 fold start="<<\s*\\\_$\_s*\"\z([^ \t|]*\)\"" matchgroup=shHereDoc14 end="^\z1\s*$"
359 syn region shHereDoc matchgroup=shHereDoc15 fold start="<<-\s*\\\_$\_s*'\z([^ \t|]*\)'" matchgroup=shHereDoc15 end="^\s*\z1\s*$"
360 syn region shHereDoc matchgroup=shHereDoc16 fold start="<<-\s*\\\_$\_s*\z([^ \t|]*\)" matchgroup=shHereDoc16 end="^\s*\z1\s*$"
361 syn region shHereDoc matchgroup=shHereDoc17 fold start="<<-\s*\\\_$\_s*\"\z([^ \t|]*\)\"" matchgroup=shHereDoc17 end="^\s*\z1\s*$"
362 syn region shHereDoc matchgroup=shHereDoc18 fold start="<<\s*\\\_$\_s*'\z([^ \t|]*\)'" matchgroup=shHereDoc18 end="^\z1\s*$"
363 syn region shHereDoc matchgroup=shHereDoc19 fold start="<<\\\z([^ \t|]*\)" matchgroup=shHereDoc19 end="^\z1\s*$"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000364
Bram Moolenaar071d4272004-06-13 20:20:40 +0000365else
Bram Moolenaar541f92d2015-06-19 13:27:23 +0200366 syn region shHereDoc matchgroup=shHereDoc20 start="<<\s*\\\=\z([^ \t|]*\)" matchgroup=shHereDoc20 end="^\z1\s*$" contains=@shDblQuoteList
367 syn region shHereDoc matchgroup=shHereDoc21 start="<<\s*\"\z([^ \t|]*\)\"" matchgroup=shHereDoc21 end="^\z1\s*$"
368 syn region shHereDoc matchgroup=shHereDoc22 start="<<-\s*\z([^ \t|]*\)" matchgroup=shHereDoc22 end="^\s*\z1\s*$" contains=@shDblQuoteList
369 syn region shHereDoc matchgroup=shHereDoc23 start="<<-\s*'\z([^ \t|]*\)'" matchgroup=shHereDoc23 end="^\s*\z1\s*$"
370 syn region shHereDoc matchgroup=shHereDoc24 start="<<\s*'\z([^ \t|]*\)'" matchgroup=shHereDoc24 end="^\z1\s*$"
371 syn region shHereDoc matchgroup=shHereDoc25 start="<<-\s*\"\z([^ \t|]*\)\"" matchgroup=shHereDoc25 end="^\s*\z1\s*$"
372 syn region shHereDoc matchgroup=shHereDoc26 start="<<\s*\\\_$\_s*\z([^ \t|]*\)" matchgroup=shHereDoc26 end="^\z1\s*$"
373 syn region shHereDoc matchgroup=shHereDoc27 start="<<-\s*\\\_$\_s*\z([^ \t|]*\)" matchgroup=shHereDoc27 end="^\s*\z1\s*$"
374 syn region shHereDoc matchgroup=shHereDoc28 start="<<-\s*\\\_$\_s*'\z([^ \t|]*\)'" matchgroup=shHereDoc28 end="^\s*\z1\s*$"
375 syn region shHereDoc matchgroup=shHereDoc29 start="<<\s*\\\_$\_s*'\z([^ \t|]*\)'" matchgroup=shHereDoc29 end="^\z1\s*$"
376 syn region shHereDoc matchgroup=shHereDoc30 start="<<\s*\\\_$\_s*\"\z([^ \t|]*\)\"" matchgroup=shHereDoc30 end="^\z1\s*$"
377 syn region shHereDoc matchgroup=shHereDoc31 start="<<-\s*\\\_$\_s*\"\z([^ \t|]*\)\"" matchgroup=shHereDoc31 end="^\s*\z1\s*$"
378 syn region shHereDoc matchgroup=shHereDoc32 start="<<\\\z([^ \t|]*\)" matchgroup=shHereDoc32 end="^\z1\s*$"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000379endif
380
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000381" Here Strings: {{{1
382" =============
Bram Moolenaard960d762011-09-21 19:22:10 +0200383" available for: bash; ksh (really should be ksh93 only) but not if its a posix
384if exists("b:is_bash") || (exists("b:is_kornshell") && !exists("g:is_posix"))
Bram Moolenaar97d62492012-11-15 21:28:22 +0100385 syn match shRedir "<<<" skipwhite nextgroup=shCmdParenRegion
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000386endif
387
388" Identifiers: {{{1
389"=============
Bram Moolenaarc236c162008-07-13 17:41:49 +0000390syn match shSetOption "\s\zs[-+][a-zA-Z0-9]\+\>" contained
Bram Moolenaar541f92d2015-06-19 13:27:23 +0200391syn match shVariable "\<\([bwglsav]:\)\=[a-zA-Z0-9.!@_%+,]*\ze=" nextgroup=shVarAssign
392syn match shVarAssign "=" contained nextgroup=shCmdParenRegion,shPattern,shDeref,shDerefSimple,shDoubleQuote,shExDoubleQuote,shSingleQuote,shExSingleQuote
Bram Moolenaarbc488a72013-07-05 21:01:22 +0200393syn region shAtExpr contained start="@(" end=")" contains=@shIdList
Bram Moolenaar071d4272004-06-13 20:20:40 +0000394if exists("b:is_bash")
Bram Moolenaarbc488a72013-07-05 21:01:22 +0200395 syn region shSetList oneline matchgroup=shSet start="\<\(declare\|typeset\|local\|export\|unset\)\>\ze[^/]" end="$" matchgroup=shSetListDelim end="\ze[}|);&]" matchgroup=NONE end="\ze\s\+#\|=" contains=@shIdList
396 syn region shSetList oneline matchgroup=shSet start="\<set\>\ze[^/]" end="\ze[;|)]\|$" matchgroup=shSetListDelim end="\ze[}|);&]" matchgroup=NONE end="\ze\s\+=" contains=@shIdList
Bram Moolenaar071d4272004-06-13 20:20:40 +0000397elseif exists("b:is_kornshell")
Bram Moolenaarbc488a72013-07-05 21:01:22 +0200398 syn region shSetList oneline matchgroup=shSet start="\<\(typeset\|export\|unset\)\>\ze[^/]" end="$" matchgroup=shSetListDelim end="\ze[}|);&]" matchgroup=NONE end="\ze\s\+[#=]" contains=@shIdList
399 syn region shSetList oneline matchgroup=shSet start="\<set\>\ze[^/]" end="$" matchgroup=shSetListDelim end="\ze[}|);&]" matchgroup=NONE end="\ze\s\+[#=]" contains=@shIdList
Bram Moolenaar071d4272004-06-13 20:20:40 +0000400else
Bram Moolenaarbc488a72013-07-05 21:01:22 +0200401 syn region shSetList oneline matchgroup=shSet start="\<\(set\|export\|unset\)\>\ze[^/]" end="$" matchgroup=shSetListDelim end="\ze[}|);&]" matchgroup=NONE end="\ze\s\+[#=]" contains=@shIdList
Bram Moolenaar071d4272004-06-13 20:20:40 +0000402endif
403
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000404" Functions: {{{1
Bram Moolenaarc236c162008-07-13 17:41:49 +0000405if !exists("g:is_posix")
406 syn keyword shFunctionKey function skipwhite skipnl nextgroup=shFunctionTwo
407endif
408
409if exists("b:is_bash")
Bram Moolenaar97d62492012-11-15 21:28:22 +0100410 if s:sh_fold_functions
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200411 syn region shFunctionOne fold matchgroup=shFunction start="^\s*\h[-a-zA-Z_0-9]*\s*()\_s*{" end="}" contains=@shFunctionList skipwhite skipnl nextgroup=shFunctionStart,shQuickComment
412 syn region shFunctionTwo fold matchgroup=shFunction start="\<[^d][^o]\&\h[-a-zA-Z_0-9]*\s*\%(()\)\=\_s*{" end="}" contains=shFunctionKey,@shFunctionList contained skipwhite skipnl nextgroup=shFunctionStart,shQuickComment
413 syn region shFunctionThree fold matchgroup=shFunction start="^\s*\h[-a-zA-Z_0-9]*\s*()\_s*(" end=")" contains=@shFunctionList skipwhite skipnl nextgroup=shFunctionStart,shQuickComment
414 syn region shFunctionFour fold matchgroup=shFunction start="\<[^d][^o]\&\h[-a-zA-Z_0-9]*\s*\%(()\)\=\_s*)" end=")" contains=shFunctionKey,@shFunctionList contained skipwhite skipnl nextgroup=shFunctionStart,shQuickComment
Bram Moolenaarc236c162008-07-13 17:41:49 +0000415 else
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200416 syn region shFunctionOne matchgroup=shFunction start="^\s*\h[-a-zA-Z_0-9]*\s*()\_s*{" end="}" contains=@shFunctionList
417 syn region shFunctionTwo matchgroup=shFunction start="\<[^d][^o]\&\h[-a-zA-Z_0-9]*\s*\%(()\)\=\_s*{" end="}" contains=shFunctionKey,@shFunctionList contained
418 syn region shFunctionThree matchgroup=shFunction start="^\s*\h[-a-zA-Z_0-9]*\s*()\_s*(" end=")" contains=@shFunctionList
419 syn region shFunctionFour matchgroup=shFunction start="\<[^d][^o]\&\h[-a-zA-Z_0-9]*\s*\%(()\)\=\_s*(" end=")" contains=shFunctionKey,@shFunctionList contained
Bram Moolenaarc236c162008-07-13 17:41:49 +0000420 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000421else
Bram Moolenaar97d62492012-11-15 21:28:22 +0100422 if s:sh_fold_functions
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200423 syn region shFunctionOne fold matchgroup=shFunction start="^\s*\h\w*\s*()\_s*{" end="}" contains=@shFunctionList skipwhite skipnl nextgroup=shFunctionStart,shQuickComment
424 syn region shFunctionTwo fold matchgroup=shFunction start="\<[^d][^o]\&\h\w*\s*\%(()\)\=\_s*{" end="}" contains=shFunctionKey,@shFunctionList contained skipwhite skipnl nextgroup=shFunctionStart,shQuickComment
425 syn region shFunctionThree fold matchgroup=shFunction start="^\s*\h\w*\s*()\_s*(" end=")" contains=@shFunctionList skipwhite skipnl nextgroup=shFunctionStart,shQuickComment
426 syn region shFunctionFour fold matchgroup=shFunction start="\<[^d][^o]\&\h\w*\s*\%(()\)\=\_s*(" end=")" contains=shFunctionKey,@shFunctionList contained skipwhite skipnl nextgroup=shFunctionStart,shQuickComment
Bram Moolenaarc236c162008-07-13 17:41:49 +0000427 else
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200428 syn region shFunctionOne matchgroup=shFunction start="^\s*\h\w*\s*()\_s*{" end="}" contains=@shFunctionList
429 syn region shFunctionTwo matchgroup=shFunction start="\<[^d][^o]\&\h\w*\s*\%(()\)\=\_s*{" end="}" contains=shFunctionKey,@shFunctionList contained
430 syn region shFunctionThree matchgroup=shFunction start="^\s*\h\w*\s*()\_s*(" end=")" contains=@shFunctionList
431 syn region shFunctionFour matchgroup=shFunction start="\<[^d][^o]\&\h\w*\s*\%(()\)\=\_s*(" end=")" contains=shFunctionKey,@shFunctionList contained
Bram Moolenaarc236c162008-07-13 17:41:49 +0000432 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000433endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000434
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000435" Parameter Dereferencing: {{{1
436" ========================
Bram Moolenaar97d62492012-11-15 21:28:22 +0100437syn match shDerefSimple "\$\%(\k\+\|\d\)"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000438syn region shDeref matchgroup=PreProc start="\${" end="}" contains=@shDerefList,shDerefVarArray
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100439if !exists("g:sh_no_error")
440 syn match shDerefWordError "[^}$[]" contained
441endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000442syn match shDerefSimple "\$[-#*@!?]"
443syn match shDerefSimple "\$\$"
444if exists("b:is_bash") || exists("b:is_kornshell")
445 syn region shDeref matchgroup=PreProc start="\${##\=" end="}" contains=@shDerefList
Bram Moolenaarc236c162008-07-13 17:41:49 +0000446 syn region shDeref matchgroup=PreProc start="\${\$\$" end="}" contains=@shDerefList
Bram Moolenaar071d4272004-06-13 20:20:40 +0000447endif
448
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000449" bash: ${!prefix*} and ${#parameter}: {{{1
450" ====================================
Bram Moolenaar071d4272004-06-13 20:20:40 +0000451if exists("b:is_bash")
452 syn region shDeref matchgroup=PreProc start="\${!" end="\*\=}" contains=@shDerefList,shDerefOp
Bram Moolenaar97d62492012-11-15 21:28:22 +0100453 syn match shDerefVar contained "{\@<=!\k\+" nextgroup=@shDerefVarList
Bram Moolenaar071d4272004-06-13 20:20:40 +0000454endif
455
456syn match shDerefSpecial contained "{\@<=[-*@?0]" nextgroup=shDerefOp,shDerefOpError
457syn match shDerefSpecial contained "\({[#!]\)\@<=[[:alnum:]*@_]\+" nextgroup=@shDerefVarList,shDerefOp
Bram Moolenaar97d62492012-11-15 21:28:22 +0100458syn match shDerefVar contained "{\@<=\k\+" nextgroup=@shDerefVarList
Bram Moolenaar071d4272004-06-13 20:20:40 +0000459
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000460" sh ksh bash : ${var[... ]...} array reference: {{{1
Bram Moolenaare2719092015-01-10 15:09:25 +0100461syn region shDerefVarArray contained matchgroup=shDeref start="\[" end="]" contains=@shCommandSubList nextgroup=shDerefOp,shDerefOpError
Bram Moolenaar071d4272004-06-13 20:20:40 +0000462
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000463" Special ${parameter OPERATOR word} handling: {{{1
Bram Moolenaare2719092015-01-10 15:09:25 +0100464" sh ksh bash : ${parameter:-word} word is default value
465" sh ksh bash : ${parameter:=word} assign word as default value
466" sh ksh bash : ${parameter:?word} display word if parameter is null
467" sh ksh bash : ${parameter:+word} use word if parameter is not null, otherwise nothing
468" ksh bash : ${parameter#pattern} remove small left pattern
469" ksh bash : ${parameter##pattern} remove large left pattern
470" ksh bash : ${parameter%pattern} remove small right pattern
471" ksh bash : ${parameter%%pattern} remove large right pattern
472" bash : ${parameter^pattern} Case modification
473" bash : ${parameter^^pattern} Case modification
474" bash : ${parameter,pattern} Case modification
475" bash : ${parameter,,pattern} Case modification
Bram Moolenaar071d4272004-06-13 20:20:40 +0000476syn cluster shDerefPatternList contains=shDerefPattern,shDerefString
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100477if !exists("g:sh_no_error")
478 syn match shDerefOpError contained ":[[:punct:]]"
479endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000480syn match shDerefOp contained ":\=[-=?]" nextgroup=@shDerefPatternList
481syn match shDerefOp contained ":\=+" nextgroup=@shDerefPatternList
482if exists("b:is_bash") || exists("b:is_kornshell")
483 syn match shDerefOp contained "#\{1,2}" nextgroup=@shDerefPatternList
484 syn match shDerefOp contained "%\{1,2}" nextgroup=@shDerefPatternList
Bram Moolenaar5b8d8fd2005-08-16 23:01:50 +0000485 syn match shDerefPattern contained "[^{}]\+" contains=shDeref,shDerefSimple,shDerefPattern,shDerefString,shCommandSub,shDerefEscape nextgroup=shDerefPattern
Bram Moolenaar071d4272004-06-13 20:20:40 +0000486 syn region shDerefPattern contained start="{" end="}" contains=shDeref,shDerefSimple,shDerefString,shCommandSub nextgroup=shDerefPattern
Bram Moolenaar5b8d8fd2005-08-16 23:01:50 +0000487 syn match shDerefEscape contained '\%(\\\\\)*\\.'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000488endif
Bram Moolenaard960d762011-09-21 19:22:10 +0200489if exists("b:is_bash")
490 syn match shDerefOp contained "[,^]\{1,2}" nextgroup=@shDerefPatternList
491endif
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200492syn region shDerefString contained matchgroup=shDerefDelim start=+\%(\\\)\@<!'+ end=+'+ contains=shStringSpecial
493syn region shDerefString contained matchgroup=shDerefDelim start=+\%(\\\)\@<!"+ skip=+\\"+ end=+"+ contains=@shDblQuoteList,shStringSpecial
Bram Moolenaarc236c162008-07-13 17:41:49 +0000494syn match shDerefString contained "\\["']" nextgroup=shDerefPattern
Bram Moolenaar071d4272004-06-13 20:20:40 +0000495
Bram Moolenaar071d4272004-06-13 20:20:40 +0000496if exists("b:is_bash")
Bram Moolenaar5b8d8fd2005-08-16 23:01:50 +0000497 " bash : ${parameter:offset}
498 " bash : ${parameter:offset:length}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000499 syn region shDerefOp contained start=":[$[:alnum:]_]"me=e-1 end=":"me=e-1 end="}"me=e-1 contains=@shCommandSubList nextgroup=shDerefPOL
Bram Moolenaar5b8d8fd2005-08-16 23:01:50 +0000500 syn match shDerefPOL contained ":[^}]\+" contains=@shCommandSubList
501
502 " bash : ${parameter//pattern/string}
503 " bash : ${parameter//pattern}
504 syn match shDerefPPS contained '/\{1,2}' nextgroup=shDerefPPSleft
Bram Moolenaar97d62492012-11-15 21:28:22 +0100505 syn region shDerefPPSleft contained start='.' skip=@\%(\\\\\)*\\/@ matchgroup=shDerefOp end='/' end='\ze}' nextgroup=shDerefPPSright contains=@shCommandSubList
506 syn region shDerefPPSright contained start='.' skip=@\%(\\\\\)\+@ end='\ze}' contains=@shCommandSubList
Bram Moolenaar071d4272004-06-13 20:20:40 +0000507endif
508
Bram Moolenaarc236c162008-07-13 17:41:49 +0000509" Arithmetic Parenthesized Expressions: {{{1
Bram Moolenaarbc488a72013-07-05 21:01:22 +0200510"syn region shParen matchgroup=shArithRegion start='[^$]\zs(\%(\ze[^(]\|$\)' end=')' contains=@shArithParenList
511syn region shParen matchgroup=shArithRegion start='\$\@!(\%(\ze[^(]\|$\)' end=')' contains=@shArithParenList
Bram Moolenaarc236c162008-07-13 17:41:49 +0000512
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000513" Useful sh Keywords: {{{1
514" ===================
Bram Moolenaar071d4272004-06-13 20:20:40 +0000515syn keyword shStatement break cd chdir continue eval exec exit kill newgrp pwd read readonly return shift test trap ulimit umask wait
516syn keyword shConditional contained elif else then
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100517if !exists("g:sh_no_error")
518 syn keyword shCondError elif else then
519endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000520
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000521" Useful ksh Keywords: {{{1
522" ====================
Bram Moolenaar071d4272004-06-13 20:20:40 +0000523if exists("b:is_kornshell") || exists("b:is_bash")
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200524 syn keyword shStatement autoload bg false fc fg functions getopts hash history integer jobs let nohup printf r stop suspend times true type unalias whence
Bram Moolenaarc236c162008-07-13 17:41:49 +0000525 if exists("g:is_posix")
526 syn keyword shStatement command
527 else
528 syn keyword shStatement time
529 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000530
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000531" Useful bash Keywords: {{{1
532" =====================
Bram Moolenaar071d4272004-06-13 20:20:40 +0000533 if exists("b:is_bash")
534 syn keyword shStatement bind builtin dirs disown enable help local logout popd pushd shopt source
535 else
536 syn keyword shStatement login newgrp
537 endif
538endif
539
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000540" Synchronization: {{{1
541" ================
Bram Moolenaar071d4272004-06-13 20:20:40 +0000542if !exists("sh_minlines")
543 let sh_minlines = 200
544endif
545if !exists("sh_maxlines")
546 let sh_maxlines = 2 * sh_minlines
547endif
548exec "syn sync minlines=" . sh_minlines . " maxlines=" . sh_maxlines
549syn sync match shCaseEsacSync grouphere shCaseEsac "\<case\>"
550syn sync match shCaseEsacSync groupthere shCaseEsac "\<esac\>"
551syn sync match shDoSync grouphere shDo "\<do\>"
552syn sync match shDoSync groupthere shDo "\<done\>"
553syn sync match shForSync grouphere shFor "\<for\>"
554syn sync match shForSync groupthere shFor "\<in\>"
555syn sync match shIfSync grouphere shIf "\<if\>"
556syn sync match shIfSync groupthere shIf "\<fi\>"
557syn sync match shUntilSync grouphere shRepeat "\<until\>"
558syn sync match shWhileSync grouphere shRepeat "\<while\>"
559
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000560" Default Highlighting: {{{1
561" =====================
Bram Moolenaar071d4272004-06-13 20:20:40 +0000562hi def link shArithRegion shShellVariables
Bram Moolenaarbc488a72013-07-05 21:01:22 +0200563hi def link shAtExpr shSetList
Bram Moolenaardf177f62005-02-22 08:39:57 +0000564hi def link shBeginHere shRedir
Bram Moolenaar071d4272004-06-13 20:20:40 +0000565hi def link shCaseBar shConditional
Bram Moolenaar071d4272004-06-13 20:20:40 +0000566hi def link shCaseCommandSub shCommandSub
567hi def link shCaseDoubleQuote shDoubleQuote
Bram Moolenaardf177f62005-02-22 08:39:57 +0000568hi def link shCaseIn shConditional
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200569hi def link shQuote shOperator
Bram Moolenaar071d4272004-06-13 20:20:40 +0000570hi def link shCaseSingleQuote shSingleQuote
571hi def link shCaseStart shConditional
572hi def link shCmdSubRegion shShellVariables
Bram Moolenaar5c736222010-01-06 20:54:52 +0100573hi def link shColon shComment
Bram Moolenaar071d4272004-06-13 20:20:40 +0000574hi def link shDerefOp shOperator
Bram Moolenaardf177f62005-02-22 08:39:57 +0000575hi def link shDerefPOL shDerefOp
Bram Moolenaar5b8d8fd2005-08-16 23:01:50 +0000576hi def link shDerefPPS shDerefOp
Bram Moolenaardf177f62005-02-22 08:39:57 +0000577hi def link shDeref shShellVariables
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200578hi def link shDerefDelim shOperator
Bram Moolenaar071d4272004-06-13 20:20:40 +0000579hi def link shDerefSimple shDeref
580hi def link shDerefSpecial shDeref
581hi def link shDerefString shDoubleQuote
Bram Moolenaardf177f62005-02-22 08:39:57 +0000582hi def link shDerefVar shDeref
Bram Moolenaar071d4272004-06-13 20:20:40 +0000583hi def link shDoubleQuote shString
584hi def link shEcho shString
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200585hi def link shEchoDelim shOperator
Bram Moolenaarc236c162008-07-13 17:41:49 +0000586hi def link shEchoQuote shString
Bram Moolenaar83d1b192015-04-13 14:22:40 +0200587hi def link shForPP shLoop
Bram Moolenaar071d4272004-06-13 20:20:40 +0000588hi def link shEmbeddedEcho shString
Bram Moolenaarc236c162008-07-13 17:41:49 +0000589hi def link shEscape shCommandSub
Bram Moolenaare90ee312010-08-05 22:08:47 +0200590hi def link shExDoubleQuote shDoubleQuote
Bram Moolenaardf177f62005-02-22 08:39:57 +0000591hi def link shExSingleQuote shSingleQuote
Bram Moolenaarc236c162008-07-13 17:41:49 +0000592hi def link shFunction Function
Bram Moolenaar071d4272004-06-13 20:20:40 +0000593hi def link shHereDoc shString
Bram Moolenaardf177f62005-02-22 08:39:57 +0000594hi def link shHerePayload shHereDoc
Bram Moolenaar071d4272004-06-13 20:20:40 +0000595hi def link shLoop shStatement
Bram Moolenaar5c736222010-01-06 20:54:52 +0100596hi def link shMoreSpecial shSpecial
Bram Moolenaar071d4272004-06-13 20:20:40 +0000597hi def link shOption shCommandSub
598hi def link shPattern shString
Bram Moolenaarc236c162008-07-13 17:41:49 +0000599hi def link shParen shArithmetic
Bram Moolenaar071d4272004-06-13 20:20:40 +0000600hi def link shPosnParm shShellVariables
Bram Moolenaarc236c162008-07-13 17:41:49 +0000601hi def link shQuickComment shComment
Bram Moolenaar071d4272004-06-13 20:20:40 +0000602hi def link shRange shOperator
603hi def link shRedir shOperator
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200604hi def link shSetListDelim shOperator
Bram Moolenaarc236c162008-07-13 17:41:49 +0000605hi def link shSetOption shOption
Bram Moolenaar071d4272004-06-13 20:20:40 +0000606hi def link shSingleQuote shString
607hi def link shSource shOperator
608hi def link shStringSpecial shSpecial
609hi def link shSubShRegion shOperator
610hi def link shTestOpr shConditional
Bram Moolenaar9964e462007-05-05 17:54:07 +0000611hi def link shTestPattern shString
612hi def link shTestDoubleQuote shString
613hi def link shTestSingleQuote shString
Bram Moolenaar071d4272004-06-13 20:20:40 +0000614hi def link shVariable shSetList
615hi def link shWrapLineOperator shOperator
616
617if exists("b:is_bash")
618 hi def link bashAdminStatement shStatement
619 hi def link bashSpecialVariables shShellVariables
620 hi def link bashStatement shStatement
Bram Moolenaarcd71fa32005-03-11 22:46:48 +0000621 hi def link shFunctionParen Delimiter
622 hi def link shFunctionDelim Delimiter
Bram Moolenaar97d62492012-11-15 21:28:22 +0100623 hi def link shCharClass shSpecial
Bram Moolenaar071d4272004-06-13 20:20:40 +0000624endif
625if exists("b:is_kornshell")
626 hi def link kshSpecialVariables shShellVariables
627 hi def link kshStatement shStatement
Bram Moolenaarcd71fa32005-03-11 22:46:48 +0000628 hi def link shFunctionParen Delimiter
Bram Moolenaar071d4272004-06-13 20:20:40 +0000629endif
630
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100631if !exists("g:sh_no_error")
632 hi def link shCaseError Error
633 hi def link shCondError Error
634 hi def link shCurlyError Error
635 hi def link shDerefError Error
636 hi def link shDerefOpError Error
637 hi def link shDerefWordError Error
638 hi def link shDoError Error
639 hi def link shEsacError Error
640 hi def link shIfError Error
641 hi def link shInError Error
642 hi def link shParenError Error
643 hi def link shTestError Error
644 if exists("b:is_kornshell")
645 hi def link shDTestError Error
646 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000647endif
648
649hi def link shArithmetic Special
650hi def link shCharClass Identifier
651hi def link shSnglCase Statement
652hi def link shCommandSub Special
653hi def link shComment Comment
654hi def link shConditional Conditional
Bram Moolenaar9964e462007-05-05 17:54:07 +0000655hi def link shCtrlSeq Special
Bram Moolenaar071d4272004-06-13 20:20:40 +0000656hi def link shExprRegion Delimiter
Bram Moolenaarcd71fa32005-03-11 22:46:48 +0000657hi def link shFunctionKey Function
Bram Moolenaar071d4272004-06-13 20:20:40 +0000658hi def link shFunctionName Function
659hi def link shNumber Number
660hi def link shOperator Operator
661hi def link shRepeat Repeat
662hi def link shSet Statement
663hi def link shSetList Identifier
664hi def link shShellVariables PreProc
665hi def link shSpecial Special
666hi def link shStatement Statement
667hi def link shString String
668hi def link shTodo Todo
669hi def link shAlias Identifier
Bram Moolenaar541f92d2015-06-19 13:27:23 +0200670hi def link shHereDoc01 shRedir
671hi def link shHereDoc02 shRedir
672hi def link shHereDoc03 shRedir
673hi def link shHereDoc04 shRedir
674hi def link shHereDoc05 shRedir
675hi def link shHereDoc06 shRedir
676hi def link shHereDoc07 shRedir
677hi def link shHereDoc08 shRedir
678hi def link shHereDoc09 shRedir
679hi def link shHereDoc10 shRedir
680hi def link shHereDoc11 shRedir
681hi def link shHereDoc12 shRedir
682hi def link shHereDoc13 shRedir
683hi def link shHereDoc14 shRedir
684hi def link shHereDoc15 shRedir
685hi def link shHereDoc16 shRedir
686hi def link shHereDoc17 shRedir
687hi def link shHereDoc18 shRedir
688hi def link shHereDoc19 shRedir
689hi def link shHereDoc20 shRedir
690hi def link shHereDoc21 shRedir
691hi def link shHereDoc22 shRedir
692hi def link shHereDoc23 shRedir
693hi def link shHereDoc24 shRedir
694hi def link shHereDoc25 shRedir
695hi def link shHereDoc26 shRedir
696hi def link shHereDoc27 shRedir
697hi def link shHereDoc28 shRedir
698hi def link shHereDoc29 shRedir
699hi def link shHereDoc30 shRedir
700hi def link shHereDoc31 shRedir
701hi def link shHereDoc32 shRedir
Bram Moolenaar071d4272004-06-13 20:20:40 +0000702
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000703" Set Current Syntax: {{{1
704" ===================
Bram Moolenaar071d4272004-06-13 20:20:40 +0000705if exists("b:is_bash")
706 let b:current_syntax = "bash"
707elseif exists("b:is_kornshell")
708 let b:current_syntax = "ksh"
709else
710 let b:current_syntax = "sh"
711endif
712
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000713" vim: ts=16 fdm=marker