mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-11-25 23:47:53 +00:00
env_parallel.{bash,fish,ksh,zsh} fixes + testsuite.
This commit is contained in:
parent
3e440983e7
commit
f905690898
|
@ -65,7 +65,9 @@ env_parallel() {
|
||||||
|
|
||||||
# --record-env
|
# --record-env
|
||||||
if ! perl -e 'exit grep { /^--record-env$/ } @ARGV' -- "$@"; then
|
if ! perl -e 'exit grep { /^--record-env$/ } @ARGV' -- "$@"; then
|
||||||
(compgen -a; compgen -A function; compgen -A variable) |
|
(compgen -a;
|
||||||
|
compgen -A function;
|
||||||
|
compgen -A variable) |
|
||||||
cat > $HOME/.parallel/ignored_vars
|
cat > $HOME/.parallel/ignored_vars
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -79,12 +79,20 @@ function env_parallel
|
||||||
end;
|
end;
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# --record-env
|
||||||
|
perl -e 'exit grep { /^--record-env$/ } @ARGV' -- $argv; or begin;
|
||||||
|
begin;
|
||||||
|
functions -n | perl -pe 's/,/\n/g';
|
||||||
|
set -n;
|
||||||
|
end | cat > $HOME/.parallel/ignored_vars;
|
||||||
|
end;
|
||||||
|
|
||||||
# Export function definitions
|
# Export function definitions
|
||||||
functions -n | perl -pe 's/,/\n/g' | grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ | while read d; functions $d; end;
|
functions -n | perl -pe 's/,/\n/g' | grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ | while read d; functions $d; end;
|
||||||
# Convert scalar vars to fish \XX quoting
|
# Convert scalar vars to fish \XX quoting
|
||||||
eval (set -L | grep -E "^$_grep_REGEXP " | grep -vE "^$_ignore_UNDERSCORE " | perl -ne 'chomp;
|
eval (set -L | grep -E "^$_grep_REGEXP " | grep -vE "^$_ignore_UNDERSCORE " | perl -ne 'chomp;
|
||||||
($name,$val)=split(/ /,$_,2);
|
($name,$val)=split(/ /,$_,2);
|
||||||
$name=~/^(HOME|USER|COLUMNS|FISH_VERSION|LINES|PWD|SHLVL|_|history|status|version)$/ and next;
|
$name=~/^(HOME|USER|COLUMNS|FISH_VERSION|LINES|PWD|SHLVL|_|history|status|version)$|\./ and next;
|
||||||
if($val=~/^'"'"'/) { next; }
|
if($val=~/^'"'"'/) { next; }
|
||||||
print "set $name \"\$$name\";\n";
|
print "set $name \"\$$name\";\n";
|
||||||
')
|
')
|
||||||
|
@ -127,7 +135,7 @@ function env_parallel
|
||||||
end |perl -pe 's/\001/\\cb/g and print STDERR "env_parallel: Warning: ASCII value 1 in variables is not supported\n";
|
end |perl -pe 's/\001/\\cb/g and print STDERR "env_parallel: Warning: ASCII value 1 in variables is not supported\n";
|
||||||
s/\n/\001/'
|
s/\n/\001/'
|
||||||
)
|
)
|
||||||
parallel $argv;
|
perl -e 'exit grep { /^--record-env$/ } @ARGV' -- $argv; and parallel $argv;
|
||||||
set _parallel_exit_CODE $status
|
set _parallel_exit_CODE $status
|
||||||
set -e PARALLEL_ENV
|
set -e PARALLEL_ENV
|
||||||
return $_parallel_exit_CODE
|
return $_parallel_exit_CODE
|
||||||
|
|
|
@ -65,7 +65,9 @@ env_parallel() {
|
||||||
|
|
||||||
# --record-env
|
# --record-env
|
||||||
if ! perl -e 'exit grep { /^--record-env$/ } @ARGV' -- "$@"; then
|
if ! perl -e 'exit grep { /^--record-env$/ } @ARGV' -- "$@"; then
|
||||||
(compgen -a; compgen -A function; compgen -A variable) |
|
(alias | perl -pe 's/=.*//';
|
||||||
|
typeset +p -f | perl -pe 's/\(\).*//';
|
||||||
|
typeset +p | perl -pe 's/^typeset .. //') |
|
||||||
cat > $HOME/.parallel/ignored_vars
|
cat > $HOME/.parallel/ignored_vars
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -65,7 +65,9 @@ env_parallel() {
|
||||||
|
|
||||||
# --record-env
|
# --record-env
|
||||||
if ! perl -e 'exit grep { /^--record-env$/ } @ARGV' -- "$@"; then
|
if ! perl -e 'exit grep { /^--record-env$/ } @ARGV' -- "$@"; then
|
||||||
(compgen -a; compgen -A function; compgen -A variable) |
|
(print -l ${(k)aliases};
|
||||||
|
print -l ${(k)functions};
|
||||||
|
print -l ${(k)parameters}) |
|
||||||
cat > $HOME/.parallel/ignored_vars
|
cat > $HOME/.parallel/ignored_vars
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -4,6 +4,10 @@ echo '### test --env _'
|
||||||
echo 'Both test that variables are copied,'
|
echo 'Both test that variables are copied,'
|
||||||
echo 'but also that they are NOT copied, if ignored'
|
echo 'but also that they are NOT copied, if ignored'
|
||||||
|
|
||||||
|
#
|
||||||
|
## par_*_man = tests from the man page
|
||||||
|
#
|
||||||
|
|
||||||
par_bash_man() {
|
par_bash_man() {
|
||||||
echo '### bash'
|
echo '### bash'
|
||||||
|
|
||||||
|
@ -289,6 +293,10 @@ _EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
## par_*_underscore = tests with --env _
|
||||||
|
#
|
||||||
|
|
||||||
par_bash_underscore() {
|
par_bash_underscore() {
|
||||||
echo '### bash'
|
echo '### bash'
|
||||||
myscript=$(cat <<'_EOF'
|
myscript=$(cat <<'_EOF'
|
||||||
|
@ -296,6 +304,10 @@ par_bash_underscore() {
|
||||||
|
|
||||||
. `which env_parallel.bash`;
|
. `which env_parallel.bash`;
|
||||||
|
|
||||||
|
alias not_copied_alias="echo BAD"
|
||||||
|
not_copied_func() { echo BAD; };
|
||||||
|
not_copied_var=BAD
|
||||||
|
not_copied_array=(BAD BAD BAD);
|
||||||
env_parallel --record-env;
|
env_parallel --record-env;
|
||||||
alias myecho="echo \$myvar aliases in";
|
alias myecho="echo \$myvar aliases in";
|
||||||
myfunc() { myecho ${myarray[@]} functions $*; };
|
myfunc() { myecho ${myarray[@]} functions $*; };
|
||||||
|
@ -308,6 +320,11 @@ par_bash_underscore() {
|
||||||
env_parallel --env _ myfunc ::: work;
|
env_parallel --env _ myfunc ::: work;
|
||||||
env_parallel --env _ -S server myfunc ::: work;
|
env_parallel --env _ -S server myfunc ::: work;
|
||||||
|
|
||||||
|
env_parallel --env _ -S server not_copied_alias ::: error=OK;
|
||||||
|
env_parallel --env _ -S server not_copied_func ::: error=OK;
|
||||||
|
env_parallel --env _ -S server echo \$not_copied_var ::: error=OK;
|
||||||
|
env_parallel --env _ -S server echo \${not_copied_array[@]} ::: error=OK;
|
||||||
|
|
||||||
echo myvar >> ~/.parallel/ignored_vars;
|
echo myvar >> ~/.parallel/ignored_vars;
|
||||||
env_parallel --env _ myfunc ::: work;
|
env_parallel --env _ myfunc ::: work;
|
||||||
env_parallel --env _ -S server myfunc ::: work;
|
env_parallel --env _ -S server myfunc ::: work;
|
||||||
|
@ -336,6 +353,10 @@ par_zsh_underscore() {
|
||||||
|
|
||||||
. `which env_parallel.zsh`;
|
. `which env_parallel.zsh`;
|
||||||
|
|
||||||
|
alias not_copied_alias="echo BAD"
|
||||||
|
not_copied_func() { echo BAD; };
|
||||||
|
not_copied_var=BAD
|
||||||
|
not_copied_array=(BAD BAD BAD);
|
||||||
env_parallel --record-env;
|
env_parallel --record-env;
|
||||||
alias myecho="echo \$myvar aliases in";
|
alias myecho="echo \$myvar aliases in";
|
||||||
eval `cat <<"_EOS";
|
eval `cat <<"_EOS";
|
||||||
|
@ -349,6 +370,11 @@ par_zsh_underscore() {
|
||||||
env_parallel --env _ myfunc ::: work;
|
env_parallel --env _ myfunc ::: work;
|
||||||
env_parallel --env _ -S server myfunc ::: work;
|
env_parallel --env _ -S server myfunc ::: work;
|
||||||
|
|
||||||
|
env_parallel --env _ -S server not_copied_alias ::: error=OK;
|
||||||
|
env_parallel --env _ -S server not_copied_func ::: error=OK;
|
||||||
|
env_parallel --env _ -S server echo \$not_copied_var ::: error=OK;
|
||||||
|
env_parallel --env _ -S server echo \$\{not_copied_array\[\@\]\} ::: error=OK;
|
||||||
|
|
||||||
echo myvar >> ~/.parallel/ignored_vars;
|
echo myvar >> ~/.parallel/ignored_vars;
|
||||||
env_parallel --env _ myfunc ::: work;
|
env_parallel --env _ myfunc ::: work;
|
||||||
env_parallel --env _ -S server myfunc ::: work;
|
env_parallel --env _ -S server myfunc ::: work;
|
||||||
|
@ -377,6 +403,10 @@ par_ksh_underscore() {
|
||||||
myscript=$(cat <<'_EOF'
|
myscript=$(cat <<'_EOF'
|
||||||
echo "### Testing of --env _"
|
echo "### Testing of --env _"
|
||||||
|
|
||||||
|
alias not_copied_alias="echo BAD"
|
||||||
|
not_copied_func() { echo BAD; };
|
||||||
|
not_copied_var=BAD
|
||||||
|
not_copied_array=(BAD BAD BAD);
|
||||||
. `which env_parallel.ksh`;
|
. `which env_parallel.ksh`;
|
||||||
env_parallel --record-env;
|
env_parallel --record-env;
|
||||||
alias myecho="echo \$myvar aliases in";
|
alias myecho="echo \$myvar aliases in";
|
||||||
|
@ -390,6 +420,11 @@ par_ksh_underscore() {
|
||||||
env_parallel --env _ myfunc ::: work;
|
env_parallel --env _ myfunc ::: work;
|
||||||
env_parallel --env _ -S server myfunc ::: work;
|
env_parallel --env _ -S server myfunc ::: work;
|
||||||
|
|
||||||
|
env_parallel --env _ -S server not_copied_alias ::: error=OK;
|
||||||
|
env_parallel --env _ -S server not_copied_func ::: error=OK;
|
||||||
|
env_parallel --env _ -S server echo \$not_copied_var ::: error=OK;
|
||||||
|
env_parallel --env _ -S server echo \${not_copied_array[@]} ::: error=OK;
|
||||||
|
|
||||||
echo myvar >> ~/.parallel/ignored_vars;
|
echo myvar >> ~/.parallel/ignored_vars;
|
||||||
env_parallel --env _ myfunc ::: work;
|
env_parallel --env _ myfunc ::: work;
|
||||||
env_parallel --env _ -S server myfunc ::: work;
|
env_parallel --env _ -S server myfunc ::: work;
|
||||||
|
@ -416,6 +451,10 @@ _disabled_pdksh_underscore() {
|
||||||
myscript=$(cat <<'_EOF'
|
myscript=$(cat <<'_EOF'
|
||||||
echo "### Testing of --env _"
|
echo "### Testing of --env _"
|
||||||
|
|
||||||
|
alias not_copied_alias="echo BAD"
|
||||||
|
not_copied_func() { echo BAD; };
|
||||||
|
not_copied_var=BAD
|
||||||
|
not_copied_array=(BAD BAD BAD);
|
||||||
. `which env_parallel.pdksh`;
|
. `which env_parallel.pdksh`;
|
||||||
env_parallel --record-env;
|
env_parallel --record-env;
|
||||||
alias myecho="echo \$myvar aliases in";
|
alias myecho="echo \$myvar aliases in";
|
||||||
|
@ -429,6 +468,11 @@ _disabled_pdksh_underscore() {
|
||||||
env_parallel --env _ myfunc ::: work;
|
env_parallel --env _ myfunc ::: work;
|
||||||
env_parallel --env _ -S server myfunc ::: work;
|
env_parallel --env _ -S server myfunc ::: work;
|
||||||
|
|
||||||
|
env_parallel --env _ -S server not_copied_alias ::: error=OK;
|
||||||
|
env_parallel --env _ -S server not_copied_func ::: error=OK;
|
||||||
|
env_parallel --env _ -S server echo \$not_copied_var ::: error=OK;
|
||||||
|
env_parallel --env _ -S server echo \${not_copied_array[@]} ::: error=OK;
|
||||||
|
|
||||||
echo myvar >> ~/.parallel/ignored_vars;
|
echo myvar >> ~/.parallel/ignored_vars;
|
||||||
env_parallel --env _ myfunc ::: work;
|
env_parallel --env _ myfunc ::: work;
|
||||||
env_parallel --env _ -S server myfunc ::: work;
|
env_parallel --env _ -S server myfunc ::: work;
|
||||||
|
@ -526,6 +570,13 @@ par_fish_underscore() {
|
||||||
echo "### Testing of --env _"
|
echo "### Testing of --env _"
|
||||||
|
|
||||||
# . `which env_parallel.fish`;
|
# . `which env_parallel.fish`;
|
||||||
|
|
||||||
|
alias not_copied_alias="echo BAD"
|
||||||
|
function not_copied_func
|
||||||
|
echo BAD
|
||||||
|
end
|
||||||
|
set not_copied_var "BAD";
|
||||||
|
set not_copied_array BAD BAD BAD;
|
||||||
env_parallel --record-env;
|
env_parallel --record-env;
|
||||||
alias myecho="echo \$myvar aliases";
|
alias myecho="echo \$myvar aliases";
|
||||||
function myfunc
|
function myfunc
|
||||||
|
@ -540,6 +591,11 @@ par_fish_underscore() {
|
||||||
env_parallel --env _ myfunc ::: work;
|
env_parallel --env _ myfunc ::: work;
|
||||||
env_parallel --env _ -S server myfunc ::: work;
|
env_parallel --env _ -S server myfunc ::: work;
|
||||||
|
|
||||||
|
env_parallel --env _ -S server not_copied_alias ::: error=OK;
|
||||||
|
env_parallel --env _ -S server not_copied_func ::: error=OK;
|
||||||
|
env_parallel --env _ -S server echo \$not_copied_var ::: error=OK;
|
||||||
|
env_parallel --env _ -S server echo \$not_copied_array ::: error=OK;
|
||||||
|
|
||||||
echo myvar >> ~/.parallel/ignored_vars;
|
echo myvar >> ~/.parallel/ignored_vars;
|
||||||
env_parallel --env _ myfunc ::: work;
|
env_parallel --env _ myfunc ::: work;
|
||||||
env_parallel --env _ -S server myfunc ::: work;
|
env_parallel --env _ -S server myfunc ::: work;
|
||||||
|
|
|
@ -61,17 +61,21 @@ par_bash_underscore variables in aliases in and arrays in functions work
|
||||||
par_bash_underscore variables in aliases in and arrays in functions work
|
par_bash_underscore variables in aliases in and arrays in functions work
|
||||||
par_bash_underscore variables in aliases in and arrays in functions work
|
par_bash_underscore variables in aliases in and arrays in functions work
|
||||||
par_bash_underscore variables in aliases in and arrays in functions work
|
par_bash_underscore variables in aliases in and arrays in functions work
|
||||||
|
par_bash_underscore /bin/bash: line 57: not_copied_alias: command not found
|
||||||
|
par_bash_underscore /bin/bash: line 57: not_copied_func: command not found
|
||||||
|
par_bash_underscore error=OK
|
||||||
|
par_bash_underscore error=OK
|
||||||
par_bash_underscore aliases in and arrays in functions work
|
par_bash_underscore aliases in and arrays in functions work
|
||||||
par_bash_underscore aliases in and arrays in functions work
|
par_bash_underscore aliases in and arrays in functions work
|
||||||
par_bash_underscore aliases in functions work
|
par_bash_underscore aliases in functions work
|
||||||
par_bash_underscore aliases in functions work
|
par_bash_underscore aliases in functions work
|
||||||
par_bash_underscore /bin/bash: line 71: myecho: command not found
|
par_bash_underscore /bin/bash: line 52: myecho: command not found
|
||||||
par_bash_underscore OK if no myecho ^^^^^^^^^^^^^^^^^^^^^^^^^
|
par_bash_underscore OK if no myecho ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
par_bash_underscore /bin/bash: line 71: myecho: command not found
|
par_bash_underscore /bin/bash: line 52: myecho: command not found
|
||||||
par_bash_underscore OK if no myecho ^^^^^^^^^^^^^^^^^^^^^^^^^
|
par_bash_underscore OK if no myecho ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
par_bash_underscore /bin/bash: line 69: myfunc: command not found
|
par_bash_underscore /bin/bash: line 50: myfunc: command not found
|
||||||
par_bash_underscore OK if no myfunc ^^^^^^^^^^^^^^^^^^^^^^^^^
|
par_bash_underscore OK if no myfunc ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
par_bash_underscore /bin/bash: line 69: myfunc: command not found
|
par_bash_underscore /bin/bash: line 50: myfunc: command not found
|
||||||
par_bash_underscore OK if no myfunc ^^^^^^^^^^^^^^^^^^^^^^^^^
|
par_bash_underscore OK if no myfunc ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
par_csh_funky 3 arg alias_works
|
par_csh_funky 3 arg alias_works
|
||||||
par_csh_funky myvar works
|
par_csh_funky myvar works
|
||||||
|
@ -237,6 +241,14 @@ par_fish_underscore variables in aliases and arrays in functions work
|
||||||
par_fish_underscore variables in aliases and arrays in functions work
|
par_fish_underscore variables in aliases and arrays in functions work
|
||||||
par_fish_underscore variables in aliases and arrays in functions work
|
par_fish_underscore variables in aliases and arrays in functions work
|
||||||
par_fish_underscore variables in aliases and arrays in functions work
|
par_fish_underscore variables in aliases and arrays in functions work
|
||||||
|
par_fish_underscore fish: Unknown command 'not_copied_alias error=OK'
|
||||||
|
par_fish_underscore fish: not_copied_alias error\=OK
|
||||||
|
par_fish_underscore ^
|
||||||
|
par_fish_underscore fish: Unknown command 'not_copied_func error=OK'
|
||||||
|
par_fish_underscore fish: not_copied_func error\=OK
|
||||||
|
par_fish_underscore ^
|
||||||
|
par_fish_underscore error=OK
|
||||||
|
par_fish_underscore error=OK
|
||||||
par_fish_underscore aliases and arrays in functions work
|
par_fish_underscore aliases and arrays in functions work
|
||||||
par_fish_underscore aliases and arrays in functions work
|
par_fish_underscore aliases and arrays in functions work
|
||||||
par_fish_underscore aliases functions work
|
par_fish_underscore aliases functions work
|
||||||
|
@ -319,17 +331,21 @@ par_ksh_underscore variables in aliases in and arrays in functions work
|
||||||
par_ksh_underscore variables in aliases in and arrays in functions work
|
par_ksh_underscore variables in aliases in and arrays in functions work
|
||||||
par_ksh_underscore variables in aliases in and arrays in functions work
|
par_ksh_underscore variables in aliases in and arrays in functions work
|
||||||
par_ksh_underscore variables in aliases in and arrays in functions work
|
par_ksh_underscore variables in aliases in and arrays in functions work
|
||||||
|
par_ksh_underscore /usr/bin/ksh: line 8: not_copied_alias: not found
|
||||||
|
par_ksh_underscore /usr/bin/ksh: line 8: not_copied_func: not found
|
||||||
|
par_ksh_underscore error=OK
|
||||||
|
par_ksh_underscore error=OK
|
||||||
par_ksh_underscore aliases in and arrays in functions work
|
par_ksh_underscore aliases in and arrays in functions work
|
||||||
par_ksh_underscore aliases in and arrays in functions work
|
par_ksh_underscore aliases in and arrays in functions work
|
||||||
par_ksh_underscore aliases in functions work
|
par_ksh_underscore aliases in functions work
|
||||||
par_ksh_underscore aliases in functions work
|
par_ksh_underscore aliases in functions work
|
||||||
par_ksh_underscore /usr/bin/ksh[114]: myecho: not found [No such file or directory]
|
par_ksh_underscore /usr/bin/ksh[4]: myecho: not found [No such file or directory]
|
||||||
par_ksh_underscore OK if no myecho ^^^^^^^^^^^^^^^^^
|
par_ksh_underscore OK if no myecho ^^^^^^^^^^^^^^^^^
|
||||||
par_ksh_underscore /usr/bin/ksh[114]: myecho: not found [No such file or directory]
|
par_ksh_underscore /usr/bin/ksh[4]: myecho: not found [No such file or directory]
|
||||||
par_ksh_underscore OK if no myecho ^^^^^^^^^^^^^^^^^
|
par_ksh_underscore OK if no myecho ^^^^^^^^^^^^^^^^^
|
||||||
par_ksh_underscore /usr/bin/ksh: line 114: myfunc: not found
|
par_ksh_underscore /usr/bin/ksh: line 4: myfunc: not found
|
||||||
par_ksh_underscore OK if no myfunc ^^^^^^^^^^^^^^^^^
|
par_ksh_underscore OK if no myfunc ^^^^^^^^^^^^^^^^^
|
||||||
par_ksh_underscore /usr/bin/ksh: line 114: myfunc: not found
|
par_ksh_underscore /usr/bin/ksh: line 4: myfunc: not found
|
||||||
par_ksh_underscore OK if no myfunc ^^^^^^^^^^^^^^^^^
|
par_ksh_underscore OK if no myfunc ^^^^^^^^^^^^^^^^^
|
||||||
par_tcsh_funky
|
par_tcsh_funky
|
||||||
par_tcsh_funky
|
par_tcsh_funky
|
||||||
|
@ -484,6 +500,10 @@ par_zsh_underscore variables in aliases in and arrays in functions work
|
||||||
par_zsh_underscore variables in aliases in and arrays in functions work
|
par_zsh_underscore variables in aliases in and arrays in functions work
|
||||||
par_zsh_underscore variables in aliases in and arrays in functions work
|
par_zsh_underscore variables in aliases in and arrays in functions work
|
||||||
par_zsh_underscore variables in aliases in and arrays in functions work
|
par_zsh_underscore variables in aliases in and arrays in functions work
|
||||||
|
par_zsh_underscore (eval):1: command not found: not_copied_alias
|
||||||
|
par_zsh_underscore (eval):1: command not found: not_copied_func
|
||||||
|
par_zsh_underscore BAD error=OK
|
||||||
|
par_zsh_underscore error=OK
|
||||||
par_zsh_underscore aliases in and arrays in functions work
|
par_zsh_underscore aliases in and arrays in functions work
|
||||||
par_zsh_underscore aliases in and arrays in functions work
|
par_zsh_underscore aliases in and arrays in functions work
|
||||||
par_zsh_underscore aliases in functions work
|
par_zsh_underscore aliases in functions work
|
||||||
|
|
Loading…
Reference in a new issue