parallel: :::: - (stdin) also works. Test added for ::: and ::::

This commit is contained in:
Ole Tange 2011-05-05 18:52:23 +02:00
parent 0f7fdcdffb
commit ba6af9c3d2
4 changed files with 103 additions and 1 deletions

View file

@ -720,6 +720,7 @@ sub open_or_exit {
# exits if file cannot be opened
my $file = shift;
if($file eq "-") {
$Global::stdin_in_opt_a = 1;
return ($Global::original_stdin || *STDIN);
}
if(ref $file eq "GLOB") {
@ -3016,7 +3017,7 @@ sub start {
$pid = ::open3($in, ">&OUT", ">&ERR", $command) ||
::die_bug("open3-pipe");
$job->set_stdin($in);
} elsif(@::opt_a and $job->seq() == 1) {
} elsif(@::opt_a and not $Global::stdin_in_opt_a and $job->seq() == 1) {
# Give STDIN to the first job if using -a
*IN = *STDIN;
$pid = ::open3("<&IN", ">&OUT", ">&ERR", $command) ||

View file

@ -191,6 +191,8 @@ B<:::> and B<::::> can be mixed. So these are equivalent:
parallel echo {1} {2} {3} :::: <(seq 6 7) <(seq 4 5) :::: <(seq 1 3)
parallel -a <(seq 6 7) echo {1} {2} {3} :::: <(seq 4 5) :::: <(seq 1 3)
parallel -a <(seq 6 7) -a <(seq 4 5) echo {1} {2} {3} ::: 1 2 3
seq 6 7 | parallel -a - -a <(seq 4 5) echo {1} {2} {3} ::: 1 2 3
seq 4 5 | parallel echo {1} {2} {3} :::: <(seq 6 7) - ::: 1 2 3
=item B<::::> I<argfiles>

View file

@ -0,0 +1,20 @@
#!/bin/bash
echo '### Test :::: mixed with :::'
echo '### Test :::: < ::: :::'
parallel -k echo {1} {2} {3} :::: <(seq 6 7) ::: 4 5 ::: 1 2 3
echo '### Test :::: < < :::: <'
parallel -k echo {1} {2} {3} :::: <(seq 6 7) <(seq 4 5) :::: <(seq 1 3)
echo '### Test -a :::: < :::: <'
parallel -k -a <(seq 6 7) echo {1} {2} {3} :::: <(seq 4 5) :::: <(seq 1 3)
echo '### Test -a -a :::'
parallel -k -a <(seq 6 7) -a <(seq 4 5) echo {1} {2} {3} ::: 1 2 3
echo '### Test -a - -a :::'
seq 6 7 | parallel -k -a - -a <(seq 4 5) echo {1} {2} {3} ::: 1 2 3
echo '### Test :::: < - :::'
seq 4 5 | parallel -k echo {1} {2} {3} :::: <(seq 6 7) - ::: 1 2 3

View file

@ -0,0 +1,79 @@
### Test :::: mixed with :::
### Test :::: < ::: :::
6 4 1
6 4 2
6 4 3
6 5 1
6 5 2
6 5 3
7 4 1
7 4 2
7 4 3
7 5 1
7 5 2
7 5 3
### Test :::: < < :::: <
6 4 1
6 4 2
6 4 3
6 5 1
6 5 2
6 5 3
7 4 1
7 4 2
7 4 3
7 5 1
7 5 2
7 5 3
### Test -a :::: < :::: <
6 4 1
6 4 2
6 4 3
6 5 1
6 5 2
6 5 3
7 4 1
7 4 2
7 4 3
7 5 1
7 5 2
7 5 3
### Test -a -a :::
6 4 1
6 4 2
6 4 3
6 5 1
6 5 2
6 5 3
7 4 1
7 4 2
7 4 3
7 5 1
7 5 2
7 5 3
### Test -a - -a :::
6 4 1
6 4 2
6 4 3
6 5 1
6 5 2
6 5 3
7 4 1
7 4 2
7 4 3
7 5 1
7 5 2
7 5 3
### Test :::: < - :::
6 4 1
6 4 2
6 4 3
6 5 1
6 5 2
6 5 3
7 4 1
7 4 2
7 4 3
7 5 1
7 5 2
7 5 3