Bug 438989 - Picky: vim coloring for bash scripts handles a special case wrongly
Picky: vim coloring for bash scripts handles a special case wrongly
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: vim (Show other bugs)
All Linux
low Severity low
: rc
: ---
Assigned To: Karsten Hopp
Depends On:
  Show dependency treegraph
Reported: 2008-03-26 09:07 EDT by David Tonhofer
Modified: 2008-10-30 09:17 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2008-10-30 09:17:55 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description David Tonhofer 2008-03-26 09:07:18 EDT
Description of problem:

vim colors the text of a bash script, so that syntactic elements have different
colors depending on how bash will interprete them (is this correctly expressed?)

For example using "colorscheme murphy" (in ~/.vimrc) the text

echo $ALPHA

would have the token "echo" in yellow and the token "$ALPHA" in blue for example.

The text 

echo "foo$ALPHA.bar"

would have echo   in yellow
           "      in yellow
           $ALPHA in blue (a to be resolved variable)
           .bar   in green (text not part of the variable)

A special case is

echo $10

This is interpreted by bash as "print the value of $1, then print 0", not
as "print the value of $10", which would be "echo ${10}"

vim colors this wrongly

It colors it with "echo" in yellow, "$10" in blue.

It should color it with "echo" in yellow, "$1" in blue, "0" in green.

Very obscure indeed.

Version-Release number of selected component (if applicable):


How reproducible:

Comment 1 Karsten Hopp 2008-10-30 09:17:55 EDT
The current Fedora 10 version seems to get this right, '1' is colored differently than '0' with your testcase. Unfortunately I'm not allowed to push a new package with such a minor fix, but I'll try to get this bugzilla approved when I have to do the next vim erratum (non-security only).
I think a fix would be to edit /usr/share/vim/vim63/syntax/sh.vim and replace the line

syn match  shDerefSimple        "\$\w\+"


syn match  shDerefSimple        "\$\%(\h*\w*\|\d\)"

Note You need to log in before you can comment on or make changes to this bug.