bug #35069: --pipe without command should give reasonable error message.

This commit is contained in:
Ole Tange 2011-12-18 21:49:37 +01:00
parent 2506e775f7
commit 6f3da78d6c
4 changed files with 25 additions and 12 deletions

View file

@ -131,7 +131,6 @@ for my $sshlogin (values %Global::host) {
$sshlogin->max_jobs_running();
}
init_run_jobs();
my $sem;
if($Global::semaphore) {
@ -4221,18 +4220,26 @@ sub get {
);
$cmd_line->populate();
::debug("cmd_line->number_of_args ".$cmd_line->number_of_args()."\n");
if(not $::opt_pipe and $cmd_line->number_of_args() == 0) {
if($::opt_pipe) {
if($cmd_line->replaced() eq "") {
# Empty command - pipe requires a command
print STDERR "$Global::progname: --pipe must have a ".
"command to pipe into (e.g. 'cat')\n";
::wait_and_exit(255);
}
} else {
if($cmd_line->number_of_args() == 0) {
# We did not get more args - maybe at EOF string?
return undef;
} elsif($cmd_line->replaced() eq "") {
# Empty command - get the next instead
return $self->get();
} else {
}
}
$self->set_seq($self->seq()+1);
return $cmd_line;
}
}
}
sub unget {
my $self = shift;

View file

@ -19,4 +19,7 @@ seq 2 | stdout parallel -X --eta echo
echo '### --timeout on remote machines'
parallel -j0 --timeout 3 --onall -S .. 'sleep {}; echo {}' ::: 1 6 7 ; echo $?
echo '### --pipe without command'
seq -w 10 | stdout parallel --pipe
EOF

View file

@ -22,3 +22,5 @@ Computers / CPU cores / Max jobs to run
1
1
2
### --pipe without command
parallel: --pipe must have a command to pipe into (e.g. 'cat')

View file

@ -12,6 +12,7 @@ cat ... | parallel --pipe [options] [command [arguments]]
{3} {3.} {3/} {3/.} Positional replacement strings
-S sshlogin Example: foo@server.example.com
--slf .. Use ~/.parallel/sshloginfile as the list of sshlogins
--trc {}.bar Shorthand for --transfer --return {}.bar --cleanup
--onall Run the given command with argument on all sshlogins
--nonall Run the given command with no arguments on all sshlogins