Hi,
I'm wondering if there is any concept like closure in bash. In the
first example, when export -f testing, the parallel command work just
fine. But in the second example, I just exported testing2, var is not
exported. Then the parallel doesn't work as expected. In the last
example, I exported var, so parallel works as expected.
If something like closure were supported, then I don't have to
explicitly export var. This will be convenient if there are many
external variables used in testing2.
Does anybody know if there is something like closure to eliminated the
need of extra exports? Thanks!
~/linux/test/gnu/parallel$ cat main.sh
#!/usr/bin/env bash
#(echo x; echo y;) | parallel echo "a{}"
function testing {
echo test$1
}
export -f testing
(echo x; echo y;) | parallel testing '{}'
var=hello
function testing2 {
echo $var$1
}
export -f testing2
(echo x; echo y;) | parallel testing2 '{}'
export var
(echo x; echo y;) | parallel testing2 '{}'
~/linux/test/gnu/parallel$ ./main.sh
testy
testx
x
y
helloy
hellox
--
Regards,
Peng