Re: [PATCH v2 3/5] ci: separate whitespace check script
- From
Chris Torek <chris.torek@gmail.com>
- Date
- May 4, 2024, 06:51 UTC
- Message-ID
- <CAPx1GveuQMeKt0_ZuY4DN0_tKrLBjXpWLngxYTtbzV=iHYT-QQ@mail.gmail.com>
- In-Reply-To
- <ZjUmEuKZB1xwAPo7@ncase>
On Fri, May 3, 2024 at 11:27 PM Patrick Steinhardt <ps@pks.im> wrote:
Show 13 quoted lines
> > On Fri, May 03, 2024 at 09:49:13AM -0700, Junio C Hamano wrote: > > This is a question to Patrick, but what makes it bad to assume > > "bash" is in "/bin" when it is OK to assume that "env" is always in > > "/usr/bin"? > > My own bias. I know of systems without "/bin/bash" (NixOS), but I don't > know of any without "/usr/bin/env". But you're right, "/usr/bin/env" is > not part of POSIX and thus not really portable, either. > > Ultimately I don't think there is any way to write the shebang so that > it is fully POSIX compliant. So I'd rather go with the option which is > supported on more systems, which is to the best of my knowlede env(1).
The various BSDs mostly stick bash in /usr/local/bin; some versions of macOS did not have a /bin/bash either, as I recall, though my current mac-laptop does.
In any case, #! /usr/bin/env <program> is pretty darn common; it's found in a lot of Python scripts, for instance. It works well on old SunOS, on the various BSDs, on macOS, and on Linux, provided of course that the given <program> is installed at all.
The *most* portable method is generally to use only POSIX /bin/sh constructs, of course. :-)
Chris