Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Oct 2010 07:48:19 +0400
From:      Anonymous <swell.k@gmail.com>
To:        Devin Teske <dteske@vicor.com>
Cc:        Brandon Gooch <jamesbrandongooch@gmail.com>, freebsd-hackers@freebsd.org, Garrett Cooper <gcooper@FreeBSD.org>
Subject:   Re: sysrc -- a sysctl(8)-like utility for managing /etc/rc.conf et. al.
Message-ID:  <86lj65ie4c.fsf@gmail.com>
In-Reply-To: <238E0B24-AA12-4684-9651-84DA665BE893@vicor.com> (Devin Teske's message of "Sat, 9 Oct 2010 15:39:44 -0700")
References:  <1286397912.27308.40.camel@localhost.localdomain> <AANLkTikoohMo5ng-RM3tctTH__P6cqhQpm=FPhSE9mMg@mail.gmail.com> <51B4504F-5AA4-47C5-BF23-FA51DE5BC8C8@vicor.com> <AANLkTim=BLkd229vdEst8U0ugpq3UsHPxjZZp2qaJxH-@mail.gmail.com> <238E0B24-AA12-4684-9651-84DA665BE893@vicor.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Devin Teske <dteske@vicor.com> writes:

>>> ############################################################ GLOBALS
>>> 
>>> # Global exit status variables
>>> : ${SUCCESS:=0}
>>> : ${FAILURE:=1}
>> 
>> Should this really be set to something other than 0 or 1 by the
>> end-user's environment? This would simplify a lot of return/exit
>> calls...
>
> A scenario that I envision that almost never arises, but...
>
> Say someone wanted to call my script but wanted to mask it to always return with success (why? I dunno... it's conceivable though).
>
> Example: (this should be considered ugly -- because it is)
>
> FAILURE=0 && sysrc foo && reboot

Wouldn't this bork functions used inside a conditional?

  : ${FAILURE:=1}
  foo() { return ${FAILURE-1}; }
  if ! foo; then
      echo good
  else
      echo error
  fi

  $ test.sh
  good
  $ FAILURE=0 test.sh
  error

I think only sysrc_set() is affected, though.

  if sysrc_set "$NAME" "${1#*=}"; then
          echo " -> $( sysrc "$NAME" )"
  fi

  $ sysrc hostname=blah
  hostname: raphael.local
  sysrc: cannot create /etc/rc.conf: permission denied
  $ FAILURE=0 sh sysrc hostname=blah
  hostname: raphael.local
  sysrc: cannot create /etc/rc.conf: permission denied
   -> raphael.local



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86lj65ie4c.fsf>