Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Jul 2008 10:59:00 -0400
From:      Thomas Dickey <dickey@radix.net>
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:  <20080710145859.GA10639@saltmine.radix.net>
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

--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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080710145859.GA10639>