Obscure shell syntax hifghlighting problem: Solved!

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Obscure shell syntax hifghlighting problem: Solved!

J S-3
On 2019/05/21 13:17, someone replied thusly to '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? 

Thank you!  Changing the space to a zero does both of these thngs:

1) Clears the VIM syntax highlighting error.

2) Does not change the bash functionality.

That zero works in bash is, of course, not mentioned in "man bash".  How did you figure that out?
Maybe I should take it up with the bash maintainer.

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/856770722.5136208.1558863606401%40mail.yahoo.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Obscure shell syntax hifghlighting problem: Solved!

Paul-7
> That zero works in bash is, of course, not mentioned in "man bash".  How did you figure that out?Maybe I should take it up with the bash maintainer.

From the manual: "If offset evaluates to a number less than zero…"

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20190526095243.GA23052%40rainslide.net.
For more options, visit https://groups.google.com/d/optout.

signature.asc (817 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Obscure shell syntax hifghlighting problem: Solved!

John Little-4
In reply to this post by J S-3
On Sunday, May 26, 2019 at 9:40:30 PM UTC+12, J S wrote:
> That zero works in bash is, of course, not mentioned in "man bash".
In the manual, in 3.5.3 Shell Parameter Expansion, it says:

In each of the cases below, word is subject to tilde expansion, parameter expansion, command substitution, and arithmetic expansion.

"0-9" is seen as arithmetic. "1-10" would serve, too.

Regards, John Little

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/8117e736-6bf8-4811-9feb-637dfa448514%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.