From: Chris Torek Date: Sat, 04 May 2024 06:51:35 GMT Subject: Re: [PATCH v2 3/5] ci: separate whitespace check script Message-ID: In-Reply-To: On Fri, May 3, 2024 at 11:27 PM Patrick Steinhardt wrote: > > 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 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 is installed at all. The *most* portable method is generally to use only POSIX /bin/sh constructs, of course. :-) Chris