从子进程调用bash函数
我不确定这是否可能,但我正在寻找一种从其子进程调用bash函数的方法。可能是这样的:从子进程调用bash函数,bash,subprocess,Bash,Subprocess,我不确定这是否可能,但我正在寻找一种从其子进程调用bash函数的方法。可能是这样的: function testfunc() { echo test function; } bash -c 'testfunc' 这显然不起作用,但有没有办法实现这样的目标 非常感谢你的帮助 $ function blargh () { > echo $1 > } $ export -f blargh $ bash $ blargh hi there hi $ exit $ bash -c "blar
function testfunc() { echo test function; }
bash -c 'testfunc'
这显然不起作用,但有没有办法实现这样的目标
非常感谢你的帮助
$ function blargh () {
> echo $1
> }
$ export -f blargh
$ bash
$ blargh hi there
hi
$ exit
$ bash -c "blargh hi there"
hi
export-f
是不明显的位
$ help export
export: export [-fn] [name[=value] ...] or export -p
Set export attribute for shell variables.
Marks each NAME for automatic export to the environment of subsequently
executed commands. If VALUE is supplied, assign VALUE before exporting.
Options:
-f refer to shell functions
...
可能重复: