From 0d9812ddb4e87bbb391bbb1a014cdc8b61c06e39 Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Fri, 13 Jan 2017 15:47:13 +0100 Subject: [PATCH] parallel: --sqlmaster +DBURL works with different commands. --- src/parallel | 61 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 47 insertions(+), 14 deletions(-) diff --git a/src/parallel b/src/parallel index 16b2714c..b7b6e11a 100755 --- a/src/parallel +++ b/src/parallel @@ -1259,7 +1259,7 @@ sub check_invalid_option_combinations { sub init_globals { # Defaults: - $Global::version = 20170101; + $Global::version = 20170111; $Global::progname = 'parallel'; $Global::infinity = 2**31; $Global::debug = 0; @@ -9197,12 +9197,44 @@ sub replaced { # for each arg: # replace replacement strings with replacement in the word value # push to replace word value - $perl_expressions_as_re ||= - join("|", map {s/^-?\d+//; "\Q$_\E"} keys %{$self->{'replacecount'}}); - for my $arg (@$argref) { - my $val = $word; - # Replace {= perl expr =} with value for each arg - $val =~ s{\257<(-?\d+)?($perl_expressions_as_re)\257>} + + if($opt::sqlworker) { + $perl_expressions_as_re = + join("|", map {s/^-?\d+//; "\Q$_\E"} keys %{$self->{'replacecount'}}); + for my $arg (@$argref) { + my $val = $word; + # Replace {= perl expr =} with value for each arg + $val =~ s{\257<(-?\d+)?($perl_expressions_as_re)\257>} + { + if($1) { + # Positional replace + # Find the relevant arg and replace it + ($argref->[$1 > 0 ? $1-1 : $n+$1] ? # If defined: replace + $argref->[$1 > 0 ? $1-1 : $n+$1]-> + replace($2,$quote_arg,$self) + : ""); + } else { + # Normal replace + $normal_replace ||= 1; + ($arg ? $arg->replace($2,$quote_arg,$self) : ""); + } + }gxe; + if($quote) { + CORE::push(@{$replace{::shell_quote_scalar($word)}}, + ::shell_quote_scalar($val)); + } else { + CORE::push(@{$replace{$word}}, $val); + } + # No normal replacements => only run once + $normal_replace or last; + } + } else { + $perl_expressions_as_re ||= + join("|", map {s/^-?\d+//; "\Q$_\E"} keys %{$self->{'replacecount'}}); + for my $arg (@$argref) { + my $val = $word; + # Replace {= perl expr =} with value for each arg + $val =~ s{\257<(-?\d+)?($perl_expressions_as_re)\257>} { if($1) { # Positional replace @@ -9217,14 +9249,15 @@ sub replaced { ($arg ? $arg->replace($2,$quote_arg,$self) : ""); } }goxe; - if($quote) { - CORE::push(@{$replace{::shell_quote_scalar($word)}}, - ::shell_quote_scalar($val)); - } else { - CORE::push(@{$replace{$word}}, $val); + if($quote) { + CORE::push(@{$replace{::shell_quote_scalar($word)}}, + ::shell_quote_scalar($val)); + } else { + CORE::push(@{$replace{$word}}, $val); + } + # No normal replacements => only run once + $normal_replace or last; } - # No normal replacements => only run once - $normal_replace or last; } } *Arg::arg = [];