3 ms·
If you want familiar syntax, Oil is the most bash-compatible shell by a mile (which means it's also POSIX compliant). But you can opt in to a bunch of fixes fo
by chubot 6y ago
If you want familiar syntax, Oil is the most bash-compatible shell by a mile (which means it's also POSIX compliant).
But you can opt in to a bunch of fixes for longstanding shell warts, shown here:
https://www.oilshell.org/release/0.8.0/doc/idioms.html https://www.oilshell.org/release/0.8.0/doc/idioms.html
So upgrading is / will be worth it.
-----
There's an issue to run fzf, which was partially done last year: https://github.com/oilshell/oil/issues/322 https://github.com/oilshell/oil/issues/322
I could use help looking into what remains there!
And there are more such issues here: https://github.com/oilshell/oil/labels/should-run-this https://github.com/oilshell/oil/labels/should-run-this
Just running these scripts and localizing the error is a big help! And that would get us closer to a new shell that can be realistically adopted.
Oil has run thousands of lines of unmodified bash scripts, and many thousands more with minor patches, including some of the biggest shell scripts in the world:
https://www.oilshell.org/blog/2020/04/release-0.8.pre4.html https://www.oilshell.org/blog/2020/04/release-0.8.pre4.html
- fmakunbound 6y agoThanks for the Oil shell suggestion. I will definitely check it out this evening. I don't care for POSIX compatibility. I'm a long time Bash user, I've written programs I probably should not have in Bash, and I'm familiar with most of the pitfalls described in a recent HN post https://news.ycombinator.com/item?id=24401085 https://news.ycombinator.com/item?id=24401085 however, after reading through them I thought this is some serious bullshit one must contend with and went looking or alternate shells. Elvish being one of them.
- chubot 6y agoIf you've written programs you shouldn't have in bash, then you're very much the target user for Oil :) As stated on the home page, it's our upgrade path from bash to a better language and runtime. So I would be interested if those programs run under Oil. Many do, and if they don't, the fix is usually small. Other programs I've run include Lisp and brainfuck interpreters in bash. And thousands of lines of bash completion scripts. If the programs run, you can opt into strictness checks to improve them / find bugs. And if you want to drop bash compatibility, you can use the new Oil language. (still in progress, but you can try it right now) The goal of Oil is very much to REMOVE all the pitfalls in that thread! It's done with option groups shopt -s oil:basic or shopt -s oil:all. Feel free to contact me on Github or Zulip about it. If you have bash programs, that makes it more interesting. I'm looking for feedback to help shape the Oil language :) Based on my experience I think only 10% of bash users write a program that's longer than 5 lines, or use any bash features. Most people just use what their distro provides (which is what I did for years as well).
- akavel 6y agoA link to some related fun & craziness, for people not too familiar with Oil: https://github.com/oilshell/oil/wiki/The-Biggest-Shell-Programs-in-the-World https://github.com/oilshell/oil/wiki/The-Biggest-Shell-Progr...
- xiaq 6y 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-POSIX-Mode.html 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.
- chubot 6y agoYeah 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 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.
- IgorPartola 6y agoThe buried lede here is that Oil uses some kind of tool to translate Python to C++ before running it. This sounds super interesting. Also am I misreading or is Oil written in Python 2.7?
- chubot 6y agoThere are 2 builds now: the one that runs under a slice of the Python 2 interpreter, and "oil-native", which is that code translated to C++. Rather than saying Oil is written in Python 2, it's better to say that Oil is written in ASDL + a subset of statically typed Python + an abstract dialect of regexes (similar to Eggex). In other words, it's a bunch of custom DSLs. And all of those DSLs translate to Python 2, as well as C++. So yes there is a lot of metaprogramming going on! This makes the code shorter, more correct, and even pretty fast (slightly faster than bash, and it appears we will maintain that, although it may get slower in the short term) Resources here, happy to answer any more questions: http://www.oilshell.org/blog/2019/06/17.html#why-is-it-written-in-python http://www.oilshell.org/blog/2019/06/17.html#why-is-it-writt... http://www.oilshell.org/blog/2020/03/recap.html#mycpp-the-good-the-bad-and-the-ugly http://www.oilshell.org/blog/2020/03/recap.html#mycpp-the-go...