Bug 438989 - Picky: vim coloring for bash scripts handles a special case wrongly
Summary: Picky: vim coloring for bash scripts handles a special case wrongly
Keywords:
Status: CLOSED DEFERRED
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: vim
Version: 4.8
Hardware: All
OS: Linux
low
low
Target Milestone: rc
: ---
Assignee: Karsten Hopp
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2008-03-26 13:07 UTC by David Tonhofer
Modified: 2008-10-30 13:17 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2008-10-30 13:17:55 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description David Tonhofer 2008-03-26 13:07:18 UTC
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):

vim-enhanced-6.3.046-0.40E.7

How reproducible:

Always

Comment 1 Karsten Hopp 2008-10-30 13:17:55 UTC
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\+"

with

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


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