James Vega wrote:
Charles,
As shown below, sh.vim is too loosely interpreting the arithmetic
expansion syntax. As noted in Bash's manpage and SUS[0], arithmetic
expansion should be treated as if the contained expression were within
double quotes. shArithmetic should contain a cluster that doesn't
include shSubSh.
Also, I noticed that the default syntax highlighting highlights $(()) as
an error. Should that be the case since it is specified in SUS?
On Thu, Feb 28, 2008 at 10:31:15AM -0500, Edward Allcutt wrote:
The following is highlighted badly:
start file
#!/bin/bash
echo $(( ( 2 5 ) + 1 ))
echo foo bar
end file ==
The 5 is the wrong colour and everything following until the end of file
is highlighted as if it were quoted text. Removing the parentheses around
the sub-expression corrects the highlighting but changes the meaning of the
expression.
Hello!
The was getting treated as the start of a here document -- so that
explains the treated as text problem. Please try the attached file.
Regards,
Chip Campbell
[0] -
http://www.opengroup.org/onlinepubs/95399/utilities/xcu_chap02.html#tag_02_06_04
Vim syntax file
Language: shell (sh) Korn shell (ksh) bash (sh)
Maintainer: Dr. Charles E. Campbell, Jr. [EMAIL PROTECTED]
Previous Maintainer: Lennart Schultz [EMAIL PROTECTED]
Last Change: Mar 02, 2008
Version: 96 ASTRO-ONLY
URL:
http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax
For options and settings, please use: :help ft-sh-syntax
This file includes many ideas from Éric Brunet ([EMAIL PROTECTED])
For version 5.x: Clear all syntax items {{{1
For version 6.x: Quit when a syntax file was already loaded
if version 600
syntax clear
elseif exists(b:current_syntax)
finish
endif
handling /bin/sh with is_kornshell/is_sh {{{1
b:is_sh is set when #! /bin/sh is found;
However, it often is just a masquerade by bash (typically Linux)
or kornshell (typically workstations with Posix sh).
So, when the user sets is_bash or is_kornshell,
a b:is_sh is converted into b:is_bash/b:is_kornshell,
respectively.
if !exists(b:is_kornshell) !exists(b:is_bash)
if exists(g:is_posix) !exists(g:is_kornshell)
let g:is_kornshell= g:is_posix
endif
if exists(g:is_kornshell)
let b:is_kornshell= 1
if exists(b:is_sh)
unlet b:is_sh
endif
elseif exists(g:is_bash)
let b:is_bash= 1
if exists(b:is_sh)
unlet b:is_sh
endif
else
let b:is_sh= 1
endif
endif
set up default g:sh_fold_enabled {{{1
if !exists(g:sh_fold_enabled)
let g:sh_fold_enabled= 0
elseif g:sh_fold_enabled != 0 !has(folding)
let g:sh_fold_enabled= 0
echomsg Ignoring g:sh_fold_enabled=.g:sh_fold_enabled.; need to re-compile
vim for +fold support
endif
if !exists(s:sh_fold_functions)
let s:sh_fold_functions = 1
endif
if !exists(s:sh_fold_heredoc)
let s:sh_fold_heredoc = 2
endif
if !exists(s:sh_fold_ifdofor)
let s:sh_fold_ifdofor = 4
endif
if g:sh_fold_enabled fdm == manual
set fdm=syntax
endif
sh syntax is case sensitive {{{1
syn case match
Clusters: [EMAIL PROTECTED] clusters {{{1
==
syn cluster shErrorList
contains=shDoError,shIfError,shInError,shCaseError,shEsacError,shCurlyError,shParenError,shTestError
if exists(b:is_kornshell)
syn cluster ErrorList add=shDTestError
endif
syn cluster shArithParenList
contains=shArithmetic,shDeref,shDerefSimple,shEscape,shNumber,shOperator,shPosnParm,shExSingleQuote,shSingleQuote,shDoubleQuote,shStatement,shVariable,shAlias,shTest,shCtrlSeq,shSpecial,shParen
syn cluster shArithList [EMAIL PROTECTED],shParenError
syn cluster shCaseEsacList
contains=shCaseStart,shCase,shCaseBar,shCaseIn,shComment,shDeref,shDerefSimple,shCaseCommandSub,shCaseExSingleQuote,shCaseSingleQuote,shCaseDoubleQuote,shCtrlSeq,@shErrorList,shStringSpecial
syn cluster shCaseList [EMAIL
PROTECTED],shCaseEsac,shColon,shCommandSub,shCommandSub,shComment,shDo,shEcho,shExpr,shFor,shHereDoc,shIf,shRedir,shSetList,shSource,shStatement,shVariable,shCtrlSeq
syn cluster shColonList [EMAIL PROTECTED]
syn cluster shCommandSubList
contains=shArithmetic,shDeref,shDerefSimple,shEscape,shNumber,shOperator,shPosnParm,shExSingleQuote,shSingleQuote,shDoubleQuote,shStatement,shVariable,shSubSh,shAlias,shTest,shCtrlSeq,shSpecial
syn cluster shCurlyList
contains=shNumber,shComma,shDeref,shDerefSimple,shDerefSpecial
syn cluster shDblQuoteList
contains=shCommandSub,shDeref,shDerefSimple,shPosnParm,shExSingleQuote,shCtrlSeq,shSpecial
syn cluster shDerefList
contains=shDeref,shDerefSimple,shDerefVar,shDerefSpecial,shDerefWordError,shDerefPPS
syn cluster shDerefVarList
contains=shDerefOp,shDerefVarArray,shDerefOpError
syn cluster shEchoList
contains=shArithmetic,shCommandSub,shDeref,shDerefSimple,shExpr,shExSingleQuote,shSingleQuote,shDoubleQuote,shCtrlSeq,shEchoQuote
syn cluster shExprList1