[Bash-completion-devel] [bash-completion-Bugs][311858] _get_cword breaks command substitution
bash-completion-bugs at alioth.debian.org
bash-completion-bugs at alioth.debian.org
Sun Sep 20 21:41:48 UTC 2009
Bugs item #311858, was changed at 2009-07-30 19:41 by Freddy Vulto
You can respond by visiting:
https://alioth.debian.org/tracker/?func=detail&atid=413095&aid=311858&group_id=100114
Status: Open
Priority: 3
Submitted By: Ville Skyttä (scop-guest)
Assigned to: Nobody (None)
Summary: _get_cword breaks command substitution
Distribution: None
Originally reported in: Fedora / Red Hat Bugzilla
Milestone: None
Status: None
Original bug number: 512625
Initial Comment:
_get_cword breaks command substitutions ($(...), `...`) by turning them into literal strings.
For example, when one writes "somecommand $(cat /tmp/f<TAB>" the intention is to complete /tmp/f* files, but if the "somecommand" completion does `_get_cword`, that stuff turns to a literal '$(cat /tmp/f' string which is then processed later in the "somecommand" completion function.
----------------------------------------------------------------------
>Comment By: Freddy Vulto (fvu-guest)
Date: 2009-09-20 23:41
Message:
This is also the default what is in COMP_CWORDS[COMP_CWORD]:
$ a $(b c
COMP_CWORD: 1
COMP_WORDS:
0: a
1: $(b c
Since _get_cword's only intention is/was to take the current
cursor position into account, I'm inclined to leave things the
way they are. Returning `c' would mean re-parsing `$(b c'
which may not be as easy as it seems, regarding handling all
situations with possible quotes and nested meta-characters,
e.g. $(w3m 'foo bar'<TAB>
What strikes me though, is that bash is starting completion
for `a' whereas bash would do a better job starting completion
for `b', especially since bash already knows that a subshell
is invoked, because it does command completion on `b' in this
case:
$ a $(b<TAB>
bash
bashbug
batch
bc
To reproduce:
1. Install completions for a & b:
_a() { echo a; }
_b() { echo b; }
complete -F _a a
complete -F _b b
2. Complete a:
$ a $(b c<TAB>
Bash replies with 'a' instead of 'b'.
Do you agree that bash should start completion for b? I'm
inclined to report this as a bug/feature request on bug-bash?
----------------------------------------------------------------------
You can respond by visiting:
https://alioth.debian.org/tracker/?func=detail&atid=413095&aid=311858&group_id=100114
More information about the Bash-completion-devel
mailing list