Linux – Strange bash error: “error importing function definition for `BASH_FUNC_module'”

bashlinuxshellshock

Sample script:

#!/usr/bin/env bash
echo "abc"

Output from Bash version 4.1.2(1)-release:

$ ./a.bash
bash: BASH_FUNC_module(): line 0: syntax error near unexpected token `)'
bash: BASH_FUNC_module(): line 0: `BASH_FUNC_module() () {  eval `/usr/bin/modulecmd bash $*`'
bash: error importing function definition for `BASH_FUNC_module'
abc

Output from Bash version 3.2.25(1)-release:

$ ./a.bash
abc

Interestingly, they both work, but I would like to remove that ugly message.

I think this is related to the Shellshock patch, but I need some help to confirm.

I did some Googling, and most pages point to behaviour of Bash after Shellshock patching, but I don't know the correct workaround.

What is the workaround for this issue?

I am working at a "mega corp", so control over installed packages is nil.

Best Answer

The only immediately obvious error is that someone did eval `/usr/bin/modulecmd bash $*`. There are too many weird things in that code to go into detail (does it really need eval, why the ye olde style backticks, why $* instead of $@, and why are there no quotes anywhere), but it looks like you may have a severely handicapped shell to deal with.

Related Question