[Pm-utils] [PATCH 14/17] Remove redundant exit call from 95led

Michael Biebl mbiebl at gmail.com
Sat Feb 16 05:13:51 PST 2008


2008/2/16, Michael Biebl <mbiebl at gmail.com>:
> 2008/2/16, Victor Lowther <victor.lowther at gmail.com>:
> > On Fri, Feb 15, 2008 at 09:07:19AM +0100, Michael Biebl wrote:
> > > 2008/2/15, Victor Lowther <victor.lowther at gmail.com>:
> > >
> > > >
> > > >  -[ -f /proc/acpi/ibm/led ] || exit 1
> > >
> > > I like explicitly returning 1, because you immediately see, that we
> > > return 1 in case we don't find the required resource. (This comment is
> > > true for #13, #11, #9, #7, #6)
> > >
> > > >  +[ -f /proc/acpi/ibm/led ] || exit
> > >
> > > This is imho harder to read and understand. So I vote against removing
> > > the explicit "exit 1".
> >
> > If we are checking for the exit status codes in the script, then this
> > should actually be an explicit exit 0.
> >
> > The reason for that is that these scripts run on all systems,
> > but if a system does not need the script's functionality, then it is not
> > a failure, it is just the script recognizing that fact and exiting.
>
> What about a  different return code then. So you have:
> succeeded (0), failed (1), skipped (2).

The hooks could then look like this:

check_prerequisites || exit 2

case "$1" in
        hibernate|suspend)
                do_stuff || exit 1
                ;;
        thaw|resume)
                do_stuff || exit 1
                ;;
        *)
                exit 2
                ;;
esac

exit 0


What do you think?

Michael

-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?


More information about the Pm-utils mailing list