On Wed, Apr 19, 2023 at 03:53:57PM +0200, Laszlo Ersek wrote:
>> snprintf (cmd, sizeof cmd,
>> - "if %s --object tls-creds-x509,id=tls0 |& grep -sq
'TLS credentials support requires GNUTLS'; then exit 1; else exit 0; fi",
>> + "if %s --object tls-creds-x509,id=tls0 \\\n"
>> + " |& grep -sq 'TLS credentials support requires
GNUTLS'\n"
>
> Note: |& is a bashism; but system() might not invoke bash. So this is
> already non-portable code; and we should be fixing that. (I don't
> mind doing it as a followup if you end up pushing before seeing this
> message).
I noticed |& too; my thought was "TIL". :)
>
>> + "then\n"
>> + " exit 1\n"
>> + "else\n"
>> + " exit 0\n"
>> + "fi\n",
>
> For that matter, 'if ...; then exit 1; else exit 0; fi' can be
> compressed to '! ...'.
>
Yes, I noticed that too, but I assumed there was a finer point I was
missing. :/
autoconf still avoids it because of portability to Solaris /bin/sh
(not /bin/xpg4/sh), which lacked !. But that's ancient history these
days; ALL modern sh support ! correctly. (Note that support for '!
command...' is different than 'test ! expr...', which itself has its
own set of portability pitfalls that autoconf cares about; but that is
yet another place where modern sh is now quite portable).
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization:
qemu.org |
libvirt.org