[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#33468: A bug with yes and --help
From: |
Bernhard Voelker |
Subject: |
bug#33468: A bug with yes and --help |
Date: |
Thu, 29 Nov 2018 09:48:34 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 |
On 11/27/18 10:04 PM, Paul Eggert wrote:
> I'd rather see a function than a big macro like that. Can we do it as a
> function instead?
>
> Is the idea to deprecate and/or stop using parse_long_options, since it
> doesn't work the way the Gnu Coding Standards says it should? If so,
> maybe it would be simpler to change parse_long_options instead. This
> could involve changing the API for parse_long_options.
Thank you very much both for your comments.
Indeed, parse_long_options is not good enough for our purposes
in the following regards:
* it only runs if (argc == 2), i.e., it doesn't handle e.g.
$ yes --help me
* it stops at the first non-option argument, i.e., it doesn't allow
to handle the GNU standard options after an argument, e.g.
$ dd if=... --help
(The above is especially nice if one already typed a quite long dd command,
and needs to know one another option, so one could just append --help, and
then re-edit the command replacing --help by the then-known other option.)
* it does not allow to differentiate between the need to scan all
arguments vs. stopping at the first non-option argument; this is
important for programs launching other programs. E.g. nohup should
not gobble the --help option after COMMAND:
$ nohup COMMAND --help
* if a command does not allow other options, then another getopt_long call
is needed.
The attached are quite raw attempts to address this - yes, as a function
instead of a macro. ;-)
The idea is to have a function which allows only the --help or --version
option, and complaining about any other option (well, programs allowing
other options besides the GNU standard options will have their own
getopt_long loop anyway). And it allows by the SCAN_ALL parameter to
stop or not stop at the 1st non-option argument.
* [PATCH] long-options: add parse_gnu_standard_options_only
gnulib patch!
* [PATCH] all: detect --help and --version more consistently [FIXME]
FIXME: NEWS, syntax-check, tests.
Have a nice day,
Berny
0001-long-options-add-parse_gnu_standard_options_only.patch
Description: Text Data
0001-all-detect-help-and-version-more-consistently-FIXME.patch
Description: Text Data