Come uscire da una funzione se una condizione è vera senza uccidere l'intero script, basta tornare indietro prima di chiamare la funzione.Come uscire da una funzione in bash
Esempio
Come uscire da una funzione se una condizione è vera senza uccidere l'intero script, basta tornare indietro prima di chiamare la funzione.Come uscire da una funzione in bash
Esempio
Uso return
esercente:
function FUNCT {
if [ blah is false ]; then
return 1 # or return 0, or even you can omit the argument.
else
keep running the function
fi
}
Uso:
return [n]
Da help return
ritorno: ritorno [n]
Return from a shell function. Causes a function or sourced script to exit with the return value specified by N. If N is omitted, the return status is that of the last command executed within the function or script. Exit Status: Returns N, or failure if the shell is not executing a function or script.
Si noti che se si dispone di 'set -e' impostare nella parte superiore del vostro script e il vostro' tornare 1' o qualsiasi altro numero oltre lo 0, l'intero lo script uscirà. –