diff --git a/src/env_parallel b/src/env_parallel index 41279adf..3a5ad1e6 100755 --- a/src/env_parallel +++ b/src/env_parallel @@ -33,7 +33,7 @@ while test $# -gt 0; do grep env_parallel.ksh $HOME/.kshrc 2>/dev/null || echo 'source `which env_parallel.ksh`' >> $HOME/.kshrc grep env_parallel.pdksh $HOME/.profile 2>/dev/null || - echo 'source `which env_parallel.pdksh`' >> $HOME/.profile + echo '. `which env_parallel.pdksh`' >> $HOME/.profile grep env_parallel.csh $HOME/.cshrc 2>/dev/null || echo 'source `which env_parallel.csh`' >> $HOME/.cshrc grep env_parallel.tcsh $HOME/.tcshrc 2>/dev/null || @@ -78,7 +78,7 @@ ksh: Put this in $HOME/.kshrc: source `which env_parallel.ksh` Supports: aliases, functions, variables, arrays pdksh: Put this in $HOME/.profile: source `which env_parallel.pdksh` - E.g. by doing: echo 'source `which env_parallel.pdksh`' >> $HOME/.profile + E.g. by doing: echo '. `which env_parallel.pdksh`' >> $HOME/.profile Supports: aliases, functions, variables, arrays csh: Put this in $HOME/.cshrc: source `which env_parallel.csh` diff --git a/src/env_parallel.bash b/src/env_parallel.bash index 54f64171..ce735156 100755 --- a/src/env_parallel.bash +++ b/src/env_parallel.bash @@ -26,11 +26,20 @@ # Fifth Floor, Boston, MA 02110-1301 USA # Supports env of 127426 bytes + env_parallel() { - export PARALLEL_ENV="$(echo "shopt -s expand_aliases 2>/dev/null"; alias;typeset -p | - grep -vFf <(readonly) | - grep -v 'declare .. (GROUPS|FUNCNAME|DIRSTACK|_|PIPESTATUS|USERNAME|BASH_[A-Z_]+) '; + # env_parallel.bash + PARALLEL_ENV="$(alias; + typeset -p | + grep -vFf <(readonly) | + grep -v 'declare .. (GROUPS|FUNCNAME|DIRSTACK|_|PIPESTATUS|USERNAME|BASH_[A-Z_]+) '; typeset -f)"; + # Copy shopt (so e.g. extended globbing works) + parallel_shopt="$(shopt 2>/dev/null | + perl -pe 's:\s+off:;: and s/^/shopt -u /; + s:\s+on:;: and s/^/shopt -s /;')" + export PARALLEL_ENV="$parallel_shopt$PARALLEL_ENV" + unset parallel_shopt; `which parallel` "$@"; unset PARALLEL_ENV; } diff --git a/src/env_parallel.fish b/src/env_parallel.fish index e3e4bd44..f881cc49 100755 --- a/src/env_parallel.fish +++ b/src/env_parallel.fish @@ -41,6 +41,7 @@ # separator. function env_parallel + # env_parallel.fish setenv PARALLEL_ENV ( begin; # Export function definitions diff --git a/src/env_parallel.ksh b/src/env_parallel.ksh index 0a4d253f..2662a72e 100755 --- a/src/env_parallel.ksh +++ b/src/env_parallel.ksh @@ -26,6 +26,7 @@ # Fifth Floor, Boston, MA 02110-1301 USA env_parallel() { + # env_parallel.ksh export PARALLEL_ENV="$(alias | perl -pe 's/^/alias /';typeset -p|egrep -v 'typeset( -i)? -r|PIPESTATUS';typeset -f)"; `which parallel` "$@"; unset PARALLEL_ENV; diff --git a/src/env_parallel.pdksh b/src/env_parallel.pdksh index 67c6a53e..c82f1978 100755 --- a/src/env_parallel.pdksh +++ b/src/env_parallel.pdksh @@ -26,6 +26,7 @@ # Fifth Floor, Boston, MA 02110-1301 USA env_parallel() { + # env_parallel.pdksh export PARALLEL_ENV="$(alias | perl -pe 's/^/alias /';typeset -p|egrep -v 'typeset( -i)? -r|PIPESTATUS';typeset -f)"; `which parallel` "$@"; unset PARALLEL_ENV; diff --git a/src/env_parallel.zsh b/src/env_parallel.zsh index 7a8e254b..490735a3 100755 --- a/src/env_parallel.zsh +++ b/src/env_parallel.zsh @@ -26,6 +26,7 @@ # Fifth Floor, Boston, MA 02110-1301 USA env_parallel() { + # env_parallel.zsh export PARALLEL_ENV="$(alias | perl -pe 's/^/alias /'; typeset -p | grep -aFvf <(typeset -pr) | egrep -iav 'ZSH_EVAL_CONTEXT|LINENO=| _=|aliases|^typeset [a-z_]+$'| diff --git a/src/parallel b/src/parallel index 1bccc174..0ec83aba 100755 --- a/src/parallel +++ b/src/parallel @@ -1195,7 +1195,7 @@ sub check_invalid_option_combinations { sub init_globals { # Defaults: - $Global::version = 20160622; + $Global::version = 20160627; $Global::progname = 'parallel'; $Global::infinity = 2**31; $Global::debug = 0; diff --git a/testsuite/tests-to-run/parallel-local-0.3s.sh b/testsuite/tests-to-run/parallel-local-0.3s.sh index 6d96591a..0299da40 100644 --- a/testsuite/tests-to-run/parallel-local-0.3s.sh +++ b/testsuite/tests-to-run/parallel-local-0.3s.sh @@ -614,6 +614,17 @@ echo '### bug #48295: --results should be dynamic like --wd' echo '**' + bash -O extglob -c '. `which env_parallel.bash`; + _longopt () { + case "$prev" in + --+([-a-z0-9_])) + echo foo;; + esac; + }; + env_parallel echo ::: env_parallel 2>&1 + ' + +echo '**' EOF echo '### 1 .par file from --files expected' diff --git a/testsuite/wanted-results/parallel-local-0.3s b/testsuite/wanted-results/parallel-local-0.3s index 9e2524a0..b51b8431 100644 --- a/testsuite/wanted-results/parallel-local-0.3s +++ b/testsuite/wanted-results/parallel-local-0.3s @@ -1676,6 +1676,10 @@ B b /tmp/parallel-48295/B/1/B/2/b/stderr /tmp/parallel-48295/B/1/B/2/b/stdout echo '**' +** + bash -O extglob -c '. `which env_parallel.bash`; _longopt () { case "$prev" in --+([-a-z0-9_])) echo foo;; esac; }; env_parallel echo ::: env_parallel 2>&1 ' +env_parallel +echo '**' ** ### 1 .par file from --files expected 0