logoalt Hacker News

qudattoday at 1:30 AM2 repliesview on HN

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?


Replies

chasiltoday at 2:22 AM

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.

gaigalastoday at 1:48 AM

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.

show 1 reply