Warning: Work in progress! Leave feedback on Zulip or Github if you'd like this doc to be updated.

What is Oil?

Oil is an interactive shell and programming language. It's our upgrade path from bash.

The language is designed to be easier to learn, more consistent, and more powerful.

It runs existing shell scripts, but also borrows features from Python, JavaScript, Ruby, and Perl. It has rich data structures, declarative DSLs, and reflection/metaprogramming features.

The rest of this doc gives various

Table of Contents
It Runs Your Existing Shell Scripts
It's a New Language, which mostly borrows from other languages
Examples For the Impatient
High-Level Descriptions
Oil Mostly Borrows From Other Languages
Differences from Python
Paradigms and Style
What Should It Be Used For?
Oil Compared to Other Shells
Links To Older Descriptions
bin/oil is bin/osh with the option group all:oil
More Links

It Runs Your Existing Shell Scripts

It's a New Language, which mostly borrows from other languages

Examples For the Impatient

This post is long, so here are some concrete examples.

An important part of Oil is that existing shell code runs! These examples from Pipelines Support Vectorized, Point-Free, and Imperative Style still run.

--> syntax sh hist() { } f() { hist } <--

That illustrates some of the good parts of shell. The bad parts still run as well!

However, Oil is a brand new language. Due to some tricks I practied while #[parsing-shell][], like lexer modes, very few compromises had to be made.

TODO: function for fib, and then write it to a different directory? or maybe look up something in /usr/share/dict/words

use it as a seven letter scrabble rack?

Fibonacci

func fib(n) {
  var a = 0
  var b = 1
  for (_ in range(n)) {
    set a, b = b, a+b
  }
  return b
}

proc fib {
  var n = $1
  var a = 0
  var b = 1
  for _ in @split($(seq n)) {
    set a, b = b, a+b
  }
  return b
}

Shell Script

shopt -s all:oil

# something with a pipeline
find . -

proc main {
}

High-Level Descriptions

Oil Mostly Borrows From Other Languages

Trying to be conservative. Not inventing anything new!!!

LATER:

Differences from Python

Paradigms and Style

Oil:

What Should It Be Used For?

Oil Compared to Other Shells

Links To Older Descriptions

==> md-blog-tag oil-language ==> md-blog-tag osh-to-oil

Zulip: Oil as a clean slate ?

bin/oil is bin/osh with the option group all:oil

Everything described here is part of the osh binary. In other words, the Oil language is implemented with a set of backward-compatible extensions, often using shell options that are toggled with the shopt builtin.

More Links


Generated on Sat Jul 18 02:28:24 PDT 2020