logoalt Hacker News

gaigalastoday at 12:44 AM2 repliesview on HN

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.


Replies

NekkoDroidtoday at 6:30 AM

The simple fact that POSIX doesn't define any long options for basically any CLI tools just makes me outright ignore it when writing scripts.

I use long options in scripts so that you can actually understand which options are used. Short options are for interactive shells since those commands nobody is really gonna look at again.

show 1 reply
echoangletoday at 12:53 AM

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.

show 1 reply