From 3f88a008c457aaabb23c8a80236762650f833642 Mon Sep 17 00:00:00 2001 From: Michael Pyne Date: Wed, 16 May 2012 20:20:40 -0400 Subject: [PATCH] Change colorizer name again to stop confusing Perl. Perl seems to assume that a lowercase function name that is not *known* to be a function defined in the current package might be a filehandle or some kind of other future reserved word. e.g. with "print foo ($message)" Perl thinks you're trying to send $message to the filehandle foo if foo wasn't defined in the current package (even if it's imported from another module). To fix this we make the function start with a capital letter (to fix the potential reserved word warning from the last commit changing colorizer name), and always reference the full package when using the subroutine from outside of ksb::Debug. --- kdesrc-build | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/kdesrc-build b/kdesrc-build index df8338d..a7fce35 100755 --- a/kdesrc-build +++ b/kdesrc-build @@ -129,14 +129,12 @@ my $run_mode = 'build'; # Determines if updating, building, installing, etc. my $pkg = shift; my $caller = caller; my @exports = qw(debug pretending debugging whisper - note info warning error pretend ksb_clr); + note info warning error pretend); ksb::Util::exportFunctionsToPackage($pkg, $caller, @exports); } - # I'm lazy and would rather write in shorthand for the colors. This sub - # allows me to do so. - sub ksb_clr + sub ksb::Debug::colorize { my $str = shift; @@ -209,22 +207,24 @@ my $run_mode = 'build'; # Determines if updating, building, installing, etc. # You can also use the pretend output subroutine, which is emitted if, and only # if pretend mode is enabled. # - # ksb_clr is automatically run on the input for all of those functions. - # Also, the terminal color is automatically reset to normal as well so you don't - # need to manually add the ] to reset. + # ksb::Debug::colorize is automatically run on the input for all of those + # functions. Also, the terminal color is automatically reset to normal as + # well so you don't need to manually add the ] to reset. - # Subroutine used to actually display the data, calls ksb_clr on each entry first. + # Subroutine used to actually display the data, calls ksb::Debug::colorize on each entry first. sub print_clr(@) { - print ksb_clr($_) foreach (@_); - print ksb_clr("]\n"); + # Leading + prevents Perl from assuming the plain word "colorize" is actually + # a filehandle or future reserved word. + print +colorize($_) foreach (@_); + print +colorize("]\n"); if (defined $screenLog) { my @savedColors = ($RED, $GREEN, $YELLOW, $NORMAL, $BOLD); # Remove color but still extract codes ($RED, $GREEN, $YELLOW, $NORMAL, $BOLD) = ("") x 5; - print ($screenLog ksb_clr($_)) foreach (@_); + print ($screenLog colorize($_)) foreach (@_); print ($screenLog "\n"); ($RED, $GREEN, $YELLOW, $NORMAL, $BOLD) = @savedColors; @@ -258,8 +258,8 @@ my $run_mode = 'build'; # Determines if updating, building, installing, etc. sub error(@) { - print STDERR (ksb_clr $_) foreach (@_); - print STDERR (ksb_clr "]\n"); + print STDERR (colorize $_) foreach (@_); + print STDERR (colorize "]\n"); } sub pretend(@) @@ -1808,15 +1808,15 @@ EOF { # Something *is* running, likely kdesrc-build. Don't use error, # it'll scan for $! - print ksb_clr(" r[*y[*r[*] kdesrc-build appears to be running. Do you want to:\n"); - print ksb_clr(" (b[Q])uit, (b[P])roceed anyways?: "); + print ksb::Debug::colorize(" r[*y[*r[*] kdesrc-build appears to be running. Do you want to:\n"); + print ksb::Debug::colorize(" (b[Q])uit, (b[P])roceed anyways?: "); my $choice = ; chomp $choice; if (lc $choice ne 'p') { - say ksb_clr(" y[*] kdesrc-build run canceled."); + say ksb::Debug::colorize(" y[*] kdesrc-build run canceled."); return 0; } @@ -5243,7 +5243,7 @@ EOF my $message; if (not defined $count) { - $message = ksb_clr ("b[y[Unknown changes]."); + $message = ksb::Debug::colorize ("b[y[Unknown changes]."); $ipc->notifyUpdateSuccess($moduleName, $message); } elsif ($count) @@ -7399,7 +7399,7 @@ sub check_for_ssh_agent if ($noKeys) { # Use print so user can't inadvertently keep us quiet about this. - print ksb_clr (<