(Obscure) problem with bash syntax highlighting

18 views
Skip to first unread message

J S

unread,
May 24, 2019, 7:52:39 AM5/24/19
to v...@vim.org
bash allows (yes, it is a "bashism") syntax like:

$ echo ${var:9:5}

To mean extract a substring of the variable, starting at position 9 and of length 5.

But is also allows the offset (and then length, too, but ignore that for now) to be
negative.  But, alas, as noted in "man bash", if the offset is negative, you have to
put a space after the :, in order to avoid ambiguity with the usual ${var:-xxx}
construct.  So, you have to write:

$ echo ${var: -9:5}

Alas, vim flags this as an error.  If I take out the space before the -, the
highlighting is OK.  But with the space, it is flagged as error.

Can this be fixed?

Note: I tried contacting the listed author/maintainer (Charles Campbell) via email first (before posting this), but the mail bounced.  It looks like the sh.vim file hasn't been updated since 2014.

Note also: This was tested under VIM 7.4 (which is what I use).  If it has been fixed in a later version, please let me know.

L A Walsh

unread,
May 24, 2019, 1:27:00 PM5/24/19
to vim...@googlegroups.com, v...@vim.org
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
----
ok, though isn't it more important to prune unnecessary content?
:-|



On 2019/05/21 13:17, 'J S' via vim_use wrote:
> But is also allows the offset (and then length, too, but ignore that
> for now) to be negative. But, alas, as noted in "man bash", if the
> offset is negative, you have to
> put a space after the :, in order to avoid ambiguity with the usual
> ${var:-xxx} construct. So, you have to write:
>
> $ echo ${var: -9:5}
>
> Alas, vim flags this as an error. If I take out the space before the
> -, the highlighting is OK. But with the space, it is flagged as error.
>
> Can this be fixed?
Not that it fixes the syntax, but I've always used "${var:0-9:5}" so the
field
would clearly stand out as starting with an integer and not the ambiguous
'dash'. Is that flagged as an error too?

Just curious....

-l

Tony Mechelynck

unread,
May 24, 2019, 2:48:59 PM5/24/19
to vim_use
On Fri, May 24, 2019 at 1:52 PM 'J S' via vim_use
<vim...@googlegroups.com> wrote:
[...]
> Note: I tried contacting the listed author/maintainer (Charles Campbell) via email first (before posting this), but the mail bounced. It looks like the sh.vim file hasn't been updated since 2014.

Dr. Chip's adress is listed in $VIMRUNTIME/syntax/sh.vim as:

" Maintainer: Charles E. Campbell <NdrO...@PcampbellAfamily.Mbiz>

which is intentionally obfuscated to avoid spamming. Remove the
letters making up NOSPAM to get his actual email address.

Best regards,
Tony.

Gary Johnson

unread,
May 24, 2019, 3:08:05 PM5/24/19
to vim_use
Also, the latest version (as of 8.1.1200) in $VIMRUNTIME/syntax is
version 186, last changed on March 26, 2019.

Regards,
Gary

Reply all
Reply to author
Forward
0 new messages