Ville Skyttä wrote: > Hello, > > Is it intentional that COMP_CWORD may have a negative value within a > completion function? I did not find any indication of that in the bash man > page. For example: > > foo() > { > echo "COMP_CWORD:$COMP_CWORD" > } > complete -F foo bar > > Then, type "bar " (sans quotes, two spaces), go back between the two spaces > and hit tab. All bash versions I've tried with (various 3.x and 4.0 ones) > print out COMP_CWORD:-2. The -2 will obviously not work too well with things > like ${COMP_WORDS[COMP_CWORD]} (bad array subscript).
Thanks for the report. This will be fixed in either a patch or the next version of bash. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/