[Bash-completion-devel] RFC: Better long option with argument completion
d.paleino at gmail.com
Mon Apr 13 16:05:40 UTC 2009
On Mon, 13 Apr 2009 14:23:09 +0300, Ville Skyttä wrote:
> Currently completion of long options that take arguments is pretty bad.
> For an example, many completions list things like "--foo=" in their compgen
> -W strings which end up completed as "--foo\= " which is annoying, especially
> the trailing space. Some completions use "internal" workarounds for this
> which is suboptimal from maintenance point of view.
> With bash 4.x I suppose we could use compopt -o nospace but I suggest doing
> something about this already now.
> So I came up with the attached patch. The idea is that for all long options
> that take an argument and can take it in both "--foo=bar" and "--foo bar"
> forms, we only list "--foo" (not "--foo=") in completions, run it through
> _split_longopt, and code the completion logic as if "--foo bar" had been
> passed and it'll work for both "--foo=bar" and "--foo bar".
The patch looks good to me, just one *curiosity* (i.e. only curiosity, nothing
to fix :P): why are you quoting
? I'm in favour of *always* quoting things, just to be safe, but was just
curious if there was a specific reason here. I never found a longopt with
embedded space :)
> Additionally, using the return value of _split_longopt we can "return 0"
> early to avoid doing potentially weird/slow things with last resort default
> completions later when a --foo=bar thing is being completed and we don't have
> specific completions for the required argument for --foo (the assumption
> being that if --foo= is specified, --foo requires an argument).
Good, that would speed up things a bit.
> The attached patch contains _split_longopt and a few modifications to
> existing completions to illustrate its usage and how it helps and what kind
> of cleanups and improved features it allows.
> Comments? I would like to commit _split_longopt soon and start changing
> existing completions to use it.
I'm fully in favour of it.
As soon as you'll commit the patch (if there are no other objections), I'll
start fixing completions too. :)
Thank you for your work,
. ''`. Debian maintainer | http://wiki.debian.org/DavidPaleino
: :' : Linuxer #334216 --|-- http://www.hanskalabs.net/
`. `'` GPG: 1392B174 ----|---- http://snipr.com/qa_page
`- 2BAB C625 4E66 E7B8 450A C3E1 E6AA 9017 1392 B174
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 197 bytes
Desc: not available
More information about the Bash-completion-devel