comparison runtime/syntax/sh.vim @ 167:c93c9cad9618

updated for version 7.0051
author vimboss
date Tue, 22 Feb 2005 08:39:57 +0000
parents e8f07016e34d
children 3b32f6b507fa
comparison
equal deleted inserted replaced
166:3a28ed993bbe 167:c93c9cad9618
1 " Vim syntax file 1 " Vim syntax file
2 " Language: shell (sh) Korn shell (ksh) bash (sh) 2 " Language: shell (sh) Korn shell (ksh) bash (sh)
3 " Maintainer: Dr. Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz> 3 " Maintainer: Dr. Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz>
4 " Previous Maintainer: Lennart Schultz <Lennart.Schultz@ecmwf.int> 4 " Previous Maintainer: Lennart Schultz <Lennart.Schultz@ecmwf.int>
5 " Last Change: Dec 28, 2004 5 " Last Change: Feb 16, 2005
6 " Version: 71 6 " Version: 72
7 " URL: http://www.erols.com/astronaut/vim/index.html#vimlinks_syntax 7 " URL: http://www.erols.com/astronaut/vim/index.html#vimlinks_syntax
8 " 8 "
9 " Using the following VIM variables: {{{1 9 " Using the following VIM variables: {{{1
10 " b:is_kornshell if defined, enhance with kornshell syntax 10 " b:is_kornshell if defined, enhance with kornshell syntax
11 " b:is_bash if defined, enhance with bash syntax 11 " b:is_bash if defined, enhance with bash syntax
61 " sh syntax is case sensitive 61 " sh syntax is case sensitive
62 syn case match 62 syn case match
63 63
64 " Clusters: contains=@... clusters {{{1 64 " Clusters: contains=@... clusters {{{1
65 "================================== 65 "==================================
66 syn cluster shCaseEsacList contains=shCaseStart,shCase,shCaseBar,shCaseIn,shComment,shDeref,shDerefSimple,shCaseCommandSub,shCaseSingleQuote,shCaseDoubleQuote,shSpecial 66 syn cluster shCaseEsacList contains=shCaseStart,shCase,shCaseBar,shCaseIn,shComment,shDeref,shDerefSimple,shCaseCommandSub,shCaseExSingleQuote,shCaseSingleQuote,shCaseDoubleQuote,shSpecial
67 syn cluster shCaseList contains=@shCommandSubList,shCaseEsac,shColon,shCommandSub,shCommandSub,shComment,shDo,shEcho,shExpr,shFor,shHereDoc,shIf,shRedir,shSetList,shSource,shStatement,shVariable,bkshFunction,shSpecial 67 syn cluster shCaseList contains=@shCommandSubList,shCaseEsac,shColon,shCommandSub,shCommandSub,shComment,shDo,shEcho,shExpr,shFor,shHereDoc,shIf,shRedir,shSetList,shSource,shStatement,shVariable,bkshFunction,shSpecial
68 syn cluster shColonList contains=@shCaseList 68 syn cluster shColonList contains=@shCaseList
69 syn cluster shCommandSubList contains=shArithmetic,shDeref,shDerefSimple,shNumber,shOperator,shPosnParm,shSpecial,shSingleQuote,shDoubleQuote,shStatement,shVariable,shSubSh,shAlias,shTest 69 syn cluster shCommandSubList contains=shArithmetic,shDeref,shDerefSimple,shNumber,shOperator,shPosnParm,shSpecial,shExSingleQuote,shSingleQuote,shDoubleQuote,shStatement,shVariable,shSubSh,shAlias,shTest
70 syn cluster shDblQuoteList contains=shCommandSub,shDeref,shDerefSimple,shSpecial,shPosnParm 70 syn cluster shDblQuoteList contains=shCommandSub,shDeref,shDerefSimple,shSpecial,shPosnParm
71 syn cluster shDerefList contains=shDeref,shDerefSimple,shDerefVar,shDerefSpecial,shDerefWordError 71 syn cluster shDerefList contains=shDeref,shDerefSimple,shDerefVar,shDerefSpecial,shDerefWordError
72 syn cluster shDerefVarList contains=shDerefOp,shDerefVarArray,shDerefOpError 72 syn cluster shDerefVarList contains=shDerefOp,shDerefVarArray,shDerefOpError
73 syn cluster shEchoList contains=shArithmetic,shCommandSub,shDeref,shDerefSimple,shExpr,shSingleQuote,shDoubleQuote,shSpecial 73 syn cluster shEchoList contains=shArithmetic,shCommandSub,shDeref,shDerefSimple,shExpr,shExSingleQuote,shSingleQuote,shDoubleQuote,shSpecial
74 syn cluster shExprList1 contains=shCharClass,shNumber,shOperator,shSingleQuote,shDoubleQuote,shSpecial,shExpr,shDblBrace,shDeref,shDerefSimple 74 syn cluster shExprList1 contains=shCharClass,shNumber,shOperator,shExSingleQuote,shSingleQuote,shDoubleQuote,shSpecial,shExpr,shDblBrace,shDeref,shDerefSimple
75 syn cluster shExprList2 contains=@shExprList1,@shCaseList,shTest 75 syn cluster shExprList2 contains=@shExprList1,@shCaseList,shTest
76 syn cluster shFunctionList contains=@shCaseList,shOperator 76 syn cluster shFunctionList contains=@shCaseList,shOperator
77 syn cluster shHereBeginList contains=@shCommandSubList 77 syn cluster shHereBeginList contains=@shCommandSubList
78 syn cluster shHereList contains=shBeginHere,shHerePayload 78 syn cluster shHereList contains=shBeginHere,shHerePayload
79 syn cluster shHereListDQ contains=shBeginHere,@shDblQuoteList,shHerePayload 79 syn cluster shHereListDQ contains=shBeginHere,@shDblQuoteList,shHerePayload
80 syn cluster shIdList contains=shCommandSub,shWrapLineOperator,shIdWhiteSpace,shDeref,shDerefSimple,shSpecial,shRedir,shSingleQuote,shDoubleQuote,shExpr 80 syn cluster shIdList contains=shCommandSub,shWrapLineOperator,shIdWhiteSpace,shDeref,shDerefSimple,shSpecial,shRedir,shExSingleQuote,shSingleQuote,shDoubleQuote,shExpr
81 syn cluster shLoopList contains=@shCaseList,shTestOpr,shExpr,shDblBrace,shConditional,shCaseEsac,shTest 81 syn cluster shLoopList contains=@shCaseList,shTestOpr,shExpr,shDblBrace,shConditional,shCaseEsac,shTest
82 syn cluster shSubShList contains=@shCaseList 82 syn cluster shSubShList contains=@shCaseList
83 syn cluster shTestList contains=shCharClass,shComment,shCommandSub,shDeref,shDerefSimple,shDoubleQuote,shExpr,shExpr,shNumber,shOperator,shSingleQuote,shSpecial,shTestOpr,shTest 83 syn cluster shTestList contains=shCharClass,shComment,shCommandSub,shDeref,shDerefSimple,shDoubleQuote,shExpr,shExpr,shNumber,shOperator,shExSingleQuote,shSingleQuote,shSpecial,shTestOpr,shTest
84 84
85 85
86 " Echo: {{{1 86 " Echo: {{{1
87 " ==== 87 " ====
88 " This one is needed INSIDE a CommandSub, so that `echo bla` be correct 88 " This one is needed INSIDE a CommandSub, so that `echo bla` be correct
89 syn 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 89 syn 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
90 syn 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 90 syn 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
91 91
92 " This must be after the strings, so that bla \" be correct 92 " This must be after the strings, so that bla \" be correct
93 syn 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,shSingleQuote,shDeref,shDerefSimple,shSpecialVar,shSpecial,shOperator,shDoubleQuote,shCharClass 93 syn 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,shSpecial,shOperator,shDoubleQuote,shCharClass
94 94
95 " Alias: {{{1 95 " Alias: {{{1
96 " ===== 96 " =====
97 if exists("b:is_kornshell") || exists("b:is_bash") 97 if exists("b:is_kornshell") || exists("b:is_bash")
98 syn match shStatement "\<alias\>" 98 syn match shStatement "\<alias\>"
122 " Operators: {{{1 122 " Operators: {{{1
123 " ========== 123 " ==========
124 syn match shOperator "[!&;|]" 124 syn match shOperator "[!&;|]"
125 syn match shOperator "\[[[^:]\|\]]" 125 syn match shOperator "\[[[^:]\|\]]"
126 syn match shOperator "!\==" skipwhite nextgroup=shPattern 126 syn match shOperator "!\==" skipwhite nextgroup=shPattern
127 syn match shPattern "\<\S\+\())\)\@=" contained contains=shSingleQuote,shDoubleQuote,shDeref 127 syn match shPattern "\<\S\+\())\)\@=" contained contains=shExSingleQuote,shSingleQuote,shDoubleQuote,shDeref
128 128
129 " Subshells: {{{1 129 " Subshells: {{{1
130 " ========== 130 " ==========
131 syn region shExpr transparent matchgroup=shExprRegion start="{" end="}" contains=@shExprList2 131 syn region shExpr transparent matchgroup=shExprRegion start="{" end="}" contains=@shExprList2
132 syn region shSubSh transparent matchgroup=shSubShRegion start="(" end=")" contains=@shSubShList 132 syn region shSubSh transparent matchgroup=shSubShRegion start="(" end=")" contains=@shSubShList
161 syn region shRepeat matchgroup=shLoop start="\<until\>" end="\<do\>"me=e-2 contains=@shLoopList 161 syn region shRepeat matchgroup=shLoop start="\<until\>" end="\<do\>"me=e-2 contains=@shLoopList
162 endif 162 endif
163 163
164 " Case: case...esac {{{1 164 " Case: case...esac {{{1
165 " ==== 165 " ====
166 syn match shCaseBar contained skipwhite "[^|"`'()]\{-}|"hs=e nextgroup=shCase,shCaseStart,shCaseBar,shComment,shCaseSingleQuote,shCaseDoubleQuote 166 syn match shCaseBar contained skipwhite "[^|"`'()]\{-}|"hs=e nextgroup=shCase,shCaseStart,shCaseBar,shComment,shCaseExSingleQuote,shCaseSingleQuote,shCaseDoubleQuote
167 syn match shCaseStart contained skipwhite skipnl "(" nextgroup=shCase,shCaseBar 167 syn match shCaseStart contained skipwhite skipnl "(" nextgroup=shCase,shCaseBar
168 syn region shCase contained skipwhite skipnl matchgroup=shSnglCase start="[^$()]\{-})"ms=s,hs=e end=";;" end="esac"me=s-1 contains=@shCaseList nextgroup=shCaseStart,shCase,,shComment 168 syn region shCase contained skipwhite skipnl matchgroup=shSnglCase start="[^$()]\{-})"ms=s,hs=e end=";;" end="esac"me=s-1 contains=@shCaseList nextgroup=shCaseStart,shCase,,shComment
169 syn region shCaseEsac matchgroup=shConditional start="\<case\>" end="\<esac\>" contains=@shCaseEsacList 169 syn region shCaseEsac matchgroup=shConditional start="\<case\>" end="\<esac\>" contains=@shCaseEsacList
170 syn keyword shCaseIn contained skipwhite skipnl in nextgroup=shCase,shCaseStart,shCaseBar,shComment,shCaseSingleQuote,shCaseDoubleQuote 170 syn keyword shCaseIn contained skipwhite skipnl in nextgroup=shCase,shCaseStart,shCaseBar,shComment,shCaseExSingleQuote,shCaseSingleQuote,shCaseDoubleQuote
171 syn region shCaseSingleQuote matchgroup=shOperator start=+'+ skip=+\\\\\|\\.+ end=+'+ contains=shStringSpecial skipwhite skipnl nextgroup=shCaseBar contained 171 if exists("b:is_bash")
172 syn region shCaseExSingleQuote matchgroup=shOperator start=+\$'+ skip=+\\\\\|\\.+ end=+'+ contains=shStringSpecial,shSpecial skipwhite skipnl nextgroup=shCaseBar contained
173 else
174 syn region shCaseExSingleQuote matchgroup=Error start=+\$'+ skip=+\\\\\|\\.+ end=+'+ contains=shStringSpecial skipwhite skipnl nextgroup=shCaseBar contained
175 endif
176 syn region shCaseSingleQuote matchgroup=shOperator start=+'+ end=+'+ contains=shStringSpecial skipwhite skipnl nextgroup=shCaseBar contained
172 syn region shCaseDoubleQuote matchgroup=shOperator start=+"+ skip=+\\\\\|\\.+ end=+"+ contains=@shDblQuoteList,shStringSpecial skipwhite skipnl nextgroup=shCaseBar contained 177 syn region shCaseDoubleQuote matchgroup=shOperator start=+"+ skip=+\\\\\|\\.+ end=+"+ contains=@shDblQuoteList,shStringSpecial skipwhite skipnl nextgroup=shCaseBar contained
173 syn region shCaseCommandSub start=+`+ skip=+\\\\\|\\.+ end=+`+ contains=@shCommandSubList skipwhite skipnl nextgroup=shCaseBar contained 178 syn region shCaseCommandSub start=+`+ skip=+\\\\\|\\.+ end=+`+ contains=@shCommandSubList skipwhite skipnl nextgroup=shCaseBar contained
174 179
175 " Misc: {{{1 180 " Misc: {{{1
176 "====== 181 "======
186 if exists("b:is_kornshell") || exists("b:is_bash") 191 if exists("b:is_kornshell") || exists("b:is_bash")
187 syn region shCommandSub matchgroup=shCmdSubRegion start="\$(" skip='\\\\\|\\.' end=")" contains=@shCommandSubList 192 syn region shCommandSub matchgroup=shCmdSubRegion start="\$(" skip='\\\\\|\\.' end=")" contains=@shCommandSubList
188 syn region shArithmetic matchgroup=shArithRegion start="\$((" skip='\\\\\|\\.' end="))" contains=@shCommandSubList 193 syn region shArithmetic matchgroup=shArithRegion start="\$((" skip='\\\\\|\\.' end="))" contains=@shCommandSubList
189 syn match shSkipInitWS contained "^\s\+" 194 syn match shSkipInitWS contained "^\s\+"
190 else 195 else
191 syn region shCommandSub matchgroup=Error start="$(" end=")" contains=@shCommandSubList 196 syn region shCommandSub matchgroup=Error start="\$(" end=")" contains=@shCommandSubList
192 endif 197 endif
193 198
194 if exists("b:is_bash") 199 if exists("b:is_bash")
195 syn cluster shCommandSubList add=bashSpecialVariables,bashStatement 200 syn cluster shCommandSubList add=bashSpecialVariables,bashStatement
196 syn cluster shCaseList add=bashAdminStatement,bashStatement 201 syn cluster shCaseList add=bashAdminStatement,bashStatement
211 syn region shColon start="^\s*:" end="$\|" end="#"me=e-1 contains=@shColonList 216 syn region shColon start="^\s*:" end="$\|" end="#"me=e-1 contains=@shColonList
212 217
213 " String And Character Constants: {{{1 218 " String And Character Constants: {{{1
214 "================================ 219 "================================
215 syn match shNumber "-\=\<\d\+\>" 220 syn match shNumber "-\=\<\d\+\>"
216 syn match shSpecial "\\\d\d\d\|\\[abcfnrtv0]" contained 221 if exists("b:is_bash")
222 syn match shSpecial "\\\o\o\o\|\\x\x\x\|\\c.\|\\[abefnrtv]" contained
223 else
224 syn match shSpecial "\\\d\d\d\|\\[abcfnrtv0]" contained
225 endif
226 if exists("b:is_bash")
227 syn region shExSingleQuote matchgroup=shOperator start=+\$'+ skip=+\\\\\|\\.+ end=+'+ contains=shStringSpecial,shSpecial
228 else
229 syn region shExSingleQuote matchGroup=Error start=+\$'+ skip=+\\\\\|\\.+ end=+'+ contains=shStringSpecial,shSpecial
230 endif
217 syn region shSingleQuote matchgroup=shOperator start=+'+ end=+'+ contains=shStringSpecial 231 syn region shSingleQuote matchgroup=shOperator start=+'+ end=+'+ contains=shStringSpecial
218 syn region shDoubleQuote matchgroup=shOperator start=+"+ skip=+\\"+ end=+"+ contains=@shDblQuoteList,shStringSpecial 232 syn region shDoubleQuote matchgroup=shOperator start=+"+ skip=+\\"+ end=+"+ contains=@shDblQuoteList,shStringSpecial
219 syn match shStringSpecial "[^[:print:]]" contained 233 syn match shStringSpecial "[^[:print:]]" contained
220 syn match shSpecial "\\[\\\"\'`$()#]" 234 syn match shSpecial "\\[\\\"\'`$()#]"
221 235
312 326
313 " Identifiers: {{{1 327 " Identifiers: {{{1
314 "============= 328 "=============
315 syn match shVariable "\<\([bwglsav]:\)\=[a-zA-Z0-9.!@_%+,]*\ze=" nextgroup=shSetIdentifier 329 syn match shVariable "\<\([bwglsav]:\)\=[a-zA-Z0-9.!@_%+,]*\ze=" nextgroup=shSetIdentifier
316 syn match shIdWhiteSpace contained "\s" 330 syn match shIdWhiteSpace contained "\s"
317 syn match shSetIdentifier contained "=" nextgroup=shPattern,shDeref,shDerefSimple,shDoubleQuote,shSingleQuote 331 syn match shSetIdentifier contained "=" nextgroup=shPattern,shDeref,shDerefSimple,shDoubleQuote,shSingleQuote,shExSingleQuote
318 if exists("b:is_bash") 332 if exists("b:is_bash")
319 syn region shSetList matchgroup=shSet start="\<\(declare\|typeset\|local\|export\|unset\)\>\ze[^/]" end="$" matchgroup=shOperator end="[;&]"me=e-1 matchgroup=NONE end="#\|="me=e-1 contains=@shIdList 333 syn region shSetList matchgroup=shSet start="\<\(declare\|typeset\|local\|export\|unset\)\>\ze[^/]" end="$" matchgroup=shOperator end="[;&]"me=e-1 matchgroup=NONE end="#\|="me=e-1 contains=@shIdList
320 syn region shSetList matchgroup=shSet start="\<set\>[^/]"me=e-1 end="$" end="\\ze[|)]" matchgroup=shOperator end="[;&]"me=e-1 matchgroup=NONE end="[#=]"me=e-1 contains=@shIdList 334 syn region shSetList matchgroup=shSet start="\<set\>[^/]"me=e-1 end="$" end="\\ze[|)]" matchgroup=shOperator end="[;&]"me=e-1 matchgroup=NONE end="[#=]"me=e-1 contains=@shIdList
321 syn match shSet "\<\(declare\|typeset\|local\|export\|set\|unset\)$" 335 syn match shSet "\<\(declare\|typeset\|local\|export\|set\|unset\)$"
322 elseif exists("b:is_kornshell") 336 elseif exists("b:is_kornshell")
446 syn sync match shWhileSync grouphere shRepeat "\<while\>" 460 syn sync match shWhileSync grouphere shRepeat "\<while\>"
447 461
448 " Default Highlighting: {{{1 462 " Default Highlighting: {{{1
449 " ===================== 463 " =====================
450 hi def link shArithRegion shShellVariables 464 hi def link shArithRegion shShellVariables
465 hi def link shBeginHere shRedir
451 hi def link shCaseBar shConditional 466 hi def link shCaseBar shConditional
452 hi def link shCaseIn shConditional
453 hi def link shCaseCommandSub shCommandSub 467 hi def link shCaseCommandSub shCommandSub
454 hi def link shCaseDoubleQuote shDoubleQuote 468 hi def link shCaseDoubleQuote shDoubleQuote
469 hi def link shCaseIn shConditional
455 hi def link shCaseSingleQuote shSingleQuote 470 hi def link shCaseSingleQuote shSingleQuote
456 hi def link shCaseStart shConditional 471 hi def link shCaseStart shConditional
457 hi def link shCmdSubRegion shShellVariables 472 hi def link shCmdSubRegion shShellVariables
458 hi def link shColon shStatement 473 hi def link shColon shStatement
459 474 hi def link shDerefOp shOperator
475 hi def link shDerefPatStringOp shDerefOp
476 hi def link shDerefPatString shDerefPattern
477 hi def link shDerefPOL shDerefOp
460 hi def link shDeref shShellVariables 478 hi def link shDeref shShellVariables
461 hi def link shDerefOp shOperator
462
463 hi def link shDerefVar shDeref
464 hi def link shDerefPOL shDerefOp
465 hi def link shDerefPatString shDerefPattern
466 hi def link shDerefPatStringOp shDerefOp
467 hi def link shDerefSimple shDeref 479 hi def link shDerefSimple shDeref
468 hi def link shDerefSpecial shDeref 480 hi def link shDerefSpecial shDeref
469 hi def link shDerefString shDoubleQuote 481 hi def link shDerefString shDoubleQuote
470 hi def link shHerePayload shHereDoc 482 hi def link shDerefVar shDeref
471 hi def link shBeginHere shRedir
472
473 hi def link shDoubleQuote shString 483 hi def link shDoubleQuote shString
474 hi def link shEcho shString 484 hi def link shEcho shString
475 hi def link shEmbeddedEcho shString 485 hi def link shEmbeddedEcho shString
486 hi def link shExSingleQuote shSingleQuote
476 hi def link shHereDoc shString 487 hi def link shHereDoc shString
488 hi def link shHerePayload shHereDoc
477 hi def link shLoop shStatement 489 hi def link shLoop shStatement
478 hi def link shOption shCommandSub 490 hi def link shOption shCommandSub
479 hi def link shPattern shString 491 hi def link shPattern shString
480 hi def link shPosnParm shShellVariables 492 hi def link shPosnParm shShellVariables
481 hi def link shRange shOperator 493 hi def link shRange shOperator