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

From: Laslo Hunhold <>
Date: Tue, 2 Jul 2019 08:02:41 +0200

On Mon, 1 Jul 2019 22:30:43 -0700
Michael Forney <> wrote:

Dear Michael,

> 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.

glibc is such a bloody piece of garbage! It is an outright insult that
they are deliberately POSIX-non-compliant and only offer to set some
crude ugly environment variable (what could go wrong?) to fix it.
Their arrogance and lethargy is legendary and the only reason anybody
is still using the glibc and other GNU abominations is due to their
insistence on extending all standard interfaces, including the kitchen
sink, with their own proprietary stuff (yes, Mr. Stallman, glibc is a
properitary mess). When a developer is not extra-careful they end up
using these extensions. Switching the glibc means, especially for big
and old projects, rewriting significant parts of the code.

It's even more of a shame that the glibc assumes it's "the only true"
libc, so much that musl has to imitate it in many ways. If I were a
musl developer I'd print a #warning every time an #ifdef is triggered
that was placed deliberately to babysit GNU-reliant code, so people
finally stop using GNUisms and we can stop this viscious cycle.

> 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") {
> ...
> 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.

I would keep it simple and add a small check in ARGBEGIN to set argv0
either to argv[0] or "(null)" if it is NULL. Sure, printf may handle
NULL properly, but it's an error in OpenBSD and we should avoid passing
NULLs to it. However, what we should never do is extend the code and
interfaces for crude edge cases.

With best regards


Laslo Hunhold <>

Received on Tue Jul 02 2019 - 08:02:41 CEST

This archive was generated by hypermail 2.3.0 : Tue Jul 02 2019 - 08:12:24 CEST