Possible Duplicate:
Get exit code of process that's piped to another
I am using the following command line (in a makefile) to pipe the verbose error messages from my compiler through a perl script that simplifies them into something human-readable:
g++ -c source.cpp -o source.o 2>&1 | perl /bin/gSTLFilt.pl
Unfortunately, this approach "masks" the error value returned by the g++
command. make has no idea that the g++
command has failed, because all it gets back is the error result from the perl
command.
Is there a way to pipe the output, and still retain the original error condition?
In case it makes a difference: I am using GNU Make 3.81 and g++ (GCC) 3.4.5 (mingw-vista special r3) in an MSYS console running GNU bash, version 2.04.0(1)-release (i686-pc-msys) on Windows XP.