无返回值

控制流 / 跳转语句 / return 语句

printMainData() {
    echo "printMainData"
}

printOtherData() {
    echo "printOtherData"
}

#return without a number keeps the exit code of the last command;
#here it is the code of [[ ]], which was true, so 0
printSomeData() {
    local printAll=$1
    printMainData
    if [[ $printAll != true ]]; then
        return
    fi
    printOtherData
}

printSomeData false
#prints "printMainData"

printSomeData true
#prints "printMainData"
#and "printOtherData"