From 0c7f6c91e6db2f3552334dd4dbbbfdac89946f1c Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Fri, 18 Sep 2015 22:28:47 +0200 Subject: [PATCH] Fixed bug #45998: --pipe to function broken. --- doc/release_new_version | 4 ++++ src/parallel | 6 +++--- testsuite/tests-to-run/parallel-local-0.3s.sh | 6 ++++++ testsuite/wanted-results/parallel-local-0.3s | 7 +++++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/doc/release_new_version b/doc/release_new_version index 80913d93..a07582b5 100644 --- a/doc/release_new_version +++ b/doc/release_new_version @@ -237,12 +237,16 @@ New in this release: * <> GNU Parallel was used (unfortunately with wrong citation) in: TADSim: Discrete Event-Based Performance Prediction for Temperature-Accelerated Dynamics http://vruehle.de/publications/2015c.pdf +* Third-party selling GNU Parallel T-shirts http://www.aliexpress.com/item/2015F-BSO-GNU-LOGO-GNU-PARALLEL-men-s-shirt-sleeve-visual-illusion-error/32464827966.html + * Joys of gnu parallel http://scottolesen.com/index.php/2015/08/26/joys-of-gnu-parallel/ * Crop and resize images with bash and ImageMagick https://www.simonholywell.com/post/2015/08/image-resize-crop-bash-imagemagick/ * Three Ways to Script Processes in Parallel http://www.codeword.xyz/2015/09/02/three-ways-to-script-processes-in-parallel/ +* What It Looks Like to Process 3.5 Million Books http://blog.gdeltproject.org/what-it-looks-like-to-process-3-5-million-books/ + * L’Exploration De Données Twitter http://blog.inovia-conseil.fr/?p=233 * Bug fixes and man page updates. diff --git a/src/parallel b/src/parallel index f2109bcc..07095fd9 100755 --- a/src/parallel +++ b/src/parallel @@ -6006,7 +6006,7 @@ sub empty_input_wrapper { # Returns: # $wrapped_command = the wrapped command my $command = shift; - my $script = '$c="'.::perl_quote_scalar($command).'";'. + my $script = '$c="'.::perl_quote_scalar($Global::shell." -c ".::shell_quote_scalar($command)).'";'. ::spacefree(0,q{ if(sysread(STDIN, $buf, 1)) { open($fh, "|-", $c) || die; @@ -8345,7 +8345,7 @@ sub new { # with the {= perl expr =} # Avoid replacing inside existing {= perl expr =} while(s{((^|\257>)[^\257]*?) # Don't replace after \257 unless \257> - \Q$rpl\E} + \Q$rpl\E} {$1\257<$Global::rpl{$rpl}\257>}xg) { } # Do the same for the positional replacement strings @@ -8354,7 +8354,7 @@ sub new { if($posrpl =~ s/^\{//) { # Only do this if the shorthand start with { while(s{((^|\257>)[^\257]*?) # Don't replace after \257 unless \257> - \{(-?\d+)\Q$posrpl\E} + \{(-?\d+)\Q$posrpl\E} {$1\257<$3 $Global::rpl{$rpl}\257>}xg) { } } diff --git a/testsuite/tests-to-run/parallel-local-0.3s.sh b/testsuite/tests-to-run/parallel-local-0.3s.sh index 343f9e32..aea70909 100644 --- a/testsuite/tests-to-run/parallel-local-0.3s.sh +++ b/testsuite/tests-to-run/parallel-local-0.3s.sh @@ -206,6 +206,12 @@ echo '### bug #45939: {2} in {= =} fails' parallel echo '{= s/O{2}//=}' ::: OOOK parallel echo '{2}-{=1 s/O{2}//=}' ::: OOOK ::: OK +echo '**' + +echo '### bug #45998: --pipe to function broken' +myfunc() { echo $1; cat; }; export -f myfunc; echo OK | parallel --pipe myfunc {#} + + 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 f595a09f..3fdedf9b 100644 --- a/testsuite/wanted-results/parallel-local-0.3s +++ b/testsuite/wanted-results/parallel-local-0.3s @@ -436,5 +436,12 @@ parallel echo '{= s/O{2}//=}' ::: OOOK OK parallel echo '{2}-{=1 s/O{2}//=}' ::: OOOK ::: OK OK-OK +echo '**' +** +echo '### bug #45998: --pipe to function broken' +### bug #45998: --pipe to function broken +myfunc() { echo $1; cat; }; export -f myfunc; echo OK | parallel --pipe myfunc {#} +1 +OK ### 1 .par file from --files expected 1