Hacker News new | ask | show | jobs
by xiaq 2109 days ago
> Oil is the most bash-compatible shell by a mile (which means it's also POSIX compliant).

Bash is not POSIX-compliant by default; it has a POSIX mode (https://www.gnu.org/software/bash/manual/html_node/Bash-POSI...), which changes a lot of behaviors. It's mostly small things, but it's a long list nonetheless.

I wonder what's Oil's approach here - does Oil has separate "bash mode" and "POSIX mode"? Or are the divergences inconsequential enough for most scripts that you don't bother distinguishing them?

FWIW, I avoid using the word "POSIX-compliant", because strict POSIX compliance is usually not exactly what people want when they use this word. Instead I'd just say "POSIX-ish" as a vague notation for the intersection set between bash and the actual POSIX standard, and maybe more minimal POSIX-ish shells like dash.

1 comments

Yeah I agree it's not a great phrase, but people seem to have it in their heads.

What I mean is that although Oil is very bash-compatible, and that's how I usually describe it, it's not ONLY bash compatible.

Oil's spec tests run against multiple shells for this reason. I try not to reproduce the bugs of bash unless they are necessary to actually run something. (And this happens a lot -- there are accidental corners that nobody uses.)

For example, the Linux distro milestone in 2018 showed Oil's portability: Debian's debootstrap runs with dash, Alpine's abuild runs with busybox ash, and Aboriginal runs with bash.

But Oil runs all 3 of those scripts by default, unmodified. For example, the Alpine one used alias, which is off by default in bash, but on in POSIX mode. Oil has aliases on for this reason (which makes it more POSIX compliant than bash in that regard.)

----

I also test with the Smoosh POSIX test suite, from the Smoosh formal semantics (though that is not the only suite the paper uses to judge compliance.) On that suite, Oil passes more POSIX tests than all shells except bash now. And the differences are mostly unimplemented features, so I think it's inevitable that it will pass more than bash.

So I still believe in the assertion here: Oil is actually a better POSIX. It describes what shell scripts require in practice, better than POSIX does.

http://www.oilshell.org/blog/2018/01/28.html#limit-to-posix

----

So Oil doesn't have a POSIX mode yet. It might in the future. So far it doesn't seem necessary to run real shell scripts.

But yes I agree that "POSIX by the letter" isn't a super useful property. What I mean is that Oil is designed to run a wide variety of shell scripts, and also help people write portable code.

I think when people say "POSIX" they mean "I want my program to run under multiple shells", and Oil definitely supports that.