Portable Operating System Interface / POSIX
POSIX is an ancient standard, a (failed) attempt to keep all the UNIX versions compatible back in 1988 — more than four decades ago.
When Linux and BSD came out they decided they would play as nicely as they could, but would not put up with the snail’s pace of innovation in the POSIX standard and neither should you.
📰 The same thing happened with the Mozilla web browser adding background, blink, and a host of other HTML elements; and the W3 Working Group splitting from W3C. Standards can be good but they can also destroy progress. At this point writing 40-year-old POSIX compliant anything is the latter.
💢 The dumbest, most annoying invocation of “POSIX compliance” is the ridiculously bad/slow/stupid use of
cutand their ilk. None of these are needed with modern Bash 4.4+.
The Only OS Standards That Matter: Linux and BSD
Most of the world runs on GNU/Linux and BSD. The only thing you should ever worry about is compatibility with the last LTS release of either of these. Anything more is wasted cognitive overhead.
POSIX is Dead
Recognize any of these?
- OS X
Yeah, didn’t think so. I’ll bet only AIX and Solaris have any machines still alive out there buried in the bowels of massive corporate dungeons supported by the weight of decades of technical debt bearing down on them from the ancient stone walls all around them. You get the idea.
America’s nuclear arsenal still runs on floppy disks.
Do you want to be anywhere near those organizations?
That’s right. I see you are a very intelligent technologist.
But the answer is actually,
And if anyone tries to entice you into working at one of these career killing places you should run screaming and warn all those you know and love about the vampirous beast looking for vibrant souls to suck down its undead gullet.
Performance and Portability are Still Alive
Just because POSIX is dead doesn’t mean we should not be concerned with startup times — the reason
Portability just makes common sense. We can still make most of
ls options work the same way. Maintaining compatibility doesn’t require a standard, just a brain that — like — works.
Opposition from Crusty Old Religious Zealots
The words I have just written above will throw certain individuals into a massive rage — mostly because they know it is true and cannot deal with the cognitive dissonance that has calcified into their diseased minds.
I know, I used to be one.
I was so influenced by having to write POSIX shell at IBM for 10 years that had to run on 10s of thousands of different UNIX and Linux machines that it practically became a religion to me — as it has for many others.
But the cult of POSIX has reached a Jim Jones kool-aide level of crazy. Time for us to save as many as we can and let the other zombies succumb to Darwin’s laws.
Your Grandpa Wants His POSIX Shell Scripts Back
There’s a lot of outdated crap advice on StackExchange and the rest of the Internet. Here’s what you really need to know.
Using any of the following out-of-date, defunct commands just shows how uninformed, old, or stupid you are:
All of these can be replaced with Bash 4.4+.
This isn’t a matter of opinion. It’s a matter of objective efficiency.
What’s even worse is that it’s been discovered that every time you unnecessarily fork a sub-shell a cute animal dies somewhere that you will never see. It’s true. That’s how toxic these commands are today.
Do the right thing. Don’t kill cute animals with your idiocy.
Then again, maybe you’re a sadist troll. God knows the world is full of them right now.
💬 Notice that
perlis not in the list. Using
sed -ialso shows how stupid you are. Perl defined the current standard in regular expression matching. You should always use
perl -iinstead of
sed -ifor anything that needs it, for example
perl -p -i -e 's/foo/bar/g' **/*to recursively find and replace
bar. Perl is far more safe and powerful than
sedfor such things. Yes it’s bigger, but when you actually need something besides Bash
perlshould be the first thing you reach for — not Python, which actually loads
libpcre.sowhich is Perl’s own regular expression library. Perl also replaces any
awkstuff you might think you need.