[arch-projects] [initscripts][PATCH] rc: exit with error count, not error sum
d at falconindy.com
Sun Apr 24 18:28:02 EDT 2011
On Mon, Apr 25, 2011 at 12:07:07AM +0200, Seblu wrote:
> On Sun, Apr 24, 2011 at 11:42 PM, Dave Reisner <d at falconindy.com> wrote:
> > cc199761f assumes that /etc/rc.d scripts will exit with a value of 0 or
> > 1. Since this can't be guaranteed, clamp the return value to 0 or 1
> > before adding it to the exit value.
> > ---
> > rc | 2 +-
> > 1 files changed, 1 insertions(+), 1 deletions(-)
> > diff --git a/rc b/rc
> > index 1e64119..54dc11c 100755
> > --- a/rc
> > +++ b/rc
> > @@ -45,7 +45,7 @@ case $1 in
> > shift
> > for i; do
> > [[ -x "/etc/rc.d/$i" ]] && "/etc/rc.d/$i" $action
> > - (( ret += $? ))
> > + (( ret += !! $? )) # clamp exit value to 0/1
> > done
> why doen't increment ret each time a non zero value is detected? This
> is simpler no?
> (($?)) || ((ret++) ?
Well, it'd be && instead of ||, but this is the first thing that came to
mine (using an old C idiom). It's 6 of one, a half dozen of another.
Also, I just noticed that this increments the exit value when the [[ -x
check fails, but I think I'm okay with that.
More information about the arch-projects