How to ignore mv error?
Errors in Recipes (from TFM)
To ignore errors in a recipe line, write a
-
at the beginning of the line's text (after the initial tab).
So the target would be something like:
moveit:
-mv foo.o ../baz
I notice nobody has actually answered the original question itself yet, specifically how to ignore errors (all the answers are currently concerned with only calling the command if it won't cause an error).
To actually ignore errors, you can simply do:
mv -f foo.o ../baz 2>/dev/null; true
This will redirect stderr
output to null
, and follow the command with true
(which always returns 0
, causing make to believe the command succeeded regardless of what actually happened), allowing program flow to continue.