Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bash tabbing for autocompletion escapes $

In shell (GNU bash, version 4.2.47(1)-release (x86_64-suse-linux-gnu)), when I hit tab for autocompletion, the "$" is escaped after the variable name is completed, but if there is no completion then it just bells. E.g.

$ ls $JDK_H<tab>

results in

$ ls \$JDK_HOME (with a trailing space)

On an old GNU bash, version 3.2.51(1)-release (x86_64-suse-linux-gnu), it did not escape the "$" after completion which is what I would like.

Is there a way to get that old behavior without strong side-effects? My BASHOPTS and SHELLOPTS are:

# (indented for readability)
BASHOPTS=checkwinsize:cmdhist:expand_aliases:extglob:extquote
            :force_fignore:histappend:interactive_comments:login_shell
            :progcomp:promptvars:sourcepath
SHELLOPTS=braceexpand:emacs:hashall:histexpand:history
            :interactive-comments:monitor

Thanks. I am using SLES SP11.

--UPDATE. Other completions seem to work as usual, e.g. cd or echo do not escape the $. I also momentarily commented out /etc/share/bash-completion/bash_completion from my /etc/bash.bashrc which stopped $-escaping. So it appears like some kind of complete config issue.

like image 420
Dinesh Avatar asked Sep 08 '15 16:09

Dinesh


1 Answers

Recent bash versions introduced some compatibility issues regarding this. Try like this:

complete -r # temporarily disable all completion rules
shopt -s direxpand

Links to similar problems reported to the bug-bash mail list:

  • http://lists.gnu.org/archive/html/bug-bash/2014-01/msg00062.html
  • http://lists.gnu.org/archive/html/bug-bash/2015-08/msg00176.html
like image 81
pynexj Avatar answered Sep 28 '22 16:09

pynexj