Make:命令失败后如何继续? [英] Make: how to continue after a command fails?

查看:865
本文介绍了Make:命令失败后如何继续?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

命令$ make all给出诸如rm: cannot remove '.lambda': No such file or directory之类的错误,因此它停止了.我希望它忽略rm-not-found-errors.我该如何强制制作?

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?

制作文件

all:
        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

推荐答案

尝试使用-i标志(或--ignore-errors). 文档似乎提出了一种更强大的方法来实现此目标,方法是方式:

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.

例如,

clean:
  -rm -f *.o

即使无法删除文件,这也会导致rm继续.

This causes rm to continue even if it is unable to remove a file.

所有示例均与rm一起使用,但适用于您需要忽略其错误(例如mkdir)的任何其他命令.

All examples are with rm, but are applicable to any other command you need to ignore errors from (i.e. mkdir).

这篇关于Make:命令失败后如何继续?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆