Error in bash syntax file

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Error in bash syntax file

J S-3
The following line of legal bash code gets flagged as an error:

echo ${@:i:1}

The above line displays the i'th command line argument.

I am running vim 8.1, with lots of patches applied.  My sh.vim files (3 of them) are all dated Jun 15, 2019.

--
--
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/362297683.6459386.1596059832744%40mail.yahoo.com.
Reply | Threaded
Open this post in threaded view
|

Re: Error in bash syntax file

Tony Mechelynck
On Wed, Jul 29, 2020 at 11:57 PM 'J S' via vim_use
<[hidden email]> wrote:
>
> The following line of legal bash code gets flagged as an error:
>
> echo ${@:i:1}
>
> The above line displays the i'th command line argument.
>
> I am running vim 8.1, with lots of patches applied.  My sh.vim files (3 of them) are all dated Jun 15, 2019.

Can you please try a more recent version? I am running a Vim 8.2.1360
which I compiled yesterday night  (2020-08-03 23:06:35 UTC) and my
$VIMRUNTIME/syntax/sh.vim (which is the script responsible for syntax
highlighting, including flagging syntax errors) is dated April 14,
2020.

Also, if all your shell scripts are for bash (and *might* use syntax
acceptable to bash but not to legacy sh) you should have
    let is_bash = 1
somewhere in your vimrc; if _some_ scripts are bash-specific but
others aren't, you could set this variable to 1, or unset it (and
possibly set another one e.g. is_kornshell), _immediately before_
starting to edit such a script.

see :help ft-bash-syntax for details.

Best regards,
Tony.

--
--
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/CAJkCKXt5%3Dh5%2Bq8EqGAh1FkO3sn-c09EOE2b0nL1EZbQrMpzvFQ%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Error in bash syntax file

Charles Campbell-2
In reply to this post by J S-3
'J S' via vim_use wrote:
> The following line of legal bash code gets flagged as an error:
>
> echo ${@:i:1}
>
> The above line displays the i'th command line argument.
>
> I am running vim 8.1, with lots of patches applied.  My sh.vim files (3 of them) are all dated Jun 15, 2019.
>
Hmm, that format, ${@:var1:var2} doesn't appear to be explicitly
mentioned in the bash man page (although ${parameter:var1:var2} is).
So, please try the sh.vim from my website:
http://www.drchip.org/astronaut/vim/index.html#SYNTAX_SH (put it into
your personal $HOME/.vim/syntax folder).

Regards,
Chip Campbell

--
--
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/9c4ddd20-dafc-c7a0-47e1-da55b48d1e86%40drchip.org.
Reply | Threaded
Open this post in threaded view
|

Re: Error in bash syntax file

J S-3
In reply to this post by J S-3
i can confirm that using the latest sh.vim file from your website (installed as you suggested, in my private .vim directory) fixes the problem. Thank you for that.


Regarding your comment:

> Hmm, that format, ${@:var1:var2} doesn't appear to be explicitly
> mentioned in the bash man page (although ${parameter:var1:var2} is).

I don't know if it is ever explicitly mentioned, but it is pretty clear that @ can generally be used throughout to refer to all the args together, sort of as if they were all concatenated together. I find the bash man page large and complicated, so I can't say for sure how explicitly stated this is.

Also, just out of passing interest, I tested this under VIM 7.4 at some point and the bug did not present, so it seems to have been introduced between then and now.

Anyway, I am considering this as "problem solved".
On Wednesday, July 29, 2020, 05:57:32 PM EDT, 'J S' via vim_use <[hidden email]> wrote:


The following line of legal bash code gets flagged as an error:

echo ${@:i:1}

The above line displays the i'th command line argument.

I am running vim 8.1, with lots of patches applied.  My sh.vim files (3 of them) are all dated Jun 15, 2019.

--
--
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 vim_use+[hidden email]
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/362297683.6459386.1596059832744%40mail.yahoo.com.

--
--
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/964897860.1852609.1597507966094%40mail.yahoo.com.
Reply | Threaded
Open this post in threaded view
|

Re: Error in bash syntax file

Tony Mechelynck
On Sat, Aug 15, 2020 at 6:13 PM 'J S' via vim_use
<[hidden email]> wrote:

>
> i can confirm that using the latest sh.vim file from your website (installed as you suggested, in my private .vim directory) fixes the problem. Thank you for that.
>
>
> Regarding your comment:
>
> > Hmm, that format, ${@:var1:var2} doesn't appear to be explicitly
> > mentioned in the bash man page (although ${parameter:var1:var2} is).
>
> I don't know if it is ever explicitly mentioned, but it is pretty clear that @ can generally be used throughout to refer to all the args together, sort of as if they were all concatenated together. I find the bash man page large and complicated, so I can't say for sure how explicitly stated this is.

At line 384sqq of the bash manpage for GNU Bash 4.4, part of section PARAMETERS:

       @      Expands to the positional parameters, starting from one.
When the expansion occurs within double quotes, each parameter expands
to a separate word.  That is, "$@" is equivalent to "$1" "$2" ...   If
 the  double-quoted  expansion
              occurs within a word, the expansion of the first
parameter is joined with the beginning part of the original word, and
the expansion of the last parameter is joined with the last part of
the original word.  When there are no posi-
              tional parameters, "$@" and $@ expand to nothing (i.e.,
they are removed).

>
> Also, just out of passing interest, I tested this under VIM 7.4 at some point and the bug did not present, so it seems to have been introduced between then and now.
>
> Anyway, I am considering this as "problem solved".
> On Wednesday, July 29, 2020, 05:57:32 PM EDT, 'J S' via vim_use <[hidden email]> wrote:
>
>
> The following line of legal bash code gets flagged as an error:
>
> echo ${@:i:1}
>
> The above line displays the i'th command line argument.
>
> I am running vim 8.1, with lots of patches applied.  My sh.vim files (3 of them) are all dated Jun 15, 2019.
>
> --
> --
> 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/362297683.6459386.1596059832744%40mail.yahoo.com.
>
> --
> --
> 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/964897860.1852609.1597507966094%40mail.yahoo.com.

--
--
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/CAJkCKXtBeSwf%3DimWnu8og8%2Bc1%2BS1aEz4%3DFkiZXVUdsZH%3Dv2_Ow%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Error in bash syntax file

J S-3
In reply to this post by J S-3
Regarding the below commentary by me in response to Chip, upon which Tony saw fit to comment (by quoting the bash manual):

I have no need for manual quoting or any lack of understanding about how @ works. I was merely responding to Chip's implicit statement that there's nothing in the bash manual explicitly mentioning the ${@:expr:expr} syntax. In agreement with Chip, I was noting that there is adequate documentation therein of what @ does and of what ${var:expr:expr} does, but you sort of have to "read between the lines" to put the two together.

With that said, I think we have reached end of thread.

On Saturday, August 15, 2020, 12:13:06 PM EDT, 'J S' via vim_use <[hidden email]> wrote:

> Hmm, that format, ${@:var1:var2} doesn't appear to be explicitly
> mentioned in the bash man page (although ${parameter:var1:var2} is).

I don't know if it is ever explicitly mentioned, but it is pretty clear that @ can generally be used throughout to refer to all the args together, sort of as if they were all concatenated together. I find the bash man page large and complicated, so I can't say for sure how explicitly stated this is.

--
--
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/1640953580.2058364.1597597099446%40mail.yahoo.com.