blob: 2fe13fbde672994745d7d07bc06e5cfdf72103a6 [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 Moolenaare4a3bcf2016-08-26 19:52:37 +02005" Last Change: Aug 23, 2016
6" Version: 161
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 Moolenaarb4ff5182015-11-10 21:15:48 +01009" This file includes many ideas from Eric 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
Bram Moolenaar802a0d92016-06-26 16:17:58 +020013if v:version < 600
Bram Moolenaar071d4272004-06-13 20:20:40 +000014 syntax clear
15elseif exists("b:current_syntax")
16 finish
17endif
18
Bram Moolenaard960d762011-09-21 19:22:10 +020019" trying to answer the question: which shell is /bin/sh, really?
Bram Moolenaar97d62492012-11-15 21:28:22 +010020" If the user has not specified any of g:is_kornshell, g:is_bash, g:is_posix, g:is_sh, then guess.
Bram Moolenaar91c49372016-05-08 09:50:29 +020021if getline(1) =~ '\<ksh$'
22 let b:is_kornshell = 1
23elseif getline(1) =~ '\<bash$'
24 let b:is_bash = 1
25elseif getline(1) =~ '\<dash$'
26 let b:is_posix = 1
27elseif !exists("g:is_kornshell") && !exists("g:is_bash") && !exists("g:is_posix") && !exists("g:is_sh")
Bram Moolenaarbc488a72013-07-05 21:01:22 +020028 let s:shell = ""
Bram Moolenaard960d762011-09-21 19:22:10 +020029 if executable("/bin/sh")
Bram Moolenaarbc488a72013-07-05 21:01:22 +020030 let s:shell = resolve("/bin/sh")
Bram Moolenaard960d762011-09-21 19:22:10 +020031 elseif executable("/usr/bin/sh")
Bram Moolenaarbc488a72013-07-05 21:01:22 +020032 let s:shell = resolve("/usr/bin/sh")
Bram Moolenaard960d762011-09-21 19:22:10 +020033 endif
Bram Moolenaar91c49372016-05-08 09:50:29 +020034 if s:shell =~ 'ksh$'
35 let b:is_kornshell= 1
36 elseif s:shell =~ 'bash$'
37 let b:is_bash = 1
Bram Moolenaarbc488a72013-07-05 21:01:22 +020038 elseif s:shell =~ 'dash$'
Bram Moolenaar91c49372016-05-08 09:50:29 +020039 let b:is_posix = 1
Bram Moolenaarbc488a72013-07-05 21:01:22 +020040 endif
41 unlet s:shell
Bram Moolenaard960d762011-09-21 19:22:10 +020042endif
43
Bram Moolenaard4755bb2004-09-02 19:12:26 +000044" handling /bin/sh with is_kornshell/is_sh {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +000045" b:is_sh is set when "#! /bin/sh" is found;
46" However, it often is just a masquerade by bash (typically Linux)
47" or kornshell (typically workstations with Posix "sh").
Bram Moolenaard960d762011-09-21 19:22:10 +020048" So, when the user sets "g:is_bash", "g:is_kornshell",
49" or "g:is_posix", a b:is_sh is converted into b:is_bash/b:is_kornshell,
Bram Moolenaar071d4272004-06-13 20:20:40 +000050" respectively.
51if !exists("b:is_kornshell") && !exists("b:is_bash")
Bram Moolenaar7fc904b2006-04-13 20:37:35 +000052 if exists("g:is_posix") && !exists("g:is_kornshell")
53 let g:is_kornshell= g:is_posix
54 endif
55 if exists("g:is_kornshell")
Bram Moolenaar071d4272004-06-13 20:20:40 +000056 let b:is_kornshell= 1
57 if exists("b:is_sh")
58 unlet b:is_sh
59 endif
Bram Moolenaar7fc904b2006-04-13 20:37:35 +000060 elseif exists("g:is_bash")
Bram Moolenaar071d4272004-06-13 20:20:40 +000061 let b:is_bash= 1
62 if exists("b:is_sh")
63 unlet b:is_sh
64 endif
65 else
66 let b:is_sh= 1
67 endif
68endif
69
Bram Moolenaarcd71fa32005-03-11 22:46:48 +000070" set up default g:sh_fold_enabled {{{1
Bram Moolenaarb4ff5182015-11-10 21:15:48 +010071" ================================
Bram Moolenaar071d4272004-06-13 20:20:40 +000072if !exists("g:sh_fold_enabled")
73 let g:sh_fold_enabled= 0
Bram Moolenaar293ee4d2004-12-09 21:34:53 +000074elseif g:sh_fold_enabled != 0 && !has("folding")
75 let g:sh_fold_enabled= 0
Bram Moolenaarcd71fa32005-03-11 22:46:48 +000076 echomsg "Ignoring g:sh_fold_enabled=".g:sh_fold_enabled."; need to re-compile vim for +fold support"
77endif
Bram Moolenaarc236c162008-07-13 17:41:49 +000078if !exists("s:sh_fold_functions")
Bram Moolenaar97d62492012-11-15 21:28:22 +010079 let s:sh_fold_functions= and(g:sh_fold_enabled,1)
Bram Moolenaarc236c162008-07-13 17:41:49 +000080endif
81if !exists("s:sh_fold_heredoc")
Bram Moolenaar97d62492012-11-15 21:28:22 +010082 let s:sh_fold_heredoc = and(g:sh_fold_enabled,2)
Bram Moolenaarc236c162008-07-13 17:41:49 +000083endif
84if !exists("s:sh_fold_ifdofor")
Bram Moolenaar97d62492012-11-15 21:28:22 +010085 let s:sh_fold_ifdofor = and(g:sh_fold_enabled,4)
Bram Moolenaarc236c162008-07-13 17:41:49 +000086endif
Bram Moolenaarcd71fa32005-03-11 22:46:48 +000087if g:sh_fold_enabled && &fdm == "manual"
Bram Moolenaar97d62492012-11-15 21:28:22 +010088 " Given that the user provided g:sh_fold_enabled
89 " AND g:sh_fold_enabled is manual (usual default)
90 " implies a desire for syntax-based folding
91 setl fdm=syntax
Bram Moolenaar071d4272004-06-13 20:20:40 +000092endif
93
Bram Moolenaare0fa3742016-02-20 15:47:01 +010094" set up the syntax-highlighting iskeyword
Bram Moolenaar91c49372016-05-08 09:50:29 +020095if has("patch-7.4.1142")
96 if exists("b:is_bash")
97 exe "syn iskeyword ".&iskeyword.",-,:"
98 else
99 exe "syn iskeyword ".&iskeyword.",-"
100 endif
Bram Moolenaare0fa3742016-02-20 15:47:01 +0100101endif
102
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100103" Set up folding commands for shell {{{1
104" =================================
105if s:sh_fold_functions
106 com! -nargs=* ShFoldFunctions <args> fold
107else
108 com! -nargs=* ShFoldFunctions <args>
109endif
110if s:sh_fold_heredoc
111 com! -nargs=* ShFoldHereDoc <args> fold
112else
113 com! -nargs=* ShFoldHereDoc <args>
114endif
115if s:sh_fold_ifdofor
116 com! -nargs=* ShFoldIfDoFor <args> fold
117else
118 com! -nargs=* ShFoldIfDoFor <args>
119endif
120
Bram Moolenaarcd71fa32005-03-11 22:46:48 +0000121" sh syntax is case sensitive {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000122syn case match
123
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000124" Clusters: contains=@... clusters {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000125"==================================
Bram Moolenaar5c736222010-01-06 20:54:52 +0100126syn cluster shErrorList contains=shDoError,shIfError,shInError,shCaseError,shEsacError,shCurlyError,shParenError,shTestError,shOK
Bram Moolenaarc236c162008-07-13 17:41:49 +0000127if exists("b:is_kornshell")
128 syn cluster ErrorList add=shDTestError
129endif
Bram Moolenaare4a3bcf2016-08-26 19:52:37 +0200130syn 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
Bram Moolenaarc236c162008-07-13 17:41:49 +0000131syn cluster shArithList contains=@shArithParenList,shParenError
Bram Moolenaar5c736222010-01-06 20:54:52 +0100132syn cluster shCaseEsacList contains=shCaseStart,shCase,shCaseBar,shCaseIn,shComment,shDeref,shDerefSimple,shCaseCommandSub,shCaseExSingleQuote,shCaseSingleQuote,shCaseDoubleQuote,shCtrlSeq,@shErrorList,shStringSpecial,shCaseRange
Bram Moolenaare4a3bcf2016-08-26 19:52:37 +0200133syn cluster shCaseList contains=@shCommandSubList,shCaseEsac,shColon,shCommandSub,shComment,shDo,shEcho,shExpr,shFor,shHereDoc,shIf,shHereString,shRedir,shSetList,shSource,shStatement,shVariable,shCtrlSeq
134syn cluster shCommandSubList contains=shAlias,shArithmetic,shComment,shCmdParenRegion,shCtrlSeq,shDeref,shDerefSimple,shDoubleQuote,shEcho,shEscape,shExDoubleQuote,shExpr,shExSingleQuote,shHereDoc,shNumber,shOperator,shOption,shPosnParm,shHereString,shRedir,shSingleQuote,shSpecial,shStatement,shSubSh,shTest,shVariable
Bram Moolenaar572cb562005-08-05 21:35:02 +0000135syn cluster shCurlyList contains=shNumber,shComma,shDeref,shDerefSimple,shDerefSpecial
Bram Moolenaar97d62492012-11-15 21:28:22 +0100136syn cluster shDblQuoteList contains=shCommandSub,shDeref,shDerefSimple,shEscape,shPosnParm,shCtrlSeq,shSpecial
Bram Moolenaaracb4f222016-01-10 15:59:26 +0100137syn cluster shDerefList contains=shDeref,shDerefSimple,shDerefVar,shDerefSpecial,shDerefWordError,shDerefPSR,shDerefPPS
Bram Moolenaarbc8801c2016-08-02 21:04:33 +0200138syn cluster shDerefVarList contains=shDerefOff,shDerefOp,shDerefVarArray,shDerefOpError
Bram Moolenaar97d62492012-11-15 21:28:22 +0100139syn cluster shEchoList contains=shArithmetic,shCommandSub,shDeref,shDerefSimple,shEscape,shExpr,shExSingleQuote,shExDoubleQuote,shSingleQuote,shDoubleQuote,shCtrlSeq,shEchoQuote
Bram Moolenaare90ee312010-08-05 22:08:47 +0200140syn cluster shExprList1 contains=shCharClass,shNumber,shOperator,shExSingleQuote,shExDoubleQuote,shSingleQuote,shDoubleQuote,shExpr,shDblBrace,shDeref,shDerefSimple,shCtrlSeq
Bram Moolenaar383f9bc2005-01-19 22:18:32 +0000141syn cluster shExprList2 contains=@shExprList1,@shCaseList,shTest
Bram Moolenaare4a3bcf2016-08-26 19:52:37 +0200142syn cluster shFunctionList contains=@shCommandSubList,shCaseEsac,shColon,shCommandSub,shComment,shDo,shEcho,shExpr,shFor,shHereDoc,shIf,shOption,shHereString,shRedir,shSetList,shSource,shStatement,shVariable,shOperator,shCtrlSeq
Bram Moolenaar7263a772007-05-10 17:35:54 +0000143if exists("b:is_kornshell") || exists("b:is_bash")
Bram Moolenaarc236c162008-07-13 17:41:49 +0000144 syn cluster shFunctionList add=shRepeat
Bram Moolenaar7263a772007-05-10 17:35:54 +0000145 syn cluster shFunctionList add=shDblBrace,shDblParen
146endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000147syn cluster shHereBeginList contains=@shCommandSubList
148syn cluster shHereList contains=shBeginHere,shHerePayload
149syn cluster shHereListDQ contains=shBeginHere,@shDblQuoteList,shHerePayload
Bram Moolenaare4a3bcf2016-08-26 19:52:37 +0200150syn cluster shIdList contains=shCommandSub,shWrapLineOperator,shSetOption,shDeref,shDerefSimple,shHereString,shRedir,shExSingleQuote,shExDoubleQuote,shSingleQuote,shDoubleQuote,shExpr,shCtrlSeq,shStringSpecial,shAtExpr
151syn cluster shIfList contains=@shLoopList,shDblBrace,shDblParen,shFunctionKey,shFunctionOne,shFunctionTwo,shParen
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100152syn cluster shLoopList contains=@shCaseList,@shErrorList,shCaseEsac,shConditional,shDblBrace,shExpr,shFor,shForPP,shIf,shOption,shSet,shTest,shTestOpr,shTouch
Bram Moolenaar91c49372016-05-08 09:50:29 +0200153syn cluster shPPSRightList contains=shComment,shDeref,shDerefSimple,shEscape,shPosnParm
Bram Moolenaare4a3bcf2016-08-26 19:52:37 +0200154syn cluster shSubShList contains=@shCommandSubList,shCaseEsac,shColon,shCommandSub,shComment,shDo,shEcho,shExpr,shFor,shIf,shHereString,shRedir,shSetList,shSource,shStatement,shVariable,shCtrlSeq,shOperator
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200155syn cluster shTestList contains=shCharClass,shCommandSub,shCtrlSeq,shDeref,shDerefSimple,shDoubleQuote,shExDoubleQuote,shExpr,shExSingleQuote,shNumber,shOperator,shSingleQuote,shTest,shTestOpr
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100156
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000157" Echo: {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000158" ====
159" This one is needed INSIDE a CommandSub, so that `echo bla` be correct
Bram Moolenaarbc488a72013-07-05 21:01:22 +0200160syn 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
161syn 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 +0100162syn match shEchoQuote contained '\%(\\\\\)*\\["`'()]'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000163
Bram Moolenaarc236c162008-07-13 17:41:49 +0000164" This must be after the strings, so that ... \" will be correct
Bram Moolenaare90ee312010-08-05 22:08:47 +0200165syn 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 +0000166
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000167" Alias: {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000168" =====
169if exists("b:is_kornshell") || exists("b:is_bash")
170 syn match shStatement "\<alias\>"
Bram Moolenaard960d762011-09-21 19:22:10 +0200171 syn region shAlias matchgroup=shStatement start="\<alias\>\s\+\(\h[-._[:alnum:]]\+\)\@=" skip="\\$" end="\>\|`"
172 syn region shAlias matchgroup=shStatement start="\<alias\>\s\+\(\h[-._[:alnum:]]\+=\)\@=" skip="\\$" end="="
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100173
174 " Touch: {{{1
175 " =====
Bram Moolenaar802a0d92016-06-26 16:17:58 +0200176 syn match shTouch '\<touch\>[^;#]*' skipwhite nextgroup=shComment contains=shTouchCmd
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100177 syn match shTouchCmd '\<touch\>' contained
Bram Moolenaar071d4272004-06-13 20:20:40 +0000178endif
179
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000180" Error Codes: {{{1
181" ============
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100182if !exists("g:sh_no_error")
Bram Moolenaare2719092015-01-10 15:09:25 +0100183 syn match shDoError "\<done\>"
184 syn match shIfError "\<fi\>"
185 syn match shInError "\<in\>"
186 syn match shCaseError ";;"
187 syn match shEsacError "\<esac\>"
188 syn match shCurlyError "}"
189 syn match shParenError ")"
190 syn match shOK '\.\(done\|fi\|in\|esac\)'
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100191 if exists("b:is_kornshell")
Bram Moolenaare2719092015-01-10 15:09:25 +0100192 syn match shDTestError "]]"
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100193 endif
Bram Moolenaare2719092015-01-10 15:09:25 +0100194 syn match shTestError "]"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000195endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000196
Bram Moolenaarc236c162008-07-13 17:41:49 +0000197" Options: {{{1
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000198" ====================
Bram Moolenaar7db8f6f2016-03-29 23:12:46 +0200199syn match shOption "\s\zs[-+][-_a-zA-Z#@]\+"
Bram Moolenaarbc488a72013-07-05 21:01:22 +0200200syn match shOption "\s\zs--[^ \t$`'"|);]\+"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000201
Bram Moolenaar7263a772007-05-10 17:35:54 +0000202" File Redirection Highlighted As Operators: {{{1
203"===========================================
204syn match shRedir "\d\=>\(&[-0-9]\)\="
205syn match shRedir "\d\=>>-\="
206syn match shRedir "\d\=<\(&[-0-9]\)\="
207syn match shRedir "\d<<-\="
208
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000209" Operators: {{{1
210" ==========
Bram Moolenaar7263a772007-05-10 17:35:54 +0000211syn match shOperator "<<\|>>" contained
Bram Moolenaarc236c162008-07-13 17:41:49 +0000212syn match shOperator "[!&;|]" contained
213syn match shOperator "\[[[^:]\|\]]" contained
Bram Moolenaar541f92d2015-06-19 13:27:23 +0200214syn match shOperator "[-=/*+%]\==" skipwhite nextgroup=shPattern
Bram Moolenaare90ee312010-08-05 22:08:47 +0200215syn match shPattern "\<\S\+\())\)\@=" contained contains=shExSingleQuote,shSingleQuote,shExDoubleQuote,shDoubleQuote,shDeref
Bram Moolenaar071d4272004-06-13 20:20:40 +0000216
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000217" Subshells: {{{1
218" ==========
Bram Moolenaare4a3bcf2016-08-26 19:52:37 +0200219syn region shExpr transparent matchgroup=shExprRegion start="{" end="}" contains=@shExprList2 nextgroup=shSpecialNxt
220syn region shSubSh transparent matchgroup=shSubShRegion start="[^(]\zs(" end=")" contains=@shSubShList nextgroup=shSpecialNxt
Bram Moolenaar071d4272004-06-13 20:20:40 +0000221
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000222" Tests: {{{1
223"=======
Bram Moolenaar00a927d2010-05-14 23:24:24 +0200224syn region shExpr matchgroup=shRange start="\[" skip=+\\\\\|\\$\|\[+ end="\]" contains=@shTestList,shSpecial
Bram Moolenaar5c736222010-01-06 20:54:52 +0100225syn region shTest transparent matchgroup=shStatement start="\<test\s" skip=+\\\\\|\\$+ matchgroup=NONE end="[;&|]"me=e-1 end="$" contains=@shExprList1
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100226syn region shNoQuote start='\S' skip='\%(\\\\\)*\\.' end='\ze\s' contained
Bram Moolenaar91c49372016-05-08 09:50:29 +0200227syn match shAstQuote contained '\*\ze"' nextgroup=shString
Bram Moolenaar541f92d2015-06-19 13:27:23 +0200228syn match shTestOpr contained '[^-+/%]\zs=' skipwhite nextgroup=shTestDoubleQuote,shTestSingleQuote,shTestPattern
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100229syn match shTestOpr contained "<=\|>=\|!=\|==\|=\~\|-.\>\|-\(nt\|ot\|ef\|eq\|ne\|lt\|le\|gt\|ge\)\>\|[!<>]"
Bram Moolenaar9964e462007-05-05 17:54:07 +0000230syn match shTestPattern contained '\w\+'
Bram Moolenaar91c49372016-05-08 09:50:29 +0200231syn region shTestDoubleQuote contained start='\%(\%(\\\\\)*\\\)\@<!"' skip=+\\\\\|\\"+ end='"' contains=shDeref,shDerefSimple,shDerefSpecial
Bram Moolenaar9964e462007-05-05 17:54:07 +0000232syn match shTestSingleQuote contained '\\.'
233syn match shTestSingleQuote contained "'[^']*'"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000234if exists("b:is_kornshell") || exists("b:is_bash")
Bram Moolenaar91c49372016-05-08 09:50:29 +0200235 syn region shDblBrace matchgroup=Delimiter start="\[\[" skip=+\%(\\\\\)*\\$+ end="\]\]" contains=@shTestList,shAstQuote,shNoQuote,shComment
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100236 syn region shDblParen matchgroup=Delimiter start="((" skip=+\%(\\\\\)*\\$+ end="))" contains=@shTestList,shComment
Bram Moolenaar071d4272004-06-13 20:20:40 +0000237endif
238
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000239" Character Class In Range: {{{1
240" =========================
Bram Moolenaar071d4272004-06-13 20:20:40 +0000241syn match shCharClass contained "\[:\(backspace\|escape\|return\|xdigit\|alnum\|alpha\|blank\|cntrl\|digit\|graph\|lower\|print\|punct\|space\|upper\|tab\):\]"
242
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000243" Loops: do, if, while, until {{{1
244" ======
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100245ShFoldIfDoFor syn region shDo transparent matchgroup=shConditional start="\<do\>" matchgroup=shConditional end="\<done\>" contains=@shLoopList
246ShFoldIfDoFor syn region shIf transparent matchgroup=shConditional start="\<if\_s" matchgroup=shConditional skip=+-fi\>+ end="\<;\_s*then\>" end="\<fi\>" contains=@shIfList
247ShFoldIfDoFor syn region shFor matchgroup=shLoop start="\<for\ze\_s\s*\%(((\)\@!" end="\<in\>" end="\<do\>"me=e-2 contains=@shLoopList,shDblParen skipwhite nextgroup=shCurlyIn
248ShFoldIfDoFor syn region shForPP matchgroup=shLoop start='\<for\>\_s*((' end='))' contains=shTestOpr
249
Bram Moolenaar071d4272004-06-13 20:20:40 +0000250if exists("b:is_kornshell") || exists("b:is_bash")
Bram Moolenaarc236c162008-07-13 17:41:49 +0000251 syn cluster shCaseList add=shRepeat
252 syn cluster shFunctionList add=shRepeat
253 syn region shRepeat matchgroup=shLoop start="\<while\_s" end="\<in\_s" end="\<do\>"me=e-2 contains=@shLoopList,shDblParen,shDblBrace
254 syn region shRepeat matchgroup=shLoop start="\<until\_s" end="\<in\_s" end="\<do\>"me=e-2 contains=@shLoopList,shDblParen,shDblBrace
255 syn region shCaseEsac matchgroup=shConditional start="\<select\s" matchgroup=shConditional end="\<in\>" end="\<do\>" contains=@shLoopList
Bram Moolenaar071d4272004-06-13 20:20:40 +0000256else
Bram Moolenaarc236c162008-07-13 17:41:49 +0000257 syn region shRepeat matchgroup=shLoop start="\<while\_s" end="\<do\>"me=e-2 contains=@shLoopList
258 syn region shRepeat matchgroup=shLoop start="\<until\_s" end="\<do\>"me=e-2 contains=@shLoopList
Bram Moolenaar071d4272004-06-13 20:20:40 +0000259endif
Bram Moolenaar572cb562005-08-05 21:35:02 +0000260syn region shCurlyIn contained matchgroup=Delimiter start="{" end="}" contains=@shCurlyList
261syn match shComma contained ","
Bram Moolenaar071d4272004-06-13 20:20:40 +0000262
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000263" Case: case...esac {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000264" ====
Bram Moolenaarc236c162008-07-13 17:41:49 +0000265syn match shCaseBar contained skipwhite "\(^\|[^\\]\)\(\\\\\)*\zs|" nextgroup=shCase,shCaseStart,shCaseBar,shComment,shCaseExSingleQuote,shCaseSingleQuote,shCaseDoubleQuote
Bram Moolenaar071d4272004-06-13 20:20:40 +0000266syn match shCaseStart contained skipwhite skipnl "(" nextgroup=shCase,shCaseBar
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100267ShFoldIfDoFor syn region shCase contained skipwhite skipnl matchgroup=shSnglCase start="\%(\\.\|[^#$()'" \t]\)\{-}\zs)" end=";;" end="esac"me=s-1 contains=@shCaseList nextgroup=shCaseStart,shCase,shComment
268ShFoldIfDoFor syn region shCaseEsac matchgroup=shConditional start="\<case\>" end="\<esac\>" contains=@shCaseEsacList
269
Bram Moolenaardf177f62005-02-22 08:39:57 +0000270syn keyword shCaseIn contained skipwhite skipnl in nextgroup=shCase,shCaseStart,shCaseBar,shComment,shCaseExSingleQuote,shCaseSingleQuote,shCaseDoubleQuote
271if exists("b:is_bash")
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200272 syn region shCaseExSingleQuote matchgroup=shQuote start=+\$'+ skip=+\\\\\|\\.+ end=+'+ contains=shStringSpecial,shSpecial skipwhite skipnl nextgroup=shCaseBar contained
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100273elseif !exists("g:sh_no_error")
Bram Moolenaardf177f62005-02-22 08:39:57 +0000274 syn region shCaseExSingleQuote matchgroup=Error start=+\$'+ skip=+\\\\\|\\.+ end=+'+ contains=shStringSpecial skipwhite skipnl nextgroup=shCaseBar contained
275endif
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200276syn region shCaseSingleQuote matchgroup=shQuote start=+'+ end=+'+ contains=shStringSpecial skipwhite skipnl nextgroup=shCaseBar contained
277syn region shCaseDoubleQuote matchgroup=shQuote start=+"+ skip=+\\\\\|\\.+ end=+"+ contains=@shDblQuoteList,shStringSpecial skipwhite skipnl nextgroup=shCaseBar contained
Bram Moolenaar071d4272004-06-13 20:20:40 +0000278syn region shCaseCommandSub start=+`+ skip=+\\\\\|\\.+ end=+`+ contains=@shCommandSubList skipwhite skipnl nextgroup=shCaseBar contained
Bram Moolenaar97d62492012-11-15 21:28:22 +0100279if exists("b:is_bash")
280 syn region shCaseRange matchgroup=Delimiter start=+\[+ skip=+\\\\+ end=+\]+ contained contains=shCharClass
281 syn match shCharClass '\[:\%(alnum\|alpha\|ascii\|blank\|cntrl\|digit\|graph\|lower\|print\|punct\|space\|upper\|word\|or\|xdigit\):\]' contained
282else
283 syn region shCaseRange matchgroup=Delimiter start=+\[+ skip=+\\\\+ end=+\]+ contained
284endif
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000285" Misc: {{{1
286"======
Bram Moolenaar071d4272004-06-13 20:20:40 +0000287syn match shWrapLineOperator "\\$"
Bram Moolenaar97d62492012-11-15 21:28:22 +0100288syn region shCommandSub start="`" skip="\\\\\|\\." end="`" contains=@shCommandSubList
Bram Moolenaarbc488a72013-07-05 21:01:22 +0200289syn match shEscape contained '\%(^\)\@!\%(\\\\\)*\\.'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000290
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000291" $() and $(()): {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000292" $(..) is not supported by sh (Bourne shell). However, apparently
293" some systems (HP?) have as their /bin/sh a (link to) Korn shell
294" (ie. Posix compliant shell). /bin/ksh should work for those
295" systems too, however, so the following syntax will flag $(..) as
296" an Error under /bin/sh. By consensus of vimdev'ers!
297if exists("b:is_kornshell") || exists("b:is_bash")
298 syn region shCommandSub matchgroup=shCmdSubRegion start="\$(" skip='\\\\\|\\.' end=")" contains=@shCommandSubList
Bram Moolenaarc236c162008-07-13 17:41:49 +0000299 syn region shArithmetic matchgroup=shArithRegion start="\$((" skip='\\\\\|\\.' end="))" contains=@shArithList
Bram Moolenaar61d35bd2012-03-28 20:51:51 +0200300 syn region shArithmetic matchgroup=shArithRegion start="\$\[" skip='\\\\\|\\.' end="\]" contains=@shArithList
Bram Moolenaar071d4272004-06-13 20:20:40 +0000301 syn match shSkipInitWS contained "^\s\+"
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100302elseif !exists("g:sh_no_error")
Bram Moolenaardf177f62005-02-22 08:39:57 +0000303 syn region shCommandSub matchgroup=Error start="\$(" end=")" contains=@shCommandSubList
Bram Moolenaar071d4272004-06-13 20:20:40 +0000304endif
Bram Moolenaare2719092015-01-10 15:09:25 +0100305syn region shCmdParenRegion matchgroup=shCmdSubRegion start="(\ze[^(]" skip='\\\\\|\\.' end=")" contains=@shCommandSubList
Bram Moolenaar071d4272004-06-13 20:20:40 +0000306
307if exists("b:is_bash")
308 syn cluster shCommandSubList add=bashSpecialVariables,bashStatement
309 syn cluster shCaseList add=bashAdminStatement,bashStatement
Bram Moolenaard960d762011-09-21 19:22:10 +0200310 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 Moolenaarb4ff5182015-11-10 21:15:48 +0100311 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
Bram Moolenaar071d4272004-06-13 20:20:40 +0000312 syn keyword bashAdminStatement daemon killall killproc nice reload restart start status stop
Bram Moolenaar97d62492012-11-15 21:28:22 +0100313 syn keyword bashStatement command compgen
Bram Moolenaar071d4272004-06-13 20:20:40 +0000314endif
315
316if exists("b:is_kornshell")
317 syn cluster shCommandSubList add=kshSpecialVariables,kshStatement
318 syn cluster shCaseList add=kshStatement
319 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 Moolenaarb4ff5182015-11-10 21:15:48 +0100320 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
Bram Moolenaar97d62492012-11-15 21:28:22 +0100321 syn keyword kshStatement command setgroups setsenv
Bram Moolenaar071d4272004-06-13 20:20:40 +0000322endif
323
324syn match shSource "^\.\s"
325syn match shSource "\s\.\s"
Bram Moolenaar5c736222010-01-06 20:54:52 +0100326"syn region shColon start="^\s*:" end="$" end="\s#"me=e-2 contains=@shColonList
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100327"syn region shColon start="^\s*\zs:" end="$" end="\s#"me=e-2
Bram Moolenaar91c49372016-05-08 09:50:29 +0200328if exists("b:is_kornshell")
329 syn match shColon '^\s*\zs:'
330endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000331
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000332" String And Character Constants: {{{1
333"================================
Bram Moolenaar7db8f6f2016-03-29 23:12:46 +0200334syn match shNumber "\<\d\+\>#\="
Bram Moolenaarbc8801c2016-08-02 21:04:33 +0200335syn match shNumber "\<-\=\.\=\d\+\>#\="
Bram Moolenaar802a0d92016-06-26 16:17:58 +0200336syn match shCtrlSeq "\\\d\d\d\|\\[abcfnrtv0]" contained
Bram Moolenaardf177f62005-02-22 08:39:57 +0000337if exists("b:is_bash")
Bram Moolenaar802a0d92016-06-26 16:17:58 +0200338 syn match shSpecial "[^\\]\(\\\\\)*\zs\\\o\o\o\|\\x\x\x\|\\c[^"]\|\\[abefnrtv]" contained
339 syn match shSpecial "^\(\\\\\)*\zs\\\o\o\o\|\\x\x\x\|\\c[^"]\|\\[abefnrtv]" contained
Bram Moolenaardf177f62005-02-22 08:39:57 +0000340endif
341if exists("b:is_bash")
Bram Moolenaare4a3bcf2016-08-26 19:52:37 +0200342 syn region shExSingleQuote matchgroup=shQuote start=+\$'+ skip=+\\\\\|\\.+ end=+'+ contains=shStringSpecial,shSpecial nextgroup=shSpecialNxt
343 syn region shExDoubleQuote matchgroup=shQuote start=+\$"+ skip=+\\\\\|\\.\|\\"+ end=+"+ contains=@shDblQuoteList,shStringSpecial,shSpecial nextgroup=shSpecialNxt
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100344elseif !exists("g:sh_no_error")
Bram Moolenaar9964e462007-05-05 17:54:07 +0000345 syn region shExSingleQuote matchGroup=Error start=+\$'+ skip=+\\\\\|\\.+ end=+'+ contains=shStringSpecial
Bram Moolenaare90ee312010-08-05 22:08:47 +0200346 syn region shExDoubleQuote matchGroup=Error start=+\$"+ skip=+\\\\\|\\.+ end=+"+ contains=shStringSpecial
Bram Moolenaardf177f62005-02-22 08:39:57 +0000347endif
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200348syn region shSingleQuote matchgroup=shQuote start=+'+ end=+'+ contains=@Spell
Bram Moolenaard960d762011-09-21 19:22:10 +0200349syn region shDoubleQuote matchgroup=shQuote start=+\%(\%(\\\\\)*\\\)\@<!"+ skip=+\\"+ end=+"+ contains=@shDblQuoteList,shStringSpecial,@Spell
Bram Moolenaar802a0d92016-06-26 16:17:58 +0200350syn match shStringSpecial "[^[:print:] \t]" contained
351syn match shStringSpecial "[^\\]\zs\%(\\\\\)*\\[\\"'`$()#]"
352syn match shSpecial "[^\\]\zs\%(\\\\\)*\\[\\"'`$()#]" nextgroup=shBkslshSnglQuote,shBkslshDblQuote
Bram Moolenaar60cce2f2015-10-13 23:21:27 +0200353syn match shSpecial "^\%(\\\\\)*\\[\\"'`$()#]"
Bram Moolenaare4a3bcf2016-08-26 19:52:37 +0200354syn match shSpecialNxt contained "\\[\\"'`$()#]"
Bram Moolenaar802a0d92016-06-26 16:17:58 +0200355syn region shBkslshSnglQuote contained matchgroup=shQuote start=+'+ end=+'+ contains=@Spell
356syn region shBkslshDblQuote contained matchgroup=shQuote start=+"+ skip=+\\"+ end=+"+ contains=@shDblQuoteList,shStringSpecial,@Spell
Bram Moolenaar071d4272004-06-13 20:20:40 +0000357
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000358" Comments: {{{1
359"==========
Bram Moolenaar5c736222010-01-06 20:54:52 +0100360syn cluster shCommentGroup contains=shTodo,@Spell
361syn keyword shTodo contained COMBAK FIXME TODO XXX
362syn match shComment "^\s*\zs#.*$" contains=@shCommentGroup
363syn match shComment "\s\zs#.*$" contains=@shCommentGroup
Bram Moolenaar97d62492012-11-15 21:28:22 +0100364syn match shComment contained "#.*$" contains=@shCommentGroup
Bram Moolenaar5c736222010-01-06 20:54:52 +0100365syn match shQuickComment contained "#.*$"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000366
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000367" Here Documents: {{{1
368" =========================================
Bram Moolenaarbc8801c2016-08-02 21:04:33 +0200369ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc01 start="<<\s*\\\=\z([^ \t|>]\+\)" matchgroup=shHereDoc01 end="^\z1\s*$" contains=@shDblQuoteList
370ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc02 start="<<\s*\"\z([^ \t|>]\+\)\"" matchgroup=shHereDoc02 end="^\z1\s*$"
371ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc03 start="<<-\s*\z([^ \t|>]\+\)" matchgroup=shHereDoc03 end="^\s*\z1\s*$" contains=@shDblQuoteList
372ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc04 start="<<-\s*'\z([^ \t|>]\+\)'" matchgroup=shHereDoc04 end="^\s*\z1\s*$"
373ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc05 start="<<\s*'\z([^ \t|>]\+\)'" matchgroup=shHereDoc05 end="^\z1\s*$"
374ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc06 start="<<-\s*\"\z([^ \t|>]\+\)\"" matchgroup=shHereDoc06 end="^\s*\z1\s*$"
375ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc07 start="<<\s*\\\_$\_s*\z([^ \t|>]\+\)" matchgroup=shHereDoc07 end="^\z1\s*$" contains=@shDblQuoteList
376ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc08 start="<<\s*\\\_$\_s*'\z([^ \t|>]\+\)'" matchgroup=shHereDoc08 end="^\z1\s*$"
377ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc09 start="<<\s*\\\_$\_s*\"\z([^ \t|>]\+\)\"" matchgroup=shHereDoc09 end="^\z1\s*$"
378ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc10 start="<<-\s*\\\_$\_s*\z([^ \t|>]\+\)" matchgroup=shHereDoc10 end="^\s*\z1\s*$"
379ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc11 start="<<-\s*\\\_$\_s*\\\z([^ \t|>]\+\)" matchgroup=shHereDoc11 end="^\s*\z1\s*$"
380ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc12 start="<<-\s*\\\_$\_s*'\z([^ \t|>]\+\)'" matchgroup=shHereDoc12 end="^\s*\z1\s*$"
381ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc13 start="<<-\s*\\\_$\_s*\"\z([^ \t|>]\+\)\"" matchgroup=shHereDoc13 end="^\s*\z1\s*$"
382ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc14 start="<<\\\z([^ \t|>]\+\)" matchgroup=shHereDoc14 end="^\z1\s*$"
383ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc15 start="<<-\s*\\\z([^ \t|>]\+\)" matchgroup=shHereDoc15 end="^\s*\z1\s*$"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000384
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000385" Here Strings: {{{1
386" =============
Bram Moolenaard960d762011-09-21 19:22:10 +0200387" available for: bash; ksh (really should be ksh93 only) but not if its a posix
388if exists("b:is_bash") || (exists("b:is_kornshell") && !exists("g:is_posix"))
Bram Moolenaare4a3bcf2016-08-26 19:52:37 +0200389 syn match shHereString "<<<" skipwhite nextgroup=shCmdParenRegion
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000390endif
391
392" Identifiers: {{{1
393"=============
Bram Moolenaarc236c162008-07-13 17:41:49 +0000394syn match shSetOption "\s\zs[-+][a-zA-Z0-9]\+\>" contained
Bram Moolenaar541f92d2015-06-19 13:27:23 +0200395syn match shVariable "\<\([bwglsav]:\)\=[a-zA-Z0-9.!@_%+,]*\ze=" nextgroup=shVarAssign
396syn match shVarAssign "=" contained nextgroup=shCmdParenRegion,shPattern,shDeref,shDerefSimple,shDoubleQuote,shExDoubleQuote,shSingleQuote,shExSingleQuote
Bram Moolenaarbc488a72013-07-05 21:01:22 +0200397syn region shAtExpr contained start="@(" end=")" contains=@shIdList
Bram Moolenaar071d4272004-06-13 20:20:40 +0000398if exists("b:is_bash")
Bram Moolenaarbc488a72013-07-05 21:01:22 +0200399 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
400 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 +0000401elseif exists("b:is_kornshell")
Bram Moolenaarbc488a72013-07-05 21:01:22 +0200402 syn region shSetList oneline matchgroup=shSet start="\<\(typeset\|export\|unset\)\>\ze[^/]" end="$" matchgroup=shSetListDelim end="\ze[}|);&]" matchgroup=NONE end="\ze\s\+[#=]" contains=@shIdList
403 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 +0000404else
Bram Moolenaarbc488a72013-07-05 21:01:22 +0200405 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 +0000406endif
407
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000408" Functions: {{{1
Bram Moolenaarc236c162008-07-13 17:41:49 +0000409if !exists("g:is_posix")
410 syn keyword shFunctionKey function skipwhite skipnl nextgroup=shFunctionTwo
411endif
412
413if exists("b:is_bash")
Bram Moolenaar91c49372016-05-08 09:50:29 +0200414 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
415 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
416 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
417 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
Bram Moolenaar071d4272004-06-13 20:20:40 +0000418else
Bram Moolenaar91c49372016-05-08 09:50:29 +0200419 ShFoldFunctions syn region shFunctionOne matchgroup=shFunction start="^\s*\h\w*\s*()\_s*{" end="}" contains=@shFunctionList skipwhite skipnl nextgroup=shFunctionStart,shQuickComment
420 ShFoldFunctions syn region shFunctionTwo matchgroup=shFunction start="\%(do\)\@!\&\<\h\w*\>\s*\%(()\)\=\_s*{" end="}" contains=shFunctionKey,@shFunctionList contained skipwhite skipnl nextgroup=shFunctionStart,shQuickComment
421 ShFoldFunctions syn region shFunctionThree matchgroup=shFunction start="^\s*\h\w*\s*()\_s*(" end=")" contains=@shFunctionList skipwhite skipnl nextgroup=shFunctionStart,shQuickComment
422 ShFoldFunctions syn region shFunctionFour matchgroup=shFunction start="\%(do\)\@!\&\<\h\w*\>\s*\%(()\)\=\_s*(" end=")" contains=shFunctionKey,@shFunctionList contained skipwhite skipnl nextgroup=shFunctionStart,shQuickComment
Bram Moolenaar071d4272004-06-13 20:20:40 +0000423endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000424
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000425" Parameter Dereferencing: {{{1
426" ========================
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100427if !exists("g:sh_no_error")
Bram Moolenaar91c49372016-05-08 09:50:29 +0200428 syn match shDerefWordError "[^}$[~]" contained
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100429endif
Bram Moolenaarbc8801c2016-08-02 21:04:33 +0200430syn match shDerefSimple "\$\%(\h\w*\|\d\)"
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100431syn region shDeref matchgroup=PreProc start="\${" end="}" contains=@shDerefList,shDerefVarArray
Bram Moolenaar071d4272004-06-13 20:20:40 +0000432syn match shDerefSimple "\$[-#*@!?]"
433syn match shDerefSimple "\$\$"
Bram Moolenaare4a3bcf2016-08-26 19:52:37 +0200434syn match shDerefSimple "\${\d}"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000435if exists("b:is_bash") || exists("b:is_kornshell")
436 syn region shDeref matchgroup=PreProc start="\${##\=" end="}" contains=@shDerefList
Bram Moolenaarc236c162008-07-13 17:41:49 +0000437 syn region shDeref matchgroup=PreProc start="\${\$\$" end="}" contains=@shDerefList
Bram Moolenaar071d4272004-06-13 20:20:40 +0000438endif
439
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100440" ksh: ${!var[*]} array index list syntax: {{{1
441" ========================================
442if exists("b:is_kornshell")
443 syn region shDeref matchgroup=PreProc start="\${!" end="}" contains=@shDerefVarArray
444endif
445
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000446" bash: ${!prefix*} and ${#parameter}: {{{1
447" ====================================
Bram Moolenaar071d4272004-06-13 20:20:40 +0000448if exists("b:is_bash")
Bram Moolenaarbc8801c2016-08-02 21:04:33 +0200449 syn region shDeref matchgroup=PreProc start="\${!" end="\*\=}" contains=@shDerefList,shDerefOff
450 syn match shDerefVar contained "{\@<=!\h\w*" nextgroup=@shDerefVarList
Bram Moolenaar071d4272004-06-13 20:20:40 +0000451endif
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100452if exists("b:is_kornshell")
Bram Moolenaarbc8801c2016-08-02 21:04:33 +0200453 syn match shDerefVar contained "{\@<=!\h\w*[[:alnum:]_.]*" nextgroup=@shDerefVarList
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100454endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000455
456syn match shDerefSpecial contained "{\@<=[-*@?0]" nextgroup=shDerefOp,shDerefOpError
457syn match shDerefSpecial contained "\({[#!]\)\@<=[[:alnum:]*@_]\+" nextgroup=@shDerefVarList,shDerefOp
Bram Moolenaarbc8801c2016-08-02 21:04:33 +0200458syn match shDerefVar contained "{\@<=\h\w*" nextgroup=@shDerefVarList
Bram Moolenaare4a3bcf2016-08-26 19:52:37 +0200459syn match shDerefVar contained '\d' nextgroup=@shDerefVarList
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100460if exists("b:is_kornshell")
Bram Moolenaarbc8801c2016-08-02 21:04:33 +0200461 syn match shDerefVar contained "{\@<=\h\w*[[:alnum:]_.]*" nextgroup=@shDerefVarList
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100462endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000463
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000464" sh ksh bash : ${var[... ]...} array reference: {{{1
Bram Moolenaare2719092015-01-10 15:09:25 +0100465syn region shDerefVarArray contained matchgroup=shDeref start="\[" end="]" contains=@shCommandSubList nextgroup=shDerefOp,shDerefOpError
Bram Moolenaar071d4272004-06-13 20:20:40 +0000466
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000467" Special ${parameter OPERATOR word} handling: {{{1
Bram Moolenaare2719092015-01-10 15:09:25 +0100468" sh ksh bash : ${parameter:-word} word is default value
469" sh ksh bash : ${parameter:=word} assign word as default value
470" sh ksh bash : ${parameter:?word} display word if parameter is null
471" sh ksh bash : ${parameter:+word} use word if parameter is not null, otherwise nothing
472" ksh bash : ${parameter#pattern} remove small left pattern
473" ksh bash : ${parameter##pattern} remove large left pattern
474" ksh bash : ${parameter%pattern} remove small right pattern
475" ksh bash : ${parameter%%pattern} remove large right pattern
476" bash : ${parameter^pattern} Case modification
477" bash : ${parameter^^pattern} Case modification
478" bash : ${parameter,pattern} Case modification
479" bash : ${parameter,,pattern} Case modification
Bram Moolenaar071d4272004-06-13 20:20:40 +0000480syn cluster shDerefPatternList contains=shDerefPattern,shDerefString
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100481if !exists("g:sh_no_error")
482 syn match shDerefOpError contained ":[[:punct:]]"
483endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000484syn match shDerefOp contained ":\=[-=?]" nextgroup=@shDerefPatternList
485syn match shDerefOp contained ":\=+" nextgroup=@shDerefPatternList
486if exists("b:is_bash") || exists("b:is_kornshell")
Bram Moolenaare4a3bcf2016-08-26 19:52:37 +0200487 syn match shDerefOp contained "#\{1,2}" nextgroup=@shDerefPatternList
488 syn match shDerefOp contained "%\{1,2}" nextgroup=@shDerefPatternList
489 syn match shDerefPattern contained "[^{}]\+" contains=shDeref,shDerefSimple,shDerefPattern,shDerefString,shCommandSub,shDerefEscape nextgroup=shDerefPattern
Bram Moolenaar071d4272004-06-13 20:20:40 +0000490 syn region shDerefPattern contained start="{" end="}" contains=shDeref,shDerefSimple,shDerefString,shCommandSub nextgroup=shDerefPattern
Bram Moolenaar5b8d8fd2005-08-16 23:01:50 +0000491 syn match shDerefEscape contained '\%(\\\\\)*\\.'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000492endif
Bram Moolenaard960d762011-09-21 19:22:10 +0200493if exists("b:is_bash")
494 syn match shDerefOp contained "[,^]\{1,2}" nextgroup=@shDerefPatternList
495endif
Bram Moolenaare4a3bcf2016-08-26 19:52:37 +0200496syn region shDerefString contained matchgroup=shDerefDelim start=+\%(\\\)\@<!'+ end=+'+ contains=shStringSpecial
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200497syn region shDerefString contained matchgroup=shDerefDelim start=+\%(\\\)\@<!"+ skip=+\\"+ end=+"+ contains=@shDblQuoteList,shStringSpecial
Bram Moolenaarc236c162008-07-13 17:41:49 +0000498syn match shDerefString contained "\\["']" nextgroup=shDerefPattern
Bram Moolenaar071d4272004-06-13 20:20:40 +0000499
Bram Moolenaar071d4272004-06-13 20:20:40 +0000500if exists("b:is_bash")
Bram Moolenaar5b8d8fd2005-08-16 23:01:50 +0000501 " bash : ${parameter:offset}
502 " bash : ${parameter:offset:length}
Bram Moolenaare4a3bcf2016-08-26 19:52:37 +0200503 syn region shDerefOff contained start=':' end='\ze:' end='\ze}' contains=shDeref,shDerefSimple,shDerefEscape nextgroup=shDerefLen,shDeref,shDerefSimple
504 syn region shDerefOff contained start=':\s-' end='\ze:' end='\ze}' contains=shDeref,shDerefSimple,shDerefEscape nextgroup=shDerefLen,shDeref,shDerefSimple
Bram Moolenaarbc8801c2016-08-02 21:04:33 +0200505 syn match shDerefLen contained ":[^}]\+" contains=shDeref,shDerefSimple
Bram Moolenaar5b8d8fd2005-08-16 23:01:50 +0000506
507 " bash : ${parameter//pattern/string}
508 " bash : ${parameter//pattern}
509 syn match shDerefPPS contained '/\{1,2}' nextgroup=shDerefPPSleft
Bram Moolenaar97d62492012-11-15 21:28:22 +0100510 syn region shDerefPPSleft contained start='.' skip=@\%(\\\\\)*\\/@ matchgroup=shDerefOp end='/' end='\ze}' nextgroup=shDerefPPSright contains=@shCommandSubList
Bram Moolenaar91c49372016-05-08 09:50:29 +0200511 syn region shDerefPPSright contained start='.' skip=@\%(\\\\\)\+@ end='\ze}' contains=@shPPSRightList
Bram Moolenaaracb4f222016-01-10 15:59:26 +0100512
513 " bash : ${parameter/#substring/replacement}
514 syn match shDerefPSR contained '/#' nextgroup=shDerefPSRleft
515 syn region shDerefPSRleft contained start='.' skip=@\%(\\\\\)*\\/@ matchgroup=shDerefOp end='/' end='\ze}' nextgroup=shDerefPSRright
516 syn region shDerefPSRright contained start='.' skip=@\%(\\\\\)\+@ end='\ze}'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000517endif
518
Bram Moolenaarc236c162008-07-13 17:41:49 +0000519" Arithmetic Parenthesized Expressions: {{{1
Bram Moolenaarbc488a72013-07-05 21:01:22 +0200520"syn region shParen matchgroup=shArithRegion start='[^$]\zs(\%(\ze[^(]\|$\)' end=')' contains=@shArithParenList
521syn region shParen matchgroup=shArithRegion start='\$\@!(\%(\ze[^(]\|$\)' end=')' contains=@shArithParenList
Bram Moolenaarc236c162008-07-13 17:41:49 +0000522
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000523" Useful sh Keywords: {{{1
524" ===================
Bram Moolenaar071d4272004-06-13 20:20:40 +0000525syn keyword shStatement break cd chdir continue eval exec exit kill newgrp pwd read readonly return shift test trap ulimit umask wait
526syn keyword shConditional contained elif else then
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100527if !exists("g:sh_no_error")
528 syn keyword shCondError elif else then
529endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000530
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000531" Useful ksh Keywords: {{{1
532" ====================
Bram Moolenaar071d4272004-06-13 20:20:40 +0000533if exists("b:is_kornshell") || exists("b:is_bash")
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200534 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 +0000535 if exists("g:is_posix")
536 syn keyword shStatement command
537 else
538 syn keyword shStatement time
539 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000540
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000541" Useful bash Keywords: {{{1
542" =====================
Bram Moolenaar071d4272004-06-13 20:20:40 +0000543 if exists("b:is_bash")
544 syn keyword shStatement bind builtin dirs disown enable help local logout popd pushd shopt source
545 else
546 syn keyword shStatement login newgrp
547 endif
548endif
549
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000550" Synchronization: {{{1
551" ================
Bram Moolenaar03413f42016-04-12 21:07:15 +0200552if !exists("g:sh_minlines")
553 let s:sh_minlines = 200
554else
555 let s:sh_minlines= g:sh_minlines
Bram Moolenaar071d4272004-06-13 20:20:40 +0000556endif
Bram Moolenaar03413f42016-04-12 21:07:15 +0200557if !exists("g:sh_maxlines")
558 let s:sh_maxlines = 2*s:sh_minlines
559 if s:sh_maxlines < 25
560 let s:sh_maxlines= 25
561 endif
562else
563 let s:sh_maxlines= g:sh_maxlines
Bram Moolenaar071d4272004-06-13 20:20:40 +0000564endif
Bram Moolenaar03413f42016-04-12 21:07:15 +0200565exec "syn sync minlines=" . s:sh_minlines . " maxlines=" . s:sh_maxlines
Bram Moolenaar071d4272004-06-13 20:20:40 +0000566syn sync match shCaseEsacSync grouphere shCaseEsac "\<case\>"
567syn sync match shCaseEsacSync groupthere shCaseEsac "\<esac\>"
568syn sync match shDoSync grouphere shDo "\<do\>"
569syn sync match shDoSync groupthere shDo "\<done\>"
570syn sync match shForSync grouphere shFor "\<for\>"
571syn sync match shForSync groupthere shFor "\<in\>"
572syn sync match shIfSync grouphere shIf "\<if\>"
573syn sync match shIfSync groupthere shIf "\<fi\>"
574syn sync match shUntilSync grouphere shRepeat "\<until\>"
575syn sync match shWhileSync grouphere shRepeat "\<while\>"
576
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000577" Default Highlighting: {{{1
578" =====================
Bram Moolenaar071d4272004-06-13 20:20:40 +0000579hi def link shArithRegion shShellVariables
Bram Moolenaar91c49372016-05-08 09:50:29 +0200580hi def link shAstQuote shDoubleQuote
Bram Moolenaarbc488a72013-07-05 21:01:22 +0200581hi def link shAtExpr shSetList
Bram Moolenaardf177f62005-02-22 08:39:57 +0000582hi def link shBeginHere shRedir
Bram Moolenaar071d4272004-06-13 20:20:40 +0000583hi def link shCaseBar shConditional
Bram Moolenaar071d4272004-06-13 20:20:40 +0000584hi def link shCaseCommandSub shCommandSub
585hi def link shCaseDoubleQuote shDoubleQuote
Bram Moolenaardf177f62005-02-22 08:39:57 +0000586hi def link shCaseIn shConditional
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200587hi def link shQuote shOperator
Bram Moolenaar071d4272004-06-13 20:20:40 +0000588hi def link shCaseSingleQuote shSingleQuote
589hi def link shCaseStart shConditional
590hi def link shCmdSubRegion shShellVariables
Bram Moolenaar5c736222010-01-06 20:54:52 +0100591hi def link shColon shComment
Bram Moolenaar071d4272004-06-13 20:20:40 +0000592hi def link shDerefOp shOperator
Bram Moolenaardf177f62005-02-22 08:39:57 +0000593hi def link shDerefPOL shDerefOp
Bram Moolenaar5b8d8fd2005-08-16 23:01:50 +0000594hi def link shDerefPPS shDerefOp
Bram Moolenaaracb4f222016-01-10 15:59:26 +0100595hi def link shDerefPSR shDerefOp
Bram Moolenaardf177f62005-02-22 08:39:57 +0000596hi def link shDeref shShellVariables
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200597hi def link shDerefDelim shOperator
Bram Moolenaar071d4272004-06-13 20:20:40 +0000598hi def link shDerefSimple shDeref
599hi def link shDerefSpecial shDeref
600hi def link shDerefString shDoubleQuote
Bram Moolenaardf177f62005-02-22 08:39:57 +0000601hi def link shDerefVar shDeref
Bram Moolenaar071d4272004-06-13 20:20:40 +0000602hi def link shDoubleQuote shString
603hi def link shEcho shString
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200604hi def link shEchoDelim shOperator
Bram Moolenaarc236c162008-07-13 17:41:49 +0000605hi def link shEchoQuote shString
Bram Moolenaar83d1b192015-04-13 14:22:40 +0200606hi def link shForPP shLoop
Bram Moolenaare4a3bcf2016-08-26 19:52:37 +0200607hi def link shFunction Function
Bram Moolenaar071d4272004-06-13 20:20:40 +0000608hi def link shEmbeddedEcho shString
Bram Moolenaarc236c162008-07-13 17:41:49 +0000609hi def link shEscape shCommandSub
Bram Moolenaare90ee312010-08-05 22:08:47 +0200610hi def link shExDoubleQuote shDoubleQuote
Bram Moolenaardf177f62005-02-22 08:39:57 +0000611hi def link shExSingleQuote shSingleQuote
Bram Moolenaar071d4272004-06-13 20:20:40 +0000612hi def link shHereDoc shString
Bram Moolenaare4a3bcf2016-08-26 19:52:37 +0200613hi def link shHereString shRedir
Bram Moolenaardf177f62005-02-22 08:39:57 +0000614hi def link shHerePayload shHereDoc
Bram Moolenaar071d4272004-06-13 20:20:40 +0000615hi def link shLoop shStatement
Bram Moolenaare4a3bcf2016-08-26 19:52:37 +0200616hi def link shSpecialNxt shSpecial
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100617hi def link shNoQuote shDoubleQuote
Bram Moolenaar071d4272004-06-13 20:20:40 +0000618hi def link shOption shCommandSub
619hi def link shPattern shString
Bram Moolenaarc236c162008-07-13 17:41:49 +0000620hi def link shParen shArithmetic
Bram Moolenaar071d4272004-06-13 20:20:40 +0000621hi def link shPosnParm shShellVariables
Bram Moolenaarc236c162008-07-13 17:41:49 +0000622hi def link shQuickComment shComment
Bram Moolenaar071d4272004-06-13 20:20:40 +0000623hi def link shRange shOperator
624hi def link shRedir shOperator
Bram Moolenaar4b22cdb2010-08-02 22:12:46 +0200625hi def link shSetListDelim shOperator
Bram Moolenaarc236c162008-07-13 17:41:49 +0000626hi def link shSetOption shOption
Bram Moolenaar071d4272004-06-13 20:20:40 +0000627hi def link shSingleQuote shString
628hi def link shSource shOperator
629hi def link shStringSpecial shSpecial
630hi def link shSubShRegion shOperator
631hi def link shTestOpr shConditional
Bram Moolenaar9964e462007-05-05 17:54:07 +0000632hi def link shTestPattern shString
633hi def link shTestDoubleQuote shString
634hi def link shTestSingleQuote shString
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100635hi def link shTouchCmd shStatement
Bram Moolenaar071d4272004-06-13 20:20:40 +0000636hi def link shVariable shSetList
637hi def link shWrapLineOperator shOperator
638
639if exists("b:is_bash")
640 hi def link bashAdminStatement shStatement
641 hi def link bashSpecialVariables shShellVariables
642 hi def link bashStatement shStatement
Bram Moolenaar97d62492012-11-15 21:28:22 +0100643 hi def link shCharClass shSpecial
Bram Moolenaarbc8801c2016-08-02 21:04:33 +0200644 hi def link shDerefOff shDerefOp
645 hi def link shDerefLen shDerefOff
Bram Moolenaar071d4272004-06-13 20:20:40 +0000646endif
647if exists("b:is_kornshell")
648 hi def link kshSpecialVariables shShellVariables
649 hi def link kshStatement shStatement
Bram Moolenaar071d4272004-06-13 20:20:40 +0000650endif
651
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100652if !exists("g:sh_no_error")
653 hi def link shCaseError Error
654 hi def link shCondError Error
655 hi def link shCurlyError Error
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100656 hi def link shDerefOpError Error
657 hi def link shDerefWordError Error
658 hi def link shDoError Error
659 hi def link shEsacError Error
660 hi def link shIfError Error
661 hi def link shInError Error
662 hi def link shParenError Error
663 hi def link shTestError Error
664 if exists("b:is_kornshell")
665 hi def link shDTestError Error
666 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000667endif
668
669hi def link shArithmetic Special
670hi def link shCharClass Identifier
671hi def link shSnglCase Statement
672hi def link shCommandSub Special
673hi def link shComment Comment
674hi def link shConditional Conditional
Bram Moolenaar9964e462007-05-05 17:54:07 +0000675hi def link shCtrlSeq Special
Bram Moolenaar071d4272004-06-13 20:20:40 +0000676hi def link shExprRegion Delimiter
Bram Moolenaarcd71fa32005-03-11 22:46:48 +0000677hi def link shFunctionKey Function
Bram Moolenaar071d4272004-06-13 20:20:40 +0000678hi def link shFunctionName Function
679hi def link shNumber Number
680hi def link shOperator Operator
681hi def link shRepeat Repeat
682hi def link shSet Statement
683hi def link shSetList Identifier
684hi def link shShellVariables PreProc
685hi def link shSpecial Special
686hi def link shStatement Statement
687hi def link shString String
688hi def link shTodo Todo
689hi def link shAlias Identifier
Bram Moolenaar541f92d2015-06-19 13:27:23 +0200690hi def link shHereDoc01 shRedir
691hi def link shHereDoc02 shRedir
692hi def link shHereDoc03 shRedir
693hi def link shHereDoc04 shRedir
694hi def link shHereDoc05 shRedir
695hi def link shHereDoc06 shRedir
696hi def link shHereDoc07 shRedir
697hi def link shHereDoc08 shRedir
698hi def link shHereDoc09 shRedir
699hi def link shHereDoc10 shRedir
700hi def link shHereDoc11 shRedir
701hi def link shHereDoc12 shRedir
702hi def link shHereDoc13 shRedir
703hi def link shHereDoc14 shRedir
704hi def link shHereDoc15 shRedir
Bram Moolenaarb4ff5182015-11-10 21:15:48 +0100705
706" Delete shell folding commands {{{1
707" =============================
708delc ShFoldFunctions
709delc ShFoldHereDoc
710delc ShFoldIfDoFor
Bram Moolenaar071d4272004-06-13 20:20:40 +0000711
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000712" Set Current Syntax: {{{1
713" ===================
Bram Moolenaar071d4272004-06-13 20:20:40 +0000714if exists("b:is_bash")
715 let b:current_syntax = "bash"
716elseif exists("b:is_kornshell")
717 let b:current_syntax = "ksh"
718else
719 let b:current_syntax = "sh"
720endif
721
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000722" vim: ts=16 fdm=marker