|
From: | Paolo Bonzini |
Subject: | Re: [PATCH v2 1/2] storage-daemon: report unexpected arguments on the fly |
Date: | Mon, 1 Mar 2021 17:29:09 +0100 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 |
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 <pbonzini@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
[Prev in Thread] | Current Thread | [Next in Thread] |