diff --git a/src/env_parallel.csh b/src/env_parallel.csh index 5bf60bfc..ae7a2562 100755 --- a/src/env_parallel.csh +++ b/src/env_parallel.csh @@ -26,9 +26,9 @@ # Fifth Floor, Boston, MA 02110-1301 USA set _parallel_exit_CODE=0 -if ("`alias env_parallel`" == '' || ! $?PARALLEL) then +if ("`alias env_parallel`" == '' || ! $?PARALLEL_CSH) then # Activate alias - alias env_parallel '(setenv PARALLEL "\!*"; source `which env_parallel.csh`)' + alias env_parallel '(setenv PARALLEL_CSH "\!*"; source `which env_parallel.csh`)' else # Get the --env variables if set # --env _ should be ignored @@ -50,7 +50,7 @@ else $vars = join "|",map { quotemeta $_ } @envvar; print $vars ? "($vars)" : "(.*)"; 'EOF' - set _grep_REGEXP="`perl $_tMpscRIpt -- $PARALLEL`" + set _grep_REGEXP="`perl $_tMpscRIpt -- $PARALLEL_CSH`" # Deal with --env _ cat <<'EOF' > $_tMpscRIpt @@ -71,7 +71,7 @@ else } } 'EOF' - set _ignore_UNDERSCORE="`perl $_tMpscRIpt -- $PARALLEL`" + set _ignore_UNDERSCORE="`perl $_tMpscRIpt -- $PARALLEL_CSH`" rm $_tMpscRIpt # Get the scalar and array variable names @@ -92,7 +92,7 @@ else eval if'(${#'$_vARnAmE'} > 1) echo array_'$_vARnAmE'="$'$_vARnAmE'"' >> $_tMpvARfILe; end 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 '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 @@ -130,10 +130,10 @@ else setenv PARALLEL_ENV "`cat $_tMpaLLfILe; rm $_tMpaLLfILe`"; unset _tMpaLLfILe; - # Use $PARALLEL set in calling alias + # Use $PARALLEL_CSH set in calling alias parallel set _parallel_exit_CODE=$status setenv PARALLEL_ENV - setenv PARALLEL + setenv PARALLEL_CSH endif (exit $_parallel_exit_CODE) diff --git a/src/env_parallel.tcsh b/src/env_parallel.tcsh index ba45b402..7fe1af83 100755 --- a/src/env_parallel.tcsh +++ b/src/env_parallel.tcsh @@ -26,9 +26,9 @@ # Fifth Floor, Boston, MA 02110-1301 USA set _parallel_exit_CODE=0 -if ("`alias env_parallel`" == '' || ! $?PARALLEL) then +if ("`alias env_parallel`" == '' || ! $?PARALLEL_CSH) then # Activate alias - alias env_parallel '(setenv PARALLEL "\!*"; source `which env_parallel.tcsh`)' + alias env_parallel '(setenv PARALLEL_CSH "\!*"; source `which env_parallel.csh`)' else # Get the --env variables if set # --env _ should be ignored @@ -50,12 +50,12 @@ else $vars = join "|",map { quotemeta $_ } @envvar; print $vars ? "($vars)" : "(.*)"; 'EOF' - set _grep_REGEXP="`perl $_tMpscRIpt -- $PARALLEL`" + set _grep_REGEXP="`perl $_tMpscRIpt -- $PARALLEL_CSH`" # Deal with --env _ cat <<'EOF' > $_tMpscRIpt #!/usr/bin/perl - + for(@ARGV){ $next_is_env and push @envvar, split/,/, $_; $next_is_env=/^--env$/; @@ -71,7 +71,7 @@ else } } 'EOF' - set _ignore_UNDERSCORE="`perl $_tMpscRIpt -- $PARALLEL`" + set _ignore_UNDERSCORE="`perl $_tMpscRIpt -- $PARALLEL_CSH`" rm $_tMpscRIpt # Get the scalar and array variable names @@ -83,6 +83,7 @@ else # Make a tmpfile for the variable definitions + alias set _tMpaLLfILe=`_tempfile` foreach _vARnAmE ($_vARnAmES); + # These 3 lines break in csh version 20110502-3 # if not defined: next eval if'(! $?'$_vARnAmE') continue' # if $#myvar <= 1 echo scalar_myvar=$var @@ -91,7 +92,7 @@ else eval if'(${#'$_vARnAmE'} > 1) echo array_'$_vARnAmE'="$'$_vARnAmE'"' >> $_tMpvARfILe; end 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 '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 @@ -125,18 +126,14 @@ else # Quoted: s/\^/\\001alias\ /\; alias | \ perl -ne '/^'"$_grep_REGEXP"'/ or next; /^'"$_ignore_UNDERSCORE"'[^_a-zA-Z]/ and next; print' | \ - 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 - + 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; - # Use $PARALLEL set in calling alias + # Use $PARALLEL_CSH set in calling alias parallel set _parallel_exit_CODE=$status setenv PARALLEL_ENV - setenv PARALLEL + setenv PARALLEL_CSH endif (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' - diff --git a/src/parallel b/src/parallel index 85f20f3d..601ca1d5 100755 --- a/src/parallel +++ b/src/parallel @@ -1444,7 +1444,7 @@ sub check_invalid_option_combinations() { sub init_globals() { # Defaults: - $Global::version = 20181223; + $Global::version = 20190122; $Global::progname = 'parallel'; $Global::infinity = 2**31; $Global::debug = 0; @@ -2028,7 +2028,11 @@ sub read_options() { } # Add options from shell variable $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");