source | all docs for version 0.8.pre8 | all versions | oilshell.org
Warning: Work in progress! Leave feedback on Zulip or Github if you'd like this doc to be updated.
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
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 {
}
Trying to be conservative. Not inventing anything new!!!
Shell for the command syntax. Piplines, ;, and && ||.
Python for expression language:
JavaScript:
Ruby
Perl
push
builtin resemblanceJulia
;
autovivification from Perl/awk
Go:
func
type declaration syntaxLATER:
R language (probably later, need help): data frames, lazy evaluation
Honorable mention: Lua: reentrant interpreter. However the use of Unix syscalls implies global process state.
Lisp: symbol types
Types:
dataflow: concurrent processes and files, pipelines
imperative: the original Bourne shell added this.
Oil:
getting rid of: ksh. Bourne shell is good; ksh is bad because it adds bad string operators.
Add Python STRUCTURED DATA.
Add declarative paradigm to shell.
Package managers like Alpine Linux, Gentoo need declarative formats. So do tools like Docker and Chef.
Language-Oriented -- internal DSLs.
==> 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.