Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
The command
$ make all
gives errors such as
rm: cannot remove '.lambda': No such file or directory
so it stops. I want it to ignore the rm-not-found-errors. How can I force-make?
Makefile
make clean
make .lambda
make .lambda_t
make .activity
make .activity_t_lambda
clean:
rm .lambda .lambda_t .activity .activity_t_lambda
.lambda:
awk '{printf "%.4f \n", log(2)/log(2.71828183)/$$1}' t_year > .lambda
.lambda_t:
paste .lambda t_year > .lambda_t
.activity:
awk '{printf "%.4f \n", $$1*2.71828183^(-$$1*$$2)}' .lambda_t > .activity
.activity_t_lambda:
paste .activity t_year .lambda | sed -e 's@\t@\t\&\t@g' -e 's@$$@\t\\\\@g' | tee > .activity_t_lambda > ../RESULTS/currentActivity.tex
Try the
-i
flag (or
--ignore-errors
).
The documentation
seems to suggest a more robust way to achieve this, by the way:
To ignore errors in a command line, write a
-
at the beginning of the line's text (after the initial tab). The
-
is discarded before the command is passed to the shell for execution.
For example,
clean:
-rm -f *.o
This causes rm
to continue even if it is unable to remove a file.
All examples are with rm
, but are applicable to any other command you need to ignore errors from (i.e. mkdir
).
–
–
–
–
–
–
–
–
Return successfully by blocking rm
's returncode behind a pipe with the true
command, which always returns 0
(success)
rm file || true
–
–
–
To get make to actually ignore errors on a single line, you can simply suffix it with ; true
, setting the return value to 0. For example:
rm .lambda .lambda_t .activity .activity_t_lambda 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.
–
Usage of -
seems to be a proper way of handling such situations as it can ignore the error of a specific command, but not all errors.
You can find more information by the following link.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.