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

From: Michael Forney <mforney_AT_mforney.org>
Date: Mon, 1 Jul 2019 22:30:43 -0700

On 2019-06-30, Laslo Hunhold <dev_AT_frign.de> wrote:
> What do the others think?

Thanks for investigating this, Laslo. Your findings seem to match my
quick experimentation, and at this point I am leaning towards sticking
with ARGBEGIN/ARGEND, but using a simpler implementation like the one
I shared or the one you are using for farbfeld. It's good to know that
we could wrap getopt(3) if necessary, but I had forgotten about
POSIXLY_CORRECT. I think that alone might be reason enough to avoid
it. I think the argv permutation glibc getopt does by default would be
a serious regression.

Additionally, I've been thinking about the argv = { NULL } case.
Currently argv0 will get set to NULL, but there seems to be a lot of
places where it is passed to printf without checking (even though most
implementations will print "(null)"). I'm thinking we should probably
provide a fallback argv0 in this case. Perhaps we could pass it as a
parameter to ARGBEGIN, like

        ARGBEGIN("rm") {
        ...
        } ARGEND

Or maybe we could just introduce an idiom always used as the first
statement in main() like

        argv0 = argc ? argv[0] : "rm";

rather than implicitly setting it ARGBEGIN.
Received on Tue Jul 02 2019 - 07:30:43 CEST

This archive was generated by hypermail 2.3.0 : Tue Jul 02 2019 - 07:36:22 CEST