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>
Michael Witten committed
Feb 3, 2008 at 19:53 UTC
874299760708e3bd4d63e9afa8da3fe8a7ddc006
1 file changed
+23
-2
git-send-email.perl
+23
-2
@@ -24,8 +24,6 @@ use Data::Dumper;
24
use Term::ANSIColor;
25
use Git;
26
27
-$SIG{INT} = sub { print color("reset"), "\n"; exit };
28
-
27
package FakeTerm;
28
sub new {
29
my ($class, $reason) = @_;
@@ -201,6 +199,29 @@ my %config_settings = (
199
"aliasesfile" => \@alias_files,
200
);
201
202
+# Handle Uncouth Termination
203
+sub signal_handler {
204
+
205
+ # Make text normal
206
+ print color("reset"), "\n";
207
+
208
+ # SMTP password masked
209
+ system "stty echo";
210
+
211
+ # tmp files from --compose
212
+ if (-e $compose_filename) {
213
+ print "'$compose_filename' contains an intermediate version of the email you were composing.\n";
214
+ }
215
+ if (-e ($compose_filename . ".final")) {
216
+ print "'$compose_filename.final' contains the composed email.\n"
217
+ }
218
+
219
+ exit;
220
+};
221
+
222
+$SIG{TERM} = \&signal_handler;
223
+$SIG{INT} = \&signal_handler;
224
+
225
# Begin by accumulating all the variables (defined above), that we will end up
226
# needing, first, from the command line:
227