qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: BALATON Zoltan <balaton@eik.bme.hu>,
	Stefan Hajnoczi <stefanha@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	John Snow <jsnow@redhat.com>,
	qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH 1/2] trace: document how to specify multiple --trace patterns
Date: Tue, 19 Jan 2021 10:31:49 -0600	[thread overview]
Message-ID: <5b620b0a-a21a-e1c4-8f4f-f16bc5b484aa@redhat.com> (raw)
In-Reply-To: <6bf62c67-7dff-11e2-37e8-a0e67da89bb2@eik.bme.hu>

On 1/14/21 8:18 AM, BALATON Zoltan wrote:

>> I wasn't aware of the fact that some of the utilities are sensitive to
>> '--' vs '-'! I'm in favor of consistently using '--' in documentation
>> but allowing both for backwards compatibility where '-' is currently
>> supported.
>>
>> If we are in agreement, then let's:
>>
>> 1. Add a section to CODING_STYLE.rst or other developer documentation
>>   documenting this.

Seems reasonable to me.

> 
> I'd be more in favour of documenting that QEMU accepts - options but
> also -- as alternative and fixing the tools that currently use
> getopt_long to use getopt_long_only to keep it consistent with main QEMU
> executable. Otherwise this will get more and more inconsistent with new
> options added with -- and old ones only exist in - form so to keep
> consistency we should standardise on - not --.

I've got less practical experience with getopt_long_only(); I know there
are some utilities like gcc that have to use it, but GNU coding
standards prefer getopt_long() over getopt_long_only().  I think one of
the reasons is the potential for ambiguity: if you have a program that
accepts a series of short options without arguments, you can combine
them together (think 'ls -lF'), but what happens when your combination
of letters then resembles a long option?  A bit contrived, but 'ls --no'
is short for 'ls --no-group' (aka 'ls -G'), while 'ls -no' is the same
as 'ls -n -o', which has different behavior.  ls uses getopt_long(),
hence the use of -- matters; but if it were to use getopt_long_only(),
you would have changed the behavior of 'ls -no' (it would now favor
--no-group over -n -o).

That's not to say we can't switch qemu-img, qemu-storage-daemon,
qemu-io, and friends to use getopt_long_only(), but merely that we have
to be careful of what it will do to their command line parsing, and
whether it will introduce any unintended regressions.

So the conservative answer from me is to prefer documenting '--' options
everywhere, rather than trying to figure out when '-' is acceptable with
long option names.

> 
>> 2. Convert existing documentation to use '--'. This will make it more
>>   consistent and also avoid confusion about '-' vs '--'.
> 
> You could still use -- in documentation but what's the problem with - if
> -- is also accepted if one wants to type that?

Supporting lazy typists is one thing, but our documentation should stick
to the preferred form, even when shorter forms are possible.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



  parent reply	other threads:[~2021-01-19 19:10 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-12 16:58 [PATCH 0/2] trace: documentation improvements Stefan Hajnoczi
2021-01-12 16:58 ` [PATCH 1/2] trace: document how to specify multiple --trace patterns Stefan Hajnoczi
2021-01-12 18:50   ` Philippe Mathieu-Daudé
2021-01-12 20:44   ` BALATON Zoltan
2021-01-13  9:48     ` Stefan Hajnoczi
     [not found]       ` <afd6945e-2666-1b80-70c8-27564cf5ac5@eik.bme.hu>
2021-01-13 14:15         ` Stefan Hajnoczi
2021-02-15 11:39           ` Kevin Wolf
2021-01-13 21:42       ` John Snow
2021-01-13 22:15         ` Eric Blake
2021-01-13 23:08           ` John Snow
2021-01-13 23:45             ` BALATON Zoltan
2021-01-14  0:20               ` John Snow
2021-01-14 14:02                 ` Stefan Hajnoczi
2021-01-14 14:18                   ` BALATON Zoltan
2021-01-14 16:44                     ` Stefan Hajnoczi
2021-01-19 16:31                     ` Eric Blake [this message]
2021-02-01 11:22                       ` Stefan Hajnoczi
2021-01-14 17:22                   ` John Snow
2021-01-12 16:58 ` [PATCH 2/2] trace: update docs with meson build information Stefan Hajnoczi
2021-02-01 11:23 ` [PATCH 0/2] trace: documentation improvements Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5b620b0a-a21a-e1c4-8f4f-f16bc5b484aa@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=balaton@eik.bme.hu \
    --cc=jsnow@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).