diff options
author | Max Kanat-Alexander <mkanat@bugzilla.org> | 2010-04-20 01:21:58 +0200 |
---|---|---|
committer | Max Kanat-Alexander <mkanat@bugzilla.org> | 2010-04-20 01:21:58 +0200 |
commit | 049ae4ae5d0367485910064f62b1baf38fdaad04 (patch) | |
tree | 1be645e4d0d5fdf6b1bb81aea55f07cabea0e361 /Bugzilla/Install/Util.pm | |
parent | 3944a53b67f20592b960f03c65d9ff2b490f58fb (diff) | |
download | bugzilla-049ae4ae5d0367485910064f62b1baf38fdaad04.tar.gz bugzilla-049ae4ae5d0367485910064f62b1baf38fdaad04.tar.xz |
Bug 560284: Make all errors that checksetup.pl throws be red
r=mkanat, a=mkanat (module owner)
Diffstat (limited to 'Bugzilla/Install/Util.pm')
-rw-r--r-- | Bugzilla/Install/Util.pm | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Bugzilla/Install/Util.pm b/Bugzilla/Install/Util.pm index 6621a7a41..7bafa9330 100644 --- a/Bugzilla/Install/Util.pm +++ b/Bugzilla/Install/Util.pm @@ -32,6 +32,7 @@ use File::Basename; use POSIX qw(setlocale LC_CTYPE); use Safe; use Scalar::Util qw(tainted); +use Term::ANSIColor qw(colored); use base qw(Exporter); our @EXPORT_OK = qw( @@ -559,9 +560,25 @@ sub get_console_locale { sub init_console { eval { ON_WINDOWS && require Win32::Console::ANSI; }; $ENV{'ANSI_COLORS_DISABLED'} = 1 if ($@ || !-t *STDOUT); + $SIG{__DIE__} = \&_console_die; prevent_windows_dialog_boxes(); } +sub _console_die { + my ($message) = @_; + # $^S means "we are in an eval" + if ($^S) { + die $message; + } + # Remove newlines from the message before we color it, and then + # add them back in on display. Otherwise the ANSI escape code + # for resetting the color comes after the newline, and Perl thinks + # that it should put "at Bugzilla/Install.pm line 1234" after the + # message. + $message =~ s/\n+$//; + die colored($message, COLOR_ERROR) . "\n"; +} + sub prevent_windows_dialog_boxes { # This code comes from http://bugs.activestate.com/show_bug.cgi?id=82183 # and prevents Perl modules from popping up dialog boxes, particularly |