[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-bash] Closure concept in bash
From: |
Peng Yu |
Subject: |
[Help-bash] Closure concept in bash |
Date: |
Thu, 26 Jan 2012 23:39:47 -0600 |
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
- [Help-bash] Closure concept in bash,
Peng Yu <=
- Re: [Help-bash] Closure concept in bash, Greg Wooledge, 2012/01/27
- Re: [Help-bash] Closure concept in bash, Peng Yu, 2012/01/30
- Re: [Help-bash] Closure concept in bash, Bob Proulx, 2012/01/30
- Re: [Help-bash] Closure concept in bash, Peng Yu, 2012/01/30
- Re: [Help-bash] Closure concept in bash, Bob Proulx, 2012/01/31
- Re: [Help-bash] Closure concept in bash, Peng Yu, 2012/01/31
- Re: [Help-bash] Closure concept in bash, Bob Proulx, 2012/01/31
- Re: [Help-bash] Closure concept in bash, Bob Proulx, 2012/01/31
- Re: [Help-bash] Closure concept in bash, Peng Yu, 2012/01/31
- Re: [Help-bash] Closure concept in bash, Greg Wooledge, 2012/01/31