mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-11-22 14:07:55 +00:00
env_parallel.tcsh: --env _ works.
This commit is contained in:
parent
402d3960d4
commit
1cb786c62e
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -108,6 +108,68 @@ _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'
|
||||
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue