Date: Thu, 10 Jul 2008 18:09:26 +0100 From: Matthew Seaman <m.seaman@infracaninophile.co.uk> To: Malcolm Kay <malcolm.kay@internode.on.net> Cc: Anton Shterenlikht <mexas@bristol.ac.uk>, Mel <fbsd.questions@rachie.is-a-geek.net>, freebsd-questions@freebsd.org Subject: Re: snippet of configure script - explain please Message-ID: <48764246.8080904@infracaninophile.co.uk> In-Reply-To: <200807110018.43081.malcolm.kay@internode.on.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>
next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig32D090D6E4798516C5B9D567 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Malcolm Kay wrote: > On Thu, 10 Jul 2008 09:45 pm, Mel wrote: >> On Thursday 10 July 2008 06:24:46 Malcolm Kay wrote: >> >>>> 9255 if { as_var=3D$as_ac_var; eval "test \"\${$as_var+set}\" =3D= set"; }; >>>> then >>> 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? >>> ***************************************************** >> It's shorthand for ${paramter:+set}, so if unset, you get "", otherwis= e you=20 >> get "set": >> $ echo ${foo+set} >> >> $ echo ${HOME+set} >> set >=20 > So it appears; but is it stated anywhere that this shorthand is legitim= ate? > 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 ba= sh=20 > happen to have been programmed? In other words is it a safe shorthand? >=20 > Anyway thanks for the clarification, This syntax is certainly legitimate, and it is covered in the sh(1) man page. However, the relevant section talks mostly about the related form: ${parameter:+word} which means 'evaluate to null unless ${parameter} is unset or null, other= wise evaluate to "word"'. Then there's a very small and easily missed note to the effect: "In the parameter expansions shown previously, use of the colon in the format results in a test for a parameter that is unset or null; omissi= on of the colon results in a test for a parameter that is only unset." So ${parameter+word} means 'evaluate to null unless ${parameter} is unset= , otherwise evaluate to "word"' Cheers, Matthew --=20 Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard Flat 3 PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate Kent, CT11 9PW --------------enig32D090D6E4798516C5B9D567 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (FreeBSD) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEAREIAAYFAkh2Qk0ACgkQ8Mjk52CukIzkXQCeICcDCLBguFpLuxNPjmImHaye peMAnjXnh+/CB1Mxln4KfpYJ+Rk2bG5Y =PyDi -----END PGP SIGNATURE----- --------------enig32D090D6E4798516C5B9D567--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?48764246.8080904>