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

Victor Lowther victor.lowther at gmail.com
Fri Feb 15 17:34:32 PST 2008


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.  
 
> >   case "$1" in
> >         thaw|resume)
> >  @@ -9,5 +9,3 @@ case "$1" in
> >         *)
> >                 ;;
> >   esac
> >  -
> >  -exit $?
> 
> Instead of exit $?, I'd say we should return 0 here. So we have a
> defined return code of 0, when we have reached the end of the script.

I don't agree.  People who code scripts should be aware that the exit
status of a script is the exit status of the last command that script
executed.  We should not have to spell it out with explicit (and
redundant) calls to return and exit.

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

-- 
Victor Lowther
Ubuntu Certified Professional


More information about the Pm-utils mailing list