[arch-projects] [PATCH 3/3] rc: exit with a meaningful value

Seblu seblu at seblu.net
Sun Apr 24 15:44:48 EDT 2011


On Sun, Apr 24, 2011 at 9:31 PM, Dave Reisner <d at falconindy.com> wrote:
> On Sun, Apr 24, 2011 at 09:28:00PM +0200, Seblu wrote:
>> On Sun, Apr 24, 2011 at 3:01 AM, Dave Reisner <d at falconindy.com> wrote:
>> > ---
>> >  rc |    7 +++++--
>> >  1 files changed, 5 insertions(+), 2 deletions(-)
>> >
>> > diff --git a/rc b/rc
>> > index 9abeb52..1e64119 100755
>> > --- a/rc
>> > +++ b/rc
>> > @@ -11,10 +11,12 @@ e.g: rc list
>> >      rc help
>> >      rc start sshd gpm
>> >  EOF
>> > +       exit 1
>> >  }
>> >
>> > -(( $# < 1 )) && usage && exit 1
>> > +(( $# < 1 )) && usage
>> >
>> > +declare -i ret=0
>> >  case $1 in
>> >        help)
>> >                usage
>> > @@ -43,9 +45,10 @@ case $1 in
>> >                shift
>> >                for i; do
>> >                        [[ -x "/etc/rc.d/$i" ]] && "/etc/rc.d/$i" $action
>> > +                       (( ret += $? ))
>> >                done
>> >  esac
>> >
>> > -true
>> > +exit $ret
>> >
>> Why return a value which is the sum of error value rather than 1 if
>> something fail? The sum is meaningless.
>>
>> --
>> Sébastien Luttringer
>> www.seblu.net
>
> Well, it's more meaningful than always exiting 0. Perhaps I should have
> just done (( ++ret )) here.

you'r right and your patch is meaningfull! My point was just about the
sum. ++ret looks more sexy. You patch?


-- 
Sébastien Luttringer
www.seblu.net


More information about the arch-projects mailing list