Date: Sat, 09 Oct 2010 22:25:01 -0700 From: Julian Elischer <julian@freebsd.org> To: freebsd-hackers@freebsd.org Subject: Re: sysrc -- a sysctl(8)-like utility for managing /etc/rc.conf et. al. Message-ID: <4CB14E2D.3070806@freebsd.org> In-Reply-To: <238E0B24-AA12-4684-9651-84DA665BE893@vicor.com> 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
  Ah grasshoppers...
/me wonders if anyone will get the full significance of that..
On 10/9/10 3:39 PM, Devin Teske wrote:
> On Oct 9, 2010, at 1:25 PM, Garrett Cooper wrote:
>
>
>> Why not just do...
>>
>> if [ "x$rc_conf_files" = x -o "x$varname" = x ]
>> then
>>     return ${FAILURE-1}
>> fi
> I think you'll find (quite pleasantly) that if you intonate the lines...
>
> 	"rc_conf_files [is non-null] OR return failure"
> 	"varname [is non-null] OR return failure"
>
> Sounds a lot better/cleaner than the intonation of the suggested replacement:
>
> 	"if x plus rc_conf_files expands to something that is not equal to x OR x plus the expansion of varname is not x then return failure"
>
For what it matters, I'v enever found the [ "x$foo" = "x" ] construct 
to be useful.
the quoting seems to work for everything I've ever worked on.
so "officially" I'd express it as:
if [ -n  "$rc_conf_files" -o  -n "$varname" ]
but if I were hacking I'd probably express it as
if [ "$rc_conf_files" != "" ] || [ "$varname" != "" ]
then
    .....
I also sometimes find the use of the (()) operator to be useful.
Now One thing that should be bourne in mind (heh) is that
as there is a 'usual' form of format for perl there is one for sh as 
well so it's not "polite"
to make one's sh code look like perl.  :-)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4CB14E2D.3070806>
