0

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
digitaLink
  • 458
  • 3
  • 17

1 Answers1

1

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

func() {
    foo
    bar
}
export -f func
John Kugelman
  • 349,597
  • 67
  • 533
  • 578