Subject: Stupid sh tricks [ was Re: HEADS UP: RCD_SCRIPTS_EXAMPLEDIR changed to share/examples/rc.d ]
To: NetBSD Packages Technical Discussion List <tech-pkg@NetBSD.ORG>
From: Chris Jepeway <>
List: tech-pkg
Date: 12/29/2004 21:59:09
>>> : ${cups:=NO}
>> A(n arguably) less opaque way of accomplishing same:
>> 	cups=${cups:-NO}
> Perhaps, but not really...  :-)
> The ":-" syntax says "use default values", but the value isn't being
> used unless by way of the fake re-assignment.
Ah, but it's clearly an assignment statement.
You call it "fake."  I call it "less opaque."

> However the ":=" syntax says "assign default values",
My unstated argument had nothing to do with syntax, really,
but I now feel compelled to mention that := also interpolates...
> which is _exactly_
> what's desired here.
...and, since the null command ignores its args,
the interpolated var isn't used.  Me, I call that
"fake" (you don't seem to care for it, either)
and consider it about as "desirable" as doing s/t like

	echo > /dev/null ${cups:=NO}

or even

	true ${cups:=NO}

Heck, given the precedent of C, I've about talked myself
into preferring this

	if [ ${cups:=NO} != NO ] ; then
		: Start cups

(which I've never seen in the wild) to relying on the
side effects of executing a command that does nothing.

Well, sez me.  And that was my point: there's a
tenable position to take that := isn't as clear as assigning
a value that's defaulted by :-.  I pretty much
figured anybody who cared knew the syntax and [cw]ould
have the argument with themselves as to which idiom was
better suited for rc.d files.

> 						Greg A. Woods
Chris <>.