• [^] # Re: Complètement imbitable...

    Posté par . En réponse au journal astuce bash: de l'usage du elif. Évalué à -2.

    retourner le code d'erreur ne ne change pas grand chose à l'affaire.

    erreur() { 
     err="1ドル"; shift
     echo "$@" 2>&1
     : do whatever you want with "$err"
    }
    if
     echo "I am going to run foo"
     foo ; err="$?"
     (($err))
    then error "$err" "couldn't run foo" 
    elif
     echo "I did run foo"
     : do whatever you want here
     echo "Now I am going to run bar"
     bar ; err="$?"
     (($err))
    then error "$err" "couldn't run bar"
    else echo "I could do this all day long"
    fi