On 01/19/22 14:46, Richard W.M. Jones wrote:
On Tue, Jan 18, 2022 at 11:19:18AM -0600, Eric Blake wrote:
> On Tue, Jan 18, 2022 at 02:48:33PM +0100, Laszlo Ersek wrote:
>> + case '4':
>> + tcpip_sock_af = AF_INET;
>> + break;
>> +
>> + case '6':
>> + tcpip_sock_af = AF_INET6;
>> + break;
>
> Thus, if the user uses nbdkit -46 (or -64), the last one specified
> silently overrides the earlier one, rather than being diagnosed as
> conflicting or explicitly permitting both. The override effect
> matches the long-option naming --ipv4-only, so I can live with it, but
> I'm also open to the idea of explicitly adding code to diagnose both
> options at the same time as an error, if we think that's friendlier
> than silent override.
Is that actually an error? -4 -6 says you want to listen on IPv4 and
IPv6 which is redundant but not wrong.
No, each of -4 and -6 is a restriction, not a permission, so if they
were meant to work together, the set of enabled address families would
be empty.
They simply should not be specified together. If someone still does, the
behavior is well defined, and documented. It would be possible to catch
that case and to report an error, but it's not worth the complexity.
This is pretty common with standard utilities; here's one example: the
-l (--files-with-matches) and -L (--files-without-match) flags of "grep":
mkdir x
cd x
echo a > a
echo b > b
# prints a
grep -r -l a
# prints b
grep -r -L a
# prints b, with -L taking effect
grep -r -l -L a
# prints a, with -l taking effect
grep -r -L -l a
Thanks,
Laszlo