탭이 경로와 함께 환경 변수 내보내기를 마치면 변수 이름이 누락됩니다.

탭이 경로와 함께 환경 변수 내보내기를 마치면 변수 이름이 누락됩니다.

탭 완성을 사용하여 환경 변수를 설정하려고 합니다.

snowch$ export JAVA_HOME=/usr/lib/jvm/java-6-oracle/

섹션을 입력한 후 폴더를 탭하여 완료 할 수 있었지만 export JAVA_HOME=탭 키를 누르려고 하면 변수 이름이 손실되었습니다.

export JAVA_HOME=/u[tab]

이 되다:

export /usr/

어떻게 해결할 수 있나요?

저는 우분투 13.04를 실행하고 있습니다.

편집하다- 댓글에서 요청한 대로 디버그 출력

$ bash --norc
bash-4.2$ . /etc/bash_completion
bash-4.2$ set -x
bash-4.2$ export JAVA_HOME=/u+ local compdir=./completions
+ [[ /usr/share/bash-completion/bash_completion == */* ]]
+ compdir=/usr/share/bash-completion/completions
+ . /usr/share/bash-completion/completions/export
+ return 124
+ local cur prev words cword
+ _init_completion -n =
+ local exclude= flag outx errx inx OPTIND=1
+ getopts n:e:o:i:s flag -n =
+ case $flag in
+ exclude+==
+ getopts n:e:o:i:s flag -n =
+ COMPREPLY=()
+ local 'redir=@(?([0-9])<|?([0-9&])>?(>)|>&)'
+ _get_comp_words_by_ref -n '=<>&' cur prev words cword
+ local exclude flag i OPTIND=1
+ words=()
+ local cur cword words
+ upargs=()
+ upvars=()
+ local upargs upvars vcur vcword vprev vwords
+ getopts c:i:n:p:w: flag -n '=<>&' cur prev words cword
+ case $flag in
+ exclude='=<>&'
+ getopts c:i:n:p:w: flag -n '=<>&' cur prev words cword
+ [[ 6 -ge 3 ]]
+ case ${!OPTIND} in
+ vcur=cur
+ let 'OPTIND += 1'
+ [[ 6 -ge 4 ]]
+ case ${!OPTIND} in
+ vprev=prev
+ let 'OPTIND += 1'
+ [[ 6 -ge 5 ]]
+ case ${!OPTIND} in
+ vwords=words
+ let 'OPTIND += 1'
+ [[ 6 -ge 6 ]]
+ case ${!OPTIND} in
+ vcword=cword
+ let 'OPTIND += 1'
+ [[ 6 -ge 7 ]]
+ __get_cword_at_cursor_by_ref '=<>&' words cword cur
+ words=()
+ local cword words
+ __reassemble_comp_words_by_ref '=<>&' words cword
+ local exclude i j line ref
+ [[ -n =<>& ]]
+ exclude='<>&'
+ eval cword=1
++ cword=1
+ [[ -n <>& ]]
+ line='export JAVA_HOME=/u'
+ (( i=0, j=0 ))
+ (( i < 2 ))
+ [[ 0 -gt 0 ]]
+ ref='words[0]'
+ eval 'words[0]=${!ref}${COMP_WORDS[i]}'
++ words[0]=export
+ line=' JAVA_HOME=/u'
+ [[ 0 == 1 ]]
+ (( i++, j++ ))
+ (( i < 2 ))
+ [[ 1 -gt 0 ]]
+ [[ JAVA_HOME=/u == +([<>&]) ]]
+ ref='words[1]'
+ eval 'words[1]=${!ref}${COMP_WORDS[i]}'
++ words[1]=JAVA_HOME=/u
+ line=
+ [[ 1 == 1 ]]
+ eval cword=1
++ cword=1
+ (( i++, j++ ))
+ (( i < 2 ))
+ local i cur index=19 'lead=export JAVA_HOME=/u'
+ [[ 19 -gt 0 ]]
+ [[ -n export JAVA_HOME=/u ]]
+ [[ -n exportJAVA_HOME=/u ]]
+ cur='export JAVA_HOME=/u'
+ (( i = 0 ))
+ (( i <= cword ))
+ [[ 19 -ge 6 ]]
+ [[ export != \e\x\p\o\r\t ]]
+ [[ 0 -lt 1 ]]
+ local old_size=19
+ cur=' JAVA_HOME=/u'
+ local new_size=13
+ index=13
+ (( ++i  ))
+ (( i <= cword ))
+ [[ 13 -ge 12 ]]
+ [[  JAVA_HOME=/ != \J\A\V\A\_\H\O\M\E\=\/\u ]]
+ cur=JAVA_HOME=/u
+ (( index-- ))
+ [[ 12 -ge 12 ]]
+ [[ JAVA_HOME=/u != \J\A\V\A\_\H\O\M\E\=\/\u ]]
+ [[ 1 -lt 1 ]]
+ (( ++i  ))
+ (( i <= cword ))
+ [[ -n JAVA_HOME=/u ]]
+ [[ ! -n JAVA_HOME=/u ]]
+ [[ 12 -lt 0 ]]
+ local words cword cur
+ _upvars -a2 words export JAVA_HOME=/u -v cword 1 -v cur JAVA_HOME=/u
+ ((  10  ))
+ ((  10  ))
+ case $1 in
+ [[ -n 2 ]]
+ printf %d 2
+ [[ -n words ]]
+ unset -v words
+ eval 'words=("${@:3:2}")'
++ words=("${@:3:2}")
+ shift 4
+ ((  6  ))
+ case $1 in
+ [[ -n cword ]]
+ unset -v cword
+ eval 'cword="$3"'
++ cword=1
+ shift 3
+ ((  3  ))
+ case $1 in
+ [[ -n cur ]]
+ unset -v cur
+ eval 'cur="$3"'
++ cur=JAVA_HOME=/u
+ shift 3
+ ((  0  ))
+ [[ -n cur ]]
+ upvars+=("$vcur")
+ upargs+=(-v $vcur "$cur")
+ [[ -n cword ]]
+ upvars+=("$vcword")
+ upargs+=(-v $vcword "$cword")
+ [[ -n prev ]]
+ [[ 1 -ge 1 ]]
+ upvars+=("$vprev")
+ upargs+=(-v $vprev "${words[cword - 1]}")
+ [[ -n words ]]
+ upvars+=("$vwords")
+ upargs+=(-a${#words[@]} $vwords "${words[@]}")
+ ((  4  ))
+ local cur cword prev words
+ _upvars -v cur JAVA_HOME=/u -v cword 1 -v prev export -a2 words export JAVA_HOME=/u
+ ((  13  ))
+ ((  13  ))
+ case $1 in
+ [[ -n cur ]]
+ unset -v cur
+ eval 'cur="$3"'
++ cur=JAVA_HOME=/u
+ shift 3
+ ((  10  ))
+ case $1 in
+ [[ -n cword ]]
+ unset -v cword
+ eval 'cword="$3"'
++ cword=1
+ shift 3
+ ((  7  ))
+ case $1 in
+ [[ -n prev ]]
+ unset -v prev
+ eval 'prev="$3"'
++ prev=export
+ shift 3
+ ((  4  ))
+ case $1 in
+ [[ -n 2 ]]
+ printf %d 2
+ [[ -n words ]]
+ unset -v words
+ eval 'words=("${@:3:2}")'
++ words=("${@:3:2}")
+ shift 4
+ ((  0  ))
+ _variables
+ [[ JAVA_HOME=/u =~ ^(\$\{?)([A-Za-z0-9_]*)$ ]]
+ return 1
+ [[ JAVA_HOME=/u == @(?([0-9])<|?([0-9&])>?(>)|>&)* ]]
+ [[ export == @(?([0-9])<|?([0-9&])>?(>)|>&) ]]
+ local i skip
+ (( i=1 ))
+ (( i < 2 ))
+ [[ JAVA_HOME=/u == @(?([0-9])<|?([0-9&])>?(>)|>&)* ]]
+ i=2
+ (( 1 ))
+ (( i < 2 ))
+ [[ 1 -eq 0 ]]
+ prev=export
+ [[ -n '' ]]
+ return 0
+ local i action=variable remove=false
+ (( i=1 ))
+ (( i < cword ))
+ [[ JAVA_HOME=/u == *=\$* ]]
+ case $cur in
+ cur=/u
+ _filedir
+ local i 'IFS=
' xspec
+ _tilde /u
+ local result=0
+ [[ /u == \~* ]]
+ return 0
+ local -a toks
+ local quoted x tmp
+ _quote_readline_by_ref /u quoted
+ [[ /u == \'* ]]
+ printf -v quoted %q /u
+ [[ /u == \$* ]]
++ compgen -d -- /u
+ x=/usr
+ read -r tmp
+ toks+=("$tmp")
+ read -r tmp
+ [[ '' != -d ]]
+ xspec=
++ compgen -f -X '' -- /u
+ x=/usr
+ read -r tmp
+ toks+=("$tmp")
+ read -r tmp
+ [[ -n '' ]]
+ [[ 2 -ne 0 ]]
+ compopt -o filenames
+ COMPREPLY+=("${toks[@]}")
/usr/

답변1

exclude='<>&'실종 __reassemble_comp_words_by_ref에 대해 말했다 . =COMP_WORDBREAKS

bash-4.*다음을 사용하여 재현 할 수 있습니다 bash-completion-2.*.

COMP_WORDBREAKS=${COMP_WORDBREAKS//=}
export JAVA_HOME=/u<Tab>

수정 : =.COMP_WORDBREAKS

관련 정보