[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: |
Stephan Beal |
Subject: |
Re: make is setting exit code to 0 when gcc command fails |
Date: |
Tue, 10 Feb 2015 12:08:49 +0100 |
Beware: echo $$?
With 2 $, as that is a shell variable.
----- stephan
Sent from a mobile device, possibly from bed. Please excuse brevity and
typos.
On Feb 10, 2015 10:57 AM, "Reinier Post" <address@hidden> wrote:
> On Mon Feb 9 12:35:36 2015, address@hidden (Paul Smith) wrote:
> > 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?
>
> Guess: you're checking it like this:
>
> %.o: %.c
> $(CC) -c -o $@ $<
> @echo $?
>
> That won't work: each line will use a separate shell invocation, unless
>
> .ONESHELL:
>
> is specified.
>
> --
> Reinier Post
>
> _______________________________________________
> Help-make mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/help-make
>