Remix.run Logo
qudat 8 hours ago

This is quite a timely post compared to: https://bower.sh/posix-shell-is-all-you-need

This post was thought provoking, I wonder, is the hidden argument here that the posix spec for a shell is not well specified if there is so much variance between the implementations?

Or is the fundamental issue simply a matter of history? Both?

chasil 7 hours ago | parent | next [-]

A real problem with bash in particular is that it had many incompatible features which were masked with bash's POSIX mode.

This mode is not set when called as #!/bin/bash but is enabled for #!/bin/sh

The full list of legacy behaviors that are altered in POSIX mode are in a URL at the bottom of the bash manual page:

https://tiswww.case.edu/php/chet/bash/POSIX

Ksh doesn't do this.

gaigalas 8 hours ago | parent | prev [-]

Most shell families precede the spec. Both bash and ksh had features at the time the spec was written that are not in it. It's weird.

My main point is that following the spec doesn't guarantee shell scripts will be portable, which is a common misconception.

qudat 5 hours ago | parent [-]

> My main point is that following the spec doesn't guarantee shell scripts will be portable, which is a common misconception.

That feels like a failure in the spec. Your example illustrates it: echo has unspecified behavior that literally prevents it from being portable.

Is it possible portability is just not a feature of posix?

gaigalas 5 hours ago | parent [-]

I honestly don't know! What I know is that there is an intersection of features that work with polyfills and tweaks in all shells. That intersection has a lot of the spec, but also has a lot that is not specified anywhere.

I started to build something here 12 years ago: https://github.com/Mosai/workshop. Then here 2 years ago: https://github.com/alganet/coral

Now I'm attacking it from another angle, trying to document what I learned methodically and share the tools I made for me with everyone else.