blob: cb92bbda81deb64b410a3b4f0481730712b0a517 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: shell (sh) Korn shell (ksh) bash (sh)
3" Maintainer: Dr. Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz>
4" Previous Maintainer: Lennart Schultz <Lennart.Schultz@ecmwf.int>
Bram Moolenaarc236c162008-07-13 17:41:49 +00005" Last Change: Jul 01, 2008
6" Version: 100
Bram Moolenaarcafda4f2005-09-06 19:25:11 +00007" URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax
Bram Moolenaarc236c162008-07-13 17:41:49 +00008" For options and settings, please use: :help ft-sh-syntax
Bram Moolenaar071d4272004-06-13 20:20:40 +00009" This file includes many ideas from Éric Brunet (eric.brunet@ens.fr)
10
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 Moolenaard4755bb2004-09-02 19:12:26 +000019" handling /bin/sh with is_kornshell/is_sh {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +000020" b:is_sh is set when "#! /bin/sh" is found;
21" However, it often is just a masquerade by bash (typically Linux)
22" or kornshell (typically workstations with Posix "sh").
23" So, when the user sets "is_bash" or "is_kornshell",
24" a b:is_sh is converted into b:is_bash/b:is_kornshell,
25" respectively.
26if !exists("b:is_kornshell") && !exists("b:is_bash")
Bram Moolenaar7fc904b2006-04-13 20:37:35 +000027 if exists("g:is_posix") && !exists("g:is_kornshell")
28 let g:is_kornshell= g:is_posix
29 endif
30 if exists("g:is_kornshell")
Bram Moolenaar071d4272004-06-13 20:20:40 +000031 let b:is_kornshell= 1
32 if exists("b:is_sh")
33 unlet b:is_sh
34 endif
Bram Moolenaar7fc904b2006-04-13 20:37:35 +000035 elseif exists("g:is_bash")
Bram Moolenaar071d4272004-06-13 20:20:40 +000036 let b:is_bash= 1
37 if exists("b:is_sh")
38 unlet b:is_sh
39 endif
40 else
41 let b:is_sh= 1
42 endif
43endif
44
Bram Moolenaarc236c162008-07-13 17:41:49 +000045" adjust iskeyword for shell characters
46"setlocal isk=@,48-57,_,192-255,#,.,/
47
Bram Moolenaarcd71fa32005-03-11 22:46:48 +000048" set up default g:sh_fold_enabled {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +000049if !exists("g:sh_fold_enabled")
50 let g:sh_fold_enabled= 0
Bram Moolenaar293ee4d2004-12-09 21:34:53 +000051elseif g:sh_fold_enabled != 0 && !has("folding")
52 let g:sh_fold_enabled= 0
Bram Moolenaarcd71fa32005-03-11 22:46:48 +000053 echomsg "Ignoring g:sh_fold_enabled=".g:sh_fold_enabled."; need to re-compile vim for +fold support"
54endif
Bram Moolenaarc236c162008-07-13 17:41:49 +000055if !exists("s:sh_fold_functions")
56 let s:sh_fold_functions = 1
57endif
58if !exists("s:sh_fold_heredoc")
59 let s:sh_fold_heredoc = 2
60endif
61if !exists("s:sh_fold_ifdofor")
62 let s:sh_fold_ifdofor = 4
63endif
Bram Moolenaarcd71fa32005-03-11 22:46:48 +000064if g:sh_fold_enabled && &fdm == "manual"
65 set fdm=syntax
Bram Moolenaar071d4272004-06-13 20:20:40 +000066endif
67
Bram Moolenaarcd71fa32005-03-11 22:46:48 +000068" sh syntax is case sensitive {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +000069syn case match
70
Bram Moolenaard4755bb2004-09-02 19:12:26 +000071" Clusters: contains=@... clusters {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +000072"==================================
Bram Moolenaarc236c162008-07-13 17:41:49 +000073syn cluster shErrorList contains=shDoError,shIfError,shInError,shCaseError,shEsacError,shCurlyError,shParenError,shTestError
74if exists("b:is_kornshell")
75 syn cluster ErrorList add=shDTestError
76endif
77syn cluster shArithParenList contains=shArithmetic,shDeref,shDerefSimple,shEscape,shNumber,shOperator,shPosnParm,shExSingleQuote,shSingleQuote,shDoubleQuote,shStatement,shVariable,shAlias,shTest,shCtrlSeq,shSpecial,shParen
78syn cluster shArithList contains=@shArithParenList,shParenError
79syn cluster shCaseEsacList contains=shCaseStart,shCase,shCaseBar,shCaseIn,shComment,shDeref,shDerefSimple,shCaseCommandSub,shCaseExSingleQuote,shCaseSingleQuote,shCaseDoubleQuote,shCtrlSeq,@shErrorList,shStringSpecial
Bram Moolenaar9964e462007-05-05 17:54:07 +000080syn cluster shCaseList contains=@shCommandSubList,shCaseEsac,shColon,shCommandSub,shCommandSub,shComment,shDo,shEcho,shExpr,shFor,shHereDoc,shIf,shRedir,shSetList,shSource,shStatement,shVariable,shCtrlSeq
Bram Moolenaar071d4272004-06-13 20:20:40 +000081syn cluster shColonList contains=@shCaseList
Bram Moolenaarc236c162008-07-13 17:41:49 +000082syn cluster shCommandSubList contains=shArithmetic,shDeref,shDerefSimple,shEscape,shNumber,shOperator,shPosnParm,shExSingleQuote,shSingleQuote,shDoubleQuote,shStatement,shVariable,shSubSh,shAlias,shTest,shCtrlSeq,shSpecial
Bram Moolenaar572cb562005-08-05 21:35:02 +000083syn cluster shCurlyList contains=shNumber,shComma,shDeref,shDerefSimple,shDerefSpecial
Bram Moolenaar7263a772007-05-10 17:35:54 +000084syn cluster shDblQuoteList contains=shCommandSub,shDeref,shDerefSimple,shPosnParm,shExSingleQuote,shCtrlSeq,shSpecial
Bram Moolenaar5b8d8fd2005-08-16 23:01:50 +000085syn cluster shDerefList contains=shDeref,shDerefSimple,shDerefVar,shDerefSpecial,shDerefWordError,shDerefPPS
Bram Moolenaar071d4272004-06-13 20:20:40 +000086syn cluster shDerefVarList contains=shDerefOp,shDerefVarArray,shDerefOpError
Bram Moolenaarc236c162008-07-13 17:41:49 +000087syn cluster shEchoList contains=shArithmetic,shCommandSub,shDeref,shDerefSimple,shExpr,shExSingleQuote,shSingleQuote,shDoubleQuote,shCtrlSeq,shEchoQuote
Bram Moolenaar9964e462007-05-05 17:54:07 +000088syn cluster shExprList1 contains=shCharClass,shNumber,shOperator,shExSingleQuote,shSingleQuote,shDoubleQuote,shExpr,shDblBrace,shDeref,shDerefSimple,shCtrlSeq
Bram Moolenaar383f9bc2005-01-19 22:18:32 +000089syn cluster shExprList2 contains=@shExprList1,@shCaseList,shTest
Bram Moolenaarc236c162008-07-13 17:41:49 +000090syn cluster shFunctionList contains=@shCommandSubList,shCaseEsac,shColon,shCommandSub,shCommandSub,shComment,shDo,shEcho,shExpr,shFor,shHereDoc,shIf,shRedir,shSetList,shSource,shStatement,shVariable,shOperator,shCtrlSeq
Bram Moolenaar7263a772007-05-10 17:35:54 +000091if exists("b:is_kornshell") || exists("b:is_bash")
Bram Moolenaarc236c162008-07-13 17:41:49 +000092 syn cluster shFunctionList add=shRepeat
Bram Moolenaar7263a772007-05-10 17:35:54 +000093 syn cluster shFunctionList add=shDblBrace,shDblParen
94endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000095syn cluster shHereBeginList contains=@shCommandSubList
96syn cluster shHereList contains=shBeginHere,shHerePayload
97syn cluster shHereListDQ contains=shBeginHere,@shDblQuoteList,shHerePayload
Bram Moolenaarc236c162008-07-13 17:41:49 +000098syn cluster shIdList contains=shCommandSub,shWrapLineOperator,shSetOption,shDeref,shDerefSimple,shRedir,shExSingleQuote,shSingleQuote,shDoubleQuote,shExpr,shCtrlSeq,shStringSpecial
99syn cluster shLoopList contains=@shCaseList,shTestOpr,shExpr,shDblBrace,shConditional,shCaseEsac,shTest,@shErrorList,shSet
Bram Moolenaar7263a772007-05-10 17:35:54 +0000100syn cluster shSubShList contains=@shCaseList,shOperator
Bram Moolenaar9964e462007-05-05 17:54:07 +0000101syn cluster shTestList contains=shCharClass,shComment,shCommandSub,shDeref,shDerefSimple,shDoubleQuote,shExpr,shExpr,shNumber,shOperator,shExSingleQuote,shSingleQuote,shTestOpr,shTest,shCtrlSeq
Bram Moolenaar071d4272004-06-13 20:20:40 +0000102
103
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000104" Echo: {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000105" ====
106" This one is needed INSIDE a CommandSub, so that `echo bla` be correct
Bram Moolenaarc236c162008-07-13 17:41:49 +0000107syn region shEcho matchgroup=shStatement start="\<echo\>" skip="\\$" matchgroup=shOperator end="$" matchgroup=NONE end="[<>;&|()]"me=e-1 end="\d[<>]"me=e-2 end="#"me=e-1 contains=@shEchoList skipwhite nextgroup=shQuickComment
108syn region shEcho matchgroup=shStatement start="\<print\>" skip="\\$" matchgroup=shOperator end="$" matchgroup=NONE end="[<>;&|()]"me=e-1 end="\d[<>]"me=e-2 end="#"me=e-1 contains=@shEchoList skipwhite nextgroup=shQuickComment
109syn match shEchoQuote contained '\%(\\\\\)*\\["`']'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000110
Bram Moolenaarc236c162008-07-13 17:41:49 +0000111" This must be after the strings, so that ... \" will be correct
Bram Moolenaar9964e462007-05-05 17:54:07 +0000112syn region shEmbeddedEcho contained matchgroup=shStatement start="\<print\>" skip="\\$" matchgroup=shOperator end="$" matchgroup=NONE end="[<>;&|`)]"me=e-1 end="\d[<>]"me=e-2 end="#"me=e-1 contains=shNumber,shExSingleQuote,shSingleQuote,shDeref,shDerefSimple,shSpecialVar,shOperator,shDoubleQuote,shCharClass,shCtrlSeq
Bram Moolenaar071d4272004-06-13 20:20:40 +0000113
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000114" Alias: {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000115" =====
116if exists("b:is_kornshell") || exists("b:is_bash")
117 syn match shStatement "\<alias\>"
118 syn region shAlias matchgroup=shStatement start="\<alias\>\s\+\(\w\+\)\@=" skip="\\$" end="\>\|`"
119 syn region shAlias matchgroup=shStatement start="\<alias\>\s\+\(\w\+=\)\@=" skip="\\$" end="="
120endif
121
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000122" Error Codes: {{{1
123" ============
Bram Moolenaar071d4272004-06-13 20:20:40 +0000124syn match shDoError "\<done\>"
125syn match shIfError "\<fi\>"
126syn match shInError "\<in\>"
127syn match shCaseError ";;"
128syn match shEsacError "\<esac\>"
129syn match shCurlyError "}"
130syn match shParenError ")"
131if exists("b:is_kornshell")
132 syn match shDTestError "]]"
133endif
134syn match shTestError "]"
135
Bram Moolenaarc236c162008-07-13 17:41:49 +0000136" Options: {{{1
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000137" ====================
Bram Moolenaarc236c162008-07-13 17:41:49 +0000138syn match shOption "\s\zs[-+][a-zA-Z0-9]\+\>"
139syn match shOption "\s\zs--[^ \t$`'"|]\+"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000140
Bram Moolenaar7263a772007-05-10 17:35:54 +0000141" File Redirection Highlighted As Operators: {{{1
142"===========================================
143syn match shRedir "\d\=>\(&[-0-9]\)\="
144syn match shRedir "\d\=>>-\="
145syn match shRedir "\d\=<\(&[-0-9]\)\="
146syn match shRedir "\d<<-\="
147
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000148" Operators: {{{1
149" ==========
Bram Moolenaar7263a772007-05-10 17:35:54 +0000150syn match shOperator "<<\|>>" contained
Bram Moolenaarc236c162008-07-13 17:41:49 +0000151syn match shOperator "[!&;|]" contained
152syn match shOperator "\[[[^:]\|\]]" contained
Bram Moolenaar071d4272004-06-13 20:20:40 +0000153syn match shOperator "!\==" skipwhite nextgroup=shPattern
Bram Moolenaardf177f62005-02-22 08:39:57 +0000154syn match shPattern "\<\S\+\())\)\@=" contained contains=shExSingleQuote,shSingleQuote,shDoubleQuote,shDeref
Bram Moolenaar071d4272004-06-13 20:20:40 +0000155
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000156" Subshells: {{{1
157" ==========
Bram Moolenaar071d4272004-06-13 20:20:40 +0000158syn region shExpr transparent matchgroup=shExprRegion start="{" end="}" contains=@shExprList2
159syn region shSubSh transparent matchgroup=shSubShRegion start="(" end=")" contains=@shSubShList
160
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000161" Tests: {{{1
162"=======
Bram Moolenaar071d4272004-06-13 20:20:40 +0000163"syn region shExpr transparent matchgroup=shRange start="\[" skip=+\\\\\|\\$+ end="\]" contains=@shTestList
Bram Moolenaar9964e462007-05-05 17:54:07 +0000164syn region shExpr matchgroup=shRange start="\[" skip=+\\\\\|\\$+ end="\]" contains=@shTestList
165syn region shTest transparent matchgroup=shStatement start="\<test\>" skip=+\\\\\|\\$+ matchgroup=NONE end="[;&|]"me=e-1 end="$" contains=@shExprList1
166syn match shTestOpr contained "<=\|>=\|!=\|==\|-.\>\|-\(nt\|ot\|ef\|eq\|ne\|lt\|le\|gt\|ge\)\>\|[!<>]"
167syn match shTestOpr contained '=' skipwhite nextgroup=shTestDoubleQuote,shTestSingleQuote,shTestPattern
168syn match shTestPattern contained '\w\+'
169syn match shTestDoubleQuote contained '"[^"]*"'
170syn match shTestSingleQuote contained '\\.'
171syn match shTestSingleQuote contained "'[^']*'"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000172if exists("b:is_kornshell") || exists("b:is_bash")
173 syn region shDblBrace matchgroup=Delimiter start="\[\[" skip=+\\\\\|\\$+ end="\]\]" contains=@shTestList
174 syn region shDblParen matchgroup=Delimiter start="((" skip=+\\\\\|\\$+ end="))" contains=@shTestList
175endif
176
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000177" Character Class In Range: {{{1
178" =========================
Bram Moolenaar071d4272004-06-13 20:20:40 +0000179syn match shCharClass contained "\[:\(backspace\|escape\|return\|xdigit\|alnum\|alpha\|blank\|cntrl\|digit\|graph\|lower\|print\|punct\|space\|upper\|tab\):\]"
180
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000181" Loops: do, if, while, until {{{1
182" ======
Bram Moolenaarc236c162008-07-13 17:41:49 +0000183if (g:sh_fold_enabled % (s:sh_fold_ifdofor * 2))/s:sh_fold_ifdofor
Bram Moolenaar8dff8182006-04-06 20:18:50 +0000184 syn region shDo fold transparent matchgroup=shConditional start="\<do\>" matchgroup=shConditional end="\<done\>" contains=@shLoopList
Bram Moolenaarc236c162008-07-13 17:41:49 +0000185 syn region shIf fold transparent matchgroup=shConditional start="\<if\_s" matchgroup=shConditional end="\<;\_s*then\>" end="\<fi\>" contains=@shLoopList,shDblBrace,shDblParen,shFunctionKey
186 syn region shFor fold matchgroup=shLoop start="\<for\_s" end="\<in\_s" end="\<do\>"me=e-2 contains=@shLoopList,shDblParen skipwhite nextgroup=shCurlyIn
Bram Moolenaar8dff8182006-04-06 20:18:50 +0000187else
188 syn region shDo transparent matchgroup=shConditional start="\<do\>" matchgroup=shConditional end="\<done\>" contains=@shLoopList
Bram Moolenaarc236c162008-07-13 17:41:49 +0000189 syn region shIf transparent matchgroup=shConditional start="\<if\_s" matchgroup=shConditional end="\<;\_s*then\>" end="\<fi\>" contains=@shLoopList,shDblBrace,shDblParen,shFunctionKey
190 syn region shFor matchgroup=shLoop start="\<for\_s" end="\<in\>" end="\<do\>"me=e-2 contains=@shLoopList,shDblParen skipwhite nextgroup=shCurlyIn
Bram Moolenaar8dff8182006-04-06 20:18:50 +0000191endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000192if exists("b:is_kornshell") || exists("b:is_bash")
Bram Moolenaarc236c162008-07-13 17:41:49 +0000193 syn cluster shCaseList add=shRepeat
194 syn cluster shFunctionList add=shRepeat
195 syn region shRepeat matchgroup=shLoop start="\<while\_s" end="\<in\_s" end="\<do\>"me=e-2 contains=@shLoopList,shDblParen,shDblBrace
196 syn region shRepeat matchgroup=shLoop start="\<until\_s" end="\<in\_s" end="\<do\>"me=e-2 contains=@shLoopList,shDblParen,shDblBrace
197 syn region shCaseEsac matchgroup=shConditional start="\<select\s" matchgroup=shConditional end="\<in\>" end="\<do\>" contains=@shLoopList
Bram Moolenaar071d4272004-06-13 20:20:40 +0000198else
Bram Moolenaarc236c162008-07-13 17:41:49 +0000199 syn region shRepeat matchgroup=shLoop start="\<while\_s" end="\<do\>"me=e-2 contains=@shLoopList
200 syn region shRepeat matchgroup=shLoop start="\<until\_s" end="\<do\>"me=e-2 contains=@shLoopList
Bram Moolenaar071d4272004-06-13 20:20:40 +0000201endif
Bram Moolenaar572cb562005-08-05 21:35:02 +0000202syn region shCurlyIn contained matchgroup=Delimiter start="{" end="}" contains=@shCurlyList
203syn match shComma contained ","
Bram Moolenaar071d4272004-06-13 20:20:40 +0000204
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000205" Case: case...esac {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000206" ====
Bram Moolenaarc236c162008-07-13 17:41:49 +0000207syn match shCaseBar contained skipwhite "\(^\|[^\\]\)\(\\\\\)*\zs|" nextgroup=shCase,shCaseStart,shCaseBar,shComment,shCaseExSingleQuote,shCaseSingleQuote,shCaseDoubleQuote
Bram Moolenaar071d4272004-06-13 20:20:40 +0000208syn match shCaseStart contained skipwhite skipnl "(" nextgroup=shCase,shCaseBar
Bram Moolenaarc236c162008-07-13 17:41:49 +0000209syn region shCase contained skipwhite skipnl matchgroup=shSnglCase start="\%(\\.\|[^#$()'" \t]\)\{-}\zs)" end=";;" end="esac"me=s-1 contains=@shCaseList nextgroup=shCaseStart,shCase,shComment
210if (g:sh_fold_enabled % (s:sh_fold_ifdofor * 2))/s:sh_fold_ifdofor
Bram Moolenaar8dff8182006-04-06 20:18:50 +0000211 syn region shCaseEsac fold matchgroup=shConditional start="\<case\>" end="\<esac\>" contains=@shCaseEsacList
212else
213 syn region shCaseEsac matchgroup=shConditional start="\<case\>" end="\<esac\>" contains=@shCaseEsacList
214endif
Bram Moolenaardf177f62005-02-22 08:39:57 +0000215syn keyword shCaseIn contained skipwhite skipnl in nextgroup=shCase,shCaseStart,shCaseBar,shComment,shCaseExSingleQuote,shCaseSingleQuote,shCaseDoubleQuote
216if exists("b:is_bash")
217 syn region shCaseExSingleQuote matchgroup=shOperator start=+\$'+ skip=+\\\\\|\\.+ end=+'+ contains=shStringSpecial,shSpecial skipwhite skipnl nextgroup=shCaseBar contained
218else
219 syn region shCaseExSingleQuote matchgroup=Error start=+\$'+ skip=+\\\\\|\\.+ end=+'+ contains=shStringSpecial skipwhite skipnl nextgroup=shCaseBar contained
220endif
Bram Moolenaar8b6144b2006-02-08 09:20:24 +0000221syn region shCaseSingleQuote matchgroup=shOperator start=+'+ end=+'+ contains=shStringSpecial skipwhite skipnl nextgroup=shCaseBar contained
Bram Moolenaar071d4272004-06-13 20:20:40 +0000222syn region shCaseDoubleQuote matchgroup=shOperator start=+"+ skip=+\\\\\|\\.+ end=+"+ contains=@shDblQuoteList,shStringSpecial skipwhite skipnl nextgroup=shCaseBar contained
223syn region shCaseCommandSub start=+`+ skip=+\\\\\|\\.+ end=+`+ contains=@shCommandSubList skipwhite skipnl nextgroup=shCaseBar contained
224
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000225" Misc: {{{1
226"======
Bram Moolenaar071d4272004-06-13 20:20:40 +0000227syn match shWrapLineOperator "\\$"
228syn region shCommandSub start="`" skip="\\\\\|\\." end="`" contains=@shCommandSubList
Bram Moolenaarc236c162008-07-13 17:41:49 +0000229syn match shEscape contained '\\.'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000230
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000231" $() and $(()): {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000232" $(..) is not supported by sh (Bourne shell). However, apparently
233" some systems (HP?) have as their /bin/sh a (link to) Korn shell
234" (ie. Posix compliant shell). /bin/ksh should work for those
235" systems too, however, so the following syntax will flag $(..) as
236" an Error under /bin/sh. By consensus of vimdev'ers!
237if exists("b:is_kornshell") || exists("b:is_bash")
238 syn region shCommandSub matchgroup=shCmdSubRegion start="\$(" skip='\\\\\|\\.' end=")" contains=@shCommandSubList
Bram Moolenaarc236c162008-07-13 17:41:49 +0000239 syn region shArithmetic matchgroup=shArithRegion start="\$((" skip='\\\\\|\\.' end="))" contains=@shArithList
Bram Moolenaar071d4272004-06-13 20:20:40 +0000240 syn match shSkipInitWS contained "^\s\+"
241else
Bram Moolenaardf177f62005-02-22 08:39:57 +0000242 syn region shCommandSub matchgroup=Error start="\$(" end=")" contains=@shCommandSubList
Bram Moolenaar071d4272004-06-13 20:20:40 +0000243endif
244
245if exists("b:is_bash")
246 syn cluster shCommandSubList add=bashSpecialVariables,bashStatement
247 syn cluster shCaseList add=bashAdminStatement,bashStatement
248 syn keyword bashSpecialVariables contained BASH BASH_ENV BASH_VERSINFO BASH_VERSION CDPATH DIRSTACK EUID FCEDIT FIGNORE GLOBIGNORE GROUPS HISTCMD HISTCONTROL HISTFILE HISTFILESIZE HISTIGNORE HISTSIZE HOME HOSTFILE HOSTNAME HOSTTYPE IFS IGNOREEOF INPUTRC LANG LC_ALL LC_COLLATE LC_MESSAGES LINENO MACHTYPE MAIL MAILCHECK MAILPATH OLDPWD OPTARG OPTERR OPTIND OSTYPE PATH PIPESTATUS PPID PROMPT_COMMAND PS1 PS2 PS3 PS4 PWD RANDOM REPLY SECONDS SHELLOPTS SHLVL TIMEFORMAT TIMEOUT UID auto_resume histchars
249 syn keyword bashStatement chmod clear complete du egrep expr fgrep find gnufind gnugrep grep install less ls mkdir mv rm rmdir rpm sed sleep sort strip tail touch
250 syn keyword bashAdminStatement daemon killall killproc nice reload restart start status stop
251endif
252
253if exists("b:is_kornshell")
254 syn cluster shCommandSubList add=kshSpecialVariables,kshStatement
255 syn cluster shCaseList add=kshStatement
256 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
257 syn keyword kshStatement cat chmod clear cp du egrep expr fgrep find grep install killall less ls mkdir mv nice printenv rm rmdir sed sort strip stty tail touch tput
258endif
259
260syn match shSource "^\.\s"
261syn match shSource "\s\.\s"
262syn region shColon start="^\s*:" end="$\|" end="#"me=e-1 contains=@shColonList
263
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000264" String And Character Constants: {{{1
265"================================
Bram Moolenaar9964e462007-05-05 17:54:07 +0000266syn match shNumber "-\=\<\d\+\>#\="
267syn match shCtrlSeq "\\\d\d\d\|\\[abcfnrtv0]" contained
Bram Moolenaardf177f62005-02-22 08:39:57 +0000268if exists("b:is_bash")
269 syn match shSpecial "\\\o\o\o\|\\x\x\x\|\\c.\|\\[abefnrtv]" contained
Bram Moolenaardf177f62005-02-22 08:39:57 +0000270endif
271if exists("b:is_bash")
272 syn region shExSingleQuote matchgroup=shOperator start=+\$'+ skip=+\\\\\|\\.+ end=+'+ contains=shStringSpecial,shSpecial
273else
Bram Moolenaar9964e462007-05-05 17:54:07 +0000274 syn region shExSingleQuote matchGroup=Error start=+\$'+ skip=+\\\\\|\\.+ end=+'+ contains=shStringSpecial
Bram Moolenaardf177f62005-02-22 08:39:57 +0000275endif
Bram Moolenaar9964e462007-05-05 17:54:07 +0000276syn region shSingleQuote matchgroup=shOperator start=+'+ end=+'+ contains=shStringSpecial,@Spell
277syn region shDoubleQuote matchgroup=shOperator start=+"+ skip=+\\"+ end=+"+ contains=@shDblQuoteList,shStringSpecial,@Spell
Bram Moolenaar071d4272004-06-13 20:20:40 +0000278syn match shStringSpecial "[^[:print:]]" contained
Bram Moolenaar7263a772007-05-10 17:35:54 +0000279syn match shStringSpecial "\%(\\\\\)*\\[\\"'`$()#]"
280syn match shSpecial "[^\\]\zs\%(\\\\\)*\\[\\"'`$()#]"
281syn match shSpecial "^\%(\\\\\)*\\[\\"'`$()#]"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000282
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000283" Comments: {{{1
284"==========
Bram Moolenaar071d4272004-06-13 20:20:40 +0000285syn cluster shCommentGroup contains=shTodo,@Spell
Bram Moolenaar18144c82006-04-12 21:52:12 +0000286syn keyword shTodo contained COMBAK FIXME TODO XXX
Bram Moolenaar7263a772007-05-10 17:35:54 +0000287syn match shComment "^\s*\zs#.*$" contains=@shCommentGroup
Bram Moolenaarc236c162008-07-13 17:41:49 +0000288syn match shComment "\s\zs#.*$" contains=@shCommentGroup
289syn match shQuickComment contained "#.*$"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000290
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000291" Here Documents: {{{1
292" =========================================
Bram Moolenaar071d4272004-06-13 20:20:40 +0000293if version < 600
294 syn region shHereDoc matchgroup=shRedir start="<<\s*\**END[a-zA-Z_0-9]*\**" matchgroup=shRedir end="^END[a-zA-Z_0-9]*$" contains=@shDblQuoteList
295 syn region shHereDoc matchgroup=shRedir start="<<-\s*\**END[a-zA-Z_0-9]*\**" matchgroup=shRedir end="^\s*END[a-zA-Z_0-9]*$" contains=@shDblQuoteList
296 syn region shHereDoc matchgroup=shRedir start="<<\s*\**EOF\**" matchgroup=shRedir end="^EOF$" contains=@shDblQuoteList
297 syn region shHereDoc matchgroup=shRedir start="<<-\s*\**EOF\**" matchgroup=shRedir end="^\s*EOF$" contains=@shDblQuoteList
298 syn region shHereDoc matchgroup=shRedir start="<<\s*\**\.\**" matchgroup=shRedir end="^\.$" contains=@shDblQuoteList
299 syn region shHereDoc matchgroup=shRedir start="<<-\s*\**\.\**" matchgroup=shRedir end="^\s*\.$" contains=@shDblQuoteList
300
Bram Moolenaarc236c162008-07-13 17:41:49 +0000301elseif (g:sh_fold_enabled % (s:sh_fold_heredoc * 2))/s:sh_fold_heredoc
Bram Moolenaar9964e462007-05-05 17:54:07 +0000302 syn region shHereDoc matchgroup=shRedir fold start="<<\s*\z(\S*\)" matchgroup=shRedir end="^\z1\s*$" contains=@shDblQuoteList
Bram Moolenaarcd71fa32005-03-11 22:46:48 +0000303 syn region shHereDoc matchgroup=shRedir fold start="<<\s*\"\z(\S*\)\"" matchgroup=shRedir end="^\z1\s*$"
304 syn region shHereDoc matchgroup=shRedir fold start="<<\s*'\z(\S*\)'" matchgroup=shRedir end="^\z1\s*$"
305 syn region shHereDoc matchgroup=shRedir fold start="<<-\s*\z(\S*\)" matchgroup=shRedir end="^\s*\z1\s*$" contains=@shDblQuoteList
306 syn region shHereDoc matchgroup=shRedir fold start="<<-\s*\"\z(\S*\)\"" matchgroup=shRedir end="^\s*\z1\s*$"
307 syn region shHereDoc matchgroup=shRedir fold start="<<-\s*'\z(\S*\)'" matchgroup=shRedir end="^\s*\z1\s*$"
308 syn region shHereDoc matchgroup=shRedir fold start="<<\s*\\\_$\_s*\z(\S*\)" matchgroup=shRedir end="^\z1\s*$"
309 syn region shHereDoc matchgroup=shRedir fold start="<<\s*\\\_$\_s*\"\z(\S*\)\"" matchgroup=shRedir end="^\z1\s*$"
310 syn region shHereDoc matchgroup=shRedir fold start="<<-\s*\\\_$\_s*'\z(\S*\)'" matchgroup=shRedir end="^\s*\z1\s*$"
311 syn region shHereDoc matchgroup=shRedir fold start="<<-\s*\\\_$\_s*\z(\S*\)" matchgroup=shRedir end="^\s*\z1\s*$"
312 syn region shHereDoc matchgroup=shRedir fold start="<<-\s*\\\_$\_s*\"\z(\S*\)\"" matchgroup=shRedir end="^\s*\z1\s*$"
313 syn region shHereDoc matchgroup=shRedir fold start="<<\s*\\\_$\_s*'\z(\S*\)'" matchgroup=shRedir end="^\z1\s*$"
Bram Moolenaar9964e462007-05-05 17:54:07 +0000314 syn region shHereDoc matchgroup=shRedir fold start="<<\\\z(\S*\)" matchgroup=shRedir end="^\z1\s*$"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000315
Bram Moolenaar071d4272004-06-13 20:20:40 +0000316else
Bram Moolenaarcd71fa32005-03-11 22:46:48 +0000317 syn region shHereDoc matchgroup=shRedir start="<<\s*\\\=\z(\S*\)" matchgroup=shRedir end="^\z1\s*$" contains=@shDblQuoteList
318 syn region shHereDoc matchgroup=shRedir start="<<\s*\"\z(\S*\)\"" matchgroup=shRedir end="^\z1\s*$"
319 syn region shHereDoc matchgroup=shRedir start="<<-\s*\z(\S*\)" matchgroup=shRedir end="^\s*\z1\s*$" contains=@shDblQuoteList
320 syn region shHereDoc matchgroup=shRedir start="<<-\s*'\z(\S*\)'" matchgroup=shRedir end="^\s*\z1\s*$"
321 syn region shHereDoc matchgroup=shRedir start="<<\s*'\z(\S*\)'" matchgroup=shRedir end="^\z1\s*$"
322 syn region shHereDoc matchgroup=shRedir start="<<-\s*\"\z(\S*\)\"" matchgroup=shRedir end="^\s*\z1\s*$"
323 syn region shHereDoc matchgroup=shRedir start="<<\s*\\\_$\_s*\z(\S*\)" matchgroup=shRedir end="^\z1\s*$"
324 syn region shHereDoc matchgroup=shRedir start="<<-\s*\\\_$\_s*\z(\S*\)" matchgroup=shRedir end="^\s*\z1\s*$"
325 syn region shHereDoc matchgroup=shRedir start="<<-\s*\\\_$\_s*'\z(\S*\)'" matchgroup=shRedir end="^\s*\z1\s*$"
326 syn region shHereDoc matchgroup=shRedir start="<<\s*\\\_$\_s*'\z(\S*\)'" matchgroup=shRedir end="^\z1\s*$"
327 syn region shHereDoc matchgroup=shRedir start="<<\s*\\\_$\_s*\"\z(\S*\)\"" matchgroup=shRedir end="^\z1\s*$"
328 syn region shHereDoc matchgroup=shRedir start="<<-\s*\\\_$\_s*\"\z(\S*\)\"" matchgroup=shRedir end="^\s*\z1\s*$"
Bram Moolenaar9964e462007-05-05 17:54:07 +0000329 syn region shHereDoc matchgroup=shRedir start="<<\\\z(\S*\)" matchgroup=shRedir end="^\z1\s*$"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000330endif
331
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000332" Here Strings: {{{1
333" =============
334if exists("b:is_bash")
335 syn match shRedir "<<<"
336endif
337
338" Identifiers: {{{1
339"=============
Bram Moolenaarc236c162008-07-13 17:41:49 +0000340syn match shSetOption "\s\zs[-+][a-zA-Z0-9]\+\>" contained
341syn match shVariable "\<\([bwglsav]:\)\=[a-zA-Z0-9.!@_%+,]*\ze=" nextgroup=shSetIdentifier
342syn match shSetIdentifier "=" contained nextgroup=shPattern,shDeref,shDerefSimple,shDoubleQuote,shSingleQuote,shExSingleQuote
Bram Moolenaar071d4272004-06-13 20:20:40 +0000343if exists("b:is_bash")
Bram Moolenaarc236c162008-07-13 17:41:49 +0000344 syn region shSetList oneline matchgroup=shSet start="\<\(declare\|typeset\|local\|export\|unset\)\>\ze[^/]" end="$" matchgroup=shOperator end="\ze[}|);&]" matchgroup=NONE end="\ze#\|=" contains=@shIdList
345 syn region shSetList oneline matchgroup=shSet start="\<set\>\ze[^/]" end="\ze[;|)]\|$" matchgroup=shOperator end="\ze[}|);&]" matchgroup=NONE end="\ze[#=]" contains=@shIdList
Bram Moolenaar071d4272004-06-13 20:20:40 +0000346elseif exists("b:is_kornshell")
Bram Moolenaarc236c162008-07-13 17:41:49 +0000347 syn region shSetList oneline matchgroup=shSet start="\<\(typeset\|export\|unset\)\>\ze[^/]" end="$" matchgroup=shOperator end="\ze[}|);&]" matchgroup=NONE end="\ze[#=]" contains=@shIdList
348 syn region shSetList oneline matchgroup=shSet start="\<set\>\ze[^/]" end="$" matchgroup=shOperator end="\ze[}|);&]" matchgroup=NONE end="\ze[#=]" contains=@shIdList
Bram Moolenaar071d4272004-06-13 20:20:40 +0000349else
Bram Moolenaarc236c162008-07-13 17:41:49 +0000350 syn region shSetList oneline matchgroup=shSet start="\<\(set\|export\|unset\)\>\ze[^/]" end="$" matchgroup=shOperator end="\ze[}|);&]" matchgroup=NONE end="\ze[#=]" contains=@shIdList
Bram Moolenaar071d4272004-06-13 20:20:40 +0000351endif
352
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000353" Functions: {{{1
Bram Moolenaarc236c162008-07-13 17:41:49 +0000354if !exists("g:is_posix")
355 syn keyword shFunctionKey function skipwhite skipnl nextgroup=shFunctionTwo
356endif
357
358if exists("b:is_bash")
359 if (g:sh_fold_enabled % (s:sh_fold_functions * 2))/s:sh_fold_functions
360 syn region shFunctionOne fold matchgroup=shFunction start="^\s*\h[-a-zA-Z_0-9]*\s*()\_s*{" end="}" contains=@shFunctionList skipwhite skipnl nextgroup=shFunctionStart,shQuickComment
361 syn region shFunctionTwo fold matchgroup=shFunction start="\h[-a-zA-Z_0-9]*\s*\%(()\)\=\_s*{" end="}" contains=shFunctionKey,@shFunctionList contained skipwhite skipnl nextgroup=shFunctionStart,shQuickComment
362 else
363 syn region shFunctionOne matchgroup=shFunction start="^\s*\h[-a-zA-Z_0-9]*\s*()\_s*{" end="}" contains=@shFunctionList
364 syn region shFunctionTwo matchgroup=shFunction start="\h[-a-zA-Z_0-9]*\s*\%(()\)\=\_s*{" end="}" contains=shFunctionKey,@shFunctionList contained
365 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000366else
Bram Moolenaarc236c162008-07-13 17:41:49 +0000367 if (g:sh_fold_enabled % (s:sh_fold_functions * 2))/s:sh_fold_functions
368 syn region shFunctionOne fold matchgroup=shFunction start="^\s*\h\w*\s*()\_s*{" end="}" contains=@shFunctionList skipwhite skipnl nextgroup=shFunctionStart,shQuickComment
369 syn region shFunctionTwo fold matchgroup=shFunction start="\h\w*\s*\%(()\)\=\_s*{" end="}" contains=shFunctionKey,@shFunctionList contained skipwhite skipnl nextgroup=shFunctionStart,shQuickComment
370 else
371 syn region shFunctionOne matchgroup=shFunction start="^\s*\h\w*\s*()\_s*{" end="}" contains=@shFunctionList
372 syn region shFunctionTwo matchgroup=shFunction start="\h\w*\s*\%(()\)\=\_s*{" end="}" contains=shFunctionKey,@shFunctionList contained
373 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000374endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000375
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000376" Parameter Dereferencing: {{{1
377" ========================
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000378syn match shDerefSimple "\$\%(\h\w*\|\d\)"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000379syn region shDeref matchgroup=PreProc start="\${" end="}" contains=@shDerefList,shDerefVarArray
380syn match shDerefWordError "[^}$[]" contained
381syn match shDerefSimple "\$[-#*@!?]"
382syn match shDerefSimple "\$\$"
383if exists("b:is_bash") || exists("b:is_kornshell")
384 syn region shDeref matchgroup=PreProc start="\${##\=" end="}" contains=@shDerefList
Bram Moolenaarc236c162008-07-13 17:41:49 +0000385 syn region shDeref matchgroup=PreProc start="\${\$\$" end="}" contains=@shDerefList
Bram Moolenaar071d4272004-06-13 20:20:40 +0000386endif
387
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000388" bash: ${!prefix*} and ${#parameter}: {{{1
389" ====================================
Bram Moolenaar071d4272004-06-13 20:20:40 +0000390if exists("b:is_bash")
391 syn region shDeref matchgroup=PreProc start="\${!" end="\*\=}" contains=@shDerefList,shDerefOp
392 syn match shDerefVar contained "{\@<=!\w\+" nextgroup=@shDerefVarList
393endif
394
395syn match shDerefSpecial contained "{\@<=[-*@?0]" nextgroup=shDerefOp,shDerefOpError
396syn match shDerefSpecial contained "\({[#!]\)\@<=[[:alnum:]*@_]\+" nextgroup=@shDerefVarList,shDerefOp
397syn match shDerefVar contained "{\@<=\w\+" nextgroup=@shDerefVarList
398
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000399" sh ksh bash : ${var[... ]...} array reference: {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000400syn region shDerefVarArray contained matchgroup=shDeref start="\[" end="]" contains=@shCommandSubList nextgroup=shDerefOp,shDerefOpError
401
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000402" Special ${parameter OPERATOR word} handling: {{{1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000403" sh ksh bash : ${parameter:-word} word is default value
404" sh ksh bash : ${parameter:=word} assign word as default value
405" sh ksh bash : ${parameter:?word} display word if parameter is null
406" sh ksh bash : ${parameter:+word} use word if parameter is not null, otherwise nothing
407" ksh bash : ${parameter#pattern} remove small left pattern
408" ksh bash : ${parameter##pattern} remove large left pattern
409" ksh bash : ${parameter%pattern} remove small right pattern
410" ksh bash : ${parameter%%pattern} remove large right pattern
411syn cluster shDerefPatternList contains=shDerefPattern,shDerefString
412syn match shDerefOpError contained ":[[:punct:]]"
413syn match shDerefOp contained ":\=[-=?]" nextgroup=@shDerefPatternList
414syn match shDerefOp contained ":\=+" nextgroup=@shDerefPatternList
415if exists("b:is_bash") || exists("b:is_kornshell")
416 syn match shDerefOp contained "#\{1,2}" nextgroup=@shDerefPatternList
417 syn match shDerefOp contained "%\{1,2}" nextgroup=@shDerefPatternList
Bram Moolenaar5b8d8fd2005-08-16 23:01:50 +0000418 syn match shDerefPattern contained "[^{}]\+" contains=shDeref,shDerefSimple,shDerefPattern,shDerefString,shCommandSub,shDerefEscape nextgroup=shDerefPattern
Bram Moolenaar071d4272004-06-13 20:20:40 +0000419 syn region shDerefPattern contained start="{" end="}" contains=shDeref,shDerefSimple,shDerefString,shCommandSub nextgroup=shDerefPattern
Bram Moolenaar5b8d8fd2005-08-16 23:01:50 +0000420 syn match shDerefEscape contained '\%(\\\\\)*\\.'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000421endif
Bram Moolenaarc236c162008-07-13 17:41:49 +0000422syn region shDerefString contained matchgroup=shOperator start=+\%(\\\)\@<!'+ end=+'+ contains=shStringSpecial
423syn region shDerefString contained matchgroup=shOperator start=+\%(\\\)\@<!"+ skip=+\\"+ end=+"+ contains=@shDblQuoteList,shStringSpecial
424syn match shDerefString contained "\\["']" nextgroup=shDerefPattern
Bram Moolenaar071d4272004-06-13 20:20:40 +0000425
Bram Moolenaar071d4272004-06-13 20:20:40 +0000426if exists("b:is_bash")
Bram Moolenaar5b8d8fd2005-08-16 23:01:50 +0000427 " bash : ${parameter:offset}
428 " bash : ${parameter:offset:length}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000429 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 +0000430 syn match shDerefPOL contained ":[^}]\+" contains=@shCommandSubList
431
432 " bash : ${parameter//pattern/string}
433 " bash : ${parameter//pattern}
434 syn match shDerefPPS contained '/\{1,2}' nextgroup=shDerefPPSleft
Bram Moolenaara5792f52005-11-23 21:25:05 +0000435 syn region shDerefPPSleft contained start='.' skip=@\%(\\\)\/@ matchgroup=shDerefOp end='/' end='\ze}' nextgroup=shDerefPPSright contains=@shCommandSubList
Bram Moolenaar5b8d8fd2005-08-16 23:01:50 +0000436 syn region shDerefPPSright contained start='.' end='\ze}' contains=@shCommandSubList
Bram Moolenaar071d4272004-06-13 20:20:40 +0000437endif
438
Bram Moolenaarc236c162008-07-13 17:41:49 +0000439" Arithmetic Parenthesized Expressions: {{{1
440syn region shParen matchgroup=shArithRegion start='(\ze[^(]' end=')' contains=@shArithParenList
441
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000442" Useful sh Keywords: {{{1
443" ===================
Bram Moolenaar071d4272004-06-13 20:20:40 +0000444syn keyword shStatement break cd chdir continue eval exec exit kill newgrp pwd read readonly return shift test trap ulimit umask wait
445syn keyword shConditional contained elif else then
446syn keyword shCondError elif else then
447
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000448" Useful ksh Keywords: {{{1
449" ====================
Bram Moolenaar071d4272004-06-13 20:20:40 +0000450if exists("b:is_kornshell") || exists("b:is_bash")
Bram Moolenaarc236c162008-07-13 17:41:49 +0000451 syn keyword shStatement autoload bg false fc fg functions getopts hash history integer jobs let nohup print printf r stop suspend times true type unalias whence
452 if exists("g:is_posix")
453 syn keyword shStatement command
454 else
455 syn keyword shStatement time
456 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000457
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000458" Useful bash Keywords: {{{1
459" =====================
Bram Moolenaar071d4272004-06-13 20:20:40 +0000460 if exists("b:is_bash")
461 syn keyword shStatement bind builtin dirs disown enable help local logout popd pushd shopt source
462 else
463 syn keyword shStatement login newgrp
464 endif
465endif
466
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000467" Synchronization: {{{1
468" ================
Bram Moolenaar071d4272004-06-13 20:20:40 +0000469if !exists("sh_minlines")
470 let sh_minlines = 200
471endif
472if !exists("sh_maxlines")
473 let sh_maxlines = 2 * sh_minlines
474endif
475exec "syn sync minlines=" . sh_minlines . " maxlines=" . sh_maxlines
476syn sync match shCaseEsacSync grouphere shCaseEsac "\<case\>"
477syn sync match shCaseEsacSync groupthere shCaseEsac "\<esac\>"
478syn sync match shDoSync grouphere shDo "\<do\>"
479syn sync match shDoSync groupthere shDo "\<done\>"
480syn sync match shForSync grouphere shFor "\<for\>"
481syn sync match shForSync groupthere shFor "\<in\>"
482syn sync match shIfSync grouphere shIf "\<if\>"
483syn sync match shIfSync groupthere shIf "\<fi\>"
484syn sync match shUntilSync grouphere shRepeat "\<until\>"
485syn sync match shWhileSync grouphere shRepeat "\<while\>"
486
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000487" Default Highlighting: {{{1
488" =====================
Bram Moolenaar071d4272004-06-13 20:20:40 +0000489hi def link shArithRegion shShellVariables
Bram Moolenaardf177f62005-02-22 08:39:57 +0000490hi def link shBeginHere shRedir
Bram Moolenaar071d4272004-06-13 20:20:40 +0000491hi def link shCaseBar shConditional
Bram Moolenaar071d4272004-06-13 20:20:40 +0000492hi def link shCaseCommandSub shCommandSub
493hi def link shCaseDoubleQuote shDoubleQuote
Bram Moolenaardf177f62005-02-22 08:39:57 +0000494hi def link shCaseIn shConditional
Bram Moolenaar071d4272004-06-13 20:20:40 +0000495hi def link shCaseSingleQuote shSingleQuote
496hi def link shCaseStart shConditional
497hi def link shCmdSubRegion shShellVariables
498hi def link shColon shStatement
Bram Moolenaar071d4272004-06-13 20:20:40 +0000499hi def link shDerefOp shOperator
Bram Moolenaardf177f62005-02-22 08:39:57 +0000500hi def link shDerefPOL shDerefOp
Bram Moolenaar5b8d8fd2005-08-16 23:01:50 +0000501hi def link shDerefPPS shDerefOp
Bram Moolenaardf177f62005-02-22 08:39:57 +0000502hi def link shDeref shShellVariables
Bram Moolenaar071d4272004-06-13 20:20:40 +0000503hi def link shDerefSimple shDeref
504hi def link shDerefSpecial shDeref
505hi def link shDerefString shDoubleQuote
Bram Moolenaardf177f62005-02-22 08:39:57 +0000506hi def link shDerefVar shDeref
Bram Moolenaar071d4272004-06-13 20:20:40 +0000507hi def link shDoubleQuote shString
508hi def link shEcho shString
Bram Moolenaarc236c162008-07-13 17:41:49 +0000509hi def link shEchoQuote shString
Bram Moolenaar071d4272004-06-13 20:20:40 +0000510hi def link shEmbeddedEcho shString
Bram Moolenaarc236c162008-07-13 17:41:49 +0000511hi def link shEscape shCommandSub
Bram Moolenaardf177f62005-02-22 08:39:57 +0000512hi def link shExSingleQuote shSingleQuote
Bram Moolenaarc236c162008-07-13 17:41:49 +0000513hi def link shFunction Function
Bram Moolenaar071d4272004-06-13 20:20:40 +0000514hi def link shHereDoc shString
Bram Moolenaardf177f62005-02-22 08:39:57 +0000515hi def link shHerePayload shHereDoc
Bram Moolenaar071d4272004-06-13 20:20:40 +0000516hi def link shLoop shStatement
517hi def link shOption shCommandSub
518hi def link shPattern shString
Bram Moolenaarc236c162008-07-13 17:41:49 +0000519hi def link shParen shArithmetic
Bram Moolenaar071d4272004-06-13 20:20:40 +0000520hi def link shPosnParm shShellVariables
Bram Moolenaarc236c162008-07-13 17:41:49 +0000521hi def link shQuickComment shComment
Bram Moolenaar071d4272004-06-13 20:20:40 +0000522hi def link shRange shOperator
523hi def link shRedir shOperator
Bram Moolenaarc236c162008-07-13 17:41:49 +0000524hi def link shSetOption shOption
Bram Moolenaar071d4272004-06-13 20:20:40 +0000525hi def link shSingleQuote shString
526hi def link shSource shOperator
527hi def link shStringSpecial shSpecial
528hi def link shSubShRegion shOperator
529hi def link shTestOpr shConditional
Bram Moolenaar9964e462007-05-05 17:54:07 +0000530hi def link shTestPattern shString
531hi def link shTestDoubleQuote shString
532hi def link shTestSingleQuote shString
Bram Moolenaar071d4272004-06-13 20:20:40 +0000533hi def link shVariable shSetList
534hi def link shWrapLineOperator shOperator
535
536if exists("b:is_bash")
537 hi def link bashAdminStatement shStatement
538 hi def link bashSpecialVariables shShellVariables
539 hi def link bashStatement shStatement
Bram Moolenaarcd71fa32005-03-11 22:46:48 +0000540 hi def link shFunctionParen Delimiter
541 hi def link shFunctionDelim Delimiter
Bram Moolenaar071d4272004-06-13 20:20:40 +0000542endif
543if exists("b:is_kornshell")
544 hi def link kshSpecialVariables shShellVariables
545 hi def link kshStatement shStatement
Bram Moolenaarcd71fa32005-03-11 22:46:48 +0000546 hi def link shFunctionParen Delimiter
Bram Moolenaar071d4272004-06-13 20:20:40 +0000547endif
548
549hi def link shCaseError Error
550hi def link shCondError Error
551hi def link shCurlyError Error
552hi def link shDerefError Error
553hi def link shDerefOpError Error
554hi def link shDerefWordError Error
555hi def link shDoError Error
556hi def link shEsacError Error
557hi def link shIfError Error
558hi def link shInError Error
559hi def link shParenError Error
560hi def link shTestError Error
561if exists("b:is_kornshell")
562 hi def link shDTestError Error
563endif
564
565hi def link shArithmetic Special
566hi def link shCharClass Identifier
567hi def link shSnglCase Statement
568hi def link shCommandSub Special
569hi def link shComment Comment
570hi def link shConditional Conditional
Bram Moolenaar9964e462007-05-05 17:54:07 +0000571hi def link shCtrlSeq Special
Bram Moolenaar071d4272004-06-13 20:20:40 +0000572hi def link shExprRegion Delimiter
Bram Moolenaarcd71fa32005-03-11 22:46:48 +0000573hi def link shFunctionKey Function
Bram Moolenaar071d4272004-06-13 20:20:40 +0000574hi def link shFunctionName Function
575hi def link shNumber Number
576hi def link shOperator Operator
577hi def link shRepeat Repeat
578hi def link shSet Statement
579hi def link shSetList Identifier
580hi def link shShellVariables PreProc
581hi def link shSpecial Special
582hi def link shStatement Statement
583hi def link shString String
584hi def link shTodo Todo
585hi def link shAlias Identifier
586
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000587" Set Current Syntax: {{{1
588" ===================
Bram Moolenaar071d4272004-06-13 20:20:40 +0000589if exists("b:is_bash")
590 let b:current_syntax = "bash"
591elseif exists("b:is_kornshell")
592 let b:current_syntax = "ksh"
593else
594 let b:current_syntax = "sh"
595endif
596
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000597" vim: ts=16 fdm=marker