Bug#468366: vim: Wrong highlighting for sh arithmetic expressions

2008-03-02 Thread Charles E. Campbell, Jr.

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 

Bug#468366: vim: Wrong highlighting for sh arithmetic expressions

2008-03-02 Thread James Vega
On Sun, Mar 02, 2008 at 05:38:44PM -0500, Charles E. Campbell, Jr. wrote:
 The  was getting treated as the start of a here document -- so that  
 explains the treated as text problem.  Please try the attached file.

Works great.  Thanks.

-- 
James
GPG Key: 1024D/61326D40 2003-09-02 James Vega [EMAIL PROTECTED]


signature.asc
Description: Digital signature


Bug#468366: vim: Wrong highlighting for sh arithmetic expressions

2008-02-28 Thread Edward Allcutt
Package: vim
Version: 1:7.1-241+1
Severity: minor

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.


-- System Information:
Debian Release: lenny/sid
  APT prefers testing
  APT policy: (900, 'testing'), (800, 'unstable'), (700, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.22-3-686 (SMP w/2 CPU cores)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages vim depends on:
ii  libc6 2.7-6  GNU C Library: Shared libraries
ii  libgpmg1  1.19.6-25  General Purpose Mouse - shared lib
ii  libncurses5   5.6+20080119-1 Shared libraries for terminal hand
ii  vim-common1:7.1-241+1Vi IMproved - Common files
ii  vim-runtime   1:7.1-241+1Vi IMproved - Runtime files

vim recommends no packages.

-- no debconf information



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]