[Bash-completion-devel] RFC: Better long option with argument completion

Ville Skyttä ville.skytta at iki.fi
Mon Apr 13 17:21:24 UTC 2009


On Monday 13 April 2009, David Paleino wrote:
> On Mon, 13 Apr 2009 14:23:09 +0300, Ville Skyttä wrote:

> The patch looks good to me, just one *curiosity* (i.e. only curiosity,
> nothing to fix :P): why are you quoting
>
> +		prev="${cur%%?(\\)=*}"
> +		cur="${cur#*=}"
>
> ?

No particular reason, just a habit and general paranoia when working with 
shell code that I can't shake even when working with strict bash only code ;)

> I'm in favour of *always* quoting things, just to be safe, but was just
> curious if there was a specific reason here.

I'm actually in slightly favour of not quoting when it's known that quoting 
isn't needed, keeps things slightly more readable.  But no strong opinions 
here.

> I never found a longopt with embedded space :)

I have seen some whose values contain spaces, but anyway I don't think it'd 
matter in bash (this is with 3.2.39(1)-release), I think the braces are enough 
for it to grok what's going on:

$ cur="--foo=bar quux"
+ cur='--foo=bar quux'
$ prev=${cur%%?(\\)=*}
+ prev=--foo
$ cur=${cur#*=}
+ cur='bar quux'

$ cur="--foo bar=quux"
+ cur='--foo bar=quux'
$ prev=${cur%%?(\\)=*}
+ prev='--foo bar'
$ cur=${cur#*=}
+ cur=quux

> > Comments?  I would like to commit _split_longopt soon and start changing
> > existing completions to use it.
>
> I'm fully in favour of it.

Cool.

> As soon as you'll commit the patch (if there are no other objections), I'll
> start fixing completions too. :)

Ok, will wait until tomorrow to see if there are other opinions.



More information about the Bash-completion-devel mailing list