[Bash-completion-devel] Bug#622383: Bug#622383: bash-completion: completion only works from left to right: error : bash: $index: substring expression < 0

Alban Browaeys prahal at yahoo.com
Tue Apr 12 17:43:02 UTC 2011


Le mardi 12 avril 2011 à 19:16 +0200, David Paleino a écrit :
> tags 622383 unreproducible moreinfo
> thanks
> 
> Hello,
> 
> On Tue, 12 Apr 2011 18:56:58 +0200, Alban Browaeys wrote:
> 
> > Typing :
> > $ ls a
> > then moving the cursor between 'ls' and 'a' and pressing <Tab> leads to:
> > bash: $index: substring expression < 0
> > 
> > Thus completion only works right to the last character in a command. Is a fix
> > at reach ? Or is it by design ?
> 
> I can't reproduce this (| is where I place the cursor, and hit TAB):
> 
> $ ls a|
> acpi-path-to-use-sysfs.mdwn  am-assigned.mdwn
> [..]
> $ ls |a
> Display all 110 possibilities? (y or n)
> ^C
> $
> 

Sorry I forgot to tell there need to be a space before and after the
location where the cursor is:
$ ls <cursor>  a


> Can you please "set -x", and paste/attach the output to the bugreport?
> 
> Thank you,
> David
> 

$ ls + local cur prev split=false
+ _get_comp_words_by_ref -n = cur prev
+ 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
+ case $flag in
+ exclude==
+ getopts c:i:n:p:w: flag -n = cur prev
+ [[ 4 -ge 3 ]]
+ case ${!OPTIND} in
+ vcur=cur
+ let 'OPTIND += 1'
+ [[ 4 -ge 4 ]]
+ case ${!OPTIND} in
+ vprev=prev
+ let 'OPTIND += 1'
+ [[ 4 -ge 5 ]]
+ __get_cword_at_cursor_by_ref = words cword cur
+ words=()
+ local cword words
+ __reassemble_comp_words_by_ref = words cword
+ local exclude i j ref
+ [[ -n = ]]
+ exclude==
+ eval cword=1
++ cword=1
+ [[ -n = ]]
+ (( i=0, j=0 ))
+ (( i < 2 ))
+ [[ 0 -gt 0 ]]
+ ref='words[0]'
+ eval 'words[0]=${!ref}${COMP_WORDS[i]}'
++ words[0]=ls
+ [[ 0 == 1 ]]
+ (( i++, j++ ))
+ (( i < 2 ))
+ [[ 1 -gt 0 ]]
+ [[ -n a ]]
+ [[ '' == a ]]
+ ref='words[1]'
+ eval 'words[1]=${!ref}${COMP_WORDS[i]}'
++ words[1]=a
+ [[ 1 == 1 ]]
+ eval cword=1
++ cword=1
+ (( i++, j++ ))
+ (( i < 2 ))
+ local i cur2
+ local 'cur=ls  a'
+ local index=3
+ (( i = 0 ))
+ (( i <= cword ))
+ [[ 5 -ge 2 ]]
+ [[ ls != \l\s ]]
+ [[ 0 -lt 1 ]]
+ local old_size=5
+ cur='  a'
+ local new_size=3
+ index=1
+ (( ++i  ))
+ (( i <= cword ))
+ [[ 3 -ge 1 ]]
+ [[   != \a ]]
+ cur=' a'
+ (( index-- ))
+ [[ 2 -ge 1 ]]
+ [[   != \a ]]
+ cur=a
+ (( index-- ))
+ [[ 1 -ge 1 ]]
+ [[ a != \a ]]
+ [[ 1 -lt 1 ]]
+ (( ++i  ))
+ (( i <= cword ))
+ [[ a != \a ]]
bash: $index: substring expression < 0

Best regards,
Alban







More information about the Bash-completion-devel mailing list