blob: 9602146b0af9ae35c89642eee8b7eaaa84010873 [file] [log] [blame]
--- /usr/bin/colorgcc 2010-12-13 00:08:37.000000000 -0200
+++ colorgcc 2011-10-05 15:26:53.000000000 -0300
@@ -221,17 +221,16 @@
# Figure out which compiler to invoke based on our program name.
$0 =~ m%.*/(.*)$%;
my $progName = $1 || $0;
-my $compiler_pid;
+my $compiler;
# If called as "colorgcc", just filter STDIN to STDOUT.
-if ($progName eq 'colorgcc')
+if ($progName =~ m/^colorgcc[-0-9.]*(\.pl)?$/)
{
- open(GCCOUT, "<&STDIN");
+ $compiler = 'gcc';
}
else
{
# See if the user asked for a specific compiler.
- my $compiler;
if (!defined($compiler = $compilerPaths{$progName}))
{
# Find our wrapper dir on the PATH and tweak the PATH to remove
@@ -257,23 +256,23 @@
}
$compiler = $progName;
}
+}
- # Get the terminal type.
- my $terminal = $ENV{"TERM"} || "dumb";
+# Get the terminal type.
+my $terminal = $ENV{"TERM"} || "dumb";
- # If it's in the list of terminal types not to color, or if
- # we're writing to something that's not a tty, don't do color.
- if (! -t STDOUT || $nocolor{$terminal})
- {
+# If it's in the list of terminal types not to color, or if
+# we're writing to something that's not a tty, don't do color.
+if (! -t STDOUT || $nocolor{$terminal})
+{
exec $compiler, @ARGV
or die("Couldn't exec");
- }
-
- # Keep the pid of the compiler process so we can get its return
- # code and use that as our return code.
- $compiler_pid = open3('<&STDIN', \*GCCOUT, \*GCCOUT, $compiler, @ARGV);
}
+# Keep the pid of the compiler process so we can get its return
+# code and use that as our return code.
+my $compiler_pid = open3('<&STDIN', \*GCCOUT, \*GCCOUT, $compiler, @ARGV);
+
# Colorize the output from the compiler.
while(<GCCOUT>)
{