Reputation: 33
I'm running some legacy code on bash shell and I'm having trouble understanding/passing through this line:
BASH_FUNC_module()='() { eval `/usr/bin/modulecmd bash $*`
}'; export BASH_FUNC_module()
The error I get is:
line 364: syntax error near unexpected token `='() { eval `/usr/bin/modulecmd bash $*`
}''
line 364: `}'; export BASH_FUNC_module()'
Any pointers would be appreciated, I'm new to shell :) Thanks!
Upvotes: 2
Views: 4383
Reputation: 55
Mike Frysinger correctly describes the problem cause. However, solving the problem generally requires one of several steps:
unset -f module
More generally, to unset all exported functions you could use the following:
unset -f $(env | awk '/^BASH_FUNC_/{sub("[(].*","");print substr($0,11)}')
Of course:
unset -f
command also has the effect of removing the function(s) from the current shell.Upvotes: 0
Reputation: 531235
You are incorrectly combining the syntax for assignment and function definitions.
BASH_FUNC_module='() { eval `/usr/bin/modulecmd bash $*`; }'
export BASH_FUNC_module
Upvotes: 0
Reputation: 3072
it looks like you're trying to convert some trace/dump output of bash. most likely you want:
module() { eval `/usr/bin/modulecmd bash $*`; }
export -f module
that should work on old/new versions of bash.
Upvotes: 2