2017-06-12 17:52 GMT+03:00 Charles E Campbell <[email protected]>:
> Henry John Kupty wrote:
>>
>> Hi.
>>
>> The following snippet breaks the syntax highlight, making it consider
>> from this check onwards until the end of the file a string:
>>
>> if [ -n "${arg%{*}" ]; then
>> echo $arg
>> fi
>>
>> Trying to work around the bug by adding a comment closing the block
>> makes it even worse:
>>
>> if [ -n "${arg%{*}" ]; then #}"
>> echo $arg
>> fi
>>
>> I tested this on vim 8.0.
>>
>> Thanks in advance!
>>
>>
> I suspect that what you want is:
>
> if [ -n "${arg%{*}}" ]; then
> echo $arg
> fi Note the additional closing curly brace. Regards, Chip Campbell
This changes meaning of the command, your variant is completely
equivalent to `if true; then`. Could use this technique, but with
changing `-n …` to `… != '}'`, but this does not make syntax
highlighting script right.
I would though suggest escaping:
if test -n "${arg%\{*}" ; then
or
if [[ -n "${arg%\{*}" ]] ; then
if aiming only bash/zsh. The highlighting of the original variant is
closer to being right in zsh (unless zsh is in sh emulation mode or
some unknown option is turned on): it expects balanced braces, AFAIR
this makes using some features easier.
(Note `[[` is faster because it is a special syntax construct with
special evaluation process while `[` and `test` are somewhat regular
(though shell builtins in most shells) commands, with `test` not
disguising itself as being a special syntax construct unlike `[` which
looks like some kind of special syntax while it is not. You will not
notice a difference in speed normally, so I use `test` where I need
compatibility (and sometimes as a habit) because it does not pretend
being what it is not and `[[` where I do not need compatibility
because it has some other nice features like pattern matching.)
>
>
> --
> --
> You received this message from the "vim_dev" 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_dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
--
--
You received this message from the "vim_dev" 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_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.