Bug 438989

Summary: Picky: vim coloring for bash scripts handles a special case wrongly
Product: Red Hat Enterprise Linux 4 Reporter: David Tonhofer <bughunt>
Component: vimAssignee: Karsten Hopp <karsten>
Status: CLOSED DEFERRED QA Contact:
Severity: low Docs Contact:
Priority: low    
Version: 4.8   
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-10-30 13:17:55 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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\)"