【问题标题】:What is the correct way to export a bash function after the shellshock updates?shellshock更新后导出bash函数的正确方法是什么?
【发布时间】:2016-01-29 06:53:28
【问题描述】:

我目前的脚本有问题,但我不确定语法是否正确。我认为脚本被 bash 的 shellshock 补丁破坏了,但我只是想检查一下。

自 shellshock 补丁以来导出 bash 函数的正确方法是什么。补丁之前的正确方法是什么?

以下是我正在寻找的一些示例。

答。

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

【问题讨论】:

    标签: bash redhat shellshock-bash-bug


    【解决方案1】:

    导出函数的正确方法没有改变。定义函数,然后使用export -f

    func() {
        foo
        bar
    }
    export -f func
    

    【讨论】:

      猜你喜欢
      • 2011-09-08
      • 2014-11-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多