send-email: don't attempt to prompt if tty is closed
Attempting to prompt when the tty is closed (typically when running from cron) is pointless and emits a warning. This patch causes ask() to return early, squelching the warning. Signed-off-by: Jay Soffian <jaysoffian@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jay Soffian committed
Mar 31, 2009 at 12:22 UTC
5906f54e474c6e8aabb0f6b955d446b509cde06e
1 file changed
+3
git-send-email.perl
+3
@@ -612,6 +612,9 @@ sub ask {
612
my $default = $arg{default};
613
my $resp;
614
my $i = 0;
615
+ return defined $default ? $default : undef
616
+ unless defined $term->IN and defined fileno($term->IN) and
617
+ defined $term->OUT and defined fileno($term->OUT);
618
while ($i++ < 10) {
619
$resp = $term->readline($prompt);
620
if (!defined $resp) { # EOF