Open KES777 opened 6 years ago
It's not clear to me what you mean, the behavior with and without -d in your "example" and "without -d option completion works fine" is exactly the same (neither lists any completions per the report text). Did you expect something different? Did the one complete something the other didn't, but the output isn't included in the bug report text above?
For first example bash completion is not triggered at all. For second and third it is triggered
I cannot reproduce, works fine for me. For example *.pl files in the current dir are completed, and option completions work fine.
$ perl -d -<TAB>
-0 -a -c -C -d -D -e -F -h -i -I -l -m -M -n -p -P -s -S -T -u -U -v -V -w -W -x -X
Please see the Troubleshooting section in README.md and follow its instructions.
Start new shell and:
kes@work ~ $ set -v
history -a; history -r;
kes@work ~ $ set -x
set -x
history -a; history -r;
++ history -a
++ history -r
kes@work ~ $ perl -d + local compfile=./completions
+ [[ /usr/share/bash-completion/bash_completion == */* ]]
+ compfile=/usr/share/bash-completion/completions
+ compfile+=/perl
+ [[ -f /usr/share/bash-completion/completions/perl ]]
+ . /usr/share/bash-completion/completions/perl
+ 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=2
cword=2
++ cword=2
+ [[ -n :<>& ]]
+ line='perl -d '
+ (( i=0, j=0 ))
+ (( i < 3 ))
+ [[ 0 -gt 0 ]]
+ ref='words[0]'
+ eval 'words[0]=${!ref}${COMP_WORDS[i]}'
words[0]=${!ref}${COMP_WORDS[i]}
++ words[0]=perl
+ line=' -d '
+ [[ 0 == 2 ]]
+ (( i++, j++ ))
+ (( i < 3 ))
+ [[ 1 -gt 0 ]]
+ [[ -d == +([:<>&]) ]]
+ ref='words[1]'
+ eval 'words[1]=${!ref}${COMP_WORDS[i]}'
words[1]=${!ref}${COMP_WORDS[i]}
++ words[1]=-d
+ line=' '
+ [[ 1 == 2 ]]
+ (( i++, j++ ))
+ (( i < 3 ))
+ [[ 2 -gt 0 ]]
+ [[ '' == +([:<>&]) ]]
+ ref='words[2]'
+ eval 'words[2]=${!ref}${COMP_WORDS[i]}'
words[2]=${!ref}${COMP_WORDS[i]}
++ words[2]=
+ line=' '
+ [[ 2 == 2 ]]
+ eval cword=2
cword=2
++ cword=2
+ (( i++, j++ ))
+ (( i < 3 ))
+ [[ 3 == 2 ]]
+ local i cur index=8 'lead=perl -d '
+ [[ 8 -gt 0 ]]
+ [[ -n perl -d ]]
+ [[ -n perl-d ]]
+ cur='perl -d '
+ (( i = 0 ))
+ (( i <= cword ))
+ [[ 8 -ge 4 ]]
+ [[ perl != \p\e\r\l ]]
+ [[ 0 -lt 2 ]]
+ local old_size=8
+ cur=' -d '
+ local new_size=4
+ index=4
+ (( ++i ))
+ (( i <= cword ))
+ [[ 4 -ge 2 ]]
+ [[ - != \-\d ]]
+ cur='-d '
+ (( index-- ))
+ [[ 3 -ge 2 ]]
+ [[ -d != \-\d ]]
+ [[ 1 -lt 2 ]]
+ local old_size=3
+ cur=' '
+ local new_size=1
+ index=1
+ (( ++i ))
+ (( i <= cword ))
+ [[ 1 -ge 0 ]]
+ [[ '' != '' ]]
+ [[ 2 -lt 2 ]]
+ (( ++i ))
+ (( i <= cword ))
+ [[ -n ]]
+ [[ ! -n '' ]]
+ cur=
+ [[ 1 -lt 0 ]]
+ local words cword cur
+ _upvars -a3 words perl -d '' -v cword 2 -v cur ''
+ (( 11 ))
+ (( 11 ))
+ case $1 in
+ [[ -n 3 ]]
+ printf %d 3
+ [[ -n words ]]
+ unset -v words
+ eval 'words=("${@:3:3}")'
words=("${@:3:3}")
++ words=("${@:3:3}")
+ shift 5
+ (( 6 ))
+ case $1 in
+ [[ -n cword ]]
+ unset -v cword
+ eval 'cword="$3"'
cword="$3"
++ cword=2
+ shift 3
+ (( 3 ))
+ case $1 in
+ [[ -n cur ]]
+ unset -v cur
+ eval 'cur="$3"'
cur="$3"
++ cur=
+ shift 3
+ (( 0 ))
+ [[ -n cur ]]
+ upvars+=("$vcur")
+ upargs+=(-v $vcur "$cur")
+ [[ -n cword ]]
+ upvars+=("$vcword")
+ upargs+=(-v $vcword "$cword")
+ [[ -n prev ]]
+ [[ 2 -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 '' -v cword 2 -v prev -d -a3 words perl -d ''
+ (( 14 ))
+ (( 14 ))
+ case $1 in
+ [[ -n cur ]]
+ unset -v cur
+ eval 'cur="$3"'
cur="$3"
++ cur=
+ shift 3
+ (( 11 ))
+ case $1 in
+ [[ -n cword ]]
+ unset -v cword
+ eval 'cword="$3"'
cword="$3"
++ cword=2
+ shift 3
+ (( 8 ))
+ case $1 in
+ [[ -n prev ]]
+ unset -v prev
+ eval 'prev="$3"'
prev="$3"
++ prev=-d
+ shift 3
+ (( 5 ))
+ case $1 in
+ [[ -n 3 ]]
+ printf %d 3
+ [[ -n words ]]
+ unset -v words
+ eval 'words=("${@:3:3}")'
words=("${@:3:3}")
++ words=("${@:3:3}")
+ shift 5
+ (( 0 ))
+ _variables
+ [[ '' =~ ^(\$\{?)([A-Za-z0-9_]*)$ ]]
+ return 1
+ [[ '' == @(?([0-9])<|?([0-9&])>?(>)|>&)* ]]
+ [[ -d == @(?([0-9])<|?([0-9&])>?(>)|>&) ]]
+ local i skip
+ (( i=1 ))
+ (( i < 3 ))
+ [[ -d == @(?([0-9])<|?([0-9&])>?(>)|>&)* ]]
+ i=2
+ (( 1 ))
+ (( i < 3 ))
+ [[ '' == @(?([0-9])<|?([0-9&])>?(>)|>&)* ]]
+ i=3
+ (( 1 ))
+ (( i < 3 ))
+ [[ 2 -le 0 ]]
+ prev=-d
+ [[ -n '' ]]
+ return 0
+ local prefix= temp optPrefix optSuffix
+ [[ '' == -?* ]]
+ case $prev in
+ [[ '' == :* ]]
+ return 0
^C
history -a; history -r;
++ history -a
++ history -r
kes@work ~ $ perl -d -+ 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=2
cword=2
++ cword=2
+ [[ -n :<>& ]]
+ line='perl -d -'
+ (( i=0, j=0 ))
+ (( i < 3 ))
+ [[ 0 -gt 0 ]]
+ ref='words[0]'
+ eval 'words[0]=${!ref}${COMP_WORDS[i]}'
words[0]=${!ref}${COMP_WORDS[i]}
++ words[0]=perl
+ line=' -d -'
+ [[ 0 == 2 ]]
+ (( i++, j++ ))
+ (( i < 3 ))
+ [[ 1 -gt 0 ]]
+ [[ -d == +([:<>&]) ]]
+ ref='words[1]'
+ eval 'words[1]=${!ref}${COMP_WORDS[i]}'
words[1]=${!ref}${COMP_WORDS[i]}
++ words[1]=-d
+ line=' -'
+ [[ 1 == 2 ]]
+ (( i++, j++ ))
+ (( i < 3 ))
+ [[ 2 -gt 0 ]]
+ [[ - == +([:<>&]) ]]
+ ref='words[2]'
+ eval 'words[2]=${!ref}${COMP_WORDS[i]}'
words[2]=${!ref}${COMP_WORDS[i]}
++ words[2]=-
+ line=
+ [[ 2 == 2 ]]
+ eval cword=2
cword=2
++ cword=2
+ (( i++, j++ ))
+ (( i < 3 ))
+ [[ 3 == 2 ]]
+ local i cur index=9 'lead=perl -d -'
+ [[ 9 -gt 0 ]]
+ [[ -n perl -d - ]]
+ [[ -n perl-d- ]]
+ cur='perl -d -'
+ (( i = 0 ))
+ (( i <= cword ))
+ [[ 9 -ge 4 ]]
+ [[ perl != \p\e\r\l ]]
+ [[ 0 -lt 2 ]]
+ local old_size=9
+ cur=' -d -'
+ local new_size=5
+ index=5
+ (( ++i ))
+ (( i <= cword ))
+ [[ 5 -ge 2 ]]
+ [[ - != \-\d ]]
+ cur='-d -'
+ (( index-- ))
+ [[ 4 -ge 2 ]]
+ [[ -d != \-\d ]]
+ [[ 1 -lt 2 ]]
+ local old_size=4
+ cur=' -'
+ local new_size=2
+ index=2
+ (( ++i ))
+ (( i <= cword ))
+ [[ 2 -ge 1 ]]
+ [[ != \- ]]
+ cur=-
+ (( index-- ))
+ [[ 1 -ge 1 ]]
+ [[ - != \- ]]
+ [[ 2 -lt 2 ]]
+ (( ++i ))
+ (( i <= cword ))
+ [[ -n - ]]
+ [[ ! -n - ]]
+ [[ 1 -lt 0 ]]
+ local words cword cur
+ _upvars -a3 words perl -d - -v cword 2 -v cur -
+ (( 11 ))
+ (( 11 ))
+ case $1 in
+ [[ -n 3 ]]
+ printf %d 3
+ [[ -n words ]]
+ unset -v words
+ eval 'words=("${@:3:3}")'
words=("${@:3:3}")
++ words=("${@:3:3}")
+ shift 5
+ (( 6 ))
+ case $1 in
+ [[ -n cword ]]
+ unset -v cword
+ eval 'cword="$3"'
cword="$3"
++ cword=2
+ shift 3
+ (( 3 ))
+ case $1 in
+ [[ -n cur ]]
+ unset -v cur
+ eval 'cur="$3"'
cur="$3"
++ cur=-
+ shift 3
+ (( 0 ))
+ [[ -n cur ]]
+ upvars+=("$vcur")
+ upargs+=(-v $vcur "$cur")
+ [[ -n cword ]]
+ upvars+=("$vcword")
+ upargs+=(-v $vcword "$cword")
+ [[ -n prev ]]
+ [[ 2 -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 - -v cword 2 -v prev -d -a3 words perl -d -
+ (( 14 ))
+ (( 14 ))
+ case $1 in
+ [[ -n cur ]]
+ unset -v cur
+ eval 'cur="$3"'
cur="$3"
++ cur=-
+ shift 3
+ (( 11 ))
+ case $1 in
+ [[ -n cword ]]
+ unset -v cword
+ eval 'cword="$3"'
cword="$3"
++ cword=2
+ shift 3
+ (( 8 ))
+ case $1 in
+ [[ -n prev ]]
+ unset -v prev
+ eval 'prev="$3"'
prev="$3"
++ prev=-d
+ shift 3
+ (( 5 ))
+ case $1 in
+ [[ -n 3 ]]
+ printf %d 3
+ [[ -n words ]]
+ unset -v words
+ eval 'words=("${@:3:3}")'
words=("${@:3:3}")
++ words=("${@:3:3}")
+ shift 5
+ (( 0 ))
+ _variables
+ [[ - =~ ^(\$\{?)([A-Za-z0-9_]*)$ ]]
+ return 1
+ [[ - == @(?([0-9])<|?([0-9&])>?(>)|>&)* ]]
+ [[ -d == @(?([0-9])<|?([0-9&])>?(>)|>&) ]]
+ local i skip
+ (( i=1 ))
+ (( i < 3 ))
+ [[ -d == @(?([0-9])<|?([0-9&])>?(>)|>&)* ]]
+ i=2
+ (( 1 ))
+ (( i < 3 ))
+ [[ - == @(?([0-9])<|?([0-9&])>?(>)|>&)* ]]
+ i=3
+ (( 1 ))
+ (( i < 3 ))
+ [[ 2 -le 0 ]]
+ prev=-d
+ [[ -n '' ]]
+ return 0
+ local prefix= temp optPrefix optSuffix
+ [[ - == -?* ]]
+ case $prev in
+ [[ - == :* ]]
+ return 0
Which version of bash-completion is this, what version of bash, and on what os?
$ uname -a
Linux work 4.13.0-26-generic #29~16.04.2-Ubuntu SMP Tue Jan 9 22:00:44 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
$ bash --version
bash --version
GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
OS is: Linux Mint 18.3 How to check bash-completion version? (my version is shipped with OS, at least I do not remember that install it manually)
bash-completion version can be checked from the bash_completion file, or using your distro package management tools (maybe dpkg -l bash-completion
?). But if it's the one that comes with Linux Mint, chances are that it follows the parent Ubuntu/Debian version, which used to lag far behind -- it could be as old as 2.1.
Anyway I suggest trying with the latest version from here -- if that works, switch to it yourself, or (better) ask your distro maintainers to update the version they ship. Or figure out what the fix for this issue was and ask your distro maintainers to patch their version.
$ dpkg -l bash-completion
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-===================-==============-==============-===========================================
ii bash-completion 1:2.1-4.2ubunt all programmable completion for the bash shell
Example:
without
-d
option completion works fine:Even this works fine:
What is the problem with
-d
option? How to fix it?