mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-11-22 14:07:55 +00:00
bug #35544: --pipe would read from :::: (-a)
This commit is contained in:
parent
6f730374d8
commit
bcebac44b1
12
src/parallel
12
src/parallel
|
@ -156,7 +156,7 @@ if($Global::semaphore) {
|
|||
$SIG{TERM} = \&start_no_new_jobs;
|
||||
start_more_jobs();
|
||||
if($::opt_pipe) {
|
||||
spreadstdin();
|
||||
spreadstdin(@fhlist);
|
||||
}
|
||||
reap_if_needed();
|
||||
::debug("Start draining\n");
|
||||
|
@ -177,6 +177,7 @@ sub __PIPE_MODE__ {}
|
|||
sub spreadstdin {
|
||||
# read a record
|
||||
# Spawn a job and print the record to it.
|
||||
my @fhlist = @_; # Filehandles to read from (Defaults to STDIN)
|
||||
my $record;
|
||||
my $buf = "";
|
||||
my $header = "";
|
||||
|
@ -220,7 +221,8 @@ sub spreadstdin {
|
|||
my $recendrecstart = $recend.$recstart;
|
||||
# Force the while-loop once if everything was read by header reading
|
||||
my $force_one_time_through = 0;
|
||||
while(!$force_one_time_through++ or read(STDIN,substr($buf,length $buf,0),$::opt_blocksize)) {
|
||||
for my $in (@fhlist) {
|
||||
while(!$force_one_time_through++ or read($in,substr($buf,length $buf,0),$::opt_blocksize)) {
|
||||
# substr above = append to $buf
|
||||
reap_if_needed(); # Re-enable reaping after read() (Bug#33352)
|
||||
if($::opt_r) {
|
||||
|
@ -269,13 +271,15 @@ sub spreadstdin {
|
|||
}
|
||||
}
|
||||
}
|
||||
do_not_reap(); # Disable reaping before read(STDIN) (Bug#33352)
|
||||
do_not_reap(); # Disable reaping before read($in) (Bug#33352)
|
||||
}
|
||||
}
|
||||
|
||||
# If there is anything left in the buffer write it
|
||||
substr($buf,0,0) = $header;
|
||||
write_record_to_pipe(\$buf,$recstart,$recend);
|
||||
|
||||
::debug("Done reading STDIN\n");
|
||||
::debug("Done reading input\n");
|
||||
flush_and_close_pipes();
|
||||
::debug("Done flushing to children\n");
|
||||
$Global::start_no_new_jobs = 1;
|
||||
|
|
|
@ -43,4 +43,8 @@ echo '### Test --wd .';
|
|||
ssh $SSHLOGIN2 mkdir -p mydir;
|
||||
mkdir -p $HOME/mydir; cd $HOME/mydir;
|
||||
parallel --workdir . -S $SSHLOGIN2 ::: pwd
|
||||
|
||||
echo '### bug #35544: --pipe would read from :::: (-a)';
|
||||
parallel -j1 --pipe echo foo\;cat ::: a b c :::: <(seq 3) <(seq 4 6)
|
||||
|
||||
EOF
|
||||
|
|
|
@ -70,3 +70,16 @@ vm1
|
|||
/home/parallel/mydir
|
||||
### Test --wd .
|
||||
/home/parallel/mydir
|
||||
### bug #35544: --pipe would read from :::: (-a)
|
||||
foo
|
||||
a
|
||||
b
|
||||
c
|
||||
foo
|
||||
1
|
||||
2
|
||||
3
|
||||
foo
|
||||
4
|
||||
5
|
||||
6
|
||||
|
|
Loading…
Reference in a new issue