这几天使用ubuntu的命令行时,总是莫名其妙的多少空格。
例如$ls /var
在正常情况下应该会出现$ls /var/
但是我现在成了$ls /var空格
老兄,/var是一个目录啊,不是一个文件,不能在后不乱添空格的。
这应该是bash补全出了问题。百事问google,竟然找到了:http://timlabath.com/words/2011/05/10/ubuntu-11-04-and-broken-bash-completion/
产生问题的原因:https://bugs.launchpad.net/ubuntu/+source/bash-completion/+bug/769866/comments/10
对着解决,还真帮上忙了。
About that bash completion…
And then there was the broken bash completion (<tab>-completion.) For example, typing “ls /et<tab>
” yielded “ls /etc
” and not “ls /etc/
” (note the extra space and lack of closing slash at the end.) Reinstalling bash-completion did not fix this problem for me. What did work was removing bash-completion, renaming/etc/bash_completion.d/
→ /etc/bash_completion.d.bak/
, and then reinstalling bash-completion.
user@machine:~$sudo apt-get purge bash-completion
user@machine:~$sudo mv /etc/bash_completion.d /etc/bash_completion.d.bak
user@machine:~$sudo apt-get install bash-completion
After reinstalling bash-completion, /etc/bash_completion.d/
reappeared. Idiff
ed the two directories and the new one had way more stuff so I justrm -rf
ed the old one. I’m happy to say my bash completion is working again and I’m going to file this problem under ‘s.’ For “solved.”
我通过比较文件,然后得出,如果你装了acroread之后,会在这个文件夹下生成acroread.sh
是这个文件影响了补全的问题。
意外的收获,自己写程序时,在linux环境中也来个参数补全。
秘密就在/etc/bash_completion.d中。