help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: make is setting exit code to 0 when gcc command fails


From: Paul Smith
Subject: Re: make is setting exit code to 0 when gcc command fails
Date: Mon, 09 Feb 2015 12:35:36 -0500

On Mon, 2015-02-09 at 16:19 +0000, David Aldrich wrote:
> If I deliberately introduce a syntax error into one of my C files,
> make calls gcc to build the file, as expected, and an error is
> reported as text in bash.  However, the exit code (checked using echo
> $?) returns 0.  If I run the gcc command from the bash command line,
> the exit code is 1.
> 
> Why might make return 0 instead of 1 in the case of this compiler
> error?

Why don't you provide a sample of the makefile that doesn't work?  That
would be much simpler than us guessing at all the reasons it could be
wrong with no other information.

Typically this happens because your recipe does something AFTER the
compile command, and you aren't preserving the exit code and using it
when you exit from the recipe.

> I am running gnu make 3.81 on Centos 5, with a bash shell.

Note that make ALWAYS uses "/bin/sh", regardless of the user's shell,
unless you set the make SHELL variable in your makefile.  Of course, on
Red Hat-based systems, /bin/sh is bash (although running in a slightly
more standard mode).




reply via email to

[Prev in Thread] Current Thread [Next in Thread]