#769399 bash-completion: gets confused by curly braces

#769399#5
Date:
2014-11-13 11:36:20 UTC
From:
To:
Hi,

it seems that curly braces aren't handled too well by bash-completion.
See this example, with set -x for debugging, and hitting TAB after "git diff
@{-1} -- dri":

  $ git diff @{-1} -- dri+ local compfile=./completions
  + [[ /usr/share/bash-completion/bash_completion == */* ]]
  + compfile=/usr/share/bash-completion/completions
  + compfile+='/-1}'
  + [[ -f /usr/share/bash-completion/completions/-1} ]]
  + complete -F _minimal '-1}'
  bash: complete: -1: invalid option
  complete: usage: complete <bla-bla...>

When the @{-1} is quoted, "dri" is correctly expanded to "drivers".

Another, similar breakage:

  $ r drivers/memory/tegra/tegra{-,124-e}mc.c dri+ local compfile=./completions
  + [[ /usr/share/bash-completion/bash_completion == */* ]]
  + compfile=/usr/share/bash-completion/completions
  + compfile+='/-,124-e}mc.c'
  + [[ -f /usr/share/bash-completion/completions/-,124-e}mc.c ]]
  + complete -F _minimal '-,124-e}mc.c'
  bash: complete: -,: invalid option
  complete: usage: complete <blabla...>

The errors shows up in _completion_loader, but I'm not sure if things don't
break earlier.

Nikolaus

#769399#10
Date:
2014-11-15 19:40:27 UTC
From:
To:
The root cause is how bash itself handles curlies:

$ bash --norc
$ foo() { echo; echo "'$1'"; }
$ complete -D -F foo
$ r drivers/memory/tegra/tegra{-,124-e}mc.c dri<TAB>
'-,124-e}mc.c'

...i.e. bash thinks we're completing the command '-,124-e}mc.c'.

I don't think we can sanely fix this for real in bash completion, but
this commit will improve things -- no more errors, and minimal
filename completion activated:
http://anonscm.debian.org/cgit/bash-completion/bash-completion.git/commit/?id=32e6e49