[Bug 1813090] Re: bash completions in /usr/share/bash-completion generate unbound variable errors
Will Palmer
wmpalmer at gmail.com
Sat Oct 26 14:49:50 UTC 2019
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
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to bash-completion in Ubuntu.
https://bugs.launchpad.net/bugs/1813090
Title:
bash completions in /usr/share/bash-completion generate unbound
variable errors
Status in bash package in Ubuntu:
New
Status in bash-completion package in Ubuntu:
New
Bug description:
After upgrading from Ubuntu 18.04 LTS to 18.04.1 LTS, I get errors
whenever I attempt to tab-complete anything from an interactive bash
prompt.
Tab-completing nothing gives me:
-bash: _xspecs[$cmd]: unbound variable
Tab-completing an existing filename gives me:
-bash: !ref: unbound variable
I've partially narrowed down the cause to me putting `set -o nounset`
in my `.bashrc` file, and something in `/usr/share/bash-completion` is
triggering these unbound variable errors. (That is, the errors go away
if I remove `set -o nounset` or if I make `/usr/share/bash-
completion/bash_completion` exit immediately.)
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/bash/+bug/1813090/+subscriptions
More information about the foundations-bugs
mailing list