summaryrefslogtreecommitdiff
path: root/git-send-email.perl
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-07-02 16:03:59 -0700
committerJunio C Hamano <junkio@cox.net>2006-07-03 19:04:46 -0700
commit280242d1cc1fe2847f649d2f16b273e168fcbc48 (patch)
tree47e86796d0b55bf8752d4bb3717d3035bf2a8877 /git-send-email.perl
parent624314fda7e7bd1107db7de4e877ee6285d7d6eb (diff)
downloadgit-280242d1cc1fe2847f649d2f16b273e168fcbc48.tar.gz
send-email: do not barf when Term::ReadLine does not like your terminal
As long as we do not need to readline from the terminal, we should not barf when starting up the program. Without this patch, t9001 test on Cygwin occasionally died with the following error message: Unable to get Terminal Size. The TIOCGWINSZ ioctl didn't work. The COLUMNS and LINES environment variables didn't work. The resize program didn't work. at /usr/lib/perl5/vendor_perl/5.8/cygwin/Term/ReadKey.pm line 362. Compilation failed in require at /usr/lib/perl5/vendor_perl/5.8/Term/ReadLine/Perl.pm line 58. Acked-by: Ryan Anderson <ryan@michonline.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'git-send-email.perl')
-rwxr-xr-xgit-send-email.perl18
1 files changed, 17 insertions, 1 deletions
diff --git a/git-send-email.perl b/git-send-email.perl
index c5d9e73351..b04b8f40e9 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -22,6 +22,17 @@ use Term::ReadLine;
use Getopt::Long;
use Data::Dumper;
+package FakeTerm;
+sub new {
+ my ($class, $reason) = @_;
+ return bless \$reason, shift;
+}
+sub readline {
+ my $self = shift;
+ die "Cannot use readline on FakeTerm: $$self";
+}
+package main;
+
# most mail servers generate the Date: header, but not all...
$ENV{LC_ALL} = 'C';
use POSIX qw/strftime/;
@@ -46,7 +57,12 @@ my $smtp_server;
# Example reply to:
#$initial_reply_to = ''; #<20050203173208.GA23964@foobar.com>';
-my $term = new Term::ReadLine 'git-send-email';
+my $term = eval {
+ new Term::ReadLine 'git-send-email';
+};
+if ($@) {
+ $term = new FakeTerm "$@: going non-interactive";
+}
# Begin by accumulating all the variables (defined above), that we will end up
# needing, first, from the command line: