#!/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」のように機能するのはなぜですか?
関数を終了してほしい!ループを壊すだけでなく...