diff --git a/src/parallel b/src/parallel index 3d14c509..dfdda5f5 100755 --- a/src/parallel +++ b/src/parallel @@ -55,7 +55,7 @@ if($Global::max_number_of_args) { my $command = ""; if(@ARGV) { if($Global::quoting) { - $command = shell_quote(@ARGV); + $command = shell_quote_empty(@ARGV); } else { $command = join(" ", @ARGV); } @@ -574,7 +574,7 @@ sub options_hash { "wait" => \$opt::wait, # Shebang #!/usr/bin/parallel --shebang "shebang|hashbang" => \$opt::shebang, - "--internal-pipe-means-argfiles" => \$opt::internal_pipe_means_argfiles, + "internal-pipe-means-argfiles" => \$opt::internal_pipe_means_argfiles, "Y" => \$opt::retired, "skip-first-line" => \$opt::skip_first_line, "header=s" => \$opt::header, @@ -607,7 +607,7 @@ sub get_options_from_array { sub parse_options { # Returns: N/A # Defaults: - $Global::version = 20121123; + $Global::version = 20121124; $Global::progname = 'parallel'; $Global::infinity = 2**31; $Global::debug = 0; @@ -1079,6 +1079,16 @@ sub shell_quote { return wantarray ? @strings : "@strings"; } +sub shell_quote_empty { + my @strings = shell_quote(@_); + for my $a (@strings) { + if($a eq "") { + $a = "''"; + } + } + return wantarray ? @strings : "@strings"; +} + sub shell_quote_scalar { # Quote the string so shell will not expand any special chars # Returns: diff --git a/testsuite/Makefile b/testsuite/Makefile index c653b290..e2b5aefa 100644 --- a/testsuite/Makefile +++ b/testsuite/Makefile @@ -50,6 +50,6 @@ portable: timings: tests-to-run/* ../src/parallel ls tests-to-run/*.sh | xargs -n1 echo /usr/bin/time -f %e bash >/tmp/timing.script - stdout bash -x /tmp/timing.script >/tmp/timing.out + stdout bash -x /tmp/timing.script | tee /tmp/timing.out echo usr.bin.time_END >>/tmp/timing.out perl -ne '/usr.bin.time/ and do { print $$last.$$h; $$h=$$_ }; chomp; $$last = $$_' /tmp/timing.out | sort -n >timings diff --git a/testsuite/Start.sh b/testsuite/Start.sh index bc255221..234d67cf 100644 --- a/testsuite/Start.sh +++ b/testsuite/Start.sh @@ -7,7 +7,7 @@ SHFILE=/tmp/unittest-parallel.sh # Run a failing test once ls -t tests-to-run/*${1}*.sh \ -| perl -pe 's:(.*/(.*)).sh:bash $1.sh > actual-results/$2; diff -Naur wanted-results/$2 actual-results/$2: ' \ +| perl -pe 's:(.*/(.*)).sh:bash $1.sh > actual-results/$2; diff -Naur wanted-results/$2 actual-results/$2 || touch $1.sh:' \ >$SHFILE # # Try a failing test thrice diff --git a/testsuite/tests-to-run/parallel-local108.sh b/testsuite/tests-to-run/parallel-local108.sh index 3426f724..48a8a5f2 100755 --- a/testsuite/tests-to-run/parallel-local108.sh +++ b/testsuite/tests-to-run/parallel-local108.sh @@ -1,14 +1,4 @@ #!/bin/bash -PAR=parallel -cd input-files/test08 - -ls \ -| $PAR -q perl -ne '/_PRE (\d+)/ and $p=$1; /hatchname> (\d+)/ and $1!=$p and print $ARGV,"\n"' \ -| sort - -seq 1 10 | $PAR -j 1 echo | sort -seq 1 10 | $PAR -j 2 echo | sort -seq 1 10 | $PAR -j 3 echo | sort diff --git a/testsuite/tests-to-run/parallel-local140.sh b/testsuite/tests-to-run/parallel-local140.sh index b468a446..05a7907c 100644 --- a/testsuite/tests-to-run/parallel-local140.sh +++ b/testsuite/tests-to-run/parallel-local140.sh @@ -1,7 +1,2 @@ #!/bin/bash -echo "### Computing length of command line" -seq 1 2 | parallel -k -N2 echo {1} {2} -parallel --xapply -k -a <(seq 11 12) -a <(seq 1 3) echo -parallel -k -C %+ echo '"{1}_{3}_{2}_{4}"' ::: 'a% c %%b' 'a%c% b %d' -parallel -k -C %+ echo {4} ::: 'a% c %%b' diff --git a/testsuite/tests-to-run/parallel-local164.sh b/testsuite/tests-to-run/parallel-local164.sh index cd7401fd..294a8fc6 100644 --- a/testsuite/tests-to-run/parallel-local164.sh +++ b/testsuite/tests-to-run/parallel-local164.sh @@ -19,4 +19,22 @@ echo '### Test -k 2'; echo '### Test -k 1'; sleep 1 + +echo "### Computing length of command line" +seq 1 2 | parallel -k -N2 echo {1} {2} +parallel --xapply -k -a <(seq 11 12) -a <(seq 1 3) echo +parallel -k -C %+ echo '"{1}_{3}_{2}_{4}"' ::: 'a% c %%b' 'a%c% b %d' +parallel -k -C %+ echo {4} ::: 'a% c %%b' + +echo "### test08"; + cd input-files/test08; + ls | parallel -q perl -ne '/_PRE (\d+)/ and $p=$1; /hatchname> (\d+)/ and $1!=$p and print $ARGV,"\n"' | sort; + +seq 1 10 | parallel -j 1 echo | sort +seq 1 10 | parallel -j 2 echo | sort +seq 1 10 | parallel -j 3 echo | sort + +echo "bug #37694: Empty string argument skipped when using --quote" +parallel -q --nonall perl -le 'print scalar @ARGV' 'a' 'b' '' + EOF diff --git a/testsuite/wanted-results/parallel-local108 b/testsuite/wanted-results/parallel-local108 index 491d2053..e69de29b 100644 --- a/testsuite/wanted-results/parallel-local108 +++ b/testsuite/wanted-results/parallel-local108 @@ -1,32 +0,0 @@ -b -d -1 -10 -2 -3 -4 -5 -6 -7 -8 -9 -1 -10 -2 -3 -4 -5 -6 -7 -8 -9 -1 -10 -2 -3 -4 -5 -6 -7 -8 -9 diff --git a/testsuite/wanted-results/parallel-local140 b/testsuite/wanted-results/parallel-local140 index ba840ed0..e69de29b 100644 --- a/testsuite/wanted-results/parallel-local140 +++ b/testsuite/wanted-results/parallel-local140 @@ -1,8 +0,0 @@ -### Computing length of command line -1 2 -11 1 -12 2 -3 -a_b_c_{4} -a_b_c_d -{4} diff --git a/testsuite/wanted-results/parallel-local164 b/testsuite/wanted-results/parallel-local164 index 885fcaca..04124c76 100644 --- a/testsuite/wanted-results/parallel-local164 +++ b/testsuite/wanted-results/parallel-local164 @@ -3,3 +3,46 @@ ### Test -k 4 ### Test -k 2 ### Test -k 1 +### Computing length of command line +1 2 +11 1 +12 2 +3 +a_b_c_{4} +a_b_c_d +{4} +### test08 +b +d +1 +10 +2 +3 +4 +5 +6 +7 +8 +9 +1 +10 +2 +3 +4 +5 +6 +7 +8 +9 +1 +10 +2 +3 +4 +5 +6 +7 +8 +9 +bug #37694: Empty string argument skipped when using --quote +3