Fixed bug #48295: --results should be dynamic like --wd.

No test.
This commit is contained in:
Ole Tange 2016-06-22 21:43:05 +02:00
parent bd00e10525
commit d0dc1f9bd7
3 changed files with 25 additions and 34 deletions

View file

@ -78,7 +78,7 @@ NORMAL_UNINSTALL = :
PRE_UNINSTALL = : PRE_UNINSTALL = :
POST_UNINSTALL = : POST_UNINSTALL = :
subdir = src 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 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \

View file

@ -6230,7 +6230,9 @@ sub openoutputfiles {
if($opt::results) { if($opt::results) {
my $args_as_dirname = $self->{'commandline'}->args_as_dirname(); my $args_as_dirname = $self->{'commandline'}->args_as_dirname();
# Output in: prefix/name1/val1/name2/val2/stdout # 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); }) { if(eval{ File::Path::mkpath($dir); }) {
# OK # OK
} else { } else {
@ -8799,10 +8801,13 @@ sub new {
# Protect matching inside {= perl expr =} # Protect matching inside {= perl expr =}
# by replacing {= and =} with \257< and \257> # by replacing {= and =} with \257< and \257>
# in @command, --return and --tagstring (if used) # in options that can contain replacement strings:
for(@command,@$transfer_files,@$return_files, # @command, --transferfile, --return,
(defined $opt::tagstring ? $opt::tagstring : $dummy), # --tagstring, --workdir, --results
(defined $opt::workdir ? $opt::workdir : $dummy)) { for(@command, @$transfer_files, @$return_files,
$opt::tagstring, $opt::workdir, $opt::results) {
# Skip if undefined
$_ or next;
# Disallow \257 to avoid nested {= {= =} =} # Disallow \257 to avoid nested {= {= =} =}
if(/\257/) { if(/\257/) {
::error("Command cannot contain the character \257. Use a function for that."); ::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 # All {= perl expr =} have been removed: The rest is non-context
$noncontextlen += length $c; $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 = $_; my $t = $_;
while($t =~ s/ \257<([^\257]*)\257> //x) { while($t =~ s/ \257<([^\257]*)\257> //x) {
# %replacecount = { "perlexpr" => number of times seen } # %replacecount = { "perlexpr" => number of times seen }
@ -8948,24 +8956,6 @@ sub replacement_counts_and_lengths {
$replacecount{$1} ||= 1; $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($opt::bar) {
# If the command does not contain {} force it to be computed # If the command does not contain {} force it to be computed
# as it is being used by --bar # as it is being used by --bar

View file

@ -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> Create a temporary file with content. Normally B<--pipe>/B<--pipepart>
will give data to the program on stdin (standard input). With B<--cat> will give data to the program on stdin (standard input). With B<--cat>
GNU B<parallel> will create a temporary file with the name in {}, so GNU B<parallel> will create a temporary file with the name in B<{}>, so
you can do: B<parallel --pipe --cat wc {}>. you can do: B<parallel --pipe --cat wc {}>.
Implies B<--pipe> unless B<--pipepart> is used. Implies B<--pipe> unless B<--pipepart> is used.
@ -657,7 +657,7 @@ See also B<--bg>, B<man sem>.
Create a temporary fifo with content. Normally B<--pipe> and Create a temporary fifo with content. Normally B<--pipe> and
B<--pipepart> will give data to the program on stdin (standard B<--pipepart> will give data to the program on stdin (standard
input). With B<--fifo> GNU B<parallel> will create a temporary fifo input). With B<--fifo> GNU B<parallel> will create a temporary fifo
with the name in {}, so you can do: B<parallel --pipe --fifo wc {}>. with the name in B<{}>, so you can do: B<parallel --pipe --fifo wc {}>.
Beware: If data is not read from the fifo, the job will block forever. 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<replace-str> =item B<-I> I<replace-str>
Use the replacement string I<replace-str> instead of {}. Use the replacement string I<replace-str> instead of B<{}>.
=item B<--replace>[=I<replace-str>] =item B<--replace>[=I<replace-str>]
@ -840,7 +840,7 @@ Use the replacement string I<replace-str> instead of {}.
=item B<-i>[I<replace-str>] =item B<-i>[I<replace-str>]
This option is a synonym for B<-I>I<replace-str> if I<replace-str> is This option is a synonym for B<-I>I<replace-str> if I<replace-str> 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. 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 Tag lines with a string. Each output line will be prepended with
I<str> and TAB (\t). I<str> can contain replacement strings such as I<str> and TAB (\t). I<str> can contain replacement strings such as
{}. B<{}>.
B<--tagstring> is ignored when using B<-u>, B<--onall>, and B<--nonall>. 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<replace-str> =item B<--er> I<replace-str>
Use the replacement string I<replace-str> instead of {.} for input line without extension. Use the replacement string I<replace-str> instead of B<{.}> for input
line without extension.
=item B<--use-cpus-instead-of-cores> =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) 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 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 =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) =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) =item Z<>-1000 (In SQL table)
@ -4494,7 +4495,7 @@ failed:
B<map> requires Perl v5.10.0 making it harder to use on old systems. B<map> requires Perl v5.10.0 making it harder to use on old systems.
B<map> has no way of using % in the command (GNU Parallel has -I to B<map> 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<map> is option incompatible with B<xargs>, it does not By design B<map> is option incompatible with B<xargs>, it does not
have remote job execution, a structured way of saving results, have remote job execution, a structured way of saving results,