mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-11-29 09:27:56 +00:00
parallel: added --tagstring + man + test.
parallel.pod: Elaborated on problems with -u.
This commit is contained in:
parent
944cfd0026
commit
29726eee6e
27
src/parallel
27
src/parallel
|
@ -705,6 +705,9 @@ sub parse_options {
|
|||
$Global::replace{$_} = ::maybe_quote($Global::replace{$_});
|
||||
}
|
||||
%Global::replace_rev = reverse %Global::replace;
|
||||
if(defined $::opt_tag and not defined $::opt_tagstring) {
|
||||
$::opt_tagstring = $Global::replace{'{}'};
|
||||
}
|
||||
|
||||
if(grep /^$Global::arg_sep$|^$Global::arg_file_sep$/o, @ARGV) {
|
||||
# Deal with ::: and ::::
|
||||
|
@ -3728,13 +3731,8 @@ sub print {
|
|||
sub tag {
|
||||
my $self = shift;
|
||||
if(not defined $self->{'tag'}) {
|
||||
$self->{'tag'} = "";
|
||||
if(defined $::opt_tagstring) {
|
||||
$self->{'tag'} .= $::opt_tagstring."\t";
|
||||
}
|
||||
if(defined $::opt_tag) {
|
||||
$self->{'tag'} .= $self->{'commandline'}->args_as_string()."\t";
|
||||
}
|
||||
$self->{'tag'} = $self->{'commandline'}->
|
||||
replace_placeholders($::opt_tagstring,0)."\t";
|
||||
}
|
||||
return $self->{'tag'};
|
||||
}
|
||||
|
@ -3798,9 +3796,20 @@ sub new {
|
|||
# Add {} to the command if there are no {...}'s
|
||||
$command .=" ".$Global::replace{'{}'};
|
||||
}
|
||||
($sum,$len->{'no_args'},$len->{'context'},$len->{'contextgroups'},
|
||||
%replacecount) = number_of_replacements($command,$context_replace);
|
||||
}
|
||||
($sum,$len->{'no_args'},$len->{'context'},$len->{'contextgroups'},
|
||||
%replacecount) = number_of_replacements($command,$context_replace);
|
||||
if(defined $::opt_tagstring) {
|
||||
my ($dummy1,$dummy2,$dummy3,$dummy4,%repcount) =
|
||||
number_of_replacements($::opt_tagstring,$context_replace);
|
||||
# Merge %repcount with %replacecount to get the keys
|
||||
# for replacing replacement strings in $::opt_tagstring
|
||||
# The number, however, does not matter.
|
||||
for (keys %repcount) {
|
||||
$replacecount{$_} ||= 0;
|
||||
}
|
||||
}
|
||||
|
||||
my %positional_replace;
|
||||
my %multi_replace;
|
||||
for my $used (keys %replacecount) {
|
||||
|
|
|
@ -1200,6 +1200,15 @@ the lines will be prepended with the sshlogin instead.
|
|||
B<--tag> is ignored when using B<-u>.
|
||||
|
||||
|
||||
=item B<--tagstring> I<str>
|
||||
|
||||
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
|
||||
{}.
|
||||
|
||||
B<--tagstring> is ignored when using B<-u>, B<--onall>, and B<--nonall>.
|
||||
|
||||
|
||||
=item B<--tmpdir> I<dirname>
|
||||
|
||||
Directory for temporary files. GNU B<parallel> normally buffers output
|
||||
|
@ -1295,9 +1304,16 @@ a bc " -> "a bc". This is the default if B<--colsep> is used.
|
|||
|
||||
=item B<-u>
|
||||
|
||||
Ungroup output. Output is printed as soon as possible. This may cause
|
||||
output from different commands to be mixed. GNU B<parallel> runs
|
||||
faster with B<-u>. Can be reversed with B<--group>.
|
||||
Ungroup output. Output is printed as soon as possible and by passes
|
||||
GNU B<parallel> internal processing. This may cause
|
||||
output from different commands to be mixed. Compare these:
|
||||
|
||||
B<parallel -j0 'sleep {};echo -n start{};sleep {};echo {}end' ::: 1 2 3 4>
|
||||
|
||||
B<parallel -u -j0 'sleep {};echo -n start{};sleep {};echo {}end' ::: 1 2 3 4>
|
||||
|
||||
It also disables B<--tag>. GNU B<parallel> runs faster with B<-u>. Can
|
||||
be reversed with B<--group>.
|
||||
|
||||
|
||||
=item B<--extensionreplace> I<replace-str>
|
||||
|
|
|
@ -1279,6 +1279,15 @@ the lines will be prepended with the sshlogin instead.
|
|||
|
||||
@strong{--tag} is ignored when using @strong{-u}.
|
||||
|
||||
@item @strong{--tagstring} @emph{str}
|
||||
@anchor{@strong{--tagstring} @emph{str}}
|
||||
|
||||
Tag lines with a string. Each output line will be prepended with
|
||||
@emph{str} and TAB (\t). @emph{str} can contain replacement strings such as
|
||||
@{@}.
|
||||
|
||||
@strong{--tagstring} is ignored when using @strong{-u}, @strong{--onall}, and @strong{--nonall}.
|
||||
|
||||
@item @strong{--tmpdir} @emph{dirname}
|
||||
@anchor{@strong{--tmpdir} @emph{dirname}}
|
||||
|
||||
|
@ -1385,9 +1394,16 @@ a bc " -> "a bc". This is the default if @strong{--colsep} is used.
|
|||
@item @strong{-u}
|
||||
@anchor{@strong{-u}}
|
||||
|
||||
Ungroup output. Output is printed as soon as possible. This may cause
|
||||
output from different commands to be mixed. GNU @strong{parallel} runs
|
||||
faster with @strong{-u}. Can be reversed with @strong{--group}.
|
||||
Ungroup output. Output is printed as soon as possible and by passes
|
||||
GNU @strong{parallel} internal processing. This may cause
|
||||
output from different commands to be mixed. Compare these:
|
||||
|
||||
@strong{parallel -j0 'sleep @{@};echo -n start@{@};sleep @{@};echo @{@}end' ::: 1 2 3 4}
|
||||
|
||||
@strong{parallel -u -j0 'sleep @{@};echo -n start@{@};sleep @{@};echo @{@}end' ::: 1 2 3 4}
|
||||
|
||||
It also disables @strong{--tag}. GNU @strong{parallel} runs faster with @strong{-u}. Can
|
||||
be reversed with @strong{--group}.
|
||||
|
||||
@item @strong{--extensionreplace} @emph{replace-str}
|
||||
@anchor{@strong{--extensionreplace} @emph{replace-str}}
|
||||
|
|
|
@ -2,3 +2,10 @@
|
|||
|
||||
echo '### Test fix #32191'
|
||||
seq 1 150 | parallel -j9 --retries 2 -S localhost,: "/bin/non-existant 2>/dev/null"
|
||||
|
||||
echo '### Test --tagstring'
|
||||
parallel -j1 -X -v --tagstring a{}b echo ::: 3 4
|
||||
parallel -j1 -k -v --tagstring a{}b echo ::: 3 4
|
||||
parallel -j1 -k -v --tagstring a{}b echo job{#} ::: 3 4
|
||||
parallel -j1 -k -v --tagstring ajob{#}b echo job{#} ::: 3 4
|
||||
|
||||
|
|
|
@ -1 +1,16 @@
|
|||
### Test fix #32191
|
||||
### Test --tagstring
|
||||
echo 3 4
|
||||
a3b a4b 3 4
|
||||
echo 3
|
||||
a3b 3
|
||||
echo 4
|
||||
a4b 4
|
||||
echo job1
|
||||
a3b job1
|
||||
echo job2
|
||||
a4b job2
|
||||
echo job1
|
||||
ajob1b job1
|
||||
echo job2
|
||||
ajob2b job2
|
||||
|
|
Loading…
Reference in a new issue