私はこの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!
コマンドexit
が表示されますが、スクリプトが終了しません–なぜ機能しないexit
のですか?