Tab 上的 Bash 变量扩展完成
我正在运行 Ubuntu 11.04,当我尝试在 bash 中对以变量开头的路径使用制表符补全时,我看到一些奇怪的行为。如果我有 TOP=/scratch,并且我尝试制表符完成:
cd $TOP/foo
它会更改为:
cd \$TOP/foo
我希望它完成为: cd $TOP/foobar 或者 cd /scratch/foobar 但我会满足于不改变线路并要求我取消转义 $ 。
有谁知道我应该在 bash/readline 的哪里解决这个问题?
I'm running Ubuntu 11.04, and I'm seeing some odd behaviour when I try to use tab-completion in bash on a path that starts with a variable. If I've got TOP=/scratch, and I try to tab-complete:
cd $TOP/foo
it changes to:
cd \$TOP/foo
I'd prefer it to complete to:
cd $TOP/foobar
or
cd /scratch/foobar
but I'd settle for it just not changing the line and requiring me to un-escape the $.
Does anyone know where in bash/readline I should look to fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
找到错误报告,请注册(如果尚未注册)并将自己添加到“受影响的人员”列表中,我刚刚这样做了:
https://bugs.launchpad.net/ubuntu/+source/bash/+bug/778627
解决方法
尝试启用
direxpand
或cdable_vars
:显然 EscTab 可能是一种解决方法:
<子>
确认这是一个错误!我刚刚确认同样的事情适用于,
我在(最新的)natty 上得到了损坏的行为:
虽然我必须补充一点,我没有转义了斜杠,但是路径(虽然有效、现有、可访问和可读)没有得到扩展。
信息:https://help.ubuntu.com/community/ReportingBugs
Found the bug report, please register (if not already registered) and add yourself to the 'people affected' list, I just did:
https://bugs.launchpad.net/ubuntu/+source/bash/+bug/778627
Workarounds
Try enabling
direxpand
orcdable_vars
:Apparently EscTab might be a workaround:
Confirm that as a bug! I just confirmed that the same thing works on
I get broken behaviour on (up-to-date) natty:
Although I must add that I do not the slash escaped, but the path (while valid, existing, accessible and readable) is not getting expanded.
Info: https://help.ubuntu.com/community/ReportingBugs
其他答案中提到的错误报告 bugs.launchpad.net 通过发出命令给出了新的解决方法:
它对我有用。
The bug report refered to in other answers at bugs.launchpad.net gives a new workaround by issuing the command:
It works for me.
我在 cygwin (NT-6.1 2.0.1 2015-04-30) bash (GNU 4.3.33) 中遇到类似的问题,特别是当我尝试制表符扩展包含空格的路径时。
我将
shopt -s direxpand
放入我的 ~/.bashrc 中。问题解决了。I was having a similar problem in cygwin (NT-6.1 2.0.1 2015-04-30) bash (GNU 4.3.33), especially when I would try to tab-expand a path that contained spaces.
I put
shopt -s direxpand
in my ~/.bashrc. Problem solved.