#!/bin/bash
set -eEuo pipefail
set -x
function deploy_cleanup(){
echo "---Cleaning up---"
echo "hello"
}
trap deploy_cleanup ERR
whoami
source euaueoaue
输出:
+ trap deploy_cleanup ERR
+ whoami
chris
+ source euaueoaue
./xx.sh: line 14: euaueoaue: No such file or directory
是source
某种特殊情况吗?1
无论如何,退出代码都是如此。
如果我删除它,set -e
那么它似乎可以正常工作:
+ trap deploy_cleanup ERR
+ whoami
chris
+ source euaueoaue
./xx.sh: line 14: euaueoaue: No such file or directory
++ deploy_cleanup
++ echo '---Cleaning up---'
---Cleaning up---
++ echo hello
hello