下面是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!
我看到命令「退出」,但它並沒有退出工作退出腳本
爲什麼退出不起作用?