|
blog | oilshell.org
Why Use Oil?
2020-08-07
(Last updated 2021-01-23)
Oil is a new Unix shell. It's our upgrade path from bash to a better
language and runtime.
There are many parts of the Oil project, with various degrees of maturity. The
POSIX and bash features are the most mature.
This page describe the benefits of Oil concisely, linking to details. It's
a draft, and will be improved and updated continuously. Let me
know if it gets out of date!
Related: Four Features That Justify a New Unix
Shell.
What You Can Use Right Now
Oil runs your existing POSIX shell scripts and bash scripts. It doesn't
fragment your codebase or pool of contributors. Wiki: Shell Programs That Run
Under
OSH.
If you're not ready to switch right away, you can use it simultaneously with
bash. Oil is a good a dev tool for shell scripts, like
ShellCheck.
- It can find bugs in your shell scripts.
- It parses more strictly. For example, it found bugs in ble.sh by
statically parsing it.
- It has more than a dozen strict
modes
at runtime, some of which are described under the
#real-problems tag. (TODO: more docs / blog posts about
strict modes).
- It has better and more precise error messages than any other POSIX shell.
It points you to line number and column that caused the error.
- It helps you avoid unsafe constructs (security).
eval_unsafe_arith
is off by default. Static parsing is preferable to
dynamic parsing. The latter leads to data executed as code.
- It has reliable error
handling. It fixes
several well-known problems with shell's
errexit
.
- It has better tracing,
which will help you understand existing shell programs.
More benefits:
- It saves you from quoting hell. No more
!qefs
(quote every f***ing
substitution). See Simple Word
Evaluation.
- Splicing syntax is
@myarray
, not the awkward "${myarray[@]}"
(blog
post).
- Data Structures
- Ruby-like Blocks are a new shell language construct which open up many
possibilities.
cd /tmp { echo $PWD }
works!
- It prints strings consistently with a format called QSN.
- Conveniences like a builtin
readlink
.
If you can write Python, you can change Oil! See the section below.
For System Integrators, e.g. Linux Distro Maintainers
Oil is standards compliant:
- It's a POSIX shell, which means it can be the only shell on a Unix
system. You don't have to maintain two shells.
- It ships as standard C++ 11, and is written against ANSI C APIs (e.g. GNU
libc, musl libc). Oil has very few build dependencies.
- Note that Oil's metalanguage is statically-typed Python + DSLs,
but you don't need a Python interpreter to build or use it.
This work will happen in 2021 or later (or never). I hope Oil will be useful
soon, and attract contributors.
- A brand new expression language, with types.
- We want to get rid of ugly shell syntax like
${x%%prefix}
, in favor of
Python- or JavaScript-like expressions.
- An awk-like language for filtering tables.
- It will use QTSV, an
enhancement to TSV that uses QSN strings.
- Blocks enable "declarative" configuration and DSLs. For example, the
ability to generate Ninja files. A replacement for the
shell-in-YAML antipattern.
- A better flag parser for shell.
- A sandboxed interpreter for configuration, and for writing a shell UI in
shell.
- That is, a foundation for a principled interactive shell, i.e. written in
Oil and not C/C++.
- Descriptions shown in completion.
- A zsh-like interactive interface.
- Performance
- Parsing speed.
- Runtime "compute" speed.
- I/O speed (already done). Oil Starts Fewer Processes Than Other Shells
(TODO: blog post)
Oil's Code Is Easy To Modify
- It takes 2 minutes to build and modify. (TODO: screencast.)
- Statically typed with MyPy.
- Written in high level DSLs, which means the code is short. In
comparison, the bash implementation is long-winded. It grovels
through backslashes and braces one at a time.
- Despite the high-level languages, the resulting code is efficient, due to
mycpp.
- Comprehensive continuous build infrastructure.
Why Not Use It?
- The documentation is sparse. Help wanted!
- As of January 2021, there's still a separation between oil-native
and Oil in Python. I hope that oil-native will be the recommended
tarball by the end of 2021.
More Information
Get Oil