env_parallel.{ash/dash/sh}: Added.

env_parallel.{bash/zsh/ksh}: Make them more similar to sh.
This commit is contained in:
Ole Tange 2017-02-12 21:48:15 +01:00
parent 09cc44e209
commit 87815c2a91
13 changed files with 1024 additions and 2953 deletions

View file

@ -1,6 +1,8 @@
bin_SCRIPTS = parallel sql niceload parcat \
env_parallel env_parallel.bash env_parallel.zsh env_parallel.fish \
env_parallel.ksh env_parallel.pdksh env_parallel.csh env_parallel.tcsh
bin_SCRIPTS = parallel sql niceload parcat env_parallel \
env_parallel.ash env_parallel.bash env_parallel.csh \
env_parallel.dash env_parallel.fish env_parallel.ksh \
env_parallel.pdksh env_parallel.sh env_parallel.tcsh \
env_parallel.zsh
install-exec-hook:
rm $(DESTDIR)$(bindir)/sem || true

View file

@ -230,8 +230,10 @@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
bin_SCRIPTS = parallel sql niceload parcat \
env_parallel env_parallel.bash env_parallel.zsh env_parallel.fish \
env_parallel.ksh env_parallel.pdksh env_parallel.csh env_parallel.tcsh
env_parallel env_parallel.bash env_parallel.csh \
env_parallel.dash env_parallel.fish env_parallel.ksh \
env_parallel.pdksh env_parallel.sh env_parallel.tcsh \
env_parallel.zsh
@DOCUMENTATION_TRUE@man_MANS = parallel.1 env_parallel.1 sem.1 sql.1 niceload.1 \
@DOCUMENTATION_TRUE@ parallel_tutorial.7 parallel_design.7 parallel_alternatives.7 \

174
src/env_parallel.ash Normal file
View file

@ -0,0 +1,174 @@
#!/usr/bin/env ash
# This file must be sourced in ash:
#
# . `which env_parallel.ash`
#
# after which 'env_parallel' works
#
#
# Copyright (C) 2017
# Ole Tange and Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>
# or write to the Free Software Foundation, Inc., 51 Franklin St,
# Fifth Floor, Boston, MA 02110-1301 USA
env_parallel() {
# based on env_parallel.sh
_names_of_ALIASES() {
alias | perl -pe 's/=.*//'
}
_bodies_of_ALIASES() {
alias "$@" | perl -pe 's/^/alias /'
}
_names_of_maybe_FUNCTIONS() {
set | perl -ne '/^(\S+)\(\)\{$/ and print "$1\n"'
}
_names_of_FUNCTIONS() {
# myfunc is a function
type `_names_of_maybe_FUNCTIONS` |
perl -ne '/^(\S+) is a function$/ and not $seen{$1}++ and print "$1\n"'
}
_bodies_of_FUNCTIONS() {
type "$@" | perl -ne '/^(\S+) is a function$/ or print'
}
_names_of_VARIABLES() {
# This may screw up if variables contain \n and =
set | perl -ne 's/^(\S+)=.*/$1/ and print;'
}
_bodies_of_VARIABLES() {
# Crappy typeset -p
for _i in "$@"
do
perl -e 'print @ARGV' "$_i="
eval echo \"\$$_i\" | perl -e '$/=undef; $a=<>; chop($a); print $a' |
perl -pe 's/[\002-\011\013-\032\\\#\?\`\(\)\{\}\[\]\^\*\<\=\>\~\|\; \"\!\$\&\202-\377]/\\$&/go;'"s/'/\\\'/g; s/[\n]/'\\n'/go;";
echo
done
}
_remove_bad_NAMES() {
# Do not transfer vars and funcs from env_parallel
grep -Ev '^(_names_of_ALIASES|_bodies_of_ALIASES|_names_of_maybe_FUNCTIONS|_names_of_FUNCTIONS|_bodies_of_FUNCTIONS|_names_of_VARIABLES|_bodies_of_VARIABLES|_remove_bad_NAMES|_prefix_PARALLEL_ENV|_get_ignored_VARS|_make_grep_REGEXP|_ignore_UNDERSCORE|_alias_NAMES|_list_alias_BODIES|_function_NAMES|_list_function_BODIES|_variable_NAMES|_list_variable_VALUES|_prefix_PARALLEL_ENV)$' |
# Filter names matching --env
grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ |
# Vars set by /bin/sh
grep -Ev '^(_)$'
}
_get_ignored_VARS() {
perl -e '
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 $_ } "env_parallel", @ignored_vars;
print $vars ? "($vars)" : "(,,nO,,VaRs,,)";
}
}
' -- "$@"
}
# 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 (.*)
_make_grep_REGEXP() {
perl -e '
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)" : "(.*)";
' -- "$@"
}
if which parallel | grep 'no parallel in' >/dev/null; then
echo 'env_parallel: Error: parallel must be in $PATH.' >&2
return 1
fi
if which parallel >/dev/null; then
true which on linux
else
echo 'env_parallel: Error: parallel must be in $PATH.' >&2
return 1
fi
# Grep regexp for vars given by --env
_grep_REGEXP="`_make_grep_REGEXP \"$@\"`"
# Deal with --env _
_ignore_UNDERSCORE="`_get_ignored_VARS \"$@\"`"
# --record-env
if perl -e 'exit grep { /^--record-env$/ } @ARGV' -- "$@"; then
true skip
else
(_names_of_ALIASES;
_names_of_FUNCTIONS;
_names_of_VARIABLES) |
cat > $HOME/.parallel/ignored_vars
return 0
fi
# Grep alias names
_alias_NAMES="`_names_of_ALIASES | _remove_bad_NAMES`"
_list_alias_BODIES="_bodies_of_ALIASES $_alias_NAMES"
if [ "$_alias_NAMES" = "" ] ; then
# no aliases selected
_list_alias_BODIES="true"
fi
unset _alias_NAMES
# Grep function names
_function_NAMES="`_names_of_FUNCTIONS | _remove_bad_NAMES`"
_list_function_BODIES="_bodies_of_FUNCTIONS $_function_NAMES"
if [ "$_function_NAMES" = "" ] ; then
# no functions selected
_list_function_BODIES="true"
fi
unset _function_NAMES
# Grep variable names
_variable_NAMES="`_names_of_VARIABLES | _remove_bad_NAMES`"
_list_variable_VALUES="_bodies_of_VARIABLES $_variable_NAMES"
if [ "$_variable_NAMES" = "" ] ; then
# no variables selected
_list_variable_VALUES="true"
fi
unset _variable_NAMES
PARALLEL_ENV="`
$_list_alias_BODIES;
$_list_function_BODIES;
$_list_variable_VALUES;
`"
export PARALLEL_ENV
unset _list_alias_BODIES
unset _list_variable_VALUES
unset _list_function_BODIES
`which parallel` "$@";
_parallel_exit_CODE=$?
unset PARALLEL_ENV;
return $_parallel_exit_CODE
}

View file

@ -28,23 +28,40 @@
env_parallel() {
# env_parallel.bash
# 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 (.*)
local _grep_REGEXP="$(
perl -e '
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)" : "(.*)";
' -- "$@"
)"
# Deal with --env _
local _ignore_UNDERSCORE="$(
_names_of_ALIASES() {
compgen -a
}
_bodies_of_ALIASES() {
alias "$@"
}
_names_of_FUNCTIONS() {
compgen -A function
}
_bodies_of_FUNCTIONS() {
typeset -f "$@"
}
_names_of_VARIABLES() {
compgen -A variable
}
_bodies_of_VARIABLES() {
typeset -p "$@"
}
_remove_bad_NAMES() {
# Do not transfer vars and funcs from env_parallel
grep -Ev '^(_names_of_ALIASES|_bodies_of_ALIASES|_names_of_maybe_FUNCTIONS|_names_of_FUNCTIONS|_bodies_of_FUNCTIONS|_names_of_VARIABLES|_bodies_of_VARIABLES|_remove_bad_NAMES|_prefix_PARALLEL_ENV|_get_ignored_VARS|_make_grep_REGEXP|_ignore_UNDERSCORE|_alias_NAMES|_list_alias_BODIES|_function_NAMES|_list_function_BODIES|_variable_NAMES|_list_variable_VALUES|_prefix_PARALLEL_ENV)$' |
grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ |
grep -vFf <(readonly) |
grep -Ev '^(BASHOPTS|BASHPID|EUID|GROUPS|FUNCNAME|DIRSTACK|_|PIPESTATUS|PPID|SHELLOPTS|UID|USERNAME|BASH_[A-Z_]+)$'
}
_prefix_PARALLEL_ENV() {
shopt 2>/dev/null |
perl -pe 's:\s+off:;: and s/^/shopt -u /;
s:\s+on:;: and s/^/shopt -s /;
s:;$:&>/dev/null;:';
echo 'shopt -s expand_aliases &>/dev/null';
}
_get_ignored_VARS() {
perl -e '
for(@ARGV){
$next_is_env and push @envvar, split/,/, $_;
@ -61,44 +78,74 @@ env_parallel() {
}
}
' -- "$@"
)"
}
# 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 (.*)
_make_grep_REGEXP() {
perl -e '
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)" : "(.*)";
' -- "$@"
}
if which parallel | grep 'no parallel in' >/dev/null; then
echo 'env_parallel: Error: parallel must be in $PATH.' >&2
return 1
fi
if which parallel >/dev/null; then
true which on linux
else
echo 'env_parallel: Error: parallel must be in $PATH.' >&2
return 1
fi
# Grep regexp for vars given by --env
_grep_REGEXP="`_make_grep_REGEXP \"$@\"`"
# Deal with --env _
_ignore_UNDERSCORE="`_get_ignored_VARS \"$@\"`"
# --record-env
if ! perl -e 'exit grep { /^--record-env$/ } @ARGV' -- "$@"; then
(compgen -a;
compgen -A function;
compgen -A variable) |
if perl -e 'exit grep { /^--record-env$/ } @ARGV' -- "$@"; then
true skip
else
(_names_of_ALIASES;
_names_of_FUNCTIONS;
_names_of_VARIABLES) |
cat > $HOME/.parallel/ignored_vars
return 0
fi
# Grep alias names
local _alias_NAMES="$(compgen -a |
grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ )"
local _list_alias_BODIES="alias $_alias_NAMES"
if [[ "$_alias_NAMES" = "" ]] ; then
_alias_NAMES="`_names_of_ALIASES | _remove_bad_NAMES`"
_list_alias_BODIES="_bodies_of_ALIASES $_alias_NAMES"
if [ "$_alias_NAMES" = "" ] ; then
# no aliases selected
_list_alias_BODIES="true"
fi
unset _alias_NAMES
# Grep function names
local _function_NAMES="$(compgen -A function |
grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ )"
local _list_function_BODIES="typeset -f $_function_NAMES"
if [[ "$_function_NAMES" = "" ]] ; then
_function_NAMES="`_names_of_FUNCTIONS | _remove_bad_NAMES`"
_list_function_BODIES="_bodies_of_FUNCTIONS $_function_NAMES"
if [ "$_function_NAMES" = "" ] ; then
# no functions selected
_list_function_BODIES="true"
fi
unset _function_NAMES
# Grep variable names
local _variable_NAMES="$(compgen -A variable |
grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ |
grep -vFf <(readonly) |
grep -Ev '^(BASHOPTS|BASHPID|EUID|GROUPS|FUNCNAME|DIRSTACK|_|PIPESTATUS|PPID|SHELLOPTS|UID|USERNAME|BASH_[A-Z_]+)$')"
local _list_variable_VALUES="typeset -p $_variable_NAMES"
if [[ "$_variable_NAMES" = "" ]] ; then
_variable_NAMES="`_names_of_VARIABLES | _remove_bad_NAMES`"
_list_variable_VALUES="_bodies_of_VARIABLES $_variable_NAMES"
if [ "$_variable_NAMES" = "" ] ; then
# no variables selected
_list_variable_VALUES="true"
fi
@ -106,15 +153,13 @@ env_parallel() {
# Copy shopt (so e.g. extended globbing works)
# But force expand_aliases as aliases otherwise do not work
export PARALLEL_ENV="$(
shopt 2>/dev/null |
perl -pe 's:\s+off:;: and s/^/shopt -u /;
s:\s+on:;: and s/^/shopt -s /;
s:;$:&>/dev/null;:';
echo 'shopt -s expand_aliases &>/dev/null';
PARALLEL_ENV="`
_prefix_PARALLEL_ENV
$_list_alias_BODIES;
$_list_function_BODIES;
$_list_variable_VALUES;
$_list_function_BODIES)";
`"
export PARALLEL_ENV
unset _list_alias_BODIES
unset _list_variable_VALUES
unset _list_function_BODIES

174
src/env_parallel.dash Executable file
View file

@ -0,0 +1,174 @@
#!/usr/bin/env dash
# This file must be sourced in dash:
#
# . `which env_parallel.dash`
#
# after which 'env_parallel' works
#
#
# Copyright (C) 2017
# Ole Tange and Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>
# or write to the Free Software Foundation, Inc., 51 Franklin St,
# Fifth Floor, Boston, MA 02110-1301 USA
env_parallel() {
# based on env_parallel.sh
_names_of_ALIASES() {
alias | perl -pe 's/=.*//'
}
_bodies_of_ALIASES() {
alias "$@" | perl -pe 's/^/alias /'
}
_names_of_maybe_FUNCTIONS() {
set | perl -ne '/^(\S+)\(\)\{$/ and print "$1\n"'
}
_names_of_FUNCTIONS() {
# myfunc is a function
type `_names_of_maybe_FUNCTIONS` |
perl -ne '/^(\S+) is a function$/ and not $seen{$1}++ and print "$1\n"'
}
_bodies_of_FUNCTIONS() {
type "$@" | perl -ne '/^(\S+) is a function$/ or print'
}
_names_of_VARIABLES() {
# This may screw up if variables contain \n and =
set | perl -ne 's/^(\S+)=.*/$1/ and print;'
}
_bodies_of_VARIABLES() {
# Crappy typeset -p
for _i in "$@"
do
perl -e 'print @ARGV' "$_i="
eval echo \"\$$_i\" | perl -e '$/=undef; $a=<>; chop($a); print $a' |
perl -pe 's/[\002-\011\013-\032\\\#\?\`\(\)\{\}\[\]\^\*\<\=\>\~\|\; \"\!\$\&\202-\377]/\\$&/go;'"s/'/\\\'/g; s/[\n]/'\\n'/go;";
echo
done
}
_remove_bad_NAMES() {
# Do not transfer vars and funcs from env_parallel
grep -Ev '^(_names_of_ALIASES|_bodies_of_ALIASES|_names_of_maybe_FUNCTIONS|_names_of_FUNCTIONS|_bodies_of_FUNCTIONS|_names_of_VARIABLES|_bodies_of_VARIABLES|_remove_bad_NAMES|_prefix_PARALLEL_ENV|_get_ignored_VARS|_make_grep_REGEXP|_ignore_UNDERSCORE|_alias_NAMES|_list_alias_BODIES|_function_NAMES|_list_function_BODIES|_variable_NAMES|_list_variable_VALUES|_prefix_PARALLEL_ENV)$' |
# Filter names matching --env
grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ |
# Vars set by /bin/sh
grep -Ev '^(_)$'
}
_get_ignored_VARS() {
perl -e '
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 $_ } "env_parallel", @ignored_vars;
print $vars ? "($vars)" : "(,,nO,,VaRs,,)";
}
}
' -- "$@"
}
# 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 (.*)
_make_grep_REGEXP() {
perl -e '
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)" : "(.*)";
' -- "$@"
}
if which parallel | grep 'no parallel in' >/dev/null; then
echo 'env_parallel: Error: parallel must be in $PATH.' >&2
return 1
fi
if which parallel >/dev/null; then
true which on linux
else
echo 'env_parallel: Error: parallel must be in $PATH.' >&2
return 1
fi
# Grep regexp for vars given by --env
_grep_REGEXP="`_make_grep_REGEXP \"$@\"`"
# Deal with --env _
_ignore_UNDERSCORE="`_get_ignored_VARS \"$@\"`"
# --record-env
if perl -e 'exit grep { /^--record-env$/ } @ARGV' -- "$@"; then
true skip
else
(_names_of_ALIASES;
_names_of_FUNCTIONS;
_names_of_VARIABLES) |
cat > $HOME/.parallel/ignored_vars
return 0
fi
# Grep alias names
_alias_NAMES="`_names_of_ALIASES | _remove_bad_NAMES`"
_list_alias_BODIES="_bodies_of_ALIASES $_alias_NAMES"
if [ "$_alias_NAMES" = "" ] ; then
# no aliases selected
_list_alias_BODIES="true"
fi
unset _alias_NAMES
# Grep function names
_function_NAMES="`_names_of_FUNCTIONS | _remove_bad_NAMES`"
_list_function_BODIES="_bodies_of_FUNCTIONS $_function_NAMES"
if [ "$_function_NAMES" = "" ] ; then
# no functions selected
_list_function_BODIES="true"
fi
unset _function_NAMES
# Grep variable names
_variable_NAMES="`_names_of_VARIABLES | _remove_bad_NAMES`"
_list_variable_VALUES="_bodies_of_VARIABLES $_variable_NAMES"
if [ "$_variable_NAMES" = "" ] ; then
# no variables selected
_list_variable_VALUES="true"
fi
unset _variable_NAMES
PARALLEL_ENV="`
$_list_alias_BODIES;
$_list_function_BODIES;
$_list_variable_VALUES;
`"
export PARALLEL_ENV
unset _list_alias_BODIES
unset _list_variable_VALUES
unset _list_function_BODIES
`which parallel` "$@";
_parallel_exit_CODE=$?
unset PARALLEL_ENV;
return $_parallel_exit_CODE
}

View file

@ -28,23 +28,37 @@
env_parallel() {
# env_parallel.ksh
# 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 (.*)
_grep_REGEXP="$(
perl -e '
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)" : "(.*)";
' -- "$@"
)"
# Deal with --env _
_ignore_UNDERSCORE="$(
_names_of_ALIASES() {
alias | perl -pe 's/=.*//'
}
_bodies_of_ALIASES() {
alias "$@" | perl -pe 's/^/alias /'
}
_names_of_maybe_FUNCTIONS() {
true not used
}
_names_of_FUNCTIONS() {
typeset +p -f | perl -pe 's/\(\).*//'
}
_bodies_of_FUNCTIONS() {
typeset -f "$@"
}
_names_of_VARIABLES() {
typeset +p | perl -pe 's/^typeset .. //'
}
_bodies_of_VARIABLES() {
typeset -p "$@"
}
_remove_bad_NAMES() {
# Do not transfer vars and funcs from env_parallel
grep -Ev '^(_names_of_ALIASES|_bodies_of_ALIASES|_names_of_maybe_FUNCTIONS|_names_of_FUNCTIONS|_bodies_of_FUNCTIONS|_names_of_VARIABLES|_bodies_of_VARIABLES|_remove_bad_NAMES|_prefix_PARALLEL_ENV|_get_ignored_VARS|_make_grep_REGEXP|_ignore_UNDERSCORE|_alias_NAMES|_list_alias_BODIES|_function_NAMES|_list_function_BODIES|_variable_NAMES|_list_variable_VALUES|_prefix_PARALLEL_ENV)$' |
# Filter names matching --env
grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ |
# Vars set by /bin/sh
grep -Ev '^(_)$'
}
_get_ignored_VARS() {
perl -e '
for(@ARGV){
$next_is_env and push @envvar, split/,/, $_;
@ -61,56 +75,89 @@ env_parallel() {
}
}
' -- "$@"
)"
}
# 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 (.*)
_make_grep_REGEXP() {
perl -e '
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)" : "(.*)";
' -- "$@"
}
if which parallel | grep 'no parallel in' >/dev/null; then
echo 'env_parallel: Error: parallel must be in $PATH.' >&2
return 1
fi
if which parallel >/dev/null; then
true which on linux
else
echo 'env_parallel: Error: parallel must be in $PATH.' >&2
return 1
fi
# Grep regexp for vars given by --env
_grep_REGEXP="`_make_grep_REGEXP \"$@\"`"
# Deal with --env _
_ignore_UNDERSCORE="`_get_ignored_VARS \"$@\"`"
# --record-env
if ! perl -e 'exit grep { /^--record-env$/ } @ARGV' -- "$@"; then
(alias | perl -pe 's/=.*//';
typeset +p -f | perl -pe 's/\(\).*//';
typeset +p | perl -pe 's/^typeset .. //') |
if perl -e 'exit grep { /^--record-env$/ } @ARGV' -- "$@"; then
true skip
else
(_names_of_ALIASES;
_names_of_FUNCTIONS;
_names_of_VARIABLES) |
cat > $HOME/.parallel/ignored_vars
return 0
fi
# Grep alias names
_alias_NAMES="$(alias | perl -pe 's/=.*//' |
grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ )"
_list_alias_BODIES="alias $_alias_NAMES | perl -pe 's/^/alias /'"
if [[ "$_alias_NAMES" = "" ]] ; then
_alias_NAMES="`_names_of_ALIASES | _remove_bad_NAMES`"
_list_alias_BODIES="_bodies_of_ALIASES $_alias_NAMES"
if [ "$_alias_NAMES" = "" ] ; then
# no aliases selected
_list_alias_BODIES="true"
fi
unset _alias_NAMES
# Grep function names
_function_NAMES="$(typeset +p -f | perl -pe 's/\(\).*//' |
grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ )"
_list_function_BODIES="typeset -f $_function_NAMES"
if [[ "$_function_NAMES" = "" ]] ; then
_function_NAMES="`_names_of_FUNCTIONS | _remove_bad_NAMES`"
_list_function_BODIES="_bodies_of_FUNCTIONS $_function_NAMES"
if [ "$_function_NAMES" = "" ] ; then
# no functions selected
_list_function_BODIES="true"
fi
unset _function_NAMES
# Grep variable names
_variable_NAMES="$(typeset +p | perl -pe 's/^typeset .. //' |
grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ |
grep -Ev '^(PIPESTATUS)$')"
_list_variable_VALUES="typeset -p $_variable_NAMES"
if [[ "$_variable_NAMES" = "" ]] ; then
_variable_NAMES="`_names_of_VARIABLES | _remove_bad_NAMES`"
_list_variable_VALUES="_bodies_of_VARIABLES $_variable_NAMES"
if [ "$_variable_NAMES" = "" ] ; then
# no variables selected
_list_variable_VALUES="true"
fi
unset _variable_NAMES
# eval is needed for aliases - cannot explain why
export PARALLEL_ENV="$(
eval $_list_alias_BODIES;
PARALLEL_ENV="`
$_list_alias_BODIES;
$_list_function_BODIES;
$_list_variable_VALUES;
$_list_function_BODIES)";
`"
export PARALLEL_ENV
unset _list_alias_BODIES
unset _list_variable_VALUES
unset _list_function_BODIES
`which parallel` "$@";
_parallel_exit_CODE=$?
unset PARALLEL_ENV;

View file

@ -28,6 +28,93 @@
env_parallel() {
# env_parallel.pdksh
_names_of_ALIASES() {
compgen -a
}
_bodies_of_ALIASES() {
alias "$@" | perl -pe 's/^/alias /'
}
_names_of_FUNCTIONS() {
compgen -A function
}
_bodies_of_FUNCTIONS() {
typeset -f "$@"
}
_names_of_VARIABLES() {
compgen -A variable
}
_bodies_of_VARIABLES() {
typeset -p "$@"
}
_remove_bad_NAMES() {
_tmp_READONLY="$(mktemp)"
readonly > "$_tmp_READONLY"
grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ |
grep -vFf $_tmp_READONLY |
grep -Ev '^(PIPESTATUS)'
rm $_tmp_READONLY
unset _tmp_READONLY
}
_prefix_PARALLEL_ENV() {
shopt 2>/dev/null |
perl -pe 's:\s+off:;: and s/^/shopt -u /;
s:\s+on:;: and s/^/shopt -s /;
s:;$:&>/dev/null;:';
echo 'shopt -s expand_aliases &>/dev/null';
}
_get_ignored_VARS() {
perl -e '
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 $_ } "env_parallel", @ignored_vars;
print $vars ? "($vars)" : "(,,nO,,VaRs,,)";
}
}
' -- "$@"
}
# 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 (.*)
_make_grep_REGEXP() {
perl -e '
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)" : "(.*)";
' -- "$@"
}
if which parallel | grep 'no parallel in' >/dev/null; then
echo 'env_parallel: Error: parallel must be in $PATH.' >&2
return 1
fi
if which parallel >/dev/null; then
true which on linux
else
echo 'env_parallel: Error: parallel must be in $PATH.' >&2
return 1
fi
# Grep regexp for vars given by --env
_grep_REGEXP="`_make_grep_REGEXP \"$@\"`"
# Deal with --env _
_ignore_UNDERSCORE="`_get_ignored_VARS \"$@\"`"
# Get the --env variables if set
# --env _ should be ignored
# and convert a b c to (a|b|c)
@ -64,53 +151,49 @@ env_parallel() {
)"
# --record-env
if ! perl -e 'exit grep { /^--record-env$/ } @ARGV' -- "$@"; then
(compgen -a; compgen -A function; compgen -A variable) |
if perl -e 'exit grep { /^--record-env$/ } @ARGV' -- "$@"; then
true skip
else
(_names_of_ALIASES;
_names_of_FUNCTIONS;
_names_of_VARIABLES) |
cat > $HOME/.parallel/ignored_vars
return 0
fi
# Grep alias names
_alias_NAMES="$(alias | perl -pe 's/=.*//' |
grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ )"
_list_alias_BODIES="alias $_alias_NAMES | perl -pe 's/^/alias /'"
if [[ "$_alias_NAMES" = "" ]] ; then
_alias_NAMES="`_names_of_ALIASES | _remove_bad_NAMES`"
_list_alias_BODIES="_bodies_of_ALIASES $_alias_NAMES"
if [ "$_alias_NAMES" = "" ] ; then
# no aliases selected
_list_alias_BODIES="true"
fi
unset _alias_NAMES
# Grep function names
_function_NAMES=$(typeset +p -f | perl -pe 's/\(\).*//' |
grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ )
_list_function_BODIES="typeset -f $_function_NAMES"
if [[ "$_function_NAMES" = "" ]] ; then
_function_NAMES="`_names_of_FUNCTIONS | _remove_bad_NAMES`"
_list_function_BODIES="_bodies_of_FUNCTIONS $_function_NAMES"
if [ "$_function_NAMES" = "" ] ; then
# no functions selected
_list_function_BODIES="true"
fi
unset _function_NAMES
# Grep variable names
_tmp_READONLY="$(mktemp)"
readonly > "$_tmp_READONLY"
_variable_NAMES="$(typeset | perl -pe 's/^(type)?set( -.)* //' |
grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ |
grep -vFf $_tmp_READONLY |
grep -Ev '^(PIPESTATUS)')"
rm $_tmp_READONLY
unset _tmp_READONLY
_list_variable_VALUES="typeset -p $_variable_NAMES"
if [[ "$_variable_NAMES" = "" ]] ; then
_variable_NAMES="`_names_of_VARIABLES | _remove_bad_NAMES`"
_list_variable_VALUES="_bodies_of_VARIABLES $_variable_NAMES"
if [ "$_variable_NAMES" = "" ] ; then
# no variables selected
_list_variable_VALUES="true"
fi
unset _variable_NAMES
# eval is needed for aliases - cannot explain why
export PARALLEL_ENV="$(
export PARALLEL_ENV="`
eval $_list_alias_BODIES;
$_list_function_BODIES
$_list_variable_VALUES;
$_list_function_BODIES)";
`";
unset _list_alias_BODIES
unset _list_variable_VALUES
unset _list_function_BODIES

View file

@ -81,6 +81,50 @@ Same as GNU B<parallel>.
=head1 SUPPORTED SHELLS
=head2 ash
B<--env> is supported to export only the variable, or alias with the
given name. Multiple B<--env>s can be given.
Installation
Put this in $HOME/.profile:
. `which env_parallel.ash`
E.g. by doing:
echo '. `which env_parallel.ash`' >> $HOME/.profile
=over 8
=item aliases
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
ash cannot list defined functions - thus is not supported.
=item variables
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
ash does not support arrays.
=back
=head2 Bash
B<--env> is supported to export only the variable, alias, function, or
@ -184,6 +228,50 @@ Not supported by B<csh>.
=back
=head2 dash
B<--env> is supported to export only the variable, or alias with the
given name. Multiple B<--env>s can be given.
Installation
Put this in $HOME/.profile:
. `which env_parallel.dash`
E.g. by doing:
echo '. `which env_parallel.dash`' >> $HOME/.profile
=over 8
=item aliases
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
dash cannot list defined functions - thus is not supported.
=item variables
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
dash does not support arrays.
=back
=head2 fish
B<--env> is supported to export only the variable, alias, function, or
@ -342,6 +430,50 @@ E.g. by doing:
=back
=head2 sh
B<--env> is supported to export only the variable, or alias with the
given name. Multiple B<--env>s can be given.
Installation
Put this in $HOME/.profile:
. `which env_parallel.sh`
E.g. by doing:
echo '. `which env_parallel.sh`' >> $HOME/.profile
=over 8
=item aliases
sh does not support aliases.
=item functions
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=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
sh does not support arrays.
=back
=head2 tcsh
B<--env> is supported to export only the variable, alias, or

174
src/env_parallel.sh Normal file
View file

@ -0,0 +1,174 @@
#!/usr/bin/env sh
# This file must be sourced in sh:
#
# . `which env_parallel.sh`
#
# after which 'env_parallel' works
#
#
# Copyright (C) 2017
# Ole Tange and Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>
# or write to the Free Software Foundation, Inc., 51 Franklin St,
# Fifth Floor, Boston, MA 02110-1301 USA
env_parallel() {
# env_parallel.sh
_names_of_ALIASES() {
alias | perl -pe 's/=.*//'
}
_bodies_of_ALIASES() {
alias "$@" | perl -pe 's/^/alias /'
}
_names_of_maybe_FUNCTIONS() {
set | perl -ne '/^(\S+)\(\)\{$/ and print "$1\n"'
}
_names_of_FUNCTIONS() {
# myfunc is a function
type `_names_of_maybe_FUNCTIONS` |
perl -ne '/^(\S+) is a function$/ and not $seen{$1}++ and print "$1\n"'
}
_bodies_of_FUNCTIONS() {
type "$@" | perl -ne '/^(\S+) is a function$/ or print'
}
_names_of_VARIABLES() {
# This may screw up if variables contain \n and =
set | perl -ne 's/^(\S+)=.*/$1/ and print;'
}
_bodies_of_VARIABLES() {
# Crappy typeset -p
for _i in "$@"
do
perl -e 'print @ARGV' "$_i="
eval echo \"\$$_i\" | perl -e '$/=undef; $a=<>; chop($a); print $a' |
perl -pe 's/[\002-\011\013-\032\\\#\?\`\(\)\{\}\[\]\^\*\<\=\>\~\|\; \"\!\$\&\202-\377]/\\$&/go;'"s/'/\\\'/g; s/[\n]/'\\n'/go;";
echo
done
}
_remove_bad_NAMES() {
# Do not transfer vars and funcs from env_parallel
grep -Ev '^(_names_of_ALIASES|_bodies_of_ALIASES|_names_of_maybe_FUNCTIONS|_names_of_FUNCTIONS|_bodies_of_FUNCTIONS|_names_of_VARIABLES|_bodies_of_VARIABLES|_remove_bad_NAMES|_prefix_PARALLEL_ENV|_get_ignored_VARS|_make_grep_REGEXP|_ignore_UNDERSCORE|_alias_NAMES|_list_alias_BODIES|_function_NAMES|_list_function_BODIES|_variable_NAMES|_list_variable_VALUES|_prefix_PARALLEL_ENV)$' |
# Filter names matching --env
grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ |
# Vars set by /bin/sh
grep -Ev '^(_)$'
}
_get_ignored_VARS() {
perl -e '
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 $_ } "env_parallel", @ignored_vars;
print $vars ? "($vars)" : "(,,nO,,VaRs,,)";
}
}
' -- "$@"
}
# 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 (.*)
_make_grep_REGEXP() {
perl -e '
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)" : "(.*)";
' -- "$@"
}
if which parallel | grep 'no parallel in' >/dev/null; then
echo 'env_parallel: Error: parallel must be in $PATH.' >&2
return 1
fi
if which parallel >/dev/null; then
true which on linux
else
echo 'env_parallel: Error: parallel must be in $PATH.' >&2
return 1
fi
# Grep regexp for vars given by --env
_grep_REGEXP="`_make_grep_REGEXP \"$@\"`"
# Deal with --env _
_ignore_UNDERSCORE="`_get_ignored_VARS \"$@\"`"
# --record-env
if perl -e 'exit grep { /^--record-env$/ } @ARGV' -- "$@"; then
true skip
else
(_names_of_ALIASES;
_names_of_FUNCTIONS;
_names_of_VARIABLES) |
cat > $HOME/.parallel/ignored_vars
return 0
fi
# Grep alias names
_alias_NAMES="`_names_of_ALIASES | _remove_bad_NAMES`"
_list_alias_BODIES="_bodies_of_ALIASES $_alias_NAMES"
if [ "$_alias_NAMES" = "" ] ; then
# no aliases selected
_list_alias_BODIES="true"
fi
unset _alias_NAMES
# Grep function names
_function_NAMES="`_names_of_FUNCTIONS | _remove_bad_NAMES`"
_list_function_BODIES="_bodies_of_FUNCTIONS $_function_NAMES"
if [ "$_function_NAMES" = "" ] ; then
# no functions selected
_list_function_BODIES="true"
fi
unset _function_NAMES
# Grep variable names
_variable_NAMES="`_names_of_VARIABLES | _remove_bad_NAMES`"
_list_variable_VALUES="_bodies_of_VARIABLES $_variable_NAMES"
if [ "$_variable_NAMES" = "" ] ; then
# no variables selected
_list_variable_VALUES="true"
fi
unset _variable_NAMES
PARALLEL_ENV="`
$_list_alias_BODIES;
$_list_function_BODIES;
$_list_variable_VALUES;
`"
export PARALLEL_ENV
unset _list_alias_BODIES
unset _list_variable_VALUES
unset _list_function_BODIES
`which parallel` "$@";
_parallel_exit_CODE=$?
unset PARALLEL_ENV;
return $_parallel_exit_CODE
}

View file

@ -28,23 +28,34 @@
env_parallel() {
# env_parallel.zsh
# 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 (.*)
_grep_REGEXP="$(
perl -e '
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)" : "(.*)";
' -- "$@"
)"
# Deal with --env _
local _ignore_UNDERSCORE="$(
_names_of_ALIASES() {
print -l ${(k)aliases}
}
_bodies_of_ALIASES() {
echo "alias "$(echo "$@"|xargs)" | perl -pe 's/^/alias /'"
}
_names_of_FUNCTIONS() {
print -l ${(k)functions}
}
_bodies_of_FUNCTIONS() {
echo "typeset -f "$(echo "$@"|xargs)
}
_names_of_VARIABLES() {
print -l ${(k)parameters}
}
_bodies_of_VARIABLES() {
echo typeset -p "$(echo $@|xargs)" '| grep -aFvf <(typeset -pr)'
}
_remove_bad_NAMES() {
# Do not transfer vars and funcs from env_parallel
grep -Ev '^(_names_of_ALIASES|_bodies_of_ALIASES|_names_of_maybe_FUNCTIONS|_names_of_FUNCTIONS|_bodies_of_FUNCTIONS|_names_of_VARIABLES|_bodies_of_VARIABLES|_remove_bad_NAMES|_prefix_PARALLEL_ENV|_get_ignored_VARS|_make_grep_REGEXP|_ignore_UNDERSCORE|_alias_NAMES|_list_alias_BODIES|_function_NAMES|_list_function_BODIES|_variable_NAMES|_list_variable_VALUES|_prefix_PARALLEL_ENV)$' |
grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ |
grep -v '=' |
grep -Ev '^([-?#!$*@_0]|zsh_eval_context|ZSH_EVAL_CONTEXT|LINENO|IFS|commands|functions|options|aliases|EUID|EGID|UID|GID)$' |
grep -Ev '^(dis_patchars|patchars|terminfo|funcstack|galiases|keymaps|parameters|jobdirs|dirstack|functrace|funcsourcetrace|zsh_scheduled_events|dis_aliases|dis_reswords|dis_saliases|modules|reswords|saliases|widgets|userdirs|historywords|nameddirs|termcap|dis_builtins|dis_functions|jobtexts|funcfiletrace|dis_galiases|builtins|history|jobstates)$'
}
_get_ignored_VARS() {
perl -e '
for(@ARGV){
$next_is_env and push @envvar, split/,/, $_;
@ -61,59 +72,87 @@ env_parallel() {
}
}
' -- "$@"
)"
}
# 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 (.*)
_make_grep_REGEXP() {
perl -e '
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)" : "(.*)";
' -- "$@"
}
if which parallel | grep 'no parallel in' >/dev/null; then
echo 'env_parallel: Error: parallel must be in $PATH.' >&2
return 1
fi
if which parallel >/dev/null; then
true which on linux
else
echo 'env_parallel: Error: parallel must be in $PATH.' >&2
return 1
fi
# Grep regexp for vars given by --env
_grep_REGEXP="`_make_grep_REGEXP \"$@\"`"
# Deal with --env _
_ignore_UNDERSCORE="`_get_ignored_VARS \"$@\"`"
# --record-env
if ! perl -e 'exit grep { /^--record-env$/ } @ARGV' -- "$@"; then
(print -l ${(k)aliases};
print -l ${(k)functions};
print -l ${(k)parameters}) |
if perl -e 'exit grep { /^--record-env$/ } @ARGV' -- "$@"; then
true skip
else
(_names_of_ALIASES;
_names_of_FUNCTIONS;
_names_of_VARIABLES) |
cat > $HOME/.parallel/ignored_vars
return 0
fi
# Grep alias names
_alias_NAMES="$(print -l ${(k)aliases} |
grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ )"
_alias_NAMES="`_names_of_ALIASES | _remove_bad_NAMES`"
_list_alias_BODIES="alias "$(echo $_alias_NAMES|xargs)" | perl -pe 's/^/alias /'"
if [[ "$_alias_NAMES" = "" ]] ; then
if [ "$_alias_NAMES" = "" ] ; then
# no aliases selected
_list_alias_BODIES="true"
fi
unset _alias_NAMES
# Grep function names
_function_NAMES="$(print -l ${(k)functions} |
grep -E "^$_grep_REGEXP\$" | grep -vE "^$_ignore_UNDERSCORE\$" |
grep -v '='
)"
_function_NAMES="`_names_of_FUNCTIONS | _remove_bad_NAMES`"
_list_function_BODIES="typeset -f "$(echo $_function_NAMES|xargs)
if [[ "$_function_NAMES" = "" ]] ; then
if [ "$_function_NAMES" = "" ] ; then
# no functions selected
_list_function_BODIES="true"
fi
unset _function_NAMES
# Grep variable names
# The grep -Ev is crap and should be better
_variable_NAMES="$(print -l ${(k)parameters} |
grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ |
grep -Ev '^([-?#!$*@_0]|zsh_eval_context|ZSH_EVAL_CONTEXT|LINENO|IFS|commands|functions|options|aliases|EUID|EGID|UID|GID)$' |
grep -Ev '^(dis_patchars|patchars|terminfo|funcstack|galiases|keymaps|parameters|jobdirs|dirstack|functrace|funcsourcetrace|zsh_scheduled_events|dis_aliases|dis_reswords|dis_saliases|modules|reswords|saliases|widgets|userdirs|historywords|nameddirs|termcap|dis_builtins|dis_functions|jobtexts|funcfiletrace|dis_galiases|builtins|history|jobstates)$'
)"
_variable_NAMES="`_names_of_VARIABLES | _remove_bad_NAMES`"
_list_variable_VALUES="typeset -p "$(echo $_variable_NAMES|xargs)" |
grep -aFvf <(typeset -pr)
"
if [[ "$_variable_NAMES" = "" ]] ; then
if [ "$_variable_NAMES" = "" ] ; then
# no variables selected
_list_variable_VALUES="true"
fi
unset _variable_NAMES
export PARALLEL_ENV="$(
PARALLEL_ENV="`
eval $_list_alias_BODIES;
eval $_list_function_BODIES;
eval $_list_variable_VALUES;
)";
`"
export PARALLEL_ENV
unset _list_alias_BODIES
unset _list_variable_VALUES
unset _list_function_BODIES

View file

@ -3508,7 +3508,7 @@ sub onall {
(@Global::ret_files ? map { "--return ".::shell_quote_scalar($_) }
@Global::ret_files : ""),
(@opt::env ? map { "--env ".::shell_quote_scalar($_) } @opt::env : ""),
(@opt::v ? "-vv" : ""),
(map { "-v" } @opt::v),
);
::debug("init", "| $0 $options\n");
open(my $parallel_fh, "|-", "$0 --will-cite -j0 $options") ||

File diff suppressed because it is too large Load diff

View file

@ -40,7 +40,7 @@ $INSTALL ash csh fdclone fish fizsh ksh mksh pdksh posh rc rush sash tcsh yash z
SSHPASS=`goodpasswd`
export SSHPASS
#shells="bash sh csh ash tcsh zsh ksh fish fizsh mksh pdksh posh rc sash yash nopathbash nopathcsh"
shells="bash sh csh ash tcsh zsh ksh fish fizsh mksh posh rc sash yash nopathbash nopathcsh"
shells="bash sh csh ash dash tcsh zsh ksh fish fizsh mksh posh rc sash yash nopathbash nopathcsh"
create_shell_user() {
shell="$1"
sudo deluser $shell && sudo mv /home/$shell /tmp/$shell.$RANDOM