mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-11-25 15:37:56 +00:00
Fixed env_parallel not working on old versions of Bash.
https://lists.gnu.org/archive/html/bug-parallel/2017-07/msg00000.html
This commit is contained in:
parent
8e22009706
commit
10b4539b1f
|
@ -97,13 +97,10 @@ env_parallel() {
|
|||
' -- "$@"
|
||||
}
|
||||
|
||||
if which parallel | grep 'no parallel in' >/dev/null; then
|
||||
echo 'env_parallel: Error: parallel must be in $PATH.' >&2
|
||||
return 255
|
||||
fi
|
||||
if which parallel >/dev/null; then
|
||||
true which on linux
|
||||
else
|
||||
|
||||
# Bash 'which' is broken in version 3.2.25 and 4.2.39
|
||||
# The crazy '[ "`...`" == "" ]' is needed for the same reason
|
||||
if [ "`which parallel`" == "" ]; then
|
||||
echo 'env_parallel: Error: parallel must be in $PATH.' >&2
|
||||
return 255
|
||||
fi
|
||||
|
@ -115,7 +112,7 @@ env_parallel() {
|
|||
_ignore_UNDERSCORE="`_get_ignored_VARS \"$@\"`"
|
||||
|
||||
# --record-env
|
||||
if perl -e 'exit grep { /^--record-env$/ } @ARGV' -- "$@"; then
|
||||
if [ "`perl -e 'exit grep { /^--record-env$/ } @ARGV' -- "$@"; echo $?`" == 0 ] ; then
|
||||
true skip
|
||||
else
|
||||
(_names_of_ALIASES;
|
||||
|
@ -152,6 +149,7 @@ env_parallel() {
|
|||
fi
|
||||
unset _variable_NAMES
|
||||
|
||||
_which_true="`which true`"
|
||||
# Copy shopt (so e.g. extended globbing works)
|
||||
# But force expand_aliases as aliases otherwise do not work
|
||||
PARALLEL_ENV="`
|
||||
|
@ -165,7 +163,7 @@ env_parallel() {
|
|||
unset _list_variable_VALUES
|
||||
unset _list_function_BODIES
|
||||
# Test if environment is too big
|
||||
if `which true` >/dev/null ; then
|
||||
if [ "`which true`" == "$_which_true" ] ; then
|
||||
`which parallel` "$@";
|
||||
_parallel_exit_CODE=$?
|
||||
unset PARALLEL_ENV;
|
||||
|
|
|
@ -1376,7 +1376,7 @@ sub check_invalid_option_combinations {
|
|||
|
||||
sub init_globals {
|
||||
# Defaults:
|
||||
$Global::version = 20170624;
|
||||
$Global::version = 20170706;
|
||||
$Global::progname = 'parallel';
|
||||
$Global::infinity = 2**31;
|
||||
$Global::debug = 0;
|
||||
|
|
|
@ -66,6 +66,21 @@ echo '### Does PARALLEL_SHELL help exporting a bash function not kill parallel'
|
|||
echo
|
||||
PARALLEL_SHELL=/bin/bash parallel --retries $RETRIES --onall -j0 -k --tag --timeout $TIMEOUT $S_POLAR 'func() { cat <(echo bash only B); };export -f func; bin/parallel func ::: ' ::: 1 2>&1 | sort
|
||||
|
||||
echo
|
||||
echo '### env_parallel echo :::: <(echo OK)'
|
||||
echo '(bash only)'
|
||||
echo
|
||||
parallel --retries $RETRIES --onall -j0 -k --tag --timeout $TIMEOUT $S_POLAR 'bin/env_parallel --install'
|
||||
parallel --retries $RETRIES --onall -j0 -k --tag --timeout $TIMEOUT $S_POLAR 'env_parallel echo env_parallel ::: OK'
|
||||
parallel --retries $RETRIES --onall -j0 -k --tag --timeout $TIMEOUT $S_POLAR 'env_parallel echo reading from process substitution :::: <(echo OK)'
|
||||
|
||||
# eval 'myfunc() { echo '$(perl -e 'print "x"x20000')'; }'
|
||||
# env_parallel myfunc ::: a | wc # OK
|
||||
# eval 'myfunc2() { echo '$(perl -e 'print "x"x120000')'; }'
|
||||
# env_parallel myfunc ::: a | wc # Fail too big env
|
||||
# Can this be made faster using `ssh -M`?
|
||||
# Can it be moved to virtualbox?
|
||||
|
||||
# Started earlier - therefore wait
|
||||
wait; cat /tmp/test_empty_cmd
|
||||
rm /tmp/test_empty_cmd
|
||||
|
|
Loading…
Reference in a new issue