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).
Please Cc me in replies, I'm not subscribed to bug-bash at the moment.