Answers:
用set +e。是的,使用启用 shell选项set -并使用禁用它们是很落后的set +。历史葡萄干,donchanow。
+就像,-但是越过某物意味着“不”,如“≠”。
每次要覆盖它时,使用set +e/ 可能都不方便set -e。我找到了一个更简单的解决方案。
而不是这样做:
set +e
command_that_might_fail_but_we_want_to_ignore_it
set -e
您可以这样做:
command_that_might_fail_but_we_want_to_ignore_it || true
或者,如果您想保存击键操作,又不介意有点晦涩,请执行以下操作:
command_that_might_fail_but_we_want_to_ignore_it || :
希望这可以帮助!
:,并在这里找到我的答案,以防其他人感到好奇。