On Sat, Dec 31, 2011 at 02:14:14PM +0100, xiscu wrote:
> Package: bash-completion
> Version: 1:1.3-1
> Severity: normal
> 
> Dear Maintainer,
> 
> * What led up to the situation?
> - Pressing <tab> to auto complete a path that uses $HOME
> 
> 
> * What exactly did you do (or not do) that was effective (or
>    ineffective)?
> -  Just try: dir $HOME/ and then press <tab>
> 
> 
> * What was the outcome of this action?
> - The command is changed to: dir \$HOME/
> (- If you then press <return> you will get the error:
> dir: cannot access $HOME/: No such file or directory)
> 
> * What outcome did you expect instead?
> - The command should be changed with the true $HOME value

I can reproduce the problem.

$ bash --noprofile --norc
bash-5.0$ echo $HOME/.bashrc 
/home/anarcat/.bashrc
bash-5.0$ . /usr/share/bash-completion/bash_completion
bash-5.0$ echo \$HOME/.bashrc
$HOME/.bashrc
bash-5.0$ 

I hit <TAB> after typing "$HOME/.bashr" in both cases, but after
bash_completion is loaded it breaks $HOME.

I've traced the problem down to this dynamic loader:

# set up dynamic completion loading
_completion_loader()
{
    # $1=_EmptycmD_ already for empty cmds in bash 4.3, set to it for earlier
    local cmd="${1:-_EmptycmD_}"

    __load_completion "$cmd" && return 124

    # Need to define *something*, otherwise there will be no completion at all.
    complete -F _minimal -- "$cmd" && return 124
} &&
complete -D -F _completion_loader

If that code is removed, the problem doesn't occur. That's a complex
piece of code I have kind of gotten lost along the way. It seems the
escape character is inserted when this is called:

    _quote_readline_by_ref '$HOME/.bashr' quoted

That's called somewhere below the _minimal callback defined above, which
is:

_minimal()
{
    local cur prev words cword split
    _init_completion -s || return
    $split && return
    _filedir
}

Things look fine there, so I'm tempted to think it's
_quote_readline_by_ref that's being too enthusiastic.

But I'm pretty lost here so i'll stop there.

Attachment: signature.asc
Description: PGP signature

Reply via email to