Index | Thread | Search

From:
Garance ELC Drosehn <gadcode@earthlink.net>
Subject:
Re: Support for /usr/bin/env -S (kind of)
To:
Theo de Raadt <deraadt@openbsd.org>
Cc:
Manuel Giraud <manuel@ledu-giraud.fr>, tech@openbsd.org
Date:
Mon, 21 Jul 2025 00:57:17 -0400

Download raw body.

Thread
On 18 Jul 2025, at 12:36, Theo de Raadt wrote:
>
> So how common is this actually, or is it just something someone wished
> and they pushed it into Linux and it actually isn't used?
>

FWIW, I'm the one who wrote this originally, and I did that for FreeBSD.
That was committed back in 2005 and I don't remember all the details.
I do remember writing a pretty long message with all the details to one
of the FreeBSD mailing lists before I committed it.

IIRC, the catalyst for it was that early FreeBSD (1990's?) did split up
the words on the '#!' line because that seemed convenient.  Years later,
someone else noticed that this behavior did not match '#!' processing on
any other unix, so they changed the behavior so it would match.  Someone
else then thought that was a bug, because they had scripts which depended
on the earlier behavior.  I forget how many times the behavior of '#!'
processing bounced back and forth, but I had some scripts which ran on
multiple versions of Unix and one of these commits broke one of those
scripts.

I read up on all the commit-log history, and fixed '#!' processing one
more time so that it matched how other unixes do it, and I think I also
left comments in the code for that processing to document that
"Yes, '#!'-parsing is really supposed to work this way".

And then in an effort to help those people who *depended* on the earlier
behavior, I implemented '-S' to the 'env' command.  I also added the
option '-P' at the same time because that addressed an issue that *I*
had with some scripts of my own.  I have had people thank me for adding
'-S'.  I have never heard from anyone who used '-P'.

I have no idea how much '-S' is used, but it's been in FreeBSD since
June 2005, and somewhere along the line those changes were picked up
by MacOS 10.  The only linux I work on is RHEL, and it looks like
Redhat added '-S' between RHEL7 and RHEL8.

-- 
Garance Alistair Drosehn           =   gadcode@earthlink.net
Lead Developer @rpi               and        gad@FreeBSD.org
Rensselaer Polytechnic Institute;             Troy, NY;  USA