Bash - 按顺序执行命令,但如果失败则忽略

时间:2016-04-11 21:01:53

标签: node.js bash

我有以下bash命令:

echo "istanbul cover /Users/amills001c/WebstormProjects/oresoftware/suman/test/build-tests/empty.js --dir ./coverage/empty.js
istanbul cover /Users/amills001c/WebstormProjects/oresoftware/suman/test/build-tests/test6.js --dir ./coverage/test6.js
istanbul cover /Users/amills001c/WebstormProjects/oresoftware/suman/test/build-tests/test7-start.js --dir ./coverage/test7-start.js
istanbul cover /Users/amills001c/WebstormProjects/oresoftware/suman/test/build-tests/test8.js --dir ./coverage/test8.js
istanbul cover /Users/amills001c/WebstormProjects/oresoftware/suman/test/build-tests/test9.js --dir ./coverage/test9.js
istanbul report" | bash

我想按顺序执行每一行。但是如果一个命令失败(以非零退出代码退出?),我还是想继续。

以上是否足够?我相信使用&&如果进程失败,将不会继续。我正在使用换行符分隔命令,如果这足够好的话。

1 个答案:

答案 0 :(得分:1)

是的,这就足够了。你可以尝试看看:

$ echo "true
true
false
true
echo 'Still running'" | bash
Still running