From d0dc1f9bd79645e5a8b6ac035292cac13ce341a2 Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Wed, 22 Jun 2016 21:43:05 +0200 Subject: [PATCH] Fixed bug #48295: --results should be dynamic like --wd. No test. --- src/Makefile.in | 2 +- src/parallel | 38 ++++++++++++++------------------------ src/parallel.pod | 19 ++++++++++--------- 3 files changed, 25 insertions(+), 34 deletions(-) diff --git a/src/Makefile.in b/src/Makefile.in index eb842a2c..4379ae5c 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -78,7 +78,7 @@ NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : subdir = src -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am README +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ diff --git a/src/parallel b/src/parallel index b8c0c1b3..ed46579c 100755 --- a/src/parallel +++ b/src/parallel @@ -6230,7 +6230,9 @@ sub openoutputfiles { if($opt::results) { my $args_as_dirname = $self->{'commandline'}->args_as_dirname(); # Output in: prefix/name1/val1/name2/val2/stdout - my $dir = $opt::results."/".$args_as_dirname; + my $dir = $self->{'commandline'}-> + replace_placeholders([$opt::results],0,0) . + "/".$args_as_dirname; if(eval{ File::Path::mkpath($dir); }) { # OK } else { @@ -8799,10 +8801,13 @@ sub new { # Protect matching inside {= perl expr =} # by replacing {= and =} with \257< and \257> - # in @command, --return and --tagstring (if used) - for(@command,@$transfer_files,@$return_files, - (defined $opt::tagstring ? $opt::tagstring : $dummy), - (defined $opt::workdir ? $opt::workdir : $dummy)) { + # in options that can contain replacement strings: + # @command, --transferfile, --return, + # --tagstring, --workdir, --results + for(@command, @$transfer_files, @$return_files, + $opt::tagstring, $opt::workdir, $opt::results) { + # Skip if undefined + $_ or next; # Disallow \257 to avoid nested {= {= =} =} if(/\257/) { ::error("Command cannot contain the character \257. Use a function for that."); @@ -8939,7 +8944,10 @@ sub replacement_counts_and_lengths { # All {= perl expr =} have been removed: The rest is non-context $noncontextlen += length $c; } - for(@$transfer_files,@$return_files) { + for(@$transfer_files, @$return_files, + $opt::tagstring, $opt::workdir, $opt::results) { + # Options that can contain replacement strings + $_ or next; my $t = $_; while($t =~ s/ \257<([^\257]*)\257> //x) { # %replacecount = { "perlexpr" => number of times seen } @@ -8948,24 +8956,6 @@ sub replacement_counts_and_lengths { $replacecount{$1} ||= 1; } } - if($opt::tagstring) { - my $t = $opt::tagstring; - while($t =~ s/ \257<([^\257]*)\257> //x) { - # %replacecount = { "perlexpr" => number of times seen } - # e.g { "$_++" => 2 } - # But for tagstring we just need to mark it as seen - $replacecount{$1} ||= 1; - } - } - if($opt::workdir) { - my $t = $opt::workdir; - while($t =~ s/ \257<([^\257]*)\257> //x) { - # %replacecount = { "perlexpr" => number of times seen } - # e.g { "$_++" => 2 } - # But for workdir we just need to mark it as seen - $replacecount{$1} ||= 1; - } - } if($opt::bar) { # If the command does not contain {} force it to be computed # as it is being used by --bar diff --git a/src/parallel.pod b/src/parallel.pod index efe1a7a6..fd9d2a6a 100644 --- a/src/parallel.pod +++ b/src/parallel.pod @@ -494,7 +494,7 @@ See B<--pipe> and B<--pipepart> for use of this. Create a temporary file with content. Normally B<--pipe>/B<--pipepart> will give data to the program on stdin (standard input). With B<--cat> -GNU B will create a temporary file with the name in {}, so +GNU B will create a temporary file with the name in B<{}>, so you can do: B. Implies B<--pipe> unless B<--pipepart> is used. @@ -657,7 +657,7 @@ See also B<--bg>, B. Create a temporary fifo with content. Normally B<--pipe> and B<--pipepart> will give data to the program on stdin (standard input). With B<--fifo> GNU B will create a temporary fifo -with the name in {}, so you can do: B. +with the name in B<{}>, so you can do: B. Beware: If data is not read from the fifo, the job will block forever. @@ -832,7 +832,7 @@ See also: B<--sshlogin>. =item B<-I> I -Use the replacement string I instead of {}. +Use the replacement string I instead of B<{}>. =item B<--replace>[=I] @@ -840,7 +840,7 @@ Use the replacement string I instead of {}. =item B<-i>[I] This option is a synonym for B<-I>I if I is -specified, and for B<-I>{} otherwise. This option is deprecated; +specified, and for B<-I {}> otherwise. This option is deprecated; use B<-I> instead. @@ -1954,7 +1954,7 @@ B<--tag> is ignored when using B<-u>. Tag lines with a string. Each output line will be prepended with I and TAB (\t). I can contain replacement strings such as -{}. +B<{}>. B<--tagstring> is ignored when using B<-u>, B<--onall>, and B<--nonall>. @@ -2114,7 +2114,8 @@ See also: B<--line-buffer> B<--group> =item B<--er> I -Use the replacement string I instead of {.} for input line without extension. +Use the replacement string I instead of B<{.}> for input +line without extension. =item B<--use-cpus-instead-of-cores> @@ -2494,7 +2495,7 @@ download images for the past 30 days: parallel wget http://www.example.com/path/to/'$(date -d "today -{1} days" +%Y%m%d)_{2}.jpg' ::: $(seq 30) ::: $(seq -w 10) B<$(date -d "today -{1} days" +%Y%m%d)> will give the dates in -YYYYMMDD with {1} days subtracted. +YYYYMMDD with B<{1}> days subtracted. =head1 EXAMPLE: Copy files as last modified date (ISO8601) with added random digits @@ -3812,7 +3813,7 @@ Killed by Ctrl-C, timeout, not enough memory or similar. =item Z<>-2 (In joblog and SQL table) -$job->skip() was called in {= =}. +$job->skip() was called in B<{= =}>. =item Z<>-1000 (In SQL table) @@ -4494,7 +4495,7 @@ failed: B requires Perl v5.10.0 making it harder to use on old systems. B has no way of using % in the command (GNU Parallel has -I to -specify another replacement string than {}). +specify another replacement string than B<{}>). By design B is option incompatible with B, it does not have remote job execution, a structured way of saving results,