On Sun, Feb 20, 2022 at 9:51 PM ethiejiesa via General
<[email protected]> wrote:
>
> 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?

Certainly -- #!/bin/sh is about as old as unix. It's a standard part
of every unix system, even systems that went obsolete back in the
1970s.

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

Sure, but it's doing unnecessary work, and adds unnecessary complexity.

> However, as I mentioned in the previous email #!/bin/sh finds the *wrong* sh
>...

But on my bullseye system /usr/bin/env sh finds /usr/bin/sh which is a
symlink to dash, not bash.

But even if sometimes /usr/bin/sh was bash instead of dash, that would
be an obscure approach which would only work some of the time, leading
to a confused user base when problem solving in the context of this
issue.

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

Is the above enough detail?

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

There would be cases where that summary could have been correct.

This is not one of them.

On top of that, this shell script would be subject to significant
change, and probably be replaced with something entirely different, in
the future.

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

Reply via email to