summaryrefslogtreecommitdiff
blob: b14a92b59a6324c40b3aafd2f6f961cc5447de74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
--- a/colorgcc
+++ b/colorgcc
@@ -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>)
 {