nullglob禁用路径选项卡,完成 [英] nullglob disables pathname tab-completion
问题描述
我发现,禁用了javascript -s nullglob
显然禁用选项卡,完成对文件和目录,而禁用了javascript -u nullglob
恢复它。为什么制表完成对目录显然依赖于 nullglob
取消设置被?
I have found that shopt -s nullglob
apparently disables tab-completion for files and directories, and shopt -u nullglob
restores it. Why does tab-completion for directories apparently rely on nullglob
being unset?
我使用bash 4.2.37(1)-release
在Debian 7。
I am using Bash 4.2.37(1)-release
on Debian 7.
推荐答案
这显然是一个已知的问题bash的完成和被列为目标,固定在3.0版本。
This is apparently a known issue with bash-completion and is listed as an objective to be fixed in the 3.0 version.
但很显然它一直这样,因为至少2012
But apparently it has been that way since at least 2012.
请参阅 https://bugs.debian.org/cgi-bin /bugreport.cgi?bug=666933 以供参考。
编辑:至少2011:的http://线程。 gmane.org/gmane.comp.shells.bash.completion.devel/3652
At least 2011: http://thread.gmane.org/gmane.comp.shells.bash.completion.devel/3652
<罢>我不都不懂nullglob如何导致在电子邮件中列出的问题,但击>
编辑:我现在明白发生了什么。问题是,水珠扩张是哑巴。它认为在全部字 $ 2 [$ J] = \\ $ {!裁判} \\ $ {COMP_WORDS [I]}
作为一个单一的和glob的尝试将其展开。通常情况下失败,它被单独留在家中,但会 nullglob
上整个参数简单地消失(从而导致问题)。
I now understand what is happening. The problem is that glob expansion is dumb. It sees the entire "word" $2[$j]=\${!ref}\${COMP_WORDS[i]}
as a single glob and tries to expand it. Normally that fails and it gets left alone but will nullglob
on that entire argument simply vanishes (thus causing the problem).
快速测试表明,这种替换:
Quick testing indicates that replacing this:
eval $2[$j]=\${!ref}\${COMP_WORDS[i]}
有两种:
eval $2\[$j\]=\${!ref}\${COMP_WORDS\[i\]}
或
eval "$2[$j]=\${!ref}\${COMP_WORDS[i]}"
似乎来解决这个问题。我不能保证这些要么是完全正确的,虽然修复的。
seems to fix the problem. I can't vouch for either of those being a fully correct fix though.
更新:这是固定在debian的bash自动完成git仓库已经(在我没有想过但方式显然是更好的)
Update: This is fixed in the debian bash-completion git repository already (in a way I hadn't thought of but which is clearly better).
<一个href=\"http://anonscm.debian.org/cgit/bash-completion/bash-completion.git/commit/bash_completion?id=732906b25096508fbc5d15d684dea0312ed7fca0\"相对=nofollow>这个承诺修复它。还有其他相关的通配符修复了。
This commit fixes it. There are other globbing related fixes too.
拼抢 __ reassemble_comp_words_by_ref
从Git的头和采购,关于当前上方的来解决这个问题作为临时解决方法/解决方案。
Grabbing the __reassemble_comp_words_by_ref
from git head and sourcing that on top of the current one appears to fix the problem as a temporary workaround/solution.
这篇关于nullglob禁用路径选项卡,完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!