处理函数的返回值怎么样?
keyin() {
# read -e -p "$1 input yï¼otherwise input n" local yorn
yorn=n
if [[ "y" == "$yorn" || "Y" == "$yorn" ]]; then
return 0
fi
return 1 # return nonzero in case of error
}
fun1() {
# handle the return value - in case of non-zero execute custom action
if ! keyin 'update software no.1'; then
return
fi
echo 'how to exit this function?'
}
fun2() {
echo "fun2 is still running"
}
fun1
fun2
易于理解的
if function; then
让我们根据函数的返回值是零还是非零来执行一个操作。
声明
read .... local yorn
读取名为
local
.我想你是说
read .... yorn
没有
地方的
单词