From 516e39a71f9a8f6e0d01fd13c40e4db0557de8df Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sat, 24 Mar 2012 01:23:58 +0100 Subject: [PATCH] Don't color output by default, add --color option. Thanks to Jari Aalto for the suggestion. --- bin/blhc | 13 +++++++++++-- t/tests.t | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/bin/blhc b/bin/blhc index 465ce0f..f7988b5 100755 --- a/bin/blhc +++ b/bin/blhc @@ -154,6 +154,9 @@ my %flag_renames = ( '-Wl,(-z,)?now' => '-Wl,-z,now', ); +# Use colored (ANSI) output? +my $option_color; + # FUNCTIONS @@ -189,8 +192,7 @@ sub error_hardening_wrapper { sub error_color { my ($message, $color) = @_; - # Use colors when writing to a terminal. - if (-t STDOUT) { + if ($option_color) { return Term::ANSIColor::colored($message, $color); } else { return $message; @@ -300,6 +302,7 @@ my $option_version = 0; my $option_all = 0; my $option_arch = undef; my $option_buildd = 0; + $option_color = 0; if (not Getopt::Long::GetOptions( 'help|h|?' => \$option_help, 'version' => \$option_version, @@ -308,6 +311,7 @@ if (not Getopt::Long::GetOptions( 'bindnow' => \$harden_bindnow, 'all' => \$option_all, # Misc. + 'color' => \$option_color, 'arch' => \$option_arch, 'buildd' => \$option_buildd, )) { @@ -623,6 +627,7 @@ B [--pie] [--bindnow] [--all] --all force +all (+pie, +bindnow) check --arch set architecture (autodetected) --buildd parser mode for buildds + --color use colored output =head1 DESCRIPTION @@ -674,6 +679,10 @@ detected). =back +=item B<--color> + +Use colored (ANSI) output for warning messages. + =back Auto detection for B<--pie> and B<--bindnow> only works if at least one diff --git a/t/tests.t b/t/tests.t index c462cfc..9d0014f 100644 --- a/t/tests.t +++ b/t/tests.t @@ -51,6 +51,7 @@ Usage: --all force +all (+pie, +bindnow) check --arch set architecture (autodetected) --buildd parser mode for buildds + --color use colored output '; -- 2.43.2