set -e选项保证程序的每一步都执行正确,如果前面一部程序执行错误,则直接退出程序
001、 不加 set -e的情况
(base) [root@PC1 test2]# ls test.sh (base) [root@PC1 test2]# cat test.sh #!/bin/bash xxxx echo step2 (base) [root@PC1 test2]# bash test.sh test.sh: line 3: xxxx: command not found step2
002、添加set -e
(base) [root@PC1 test2]# ls test.sh (base) [root@PC1 test2]# cat test.sh #!/bin/bash set -e xxxx echo step2 (base) [root@PC1 test2]# bash test.sh test.sh: line 5: xxxx: command not found
标签:选项,test2,set,PC1,sh,shell,base,test From: https://www.cnblogs.com/liujiaxin2018/p/16757375.html