From 04cca9fe433e96f3cdb463a8a5f9c1c032c11434 Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Wed, 22 Nov 2017 21:48:00 +0100 Subject: [PATCH] env_parallel.bash: Allow for $array[1]-variables to be used for parset. env_parallel: Install in .shrc. --- src/env_parallel | 2 ++ src/env_parallel.bash | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/env_parallel b/src/env_parallel index 632a919c..122a25aa 100755 --- a/src/env_parallel +++ b/src/env_parallel @@ -40,6 +40,7 @@ while test $# -gt 0; do case $key in -i|--install) installer . env_parallel.bash $HOME/.bashrc + installer . env_parallel.sh $HOME/.shrc installer . env_parallel.zsh $HOME/.zshenv installer source env_parallel.ksh $HOME/.kshrc echo $SHELL | grepq /pdksh && @@ -55,6 +56,7 @@ while test $# -gt 0; do echo '. (which env_parallel.fish)' >> $HOME/.config/fish/config.fish echo 'Installed env_parallel in: ' echo " " $HOME/.bashrc + echo " " $HOME/.shrc echo " " $HOME/.zshenv echo " " $HOME/.config/fish/config.fish echo " " $HOME/.kshrc diff --git a/src/env_parallel.bash b/src/env_parallel.bash index e39facf9..6751e437 100755 --- a/src/env_parallel.bash +++ b/src/env_parallel.bash @@ -206,12 +206,13 @@ parset() { 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 + echo parset: Error: ' ' parset myarray echo ::: foo bar >&2 return 255 fi echo "$_parset_name" | perl -ne 'chomp;for (split /[, ]/) { - if(not /^[a-zA-Z_][a-zA-Z_0-9]*$/) { + # 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;