2013-08-04 19 views

Odpowiedz

8

Zastosowanie return operatora:

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

Zastosowanie:

return [n] 

Z help return

powrót: powrót [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

Pamiętaj, że jeśli masz 'set -e' ustawić na górze skryptu i twój powrót' 1 'lub inny numer oprócz 0, całą skrypt zakończy działanie. –