[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: test -n "${var+set}"?
From: |
Derek Robert Price |
Subject: |
Re: test -n "${var+set}"? |
Date: |
Wed, 18 Feb 2004 14:20:17 -0500 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Paul Eggert wrote:
>Derek Robert Price <address@hidden> writes:
>
>>Just wondering what the logic behind all the constructs like, `test
>>"${var+set} = set', was in recently generated configure scripts.
>
>
>I suspect it's the shortest portable test for whether a shell variable
>is set. Can you think of a shorter?
Ah:
$ var=
$ unset var2
$ echo ${var+set}
set
$ echo ${var2+set}
$
Got it now. I read the bash man page as stating that this construct
wouldn't echo "set" for a variable set to the empty string.
Thanks,
Derek
- --
*8^)
Email: address@hidden
Get CVS support at <http://ximbiot.com>!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Netscape - http://enigmail.mozdev.org
iD8DBQFAM7rwLD1OTBfyMaQRAuY/AKCuccPRGvXJLR81gNSuslKVRGUxjwCcDE3i
eipeP7PT8qnxQ6sMzjPs754=
=eai3
-----END PGP SIGNATURE-----