在shell中导出函数 [英] Exporting a function in shell
本文介绍了在shell中导出函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
export -f
功能特定于Bash:
parent
#!/ bin / bash
plus1(){echo $(($ 1 + 1)) ; }
echo $(plus1 8)
export -f plus1
./child 14 21
孩子
#!/ bin / bash
echo $(plus1 $(($ 1 * $ 2)))
Please tell me how to export a function in parent shell (bash, sh or ksh) so that the function will be available to all the child process launced from the parent process?
解决方案
The export -f
feature is specific to Bash:
parent
#!/bin/bash
plus1 () { echo $(($1 + 1)); }
echo $(plus1 8)
export -f plus1
./child 14 21
child
#!/bin/bash
echo $(plus1 $(($1 * $2)) )
这篇关于在shell中导出函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文