Re-fixed bug #45841: Replacement string for total no of jobs. --bar works, too.

This commit is contained in:
Ole Tange 2015-10-18 15:18:30 +02:00
parent 03a35016a9
commit b244ddf7ca
5 changed files with 44 additions and 21 deletions

View file

@ -5614,7 +5614,7 @@ sub sshcommand_of_sshlogin {
$sshcmd = $opt::ssh; $serverlogin = $self->{'string'};
}
}
if($serverlogin =~ s/(\S+)\@(\S+)/$2/) {
# convert user@server to '-l user server'
# because lsh does not support user@server
@ -5748,7 +5748,7 @@ sub new {
return bless {
'unget' => \@unget,
'commandlinequeue' => $commandlinequeue,
'this_job_no' => 1,
'this_job_no' => 0,
'total_jobs' => undef,
}, ref($class) || $class;
}
@ -5756,17 +5756,15 @@ sub new {
sub get {
my $self = shift;
$self->{'this_job_no'}++;
if(@{$self->{'unget'}}) {
$self->{'this_job_no'}++;
my $job = shift @{$self->{'unget'}};
return ($job);
return shift @{$self->{'unget'}};
} else {
my $commandline = $self->{'commandlinequeue'}->get();
if(defined $commandline) {
$self->{'this_job_no'}++;
my $job = Job->new($commandline);
return $job;
return Job->new($commandline);
} else {
$self->{'this_job_no'}--;
return undef;
}
}
@ -5819,8 +5817,11 @@ sub total_jobs {
}
}
$record_queue->unget(@arg_records);
$self->{'total_jobs'} = $#arg_records+1+$self->{'this_job_no'};
::debug("init","Total jobs: ".$self->{'total_jobs'}."\n");
$self->{'total_jobs'} =
::ceil((1+$#arg_records+$self->{'this_job_no'})
/ ::max($Global::max_number_of_args,1));
::debug("init","Total jobs: ".$self->{'total_jobs'}.
" (".(1+$#arg_records)."+".$self->{'this_job_no'}.")\n");
}
return $self->{'total_jobs'};
}

View file

@ -1198,13 +1198,16 @@ control on the command line (used by GNU B<parallel> internally when
called with B<--sshlogin>).
=item B<--plus>
=item B<--plus> (alpha testing)
Activate additional replacement strings: {+/} {+.} {+..} {+...} {..}
{...} {/..} {/...}. The idea being that '{+foo}' matches the opposite of
{...} {/..} {/...} {##}. The idea being that '{+foo}' matches the opposite of
'{foo}' and {} = {+/}/{/} = {.}.{+.} = {+/}/{/.}.{+.} = {..}.{+..} =
{+/}/{/..}.{+..} = {...}.{+...} = {+/}/{/...}.{+...}
B<{##}> is the number of jobs to be run. It is incompatible with
B<-X>/B<-m>/B<--xargs>.
=item B<--progress>

View file

@ -233,10 +233,10 @@ parallel --wd . 'pwd; echo $OLDPWD; echo' ::: OK
echo '**'
echo 'bug #46232: {%} with --bar/--eta/--shuf or --halt xx% broken'
parallel --bar -kj2 echo {%} ::: a b ::: c d e 2>/dev/null
parallel --halt now,fail=10% -kj2 echo {%} ::: a b ::: c d e
parallel --eta -kj2 echo {%} ::: a b ::: c d e 2>/dev/null
parallel --shuf -kj2 echo {%} ::: a b ::: c d e 2>/dev/null
parallel --bar -kj2 --delay 0.1 echo {%} ::: a b ::: c d e 2>/dev/null
parallel --halt now,fail=10% -kj2 --delay 0.1 echo {%} ::: a b ::: c d e
parallel --eta -kj2 --delay 0.1 echo {%} ::: a b ::: c d e 2>/dev/null
parallel --shuf -kj2 --delay 0.1 echo {%} ::: a b ::: c d e 2>/dev/null
echo '**'
@ -251,6 +251,9 @@ echo '{##} bug #45841: Replacement string for total no of jobs'
parallel --plus echo {##} ::: {a..j};
parallel -k 'echo {= $::G++ > 3 and ($_=$Global::JobQueue->total_jobs());=}' ::: {1..10}
parallel -N7 --plus echo {#} {##} ::: {1..14}
parallel -N7 --plus echo {#} {##} ::: {1..15}
parallel -X --plus echo {#} {##} ::: {1..15}
echo '**'

View file

@ -69,6 +69,6 @@ Non-shellshock-hardened to shellshock-hardened
Function shellshock-hardened
echo '### Test --load (must give 1=true)'
### Test --load (must give 1=true)
parallel -j0 -N0 --timeout 5 --nice 10 'bzip2 < /dev/zero >/dev/null' ::: 1 2 3 & parallel --argsep ,, --joblog - -N0 parallel --load 100% echo ::: 1 ,, 1 | parallel --colsep '\t' --header : echo '{=4 $_=$_>5=}'
parallel -j0 -N0 --timeout 5 --nice 10 'bzip2 < /dev/zero >/dev/null' ::: 1 2 3 4 5 6 & parallel --argsep ,, --joblog - -N0 parallel --load 100% echo ::: 1 ,, 1 | parallel --colsep '\t' --header : echo '{=4 $_=$_>5=}'
1

View file

@ -479,28 +479,28 @@ echo '**'
**
echo 'bug #46232: {%} with --bar/--eta/--shuf or --halt xx% broken'
bug #46232: {%} with --bar/--eta/--shuf or --halt xx% broken
parallel --bar -kj2 echo {%} ::: a b ::: c d e 2>/dev/null
parallel --bar -kj2 --delay 0.1 echo {%} ::: a b ::: c d e 2>/dev/null
1
2
1
2
1
2
parallel --halt now,fail=10% -kj2 echo {%} ::: a b ::: c d e
parallel --halt now,fail=10% -kj2 --delay 0.1 echo {%} ::: a b ::: c d e
1
2
1
2
1
2
parallel --eta -kj2 echo {%} ::: a b ::: c d e 2>/dev/null
parallel --eta -kj2 --delay 0.1 echo {%} ::: a b ::: c d e 2>/dev/null
1
2
1
2
1
2
parallel --shuf -kj2 echo {%} ::: a b ::: c d e 2>/dev/null
parallel --shuf -kj2 --delay 0.1 echo {%} ::: a b ::: c d e 2>/dev/null
1
2
1
@ -542,6 +542,22 @@ echo '{##} bug #45841: Replacement string for total no of jobs'
10
10
10
parallel -N7 --plus echo {#} {##} ::: {1..14}
1 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2
parallel -N7 --plus echo {#} {##} ::: {1..15}
1 3 3 3 3 3 3 3
2 3 3 3 3 3 3 3
3 3
parallel -X --plus echo {#} {##} ::: {1..15}
1 15 15
2 15 15
3 15 15
4 15 15
5 15 15
6 15 15
7 15 15
8 15
echo '**'
**
### 1 .par file from --files expected