mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-11-22 14:07:55 +00:00
env_parallel: Support $PARALLEL in (t)csh.
This commit is contained in:
parent
8700e957fc
commit
3cdfcc1926
|
@ -26,9 +26,9 @@
|
||||||
# Fifth Floor, Boston, MA 02110-1301 USA
|
# Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
set _parallel_exit_CODE=0
|
set _parallel_exit_CODE=0
|
||||||
if ("`alias env_parallel`" == '' || ! $?PARALLEL) then
|
if ("`alias env_parallel`" == '' || ! $?PARALLEL_CSH) then
|
||||||
# Activate alias
|
# Activate alias
|
||||||
alias env_parallel '(setenv PARALLEL "\!*"; source `which env_parallel.csh`)'
|
alias env_parallel '(setenv PARALLEL_CSH "\!*"; source `which env_parallel.csh`)'
|
||||||
else
|
else
|
||||||
# Get the --env variables if set
|
# Get the --env variables if set
|
||||||
# --env _ should be ignored
|
# --env _ should be ignored
|
||||||
|
@ -50,7 +50,7 @@ else
|
||||||
$vars = join "|",map { quotemeta $_ } @envvar;
|
$vars = join "|",map { quotemeta $_ } @envvar;
|
||||||
print $vars ? "($vars)" : "(.*)";
|
print $vars ? "($vars)" : "(.*)";
|
||||||
'EOF'
|
'EOF'
|
||||||
set _grep_REGEXP="`perl $_tMpscRIpt -- $PARALLEL`"
|
set _grep_REGEXP="`perl $_tMpscRIpt -- $PARALLEL_CSH`"
|
||||||
|
|
||||||
# Deal with --env _
|
# Deal with --env _
|
||||||
cat <<'EOF' > $_tMpscRIpt
|
cat <<'EOF' > $_tMpscRIpt
|
||||||
|
@ -71,7 +71,7 @@ else
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'EOF'
|
'EOF'
|
||||||
set _ignore_UNDERSCORE="`perl $_tMpscRIpt -- $PARALLEL`"
|
set _ignore_UNDERSCORE="`perl $_tMpscRIpt -- $PARALLEL_CSH`"
|
||||||
rm $_tMpscRIpt
|
rm $_tMpscRIpt
|
||||||
|
|
||||||
# Get the scalar and array variable names
|
# Get the scalar and array variable names
|
||||||
|
@ -92,7 +92,7 @@ else
|
||||||
eval if'(${#'$_vARnAmE'} > 1) echo array_'$_vARnAmE'="$'$_vARnAmE'"' >> $_tMpvARfILe;
|
eval if'(${#'$_vARnAmE'} > 1) echo array_'$_vARnAmE'="$'$_vARnAmE'"' >> $_tMpvARfILe;
|
||||||
end
|
end
|
||||||
unset _vARnAmE _vARnAmES
|
unset _vARnAmE _vARnAmES
|
||||||
# shell quote variables (--plain needed due to $PARALLEL abuse)
|
# shell quote variables (--plain needed due to ignore if $PARALLEL is set)
|
||||||
# Convert 'scalar_myvar=...' to 'set myvar=...'
|
# Convert 'scalar_myvar=...' to 'set myvar=...'
|
||||||
# Convert 'array_myvar=...' to 'set array=(...)'
|
# 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
|
cat $_tMpvARfILe | parallel --plain --shellquote | perl -pe 's/^scalar_(\S+).=/set $1=/ or s/^array_(\S+).=(.*)/set $1=($2)/ && s/\\ / /g;' > $_tMpaLLfILe
|
||||||
|
@ -130,10 +130,10 @@ else
|
||||||
|
|
||||||
setenv PARALLEL_ENV "`cat $_tMpaLLfILe; rm $_tMpaLLfILe`";
|
setenv PARALLEL_ENV "`cat $_tMpaLLfILe; rm $_tMpaLLfILe`";
|
||||||
unset _tMpaLLfILe;
|
unset _tMpaLLfILe;
|
||||||
# Use $PARALLEL set in calling alias
|
# Use $PARALLEL_CSH set in calling alias
|
||||||
parallel
|
parallel
|
||||||
set _parallel_exit_CODE=$status
|
set _parallel_exit_CODE=$status
|
||||||
setenv PARALLEL_ENV
|
setenv PARALLEL_ENV
|
||||||
setenv PARALLEL
|
setenv PARALLEL_CSH
|
||||||
endif
|
endif
|
||||||
(exit $_parallel_exit_CODE)
|
(exit $_parallel_exit_CODE)
|
||||||
|
|
|
@ -26,9 +26,9 @@
|
||||||
# Fifth Floor, Boston, MA 02110-1301 USA
|
# Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
set _parallel_exit_CODE=0
|
set _parallel_exit_CODE=0
|
||||||
if ("`alias env_parallel`" == '' || ! $?PARALLEL) then
|
if ("`alias env_parallel`" == '' || ! $?PARALLEL_CSH) then
|
||||||
# Activate alias
|
# Activate alias
|
||||||
alias env_parallel '(setenv PARALLEL "\!*"; source `which env_parallel.tcsh`)'
|
alias env_parallel '(setenv PARALLEL_CSH "\!*"; source `which env_parallel.csh`)'
|
||||||
else
|
else
|
||||||
# Get the --env variables if set
|
# Get the --env variables if set
|
||||||
# --env _ should be ignored
|
# --env _ should be ignored
|
||||||
|
@ -50,7 +50,7 @@ else
|
||||||
$vars = join "|",map { quotemeta $_ } @envvar;
|
$vars = join "|",map { quotemeta $_ } @envvar;
|
||||||
print $vars ? "($vars)" : "(.*)";
|
print $vars ? "($vars)" : "(.*)";
|
||||||
'EOF'
|
'EOF'
|
||||||
set _grep_REGEXP="`perl $_tMpscRIpt -- $PARALLEL`"
|
set _grep_REGEXP="`perl $_tMpscRIpt -- $PARALLEL_CSH`"
|
||||||
|
|
||||||
# Deal with --env _
|
# Deal with --env _
|
||||||
cat <<'EOF' > $_tMpscRIpt
|
cat <<'EOF' > $_tMpscRIpt
|
||||||
|
@ -71,7 +71,7 @@ else
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'EOF'
|
'EOF'
|
||||||
set _ignore_UNDERSCORE="`perl $_tMpscRIpt -- $PARALLEL`"
|
set _ignore_UNDERSCORE="`perl $_tMpscRIpt -- $PARALLEL_CSH`"
|
||||||
rm $_tMpscRIpt
|
rm $_tMpscRIpt
|
||||||
|
|
||||||
# Get the scalar and array variable names
|
# Get the scalar and array variable names
|
||||||
|
@ -83,6 +83,7 @@ else
|
||||||
# Make a tmpfile for the variable definitions + alias
|
# Make a tmpfile for the variable definitions + alias
|
||||||
set _tMpaLLfILe=`_tempfile`
|
set _tMpaLLfILe=`_tempfile`
|
||||||
foreach _vARnAmE ($_vARnAmES);
|
foreach _vARnAmE ($_vARnAmES);
|
||||||
|
# These 3 lines break in csh version 20110502-3
|
||||||
# if not defined: next
|
# if not defined: next
|
||||||
eval if'(! $?'$_vARnAmE') continue'
|
eval if'(! $?'$_vARnAmE') continue'
|
||||||
# if $#myvar <= 1 echo scalar_myvar=$var
|
# if $#myvar <= 1 echo scalar_myvar=$var
|
||||||
|
@ -91,7 +92,7 @@ else
|
||||||
eval if'(${#'$_vARnAmE'} > 1) echo array_'$_vARnAmE'="$'$_vARnAmE'"' >> $_tMpvARfILe;
|
eval if'(${#'$_vARnAmE'} > 1) echo array_'$_vARnAmE'="$'$_vARnAmE'"' >> $_tMpvARfILe;
|
||||||
end
|
end
|
||||||
unset _vARnAmE _vARnAmES
|
unset _vARnAmE _vARnAmES
|
||||||
# shell quote variables (--plain needed due to $PARALLEL abuse)
|
# shell quote variables (--plain needed due to ignore if $PARALLEL is set)
|
||||||
# Convert 'scalar_myvar=...' to 'set myvar=...'
|
# Convert 'scalar_myvar=...' to 'set myvar=...'
|
||||||
# Convert 'array_myvar=...' to 'set array=(...)'
|
# 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
|
cat $_tMpvARfILe | parallel --plain --shellquote | perl -pe 's/^scalar_(\S+).=/set $1=/ or s/^array_(\S+).=(.*)/set $1=($2)/ && s/\\ / /g;' > $_tMpaLLfILe
|
||||||
|
@ -129,14 +130,10 @@ else
|
||||||
|
|
||||||
setenv PARALLEL_ENV "`cat $_tMpaLLfILe; rm $_tMpaLLfILe`";
|
setenv PARALLEL_ENV "`cat $_tMpaLLfILe; rm $_tMpaLLfILe`";
|
||||||
unset _tMpaLLfILe;
|
unset _tMpaLLfILe;
|
||||||
# Use $PARALLEL set in calling alias
|
# Use $PARALLEL_CSH set in calling alias
|
||||||
parallel
|
parallel
|
||||||
set _parallel_exit_CODE=$status
|
set _parallel_exit_CODE=$status
|
||||||
setenv PARALLEL_ENV
|
setenv PARALLEL_ENV
|
||||||
setenv PARALLEL
|
setenv PARALLEL_CSH
|
||||||
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'
|
|
||||||
|
|
||||||
|
|
|
@ -1444,7 +1444,7 @@ sub check_invalid_option_combinations() {
|
||||||
|
|
||||||
sub init_globals() {
|
sub init_globals() {
|
||||||
# Defaults:
|
# Defaults:
|
||||||
$Global::version = 20181223;
|
$Global::version = 20190122;
|
||||||
$Global::progname = 'parallel';
|
$Global::progname = 'parallel';
|
||||||
$Global::infinity = 2**31;
|
$Global::infinity = 2**31;
|
||||||
$Global::debug = 0;
|
$Global::debug = 0;
|
||||||
|
@ -2028,7 +2028,11 @@ sub read_options() {
|
||||||
}
|
}
|
||||||
# Add options from shell variable $PARALLEL
|
# Add options from shell variable $PARALLEL
|
||||||
if($ENV{'PARALLEL'}) {
|
if($ENV{'PARALLEL'}) {
|
||||||
@ARGV_env = shell_words($ENV{'PARALLEL'});
|
push @ARGV_env, shell_words($ENV{'PARALLEL'});
|
||||||
|
}
|
||||||
|
# Add options from env_parallel.csh via $PARALLEL_CSH
|
||||||
|
if($ENV{'PARALLEL_CSH'}) {
|
||||||
|
push @ARGV_env, shell_words($ENV{'PARALLEL_CSH'});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Getopt::Long::Configure("bundling","require_order");
|
Getopt::Long::Configure("bundling","require_order");
|
||||||
|
|
Loading…
Reference in a new issue