On 01/03/21 16:38, Eric Blake wrote:
On 3/1/21 9:28 AM, Paolo Bonzini wrote:
If the first character of optstring is '-', then each nonoption argv
element is handled as if it were the argument of an option with character
code 1. This removes the reordering of the argv array, and enables usage
of loc_set_cmdline to provide better error messages.
Signed-off-by: Paolo Bonzini <pbonz...@redhat.com>
---
storage-daemon/qemu-storage-daemon.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
Nice. The man page for 'getopt_long' is unclear whether setting
POSIXLY_CORRECT in the environment would break this
It doesn't. In fact, with this patch the behavior is the same as for
POSIXLY_CORRECT, though for unrelated reasons, and interestingly enough
I think the POSIXLY_CORRECT behavior is an improvement for
qemu-storage-daemon.
Unpatched:
$ qemu-storage-daemon foo --object iothread
qemu-storage-daemon: Parameter 'id' is missing
$ POSIXLY_CORRECT=1 qemu-storage-daemon foo --object iothread
qemu-storage-daemon: Unexpected argument: foo
Patched:
$ storage-daemon/qemu-storage-daemon foo --object iothread
qemu-storage-daemon: foo: Unexpected argument
$ POSIXLY_CORRECT=1 storage-daemon/qemu-storage-daemon foo --object iothread
qemu-storage-daemon: foo: Unexpected argument
Paolo