To test the command that I know will return a non-zero exit code, I use like this:
test: mybadcommand mybadcommand; test $$? -eq 1
This checks that mybadcommand returns a value of 1 output. Note that in Make files you are required to avoid a shell variable that refers to exit statuses, because in the world of make $? means addictions that are newer than the goal.
So, in the above snippet, be careful to use $$? , not $ ?.
source share