-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
set章节
设置-e参数,会导致trap命令失效(参考《trap 命令》一章),-E参数可以纠正这个行为。
对于-E参数的解释不同于官方手册
-E If set, any trap on ERR is inherited by shell functions, command substitutions, and commands executed in a subshell environment. The ERR trap is normally not in‐herited in such cases.
例如,函数中的错误是不会触发err trap,设置-E以后,函数中的错误也可以触发err trap
示例中的err trap是因为myfunc的调用返回值非0,所以触发err trap,如果在myfunc中添加return 0,就不会有err trap
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels