GNU bug report logs - #24949
Command-line argument parsing: named daemons

Previous Next

Package: emacs;

Reported by: Glenn Morris <rgm <at> gnu.org>

Date: Tue, 15 Nov 2016 22:26:01 UTC

Severity: minor

Tags: fixed

Found in version 25.1

Fixed in version 26.3

Done: Noam Postavsky <npostavs <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 24949 in the body.
You can then email your comments to 24949 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#24949; Package emacs. (Tue, 15 Nov 2016 22:26:02 GMT) Full text and rfc822 format available.

Message #3 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: submit <at> debbugs.gnu.org
Subject: Command-line argument parsing: named daemons
Date: Tue, 15 Nov 2016 17:25:46 -0500
Package: emacs
Severity: minor
Version: 25.1

This starts a daemon with a server named "FOO":
   emacs -Q --daemon=FOO

(This usage is documented in the "Initial Options" appendix of the
manual, but not mentioned in --help, or the man page.)


But this very similar form does not work (it starts an un-named daemon and
visits file "FOO"):
   emacs -Q --daemon FOO

Compare with something like "--chdir /tmp", where both forms (with and
without "=") work.

This is due to the fragility of the Emacs argument parsing code,
which seems pretty home-grown. In particular, I guess it is because
struct standard_args has --daemon listed as taking no arguments.
Options with optional arguments don't seem to be handled.

There is a 20-year old comment in emacs.c:

   Too bad we can't just use getopt for all of this, but we don't have
   enough information to do it right.

Perhaps standard argument parsing libraries have improved since then...?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24949; Package emacs. (Wed, 16 Nov 2016 03:40:02 GMT) Full text and rfc822 format available.

Message #6 received at 24949 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 24949 <at> debbugs.gnu.org
Subject: Re: bug#24949: Command-line argument parsing: named daemons
Date: Wed, 16 Nov 2016 05:39:10 +0200
> From: Glenn Morris <rgm <at> gnu.org>
> Date: Tue, 15 Nov 2016 17:25:46 -0500
> 
> Package: emacs
> Severity: minor

I think it should be wishlist.

> This starts a daemon with a server named "FOO":
>    emacs -Q --daemon=FOO
> 
> (This usage is documented in the "Initial Options" appendix of the
> manual, but not mentioned in --help, or the man page.)
> 
> 
> But this very similar form does not work (it starts an un-named daemon and
> visits file "FOO"):
>    emacs -Q --daemon FOO
> 
> Compare with something like "--chdir /tmp", where both forms (with and
> without "=") work.

I wouldn't expect it to work, since long options are documented to
need the equals sign.

> There is a 20-year old comment in emacs.c:
> 
>    Too bad we can't just use getopt for all of this, but we don't have
>    enough information to do it right.
> 
> Perhaps standard argument parsing libraries have improved since then...?

I think that comment is not about the parsing libraries, I think it's
about the fact that submitting the information getopt needs is
difficult or impossible in Emacs, given some of our options.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24949; Package emacs. (Wed, 06 Sep 2017 17:34:02 GMT) Full text and rfc822 format available.

Message #9 received at 24949 <at> debbugs.gnu.org (full text, mbox):

From: Philipp Stephani <p.stephani2 <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>, Glenn Morris <rgm <at> gnu.org>
Cc: 24949 <at> debbugs.gnu.org
Subject: Re: bug#24949: Command-line argument parsing: named daemons
Date: Wed, 06 Sep 2017 17:33:33 +0000
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> schrieb am Mi., 16. Nov. 2016 um 04:40 Uhr:

>
> > This starts a daemon with a server named "FOO":
> >    emacs -Q --daemon=FOO
> >
> > (This usage is documented in the "Initial Options" appendix of the
> > manual, but not mentioned in --help, or the man page.)
> >
> >
> > But this very similar form does not work (it starts an un-named daemon
> and
> > visits file "FOO"):
> >    emacs -Q --daemon FOO
> >
> > Compare with something like "--chdir /tmp", where both forms (with and
> > without "=") work.
>
> I wouldn't expect it to work, since long options are documented to
> need the equals sign.
>

This is incredibly surprising and also inconsistent with the man page,
which doesn't have equals signs for most options. Let's just document what
everybody expects, i.e. that all options work with and without equals sign,
and with one or two dashes.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24949; Package emacs. (Wed, 06 Sep 2017 18:06:01 GMT) Full text and rfc822 format available.

Message #12 received at 24949 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Philipp Stephani <p.stephani2 <at> gmail.com>
Cc: rgm <at> gnu.org, 24949 <at> debbugs.gnu.org
Subject: Re: bug#24949: Command-line argument parsing: named daemons
Date: Wed, 06 Sep 2017 21:05:22 +0300
> X-Spam-Status: No, score=1.1 required=5.0 tests=BAYES_50,
> 	FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,HTML_MESSAGE,T_DKIM_INVALID
> 	autolearn=disabled version=3.3.2
> From: Philipp Stephani <p.stephani2 <at> gmail.com>
> Date: Wed, 06 Sep 2017 17:33:33 +0000
> Cc: 24949 <at> debbugs.gnu.org
> 
>  > Compare with something like "--chdir /tmp", where both forms (with and
>  > without "=") work.
> 
>  I wouldn't expect it to work, since long options are documented to
>  need the equals sign.
> 
> This is incredibly surprising and also inconsistent with the man page, which doesn't have equals signs for
> most options. Let's just document what everybody expects, i.e. that all options work with and without equals
> sign, and with one or two dashes. 

Why would we want to do that?  Documentation should describe the
software, not our wishes.  If we want to change how the software
works, we should change the code first, and only after that change the
documentation.  Am I missing something here?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24949; Package emacs. (Wed, 06 Sep 2017 18:33:01 GMT) Full text and rfc822 format available.

Message #15 received at 24949 <at> debbugs.gnu.org (full text, mbox):

From: Philipp Stephani <p.stephani2 <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: rgm <at> gnu.org, 24949 <at> debbugs.gnu.org
Subject: Re: bug#24949: Command-line argument parsing: named daemons
Date: Wed, 06 Sep 2017 18:32:18 +0000
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> schrieb am Mi., 6. Sep. 2017 um 20:05 Uhr:

> > X-Spam-Status: No, score=1.1 required=5.0 tests=BAYES_50,
> >
>  FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,HTML_MESSAGE,T_DKIM_INVALID
> >       autolearn=disabled version=3.3.2
> > From: Philipp Stephani <p.stephani2 <at> gmail.com>
> > Date: Wed, 06 Sep 2017 17:33:33 +0000
> > Cc: 24949 <at> debbugs.gnu.org
> >
> >  > Compare with something like "--chdir /tmp", where both forms (with and
> >  > without "=") work.
> >
> >  I wouldn't expect it to work, since long options are documented to
> >  need the equals sign.
> >
> > This is incredibly surprising and also inconsistent with the man page,
> which doesn't have equals signs for
> > most options. Let's just document what everybody expects, i.e. that all
> options work with and without equals
> > sign, and with one or two dashes.
>
> Why would we want to do that?  Documentation should describe the
> software, not our wishes.  If we want to change how the software
> works, we should change the code first, and only after that change the
> documentation.  Am I missing something here?
>

For almost all arguments all four variants (-foo bar, --foo bar, -foo=bar,
--foo=bar) appear to work, for long and for short options. Either we should
document that they work (that's what everybody expects by now), or turn the
unwanted versions into explicit errors.
We should generally change the code and the documentation at the same time,
to make sure they are consistent.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24949; Package emacs. (Thu, 07 Sep 2017 02:32:01 GMT) Full text and rfc822 format available.

Message #18 received at 24949 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Philipp Stephani <p.stephani2 <at> gmail.com>
Cc: rgm <at> gnu.org, 24949 <at> debbugs.gnu.org
Subject: Re: bug#24949: Command-line argument parsing: named daemons
Date: Thu, 07 Sep 2017 05:31:46 +0300
> From: Philipp Stephani <p.stephani2 <at> gmail.com>
> Date: Wed, 06 Sep 2017 18:32:18 +0000
> Cc: rgm <at> gnu.org, 24949 <at> debbugs.gnu.org
> 
>  Why would we want to do that? Documentation should describe the
>  software, not our wishes. If we want to change how the software
>  works, we should change the code first, and only after that change the
>  documentation. Am I missing something here?
> 
> For almost all arguments all four variants (-foo bar, --foo bar, -foo=bar, --foo=bar) appear to work, for long and
> for short options. Either we should document that they work (that's what everybody expects by now), or turn
> the unwanted versions into explicit errors. 
> We should generally change the code and the documentation at the same time, to make sure they are
> consistent.

I agree with the last sentence.  It's almost exactly what I said.  The
rest of what you write sounds like a contradiction to me, as currently
the only inconsistency I see is that the emacs.1 man page creates a
wrong impression that omitting the = would work.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24949; Package emacs. (Fri, 08 Sep 2017 03:47:02 GMT) Full text and rfc822 format available.

Message #21 received at 24949 <at> debbugs.gnu.org (full text, mbox):

From: Richard Stallman <rms <at> gnu.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: p.stephani2 <at> gmail.com, 24949 <at> debbugs.gnu.org
Subject: Re: bug#24949: Command-line argument parsing: named daemons
Date: Thu, 07 Sep 2017 23:46:19 -0400
[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > I agree with the last sentence.  It's almost exactly what I said.  The
  > rest of what you write sounds like a contradiction to me, as currently
  > the only inconsistency I see is that the emacs.1 man page creates a
  > wrong impression that omitting the = would work.

I agree.

-- 
Dr Richard Stallman
President, Free Software Foundation (gnu.org, fsf.org)
Internet Hall-of-Famer (internethalloffame.org)
Skype: No way! See stallman.org/skype.html.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24949; Package emacs. (Sun, 07 Jan 2018 22:45:02 GMT) Full text and rfc822 format available.

Message #24 received at 24949 <at> debbugs.gnu.org (full text, mbox):

From: Philipp Stephani <p.stephani2 <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Glenn Morris <rgm <at> gnu.org>, 24949 <at> debbugs.gnu.org
Subject: Re: bug#24949: Command-line argument parsing: named daemons
Date: Sun, 07 Jan 2018 22:44:26 +0000
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> schrieb am Mi., 16. Nov. 2016 um 04:40 Uhr:

> > From: Glenn Morris <rgm <at> gnu.org>
> > Date: Tue, 15 Nov 2016 17:25:46 -0500
> >
> > Package: emacs
> > Severity: minor
>
> I think it should be wishlist.
>
> > This starts a daemon with a server named "FOO":
> >    emacs -Q --daemon=FOO
> >
> > (This usage is documented in the "Initial Options" appendix of the
> > manual, but not mentioned in --help, or the man page.)
> >
> >
> > But this very similar form does not work (it starts an un-named daemon
> and
> > visits file "FOO"):
> >    emacs -Q --daemon FOO
> >
> > Compare with something like "--chdir /tmp", where both forms (with and
> > without "=") work.
>
> I wouldn't expect it to work, since long options are documented to
> need the equals sign.
>

I've just re-checked this. The manual states: "When a long option takes an
argument, you can use either a space or an equal sign to separate the
option name and the argument.  Thus, you can write either
@samp{--display sugar-bombs:0.0} or @samp{--display=sugar-bombs:0.0}. "

So it's even documented that both forms should work.
We could either fix the "daemon" arg to match the documentation, or
slightly change the manual to state that the space variant is only possible
if the argument is mandatory (e.g. replace "takes" with "requires").
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24949; Package emacs. (Mon, 08 Jan 2018 04:01:02 GMT) Full text and rfc822 format available.

Message #27 received at 24949 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Philipp Stephani <p.stephani2 <at> gmail.com>
Cc: rgm <at> gnu.org, 24949 <at> debbugs.gnu.org
Subject: Re: bug#24949: Command-line argument parsing: named daemons
Date: Mon, 08 Jan 2018 06:00:19 +0200
> From: Philipp Stephani <p.stephani2 <at> gmail.com>
> Date: Sun, 07 Jan 2018 22:44:26 +0000
> Cc: Glenn Morris <rgm <at> gnu.org>, 24949 <at> debbugs.gnu.org
> 
> I've just re-checked this. The manual states: "When a long option takes an
> argument, you can use either a space or an equal sign to separate the
> option name and the argument.  Thus, you can write either
> @samp{--display sugar-bombs:0.0} or @samp{--display=sugar-bombs:0.0}. "
> 
> So it's even documented that both forms should work.
> We could either fix the "daemon" arg to match the documentation, or slightly change the manual to state that
> the space variant is only possible if the argument is mandatory (e.g. replace "takes" with "requires").

The manual actually already states that ("when a long option takes an
argument"), but I agree it would be good to clarify that as you
propose in the latter alternative.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24949; Package emacs. (Mon, 08 Jan 2018 08:45:01 GMT) Full text and rfc822 format available.

Message #30 received at 24949 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> suse.de>
To: Philipp Stephani <p.stephani2 <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 24949 <at> debbugs.gnu.org
Subject: Re: bug#24949: Command-line argument parsing: named daemons
Date: Mon, 08 Jan 2018 09:44:23 +0100
On Jan 07 2018, Philipp Stephani <p.stephani2 <at> gmail.com> wrote:

> I've just re-checked this. The manual states: "When a long option takes an
> argument, you can use either a space or an equal sign to separate the
> option name and the argument.  Thus, you can write either
> @samp{--display sugar-bombs:0.0} or @samp{--display=sugar-bombs:0.0}. "
>
> So it's even documented that both forms should work.

That's only true for options with a non-optional argument.  For optional
arguments the equal sign is required, otherwise it doesn't know whether
the argument belongs to the option.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab <at> suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24949; Package emacs. (Sun, 05 May 2019 04:00:02 GMT) Full text and rfc822 format available.

Message #33 received at 24949 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: rgm <at> gnu.org, Philipp Stephani <p.stephani2 <at> gmail.com>,
 24949 <at> debbugs.gnu.org
Subject: Re: bug#24949: Command-line argument parsing: named daemons
Date: Sat, 04 May 2019 23:59:14 -0400
tags 24949 fixed
close 24949 26.3
quit

Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Philipp Stephani <p.stephani2 <at> gmail.com>

>> We could either fix the "daemon" arg to match the documentation, or slightly change the manual to state that
>> the space variant is only possible if the argument is mandatory (e.g. replace "takes" with "requires").
>
> The manual actually already states that ("when a long option takes an
> argument"), but I agree it would be good to clarify that as you
> propose in the latter alternative.

Done in emacs-26.

3b86e0b812 2019-05-04T23:55:50-04:00 "Clarify handling of long options (Bug#24949)"
https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=3b86e0b812e97aa83222f042ce8323516aaca0ec





Added tag(s) fixed. Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Sun, 05 May 2019 04:00:03 GMT) Full text and rfc822 format available.

bug marked as fixed in version 26.3, send any further explanations to 24949 <at> debbugs.gnu.org and Glenn Morris <rgm <at> gnu.org> Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Sun, 05 May 2019 04:00:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#24949; Package emacs. (Sun, 05 May 2019 17:17:02 GMT) Full text and rfc822 format available.

Message #40 received at 24949 <at> debbugs.gnu.org (full text, mbox):

From: Philipp Stephani <p.stephani2 <at> gmail.com>
To: Noam Postavsky <npostavs <at> gmail.com>
Cc: Glenn Morris <rgm <at> gnu.org>, Eli Zaretskii <eliz <at> gnu.org>,
 24949 <at> debbugs.gnu.org
Subject: Re: bug#24949: Command-line argument parsing: named daemons
Date: Sun, 5 May 2019 19:16:41 +0200
Am So., 5. Mai 2019 um 05:59 Uhr schrieb Noam Postavsky <npostavs <at> gmail.com>:
>
> tags 24949 fixed
> close 24949 26.3
> quit
>
> Eli Zaretskii <eliz <at> gnu.org> writes:
>
> >> From: Philipp Stephani <p.stephani2 <at> gmail.com>
>
> >> We could either fix the "daemon" arg to match the documentation, or slightly change the manual to state that
> >> the space variant is only possible if the argument is mandatory (e.g. replace "takes" with "requires").
> >
> > The manual actually already states that ("when a long option takes an
> > argument"), but I agree it would be good to clarify that as you
> > propose in the latter alternative.
>
> Done in emacs-26.
>
> 3b86e0b812 2019-05-04T23:55:50-04:00 "Clarify handling of long options (Bug#24949)"
> https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=3b86e0b812e97aa83222f042ce8323516aaca0ec
>

Thanks




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 03 Jun 2019 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 300 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.