digitaLink
digitaLink

Reputation: 458

What is the correct way to export a bash function after the shellshock updates?

I am having problems with a script currently, but I'm not sure of the correct syntax. I think the script was broken with the shellshock patch to bash, but I just want to check.

What is the correct way to export a bash function since the shellshock patch. And what was the correct way before the patch?

Here are a few examples of what I am looking for.

A.

export BASH_FUNC_module()='() {  eval `/usr/bin/modulecmd bash $*`\0012}'

B

export BASH_FUNC_module='() {  eval `/usr/bin/modulecmd bash $*`\0012}'

C

BASH_FUNC_module='() {  eval `/usr/bin/modulecmd bash $*`\0012}'
export -f BASH_FUNC_module

Upvotes: 0

Views: 219

Answers (1)

John Kugelman
John Kugelman

Reputation: 361997

The correct way to export a function hasn't changed. Define the function, then use export -f.

func() {
    foo
    bar
}
export -f func

Upvotes: 1

Related Questions