【发布时间】:2012-05-16 05:48:42
【问题描述】:
在 KSH 中,我如何捕获 EXIT 信号并获取脚本的退出代码?
以下测试输出“About to exit script with return code 0”。我想让它从 exit 命令的返回码中输出 4。
#!/usr/bin/ksh
trapped_exit() {
typeset rc=$1
echo "(LOG SCRIPT EXECUTION & RETURN CODE)"
echo "About to exit script with return code $rc."
}
trap 'APP_RC=$?; trapped_exit $APP_RC' EXIT
exit 4
【问题讨论】:
标签: ksh