bash补全问题

sh/bash/dash/ksh/zsh等Shell脚本
回复
leetking
帖子: 62
注册时间: 2014-10-28 14:53
系统: ubuntu-18.04-LTS

bash补全问题

#1

帖子 leetking » 2015-04-25 23:44

问题:
在使用某些软件时,在输入如:--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 <ubuntu-devel-discuss@lists.ubuntu.com>
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 <bash-completion-devel@lists.alioth.debian.org>
Homepage: http://bash-completion.alioth.debian.org
附件
tab补全问题
tab补全问题
t.gif (226.12 KiB) 查看 4113 次
leetking
帖子: 62
注册时间: 2014-10-28 14:53
系统: ubuntu-18.04-LTS

Re: bash补全问题

#2

帖子 leetking » 2015-04-26 10:57

没人帮下忙吗? :em19
头像
astolia
论坛版主
帖子: 6703
注册时间: 2008-09-18 13:11

Re: bash补全问题

#3

帖子 astolia » 2015-04-26 17:37

未能重现此问题。有人与你有相同的症状,但看起来也没找到具体原因: http://unix.stackexchange.com/questions ... ble-with-a
leetking
帖子: 62
注册时间: 2014-10-28 14:53
系统: ubuntu-18.04-LTS

Re: bash补全问题

#4

帖子 leetking » 2015-04-26 19:11

astolia 写了:未能重现此问题。有人与你有相同的症状,但看起来也没找到具体原因: http://unix.stackexchange.com/questions ... ble-with-a
我记得以前都不是的,不知道怎么了,现在就是这种情况了。
头像
susbarbatus
帖子: 2966
注册时间: 2010-04-10 16:14
系统: Arch Linux

Re: bash补全问题

#5

帖子 susbarbatus » 2015-04-28 13:23

那就把 /usr/share/bash-completion/bash_completion 和 /etc/bash_completion 贴上来看看啰
沉迷将棋中……
leetking
帖子: 62
注册时间: 2014-10-28 14:53
系统: ubuntu-18.04-LTS

Re: bash补全问题

#6

帖子 leetking » 2015-04-29 17:15

susbarbatus 写了:那就把 /usr/share/bash-completion/bash_completion 和 /etc/bash_completion 贴上来看看啰
好,我这就贴上来
leetking
帖子: 62
注册时间: 2014-10-28 14:53
系统: ubuntu-18.04-LTS

Re: bash补全问题

#7

帖子 leetking » 2015-04-29 17:28

/etc/bash_completion的内容:

代码: 全选

. /usr/share/bash-completion/bash_completion
/usr/share/bash-completion/bash_completion的内容我已附件发送。
另外其他的几个可能用到的文件也发在附件里。
附件
bash的tab问题.tar
其他的一些文件。
(110 KiB) 已下载 103 次
bash_completion.txt
/usr/share/bash-completion/bash_completion
(66.07 KiB) 已下载 78 次
头像
susbarbatus
帖子: 2966
注册时间: 2010-04-10 16:14
系统: Arch Linux

Re: bash补全问题

#8

帖子 susbarbatus » 2015-04-29 18:10

嗯,楼主给的东西很详细,已经能重现出问题了,暂时没有时间,回头仔细看下
沉迷将棋中……
头像
susbarbatus
帖子: 2966
注册时间: 2010-04-10 16:14
系统: Arch Linux

Re: bash补全问题

#9

帖子 susbarbatus » 2015-04-29 18:59

已经确定是 /etc/bash_completion.d/npm 的问题,删了这个文件就正常了,具体是哪里写得不对我再检查下
沉迷将棋中……
头像
susbarbatus
帖子: 2966
注册时间: 2010-04-10 16:14
系统: Arch Linux

Re: bash补全问题

#10

帖子 susbarbatus » 2015-04-29 19:05

似乎是这句造成的,注释掉就好了

代码: 全选

COMP_WORDBREAKS=${COMP_WORDBREAKS/=/}
我不用 npm,不清楚注释掉对 npm 的补全会有什么影响
沉迷将棋中……
leetking
帖子: 62
注册时间: 2014-10-28 14:53
系统: ubuntu-18.04-LTS

Re: bash补全问题

#11

帖子 leetking » 2015-04-30 12:20

susbarbatus 写了:似乎是这句造成的,注释掉就好了

代码: 全选

COMP_WORDBREAKS=${COMP_WORDBREAKS/=/}
我不用 npm,不清楚注释掉对 npm 的补全会有什么影响
谢谢,这些天我也有其他事情要去做,过了我再按您说的试试,谢谢哈 :em06
leetking
帖子: 62
注册时间: 2014-10-28 14:53
系统: ubuntu-18.04-LTS

Re: bash补全问题

#12

帖子 leetking » 2015-05-03 20:19

susbarbatus 写了:似乎是这句造成的,注释掉就好了

代码: 全选

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