Subject: Re: bug#63733: 28.3; error ("Unknown option ‘--batch’")

From: Ulrich Mueller <[email-masked]>
Date: Fri, 26 May 2023 11:33:33 +0200

>>>>> On Fri, 26 May 2023, Eli Zaretskii wrote:

>> I would expect -batch/--batch to be idempotent in all four combinations
>> above.

> They are not idempotent.

I figured that. IMHO they should be, because it is surprising when
"-batch -batch" works but "-batch --batch" doesn't.

> Emacs doesn't use getopt, it uses its own custom code for parsing the
> command-line options, because our situation is complex: we only
> process part of the command-line options in C, the rest are processed
> in Lisp.

> What happens here is that, when you use identical "-batch" or
> "--batch" options several times, the code in sort_args removes the
> identical copies, and we are left with a single option to process.
> But if you use both "-batch" and "--batch", the extra option is not
> removed, and they both appear in the sorted argv[].  Then one of them
> is processed by 'main', the other is left for command-line-1, which
> doesn't know what to do with it.

"emacs -quick --quick" or even "emacs -Q -quick --quick" works as
expected, though.