fix: batch: don't attempt to read if stdin is closed

This commit is contained in:
Stéphane Lesimple 2022-09-12 18:49:29 +00:00 committed by Stéphane Lesimple
parent b7f4909310
commit 720222c423

View file

@ -2,6 +2,8 @@
# vim: set filetype=perl ts=4 sw=4 sts=4 et:
use common::sense;
use Scalar::Util qw{ openhandle };
use File::Basename;
use lib dirname(__FILE__) . '/../../../lib/perl';
use OVH::Result;
@ -48,7 +50,8 @@ osh_info "Use 'exit', 'quit' or ^D to stop.";
osh_info "--- waiting for input";
my @ret;
while (my $line = <STDIN>) {
my $line;
while ((openhandle(\*STDIN)) && ($line = <STDIN>)) {
chomp $line;
last if (lc($line) eq 'exit' || lc($line) eq 'quit');