[Bash-completion-devel] [SCM] bash-completion branch, master, updated. 1.90-47-g068a1a1

Igor Murzov e-mail at date.by
Wed Nov 16 23:42:05 UTC 2011


On Wed, 16 Nov 2011 23:58:22 +0200
Ville Skyttä <ville.skytta at iki.fi> wrote:

> On 11/16/2011 10:21 PM, Igor Murzov wrote:
> > The following commit has been merged in the master branch:
> > commit b3fcb55dcf3d5a99d9a705a54dd649a976706d3f
> > Author: Igor Murzov <e-mail at date.by>
> > Date:   Wed Nov 16 23:46:29 2011 +0300
> > 
> >     __get_cword_at_cursor_by_ref: Add missing quotes.
> >     
> >     Fixes  _get_comp_words_by_ref() and sftp tests (Alioth #313102).
> 
> Cool, fixes it for me too.  However, one question:
> 
> > -                cur="${cur#${words[i]}}"
> > +                cur="${cur#"${words[i]}"}"
> 
> This looks quite exotic to me, and I can't tell offhand in which cases
> quoting like this would be required and I'm too lazy to try figure it
> out myself right now, so could you shed some light on the scenarios when
> quoting like this (the inner quotes that start after the #) is needed?

I don't know that :) This was discovered by testing.

Example #1:
-------------------------------
$ x="a b c d e f"
$ y="a b"
$ echo "${x#$y}"
 c d e f
-------------------------------

Example #2:
-------------------------------
$ x="a\ b c\ d e\ f"
$ y="a\ b"
$ echo "${x#$y}"
a\ b c\ d e\ f
$ echo "${x#"$y"}"
 c\ d e\ f
-------------------------------

It turns out that without inner quotes bash converts "\ " to " " and this breaks things. Looks like it's better to use inner quotes everywhere for such expressions.

> BTW, I suppose the outer quotes are unnecessary, is that incorrect?

Outer quotes are still necessary, they apply to a result, and inner quotes to an argument.


-- Igor



More information about the Bash-completion-devel mailing list