下面是bash脚本退出并不在bash
#!/bin/bash
set -x
function doSomething() {
callee
echo "It should not go to here!"
}
function callee() {
(echo "before") && (echo "This is callee" && exit 1)
echo "why I can see this?"
}
doSomething
,这是结果...
+ set -x
+ doSomething
+ callee
+ echo before
before
+ echo 'This is callee'
This is callee
+ exit 1
+ echo 'why I can see this?'
why I can see this?
+ echo 'It should not go to here!'
It should not go to here!
我看到命令“退出”,但它并没有退出工作退出脚本
为什么退出不起作用?