免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1647 | 回复: 7
打印 上一主题 下一主题

[系统管理] 【已解决】[shell] 所有命令自动补全不对 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2015-08-26 14:35 |只看该作者 |倒序浏览
本帖最后由 bxfqing 于 2015-08-26 15:43 编辑

测试环境:ubuntu 12.04

创建以下目录
mkdir -p /tmp/11/22/

正常情况下, cat /tm命令后,按tab键,自动补全/tmp/, 斜杠会被自动补全,识别是一个目录


异常机器,输入cat /tm 然后按tab自动补全是 cat /tmp   tmp后面会被自动补全空格,感觉是被识别成文件

所有的命令,都是这个情况,可能是什么造成的?

论坛徽章:
39
辰龙
日期:2013-08-21 15:45:192015亚冠之广州富力
日期:2015-05-12 16:34:52亥猪
日期:2015-03-03 17:22:00申猴
日期:2015-03-03 17:21:37未羊
日期:2014-10-10 13:45:41戌狗
日期:2014-06-17 09:53:29巨蟹座
日期:2014-06-12 23:17:17双鱼座
日期:2014-06-10 12:42:44寅虎
日期:2014-06-09 12:52:172015亚冠之卡尔希纳萨夫
日期:2015-05-24 15:24:35黄金圣斗士
日期:2015-12-02 17:25:0815-16赛季CBA联赛之吉林
日期:2017-06-24 16:43:52
2 [报告]
发表于 2015-08-26 14:38 |只看该作者
会不会是真有个文件叫 tmp

论坛徽章:
0
3 [报告]
发表于 2015-08-26 14:41 |只看该作者
本帖最后由 bxfqing 于 2015-08-26 14:56 编辑

回复 2# 关阴月飞


    没有,所有命令,自动补全都不对,切换了一个用户,还是一个样子

论坛徽章:
0
4 [报告]
发表于 2015-08-26 14:45 |只看该作者
两台电脑的自动补全文件也是一样的
A$ md5sum /etc/bash_completion
5d4c5fb388b9e2f5ed14d01a9558bb53  /etc/bash_completion
B$ md5sum /etc/bash_completion
5d4c5fb388b9e2f5ed14d01a9558bb53  /etc/bash_completion

论坛徽章:
7
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:57:092015小元宵徽章
日期:2015-03-06 15:58:18程序设计版块每日发帖之星
日期:2015-08-09 06:20:00每日论坛发贴之星
日期:2015-08-09 06:20:00程序设计版块每日发帖之星
日期:2015-08-22 06:20:00程序设计版块每日发帖之星
日期:2015-08-27 06:20:00
5 [报告]
发表于 2015-08-26 15:47 |只看该作者
咋解决的?从未见过

论坛徽章:
0
6 [报告]
发表于 2015-08-26 15:48 |只看该作者
原因: 安装Adobe Reader9引起的问题
根本原因:TBD
/etc/bash_completion.d/
lrwxrwxrwx 1 root root   46 Mar 23 11:27 acroread.sh -> /opt/Adobe/Reader9/Resource/Shell/acroread_tab*

acroread_tab

1.71 KB, 下载次数: 9

论坛徽章:
0
7 [报告]
发表于 2015-08-26 15:50 |只看该作者
tuyajie 发表于 2015-08-26 15:47
咋解决的?从未见过


具体的问题,我还在看Adobe的添加的东西

  1. $ cat /opt/Adobe/Reader9/Resource/Shell/acroread_tab
  2. # _filedir : to handle file and directories with spaces in their names.

  3. _filedir()
  4. {
  5.         local IFS=\t\n' xspec #glob

  6.         #glob=$(set +o|grep noglob) # save glob setting.
  7.         #set -f                 # disable pathname expansion (globbing)

  8.         xspec=${1:+"!*.$1"}        # set only if glob passed in as $1
  9.         COMPREPLY=( ${COMPREPLY[@]:-} $( compgen -f -X "$xspec" -- "$cur" ) \
  10.                     $( compgen -d -- "$cur" ) )
  11.         #eval "$glob"    # restore glob setting.
  12. }

  13. _acroread()
  14. {
  15.           local cur prev opts files
  16.         COMPREPLY=()
  17.         cur="${COMP_WORDS[COMP_CWORD]}"
  18.         #prev="${COMP_WORDS[COMP_CWORD-1]}"
  19.         first="${COMP_WORDS[1]}"
  20.         #
  21.         #  The basic options we'll complete.
  22.         #
  23.         opts="--display --screen --sync -geometry -help -man -iconic -setenv -tempFile -tempFileTitle -toPostScript -openInNewWindow -installCertificate -v -version"

  24.         #
  25.         #  Complete the arguments to some of the basic commands.
  26.         #
  27.         case "${first}" in
  28.         -toPostScript)
  29.         if [[ "${cur}" == -* ]]; then
  30.         local running="-binary -start -end -pairs -optimizeForSpeed -landscape -reverse -odd -even -commentsOff -annotsOff -stampsOff -markupsOn -level2 -level3 -printerhalftones -saveVM -size -shrink  -expand -transQuality -printerName -nUp -booklet -rotateAndCenter -choosePaperByPDFPageSize"
  31.         COMPREPLY=( $(compgen -W "${running}" -- "${cur}") )
  32.         return 0
  33.         fi
  34.         ;;

  35.         -installCertificate)
  36.         if [[ "${cur}" == -* ]]; then
  37.           if [ $COMP_CWORD -eq 2 ]; then
  38.             local running="-PEM -DER"
  39.             COMPREPLY=( $(compgen -W "${running}" -- "${cur}") )
  40.             return 0
  41.           fi
  42.         fi
  43.         ;;

  44.         *)
  45.         ;;
  46.         esac


  47.         if [[ "${cur}" == -* ]] ; then
  48.           COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))  
  49.           return 0
  50.         fi

  51.         if [ $COMP_CWORD -eq 1 -o "${COMPREPLY+set}" != "set" ]; then
  52.         _filedir '[pP][dD][fF]'
  53.         fi

  54. }
  55. complete -o filenames -o nospace -F _acroread acroread
复制代码

论坛徽章:
0
8 [报告]
发表于 2015-08-26 16:00 |只看该作者
tuyajie 发表于 2015-08-26 15:47
咋解决的?从未见过


把附件文件,放到
/etc/bash_completion.d/
lrwxrwxrwx 1 root root   46 Mar 23 11:27 acroread.sh -> /opt/Adobe/Reader9/Resource/Shell/acroread_tab*

就能复现这个问题
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP