#!/bin/bash
function doSomething() {
callee
echo $?
echo "It should go to here!"
}
function callee() {
cat line.txt |while read ln
do
echo $ln
if [ 1 ] ;then
{ echo "This is callee" &&
return 2; }
fi
done
echo "It should not go to here!"
}
doSomething
下面是结果
aa
This is callee
It should not go to here!
0
It should go to here!
为什么“return”像“break”一样工作?
我要它退出功能!不仅打破循环......