2013-08-04 2 views

risposta

8

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 
} 
34

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. 
+3

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à. –