分页: 1 / 1

bash补全问题

发表于 : 2015-04-25 23:44
leetking
问题:
在使用某些软件时,在输入如:--prefix=/some-path<tab>之后就会变为 /some-path,前面的--prefix=消失了!!!...
也就是说只要在符号'='后按tab补全时,=前面的字符就会消失。
具体的操作在附件有个gif文件。

猜想:
我认为是bash-completion的设置问题,但是今天琢磨了一下午没有结果。
然后我把.bashrc中下面的:

代码: 全选

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi  
fi
语句注释后,上诉问题解决了,但是一些命令名不能补全。
这不是一个好的解决办法,希望大家可以帮忙看下。
谢谢大家! :em06
=========================

下面是我的系统信息,希望有帮助:
我的系统是ubuntu 14.04 LTS,
内核信息如下:

代码: 全选

Linux ltk-Y430P 3.13.0-49-generic #83-Ubuntu SMP Fri Apr 10 20:11:33 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
我安装了bash-completion,信息如下:

代码: 全选

Package: bash-completion
Status: install ok installed
Priority: standard
Section: shells
Installed-Size: 929
Maintainer: Ubuntu Developers <[email protected]>
Architecture: all
Multi-Arch: foreign
Version: 1:2.1-4
Replaces: bash, cryptsetup (<< 2:1.1.2-2), xen-tools (<= 4.1-1)
Depends: bash (>= 3.2)
Pre-Depends: dpkg (>= 1.15.7.2~)
Breaks: xen-tools (<= 4.1-1)
Conffiles:
 /etc/profile.d/bash_completion.sh 749e4786543bc3d19e20b0e214806c35
 /etc/bash_completion a81b3f1cb197219b815942f4fc7fa94e
Description: programmable completion for the bash shell
 bash completion extends bash's standard completion behavior to achieve
 complex command lines with just a few keystrokes.  This project was
 conceived to produce programmable completion routines for the most
 common Linux/UNIX commands, reducing the amount of typing sysadmins
 and programmers need to do on a daily basis.
Original-Maintainer: Bash Completion Maintainers <[email protected]>
Homepage: http://bash-completion.alioth.debian.org

Re: bash补全问题

发表于 : 2015-04-26 10:57
leetking
没人帮下忙吗? :em19

Re: bash补全问题

发表于 : 2015-04-26 17:37
astolia
未能重现此问题。有人与你有相同的症状,但看起来也没找到具体原因: http://unix.stackexchange.com/questions ... ble-with-a

Re: bash补全问题

发表于 : 2015-04-26 19:11
leetking
astolia 写了:未能重现此问题。有人与你有相同的症状,但看起来也没找到具体原因: http://unix.stackexchange.com/questions ... ble-with-a
我记得以前都不是的,不知道怎么了,现在就是这种情况了。

Re: bash补全问题

发表于 : 2015-04-28 13:23
susbarbatus
那就把 /usr/share/bash-completion/bash_completion 和 /etc/bash_completion 贴上来看看啰

Re: bash补全问题

发表于 : 2015-04-29 17:15
leetking
susbarbatus 写了:那就把 /usr/share/bash-completion/bash_completion 和 /etc/bash_completion 贴上来看看啰
好,我这就贴上来

Re: bash补全问题

发表于 : 2015-04-29 17:28
leetking
/etc/bash_completion的内容:

代码: 全选

. /usr/share/bash-completion/bash_completion
/usr/share/bash-completion/bash_completion的内容我已附件发送。
另外其他的几个可能用到的文件也发在附件里。

Re: bash补全问题

发表于 : 2015-04-29 18:10
susbarbatus
嗯,楼主给的东西很详细,已经能重现出问题了,暂时没有时间,回头仔细看下

Re: bash补全问题

发表于 : 2015-04-29 18:59
susbarbatus
已经确定是 /etc/bash_completion.d/npm 的问题,删了这个文件就正常了,具体是哪里写得不对我再检查下

Re: bash补全问题

发表于 : 2015-04-29 19:05
susbarbatus
似乎是这句造成的,注释掉就好了

代码: 全选

COMP_WORDBREAKS=${COMP_WORDBREAKS/=/}
我不用 npm,不清楚注释掉对 npm 的补全会有什么影响

Re: bash补全问题

发表于 : 2015-04-30 12:20
leetking
susbarbatus 写了:似乎是这句造成的,注释掉就好了

代码: 全选

COMP_WORDBREAKS=${COMP_WORDBREAKS/=/}
我不用 npm,不清楚注释掉对 npm 的补全会有什么影响
谢谢,这些天我也有其他事情要去做,过了我再按您说的试试,谢谢哈 :em06

Re: bash补全问题

发表于 : 2015-05-03 20:19
leetking
susbarbatus 写了:似乎是这句造成的,注释掉就好了

代码: 全选

COMP_WORDBREAKS=${COMP_WORDBREAKS/=/}
我不用 npm,不清楚注释掉对 npm 的补全会有什么影响
谢谢,确实是的。我把这句注释了以后就好了,但是我还是不知道什么原因。