Why Sponsor Oils? | blog | oilshell.org

Updates to the Oil FAQ

2021-02-11 (Last updated 2021-02-12)

Update: I folded this post into the FAQ. I recommend reading that page instead!

A couple weeks ago, I edited and republished the 2018 FAQ.

Since then, I rewrote 3 answers and constructed the questions below based on feedback. I'll copy them over there after collecting feedback here. It's the most popular page on the site!

Table of Contents
2021 Updates
What can I use right now?
Where can I see some sample code?
Don't shell scripts have many dependencies?
Comparisons
What's the difference between Oil and fish?
What about PowerShell?
What about $OTHER_SHELL?
What about this shell-like library / embedded DSL?
Conclusion

2021 Updates

The questions below are inspired by threads like this one from Reddit.

What can I use right now?

See Why Use Oil? — I keep it up to date.

As of February 2021, Oil is best used as a dev tool alongside bash or POSIX shell. It will help you write better programs.

You can use Oil in production, but it's slow in some cases. The upcoming C++ translation will fix that.

I encourage people to test Oil, and to give feedback on the Oil language!

Where can I see some sample code?

This program prints Hello world:

var name = 'World'
echo "Hello $name"

Here's a more complex program inspired by a lobste.rs thread. It deletes git branches that are merged, except for master:

git-branch --merged | while read --line {
  var line = _line.strip()
  # The * prefix means the branch is unmerged
  if (line != 'master' and not line.startswith('*')) {
    echo $line
  }
} | readarray -t :branches

if (len(branches) == 0) {
  echo "No merged branches"
} else {
  git branch -D @branches
}

Notice these differences between Oil and shell:

I plan to port this snippet to more languages and write a longer post about it. (I also think readarray -t should be read --lines.)

More code examples:

Don't shell scripts have many dependencies?

Yes, this is a problem. I commented on it in the last post. Oil should have some combination of these two solutions:

Note that Python, Ruby, and JavaScript also have dependency problems, and a better shell will help us fix those!

Related answer

Comparisons

This section will help you understand Oil vs. other shells. Here are the primary differences:

You may be happy using another shell! Feel free to let us know what you like, and maybe those features can be integrated into Oil.

What's the difference between Oil and fish?

Fish is a good interactive shell, but a poor language for automation. So it's the opposite of Oil, and complementary to it.

It would make sense to combine the projects in some way:

Related:

I love fish as a shell, I just don't think it's good as a scripting language

 

What about PowerShell?

See this section of the previous post. PowerShell is more natural on Windows, and it's embedded in a large VM.

What about $OTHER_SHELL?

I link to dozens of other shells on this wiki page:

Oil has taken cues from some of these projects (and vice versa). Again, the biggest difference is that Oil is the only shell that's a smooth upgrade from bash.

This post about Linux distros gives color on why Oil aims to be compatible. Most distros are based on shell, with languages like Python being either nonexistent or playing an ancillary role.

What about this shell-like library / embedded DSL?

I also maintain a list of dozens of shell DSLs in various languages:

People spent a lot of effort on these projects, so I have no doubt that they're useful. Embedding has advantages in some situations.

But I don't consider any of these libraries to be bash or shell replacements. A shell is a foundational, low-level component of a Unix system.

Conclusion

Let me know if these answers make sense! I'll edit them and copy them into the 2021 FAQ.