[Bash-completion-devel] [bash-completion-Bugs][311384] DBTS 336987: shell variables should always be a valid completion when syntactically valid

bash-completion-bugs at alioth.debian.org bash-completion-bugs at alioth.debian.org
Sat Nov 5 17:08:54 UTC 2011


Bugs item #311384, was changed at 2009-01-30 11:21 by Igor Murzov
You can respond by visiting: 
https://alioth.debian.org/tracker/?func=detail&atid=413095&aid=311384&group_id=100114

>Status: Closed
Priority: 3
Submitted By: David Paleino (hanska-guest)
Assigned to: Nobody (None)
Summary: DBTS 336987: shell variables should always be a valid completion when syntactically valid 
Distribution: None
Originally reported in: Debian BTS
Milestone: None
>Status: Fix Committed
Original bug number: 336987


Initial Comment:
Normally, bash can complete shell variables when appropriate; for
example, "foo=1" followed by "echo $f<TAB>" will complete to "echo
$foo".  However, programmable completion interferes with this; for
example, "svn ls $f<TAB>", "cvs $f<TAB>", and "ssh $f<TAB>" all fail to
complete $foo.  Shell variables should always be a valid completion when
they are syntactically valid, since they could always contain a string
appropriate for the current command.

(By "when they are syntactically valid", I mean that the shell already
knows not to complete "echo \$f<TAB>" into "echo \$foo", and that
shouldn't change.)

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

>Comment By: Igor Murzov (garik-guest)
Date: 2011-11-05 21:08

Message:
This should be fixed already by http://anonscm.debian.org/gitweb/?p=bash-completion/bash-completion.git;a=commit;h=ff8e52c9605fa0a40d642d1ddb57ada11213ac3c

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

Comment By: Mike Hanby (flakrat-guest)
Date: 2010-03-01 21:48

Message:
Anyone have a workaround for this issue?

Another couple examples where this is not working:

"ls -l $HOM<TAB>" fails to complete to "ls -l $HOME"
"du $HOM<TAB>" fails to complete to "du $HOME"

however this does work
"ls -l $HOME/<TAB>"
"du $HOME/<TAB>"



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

Comment By: Raphaël Droz (gibboris-guest)
Date: 2009-07-22 14:41

Message:
I was looking for a way to wrap $(complete) and make it call
a "variable_complete" before each specific completion
But I don't see any way to do it.
So my point of view is that we have to use the
dirty way and wish bash will make the completion
more smooth one of these days.

# copied from _cd()
comp_variables() {
        # try to allow variable completion
        if [[ "$cur" == ?(\\)\$* ]]; then
                COMPREPLY=( $( compgen -v -P '$' -- "${cur#?(\\)$}" ) )
                return 0
        fi
}

and call it in each completion... :S

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

You can respond by visiting: 
https://alioth.debian.org/tracker/?func=detail&atid=413095&aid=311384&group_id=100114



More information about the Bash-completion-devel mailing list