[Bash-completion-devel] robustness: var=$(cmd1) cmd2 -<tab>

Ville Skyttä ville.skytta at iki.fi
Mon Dec 12 21:09:22 UTC 2011

On 12/11/2011 10:48 PM, Raphaël Droz wrote:
> Just found the following bug:
> $ var=$(id) find -<tab>
> bash: eval: line1: syntax error near unexpected « ) »
> bash: eval: line1: `local cmd=id)'

I managed to reproduce this, but only when the completion for "id" has
been already loaded.

> There is a bug from bash (completions from `id` instead of `find`) but
> bash-completion should be more robust to this.
> I didn't dug further but some entry points for variables may probably be
> sanitized (or at least quoted) a bit more.

The attached patch appears to fix it for _parse_help, without breaking
completions for commands from paths containing backslashed chars (e.g.
whitespace) or ones starting with a tilde.  _parse_usage is similarly
affected, but I'm not applying this to either because all this mess
starts to have a strong code smell on it.  I'm having a hard time
believing that it's really this hard to get stuff to work, are we doing
something wrong?  There must be a cleaner way.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: foo.diff
URL: <http://lists.alioth.debian.org/pipermail/bash-completion-devel/attachments/20111212/fcdd8645/attachment.ksh>

More information about the Bash-completion-devel mailing list