set -e (was: RHEL-CentOS conversion scripts (was Re: apache?))

Michael ODonnell michael.odonnell at comcast.net
Fri Apr 10 15:04:03 EDT 2009



> one of the things that I am enthusiastic about: set -e"

I like that one, too, and I also like the way bash allows
you to trap on error conditions, thusly:


    #!/bin/bash

    function errHandler()  {
        echo 'errHandler activated'
    }

    trap errHandler ERR

    echo Ready for first error... errexit FALSE

    false                    # Force error condition.

    set -e                       # Exit on any error.

    echo Ready for second error... errexit TRUE

    false                    # Force error condition.

    echo After second error.           # Not reached.



More information about the gnhlug-discuss mailing list