mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-11-25 23:47:53 +00:00
parset/env_parset: Support for ash, dash, ksh, sh, zsh.
This commit is contained in:
parent
c73a27254a
commit
9e5433e3e5
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Copyright (C) 2016,2017
|
# Copyright (C) 2016,2017
|
||||||
# Ole Tange and Free Software Foundation, Inc.
|
# Ole Tange and Free Software Foundation, Inc.
|
||||||
|
|
|
@ -29,10 +29,10 @@ env_parallel() {
|
||||||
# based on env_parallel.sh
|
# based on env_parallel.sh
|
||||||
|
|
||||||
_names_of_ALIASES() {
|
_names_of_ALIASES() {
|
||||||
alias | perl -pe 's/=.*//'
|
alias | perl -pe 's/^alias //;s/=.*//'
|
||||||
}
|
}
|
||||||
_bodies_of_ALIASES() {
|
_bodies_of_ALIASES() {
|
||||||
alias "$@" | perl -pe 's/^/alias /'
|
alias "$@" | perl -pe 's/^(alias )?/alias /'
|
||||||
}
|
}
|
||||||
_names_of_maybe_FUNCTIONS() {
|
_names_of_maybe_FUNCTIONS() {
|
||||||
set | perl -ne '/^(\S+)\(\)\{$/ and print "$1\n"'
|
set | perl -ne '/^(\S+)\(\)\{$/ and print "$1\n"'
|
||||||
|
@ -167,6 +167,8 @@ env_parallel() {
|
||||||
unset _list_alias_BODIES
|
unset _list_alias_BODIES
|
||||||
unset _list_variable_VALUES
|
unset _list_variable_VALUES
|
||||||
unset _list_function_BODIES
|
unset _list_function_BODIES
|
||||||
|
unset _grep_REGEXP
|
||||||
|
unset _ignore_UNDERSCORE
|
||||||
# Test if environment is too big
|
# Test if environment is too big
|
||||||
if `which true` >/dev/null ; then
|
if `which true` >/dev/null ; then
|
||||||
`which parallel` "$@";
|
`which parallel` "$@";
|
||||||
|
@ -184,3 +186,74 @@ env_parallel() {
|
||||||
return 255
|
return 255
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parset() {
|
||||||
|
_parset_parallel_prg=parallel
|
||||||
|
_parset_main "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
env_parset() {
|
||||||
|
_parset_parallel_prg=env_parallel
|
||||||
|
_parset_main "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
_parset_main() {
|
||||||
|
# If $1 contains ',' or space:
|
||||||
|
# Split on , to get the destination variable names
|
||||||
|
# If $1 is a single destination variable name:
|
||||||
|
# Treat it as the name of an array
|
||||||
|
#
|
||||||
|
# # Create array named myvar
|
||||||
|
# parset myvar echo ::: {1..10}
|
||||||
|
# echo ${myvar[5]}
|
||||||
|
#
|
||||||
|
# # Put output into $var_a $var_b $var_c
|
||||||
|
# varnames=(var_a var_b var_c)
|
||||||
|
# parset "${varnames[*]}" echo ::: {1..3}
|
||||||
|
# echo $var_c
|
||||||
|
#
|
||||||
|
# # Put output into $var_a4 $var_b4 $var_c4
|
||||||
|
# parset "var_a4 var_b4 var_c4" echo ::: {1..3}
|
||||||
|
# echo $var_c4
|
||||||
|
|
||||||
|
_parset_name="$1"
|
||||||
|
if [ "$_parset_name" = "" ] ; then
|
||||||
|
echo parset: Error: No destination variable given. >&2
|
||||||
|
echo parset: Error: Try: >&2
|
||||||
|
echo parset: Error: ' ' parset myarray echo ::: foo bar >&2
|
||||||
|
return 255
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
echo "$_parset_name" |
|
||||||
|
perl -ne 'chomp;for (split /[, ]/) {
|
||||||
|
# Allow: var_32 var[3]
|
||||||
|
if(not /^[a-zA-Z_][a-zA-Z_0-9]*(\[\d+\])?$/) {
|
||||||
|
print STDERR "parset: Error: $_ is an invalid variable name.\n";
|
||||||
|
print STDERR "parset: Error: Variable names must be letter followed by letters or digits.\n";
|
||||||
|
$exitval = 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exit $exitval;
|
||||||
|
' || return 255
|
||||||
|
if echo "$_parset_name" | grep -E ',| ' >/dev/null ; then
|
||||||
|
# $1 contains , or space
|
||||||
|
# Split on , or space to get the names
|
||||||
|
eval "$(
|
||||||
|
# Compute results into files
|
||||||
|
$_parset_parallel_prg --files -k "$@" |
|
||||||
|
# var1=`cat tmpfile1; rm tmpfile1`
|
||||||
|
# var2=`cat tmpfile2; rm tmpfile2`
|
||||||
|
parallel -q echo {2}='`cat {1}; rm {1}`' :::: - :::+ $(
|
||||||
|
echo "$_parset_name" |
|
||||||
|
perl -pe 's/,/ /g'
|
||||||
|
)
|
||||||
|
)"
|
||||||
|
else
|
||||||
|
# $1 contains no space or ,
|
||||||
|
# => $1 is the name of the array to put data into
|
||||||
|
# Supported in: bash
|
||||||
|
# Arrays do not work in: ash dash
|
||||||
|
eval $_parset_name="( $( $_parset_parallel_prg --files -k "$@" |
|
||||||
|
perl -pe 'chop;$_="\"\`cat $_; rm $_\`\" "' ) )"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
|
@ -164,6 +164,8 @@ env_parallel() {
|
||||||
unset _list_alias_BODIES
|
unset _list_alias_BODIES
|
||||||
unset _list_variable_VALUES
|
unset _list_variable_VALUES
|
||||||
unset _list_function_BODIES
|
unset _list_function_BODIES
|
||||||
|
unset _grep_REGEXP
|
||||||
|
unset _ignore_UNDERSCORE
|
||||||
# Test if environment is too big
|
# Test if environment is too big
|
||||||
if [ "`which true`" == "$_which_true" ] ; then
|
if [ "`which true`" == "$_which_true" ] ; then
|
||||||
`which parallel` "$@";
|
`which parallel` "$@";
|
||||||
|
@ -183,6 +185,16 @@ env_parallel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
parset() {
|
parset() {
|
||||||
|
_parset_parallel_prg=parallel
|
||||||
|
_parset_main "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
env_parset() {
|
||||||
|
_parset_parallel_prg=env_parallel
|
||||||
|
_parset_main "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
_parset_main() {
|
||||||
# If $1 contains ',' or space:
|
# If $1 contains ',' or space:
|
||||||
# Split on , to get the destination variable names
|
# Split on , to get the destination variable names
|
||||||
# If $1 is a single destination variable name:
|
# If $1 is a single destination variable name:
|
||||||
|
@ -202,13 +214,13 @@ parset() {
|
||||||
# echo $var_c4
|
# echo $var_c4
|
||||||
|
|
||||||
_parset_name="$1"
|
_parset_name="$1"
|
||||||
shift
|
if [ "$_parset_name" = "" ] ; then
|
||||||
if [ "$_parset_name" == "" ] ; then
|
|
||||||
echo parset: Error: No destination variable given. >&2
|
echo parset: Error: No destination variable given. >&2
|
||||||
echo parset: Error: Try: >&2
|
echo parset: Error: Try: >&2
|
||||||
echo parset: Error: ' ' parset myarray echo ::: foo bar >&2
|
echo parset: Error: ' ' parset myarray echo ::: foo bar >&2
|
||||||
return 255
|
return 255
|
||||||
fi
|
fi
|
||||||
|
shift
|
||||||
echo "$_parset_name" |
|
echo "$_parset_name" |
|
||||||
perl -ne 'chomp;for (split /[, ]/) {
|
perl -ne 'chomp;for (split /[, ]/) {
|
||||||
# Allow: var_32 var[3]
|
# Allow: var_32 var[3]
|
||||||
|
@ -225,7 +237,7 @@ parset() {
|
||||||
# Split on , or space to get the names
|
# Split on , or space to get the names
|
||||||
eval "$(
|
eval "$(
|
||||||
# Compute results into files
|
# Compute results into files
|
||||||
parallel --files -k "$@" |
|
$_parset_parallel_prg --files -k "$@" |
|
||||||
# var1=`cat tmpfile1; rm tmpfile1`
|
# var1=`cat tmpfile1; rm tmpfile1`
|
||||||
# var2=`cat tmpfile2; rm tmpfile2`
|
# var2=`cat tmpfile2; rm tmpfile2`
|
||||||
parallel -q echo {2}='`cat {1}; rm {1}`' :::: - :::+ $(
|
parallel -q echo {2}='`cat {1}; rm {1}`' :::: - :::+ $(
|
||||||
|
@ -236,7 +248,9 @@ parset() {
|
||||||
else
|
else
|
||||||
# $1 contains no space or ,
|
# $1 contains no space or ,
|
||||||
# => $1 is the name of the array to put data into
|
# => $1 is the name of the array to put data into
|
||||||
eval $_parset_name="( $( parallel --files -k "$@" |
|
# Supported in: bash
|
||||||
|
# Arrays do not work in: ash dash
|
||||||
|
eval $_parset_name="( $( $_parset_parallel_prg --files -k "$@" |
|
||||||
perl -pe 'chop;$_="\"\`cat $_; rm $_\`\" "' ) )"
|
perl -pe 'chop;$_="\"\`cat $_; rm $_\`\" "' ) )"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,10 +29,10 @@ env_parallel() {
|
||||||
# based on env_parallel.sh
|
# based on env_parallel.sh
|
||||||
|
|
||||||
_names_of_ALIASES() {
|
_names_of_ALIASES() {
|
||||||
alias | perl -pe 's/=.*//'
|
alias | perl -pe 's/^alias //;s/=.*//'
|
||||||
}
|
}
|
||||||
_bodies_of_ALIASES() {
|
_bodies_of_ALIASES() {
|
||||||
alias "$@" | perl -pe 's/^/alias /'
|
alias "$@" | perl -pe 's/^(alias )?/alias /'
|
||||||
}
|
}
|
||||||
_names_of_maybe_FUNCTIONS() {
|
_names_of_maybe_FUNCTIONS() {
|
||||||
set | perl -ne '/^(\S+)\(\)\{$/ and print "$1\n"'
|
set | perl -ne '/^(\S+)\(\)\{$/ and print "$1\n"'
|
||||||
|
@ -167,6 +167,8 @@ env_parallel() {
|
||||||
unset _list_alias_BODIES
|
unset _list_alias_BODIES
|
||||||
unset _list_variable_VALUES
|
unset _list_variable_VALUES
|
||||||
unset _list_function_BODIES
|
unset _list_function_BODIES
|
||||||
|
unset _grep_REGEXP
|
||||||
|
unset _ignore_UNDERSCORE
|
||||||
# Test if environment is too big
|
# Test if environment is too big
|
||||||
if `which true` >/dev/null ; then
|
if `which true` >/dev/null ; then
|
||||||
`which parallel` "$@";
|
`which parallel` "$@";
|
||||||
|
@ -184,3 +186,74 @@ env_parallel() {
|
||||||
return 255
|
return 255
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parset() {
|
||||||
|
_parset_parallel_prg=parallel
|
||||||
|
_parset_main "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
env_parset() {
|
||||||
|
_parset_parallel_prg=env_parallel
|
||||||
|
_parset_main "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
_parset_main() {
|
||||||
|
# If $1 contains ',' or space:
|
||||||
|
# Split on , to get the destination variable names
|
||||||
|
# If $1 is a single destination variable name:
|
||||||
|
# Treat it as the name of an array
|
||||||
|
#
|
||||||
|
# # Create array named myvar
|
||||||
|
# parset myvar echo ::: {1..10}
|
||||||
|
# echo ${myvar[5]}
|
||||||
|
#
|
||||||
|
# # Put output into $var_a $var_b $var_c
|
||||||
|
# varnames=(var_a var_b var_c)
|
||||||
|
# parset "${varnames[*]}" echo ::: {1..3}
|
||||||
|
# echo $var_c
|
||||||
|
#
|
||||||
|
# # Put output into $var_a4 $var_b4 $var_c4
|
||||||
|
# parset "var_a4 var_b4 var_c4" echo ::: {1..3}
|
||||||
|
# echo $var_c4
|
||||||
|
|
||||||
|
_parset_name="$1"
|
||||||
|
if [ "$_parset_name" = "" ] ; then
|
||||||
|
echo parset: Error: No destination variable given. >&2
|
||||||
|
echo parset: Error: Try: >&2
|
||||||
|
echo parset: Error: ' ' parset myarray echo ::: foo bar >&2
|
||||||
|
return 255
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
echo "$_parset_name" |
|
||||||
|
perl -ne 'chomp;for (split /[, ]/) {
|
||||||
|
# Allow: var_32 var[3]
|
||||||
|
if(not /^[a-zA-Z_][a-zA-Z_0-9]*(\[\d+\])?$/) {
|
||||||
|
print STDERR "parset: Error: $_ is an invalid variable name.\n";
|
||||||
|
print STDERR "parset: Error: Variable names must be letter followed by letters or digits.\n";
|
||||||
|
$exitval = 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exit $exitval;
|
||||||
|
' || return 255
|
||||||
|
if echo "$_parset_name" | grep -E ',| ' >/dev/null ; then
|
||||||
|
# $1 contains , or space
|
||||||
|
# Split on , or space to get the names
|
||||||
|
eval "$(
|
||||||
|
# Compute results into files
|
||||||
|
$_parset_parallel_prg --files -k "$@" |
|
||||||
|
# var1=`cat tmpfile1; rm tmpfile1`
|
||||||
|
# var2=`cat tmpfile2; rm tmpfile2`
|
||||||
|
parallel -q echo {2}='`cat {1}; rm {1}`' :::: - :::+ $(
|
||||||
|
echo "$_parset_name" |
|
||||||
|
perl -pe 's/,/ /g'
|
||||||
|
)
|
||||||
|
)"
|
||||||
|
else
|
||||||
|
# $1 contains no space or ,
|
||||||
|
# => $1 is the name of the array to put data into
|
||||||
|
# Supported in: bash
|
||||||
|
# Arrays do not work in: ash dash
|
||||||
|
eval $_parset_name="( $( $_parset_parallel_prg --files -k "$@" |
|
||||||
|
perl -pe 'chop;$_="\"\`cat $_; rm $_\`\" "' ) )"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
|
@ -157,6 +157,8 @@ env_parallel() {
|
||||||
unset _list_alias_BODIES
|
unset _list_alias_BODIES
|
||||||
unset _list_variable_VALUES
|
unset _list_variable_VALUES
|
||||||
unset _list_function_BODIES
|
unset _list_function_BODIES
|
||||||
|
unset _grep_REGEXP
|
||||||
|
unset _ignore_UNDERSCORE
|
||||||
# Test if environment is too big
|
# Test if environment is too big
|
||||||
if `which true` >/dev/null ; then
|
if `which true` >/dev/null ; then
|
||||||
`which parallel` "$@";
|
`which parallel` "$@";
|
||||||
|
@ -174,3 +176,75 @@ env_parallel() {
|
||||||
return 255
|
return 255
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parset() {
|
||||||
|
_parset_parallel_prg=parallel
|
||||||
|
_parset_main "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
env_parset() {
|
||||||
|
_parset_parallel_prg=env_parallel
|
||||||
|
_parset_main "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
_parset_main() {
|
||||||
|
# If $1 contains ',' or space:
|
||||||
|
# Split on , to get the destination variable names
|
||||||
|
# If $1 is a single destination variable name:
|
||||||
|
# Treat it as the name of an array
|
||||||
|
#
|
||||||
|
# # Create array named myvar
|
||||||
|
# parset myvar echo ::: {1..10}
|
||||||
|
# echo ${myvar[5]}
|
||||||
|
#
|
||||||
|
# # Put output into $var_a $var_b $var_c
|
||||||
|
# varnames=(var_a var_b var_c)
|
||||||
|
# parset "${varnames[*]}" echo ::: {1..3}
|
||||||
|
# echo $var_c
|
||||||
|
#
|
||||||
|
# # Put output into $var_a4 $var_b4 $var_c4
|
||||||
|
# parset "var_a4 var_b4 var_c4" echo ::: {1..3}
|
||||||
|
# echo $var_c4
|
||||||
|
|
||||||
|
_parset_name="$1"
|
||||||
|
if [ "$_parset_name" = "" ] ; then
|
||||||
|
echo parset: Error: No destination variable given. >&2
|
||||||
|
echo parset: Error: Try: >&2
|
||||||
|
echo parset: Error: ' ' parset myarray echo ::: foo bar >&2
|
||||||
|
return 255
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
echo "$_parset_name" |
|
||||||
|
perl -ne 'chomp;for (split /[, ]/) {
|
||||||
|
# Allow: var_32 var[3]
|
||||||
|
if(not /^[a-zA-Z_][a-zA-Z_0-9]*(\[\d+\])?$/) {
|
||||||
|
print STDERR "parset: Error: $_ is an invalid variable name.\n";
|
||||||
|
print STDERR "parset: Error: Variable names must be letter followed by letters or digits.\n";
|
||||||
|
$exitval = 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exit $exitval;
|
||||||
|
' || return 255
|
||||||
|
# Internal grep gives wrong exit code in Ksh
|
||||||
|
if echo "$_parset_name" | \grep -E ',| ' >/dev/null ; then
|
||||||
|
# $1 contains , or space
|
||||||
|
# Split on , or space to get the names
|
||||||
|
eval "$(
|
||||||
|
# Compute results into files
|
||||||
|
$_parset_parallel_prg --files -k "$@" |
|
||||||
|
# var1=`cat tmpfile1; rm tmpfile1`
|
||||||
|
# var2=`cat tmpfile2; rm tmpfile2`
|
||||||
|
parallel -q echo {2}='`cat {1}; rm {1}`' :::: - :::+ $(
|
||||||
|
echo "$_parset_name" |
|
||||||
|
perl -pe 's/,/ /g'
|
||||||
|
)
|
||||||
|
)"
|
||||||
|
else
|
||||||
|
# $1 contains no space or ,
|
||||||
|
# => $1 is the name of the array to put data into
|
||||||
|
# Supported in: bash
|
||||||
|
# Arrays do not work in: ash dash
|
||||||
|
eval $_parset_name="( $( $_parset_parallel_prg --files -k "$@" |
|
||||||
|
perl -pe 'chop;$_="\"\`cat $_; rm $_\`\" "' ) )"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
|
@ -29,10 +29,10 @@ env_parallel() {
|
||||||
# env_parallel.sh
|
# env_parallel.sh
|
||||||
|
|
||||||
_names_of_ALIASES() {
|
_names_of_ALIASES() {
|
||||||
alias | perl -pe 's/=.*//'
|
alias | perl -pe 's/^alias //;s/=.*//'
|
||||||
}
|
}
|
||||||
_bodies_of_ALIASES() {
|
_bodies_of_ALIASES() {
|
||||||
alias "$@" | perl -pe 's/^/alias /'
|
alias "$@" | perl -pe 's/^(alias )?/alias /'
|
||||||
}
|
}
|
||||||
_names_of_maybe_FUNCTIONS() {
|
_names_of_maybe_FUNCTIONS() {
|
||||||
set | perl -ne '/^(\S+)\(\)\{$/ and print "$1\n"'
|
set | perl -ne '/^(\S+)\(\)\{$/ and print "$1\n"'
|
||||||
|
@ -167,6 +167,8 @@ env_parallel() {
|
||||||
unset _list_alias_BODIES
|
unset _list_alias_BODIES
|
||||||
unset _list_variable_VALUES
|
unset _list_variable_VALUES
|
||||||
unset _list_function_BODIES
|
unset _list_function_BODIES
|
||||||
|
unset _grep_REGEXP
|
||||||
|
unset _ignore_UNDERSCORE
|
||||||
# Test if environment is too big
|
# Test if environment is too big
|
||||||
if `which true` >/dev/null ; then
|
if `which true` >/dev/null ; then
|
||||||
`which parallel` "$@";
|
`which parallel` "$@";
|
||||||
|
@ -184,3 +186,74 @@ env_parallel() {
|
||||||
return 255
|
return 255
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parset() {
|
||||||
|
_parset_parallel_prg=parallel
|
||||||
|
_parset_main "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
env_parset() {
|
||||||
|
_parset_parallel_prg=env_parallel
|
||||||
|
_parset_main "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
_parset_main() {
|
||||||
|
# If $1 contains ',' or space:
|
||||||
|
# Split on , to get the destination variable names
|
||||||
|
# If $1 is a single destination variable name:
|
||||||
|
# Treat it as the name of an array
|
||||||
|
#
|
||||||
|
# # Create array named myvar
|
||||||
|
# parset myvar echo ::: {1..10}
|
||||||
|
# echo ${myvar[5]}
|
||||||
|
#
|
||||||
|
# # Put output into $var_a $var_b $var_c
|
||||||
|
# varnames=(var_a var_b var_c)
|
||||||
|
# parset "${varnames[*]}" echo ::: {1..3}
|
||||||
|
# echo $var_c
|
||||||
|
#
|
||||||
|
# # Put output into $var_a4 $var_b4 $var_c4
|
||||||
|
# parset "var_a4 var_b4 var_c4" echo ::: {1..3}
|
||||||
|
# echo $var_c4
|
||||||
|
|
||||||
|
_parset_name="$1"
|
||||||
|
if [ "$_parset_name" = "" ] ; then
|
||||||
|
echo parset: Error: No destination variable given. >&2
|
||||||
|
echo parset: Error: Try: >&2
|
||||||
|
echo parset: Error: ' ' parset myarray echo ::: foo bar >&2
|
||||||
|
return 255
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
echo "$_parset_name" |
|
||||||
|
perl -ne 'chomp;for (split /[, ]/) {
|
||||||
|
# Allow: var_32 var[3]
|
||||||
|
if(not /^[a-zA-Z_][a-zA-Z_0-9]*(\[\d+\])?$/) {
|
||||||
|
print STDERR "parset: Error: $_ is an invalid variable name.\n";
|
||||||
|
print STDERR "parset: Error: Variable names must be letter followed by letters or digits.\n";
|
||||||
|
$exitval = 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exit $exitval;
|
||||||
|
' || return 255
|
||||||
|
if echo "$_parset_name" | grep -E ',| ' >/dev/null ; then
|
||||||
|
# $1 contains , or space
|
||||||
|
# Split on , or space to get the names
|
||||||
|
eval "$(
|
||||||
|
# Compute results into files
|
||||||
|
$_parset_parallel_prg --files -k "$@" |
|
||||||
|
# var1=`cat tmpfile1; rm tmpfile1`
|
||||||
|
# var2=`cat tmpfile2; rm tmpfile2`
|
||||||
|
parallel -q echo {2}='`cat {1}; rm {1}`' :::: - :::+ $(
|
||||||
|
echo "$_parset_name" |
|
||||||
|
perl -pe 's/,/ /g'
|
||||||
|
)
|
||||||
|
)"
|
||||||
|
else
|
||||||
|
# $1 contains no space or ,
|
||||||
|
# => $1 is the name of the array to put data into
|
||||||
|
# Supported in: bash
|
||||||
|
# Arrays do not work in: ash dash
|
||||||
|
eval $_parset_name="( $( $_parset_parallel_prg --files -k "$@" |
|
||||||
|
perl -pe 'chop;$_="\"\`cat $_; rm $_\`\" "' ) )"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
|
@ -162,3 +162,75 @@ env_parallel() {
|
||||||
unset PARALLEL_ENV;
|
unset PARALLEL_ENV;
|
||||||
return $_parallel_exit_CODE
|
return $_parallel_exit_CODE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parset() {
|
||||||
|
_parset_parallel_prg=parallel
|
||||||
|
_parset_main "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
env_parset() {
|
||||||
|
_parset_parallel_prg=env_parallel
|
||||||
|
_parset_main "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
_parset_main() {
|
||||||
|
# If $1 contains ',' or space:
|
||||||
|
# Split on , to get the destination variable names
|
||||||
|
# If $1 is a single destination variable name:
|
||||||
|
# Treat it as the name of an array
|
||||||
|
#
|
||||||
|
# # Create array named myvar
|
||||||
|
# parset myvar echo ::: {1..10}
|
||||||
|
# echo ${myvar[5]}
|
||||||
|
#
|
||||||
|
# # Put output into $var_a $var_b $var_c
|
||||||
|
# varnames=(var_a var_b var_c)
|
||||||
|
# parset "${varnames[*]}" echo ::: {1..3}
|
||||||
|
# echo $var_c
|
||||||
|
#
|
||||||
|
# # Put output into $var_a4 $var_b4 $var_c4
|
||||||
|
# parset "var_a4 var_b4 var_c4" echo ::: {1..3}
|
||||||
|
# echo $var_c4
|
||||||
|
|
||||||
|
_parset_name="$1"
|
||||||
|
if [ "$_parset_name" = "" ] ; then
|
||||||
|
echo parset: Error: No destination variable given. >&2
|
||||||
|
echo parset: Error: Try: >&2
|
||||||
|
echo parset: Error: ' ' parset myarray echo ::: foo bar >&2
|
||||||
|
return 255
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
echo "$_parset_name" |
|
||||||
|
perl -ne 'chomp;for (split /[, ]/) {
|
||||||
|
# Allow: var_32 var[3]
|
||||||
|
if(not /^[a-zA-Z_][a-zA-Z_0-9]*(\[\d+\])?$/) {
|
||||||
|
print STDERR "parset: Error: $_ is an invalid variable name.\n";
|
||||||
|
print STDERR "parset: Error: Variable names must be letter followed by letters or digits.\n";
|
||||||
|
$exitval = 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exit $exitval;
|
||||||
|
' || return 255
|
||||||
|
if echo "$_parset_name" | grep -E ',| ' >/dev/null ; then
|
||||||
|
# $1 contains , or space
|
||||||
|
# Split on , or space to get the names
|
||||||
|
eval "$(
|
||||||
|
# Compute results into files
|
||||||
|
$_parset_parallel_prg --files -k "$@" |
|
||||||
|
# var1=`cat tmpfile1; rm tmpfile1`
|
||||||
|
# var2=`cat tmpfile2; rm tmpfile2`
|
||||||
|
parallel -q echo {2}='`cat {1}; rm {1}`' :::: - :::+ $(
|
||||||
|
echo "$_parset_name" |
|
||||||
|
perl -pe 's/,/ /g'
|
||||||
|
)
|
||||||
|
)"
|
||||||
|
else
|
||||||
|
# $1 contains no space or ,
|
||||||
|
# => $1 is the name of the array to put data into
|
||||||
|
# Supported in: bash
|
||||||
|
# Arrays do not work in: ash dash
|
||||||
|
eval $_parset_name="( $( $_parset_parallel_prg --files -k "$@" |
|
||||||
|
perl -pe 'chop;$_="\"\`cat $_; rm $_\`\" "' ) )"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use Getopt::Long;
|
use Getopt::Long;
|
||||||
$Global::progname="niceload";
|
$Global::progname="niceload";
|
||||||
$Global::version = 20171122;
|
$Global::version = 20171123;
|
||||||
Getopt::Long::Configure("bundling","require_order");
|
Getopt::Long::Configure("bundling","require_order");
|
||||||
get_options_from_array(\@ARGV) || die_usage();
|
get_options_from_array(\@ARGV) || die_usage();
|
||||||
if($opt::version) {
|
if($opt::version) {
|
||||||
|
|
|
@ -1383,7 +1383,7 @@ sub check_invalid_option_combinations {
|
||||||
|
|
||||||
sub init_globals {
|
sub init_globals {
|
||||||
# Defaults:
|
# Defaults:
|
||||||
$Global::version = 20171122;
|
$Global::version = 20171123;
|
||||||
$Global::progname = 'parallel';
|
$Global::progname = 'parallel';
|
||||||
$Global::infinity = 2**31;
|
$Global::infinity = 2**31;
|
||||||
$Global::debug = 0;
|
$Global::debug = 0;
|
||||||
|
|
|
@ -11,13 +11,18 @@ parset - set shell variables in parallel
|
||||||
|
|
||||||
B<parset> I<variablename> [options for GNU Parallel]
|
B<parset> I<variablename> [options for GNU Parallel]
|
||||||
|
|
||||||
|
B<env_parset> I<variablename> [options for GNU Parallel] (alpha testing)
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
B<parset> is a shell function that puts the output from GNU
|
B<parset> is a shell function that puts the output from GNU
|
||||||
B<parallel> into shell variables.
|
B<parallel> into shell variables.
|
||||||
|
|
||||||
The B<parset> function is defined as part of B<env_parallel>.
|
B<env_parset> is a shell function that puts the output from
|
||||||
|
B<env_parallel> into shell variables.
|
||||||
|
|
||||||
|
The B<parset> and B<env_parset> functions are defined as part of
|
||||||
|
B<env_parallel>.
|
||||||
|
|
||||||
If I<variablename> is a single variable name, this will be treated as
|
If I<variablename> is a single variable name, this will be treated as
|
||||||
the destination variable and made into an array.
|
the destination variable and made into an array.
|
||||||
|
@ -25,10 +30,6 @@ the destination variable and made into an array.
|
||||||
If I<variablename> contains multiple names separated by ',' or space,
|
If I<variablename> contains multiple names separated by ',' or space,
|
||||||
the names will be the destination variables.
|
the names will be the destination variables.
|
||||||
|
|
||||||
The last bug in B<parset> was discovered 2017-06-29, so the code is
|
|
||||||
ready for being tested widely. Please use it for everyday use and
|
|
||||||
report bugs.
|
|
||||||
|
|
||||||
|
|
||||||
=head1 OPTIONS
|
=head1 OPTIONS
|
||||||
|
|
||||||
|
@ -38,7 +39,7 @@ variable.
|
||||||
|
|
||||||
=head1 SUPPORTED SHELLS
|
=head1 SUPPORTED SHELLS
|
||||||
|
|
||||||
=head2 Bash
|
=head2 Bash/Zsh/Ksh
|
||||||
|
|
||||||
=head3 Examples
|
=head3 Examples
|
||||||
|
|
||||||
|
@ -60,10 +61,10 @@ Put output into vars B<$seq, $pwd, $ls>:
|
||||||
|
|
||||||
The commands to run can be an array:
|
The commands to run can be an array:
|
||||||
|
|
||||||
cmd=("echo '<<joe \"double space\" cartoon>>'" "pwd")
|
cmd=("echo first" "echo '<<joe \"double space\" cartoon>>'" "pwd")
|
||||||
parset data ::: "${cmd[@]}"
|
parset data ::: "${cmd[@]}"
|
||||||
echo "${data[0]}"
|
|
||||||
echo "${data[1]}"
|
echo "${data[1]}"
|
||||||
|
echo "${data[2]}"
|
||||||
|
|
||||||
B<parset> can not be part of a pipe. In particular this means it
|
B<parset> can not be part of a pipe. In particular this means it
|
||||||
cannot read anything from standard input (stdin) or write to a pipe:
|
cannot read anything from standard input (stdin) or write to a pipe:
|
||||||
|
@ -74,7 +75,7 @@ but must instead use a tempfile:
|
||||||
|
|
||||||
seq 10 > parallel_input
|
seq 10 > parallel_input
|
||||||
parset res echo :::: parallel_input
|
parset res echo :::: parallel_input
|
||||||
echo "${res[0]}"
|
echo "${res[1]}"
|
||||||
echo "${res[9]}"
|
echo "${res[9]}"
|
||||||
|
|
||||||
or a FIFO:
|
or a FIFO:
|
||||||
|
@ -82,24 +83,82 @@ or a FIFO:
|
||||||
mkfifo input_fifo
|
mkfifo input_fifo
|
||||||
seq 30 > input_fifo &
|
seq 30 > input_fifo &
|
||||||
parset res echo :::: input_fifo
|
parset res echo :::: input_fifo
|
||||||
echo "${res[0]}"
|
echo "${res[1]}"
|
||||||
echo "${res[29]}"
|
echo "${res[29]}"
|
||||||
|
|
||||||
or Bash process substitution:
|
or Bash/Zsh/Ksh process substitution:
|
||||||
|
|
||||||
parset res echo :::: <(seq 100)
|
parset res echo :::: <(seq 100)
|
||||||
echo "${res[0]}"
|
echo "${res[1]}"
|
||||||
echo "${res[99]}"
|
echo "${res[99]}"
|
||||||
|
|
||||||
=head3 Installation
|
=head3 Installation
|
||||||
|
|
||||||
Put this in B<$HOME/.bashrc>:
|
Put this in the relevant B<$HOME/.bashrc> or B<$HOME/.zshenv> or B<$HOME/.kshrc>:
|
||||||
|
|
||||||
. `which env_parallel.bash`
|
. `which env_parallel.bash`
|
||||||
|
. `which env_parallel.zsh`
|
||||||
|
source `which env_parallel.ksh`
|
||||||
|
|
||||||
E.g. by doing:
|
E.g. by doing:
|
||||||
|
|
||||||
echo '. `which env_parallel.bash`' >> $HOME/.bashrc
|
echo '. `which env_parallel.bash`' >> $HOME/.bashrc
|
||||||
|
echo '. `which env_parallel.zsh`' >> $HOME/.zshenv
|
||||||
|
echo 'source `which env_parallel.ksh`' >> $HOME/.kshrc
|
||||||
|
|
||||||
|
or by doing:
|
||||||
|
|
||||||
|
env_parallel --install
|
||||||
|
|
||||||
|
|
||||||
|
=head2 ash/dash (FreeBSD's /bin/sh)
|
||||||
|
|
||||||
|
=head3 Examples
|
||||||
|
|
||||||
|
ash does not support arrays.
|
||||||
|
|
||||||
|
Put output into vars B<$seq, $pwd, $ls>:
|
||||||
|
|
||||||
|
parset "seq pwd ls" ::: "seq 10" pwd ls
|
||||||
|
echo "$ls"
|
||||||
|
|
||||||
|
B<parset> can not be part of a pipe. In particular this means it
|
||||||
|
cannot read anything from standard input (stdin) or write to a pipe:
|
||||||
|
|
||||||
|
seq 3 | parset res1,res2,res3 echo Does not work
|
||||||
|
|
||||||
|
but must instead use a tempfile:
|
||||||
|
|
||||||
|
seq 3 > parallel_input
|
||||||
|
parset res1,res2,res3 echo :::: parallel_input
|
||||||
|
echo "res1"
|
||||||
|
echo "res2"
|
||||||
|
echo "res3"
|
||||||
|
|
||||||
|
or a FIFO:
|
||||||
|
|
||||||
|
mkfifo input_fifo
|
||||||
|
seq 3 > input_fifo &
|
||||||
|
parset res1,res2,res3 echo :::: input_fifo
|
||||||
|
echo "res1"
|
||||||
|
echo "res2"
|
||||||
|
echo "res3"
|
||||||
|
|
||||||
|
=head3 Installation
|
||||||
|
|
||||||
|
Put the relevant one of these into B<$HOME/.profile>:
|
||||||
|
|
||||||
|
. `which env_parallel.sh`
|
||||||
|
. `which env_parallel.ash`
|
||||||
|
. `which env_parallel.dash`
|
||||||
|
|
||||||
|
E.g. by doing:
|
||||||
|
|
||||||
|
echo '. `which env_parallel.ash`' >> $HOME/.bashrc
|
||||||
|
|
||||||
|
or by doing:
|
||||||
|
|
||||||
|
env_parallel --install
|
||||||
|
|
||||||
|
|
||||||
=head1 EXIT STATUS
|
=head1 EXIT STATUS
|
||||||
|
|
|
@ -729,7 +729,7 @@ par_parcat_args_stdin() {
|
||||||
echo OK1 > $tmp1
|
echo OK1 > $tmp1
|
||||||
echo OK2 > $tmp2
|
echo OK2 > $tmp2
|
||||||
(echo $tmp1
|
(echo $tmp1
|
||||||
echo $tmp2) | parcat
|
echo $tmp2) | parcat | sort
|
||||||
rm $tmp1 $tmp2
|
rm $tmp1 $tmp2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -771,6 +771,25 @@ par_parset() {
|
||||||
parset 'myarray[6],myarray[5],myarray[4]' echo ::: baz bar foo
|
parset 'myarray[6],myarray[5],myarray[4]' echo ::: baz bar foo
|
||||||
echo ${myarray[*]}
|
echo ${myarray[*]}
|
||||||
echo ${myarray[4]} ${myarray[5]} ${myarray[5]}
|
echo ${myarray[4]} ${myarray[5]} ${myarray[5]}
|
||||||
|
|
||||||
|
echo '### env_parset'
|
||||||
|
alias myecho='echo myecho "$myvar" "${myarr[1]}"'
|
||||||
|
myvar="myvar"
|
||||||
|
myarr=("myarr 0" "myarr 1" "myarr 2")
|
||||||
|
mynewline="`echo newline1;echo newline2;`"
|
||||||
|
env_parset arr1 myecho ::: foo bar baz
|
||||||
|
echo "${arr1[0]} ${arr1[1]} ${arr1[2]}"
|
||||||
|
env_parset comma3,comma2,comma1 myecho ::: baz bar foo
|
||||||
|
echo "$comma1 $comma2 $comma3"
|
||||||
|
env_parset 'space3 space2 space1' myecho ::: baz bar foo
|
||||||
|
echo "$space1 $space2 $space3"
|
||||||
|
env_parset 'newline3 newline2 newline1' 'echo "$mynewline";seq' ::: 3 2 1
|
||||||
|
echo "$newline1"
|
||||||
|
echo "$newline2"
|
||||||
|
echo "$newline3"
|
||||||
|
env_parset 'myarray[6],myarray[5],myarray[4]' myecho ::: baz bar foo
|
||||||
|
echo "${myarray[*]}"
|
||||||
|
echo "${myarray[4]} ${myarray[5]} ${myarray[5]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
export -f $(compgen -A function | grep par_)
|
export -f $(compgen -A function | grep par_)
|
||||||
|
|
|
@ -946,27 +946,44 @@ par_bash_environment_too_big() {
|
||||||
echo 'bug #50815: env_parallel should warn if the environment is too big'
|
echo 'bug #50815: env_parallel should warn if the environment is too big'
|
||||||
. `which env_parallel.bash`;
|
. `which env_parallel.bash`;
|
||||||
|
|
||||||
bigvar="$(yes \"| head -c 76k)"
|
bigvar="$(perl -e 'print "x"x121000')"
|
||||||
env_parallel echo ::: OK
|
env_parallel echo ::: OK_bigvar
|
||||||
env_parallel -S lo echo ::: OK
|
env_parallel -S lo echo ::: OK_bigvar_remote
|
||||||
|
|
||||||
|
bigvar="$(perl -e 'print "\""x61000')"
|
||||||
|
env_parallel echo ::: OK_bigvar_quote
|
||||||
|
env_parallel -S lo echo ::: OK_bigvar_quote_remote
|
||||||
|
|
||||||
bigvar=u
|
bigvar=u
|
||||||
eval 'bigfunc() { a="'"$(yes a| head -c 115k)"'"; };'
|
eval 'bigfunc() { a="'"$(perl -e 'print "x"x122000')"'"; };'
|
||||||
env_parallel echo ::: OK
|
env_parallel echo ::: OK_bigfunc
|
||||||
env_parallel -S lo echo ::: OK
|
env_parallel -S lo echo ::: OK_bigfunc_remote
|
||||||
|
|
||||||
bigvar="$(yes | head -c 120k)"
|
eval 'bigfunc() { a="'"$(perl -e 'print "\""x122000')"'"; };'
|
||||||
env_parallel echo ::: fail
|
env_parallel echo ::: OK_bigfunc_quote
|
||||||
env_parallel -S lo echo ::: fail
|
env_parallel -S lo echo ::: OK_bigfunc_quote_remote
|
||||||
|
bigfunc() { true; }
|
||||||
|
|
||||||
bigvar="$(yes \"| head -c 80k)"
|
echo Rest should fail
|
||||||
env_parallel echo ::: fail
|
|
||||||
env_parallel -S lo echo ::: fail
|
bigvar="$(perl -e 'print "x"x123000')"
|
||||||
|
env_parallel echo ::: fail_bigvar
|
||||||
|
env_parallel -S lo echo ::: fail_bigvar_remote
|
||||||
|
|
||||||
|
bigvar="$(perl -e 'print "\""x62000')"
|
||||||
|
env_parallel echo ::: fail_bigvar_quote
|
||||||
|
env_parallel -S lo echo ::: fail_bigvar_quote_remote
|
||||||
|
|
||||||
bigvar=u
|
bigvar=u
|
||||||
eval 'bigfunc() { a="'"$(yes a| head -c 121k)"'"; };'
|
eval 'bigfunc() { a="'"$(perl -e 'print "x"x1230000')"'"; };'
|
||||||
env_parallel echo ::: fail
|
env_parallel echo ::: fail_bigfunc
|
||||||
env_parallel -S lo echo ::: fail
|
env_parallel -S lo echo ::: fail_bigfunc_remote
|
||||||
|
|
||||||
|
eval 'bigfunc() { a="'"$(perl -e 'print "\""x123000')"'"; };'
|
||||||
|
env_parallel echo ::: fail_bigfunc_quote
|
||||||
|
env_parallel -S lo echo ::: fail_bigfunc_quote_remote
|
||||||
|
|
||||||
|
bigfunc() { true; }
|
||||||
_EOF
|
_EOF
|
||||||
)
|
)
|
||||||
ssh bash@lo "$myscript"
|
ssh bash@lo "$myscript"
|
||||||
|
@ -976,33 +993,47 @@ par_dash_environment_too_big() {
|
||||||
myscript=$(cat <<'_EOF'
|
myscript=$(cat <<'_EOF'
|
||||||
echo 'bug #50815: env_parallel should warn if the environment is too big'
|
echo 'bug #50815: env_parallel should warn if the environment is too big'
|
||||||
. `which env_parallel.dash`;
|
. `which env_parallel.dash`;
|
||||||
|
|
||||||
bigvar="$(perl -e 'print "x"x130000')"
|
bigvar="$(perl -e 'print "x"x130000')"
|
||||||
env_parallel echo ::: OK
|
env_parallel echo ::: OK_bigvar
|
||||||
env_parallel -S lo echo ::: OK
|
env_parallel -S lo echo ::: OK_bigvar_remote
|
||||||
|
|
||||||
bigvar="$(perl -e 'print "\""x65000')"
|
bigvar="$(perl -e 'print "\""x65000')"
|
||||||
env_parallel echo ::: OK
|
env_parallel echo ::: OK_bigvar_quote
|
||||||
env_parallel -S lo echo ::: OK
|
env_parallel -S lo echo ::: OK_bigvar_quote_remote
|
||||||
|
|
||||||
# Functions not supported om ash
|
# Functions not supported in dash
|
||||||
# bigvar=u
|
# bigvar=u
|
||||||
# eval 'bigfunc() { a="'"$(perl -e 'print "\""x126000')"'"; };'
|
# eval 'bigfunc() { a="'"$(perl -e 'print "x"x122000')"'"; };'
|
||||||
# env_parallel echo ::: OK
|
# env_parallel echo ::: OK_bigfunc
|
||||||
# env_parallel -S lo echo ::: OK
|
# env_parallel -S lo echo ::: OK_bigfunc_remote
|
||||||
|
#
|
||||||
|
# eval 'bigfunc() { a="'"$(perl -e 'print "\""x122000')"'"; };'
|
||||||
|
# env_parallel echo ::: OK_bigfunc_quote
|
||||||
|
# env_parallel -S lo echo ::: OK_bigfunc_quote_remote
|
||||||
|
# bigfunc() { true; }
|
||||||
|
|
||||||
|
echo Rest should fail
|
||||||
|
|
||||||
bigvar="$(perl -e 'print "x"x131000')"
|
bigvar="$(perl -e 'print "x"x131000')"
|
||||||
env_parallel echo ::: fail
|
env_parallel echo ::: fail_bigvar
|
||||||
env_parallel -S lo echo ::: fail
|
env_parallel -S lo echo ::: fail_bigvar_remote
|
||||||
|
|
||||||
bigvar="$(perl -e 'print "\""x66000')"
|
bigvar="$(perl -e 'print "\""x66000')"
|
||||||
env_parallel echo ::: fail
|
env_parallel echo ::: fail_bigvar_quote
|
||||||
env_parallel -S lo echo ::: fail
|
env_parallel -S lo echo ::: fail_bigvar_quote_remote
|
||||||
|
|
||||||
# Functions not supported om ash
|
# Functions not supported in dash
|
||||||
# bigvar=u
|
# bigvar=u
|
||||||
# eval 'bigfunc() { a="'"$(perl -e 'print "\""x126000')"'"; };'
|
# eval 'bigfunc() { a="'"$(perl -e 'print "x"x1230000')"'"; };'
|
||||||
# env_parallel echo ::: OK
|
# env_parallel echo ::: fail_bigfunc
|
||||||
# env_parallel -S lo echo ::: OK
|
# env_parallel -S lo echo ::: fail_bigfunc_remote
|
||||||
|
#
|
||||||
|
# eval 'bigfunc() { a="'"$(perl -e 'print "\""x123000')"'"; };'
|
||||||
|
# env_parallel echo ::: fail_bigfunc_quote
|
||||||
|
# env_parallel -S lo echo ::: fail_bigfunc_quote_remote
|
||||||
|
#
|
||||||
|
# bigfunc() { true; }
|
||||||
_EOF
|
_EOF
|
||||||
)
|
)
|
||||||
ssh dash@lo "$myscript"
|
ssh dash@lo "$myscript"
|
||||||
|
@ -1012,33 +1043,47 @@ par_ash_environment_too_big() {
|
||||||
myscript=$(cat <<'_EOF'
|
myscript=$(cat <<'_EOF'
|
||||||
echo 'bug #50815: env_parallel should warn if the environment is too big'
|
echo 'bug #50815: env_parallel should warn if the environment is too big'
|
||||||
. `which env_parallel.ash`;
|
. `which env_parallel.ash`;
|
||||||
|
|
||||||
bigvar="$(perl -e 'print "x"x130000')"
|
bigvar="$(perl -e 'print "x"x130000')"
|
||||||
env_parallel echo ::: OK
|
env_parallel echo ::: OK_bigvar
|
||||||
env_parallel -S lo echo ::: OK
|
env_parallel -S lo echo ::: OK_bigvar_remote
|
||||||
|
|
||||||
bigvar="$(perl -e 'print "\""x65000')"
|
bigvar="$(perl -e 'print "\""x65000')"
|
||||||
env_parallel echo ::: OK
|
env_parallel echo ::: OK_bigvar_quote
|
||||||
env_parallel -S lo echo ::: OK
|
env_parallel -S lo echo ::: OK_bigvar_quote_remote
|
||||||
|
|
||||||
# Functions not supported in ash
|
# Functions not supported in ash
|
||||||
# bigvar=u
|
# bigvar=u
|
||||||
# eval 'bigfunc() { a="'"$(perl -e 'print "\""x126000')"'"; };'
|
# eval 'bigfunc() { a="'"$(perl -e 'print "x"x122000')"'"; };'
|
||||||
# env_parallel echo ::: OK
|
# env_parallel echo ::: OK_bigfunc
|
||||||
# env_parallel -S lo echo ::: OK
|
# env_parallel -S lo echo ::: OK_bigfunc_remote
|
||||||
|
#
|
||||||
|
# eval 'bigfunc() { a="'"$(perl -e 'print "\""x122000')"'"; };'
|
||||||
|
# env_parallel echo ::: OK_bigfunc_quote
|
||||||
|
# env_parallel -S lo echo ::: OK_bigfunc_quote_remote
|
||||||
|
# bigfunc() { true; }
|
||||||
|
|
||||||
|
echo Rest should fail
|
||||||
|
|
||||||
bigvar="$(perl -e 'print "x"x131000')"
|
bigvar="$(perl -e 'print "x"x131000')"
|
||||||
env_parallel echo ::: fail
|
env_parallel echo ::: fail_bigvar
|
||||||
env_parallel -S lo echo ::: fail
|
env_parallel -S lo echo ::: fail_bigvar_remote
|
||||||
|
|
||||||
bigvar="$(perl -e 'print "\""x66000')"
|
bigvar="$(perl -e 'print "\""x66000')"
|
||||||
env_parallel echo ::: fail
|
env_parallel echo ::: fail_bigvar_quote
|
||||||
env_parallel -S lo echo ::: fail
|
env_parallel -S lo echo ::: fail_bigvar_quote_remote
|
||||||
|
|
||||||
# Functions not supported in ash
|
# Functions not supported in ash
|
||||||
# bigvar=u
|
# bigvar=u
|
||||||
# eval 'bigfunc() { a="'"$(perl -e 'print "\""x126000')"'"; };'
|
# eval 'bigfunc() { a="'"$(perl -e 'print "x"x1230000')"'"; };'
|
||||||
# env_parallel echo ::: OK
|
# env_parallel echo ::: fail_bigfunc
|
||||||
# env_parallel -S lo echo ::: OK
|
# env_parallel -S lo echo ::: fail_bigfunc_remote
|
||||||
|
#
|
||||||
|
# eval 'bigfunc() { a="'"$(perl -e 'print "\""x123000')"'"; };'
|
||||||
|
# env_parallel echo ::: fail_bigfunc_quote
|
||||||
|
# env_parallel -S lo echo ::: fail_bigfunc_quote_remote
|
||||||
|
#
|
||||||
|
# bigfunc() { true; }
|
||||||
_EOF
|
_EOF
|
||||||
)
|
)
|
||||||
ssh ash@lo "$myscript"
|
ssh ash@lo "$myscript"
|
||||||
|
@ -1048,33 +1093,47 @@ par_sh_environment_too_big() {
|
||||||
myscript=$(cat <<'_EOF'
|
myscript=$(cat <<'_EOF'
|
||||||
echo 'bug #50815: env_parallel should warn if the environment is too big'
|
echo 'bug #50815: env_parallel should warn if the environment is too big'
|
||||||
. `which env_parallel.sh`;
|
. `which env_parallel.sh`;
|
||||||
|
|
||||||
bigvar="$(perl -e 'print "x"x130000')"
|
bigvar="$(perl -e 'print "x"x130000')"
|
||||||
env_parallel echo ::: OK
|
env_parallel echo ::: OK_bigvar
|
||||||
env_parallel -S lo echo ::: OK
|
env_parallel -S lo echo ::: OK_bigvar_remote
|
||||||
|
|
||||||
bigvar="$(perl -e 'print "\""x65000')"
|
bigvar="$(perl -e 'print "\""x65000')"
|
||||||
env_parallel echo ::: OK
|
env_parallel echo ::: OK_bigvar_quote
|
||||||
env_parallel -S lo echo ::: OK
|
env_parallel -S lo echo ::: OK_bigvar_quote_remote
|
||||||
|
|
||||||
# Functions not supported on GNU/Linux
|
# Functions not supported in sh
|
||||||
# bigvar=u
|
# bigvar=u
|
||||||
# eval 'bigfunc() { a="'"$(perl -e 'print "\\\""x133000')"'"; };'
|
# eval 'bigfunc() { a="'"$(perl -e 'print "x"x122000')"'"; };'
|
||||||
# env_parallel echo ::: OK
|
# env_parallel echo ::: OK_bigfunc
|
||||||
# env_parallel -S lo echo ::: OK
|
# env_parallel -S lo echo ::: OK_bigfunc_remote
|
||||||
|
#
|
||||||
|
# eval 'bigfunc() { a="'"$(perl -e 'print "\""x122000')"'"; };'
|
||||||
|
# env_parallel echo ::: OK_bigfunc_quote
|
||||||
|
# env_parallel -S lo echo ::: OK_bigfunc_quote_remote
|
||||||
|
# bigfunc() { true; }
|
||||||
|
|
||||||
|
echo Rest should fail
|
||||||
|
|
||||||
bigvar="$(perl -e 'print "x"x131000')"
|
bigvar="$(perl -e 'print "x"x131000')"
|
||||||
env_parallel echo ::: fail
|
env_parallel echo ::: fail_bigvar
|
||||||
env_parallel -S lo echo ::: fail
|
env_parallel -S lo echo ::: fail_bigvar_remote
|
||||||
|
|
||||||
bigvar="$(perl -e 'print "\""x66000')"
|
bigvar="$(perl -e 'print "\""x66000')"
|
||||||
env_parallel echo ::: fail
|
env_parallel echo ::: fail_bigvar_quote
|
||||||
env_parallel -S lo echo ::: fail
|
env_parallel -S lo echo ::: fail_bigvar_quote_remote
|
||||||
|
|
||||||
# Functions not supported on GNU/Linux
|
# Functions not supported in sh
|
||||||
# bigvar=u
|
# bigvar=u
|
||||||
# eval 'bigfunc() { a="'"$(perl -e 'print "\""x132000')"'"; };'
|
# eval 'bigfunc() { a="'"$(perl -e 'print "x"x1230000')"'"; };'
|
||||||
# env_parallel echo ::: fail
|
# env_parallel echo ::: fail_bigfunc
|
||||||
# env_parallel -S lo echo ::: fail
|
# env_parallel -S lo echo ::: fail_bigfunc_remote
|
||||||
|
#
|
||||||
|
# eval 'bigfunc() { a="'"$(perl -e 'print "\""x123000')"'"; };'
|
||||||
|
# env_parallel echo ::: fail_bigfunc_quote
|
||||||
|
# env_parallel -S lo echo ::: fail_bigfunc_quote_remote
|
||||||
|
#
|
||||||
|
# bigfunc() { true; }
|
||||||
_EOF
|
_EOF
|
||||||
)
|
)
|
||||||
ssh sh@lo "$myscript"
|
ssh sh@lo "$myscript"
|
||||||
|
@ -1084,31 +1143,45 @@ par_zsh_environment_too_big() {
|
||||||
myscript=$(cat <<'_EOF'
|
myscript=$(cat <<'_EOF'
|
||||||
echo 'bug #50815: env_parallel should warn if the environment is too big'
|
echo 'bug #50815: env_parallel should warn if the environment is too big'
|
||||||
. `which env_parallel.zsh`;
|
. `which env_parallel.zsh`;
|
||||||
bigvar="$(perl -e 'print "x"x122000')"
|
|
||||||
env_parallel echo ::: OK
|
|
||||||
env_parallel -S lo echo ::: OK
|
|
||||||
|
|
||||||
bigvar="$(perl -e 'print "\""x122000')"
|
bigvar="$(perl -e 'print "x"x120000')"
|
||||||
env_parallel echo ::: OK
|
env_parallel echo ::: OK_bigvar
|
||||||
env_parallel -S lo echo ::: OK
|
env_parallel -S lo echo ::: OK_bigvar_remote
|
||||||
|
|
||||||
|
bigvar="$(perl -e 'print "\""x120000')"
|
||||||
|
env_parallel echo ::: OK_bigvar_quote
|
||||||
|
env_parallel -S lo echo ::: OK_bigvar_quote_remote
|
||||||
|
|
||||||
bigvar=u
|
bigvar=u
|
||||||
eval 'bigfunc() { a="'"$(perl -e 'print "x"x122000')"'"; };'
|
eval 'bigfunc() { a="'"$(perl -e 'print "x"x120000')"'"; };'
|
||||||
env_parallel echo ::: OK
|
env_parallel echo ::: OK_bigfunc
|
||||||
env_parallel -S lo echo ::: OK
|
env_parallel -S lo echo ::: OK_bigfunc_remote
|
||||||
|
|
||||||
bigvar="$(perl -e 'print "x"x123000')"
|
eval 'bigfunc() { a="'"$(perl -e 'print "\""x120000')"'"; };'
|
||||||
env_parallel echo ::: fail
|
env_parallel echo ::: OK_bigfunc_quote
|
||||||
env_parallel -S lo echo ::: fail
|
env_parallel -S lo echo ::: OK_bigfunc_quote_remote
|
||||||
|
bigfunc() { true; }
|
||||||
|
|
||||||
|
echo Rest should fail
|
||||||
|
|
||||||
|
bigvar="$(perl -e 'print "x"x121000')"
|
||||||
|
env_parallel echo ::: fail_bigvar
|
||||||
|
env_parallel -S lo echo ::: fail_bigvar_remote
|
||||||
|
|
||||||
bigvar="$(perl -e 'print "\""x123000')"
|
bigvar="$(perl -e 'print "\""x123000')"
|
||||||
env_parallel echo ::: fail
|
env_parallel echo ::: fail_bigvar_quote
|
||||||
env_parallel -S lo echo ::: fail
|
env_parallel -S lo echo ::: fail_bigvar_quote_remote
|
||||||
|
|
||||||
bigvar=u
|
bigvar=u
|
||||||
eval 'bigfunc() { a="'"$(perl -e 'print "x"x123000')"'"; };'
|
eval 'bigfunc() { a="'"$(perl -e 'print "x"x1210000')"'"; };'
|
||||||
env_parallel echo ::: fail
|
env_parallel echo ::: fail_bigfunc
|
||||||
env_parallel -S lo echo ::: fail
|
env_parallel -S lo echo ::: fail_bigfunc_remote
|
||||||
|
|
||||||
|
eval 'bigfunc() { a="'"$(perl -e 'print "\""x121000')"'"; };'
|
||||||
|
env_parallel echo ::: fail_bigfunc_quote
|
||||||
|
env_parallel -S lo echo ::: fail_bigfunc_quote_remote
|
||||||
|
|
||||||
|
bigfunc() { true; }
|
||||||
_EOF
|
_EOF
|
||||||
)
|
)
|
||||||
ssh zsh@lo "$myscript"
|
ssh zsh@lo "$myscript"
|
||||||
|
@ -1118,32 +1191,45 @@ par_ksh_environment_too_big() {
|
||||||
myscript=$(cat <<'_EOF'
|
myscript=$(cat <<'_EOF'
|
||||||
echo 'bug #50815: env_parallel should warn if the environment is too big'
|
echo 'bug #50815: env_parallel should warn if the environment is too big'
|
||||||
. `which env_parallel.ksh`;
|
. `which env_parallel.ksh`;
|
||||||
bigvar="$(perl -e 'print "x"x125000')"
|
|
||||||
env_parallel echo ::: OK
|
|
||||||
bigvar="$(perl -e 'print "x"x124000')"
|
|
||||||
env_parallel -S lo echo ::: OK
|
|
||||||
|
|
||||||
bigvar="$(perl -e 'print "\""x124000')"
|
bigvar="$(perl -e 'print "x"x122000')"
|
||||||
env_parallel echo ::: OK
|
env_parallel echo ::: OK_bigvar
|
||||||
env_parallel -S lo echo ::: OK
|
env_parallel -S lo echo ::: OK_bigvar_remote
|
||||||
|
|
||||||
|
bigvar="$(perl -e 'print "\""x122000')"
|
||||||
|
env_parallel echo ::: OK_bigvar_quote
|
||||||
|
env_parallel -S lo echo ::: OK_bigvar_quote_remote
|
||||||
|
|
||||||
bigvar=u
|
bigvar=u
|
||||||
eval 'bigfunc() { a="'"$(perl -e 'print "\""x124000')"'"; };'
|
eval 'bigfunc() { a="'"$(perl -e 'print "x"x122000')"'"; };'
|
||||||
env_parallel echo ::: OK
|
env_parallel echo ::: OK_bigfunc
|
||||||
env_parallel -S lo echo ::: OK
|
env_parallel -S lo echo ::: OK_bigfunc_remote
|
||||||
|
|
||||||
bigvar="$(perl -e 'print "x"x126000')"
|
eval 'bigfunc() { a="'"$(perl -e 'print "\""x122000')"'"; };'
|
||||||
env_parallel echo ::: fail
|
env_parallel echo ::: OK_bigfunc_quote
|
||||||
env_parallel -S lo echo ::: fail
|
env_parallel -S lo echo ::: OK_bigfunc_quote_remote
|
||||||
|
bigfunc() { true; }
|
||||||
|
|
||||||
bigvar="$(perl -e 'print "\""x125000')"
|
echo Rest should fail
|
||||||
env_parallel echo ::: fail
|
|
||||||
env_parallel -S lo echo ::: fail
|
bigvar="$(perl -e 'print "x"x123000')"
|
||||||
|
env_parallel echo ::: fail_bigvar
|
||||||
|
env_parallel -S lo echo ::: fail_bigvar_remote
|
||||||
|
|
||||||
|
bigvar="$(perl -e 'print "\""x123000')"
|
||||||
|
env_parallel echo ::: fail_bigvar_quote
|
||||||
|
env_parallel -S lo echo ::: fail_bigvar_quote_remote
|
||||||
|
|
||||||
bigvar=u
|
bigvar=u
|
||||||
eval 'bigfunc() { a="'"$(perl -e 'print "\""x125000')"'"; };'
|
eval 'bigfunc() { a="'"$(perl -e 'print "x"x1230000')"'"; };'
|
||||||
env_parallel echo ::: fail
|
env_parallel echo ::: fail_bigfunc
|
||||||
env_parallel -S lo echo ::: fail
|
env_parallel -S lo echo ::: fail_bigfunc_remote
|
||||||
|
|
||||||
|
eval 'bigfunc() { a="'"$(perl -e 'print "\""x123000')"'"; };'
|
||||||
|
env_parallel echo ::: fail_bigfunc_quote
|
||||||
|
env_parallel -S lo echo ::: fail_bigfunc_quote_remote
|
||||||
|
|
||||||
|
bigfunc() { true; }
|
||||||
_EOF
|
_EOF
|
||||||
)
|
)
|
||||||
ssh ksh@lo "$myscript"
|
ssh ksh@lo "$myscript"
|
||||||
|
@ -1161,7 +1247,391 @@ par_tcsh_environment_too_big() {
|
||||||
echo Not implemented
|
echo Not implemented
|
||||||
}
|
}
|
||||||
|
|
||||||
|
par_bash_parset() {
|
||||||
|
myscript=$(cat <<'_EOF'
|
||||||
|
echo 'parset'
|
||||||
|
. `which env_parallel.bash`
|
||||||
|
|
||||||
|
echo '### parset into array'
|
||||||
|
parset arr1 echo ::: foo bar baz
|
||||||
|
echo ${arr1[0]} ${arr1[1]} ${arr1[2]}
|
||||||
|
|
||||||
|
echo '### parset into vars with comma'
|
||||||
|
parset comma3,comma2,comma1 echo ::: baz bar foo
|
||||||
|
echo $comma1 $comma2 $comma3
|
||||||
|
|
||||||
|
echo '### parset into vars with space'
|
||||||
|
parset 'space3 space2 space1' echo ::: baz bar foo
|
||||||
|
echo $space1 $space2 $space3
|
||||||
|
|
||||||
|
echo '### parset with newlines'
|
||||||
|
parset 'newline3 newline2 newline1' seq ::: 3 2 1
|
||||||
|
echo "$newline1"
|
||||||
|
echo "$newline2"
|
||||||
|
echo "$newline3"
|
||||||
|
|
||||||
|
echo '### parset into indexed array vars'
|
||||||
|
parset 'myarray[6],myarray[5],myarray[4]' echo ::: baz bar foo
|
||||||
|
echo ${myarray[*]}
|
||||||
|
echo ${myarray[4]} ${myarray[5]} ${myarray[6]}
|
||||||
|
|
||||||
|
echo '### env_parset'
|
||||||
|
myfun() {
|
||||||
|
myecho myfun "$@";
|
||||||
|
}
|
||||||
|
alias myecho='echo myecho "$myvar" "${myarr[1]}"'
|
||||||
|
myvar="myvar"
|
||||||
|
myarr=("myarr 0" "myarr 1" "myarr 2")
|
||||||
|
mynewline="`echo newline1;echo newline2;`"
|
||||||
|
env_parset arr1 myfun ::: foo bar baz
|
||||||
|
echo "${arr1[0]} ${arr1[1]} ${arr1[2]}"
|
||||||
|
env_parset comma3,comma2,comma1 myfun ::: baz bar foo
|
||||||
|
echo "$comma1 $comma2 $comma3"
|
||||||
|
env_parset 'space3 space2 space1' myfum ::: baz bar foo
|
||||||
|
echo "$space1 $space2 $space3"
|
||||||
|
env_parset 'newline3 newline2 newline1' 'echo "$mynewline";seq' ::: 3 2 1
|
||||||
|
echo "$newline1"
|
||||||
|
echo "$newline2"
|
||||||
|
echo "$newline3"
|
||||||
|
env_parset 'myarray[6],myarray[5],myarray[4]' myfun ::: baz bar foo
|
||||||
|
echo "${myarray[*]}"
|
||||||
|
echo "${myarray[4]} ${myarray[5]} ${myarray[6]}"
|
||||||
|
_EOF
|
||||||
|
)
|
||||||
|
ssh bash@lo "$myscript"
|
||||||
|
}
|
||||||
|
|
||||||
|
par_dash_parset() {
|
||||||
|
myscript=$(cat <<'_EOF'
|
||||||
|
echo 'parset'
|
||||||
|
. `which env_parallel.dash`
|
||||||
|
|
||||||
|
# Arrays not supported in dash
|
||||||
|
# echo '### parset into array'
|
||||||
|
# parset arr1 echo ::: foo bar baz
|
||||||
|
# echo ${arr1[0]} ${arr1[1]} ${arr1[2]}
|
||||||
|
|
||||||
|
echo '### parset into vars with comma'
|
||||||
|
parset comma3,comma2,comma1 echo ::: baz bar foo
|
||||||
|
echo $comma1 $comma2 $comma3
|
||||||
|
|
||||||
|
echo '### parset into vars with space'
|
||||||
|
parset 'space3 space2 space1' echo ::: baz bar foo
|
||||||
|
echo $space1 $space2 $space3
|
||||||
|
|
||||||
|
echo '### parset with newlines'
|
||||||
|
parset 'newline3 newline2 newline1' seq ::: 3 2 1
|
||||||
|
echo "$newline1"
|
||||||
|
echo "$newline2"
|
||||||
|
echo "$newline3"
|
||||||
|
|
||||||
|
# Arrays not supported in dash
|
||||||
|
# echo '### parset into indexed array vars'
|
||||||
|
# parset 'myarray[6],myarray[5],myarray[4]' echo ::: baz bar foo
|
||||||
|
# echo ${myarray[*]}
|
||||||
|
# echo ${myarray[4]} ${myarray[5]} ${myarray[6]}
|
||||||
|
|
||||||
|
echo '### env_parset'
|
||||||
|
myfun() {
|
||||||
|
myecho myfun "$@";
|
||||||
|
}
|
||||||
|
alias myecho='echo myecho "$myvar"'
|
||||||
|
myvar="myvar"
|
||||||
|
# Arrays not supported in dash
|
||||||
|
# myarr=("myarr 0" "myarr 1" "myarr 2")
|
||||||
|
mynewline="`echo newline1;echo newline2;`"
|
||||||
|
# Arrays not supported in dash
|
||||||
|
# env_parset arr1 myfun ::: foo bar baz
|
||||||
|
# echo "${arr1[0]} ${arr1[1]} ${arr1[2]}"
|
||||||
|
env_parset comma3,comma2,comma1 myecho ::: baz bar foo
|
||||||
|
echo "$comma1 $comma2 $comma3"
|
||||||
|
env_parset 'space3 space2 space1' myecho ::: baz bar foo
|
||||||
|
echo "$space1 $space2 $space3"
|
||||||
|
env_parset 'newline3 newline2 newline1' 'echo "$mynewline";seq' ::: 3 2 1
|
||||||
|
echo "$newline1"
|
||||||
|
echo "$newline2"
|
||||||
|
echo "$newline3"
|
||||||
|
# Arrays not supported in dash
|
||||||
|
# env_parset 'myarray[6],myarray[5],myarray[4]' myfun ::: baz bar foo
|
||||||
|
# echo "${myarray[*]}"
|
||||||
|
# echo "${myarray[4]} ${myarray[5]} ${myarray[6]}"
|
||||||
|
_EOF
|
||||||
|
)
|
||||||
|
ssh dash@lo "$myscript"
|
||||||
|
}
|
||||||
|
|
||||||
|
par_ash_parset() {
|
||||||
|
myscript=$(cat <<'_EOF'
|
||||||
|
echo 'parset'
|
||||||
|
. `which env_parallel.ash`
|
||||||
|
|
||||||
|
# Arrays not supported in ash
|
||||||
|
# echo '### parset into array'
|
||||||
|
# parset arr1 echo ::: foo bar baz
|
||||||
|
# echo ${arr1[0]} ${arr1[1]} ${arr1[2]}
|
||||||
|
|
||||||
|
echo '### parset into vars with comma'
|
||||||
|
parset comma3,comma2,comma1 echo ::: baz bar foo
|
||||||
|
echo $comma1 $comma2 $comma3
|
||||||
|
|
||||||
|
echo '### parset into vars with space'
|
||||||
|
parset 'space3 space2 space1' echo ::: baz bar foo
|
||||||
|
echo $space1 $space2 $space3
|
||||||
|
|
||||||
|
echo '### parset with newlines'
|
||||||
|
parset 'newline3 newline2 newline1' seq ::: 3 2 1
|
||||||
|
echo "$newline1"
|
||||||
|
echo "$newline2"
|
||||||
|
echo "$newline3"
|
||||||
|
|
||||||
|
# Arrays not supported in ash
|
||||||
|
# echo '### parset into indexed array vars'
|
||||||
|
# parset 'myarray[6],myarray[5],myarray[4]' echo ::: baz bar foo
|
||||||
|
# echo ${myarray[*]}
|
||||||
|
# echo ${myarray[4]} ${myarray[5]} ${myarray[6]}
|
||||||
|
|
||||||
|
echo '### env_parset'
|
||||||
|
myfun() {
|
||||||
|
myecho myfun "$@";
|
||||||
|
}
|
||||||
|
alias myecho='echo myecho "$myvar"'
|
||||||
|
myvar="myvar"
|
||||||
|
# Arrays not supported in ash
|
||||||
|
# myarr=("myarr 0" "myarr 1" "myarr 2")
|
||||||
|
mynewline="`echo newline1;echo newline2;`"
|
||||||
|
# Arrays not supported in ash
|
||||||
|
# env_parset arr1 myfun ::: foo bar baz
|
||||||
|
# echo "${arr1[0]} ${arr1[1]} ${arr1[2]}"
|
||||||
|
env_parset comma3,comma2,comma1 myecho ::: baz bar foo
|
||||||
|
echo "$comma1 $comma2 $comma3"
|
||||||
|
env_parset 'space3 space2 space1' myecho ::: baz bar foo
|
||||||
|
echo "$space1 $space2 $space3"
|
||||||
|
env_parset 'newline3 newline2 newline1' 'echo "$mynewline";seq' ::: 3 2 1
|
||||||
|
echo "$newline1"
|
||||||
|
echo "$newline2"
|
||||||
|
echo "$newline3"
|
||||||
|
# Arrays not supported in ash
|
||||||
|
# env_parset 'myarray[6],myarray[5],myarray[4]' myfun ::: baz bar foo
|
||||||
|
# echo "${myarray[*]}"
|
||||||
|
# echo "${myarray[4]} ${myarray[5]} ${myarray[6]}"
|
||||||
|
_EOF
|
||||||
|
)
|
||||||
|
ssh ash@lo "$myscript"
|
||||||
|
}
|
||||||
|
|
||||||
|
par_sh_parset() {
|
||||||
|
myscript=$(cat <<'_EOF'
|
||||||
|
echo 'parset'
|
||||||
|
. `which env_parallel.sh`
|
||||||
|
|
||||||
|
# echo '### parset into array'
|
||||||
|
# echo "Arrays not supported in all sh's"
|
||||||
|
# parset arr1 echo ::: foo bar baz
|
||||||
|
# echo ${arr1[0]} ${arr1[1]} ${arr1[2]}
|
||||||
|
|
||||||
|
echo '### parset into vars with comma'
|
||||||
|
parset comma3,comma2,comma1 echo ::: baz bar foo
|
||||||
|
echo $comma1 $comma2 $comma3
|
||||||
|
|
||||||
|
echo '### parset into vars with space'
|
||||||
|
parset 'space3 space2 space1' echo ::: baz bar foo
|
||||||
|
echo $space1 $space2 $space3
|
||||||
|
|
||||||
|
echo '### parset with newlines'
|
||||||
|
parset 'newline3 newline2 newline1' seq ::: 3 2 1
|
||||||
|
echo "$newline1"
|
||||||
|
echo "$newline2"
|
||||||
|
echo "$newline3"
|
||||||
|
|
||||||
|
# echo '### parset into indexed array vars'
|
||||||
|
# echo "Arrays not supported in all sh's"
|
||||||
|
# parset 'myarray[6],myarray[5],myarray[4]' echo ::: baz bar foo
|
||||||
|
# echo ${myarray[*]}
|
||||||
|
# echo ${myarray[4]} ${myarray[5]} ${myarray[6]}
|
||||||
|
|
||||||
|
echo '### env_parset'
|
||||||
|
echo '# alias'
|
||||||
|
alias myalias='echo myalias'
|
||||||
|
env_parset alias3,alias2,alias1 myalias ::: baz bar foo
|
||||||
|
echo "$alias1"
|
||||||
|
echo "$alias2"
|
||||||
|
echo "$alias3"
|
||||||
|
|
||||||
|
# echo '# function'
|
||||||
|
# echo "Arrays not supported in all sh's"
|
||||||
|
# myfun() {
|
||||||
|
# echo myfun "$@";
|
||||||
|
# }
|
||||||
|
# env_parset fun3,fun2,fun1 myfun ::: baz bar foo
|
||||||
|
# echo "$fun1"
|
||||||
|
# echo "$fun2"
|
||||||
|
# echo "$fun3"
|
||||||
|
|
||||||
|
echo '# variable with newline'
|
||||||
|
myvar="`echo newline1;echo newline2;`"
|
||||||
|
env_parset var3,var2,var1 'echo "$myvar"' ::: baz bar foo
|
||||||
|
echo "$var1"
|
||||||
|
echo "$var2"
|
||||||
|
echo "$var3"
|
||||||
|
|
||||||
|
# Arrays not supported in sh
|
||||||
|
# myarr=("myarr 0" "myarr 1" "myarr 2")
|
||||||
|
# Arrays not supported in sh
|
||||||
|
# env_parset arr1 myfun ::: foo bar baz
|
||||||
|
# echo "${arr1[0]} ${arr1[1]} ${arr1[2]}"
|
||||||
|
|
||||||
|
echo '### parset into vars with comma'
|
||||||
|
env_parset comma3,comma2,comma1 echo ::: baz bar foo
|
||||||
|
echo "$comma1 $comma2 $comma3"
|
||||||
|
echo '### parset into vars with space'
|
||||||
|
env_parset 'space3 space2 space1' echo ::: baz bar foo
|
||||||
|
echo "$space1 $space2 $space3"
|
||||||
|
echo '### parset with newlines'
|
||||||
|
mynewline="`echo newline1;echo newline2;`"
|
||||||
|
env_parset 'newline3 newline2 newline1' 'echo "$mynewline";seq' ::: 3 2 1
|
||||||
|
echo "$newline1"
|
||||||
|
echo "$newline2"
|
||||||
|
echo "$newline3"
|
||||||
|
# Arrays not supported in sh
|
||||||
|
# env_parset 'myarray[6],myarray[5],myarray[4]' myfun ::: baz bar foo
|
||||||
|
# echo "${myarray[*]}"
|
||||||
|
# echo "${myarray[4]} ${myarray[5]} ${myarray[6]}"
|
||||||
|
_EOF
|
||||||
|
)
|
||||||
|
ssh sh@lo "$myscript"
|
||||||
|
}
|
||||||
|
|
||||||
|
par_zsh_parset() {
|
||||||
|
myscript=$(cat <<'_EOF'
|
||||||
|
echo 'parset'
|
||||||
|
. `which env_parallel.zsh`
|
||||||
|
eval "`cat <<"_EOS";
|
||||||
|
|
||||||
|
echo '### parset into array'
|
||||||
|
parset arr1 echo ::: foo bar baz
|
||||||
|
echo ${arr1[1]} ${arr1[2]} ${arr1[3]}
|
||||||
|
|
||||||
|
echo '### parset into vars with comma'
|
||||||
|
parset comma3,comma2,comma1 echo ::: baz bar foo
|
||||||
|
echo $comma1 $comma2 $comma3
|
||||||
|
|
||||||
|
echo '### parset into vars with space'
|
||||||
|
parset 'space3 space2 space1' echo ::: baz bar foo
|
||||||
|
echo $space1 $space2 $space3
|
||||||
|
|
||||||
|
echo '### parset with newlines'
|
||||||
|
parset 'newline3 newline2 newline1' seq ::: 3 2 1
|
||||||
|
echo "$newline1"
|
||||||
|
echo "$newline2"
|
||||||
|
echo "$newline3"
|
||||||
|
|
||||||
|
echo '### parset into indexed array vars'
|
||||||
|
parset 'myarray[6],myarray[5],myarray[4]' echo ::: baz bar foo
|
||||||
|
echo ${myarray[*]}
|
||||||
|
echo ${myarray[4]} ${myarray[5]} ${myarray[6]}
|
||||||
|
|
||||||
|
echo '### env_parset'
|
||||||
|
alias myecho='echo myecho "$myvar" "${myarr[1]}"';
|
||||||
|
# eval is needed because zsh does not see alias in function otherwise
|
||||||
|
eval "myfun() {
|
||||||
|
myecho myfun \"\$\@\"
|
||||||
|
}"
|
||||||
|
myvar="myvar"
|
||||||
|
myarr=("myarr 0" "myarr 1" "myarr 2")
|
||||||
|
mynewline="$(echo newline1;echo newline2;)"
|
||||||
|
env_parset arr1 myfun {} ::: foo bar baz
|
||||||
|
echo "${arr1[1]}"
|
||||||
|
echo "${arr1[2]}"
|
||||||
|
echo "${arr1[3]}"
|
||||||
|
env_parset comma3,comma2,comma1 myfun ::: baz bar foo
|
||||||
|
echo "$comma1"
|
||||||
|
echo "$comma2"
|
||||||
|
echo "$comma3"
|
||||||
|
env_parset 'space3 space2 space1' myfun ::: baz bar foo
|
||||||
|
echo "$space1"
|
||||||
|
echo "$space2"
|
||||||
|
echo "$space3"
|
||||||
|
env_parset 'newline3 newline2 newline1' 'echo "$mynewline";seq' ::: 3 2 1
|
||||||
|
echo "$newline1"
|
||||||
|
echo "$newline2"
|
||||||
|
echo "$newline3"
|
||||||
|
env_parset 'myarray[6],myarray[5],myarray[4]' myfun ::: baz bar foo
|
||||||
|
echo "${myarray[*]}"
|
||||||
|
echo "${myarray[4]} ${myarray[5]} ${myarray[6]}"
|
||||||
|
_EOS`"
|
||||||
|
_EOF
|
||||||
|
)
|
||||||
|
ssh zsh@lo "$myscript"
|
||||||
|
}
|
||||||
|
|
||||||
|
par_ksh_parset() {
|
||||||
|
myscript=$(cat <<'_EOF'
|
||||||
|
echo 'parset'
|
||||||
|
. `which env_parallel.ksh`
|
||||||
|
|
||||||
|
echo '### parset into array'
|
||||||
|
parset arr1 echo ::: foo bar baz
|
||||||
|
echo ${arr1[0]} ${arr1[1]} ${arr1[2]}
|
||||||
|
|
||||||
|
echo '### parset into vars with comma'
|
||||||
|
parset comma3,comma2,comma1 echo ::: baz bar foo
|
||||||
|
echo $comma1 $comma2 $comma3
|
||||||
|
|
||||||
|
echo '### parset into vars with space'
|
||||||
|
parset 'space3 space2 space1' echo ::: baz bar foo
|
||||||
|
echo $space1 $space2 $space3
|
||||||
|
|
||||||
|
echo '### parset with newlines'
|
||||||
|
parset 'newline3 newline2 newline1' seq ::: 3 2 1
|
||||||
|
echo "$newline1"
|
||||||
|
echo "$newline2"
|
||||||
|
echo "$newline3"
|
||||||
|
|
||||||
|
echo '### parset into indexed array vars'
|
||||||
|
parset 'myarray[6],myarray[5],myarray[4]' echo ::: baz bar foo
|
||||||
|
echo ${myarray[*]}
|
||||||
|
echo ${myarray[4]} ${myarray[5]} ${myarray[6]}
|
||||||
|
|
||||||
|
echo '### env_parset'
|
||||||
|
myfun() {
|
||||||
|
myecho myfun "$@";
|
||||||
|
}
|
||||||
|
alias myecho='echo myecho "$myvar" "${myarr[1]}"'
|
||||||
|
myvar="myvar"
|
||||||
|
myarr=("myarr 0" "myarr 1" "myarr 2")
|
||||||
|
mynewline="`echo newline1;echo newline2;`"
|
||||||
|
env_parset arr1 myfun ::: foo bar baz
|
||||||
|
echo "${arr1[0]} ${arr1[1]} ${arr1[2]}"
|
||||||
|
env_parset comma3,comma2,comma1 myfun ::: baz bar foo
|
||||||
|
echo "$comma1 $comma2 $comma3"
|
||||||
|
env_parset 'space3 space2 space1' myfum ::: baz bar foo
|
||||||
|
echo "$space1 $space2 $space3"
|
||||||
|
env_parset 'newline3 newline2 newline1' 'echo "$mynewline";seq' ::: 3 2 1
|
||||||
|
echo "$newline1"
|
||||||
|
echo "$newline2"
|
||||||
|
echo "$newline3"
|
||||||
|
env_parset 'myarray[6],myarray[5],myarray[4]' myfun ::: baz bar foo
|
||||||
|
echo "${myarray[*]}"
|
||||||
|
echo "${myarray[4]} ${myarray[5]} ${myarray[6]}"
|
||||||
|
_EOF
|
||||||
|
)
|
||||||
|
ssh ksh@lo "$myscript"
|
||||||
|
}
|
||||||
|
|
||||||
|
par_fish_parset() {
|
||||||
|
echo Not implemented
|
||||||
|
}
|
||||||
|
|
||||||
|
par_csh_parset() {
|
||||||
|
echo Not implemented
|
||||||
|
}
|
||||||
|
|
||||||
|
par_tcsh_parset() {
|
||||||
|
echo Not implemented
|
||||||
|
}
|
||||||
|
|
||||||
export -f $(compgen -A function | grep par_)
|
export -f $(compgen -A function | grep par_)
|
||||||
#compgen -A function | grep par_ | sort | parallel --delay $D -j$P --tag -k '{} 2>&1'
|
#compgen -A function | grep par_ | sort | parallel --delay $D -j$P --tag -k '{} 2>&1'
|
||||||
compgen -A function | grep par_ | sort |
|
#compgen -A function | grep par_ | sort |
|
||||||
|
compgen -A function | grep par_ | sort -r |
|
||||||
parallel --joblog /tmp/jl-`basename $0` -j200% --tag -k '{} 2>&1'
|
parallel --joblog /tmp/jl-`basename $0` -j200% --tag -k '{} 2>&1'
|
||||||
|
|
|
@ -1442,6 +1442,24 @@ par_parset 3
|
||||||
par_parset ### parset into indexed array vars
|
par_parset ### parset into indexed array vars
|
||||||
par_parset foo bar baz
|
par_parset foo bar baz
|
||||||
par_parset foo bar bar
|
par_parset foo bar bar
|
||||||
|
par_parset ### env_parset
|
||||||
|
par_parset myecho myvar myarr 1 foo myecho myvar myarr 1 bar myecho myvar myarr 1 baz
|
||||||
|
par_parset myecho myvar myarr 1 foo myecho myvar myarr 1 bar myecho myvar myarr 1 baz
|
||||||
|
par_parset myecho myvar myarr 1 foo myecho myvar myarr 1 bar myecho myvar myarr 1 baz
|
||||||
|
par_parset newline1
|
||||||
|
par_parset newline2
|
||||||
|
par_parset 1
|
||||||
|
par_parset newline1
|
||||||
|
par_parset newline2
|
||||||
|
par_parset 1
|
||||||
|
par_parset 2
|
||||||
|
par_parset newline1
|
||||||
|
par_parset newline2
|
||||||
|
par_parset 1
|
||||||
|
par_parset 2
|
||||||
|
par_parset 3
|
||||||
|
par_parset myecho myvar myarr 1 foo myecho myvar myarr 1 bar myecho myvar myarr 1 baz
|
||||||
|
par_parset myecho myvar myarr 1 foo myecho myvar myarr 1 bar myecho myvar myarr 1 bar
|
||||||
par_pipe_compress_blocks ### bug #41482: --pipe --compress blocks at different -j/seq combinations
|
par_pipe_compress_blocks ### bug #41482: --pipe --compress blocks at different -j/seq combinations
|
||||||
par_pipe_compress_blocks 1
|
par_pipe_compress_blocks 1
|
||||||
par_pipe_compress_blocks echo 1-4 + 1-4
|
par_pipe_compress_blocks echo 1-4 + 1-4
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue