Hacker News new | ask | show | jobs
by gaigalas 1 hour ago
The spec is not that good.

`local` for example is present in many shells (almost all of them), but they decided to leave it out uniquely because of ksh93 (scope is different). It became undefined behavior.

When the spec was written, ksh was important. Since then, it has only been revised but not updated and I consider it to be obsolete.

So, if you follow POSIX strictly, you then lose local scope on functions, which is more likely to cause bugs and hard to catch with a linter like you suggested. You're left with a broken feature set (on many other angles too) that is not actually practical. Even spellcheck makes concessions.

1 comments

I don’t get this point either. If local is not in the POSIX spec, I guess you can’t use it if you want to be POSIX compatible. Just because many shells do it doesn’t mean it’s POSIX.
You can target POSIX if you want to, but doing that doesn't guarantee shell scripts will work.

The blog post stresses this, the difference between POSIX and portability.

If you want portability, testing is better for now. One of the goals of these projects is to more precisely capture a retrospec (what actually works, not what was specified), it's the same thing they did with HTML5.