Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I silence an error in a makefile? [duplicate]

Tags:

makefile

I want to run diff in a makefile and catch the output,

test:
     diff a b > tmp

but diff returns non-zero if it catches any differences.

Make interprets the non-zero return code as an error, and even if I ignore the error using -diff, it still prints a warning.

makefile:7: recipe for target 'test' failed
make: [test] Error 1 (ignored)

Can I make it shut up?

like image 430
John Lawrence Aspden Avatar asked Mar 19 '23 11:03

John Lawrence Aspden


1 Answers

You need to make sure your recipe returns 0 (success) even if the diff command doesn't. Something like:

test:
        diff a b > tmp || true
like image 78
MadScientist Avatar answered Apr 25 '23 16:04

MadScientist