I am trying to instruct GNU Make 3.81 to not stop if a command fails (so I prefix the command with -) but I also want to check the exit status on the next command and print a more informative message. However my Makefile below fails:
$ cat Makefile
all:
-/bin/false
([ $$? -eq 0 ] && echo "success!") || echo "failure!"
$
$ make
/bin/false
make: [all] Error 1 (ignored)
([ $? -eq 0 ] && echo "success!") || echo "failure!"
success!
Why does the Makefile above echo "success!" instead of "failure!" ?
update:
Following and expanding on the accepted answer, below is how it should be written:
failure:
@-/bin/false && ([ $$? -eq 0 ] && echo "success!") || echo "failure!"
success:
@-/bin/true && ([ $$? -eq 0 ] && echo "success!") || echo "failure!"