bash制表以自动完成转义$ [英] bash tabbing for autocompletion escapes $

查看:63
本文介绍了bash制表以自动完成转义$的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在外壳程序( GNU bash,版本4.2.47(1)-发行版(x86_64-suse-linux-gnu))中,当我点击制表符进行自动补全时,"$"在转义后变量名已完成,但是如果没有完成,则只会响起.例如

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>

产生

$ ls \$JDK_HOME (with a trailing space)

在旧的GNU bash版本3.2.51(1)-发行版(x86_64-suse-linux-gnu)上,它在完成后并没有转义"$".

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.

有没有办法使这种旧的行为没有强烈的副作用?我的BASHOPTS和SHELLOPTS是:

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

谢谢.我正在使用SLES SP11.

Thanks. I am using SLES SP11.

-更新.其他补全似乎照常工作,例如 cd echo 不会转义 $ .我还暂时从我的/etc/bash.bashrc 中注释掉了/etc/share/bash-completion/bash_completion ,该代码停止了$转义.因此,它看起来像某种完整的配置问题.

--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.

推荐答案

最近的bash版本引入了一些与此相关的兼容性问题.尝试这样:

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

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

指向在 bug-bash 邮件列表中报告的类似问题的链接:

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

这篇关于bash制表以自动完成转义$的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆