Re: [hackers] [sbase][PATCH] Support -- in all utilities except echo(1)

From: Michael Forney <mforney_AT_mforney.org>
Date: Fri, 28 Jun 2019 02:06:26 -0700

On 2019-06-28, Laslo Hunhold <dev_AT_frign.de> wrote:
>> Rather than add a special ENOFLAGS macro, I am tempted to revert
>> 9016d288 instead. The question that remains is how to handle arguments
>> that look like options (start with `-`) for tools that don't have any
>> specified options. It seems for some tools it is important to treat
>> them as operands (e.g. printf, expr), but for others that are commonly
>> extended with additional options, it might make sense to fail with
>> usage() to catch unsupported uses (e.g. hostname, tsort, chroot).
>
> thanks for elaborating about it more! This topic was a big point of
> debate back then. In this matter Posix should have the final word. So
> in this sense, if Posix mandates for e.g. dirname(1) to support -- then
> we should not ignore -- and the user will have to write
>
> $ dirname -- --
>
> I think though that we all agree that an ENOFLAGS-macro would be
> insanity.

I don't necessarily think it would be insanity, and actually prefer it
to the one-liner used currently. Something like it might even be
necessary to handle `--` without consuming any option arguments (for
the printf and expr case mentioned above) unless we change the
ARGBEGIN macro to not advance the argv strings. Then, maybe something
like the following would work for those cases.

        ARGBEGIN {
        default:
                goto done;
        } ARGEND
done:

Though, this isn't particularly nice either...
Received on Fri Jun 28 2019 - 11:06:26 CEST

This archive was generated by hypermail 2.3.0 : Fri Jun 28 2019 - 12:12:23 CEST