bash-completion-Bugs item #311858, was changed at 2012-11-06 21:00 by Ville 
Skyttä
You can respond by visiting: 
https://alioth.debian.org/tracker/?func=detail&atid=413095&aid=311858&group_id=100114

>Status: Closed
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: Fix Committed
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: Ville Skyttä  (scop-guest)
Date: 2012-11-06 21:00

Message:
Reportedly fixed by one of these Fedora updates by the OP 
(https://bugzilla.redhat.com/show_bug.cgi?id=512625, originally reported 
against bash-completion 1.0):

bash-4.1.7-4.fc15.x86_64
bash-completion-1.2-2.fc14.noarch


----------------------------------------------------------------------

Comment By: Igor Murzov (garik-guest)
Date: 2012-11-04 12:34

Message:
Is this still an issue? Seems to work fine for me.

----------------------------------------------------------------------

Comment By: Freddy Vulto (fvu-guest)
Date: 2009-09-21 00: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

_______________________________________________
Bash-completion-devel mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/bash-completion-devel

Reply via email to