linux – ‘set -e’做了什么,为什么它会被认为是危险的?

这个问题出现在面试前的测验中,这让我很疯狂.任何人都可以回答这个并让我放心吗?测验没有引用特定的shell,但作业描述是针对unix sa的.

What does ‘set -e’ do, and why might it be considered dangerous?

如果任何子命令或管道返回非零状态,set -e会导致shell退出.


It would be dangerous to use “set -e” when creating init.d scripts: 9.3.2 –

Be careful of using set -e in init.d scripts. Writing correct init.d scripts requires accepting various error exit statuses when daemons are already running or already stopped without aborting the init.d script, and common init.d function libraries are not safe to call with set -e in effect. For init.d scripts, it’s often easier to not use set -e and instead check the result of each command separately.


转载注明原文:linux – ‘set -e’做了什么,为什么它会被认为是危险的? - 代码日志