On Sat, Oct 30, 2021 at 12:08:12PM -0400, James K. Lowden wrote:
> On Wed, 27 Oct 2021 20:15:28 +1100
> John Gardner <gardnerjo...@gmail.com> wrote:
> 
> > There's already a deprecation warning in-place warning users against
> > relying on the existence of /bin/bash or the assumption that /bin/sh
> > == /bin/bash.
> 
> Every so often I get a +10 bump on SO for my answer about writing a
> portable shell script.  The answer starts by changing the first line to 
> 
>       #! /bin/sh
> 
> because Posix says that shell has to be there.  If Posix had a slogan,
> surely it would be "Why mess around with anything else?".  ;-)
> 
> --jkl


I'd be interested in seeing a reference to where POSIX says that :-)

... because it doesn't.  It doesn't say anything about #! in shell
scripts and it say nothing about the location of the sh shell
interpreter or the existance of the /bin directory.

And since most shells don't *enforce* POSIX compliance when running in
sh mode, just shifting to whatever shell impersonates sh might give
a developer a false sense of thinking they're writing a "portable
shell script".  The interpreter never cares about calling non-portable
external utilities.

-- 
Andreas (Kusalananda) Kähäri
SciLifeLab, NBIS, ICM
Uppsala University, Sweden

.

Reply via email to