env_parallel: Fixed bug #54212: env_parallel env_parallel echo ::: 1 fails.

This commit is contained in:
Ole Tange 2018-07-18 17:29:57 +02:00
parent fe92398309
commit 628c0029cc
13 changed files with 59 additions and 21 deletions

View file

@ -157,7 +157,7 @@ env_parallel() {
push @ignored_vars, split/\s+/, $ENV{PARALLEL_IGNORED_NAMES}; push @ignored_vars, split/\s+/, $ENV{PARALLEL_IGNORED_NAMES};
chomp @ignored_vars; chomp @ignored_vars;
} }
$vars = join "|",map { quotemeta $_ } "env_parallel", @ignored_vars; $vars = join "|",map { quotemeta $_ } @ignored_vars;
print $vars ? "($vars)" : "(,,nO,,VaRs,,)"; print $vars ? "($vars)" : "(,,nO,,VaRs,,)";
' -- "$@" ' -- "$@"
} }

View file

@ -149,7 +149,7 @@ env_parallel() {
push @ignored_vars, split/\s+/, $ENV{PARALLEL_IGNORED_NAMES}; push @ignored_vars, split/\s+/, $ENV{PARALLEL_IGNORED_NAMES};
chomp @ignored_vars; chomp @ignored_vars;
} }
$vars = join "|",map { quotemeta $_ } "env_parallel", @ignored_vars; $vars = join "|",map { quotemeta $_ } @ignored_vars;
print $vars ? "($vars)" : "(,,nO,,VaRs,,)"; print $vars ? "($vars)" : "(,,nO,,VaRs,,)";
' -- "$@" ' -- "$@"
} }

View file

@ -66,7 +66,7 @@ else
"Run \"parallel --record-env\" in a clean environment first.\n"; "Run \"parallel --record-env\" in a clean environment first.\n";
} else { } else {
chomp(@ignored_vars = <IN>); chomp(@ignored_vars = <IN>);
$vars = join "|",map { quotemeta $_ } "env_parallel", @ignored_vars; $vars = join "|",map { quotemeta $_ } @ignored_vars;
print $vars ? "($vars)" : "(,,nO,,VaRs,,)"; print $vars ? "($vars)" : "(,,nO,,VaRs,,)";
} }
} }
@ -136,7 +136,3 @@ else
setenv PARALLEL setenv PARALLEL
endif endif
(exit $_parallel_exit_CODE) (exit $_parallel_exit_CODE)
# Tested working for aliases
# alias env_parallel 'setenv PARALLEL_ENV "`alias | perl -pe s/\\047/\\047\\042\\047\\042\\047/g\;s/\^\(\\S+\)\(\\s+\)\\\(\(.\*\)\\\)/\\1\\2\\3/\;s/\^\(\\S+\)\(\\s+\)\(.\*\)/\\1\\2\\047\\3\\047/\;s/\^/\\001alias\ /\;s/\\\!/\\\\\\\!/g;`";parallel \!*; setenv PARALLEL_ENV'

View file

@ -157,7 +157,7 @@ env_parallel() {
push @ignored_vars, split/\s+/, $ENV{PARALLEL_IGNORED_NAMES}; push @ignored_vars, split/\s+/, $ENV{PARALLEL_IGNORED_NAMES};
chomp @ignored_vars; chomp @ignored_vars;
} }
$vars = join "|",map { quotemeta $_ } "env_parallel", @ignored_vars; $vars = join "|",map { quotemeta $_ } @ignored_vars;
print $vars ? "($vars)" : "(,,nO,,VaRs,,)"; print $vars ? "($vars)" : "(,,nO,,VaRs,,)";
' -- "$@" ' -- "$@"
} }

View file

@ -71,7 +71,7 @@ function env_parallel
"Run \"parallel --record-env\" in a clean environment first.\n"; "Run \"parallel --record-env\" in a clean environment first.\n";
} else { } else {
chomp(@ignored_vars = <IN>); chomp(@ignored_vars = <IN>);
$vars = join "|",map { quotemeta $_ } "env_parallel", @ignored_vars; $vars = join "|",map { quotemeta $_ } @ignored_vars;
print $vars ? "($vars)" : "(,,nO,,VaRs,,)"; print $vars ? "($vars)" : "(,,nO,,VaRs,,)";
} }
} }

View file

@ -48,7 +48,8 @@ env_parallel() {
typeset +p -f | perl -pe 's/\(\).*//' typeset +p -f | perl -pe 's/\(\).*//'
} }
_bodies_of_FUNCTIONS() { _bodies_of_FUNCTIONS() {
typeset -f "$@" # typeset -f "$@"
functions "$@"
} }
_names_of_VARIABLES() { _names_of_VARIABLES() {
typeset +p | perl -pe 's/^typeset .. //' typeset +p | perl -pe 's/^typeset .. //'
@ -58,7 +59,7 @@ env_parallel() {
} }
_ignore_HARDCODED() { _ignore_HARDCODED() {
# These names cannot be detected # These names cannot be detected
echo '(_|TIMEOUT)' echo '(_|TIMEOUT|IFS)'
} }
_ignore_READONLY() { _ignore_READONLY() {
readonly | perl -e '@r = map { readonly | perl -e '@r = map {
@ -140,7 +141,7 @@ env_parallel() {
push @ignored_vars, split/\s+/, $ENV{PARALLEL_IGNORED_NAMES}; push @ignored_vars, split/\s+/, $ENV{PARALLEL_IGNORED_NAMES};
chomp @ignored_vars; chomp @ignored_vars;
} }
$vars = join "|",map { quotemeta $_ } "env_parallel", @ignored_vars; $vars = join "|",map { quotemeta $_ } @ignored_vars;
print $vars ? "($vars)" : "(,,nO,,VaRs,,)"; print $vars ? "($vars)" : "(,,nO,,VaRs,,)";
' -- "$@" ' -- "$@"
} }

View file

@ -143,7 +143,7 @@ env_parallel() {
push @ignored_vars, split/\s+/, $ENV{PARALLEL_IGNORED_NAMES}; push @ignored_vars, split/\s+/, $ENV{PARALLEL_IGNORED_NAMES};
chomp @ignored_vars; chomp @ignored_vars;
} }
$vars = join "|",map { quotemeta $_ } "env_parallel", @ignored_vars; $vars = join "|",map { quotemeta $_ } @ignored_vars;
print $vars ? "($vars)" : "(,,nO,,VaRs,,)"; print $vars ? "($vars)" : "(,,nO,,VaRs,,)";
' -- "$@" ' -- "$@"
} }

View file

@ -78,7 +78,7 @@ env_parallel() {
"Run \"parallel --record-env\" in a clean environment first.\n"; "Run \"parallel --record-env\" in a clean environment first.\n";
} else { } else {
chomp(@ignored_vars = <IN>); chomp(@ignored_vars = <IN>);
$vars = join "|",map { quotemeta $_ } "env_parallel", @ignored_vars; $vars = join "|",map { quotemeta $_ } @ignored_vars;
print $vars ? "($vars)" : "(,,nO,,VaRs,,)"; print $vars ? "($vars)" : "(,,nO,,VaRs,,)";
} }
} }

View file

@ -157,7 +157,7 @@ env_parallel() {
push @ignored_vars, split/\s+/, $ENV{PARALLEL_IGNORED_NAMES}; push @ignored_vars, split/\s+/, $ENV{PARALLEL_IGNORED_NAMES};
chomp @ignored_vars; chomp @ignored_vars;
} }
$vars = join "|",map { quotemeta $_ } "env_parallel", @ignored_vars; $vars = join "|",map { quotemeta $_ } @ignored_vars;
print $vars ? "($vars)" : "(,,nO,,VaRs,,)"; print $vars ? "($vars)" : "(,,nO,,VaRs,,)";
' -- "$@" ' -- "$@"
} }

View file

@ -66,7 +66,7 @@ else
"Run \"parallel --record-env\" in a clean environment first.\n"; "Run \"parallel --record-env\" in a clean environment first.\n";
} else { } else {
chomp(@ignored_vars = <IN>); chomp(@ignored_vars = <IN>);
$vars = join "|",map { quotemeta $_ } "env_parallel", @ignored_vars; $vars = join "|",map { quotemeta $_ } @ignored_vars;
print $vars ? "($vars)" : "(,,nO,,VaRs,,)"; print $vars ? "($vars)" : "(,,nO,,VaRs,,)";
} }
} }

View file

@ -134,7 +134,7 @@ env_parallel() {
push @ignored_vars, split/\s+/, $ENV{PARALLEL_IGNORED_NAMES}; push @ignored_vars, split/\s+/, $ENV{PARALLEL_IGNORED_NAMES};
chomp @ignored_vars; chomp @ignored_vars;
} }
$vars = join "|",map { quotemeta $_ } "env_parallel", @ignored_vars; $vars = join "|",map { quotemeta $_ } @ignored_vars;
print $vars ? "($vars)" : "(,,nO,,VaRs,,)"; print $vars ? "($vars)" : "(,,nO,,VaRs,,)";
' -- "$@" ' -- "$@"
} }

View file

@ -51,6 +51,9 @@ par_ash_man() {
# Arrays are not supported in ash # Arrays are not supported in ash
# Exporting of functions is not supported
# env_parallel --argsep --- env_parallel -k echo ::: multi level --- env_parallel
env_parallel ::: true false true false env_parallel ::: true false true false
echo exit value $? should be 2 echo exit value $? should be 2
@ -121,6 +124,8 @@ par_bash_man() {
env_parallel -k --env myarray echo '"${myarray[{}]}"' ::: 0 1 2 3 env_parallel -k --env myarray echo '"${myarray[{}]}"' ::: 0 1 2 3
env_parallel -k --env myarray -S server echo '"${myarray[{}]}"' ::: 0 1 2 3 env_parallel -k --env myarray -S server echo '"${myarray[{}]}"' ::: 0 1 2 3
env_parallel --argsep --- env_parallel -k echo ::: multi level --- env_parallel
env_parallel ::: true false true false env_parallel ::: true false true false
echo exit value $? should be 2 echo exit value $? should be 2
@ -163,6 +168,8 @@ par_csh_man() {
env_parallel -k --env myarray echo \$'{myarray[{}]}' ::: 1 2 3 4 env_parallel -k --env myarray echo \$'{myarray[{}]}' ::: 1 2 3 4
env_parallel -k --env myarray -S server echo \$'{myarray[{}]}' ::: 1 2 3 4 env_parallel -k --env myarray -S server echo \$'{myarray[{}]}' ::: 1 2 3 4
env_parallel --argsep --- env_parallel -k echo ::: multi level --- env_parallel
env_parallel ::: true false true false env_parallel ::: true false true false
echo exit value $status should be 2 echo exit value $status should be 2
@ -217,6 +224,9 @@ par_dash_man() {
# Arrays are not supported in dash # Arrays are not supported in dash
# Exporting of functions is not supported
# env_parallel --argsep --- env_parallel -k echo ::: multi level --- env_parallel
env_parallel ::: true false true false env_parallel ::: true false true false
echo exit value $? should be 2 echo exit value $? should be 2
@ -273,6 +283,8 @@ par_fish_man() {
env_parallel -k --env myarray echo '$myarray[{}]' ::: 1 2 3 4 env_parallel -k --env myarray echo '$myarray[{}]' ::: 1 2 3 4
env_parallel -k --env myarray -S server echo '$myarray[{}]' ::: 1 2 3 4 env_parallel -k --env myarray -S server echo '$myarray[{}]' ::: 1 2 3 4
env_parallel --argsep --- env_parallel -k echo ::: multi level --- env_parallel
env_parallel ::: true false true false env_parallel ::: true false true false
echo exit value $status should be 2 echo exit value $status should be 2
@ -335,6 +347,8 @@ par_ksh_man() {
env_parallel -k --env myarray echo '"${myarray[{}]}"' ::: 0 1 2 3 env_parallel -k --env myarray echo '"${myarray[{}]}"' ::: 0 1 2 3
env_parallel -k --env myarray -S server echo '"${myarray[{}]}"' ::: 0 1 2 3 env_parallel -k --env myarray -S server echo '"${myarray[{}]}"' ::: 0 1 2 3
env_parallel --argsep --- env_parallel -k echo ::: multi level --- env_parallel
env_parallel ::: true false true false env_parallel ::: true false true false
echo exit value $? should be 2 echo exit value $? should be 2
@ -398,6 +412,8 @@ par_mksh_man() {
env_parallel -k --env myarray echo '"${myarray[{}]}"' ::: 0 1 2 3 env_parallel -k --env myarray echo '"${myarray[{}]}"' ::: 0 1 2 3
env_parallel -k --env myarray -S server echo '"${myarray[{}]}"' ::: 0 1 2 3 env_parallel -k --env myarray -S server echo '"${myarray[{}]}"' ::: 0 1 2 3
env_parallel --argsep --- env_parallel -k echo ::: multi level --- env_parallel
env_parallel ::: true false true false env_parallel ::: true false true false
echo exit value $? should be 2 echo exit value $? should be 2
@ -452,6 +468,9 @@ par_sh_man() {
# Arrays are not supported # Arrays are not supported
# Exporting of functions is not supported
# env_parallel --argsep --- env_parallel -k echo ::: multi level --- env_parallel
env_parallel ::: true false true false env_parallel ::: true false true false
echo exit value $? should be 2 echo exit value $? should be 2
@ -494,6 +513,8 @@ par_tcsh_man() {
env_parallel -k --env myarray echo \$'{myarray[{}]}' ::: 1 2 3 4 env_parallel -k --env myarray echo \$'{myarray[{}]}' ::: 1 2 3 4
env_parallel -k --env myarray -S server echo \$'{myarray[{}]}' ::: 1 2 3 4 env_parallel -k --env myarray -S server echo \$'{myarray[{}]}' ::: 1 2 3 4
env_parallel --argsep --- env_parallel -k echo ::: multi level --- env_parallel
env_parallel ::: true false true false env_parallel ::: true false true false
echo exit value $status should be 2 echo exit value $status should be 2
@ -560,6 +581,8 @@ par_zsh_man() {
env_parallel -k --env myarray echo '"${myarray[{}]}"' ::: 1 2 3 4 env_parallel -k --env myarray echo '"${myarray[{}]}"' ::: 1 2 3 4
env_parallel -k --env myarray -S server echo '"${myarray[{}]}"' ::: 1 2 3 4 env_parallel -k --env myarray -S server echo '"${myarray[{}]}"' ::: 1 2 3 4
env_parallel --argsep --- env_parallel -k echo ::: multi level --- env_parallel
env_parallel ::: true false true false env_parallel ::: true false true false
echo exit value $? should be 2 echo exit value $? should be 2
@ -1653,20 +1676,20 @@ par_bash_environment_too_big() {
echo 'bug #50815: env_parallel should warn if the environment is too big' echo 'bug #50815: env_parallel should warn if the environment is too big'
. `which env_parallel.bash`; . `which env_parallel.bash`;
bigvar="$(perl -e 'print "x"x120000')" bigvar="$(perl -e 'print "x"x110000')"
env_parallel echo ::: OK_bigvar env_parallel echo ::: OK_bigvar
env_parallel -S lo echo ::: OK_bigvar_remote env_parallel -S lo echo ::: OK_bigvar_remote
bigvar="$(perl -e 'print "\""x60000')" bigvar="$(perl -e 'print "\""x55000')"
env_parallel echo ::: OK_bigvar_quote env_parallel echo ::: OK_bigvar_quote
env_parallel -S lo echo ::: OK_bigvar_quote_remote env_parallel -S lo echo ::: OK_bigvar_quote_remote
bigvar=u bigvar=u
eval 'bigfunc() { a="'"$(perl -e 'print "x"x120000')"'"; };' eval 'bigfunc() { a="'"$(perl -e 'print "x"x110000')"'"; };'
env_parallel echo ::: OK_bigfunc env_parallel echo ::: OK_bigfunc
env_parallel -S lo echo ::: OK_bigfunc_remote env_parallel -S lo echo ::: OK_bigfunc_remote
eval 'bigfunc() { a="'"$(perl -e 'print "\""x120000')"'"; };' eval 'bigfunc() { a="'"$(perl -e 'print "\""x110000')"'"; };'
env_parallel echo ::: OK_bigfunc_quote env_parallel echo ::: OK_bigfunc_quote
env_parallel -S lo echo ::: OK_bigfunc_quote_remote env_parallel -S lo echo ::: OK_bigfunc_quote_remote
bigfunc() { true; } bigfunc() { true; }

View file

@ -120,6 +120,9 @@ par_zsh_man arrays
par_zsh_man with = & " ! ' par_zsh_man with = & " ! '
par_zsh_man work, par_zsh_man work,
par_zsh_man too par_zsh_man too
par_zsh_man multi
par_zsh_man level
par_zsh_man env_parallel
par_zsh_man exit value 2 should be 2 par_zsh_man exit value 2 should be 2
par_zsh_man Unknown option: no-such-option par_zsh_man Unknown option: no-such-option
par_zsh_man exit value 255 should be 255 par_zsh_man exit value 255 should be 255
@ -315,6 +318,9 @@ par_tcsh_man arrays
par_tcsh_man with=&"' par_tcsh_man with=&"'
par_tcsh_man work, par_tcsh_man work,
par_tcsh_man too par_tcsh_man too
par_tcsh_man multi
par_tcsh_man level
par_tcsh_man env_parallel
par_tcsh_man exit value 2 should be 2 par_tcsh_man exit value 2 should be 2
par_tcsh_man Unknown option: no-such-option par_tcsh_man Unknown option: no-such-option
par_tcsh_man Usage: par_tcsh_man Usage:
@ -668,6 +674,9 @@ par_mksh_man arrays
par_mksh_man with = & " ! ' par_mksh_man with = & " ! '
par_mksh_man work, par_mksh_man work,
par_mksh_man too par_mksh_man too
par_mksh_man multi
par_mksh_man level
par_mksh_man env_parallel
par_mksh_man exit value 2 should be 2 par_mksh_man exit value 2 should be 2
par_mksh_man Unknown option: no-such-option par_mksh_man Unknown option: no-such-option
par_mksh_man exit value 255 should be 255 par_mksh_man exit value 255 should be 255
@ -1172,6 +1181,9 @@ par_fish_man arrays
par_fish_man with = & " ! ' par_fish_man with = & " ! '
par_fish_man work, par_fish_man work,
par_fish_man too par_fish_man too
par_fish_man multi
par_fish_man level
par_fish_man env_parallel
par_fish_man exit value 2 should be 2 par_fish_man exit value 2 should be 2
par_fish_man Unknown option: no-such-option par_fish_man Unknown option: no-such-option
par_fish_man exit value 255 should be 255 `sleep 1` par_fish_man exit value 255 should be 255 `sleep 1`
@ -1431,8 +1443,11 @@ par_csh_man arrays
par_csh_man arrays par_csh_man arrays
par_csh_man arrays par_csh_man arrays
par_csh_man cat ... | parallel --pipe [options] [command [arguments]] par_csh_man cat ... | parallel --pipe [options] [command [arguments]]
par_csh_man env_parallel
par_csh_man exit value -1 should be 255 par_csh_man exit value -1 should be 255
par_csh_man exit value 2 should be 2 par_csh_man exit value 2 should be 2
par_csh_man level
par_csh_man multi
par_csh_man parallel [options] [command [arguments]] (::: arguments|:::: argfile(s))... par_csh_man parallel [options] [command [arguments]] (::: arguments|:::: argfile(s))...
par_csh_man parallel [options] [command [arguments]] < list_of_arguments par_csh_man parallel [options] [command [arguments]] < list_of_arguments
par_csh_man scientific publication, please cite: par_csh_man scientific publication, please cite:
@ -1601,6 +1616,9 @@ par_bash_man arrays
par_bash_man with = & " ! ' par_bash_man with = & " ! '
par_bash_man work, par_bash_man work,
par_bash_man too par_bash_man too
par_bash_man multi
par_bash_man level
par_bash_man env_parallel
par_bash_man exit value 2 should be 2 par_bash_man exit value 2 should be 2
par_bash_man Unknown option: no-such-option par_bash_man Unknown option: no-such-option
par_bash_man exit value 255 should be 255 par_bash_man exit value 255 should be 255