Skip to content

_xspecs: bad array subscript on alias completion #388

@okomestudio

Description

@okomestudio

I'm using Bash-it (https://github.com/Bash-it/bash-it) along with bash-complete on Debian Buster, and I get an _xspecs: bad array subscript error whenever I use an alias that uses _filedir_xspec. The original ticket was filed in Bash-it: Bash-it/bash-it#1497

There is an alias

$ alias en
alias en='emacs -nw'
$ complete -p en
complete -F _alias_completion::en en

The _alias_completion::en en is a dynamically generated function by Bash-it (except the echo line, which I added only for debugging purpose and does not affect the bug):

$ type -a _alias_completion\:\:en
_alias_completion::en is a function
_alias_completion::en () 
{ 
    (( COMP_CWORD += 1 ));
    COMP_WORDS=(emacs -nw ${COMP_WORDS[@]:1});
    (( COMP_POINT -= ${#COMP_LINE} ));
    COMP_LINE=${COMP_LINE/en/emacs -nw};
    (( COMP_POINT += ${#COMP_LINE} ));
    echo [${COMP_LINE}][${COMP_CWORD}][${COMP_POINT}][${COMP_TYPE}][${COMP_KEY}][${COMP_WORDS[@]}] 1>&2;
    _filedir_xspec
}

When I use TAB after typing som to open the file named somefile, I get this:

$ en som[emacs -nw som][2][13][9][9][emacs -nw som]
bash: _xspecs: bad array subscript
efile

Note that the completion actually seems to be working (see efile following the error message), but it outputs bash: _xspecs: bad array subscript upon hitting TAB. The parameters that I echo in square brackets seem to make sense to me (though I am not actually familiar with COMP_* variables).

I am wondering if this is a bug in bash-completion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions