Завершение Bash не работает или игнорирует то, что я набрал; но работает для команд

Завершение Bash, кажется, игнорирует то, что я набрал (оно пытается завершиться, но действует так, как будто под курсором ничего нет). Я знаю, что видел, как это работало на этой машине ранее сегодня, но я не уверен, что изменилось. Некоторые примеры:

cd показывает все каталоги в моей текущей папке:

$ cd co<tab><tab>
cmake/    config/   doc/      examples/ include/  programs/ sandbox/  src/      .svn/     tests/    

Команды, подобные ls и less, показывают все каталоги файлов и в моя текущая папка:

$ ls co<tab><tab>
cmake/          config/         .cproject       Doxyfile.in     include/        programs/       README.txt      src/            tests/          
CMakeLists.txt  COPYING.txt     doc/            examples/       mainpage.dox    .project        sandbox/        .svn/           

Даже когда я пытаюсь завершить работу из другой папки, она дает мне только результаты для моей текущей папки (сообщая, что она полностью игнорирует то, что я набрала):

$ cd ~/D<tab><tab>
cmake/    config/   doc/      examples/ include/  programs/ sandbox/  src/      .svn/     tests/    

Но для команд и переменных это работает нормально:

$ if<tab><tab>
if        ifconfig  ifdown    ifnames   ifquery   ifup      
$ echo $P<tab><tab>
$PATH        $PIPESTATUS  $PPID        $PS1         $PS2         $PS4         $PWD         $PYTHONPATH  

У меня есть этот бит в моем .bashrc, и я подтвердил, что мой .bashrc действительно получен:

if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
    . /etc/bash_completion
fi

Я даже пытался вручную выполнить этот файл, но это не решает проблему:

$ . /etc/bash_completion

Был даже один момент времени, когда он работал для ls, но не работал для cd ... но я не могу сейчас воспроизвести этот результат.


Обновление: Я также только что обнаружил, что у меня есть открытые ранее терминалы, которые все еще работают. Я запустил source .bashrc в одном из них, и после этого завершение было прервано. Вот мой .bashrc:

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# 
# Modified by Neil Traft

#source ~/.profile

# Allow globs to expand hidden files
shopt -s dotglob nullglob

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar

# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# Color the prompt
export PS1="\[$(tput setaf 2)\]\u@\h:\[$(tput setaf 5)\]\W\[$(tput setaf 2)\] $\[$(tput sgr0)\] "

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'
    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi

# Add an "alert" alias for long running commands.  Use like so:
#   sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

# 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 [ -f /etc/bash_completion ] && ! shopt -oq posix; then
    . /etc/bash_completion
fi
1
задан 13 November 2013 в 06:57

1 ответ

Нашел это. Это строка:

shopt -s dotglob nullglob

В частности, именно nullglob вызвало проблему. Запуск shopt -u nullglob исправляет это.

Я думал, что это должно было добавить только точечные файлы в качестве кандидатов для расширения глобуса? Ну, я думаю, что это своего рода отдельный вопрос, поэтому мы назовем этот вопрос ответом.

0
ответ дан 13 November 2013 в 06:57

Другие вопросы по тегам:

Похожие вопросы: