From cf2b12eea8bec6c289d0772d872bd2dd57b73587 Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Sun, 17 Jul 2011 02:22:39 +0200 Subject: [PATCH] Fixed bug #33743: -q quotes # in {#}. --- src/parallel | 6 +++++- testsuite/tests-to-run/test15.sh | 24 +++++++++++++++--------- testsuite/tests-to-run/test63.sh | 10 ++++++++++ testsuite/wanted-results/test15 | 8 ++++---- testsuite/wanted-results/test33 | 20 ++++++++++---------- testsuite/wanted-results/test63 | 10 ++++++++++ 6 files changed, 54 insertions(+), 24 deletions(-) create mode 100644 testsuite/tests-to-run/test63.sh create mode 100644 testsuite/wanted-results/test63 diff --git a/src/parallel b/src/parallel index 3007aaf2..f9916efc 100755 --- a/src/parallel +++ b/src/parallel @@ -45,6 +45,8 @@ my $command; if(@ARGV) { if($Global::quoting) { $command = shell_quote(@ARGV); + # {#} is a replacement string and should not be quoted + $command =~ s/{\\#}/{#}/g; } else { $command = join(" ", @ARGV); } @@ -1972,7 +1974,9 @@ sub loadavg { if($uptime_out =~ /load average: (\d+.\d+)/) { $self->{'loadavg'} = $1; ::debug("New loadavg: ".$self->{'loadavg'}); - } + } else { + ::die_bug("loadavg_invalid_content: $uptime_out"); + } ::debug("Last update: ".$self->{'last_loadavg_update'}); if(time - $self->{'last_loadavg_update'} > 10) { # last loadavg was started 10 seconds ago diff --git a/testsuite/tests-to-run/test15.sh b/testsuite/tests-to-run/test15.sh index fc204f5a..e5b30b1d 100755 --- a/testsuite/tests-to-run/test15.sh +++ b/testsuite/tests-to-run/test15.sh @@ -31,6 +31,7 @@ send "y\n" expect "opt--interactive 3" _EOF +cat <<'EOF' | parallel -j0 -k echo '### Test -L -l and --max-lines' (echo a_b;echo c) | parallel -km -L2 echo (echo a_b;echo c) | parallel -k -L2 echo @@ -82,14 +83,16 @@ echo '### Test -x' (seq 1 10; echo 1234; seq 12 15) | stdout parallel -j1 -km -s 10 -x echo (seq 1 10; echo 1234; seq 12 15) | stdout parallel -j1 -kX -s 10 -x echo (seq 1 10; echo 1234; seq 12 15) | stdout xargs -s 10 -x echo -#echo '### Test bugfix if no command given' -#(echo echo; seq 1 5; perl -e 'print "z"x1000000'; seq 12 15) | stdout parallel -j1 -km -s 10 +EOF echo '### Test -a and --arg-file: Read input from file instead of stdin' seq 1 10 >/tmp/$$ parallel -k -a /tmp/$$ echo parallel -k --arg-file /tmp/$$ echo +#echo '### Test bugfix if no command given' +#(echo echo; seq 1 5; perl -e 'print "z"x1000000'; seq 12 15) | stdout parallel -j1 -km -s 10 + cd input-files/test15 echo 'xargs Expect: 3 1 2' @@ -114,6 +117,15 @@ chmod 755 /tmp/parallel-script-for-script2 echo via pseudotty | script -q -f -c /tmp/parallel-script-for-script2 /dev/null sleep 1 +echo '### Hans found a bug giving unitialized variable' +echo >/tmp/parallel_f1 +echo >/tmp/parallel_f2' +' +echo /tmp/parallel_f1 /tmp/parallel_f2 | stdout parallel -kv --delimiter ' ' gzip +rm /tmp/parallel_f* + + +cat <<'EOF' | parallel -j0 -k echo '### Test -i and --replace: Replace with argument' (echo a; echo END; echo b) | parallel -k -i -eEND echo repl{}ce (echo a; echo END; echo b) | parallel -k --replace -eEND echo repl{}ce @@ -160,13 +172,6 @@ echo line 1Nline 2Nline 3 | parallel -k --delimiter N echo This is printf "delimiter NUL line 1\0line 2\0line 3" | parallel -k -d '\0' echo printf "delimiter TAB line 1\tline 2\tline 3" | parallel -k --delimiter '\t' echo -echo '### Hans found a bug giving unitialized variable' -echo >/tmp/parallel_f1 -echo >/tmp/parallel_f2' -' -echo /tmp/parallel_f1 /tmp/parallel_f2 | stdout parallel -kv --delimiter ' ' gzip -rm /tmp/parallel_f* - echo '### Test --max-chars and -s: Max number of chars in a line' (echo line 1;echo line 1;echo line 2) | parallel -k --max-chars 25 -X echo (echo line 1;echo line 1;echo line 2) | parallel -k -s 25 -X echo @@ -190,3 +195,4 @@ echo '### Test --verbose and -t' echo '### Test --show-limits' (echo b; echo c; echo f) | parallel -k --show-limits echo {}ar (echo b; echo c; echo f) | parallel -j1 -kX --show-limits -s 100 echo {}ar +EOF diff --git a/testsuite/tests-to-run/test63.sh b/testsuite/tests-to-run/test63.sh new file mode 100644 index 00000000..0af30b4a --- /dev/null +++ b/testsuite/tests-to-run/test63.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +echo '### Test -q' +parallel -kq perl -e '$ARGV[0]=~/^\S+\s+\S+$/ and print $ARGV[0],"\n"' ::: "a b" c "d e f" g "h i" + +echo '### Test -q {#}' +parallel -kq echo {#} ::: a b +parallel -kq echo {\#} ::: a b +parallel -kq echo {\\#} ::: a b + diff --git a/testsuite/wanted-results/test15 b/testsuite/wanted-results/test15 index 43dff7fb..b21b2cd1 100644 --- a/testsuite/wanted-results/test15 +++ b/testsuite/wanted-results/test15 @@ -189,6 +189,10 @@ parallel Expect: 1 3 2 via pseudotty 3 2 via pseudotty +### Hans found a bug giving unitialized variable +gzip /tmp/parallel_f1 +gzip /tmp/parallel_f2' +' ### Test -i and --replace: Replace with argument replace replace @@ -275,10 +279,6 @@ line 3 delimiter TAB line 1 line 2 line 3 -### Hans found a bug giving unitialized variable -gzip /tmp/parallel_f1 -gzip /tmp/parallel_f2' -' ### Test --max-chars and -s: Max number of chars in a line line 1 line 1 line 2 diff --git a/testsuite/wanted-results/test33 b/testsuite/wanted-results/test33 index b2165a09..f7243f52 100644 --- a/testsuite/wanted-results/test33 +++ b/testsuite/wanted-results/test33 @@ -4,21 +4,21 @@ parallel [options] [command [arguments]] < list_of_arguments parallel [options] [command [arguments]] (::: arguments|:::: argfile(s))... cat ... | parallel --pipe [options] [command [arguments]] --j n Run n jobs in parallel --k Keep same order --X Multiple arguments with context replace +-j n Run n jobs in parallel +-k Keep same order +-X Multiple arguments with context replace --colsep regexp Split input on regexp for positional replacements {} {.} {/} {/.} {#} Replacement strings {3} {3.} {3/} {3/.} Positional replacement strings --S sshlogin - e.g. foo@server.example.com ---trc {}.bar Shorthand for --transfer --return {}.bar --cleanup ---onall Run the given command with argument on all sshlogins ---nonall Run the given command with no arguments on all sshlogins +-S sshlogin Example: foo@server.example.com +--trc {}.bar Shorthand for --transfer --return {}.bar --cleanup +--onall Run the given command with argument on all sshlogins +--nonall Run the given command with no arguments on all sshlogins ---pipe Split stdin (standard input) to multiple jobs. ---recend Record end separator for --pipe. ---recstart Record start separator for --pipe. +--pipe Split stdin (standard input) to multiple jobs. +--recend str Record end separator for --pipe. +--recstart str Record start separator for --pipe. See 'man parallel' for details Parsing of --jobs/-j/--max-procs/-P failed diff --git a/testsuite/wanted-results/test63 b/testsuite/wanted-results/test63 new file mode 100644 index 00000000..9560fb64 --- /dev/null +++ b/testsuite/wanted-results/test63 @@ -0,0 +1,10 @@ +### Test -q +a b +h i +### Test -q {#} +1 +2 +1 +2 +{\#} a +{\#} b