vim 7.1 - sh.vim syntax file - unwarranted syntax error detected.

9 views
Skip to first unread message

Patrick Gen-Paul

unread,
Aug 29, 2009, 1:20:44 PM8/29/09
to vim...@googlegroups.com
From the kdb package in debian lenny:

$ cat /etc/init.d/console-screen.kbd.sh

1 #!/bin/sh

[some comments snipped..]

17 PKG=kbd
18 if [ -r /etc/$PKG/config ]; then
19 . /etc/$PKG/config
20 fi
21
22 if [ -d /etc/$PKG/config.d ]; then
23 for i in `run-parts --list /etc/$PKG/config.d `; do
24 . $i
25 done
26 fi
27
28 # do some magic with the variables for compatibility with the config
29 # file of console-tools
30 for vc in '' `set | grep "^.*_vc[0-9][0-9]*=" | sed
's/^.*\(_vc[0-9][0-9]*\)=.*/\1/'`
31 ..

[..]

Syntax highlighting after line 30. colors the rest of the script mostly
red - which I understand is the color used to highlight a syntax error,
but the script executes without any problems.

I believe I am using the "default" color scheme on an xterm with a black
background.

It seems things start to go wrong just after the "for vc in" statement
so it looks like either the two single quotes followed by a back quote
or possibly, the regex following the "grep" is causing the problem.

Or maybe it is the bash + sed syntax mix?

I have seen some issues with back quotes, though nothing conclusive, and
I was wondering if the $VIMRUNTIME/syntax/sh.vim maintainer was aware of
this issue?

Maybe it has been addressed or circumvented in a more recent version of
the syntax file?

Or if this is caused by a "syntax mix", is there a way to tell vim not
to report this type of error?

I'm attaching a clean copy of the entire script to this message.

Gen-Paul.


console-screen.kbd.sh

Patrick Gen-Paul

unread,
Aug 29, 2009, 5:35:58 PM8/29/09
to v...@vim.org
console-screen.kbd.sh

Patrick Gen-Paul

unread,
Aug 29, 2009, 5:37:35 PM8/29/09
to vim...@googlegroups.com
console-screen.kbd.sh

John Little

unread,
Aug 30, 2009, 6:21:11 AM8/30/09
to vim_use
>  console-screen.kbd.sh

With vim 7.2.245, the highlighting of line 30 is ok but fails on and
after line 32, even with the very latest syntax file (v108) from the
maintainer's website (http://mysite.verizon.net/astronaut/vim/
index.html#vimlinks_syntax). It doesn't like the escaped double quote
after the square bracket. The following two line shell script
exhibits the problem:

echo [ \"Lorem
echo ipsum

Dr Chip will likely see this thread, I hope this helps him, should he
be inclined to fix it.

Regards, John

Patrick Gen-Paul

unread,
Aug 31, 2009, 12:55:55 PM8/31/09
to vim...@googlegroups.com

I had downloaded the latest version of the syntax file before I posted
and indeed it doesn't make any difference.

I guess I can always send him an email to his contact address in sh.vim
if he does not respond within the next few days.

Where this particular linux init.d script is concerned, and especially
since the line that's affected is very near the beginning, it pretty
much defeats the purpose of syntax highlighting - as time allows, I'm
sure he will want to come up with a fix.

Gen-Paul.

John Little

unread,
Sep 1, 2009, 5:33:01 AM9/1/09
to vim_use
Hi

Dr Chip sent me his v109 sh.vim to try, but...

This handles my two line test case, but the OP's script is still not
highlighted correctly; the line is

eval [ \"\${SCREEN_FONT$vc}\" ] &&
eval CONSOLE_FONT$vc=3D\${CONSOLE_=
FONT$vc:-\${SCREEN_FONT$vc}}

The highlighting is still not handling escaped quotes in evals well.
My test case used echo so that the result would be a valid script, but
it was a poor choice, the following would have been better.

eval [ \"Lorem\" ]
eval ipsum

With these convoluted eval expressions IMO rendering them perfectly is
not so desirable, but getting the parsing state (f.ex. in or out of a
quoted string) right so that the rest of the file highlights properly
is desirable.

Regards, John
Reply all
Reply to author
Forward
0 new messages