From a7ac76158feea11a26f92ecab0ff3d34d1a77762 Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Sat, 12 Sep 2015 17:51:43 +0200 Subject: [PATCH] Fixed bug #45939: {2} in {= =} fails. --- src/parallel | 11 +++++++---- testsuite/tests-to-run/parallel-local-0.3s.sh | 4 ++++ testsuite/wanted-results/parallel-local-0.3s | 6 ++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/parallel b/src/parallel index e6e982ec..f2109bcc 100755 --- a/src/parallel +++ b/src/parallel @@ -8353,11 +8353,14 @@ sub new { $posrpl = $rpl; if($posrpl =~ s/^\{//) { # Only do this if the shorthand start with { - s{\{(-?\d+)\Q$posrpl\E} - {\257<$1 $Global::rpl{$rpl}\257>}g; + while(s{((^|\257>)[^\257]*?) # Don't replace after \257 unless \257> + \{(-?\d+)\Q$posrpl\E} + {$1\257<$3 $Global::rpl{$rpl}\257>}xg) { + } } } } + # Add {} if no replacement strings in @command ($replacecount_ref, $len_ref, @command) = replacement_counts_and_lengths($return_files,@command); @@ -9077,9 +9080,9 @@ sub new { sub Q { # Q alias for ::shell_quote_scalar # Run shell_quote_scalar once to set the reference to the sub - my @a = ::shell_quote_scalar(@_); + my $a = ::shell_quote_scalar(@_); *Q = \&::shell_quote_scalar; - return @a; + return $a; } { diff --git a/testsuite/tests-to-run/parallel-local-0.3s.sh b/testsuite/tests-to-run/parallel-local-0.3s.sh index 886c56de..343f9e32 100644 --- a/testsuite/tests-to-run/parallel-local-0.3s.sh +++ b/testsuite/tests-to-run/parallel-local-0.3s.sh @@ -202,6 +202,10 @@ parallel -k echo '{=1 $_=++$::G =}' ::: {1001..1004} ::: {a..c} echo '**' +echo '### bug #45939: {2} in {= =} fails' +parallel echo '{= s/O{2}//=}' ::: OOOK +parallel echo '{2}-{=1 s/O{2}//=}' ::: OOOK ::: OK + EOF echo '### 1 .par file from --files expected' find /tmp{/*,}/*.{par,tms,tmx} 2>/dev/null -mmin -10 | wc -l diff --git a/testsuite/wanted-results/parallel-local-0.3s b/testsuite/wanted-results/parallel-local-0.3s index 3c94470c..f595a09f 100644 --- a/testsuite/wanted-results/parallel-local-0.3s +++ b/testsuite/wanted-results/parallel-local-0.3s @@ -430,5 +430,11 @@ parallel -k echo '{=1 $_=++$::G =}' ::: {1001..1004} ::: {a..c} 12 echo '**' ** +echo '### bug #45939: {2} in {= =} fails' +### bug #45939: {2} in {= =} fails +parallel echo '{= s/O{2}//=}' ::: OOOK +OK +parallel echo '{2}-{=1 s/O{2}//=}' ::: OOOK ::: OK +OK-OK ### 1 .par file from --files expected 1