Raul Miller <[email protected]> wrote:
> On Fri, Feb 18, 2022 at 12:33 PM ethiejiesa via General
> <[email protected]> wrote:
> > If we're opting for broadest portability here, then you might want to 
> > consider
> > using `#!/usr/bin/env sh'.
> 
> I do not think that this is the right approach.

Are you able to elaborate?

> #!/bin/sh finds sh just fine. 

The shebang #!/usr/bin/env sh finds sh just fine as well.

However, as I mentioned in the previous email #!/bin/sh finds the *wrong* sh
in several common cases such as the build environments of some linux package
managers. It's possible to brute-force replace the shebang in these cases, but
using /usr/bin/env makes scripts a "better citizen" while not breaking on
systems that are just fine using /bin/sh.

> (And, /bin/sh is more portable than /usr/bin/env)

If you have concrete situations in mind that back up this statement, I'm all
ears. In my experience, if anything it's the other way around. Really, the
issue isn't so black and white, but for modern systems and my particular
exposure, any problems with using /usr/bin/env have always entailed minor
fixes, while problems with using /bin/sh usually end up requiring more fragile
and/or painful workarounds.

Cheers.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to