diff --git a/src/env_parallel.bash b/src/env_parallel.bash index fce855c9..ca0b0b3c 100755 --- a/src/env_parallel.bash +++ b/src/env_parallel.bash @@ -203,6 +203,22 @@ parset() { _parset_name="$1" shift + if [ "$_parset_name" == "" ] ; then + echo parset: Error: No destination variable given. >&2 + echo parset: Error: Try: >&2 + echo parset: Error: ' ' parset myvar echo ::: foo >&2 + return 255 + fi + echo "$_parset_name" | + perl -ne 'chomp;for (split /[, ]/) { + if(not /^[a-zA-Z_][a-zA-Z_0-9]*$/) { + 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 diff --git a/src/parset.pod b/src/parset.pod index a051e831..8d3bb8c4 100644 --- a/src/parset.pod +++ b/src/parset.pod @@ -20,7 +20,7 @@ B into shell variables. The B function is defined as part of B. If I is a single variable name, this will be treated as -the destination variable and made to an array. +the destination variable and made into an array. If I contains multiple names separated by ',' or space, the names will be the destination variables. @@ -70,7 +70,12 @@ You cannot pipe into B, but must use a tempfile: parset res echo :::: parallel_input echo "${res[0]}" echo "${res[9]}" - + +or Bash process substitution: + + parset res echo :::: <(seq 100) + echo "${res[0]}" + echo "${res[99]}" =head3 Installation