mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-12-22 20:57:53 +00:00
env_parallel.ksh: Fixed for ksh #47483: env_parallel export --env only.
This commit is contained in:
parent
805d924c16
commit
a3947338da
|
@ -26,8 +26,67 @@
|
|||
# Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
env_parallel() {
|
||||
# env_parallel.ksh
|
||||
export PARALLEL_ENV="$(alias | perl -pe 's/^/alias /';typeset -p|egrep -v 'typeset( -i)? -r|PIPESTATUS';typeset -f)";
|
||||
`which parallel` "$@";
|
||||
unset PARALLEL_ENV;
|
||||
# env_parallel.ksh
|
||||
|
||||
# Get the --env variables if set
|
||||
# and convert a b c to (a|b|c)
|
||||
# If --env not set: Match everything (.*)
|
||||
grep_REGEXP="$(
|
||||
perl -e 'for(@ARGV){
|
||||
$next_is_env and push @envvar, split/,/, $_;
|
||||
$next_is_env=/^--env$/;
|
||||
}
|
||||
$vars = join "|",map { quotemeta $_ } @envvar;
|
||||
print $vars ? "($vars)" : "(.*)";
|
||||
' -- "$@"
|
||||
)"
|
||||
|
||||
# Grep alias names
|
||||
_alias_NAMES="$(alias | perl -pe 's/=.*//' |
|
||||
egrep "^${grep_REGEXP}\$")"
|
||||
_list_alias_BODIES="alias $_alias_NAMES | perl -pe 's/^/alias /'"
|
||||
if [[ "$_alias_NAMES" = "" ]] ; then
|
||||
# no aliases selected
|
||||
_list_alias_BODIES="true"
|
||||
fi
|
||||
unset _alias_NAMES
|
||||
|
||||
# Grep function names
|
||||
_function_NAMES="$(typeset +p -f | perl -pe 's/\(\).*//' |
|
||||
egrep "^${grep_REGEXP}\$")"
|
||||
_list_function_BODIES="typeset -f $_function_NAMES"
|
||||
if [[ "$_function_NAMES" = "" ]] ; then
|
||||
# no functions selected
|
||||
_list_function_BODIES="true"
|
||||
fi
|
||||
unset _function_NAMES
|
||||
|
||||
# Grep variable names
|
||||
_variable_NAMES="$(typeset +p | perl -pe 's/^typeset .. //' |
|
||||
egrep "^${grep_REGEXP}\$" |
|
||||
egrep -v '^(PIPESTATUS)$')"
|
||||
_list_variable_VALUES="typeset -p $_variable_NAMES"
|
||||
if [[ "$_variable_NAMES" = "" ]] ; then
|
||||
# no variables selected
|
||||
_list_variable_VALUES="true"
|
||||
fi
|
||||
unset _variable_NAMES
|
||||
|
||||
# eval is needed for aliases - cannot explain why
|
||||
export PARALLEL_ENV="$(
|
||||
eval $_list_alias_BODIES;
|
||||
$_list_variable_VALUES;
|
||||
$_list_function_BODIES)";
|
||||
unset _list_alias_BODIES
|
||||
unset _list_variable_VALUES
|
||||
unset _list_function_BODIES
|
||||
`which parallel` "$@";
|
||||
unset PARALLEL_ENV;
|
||||
}
|
||||
|
||||
# _env_parallel() {
|
||||
# # env_parallel.ksh
|
||||
# export PARALLEL_ENV="$(alias | perl -pe 's/^/alias /';typeset -p|egrep -v 'typeset( -i)? -r|PIPESTATUS';typeset -f)";
|
||||
# `which parallel` "$@";
|
||||
# unset PARALLEL_ENV;
|
||||
# }
|
||||
|
|
|
@ -75,6 +75,43 @@ ssh zsh@lo '
|
|||
env_parallel -k --env myarray -S server echo "\${myarray[{}]}" ::: 1 2 3
|
||||
'
|
||||
|
||||
echo '### ksh'
|
||||
ssh ksh@lo '
|
||||
. `which env_parallel.ksh`;
|
||||
alias myecho="echo aliases";
|
||||
env_parallel myecho ::: work;
|
||||
env_parallel -S server myecho ::: work;
|
||||
env_parallel --env myecho myecho ::: work;
|
||||
env_parallel --env myecho -S server myecho ::: work
|
||||
'
|
||||
|
||||
ssh ksh@lo '
|
||||
. `which env_parallel.ksh`;
|
||||
myfunc() { echo functions $*; };
|
||||
env_parallel myfunc ::: work;
|
||||
env_parallel -S server myfunc ::: work;
|
||||
env_parallel --env myfunc myfunc ::: work;
|
||||
env_parallel --env myfunc -S server myfunc ::: work
|
||||
'
|
||||
|
||||
ssh ksh@lo '
|
||||
. `which env_parallel.ksh`;
|
||||
myvar=variables;
|
||||
env_parallel echo "\$myvar" ::: work;
|
||||
env_parallel -S server echo "\$myvar" ::: work;
|
||||
env_parallel --env myvar echo "\$myvar" ::: work;
|
||||
env_parallel --env myvar -S server echo "\$myvar" ::: work
|
||||
'
|
||||
|
||||
ssh ksh@lo '
|
||||
. `which env_parallel.ksh`;
|
||||
myarray=(arrays work, too);
|
||||
env_parallel -k echo "\${myarray[{}]}" ::: 0 1 2;
|
||||
env_parallel -k -S server echo "\${myarray[{}]}" ::: 0 1 2;
|
||||
env_parallel -k --env myarray echo "\${myarray[{}]}" ::: 0 1 2;
|
||||
env_parallel -k --env myarray -S server echo "\${myarray[{}]}" ::: 0 1 2
|
||||
'
|
||||
|
||||
echo '### --env _'
|
||||
fUbAr="OK FUBAR" parallel -S parallel@lo --env _ echo '$fUbAr $DEBEMAIL' ::: test
|
||||
fUbAr="OK FUBAR" parallel -S csh@lo --env _ echo '$fUbAr $DEBEMAIL' ::: test
|
||||
|
|
|
@ -192,7 +192,7 @@ ls: cannot access bug46519.ccc: No such file or directory
|
|||
echo '### Test --nice remote'
|
||||
### Test --nice remote
|
||||
stdout parallel --nice 1 -S lo -vv 'PAR=a bash -c "echo \$PAR {}"' ::: b | perl -pe 's/\S*parallel-server\S*/one-server/;s:[a-z/\\+=0-9]{500,}:base64:i;'
|
||||
ssh lo -- exec perl -e @GNU_Parallel\\\=\\\(\\\"use\\\",\\\"IPC::Open3\\\;\\\",\\\"use\\\",\\\"MIME::Base64\\\"\\\)\\\;eval\\\"@GNU_Parallel\\\"\\\;my\\\$eval\\\=decode_base64\\\(join\\\"\\\",@ARGV\\\)\\\;eval\\\$eval\\\; base64;
|
||||
ssh lo -- exec perl -e @GNU_Parallel\\\=\\\(\\\"use\\\",\\\"IPC::Open3\\\;\\\",\\\"use\\\",\\\"MIME::Base64\\\"\\\)\\\;eval\\\"@GNU_Parallel\\\"\\\;\\\$SIG\\\{CHLD\\\}\\\=\\\"IGNORE\\\"\\\;my\\\$zip\\\=\\\(grep\\\{-x\\\$_\\\}\\\"/usr/local/bin/bzip2\\\"\\\)\\\[0\\\]\\\|\\\|\\\"bzip2\\\"\\\;my\\\(\\\$in,\\\$out,\\\$eval\\\)\\\;open3\\\(\\\$in,\\\$out,\\\"\\\>\\\&STDERR\\\",\\\$zip,\\\"-dc\\\"\\\)\\\;if\\\(my\\\$perlpid\\\=fork\\\)\\\{close\\\$in\\\;\\\$eval\\\=join\\\"\\\",\\\<\\\$out\\\>\\\;close\\\$out\\\;\\\}else\\\{close\\\$out\\\;print\\\$in\\\(decode_base64\\\(join\\\"\\\",@ARGV\\\)\\\)\\\;close\\\$in\\\;exit\\\;\\\}wait\\\;eval\\\$eval\\\; base64;
|
||||
a b
|
||||
echo '**'
|
||||
**
|
||||
|
|
|
@ -37,7 +37,7 @@ aliases work
|
|||
aliases work
|
||||
aliases work
|
||||
aliases work
|
||||
ssh zsh@lo ' myfunc() { echo functions $*; }; env_parallel myfunc ::: work; env_parallel -S server myfunc ::: work; env_parallel --env myfunc myfunc ::: work; env_parallel --env myfunc -S server myfunc ::: work '
|
||||
ssh zsh@lo ' myfunc() { echo functions $*; }; env_parallel myfunc ::: work; env_parallel -S server myfunc ::: work; env_parallel --env myfunc myfunc ::: work; env_parallel --env myfunc -S server myfunc ::: work '
|
||||
functions work
|
||||
functions work
|
||||
functions work
|
||||
|
@ -60,6 +60,36 @@ too
|
|||
arrays
|
||||
work,
|
||||
too
|
||||
echo '### ksh'
|
||||
### ksh
|
||||
ssh ksh@lo ' . `which env_parallel.ksh`; alias myecho="echo aliases"; env_parallel myecho ::: work; env_parallel -S server myecho ::: work; env_parallel --env myecho myecho ::: work; env_parallel --env myecho -S server myecho ::: work '
|
||||
aliases work
|
||||
aliases work
|
||||
aliases work
|
||||
aliases work
|
||||
ssh ksh@lo ' . `which env_parallel.ksh`; myfunc() { echo functions $*; }; env_parallel myfunc ::: work; env_parallel -S server myfunc ::: work; env_parallel --env myfunc myfunc ::: work; env_parallel --env myfunc -S server myfunc ::: work '
|
||||
functions work
|
||||
functions work
|
||||
functions work
|
||||
functions work
|
||||
ssh ksh@lo ' . `which env_parallel.ksh`; myvar=variables; env_parallel echo "\$myvar" ::: work; env_parallel -S server echo "\$myvar" ::: work; env_parallel --env myvar echo "\$myvar" ::: work; env_parallel --env myvar -S server echo "\$myvar" ::: work '
|
||||
variables work
|
||||
variables work
|
||||
variables work
|
||||
variables work
|
||||
ssh ksh@lo ' . `which env_parallel.ksh`; myarray=(arrays work, too); env_parallel -k echo "\${myarray[{}]}" ::: 0 1 2; env_parallel -k -S server echo "\${myarray[{}]}" ::: 0 1 2; env_parallel -k --env myarray echo "\${myarray[{}]}" ::: 0 1 2; env_parallel -k --env myarray -S server echo "\${myarray[{}]}" ::: 0 1 2 '
|
||||
arrays
|
||||
work,
|
||||
too
|
||||
arrays
|
||||
work,
|
||||
too
|
||||
arrays
|
||||
work,
|
||||
too
|
||||
arrays
|
||||
work,
|
||||
too
|
||||
echo '### --env _'
|
||||
### --env _
|
||||
fUbAr="OK FUBAR" parallel -S parallel@lo --env _ echo '$fUbAr $DEBEMAIL' ::: test
|
||||
|
|
|
@ -92,7 +92,7 @@ With script in $PARALLEL /bin/bash=/home/tange/privat/parallel/testsuite
|
|||
echo '### bug #42892: parallel -a nonexiting --pipepart'
|
||||
### bug #42892: parallel -a nonexiting --pipepart
|
||||
parallel --pipepart -a nonexisting wc
|
||||
parallel: Error: nonexisting is not a seekable file.
|
||||
parallel: Error: nonexisting is neither a file nor a block device
|
||||
echo '### bug #42913: Dont use $SHELL but the shell currently running'
|
||||
### bug #42913: Dont use $SHELL but the shell currently running
|
||||
echo '## Unknown shell => $SHELL (bash)'
|
||||
|
|
Loading…
Reference in a new issue