4

So I was getting the following error:

bash: _parse_usage: line 16: syntax error near unexpected token `('
bash: _parse_usage: line 16: ` -?(\[)+([a-zA-Z0-9?]))'
bash: error importing function definition for `_parse_usage'
bash: _longopt: line 14: syntax error near unexpected token `('
bash: _longopt: line 14: ` --+([-a-z0-9_]))'
bash: error importing function definition for `_longopt'

Apparently only on function invocations.

1 Answers1

7

It turns out that the error comes from bash-completion package (apt install bash-completion). Reinstalling it had no effect, so it was not corrupted. After some trial and error I traced the trigger of this error to an innocent looking line

set -a

in a file sourced from .bashrc

Exporting all new variables in .bashrc is therefore not a good idea, unless you turn the option off again using

set +a
muru
  • 207,970
  • 1
    Other things that are not a good idea with bash-completion: shopt -s nullglob – muru Jan 31 '18 at 09:58
  • 1
    after squandering an hr on this, I added the following to the end of my bashrc (maybe will add to my prompt code instead) if set | grep -q allexport; then printf 'There is a set -a in a script somewhere'; fi – Alan Berezin Apr 04 '20 at 19:29