sysrc -- a sysctl(8)-like utility for managing /etc/rc.conf et.
al.
Anonymous
swell.k at gmail.com
Mon Oct 11 04:17:29 UTC 2010
Devin Teske <dteske at 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
More information about the freebsd-hackers
mailing list