Fixed with test: bug #36595: silent loss of input with --pipe and --sshlogin.

This commit is contained in:
Ole Tange 2012-06-08 01:07:25 +02:00
parent 9489733155
commit 38ccd3f193
3 changed files with 15 additions and 5 deletions

View file

@ -66,6 +66,11 @@ my @fhlist;
if(not @fhlist) {
@fhlist = (*STDIN);
}
if($::opt_skip_first_line) {
# Skip the first line for the first file handle
my $fh = $fhlist[0];
<$fh>;
}
if($::opt_header and not $::opt_pipe) {
my $fh = $fhlist[0];
# split with colsep or \t
@ -536,6 +541,7 @@ sub options_hash {
# Shebang #!/usr/bin/parallel --shebang
"shebang|hashbang" => \$::opt_shebang,
"Y" => \$::opt_retired,
"skip-first-line" => \$::opt_skip_first_line,
"header=s" => \$::opt_header,
);
}
@ -856,7 +862,8 @@ sub read_options {
$ARGV[0]=~s/^--hashbang *//; # remove --hashbang if it is set
my $argfile = pop @ARGV;
# exec myself to split $ARGV[0] into separate fields
exec "tail -n +1 $argfile | $0 @ARGV";
exec "$0 --skip-first-line -a $argfile @ARGV";
#exec "tail -n +1 $argfile | $0 @ARGV";
}
Getopt::Long::Configure("bundling","pass_through");
@ -2565,7 +2572,7 @@ sub simultaneous_sshlogin {
my $wanted_processes = shift;
my $sshcmd = $self->sshcommand();
my $serverlogin = $self->serverlogin();
my $cmd = "$sshcmd $serverlogin echo simultaneouslogin 2>&1 &"x$wanted_processes;
my $cmd = "$sshcmd $serverlogin echo simultaneouslogin </dev/null 2>&1 &"x$wanted_processes;
::debug("Trying $wanted_processes logins at $serverlogin");
open (SIMUL, "($cmd)|grep simultaneouslogin | wc -l|") or
::die_bug("simultaneouslogin");

View file

@ -20,7 +20,7 @@ EOF
chmod 755 /tmp/shebang
/tmp/shebang
echo '### Test of #! with 2 files as input'
echo '### Test of #! with 2 files as input (2 columns)'
cat >/tmp/shebang <<EOF
#!/usr/local/bin/parallel --shebang -rk --xapply -a /tmp/123 echo
A
@ -30,4 +30,5 @@ EOF
chmod 755 /tmp/shebang
seq 1 3 >/tmp/123
/tmp/shebang
echo '### bug #36595: silent loss of input with --pipe and --sshlogin'
seq 10000 | xargs | parallel --pipe -S 10/localhost cat | wc

View file

@ -6,7 +6,9 @@ C
A
B
C
### Test of #! with 2 files as input
### Test of #! with 2 files as input (2 columns)
A 1
B 2
C 3
### bug #36595: silent loss of input with --pipe and --sshlogin
1 10000 48894