Re: [PATCH] lib: use shorter way to test if variable is set
Eric Blake <[email protected]>
| Newsgroups | gmane.comp.sysutils.autoconf.patches |
|---|---|
| Organization | Red Hat, Inc. |
| Message-ID | <[email protected]> |
On 04/15/2015 04:58 PM, Eric Blake wrote:
> Based on an idea by Bernhard Reutner-Fischer.
>
> We frequently used the idiom of 'test "${var+set}" = set' to
> test if $var was set to a non-empty string, but this can portably
> be trimmed to a more compact 'test ${var+y}' for a smaller
> configure file. Testing that a variable is not set can be done
> with '${var+false} :' (although the value of $? is not reliably
> 1 when the variable is set).
>
> Finally finding time to revisit this; here's what I will probably
> push, if no negative review comments are raised in a couple days.
Now pushed.
>
> I'll probably also work on a second patch that scrubs obvious
> uses of 'test -n "$var"' and 'test -z "$var"'; this patch just
> touched ${var+set} instances, plus AS_VAR_TEST_SET.
Still a possible future patch.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
(application/pgp-signature, 604 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJVNkBCAAoJEKeha0olJ0NqhWoH/RxPldluop+JiWSvRVjf06Fw 3zBSX9T3yLE7U5tflzvaGwVmI6LwmhcSAkzqN1Ei+ledFBgPD3i46SC1pnI70SX/ InzxNRB9C5aR3KtH94LVREaMbxiLsysqOwv1wD08YYPW72BDf7LFGgZ8jZzI6fDN OINO7+8HtjtNkE7j3WKQkCZQmBndwE0XotdgyTFETSKbZnwdLyxpFwT225OY+8YV 2iAr2BKYUTq38fsHMCzW/N0gldgQjrjGKwe3a6kGbg7yet94HzXLKkqGIoEmloLH m1EUJ/Ef0feyOnyFVPN38i4loDOTLxq9jVeXZgMfousy4pZh3XGvBxscb9U8rCo= =J+wx -----END PGP SIGNATURE-----