我有一个名为unions.sh的bash脚本:
_show_help ()
{
echo "$0 [-t time]"
echo
echo "-CARD [num]"
echo " card number"
echo
exit 0
}
_cleanup ()
{
echo Cleaning Up..
exit 5
}
trap _cleanup 0 1 2 5 6
until [ -z "$1" ]
do
case "$1" in
"--CARD")
shift
if [ -z "$1" ]; then
_fatal_error "--CARD must have an argument"
fi
_card="$1"
;;
"-h"|"--help")
_show_help
;;
esac
shift
done
当我跑./unions.sh -h输出
./unions.sh [-t time]
-CARD [num]
card number
Cleaning Up..
我有疑问。当我在帮助函数中使用exit时,它调用了_cleanup函数。 我在_cleanup函数中有相同的退出。 为什么不应该再次调用_cleanup函数?