[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
Wed Jul 22 10:41:56 UTC 2009


Bugs item #311384, was changed at 30/01/2009 08:21 by Raphaël Droz
You can respond by visiting: 
https://alioth.debian.org/tracker/?func=detail&atid=413095&aid=311384&group_id=100114

Status: Open
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: None
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: Raphaël Droz (gibboris-guest)
Date: 22/07/2009 10: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