From owner-freebsd-questions@FreeBSD.ORG Thu Jul 10 14:59:10 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E640C106566C for ; Thu, 10 Jul 2008 14:59:10 +0000 (UTC) (envelope-from dickey@saltmine.radix.net) Received: from saltmine.radix.net (saltmine.radix.net [207.192.128.40]) by mx1.freebsd.org (Postfix) with ESMTP id 93DB38FC18 for ; Thu, 10 Jul 2008 14:59:10 +0000 (UTC) (envelope-from dickey@saltmine.radix.net) Received: from saltmine.radix.net (localhost [127.0.0.1]) by saltmine.radix.net (8.12.2/8.12.2) with ESMTP id m6AEx0uG012708; Thu, 10 Jul 2008 10:59:00 -0400 (EDT) Received: (from dickey@localhost) by saltmine.radix.net (8.12.2/8.12.2/Submit) id m6AEx0kk012707; Thu, 10 Jul 2008 10:59:00 -0400 (EDT) Date: Thu, 10 Jul 2008 10:59:00 -0400 From: Thomas Dickey To: Malcolm Kay Message-ID: <20080710145859.GA10639@saltmine.radix.net> References: <20080709172513.GA51206@mech-cluster238.men.bris.ac.uk> <200807101354.46321.malcolm.kay@internode.on.net> <200807101415.51455.fbsd.questions@rachie.is-a-geek.net> <200807110018.43081.malcolm.kay@internode.on.net> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Dxnq1zWXvFF0Q93v" Content-Disposition: inline In-Reply-To: <200807110018.43081.malcolm.kay@internode.on.net> User-Agent: Mutt/1.3.27i Cc: Anton Shterenlikht , Mel , freebsd-questions@freebsd.org Subject: Re: snippet of configure script - explain please X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Jul 2008 14:59:11 -0000 --Dxnq1zWXvFF0Q93v Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jul 11, 2008 at 12:18:42AM +0930, Malcolm Kay wrote: > On Thu, 10 Jul 2008 09:45 pm, Mel wrote: > > On Thursday 10 July 2008 06:24:46 Malcolm Kay wrote: > >=20 > > > > 9255 if { as_var=3D$as_ac_var; eval "test \"\${$as_var+set}\" = =3D set"; }; > > > > then it's interesting, but config.log would probably show the actual check that was made to fill in the shell variable... > > > I find this line somewhat strange as I've not been able > > > to find documentation for the expansion of ${parameter+set} under the > > > Bourne shell. (nor bash, nor ksh) > > > ***************************************************** > > > Presumably someone out there knows where to find it? > > > ***************************************************** > >=20 > > It's shorthand for ${paramter:+set}, so if unset, you get "", otherwise= you=20 > > get "set": > > $ echo ${foo+set} > >=20 > > $ echo ${HOME+set} > > set >=20 > So it appears; but is it stated anywhere that this shorthand is legitimat= e? > I find it quite frequently arising from the GNU configuring tools but > haven't found it elsewhere. >=20 > Is it a deliberate shorthand or just a consequence of the way sh and bash= =20 > happen to have been programmed? In other words is it a safe shorthand? man sh on Solaris for instance: ${parameter:+word} If parameter is set and is non-null, substitute word; otherwise substitute nothing. In the above, word is not evaluated unless it is to be used as the substituted string, so that, in the following exam- ple, pwd is executed only if d is not set or is null: echo ${d:-`pwd`} SunOS 5.8 Last change: 9 May 1997 4 The same feature is on OpenBSD - I don't have FreeBSD at hand, but think it's likely to be found in the manpage - I just looked for /+.*} --=20 Thomas E. Dickey http://invisible-island.net ftp://invisible-island.net --Dxnq1zWXvFF0Q93v Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (SunOS) Comment: For info see http://www.gnupg.org iD8DBQFIdiOptIqByHxlDocRAgE/AJ9aNmIwgf+hCR9aH98fUIP4pUd4lACgq1zY ExpUHHL36fC5gyoJgAI4eo0= =gOp3 -----END PGP SIGNATURE----- --Dxnq1zWXvFF0Q93v--