env_parallel.tcsh: --env _ works.

This commit is contained in:
Ole Tange 2016-07-10 22:57:33 +02:00
parent 402d3960d4
commit 1cb786c62e
4 changed files with 362 additions and 211 deletions

View file

@ -202,27 +202,35 @@ E.g. by doing:
=item aliases
alias myecho=echo
env_parallel myecho ::: test
env_parallel -S server myecho ::: test
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
=item functions
myfunc() { echo $*; }
env_parallel myfunc ::: test
env_parallel -S server myfunc ::: test
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
=item variables
myvar=test
env_parallel echo '$myvar' ::: test
env_parallel -S server echo '$myvar' ::: test
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
=item arrays
myarray=(foo bar baz)
env_parallel echo '${myarray[{}]}' ::: 0 1 2
env_parallel -S server echo '${myarray[{}]}' ::: 0 1 2
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
=back
@ -327,9 +335,11 @@ E.g. by doing:
=item aliases
alias myecho echo
env_parallel myecho ::: test
env_parallel -S server myecho ::: test
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
=item functions
@ -337,16 +347,19 @@ Not supported by B<tcsh>.
=item variables
set myvar=test
env_parallel echo "\$myvar" ::: test
env_parallel -S tcsh@server echo "\$myvar" ::: test
set 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
=item arrays with no special chars
set myarray=(foo bar baz)
env_parallel echo "\${myarray\[\{\}\]}" ::: 1 2 3
env_parallel -S tcsh@server echo "\${myarray\[\{\}\]}" ::: 1 2 3
set myarray=(arrays work, too)
env_parallel -k echo \$'{myarray[{}]}' ::: 1 2 3
env_parallel -k -S server echo \$'{myarray[{}]}' ::: 1 2 3
env_parallel -k --env myarray echo \$'{myarray[{}]}' ::: 1 2 3
env_parallel -k --env myarray -S server echo \$'{myarray[{}]}' ::: 1 2 3
=back

View file

@ -29,8 +29,44 @@ if ("`alias env_parallel`" == '') then
# Activate alias
alias env_parallel 'setenv PARALLEL "\!*"; source `which env_parallel.tcsh`'
else
# Get the --env variables if set
# --env _ should be ignored
# and convert a b c to (a|b|c)
# If --env not set: Match everything (.*)
set _tMpscRIpt=`tempfile`
cat <<'EOF' > $_tMpscRIpt
for(@ARGV){
/^_$/ and $next_is_env = 0;
$next_is_env and push @envvar, split/,/, $_;
$next_is_env = /^--env$/;
}
$vars = join "|",map { quotemeta $_ } @envvar;
print $vars ? "($vars)" : "(.*)";
'EOF'
set _grep_REGEXP="`perl $_tMpscRIpt -- !*`"
# Deal with --env _
cat <<'EOF' > $_tMpscRIpt
#!/usr/bin/perl
for(@ARGV){
$next_is_env and push @envvar, split/,/, $_;
$next_is_env=/^--env$/;
}
if(grep { /^_$/ } @envvar) {
if(not open(IN, "<", "$ENV{HOME}/.parallel/ignored_vars")) {
print STDERR "parallel: Error: ",
"Run 'parallel --record-env' in a clean environment first.\n";
} else {
chomp(@ignored_vars = <IN>);
$vars = join "|",map { quotemeta $_ } @ignored_vars;
print $vars ? "($vars)" : "(nOVaRs)";
}
}
'EOF'
set _ignore_UNDERSCORE="`perl $_tMpscRIpt -- !*`"
rm $_tMpscRIpt
# Get the scalar and array variable names
set _vARnAmES=(`set | awk -e '{print $1}' |grep -vE '^(_|killring|prompt2)$'`)
set _vARnAmES=(`set | awk -e '{print $1}' |grep -vE '^(_|killring|prompt2|command)$' | grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$`)
# Make a tmpfile for the variable definitions
set _tMpvARfILe=`tempfile`
@ -38,18 +74,20 @@ else
# Make a tmpfile for the variable definitions + alias
set _tMpaLLfILe=`tempfile`
foreach _vARnAmE ($_vARnAmES);
# if $?myvar && $#myvar <= 1 echo scalar_myvar=$var
eval if'($?'$_vARnAmE' && ${#'$_vARnAmE'} <= 1) echo scalar_'$_vARnAmE'='\"\$$_vARnAmE\" >> $_tMpvARfILe;
# if $?myvar && $#myvar > 1 echo array_myvar=$var
eval if'($?'$_vARnAmE' && ${#'$_vARnAmE'} > 1) echo array_'$_vARnAmE'="$'$_vARnAmE'"' >> $_tMpvARfILe;
# if not defined: next
eval if'(! $?'$_vARnAmE') continue'
# if $#myvar <= 1 echo scalar_myvar=$var
eval if'(${#'$_vARnAmE'} <= 1) echo scalar_'$_vARnAmE'='\"\$$_vARnAmE\" >> $_tMpvARfILe;
# if $#myvar > 1 echo array_myvar=$var
eval if'(${#'$_vARnAmE'} > 1) echo array_'$_vARnAmE'="$'$_vARnAmE'"' >> $_tMpvARfILe;
end
unset _vARnAmE _vARnAmES
# shell quote variables (--plain needed due to $PARALLEL abuse)
# Convert 'scalar_myvar=...' to 'set myvar=...'
# Convert 'array_myvar=...' to 'set array=(...)'
cat $_tMpvARfILe | parallel --plain --shellquote | perl -pe 's/^scalar_(\S+).=/set $1=/ or s/^array_(\S+).=(.*)/set $1=($2)/ && s/\\ / /g;' > $_tMpaLLfILe
# Cleanup
rm $_tMpvARfILe; unset _tMpvARfILe _vARnAmE _vARnAmES
rm $_tMpvARfILe; unset _tMpvARfILe
# ALIAS TO EXPORT ALIASES:
@ -76,7 +114,10 @@ else
# Prepend with "\nalias "
# s/^/\001alias /;
# Quoted: s/\^/\\001alias\ /\;
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 >> $_tMpaLLfILe
alias | \
grep -E "^$_grep_REGEXP" | \
grep -vE "^$_ignore_UNDERSCORE""[^_a-zA-Z]" | \
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 >> $_tMpaLLfILe
setenv PARALLEL_ENV "`cat $_tMpaLLfILe; rm $_tMpaLLfILe`";
unset _tMpaLLfILe;

View file

@ -9,30 +9,30 @@ par_bash_man() {
myscript=$(cat <<'_EOF'
echo "### From man env_parallel"
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
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
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
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
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
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
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
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
_EOF
)
ssh bash@lo "$myscript"
@ -42,30 +42,30 @@ par_zsh_man() {
echo '### zsh'
myscript=$(cat <<'_EOF'
echo "### From man env_parallel"
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
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
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
myarray=(arrays work, too);
env_parallel -k echo "\${myarray[{}]}" ::: 1 2 3;
env_parallel -k -S server echo "\${myarray[{}]}" ::: 1 2 3;
env_parallel -k --env myarray echo "\${myarray[{}]}" ::: 1 2 3;
env_parallel -k --env myarray -S server echo "\${myarray[{}]}" ::: 1 2 3
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
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
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
myarray=(arrays work, too);
env_parallel -k echo "\${myarray[{}]}" ::: 1 2 3;
env_parallel -k -S server echo "\${myarray[{}]}" ::: 1 2 3;
env_parallel -k --env myarray echo "\${myarray[{}]}" ::: 1 2 3;
env_parallel -k --env myarray -S server echo "\${myarray[{}]}" ::: 1 2 3
_EOF
)
ssh zsh@lo "$myscript"
@ -75,72 +75,134 @@ par_ksh_man() {
echo '### ksh'
myscript=$(cat <<'_EOF'
echo "### From man env_parallel"
. `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
. `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
. `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
. `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
. `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
. `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
. `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
. `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
_EOF
)
ssh ksh@lo "$myscript"
}
par_tcsh_man() {
echo '### tcsh'
myscript=$(cat <<'_EOF'
echo "### From man env_parallel"
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
echo Functions not supported
set 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
set myarray=(arrays work, too)
env_parallel -k echo \$'{myarray[{}]}' ::: 1 2 3
env_parallel -k -S server echo \$'{myarray[{}]}' ::: 1 2 3
env_parallel -k --env myarray echo \$'{myarray[{}]}' ::: 1 2 3
env_parallel -k --env myarray -S server echo \$'{myarray[{}]}' ::: 1 2 3
_EOF
)
ssh -tt tcsh@lo "$myscript"
}
par_csh_man() {
echo '### csh'
myscript=$(cat <<'_EOF'
echo "### From man env_parallel"
source `which env_parallel.csh`;
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
# Functions not supported
set 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
set myarray=(arrays work, too)
env_parallel -k echo \$'{myarray[{}]}' ::: 1 2 3
env_parallel -k -S server echo \$'{myarray[{}]}' ::: 1 2 3
#env_parallel -k --env myarray echo \$'{myarray[{}]}' ::: 1 2 3
#env_parallel -k --env myarray -S server echo \$'{myarray[{}]}' ::: 1 2 3
_EOF
)
ssh csh@lo "$myscript"
}
par_bash_underscore() {
echo '### bash'
myscript=$(cat <<'_EOF'
echo "### Testing of --env _"
env_parallel --record-env;
alias myecho="echo \$myvar aliases in";
myfunc() { myecho ${myarray[@]} functions $*; };
myvar="variables in";
myarray=(and arrays in);
env_parallel myfunc ::: work;
env_parallel -S server myfunc ::: work;
env_parallel --env myfunc,myvar,myarray,myecho myfunc ::: work;
env_parallel --env myfunc,myvar,myarray,myecho -S server myfunc ::: work;
env_parallel --env _ myfunc ::: work;
env_parallel --env _ -S server myfunc ::: work;
echo myvar >> ~/.parallel/ignored_vars;
env_parallel --env _ myfunc ::: work;
env_parallel --env _ -S server myfunc ::: work;
echo myarray >> ~/.parallel/ignored_vars;
env_parallel --env _ myfunc ::: work;
env_parallel --env _ -S server myfunc ::: work;
echo myecho >> ~/.parallel/ignored_vars;
env_parallel --env _ myfunc ::: work;
echo "OK if no myecho ^^^^^^^^^^^^^^^^^^^^^^^^^" >&2;
env_parallel --env _ -S server myfunc ::: work;
echo "OK if no myecho ^^^^^^^^^^^^^^^^^^^^^^^^^" >&2;
echo myfunc >> ~/.parallel/ignored_vars;
env_parallel --env _ myfunc ::: work;
echo "OK if no myfunc ^^^^^^^^^^^^^^^^^^^^^^^^^" >&2;
env_parallel --env _ -S server myfunc ::: work;
echo "OK if no myfunc ^^^^^^^^^^^^^^^^^^^^^^^^^" >&2;
env_parallel --record-env;
alias myecho="echo \$myvar aliases in";
myfunc() { myecho ${myarray[@]} functions $*; };
myvar="variables in";
myarray=(and arrays in);
env_parallel myfunc ::: work;
env_parallel -S server myfunc ::: work;
env_parallel --env myfunc,myvar,myarray,myecho myfunc ::: work;
env_parallel --env myfunc,myvar,myarray,myecho -S server myfunc ::: work;
env_parallel --env _ myfunc ::: work;
env_parallel --env _ -S server myfunc ::: work;
echo myvar >> ~/.parallel/ignored_vars;
env_parallel --env _ myfunc ::: work;
env_parallel --env _ -S server myfunc ::: work;
echo myarray >> ~/.parallel/ignored_vars;
env_parallel --env _ myfunc ::: work;
env_parallel --env _ -S server myfunc ::: work;
echo myecho >> ~/.parallel/ignored_vars;
env_parallel --env _ myfunc ::: work;
echo "OK if no myecho ^^^^^^^^^^^^^^^^^^^^^^^^^" >&2;
env_parallel --env _ -S server myfunc ::: work;
echo "OK if no myecho ^^^^^^^^^^^^^^^^^^^^^^^^^" >&2;
echo myfunc >> ~/.parallel/ignored_vars;
env_parallel --env _ myfunc ::: work;
echo "OK if no myfunc ^^^^^^^^^^^^^^^^^^^^^^^^^" >&2;
env_parallel --env _ -S server myfunc ::: work;
echo "OK if no myfunc ^^^^^^^^^^^^^^^^^^^^^^^^^" >&2;
_EOF
)
ssh bash@lo "$myscript"
@ -150,39 +212,39 @@ par_zsh_underscore() {
echo '### zsh'
myscript=$(cat <<'_EOF'
echo "### Testing of --env _"
. `which env_parallel.zsh`;
env_parallel --record-env;
alias myecho="echo \$myvar aliases in";
eval `cat <<"_EOS";
myfunc() { myecho ${myarray[@]} functions $*; };
myvar="variables in";
myarray=(and arrays in);
env_parallel myfunc ::: work;
env_parallel -S server myfunc ::: work;
env_parallel --env myfunc,myvar,myarray,myecho myfunc ::: work;
env_parallel --env myfunc,myvar,myarray,myecho -S server myfunc ::: work;
env_parallel --env _ myfunc ::: work;
env_parallel --env _ -S server myfunc ::: work;
echo myvar >> ~/.parallel/ignored_vars;
env_parallel --env _ myfunc ::: work;
env_parallel --env _ -S server myfunc ::: work;
echo myarray >> ~/.parallel/ignored_vars;
env_parallel --env _ myfunc ::: work;
env_parallel --env _ -S server myfunc ::: work;
echo myecho >> ~/.parallel/ignored_vars;
: Not using the function, because aliases are expanded in functions;
env_parallel --env _ myecho ::: work;
echo OK if no .^^^^^^^^^^^^^^^^^^^^^^^^^ myecho >&2;
env_parallel --env _ -S server myecho ::: work;
echo OK if no .^^^^^^^^^^^^^^^^^^^^^^^^^ myecho >&2;
echo myfunc >> ~/.parallel/ignored_vars;
env_parallel --env _ myfunc ::: work;
echo OK if no .^^^^^^^^^^^^^^^^^^^^^^^^^ myfunc >&2;
env_parallel --env _ -S server myfunc ::: work;
echo OK if no .^^^^^^^^^^^^^^^^^^^^^^^^^ myfunc >&2;
_EOS`
. `which env_parallel.zsh`;
env_parallel --record-env;
alias myecho="echo \$myvar aliases in";
eval `cat <<"_EOS";
myfunc() { myecho ${myarray[@]} functions $*; };
myvar="variables in";
myarray=(and arrays in);
env_parallel myfunc ::: work;
env_parallel -S server myfunc ::: work;
env_parallel --env myfunc,myvar,myarray,myecho myfunc ::: work;
env_parallel --env myfunc,myvar,myarray,myecho -S server myfunc ::: work;
env_parallel --env _ myfunc ::: work;
env_parallel --env _ -S server myfunc ::: work;
echo myvar >> ~/.parallel/ignored_vars;
env_parallel --env _ myfunc ::: work;
env_parallel --env _ -S server myfunc ::: work;
echo myarray >> ~/.parallel/ignored_vars;
env_parallel --env _ myfunc ::: work;
env_parallel --env _ -S server myfunc ::: work;
echo myecho >> ~/.parallel/ignored_vars;
: Not using the function, because aliases are expanded in functions;
env_parallel --env _ myecho ::: work;
echo OK if no .^^^^^^^^^^^^^^^^^^^^^^^^^ myecho >&2;
env_parallel --env _ -S server myecho ::: work;
echo OK if no .^^^^^^^^^^^^^^^^^^^^^^^^^ myecho >&2;
echo myfunc >> ~/.parallel/ignored_vars;
env_parallel --env _ myfunc ::: work;
echo OK if no .^^^^^^^^^^^^^^^^^^^^^^^^^ myfunc >&2;
env_parallel --env _ -S server myfunc ::: work;
echo OK if no .^^^^^^^^^^^^^^^^^^^^^^^^^ myfunc >&2;
_EOS`
_EOF
)
ssh zsh@lo "$myscript"
@ -192,36 +254,36 @@ par_ksh_underscore() {
echo '### ksh'
myscript=$(cat <<'_EOF'
echo "### Testing of --env _"
. `which env_parallel.ksh`;
env_parallel --record-env;
alias myecho="echo \$myvar aliases in";
myfunc() { myecho ${myarray[@]} functions $*; };
myvar="variables in";
myarray=(and arrays in);
env_parallel myfunc ::: work;
env_parallel -S server myfunc ::: work;
env_parallel --env myfunc,myvar,myarray,myecho myfunc ::: work;
env_parallel --env myfunc,myvar,myarray,myecho -S server myfunc ::: work;
env_parallel --env _ myfunc ::: work;
env_parallel --env _ -S server myfunc ::: work;
echo myvar >> ~/.parallel/ignored_vars;
env_parallel --env _ myfunc ::: work;
env_parallel --env _ -S server myfunc ::: work;
echo myarray >> ~/.parallel/ignored_vars;
env_parallel --env _ myfunc ::: work;
env_parallel --env _ -S server myfunc ::: work;
echo myecho >> ~/.parallel/ignored_vars;
env_parallel --env _ myfunc ::: work;
echo "OK if no myecho ^^^^^^^^^^^^^^^^^" >&2;
env_parallel --env _ -S server myfunc ::: work;
echo "OK if no myecho ^^^^^^^^^^^^^^^^^" >&2;
echo myfunc >> ~/.parallel/ignored_vars;
env_parallel --env _ myfunc ::: work;
echo "OK if no myfunc ^^^^^^^^^^^^^^^^^" >&2;
env_parallel --env _ -S server myfunc ::: work;
echo "OK if no myfunc ^^^^^^^^^^^^^^^^^" >&2;
. `which env_parallel.ksh`;
env_parallel --record-env;
alias myecho="echo \$myvar aliases in";
myfunc() { myecho ${myarray[@]} functions $*; };
myvar="variables in";
myarray=(and arrays in);
env_parallel myfunc ::: work;
env_parallel -S server myfunc ::: work;
env_parallel --env myfunc,myvar,myarray,myecho myfunc ::: work;
env_parallel --env myfunc,myvar,myarray,myecho -S server myfunc ::: work;
env_parallel --env _ myfunc ::: work;
env_parallel --env _ -S server myfunc ::: work;
echo myvar >> ~/.parallel/ignored_vars;
env_parallel --env _ myfunc ::: work;
env_parallel --env _ -S server myfunc ::: work;
echo myarray >> ~/.parallel/ignored_vars;
env_parallel --env _ myfunc ::: work;
env_parallel --env _ -S server myfunc ::: work;
echo myecho >> ~/.parallel/ignored_vars;
env_parallel --env _ myfunc ::: work;
echo "OK if no myecho ^^^^^^^^^^^^^^^^^" >&2;
env_parallel --env _ -S server myfunc ::: work;
echo "OK if no myecho ^^^^^^^^^^^^^^^^^" >&2;
echo myfunc >> ~/.parallel/ignored_vars;
env_parallel --env _ myfunc ::: work;
echo "OK if no myfunc ^^^^^^^^^^^^^^^^^" >&2;
env_parallel --env _ -S server myfunc ::: work;
echo "OK if no myfunc ^^^^^^^^^^^^^^^^^" >&2;
_EOF
)
ssh ksh@lo "$myscript"
@ -276,7 +338,6 @@ par_zsh_funky() {
echo ${assocarr[a]}
echo Funky-"$funky"-funky
}
env_parallel alias_echo ::: alias_works
env_parallel func_echo ::: function_works
env_parallel -S zsh@lo alias_echo ::: alias_works_over_ssh
@ -290,8 +351,8 @@ _EOF
par_ksh_funky() {
myscript=$(cat <<'_EOF'
. `which env_parallel.ksh`;
. `which env_parallel.ksh`;
myvar="myvar works"
funky=$(perl -e "print pack \"c*\", 1..255")
myarray=("" array_val2 3 "" 5 " space 6 ")
@ -299,7 +360,7 @@ par_ksh_funky() {
assocarr[a]=assoc_val_a
assocarr[b]=assoc_val_b
alias alias_echo="echo 3 arg";
func_echo() {
echo $*;
echo "$myvar"
@ -307,7 +368,7 @@ par_ksh_funky() {
echo ${assocarr[a]}
echo Funky-"$funky"-funky
}
env_parallel alias_echo ::: alias_works
env_parallel func_echo ::: function_works
env_parallel -S ksh@lo alias_echo ::: alias_works_over_ssh
@ -323,18 +384,18 @@ par_fish_funky() {
myscript=$(cat <<'_EOF'
set myvar "myvar works"
setenv myenvvar "myenvvar works"
set funky (perl -e "print pack \"c*\", 1..255")
setenv funkyenv (perl -e "print pack \"c*\", 1..255")
set myarray "" array_val2 3 "" 5 " space 6 "
# Assoc arrays do not exist
#typeset -A assocarr
#assocarr[a]=assoc_val_a
#assocarr[b]=assoc_val_b
alias alias_echo="echo 3 arg";
function func_echo
echo $argv;
echo "$myvar"
@ -351,12 +412,12 @@ par_fish_funky() {
echo
echo
end
env_parallel alias_echo ::: alias_works
env_parallel func_echo ::: function_works
env_parallel -S fish@lo alias_echo ::: alias_works_over_ssh
env_parallel -S fish@lo func_echo ::: function_works_over_ssh
echo
echo
echo "$funky" | parallel --shellquote
_EOF
)
@ -373,7 +434,7 @@ par_csh_funky() {
#assocarr[b]=assoc_val_b
alias alias_echo echo 3 arg;
alias alias_echo_var 'echo $argv; echo "$myvar"; echo "${myarray[4]} special chars problem"; echo Funky-"$funky"-funky'
#function func_echo
# echo $argv;
# echo $myvar;
@ -381,7 +442,7 @@ par_csh_funky() {
# #echo ${assocarr[a]}
# echo Funky-"$funky"-funky
#end
env_parallel alias_echo ::: alias_works
env_parallel alias_echo_var ::: alias_var_works
env_parallel func_echo ::: function_does_not_work

View file

@ -81,6 +81,18 @@ par_csh_funky space special chars problem
par_csh_funky Funky-  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€亗儎厗噲墛媽崕彁憭摂晼棙櫄洔潪煚、¥ウЖ┆<D096><E29486><EFBFBD>辈炒刀犯购患骄坷谅媚牌侨墒颂臀闲岩釉罩棕仝圮蒉哙徕沅彐玷殛腱眍镳耱篝貊鼬<E8B28A><E9BCAC><EFBFBD><EFBFBD>-funky alias_var_works_over_ssh
par_csh_funky func_echo: Command not found.
par_csh_funky \\\\\\\\ \ \ \ \ \\\\\\\\\\\\\\ \!\"\#\$%\&\'\(\)\*+,-./0123456789:\;\<\=\>\?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\[\\\]\^_\`abcdefghijklmnopqrstuvwxyz\{\|\}\~€乗俓僜刓匼哱嘰圽塡奬媆孿峔嶾廫怽慭抃揬擻昞朶梊榎橽歕沑淺漒瀄焅燶<E78485><E787B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>猏玕琝璡甛痋癨盶瞈砛碶礬禱穃竆筡篭籠糪絓綷縗繺羂耚肻腬臷芢荺萛蒤蔦薥蘚蚛蝄蟎衆裓襖覾診誠謀譢豛賊赲踈躙輁轡運郳醆鈂鉢鋅錦鎈鏫鑌閈闬隲靄韁頫颸餦馶騖骪鬨鮘鯸鱘鳿鵟鶿鸤黒齖㘎<E9BD96>
par_csh_man ### csh
par_csh_man ### From man env_parallel
par_csh_man aliases work
par_csh_man aliases work
par_csh_man variables work
par_csh_man variables work
par_csh_man arrays
par_csh_man work,
par_csh_man too
par_csh_man arrays
par_csh_man work,
par_csh_man too
par_fish_funky env_parallel: Warning: ASCII value 1 in variables is not supported
par_fish_funky env_parallel: Warning: ASCII value 1 in variables is not supported
par_fish_funky 3 arg alias_works
@ -180,6 +192,30 @@ par_ksh_underscore /usr/bin/ksh: line 100: myfunc: not found
par_ksh_underscore OK if no myfunc ^^^^^^^^^^^^^^^^^
par_ksh_underscore /usr/bin/ksh: line 100: myfunc: not found
par_ksh_underscore OK if no myfunc ^^^^^^^^^^^^^^^^^
par_tcsh_man ### tcsh
par_tcsh_man ### From man env_parallel
par_tcsh_man aliases work
par_tcsh_man aliases work
par_tcsh_man aliases work
par_tcsh_man aliases work
par_tcsh_man Functions not supported
par_tcsh_man variables work
par_tcsh_man variables work
par_tcsh_man variables work
par_tcsh_man variables work
par_tcsh_man arrays
par_tcsh_man work,
par_tcsh_man too
par_tcsh_man arrays
par_tcsh_man work,
par_tcsh_man too
par_tcsh_man arrays
par_tcsh_man work,
par_tcsh_man too
par_tcsh_man arrays
par_tcsh_man work,
par_tcsh_man too
par_tcsh_man Connection to lo closed.
par_zsh_funky 3 arg alias_works
par_zsh_funky function_works
par_zsh_funky myvar works