views:

477

answers:

3

In bash, environmental variables will tab-expand correctly when placed after an echo command, for example:

echo $HOME

But after cd or cat, bash places a \ before the $ sign, like so:

cd \$HOME

If I use a variable as the second argument to a command, it won't expand at all:

cp somefile $HOM

What mysterious option do I have in my .bashrc or .inputrc file that is causing me such distress?

+2  A: 

For the second instance, you can press ESC before tab to solve it.

I don't know the solution to your problem, but you could look in /etc/bash_completion or the files under /etc/bash_completion.d to determine what commands use autocompletion and how.

help complete

Might also be helpful.

Brent
+1  A: 

The Bash Reference Manual has more information than you might want on expansion errata.

Section 8.7 looks like it would be the place to start. It give information on the 'complete' function, among other things.

Frosty
+1  A: 

Try complete -r cd to remove the special programmatic completion function that many Linux distributions install for the cd command. The function adds searching a list of of directories specified in the CDPATH variable to tab completions for cd, but at the expense of breaking the default completion behavior.

See http://www.gnu.org/software/bash/manual/bashref.html#Programmable-Completion for more gory details.

bd808