> >On Mon Feb 9 12:35:36 2015, psm...@gnu.org (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.
Indeed! +1 And in addition, to get the recipe to terminate on the first error, add the following target. .POSIX: This may not be what you want to do in general for your other recipes - you have to decide - but it works in this case. I find the combination of .ONESHELL: and .POSIX: (and .SHELL=/bin/bash) is EXACTLY what I want in ALL my recipes. > >-- >Reinier Post > >_______________________________________________ >Help-make mailing list >Help-make@gnu.org >https://lists.gnu.org/mailman/listinfo/help-make _______________________________________________ Help-make mailing list Help-make@gnu.org https://lists.gnu.org/mailman/listinfo/help-make