小编rap*_*lon的帖子

尽管set -e和/或trap处于活动状态,但未捕获Bash退出状态

有人可以在下面的代码片段中解释bash / set -e行为吗?

#!/bin/bash

# Comment if you want to test the trap only
set -e -o pipefail -u -E

# Comment if you want to test the set -e only
trap "echo ERROR CAUGHT; exit 12" ERR

function reproduce() {
    # Trigger arithmetic error on purpose
    a=$((1109962735 - hello=12272 + 1))
}

reproduce

# The script is expected to trigger the trap and/or activate the set -e. In both cases it should stop and exit here on error. …
Run Code Online (Sandbox Code Playgroud)

bash

8
推荐指数
1
解决办法
98
查看次数

标签 统计

bash ×1