Comment 2 for bug 1813090

Revision history for this message
Will Palmer (wmpalmer) wrote :

I've been dealing with this issue for years and finally tracked it down a few minutes ago.
This is caused by the line:

    declare -A _xspecs

around line 1909 of /usr/share/bash-completion/bash_completion

this line *should* read:

    declare -Ag _xspecs

to ensure the _xspecs variable remains in the global scope, regardless of where bash_completion is sourced from.

This has been fixed in the upstream repository for over a year:

    https://github.com/wpalmer/bash-completion/commit/a47bd375bb0f95dc6d388d4097c420bddb72ae33

This also causes errors in which _xspecs, having not been seen to be previously-declared, is treated as a non-associative array, resulting in errors when strings are erroneously treated as arithmetic operations to return an integer (ie: 'invalid arithmetic operator (error token is ".sh")' when trying to complete a command with .sh in the name)

This issue has already been fixed, Ubuntu needs to either sync with upstream, or to apply the patch found at the above link.

In the meantime, the attached patch can be used as a quick workaround