diff options
author | Michael Witten <mfwitten@MIT.EDU> | 2008-02-03 19:53:57 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-02-05 00:36:10 -0800 |
commit | 874299760708e3bd4d63e9afa8da3fe8a7ddc006 (patch) | |
tree | bd2bbb2a20cc02029ceb5dbe06eb88b992608431 /git-send-email.perl | |
parent | 2363d7467dcd60467b3e694b3ba6f859bb226f5c (diff) | |
download | git-874299760708e3bd4d63e9afa8da3fe8a7ddc006.tar.gz |
git-send-email: SIG{TERM,INT} handlers
A single signal handler is used for both SIGTERM and
SIGINT in order to clean up after an uncouth termination
of git-send-email.
In particular, the handler resets the text color (this cleanup
was already present), turns on tty echoing (in case termination
occurrs during a masked Password prompt), and informs the user
of of any temporary files created by --compose.
Signed-off-by: Michael Witten <mfwitten@mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-send-email.perl')
-rwxr-xr-x | git-send-email.perl | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/git-send-email.perl b/git-send-email.perl index fec55ea2df..14268fc1d4 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -24,8 +24,6 @@ use Data::Dumper; use Term::ANSIColor; use Git; -$SIG{INT} = sub { print color("reset"), "\n"; exit }; - package FakeTerm; sub new { my ($class, $reason) = @_; @@ -201,6 +199,29 @@ my %config_settings = ( "aliasesfile" => \@alias_files, ); +# Handle Uncouth Termination +sub signal_handler { + + # Make text normal + print color("reset"), "\n"; + + # SMTP password masked + system "stty echo"; + + # tmp files from --compose + if (-e $compose_filename) { + print "'$compose_filename' contains an intermediate version of the email you were composing.\n"; + } + if (-e ($compose_filename . ".final")) { + print "'$compose_filename.final' contains the composed email.\n" + } + + exit; +}; + +$SIG{TERM} = \&signal_handler; +$SIG{INT} = \&signal_handler; + # Begin by accumulating all the variables (defined above), that we will end up # needing, first, from the command line: |