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

Oil Builtins

Table of Contents
Enhanced with Block
cd
push
Builtin Flag Syntax
I/O Builtins
echo
More

Enhanced with Block

(not done)

Shell-Like Builtins

Builtins Accept Long Options
Changed: echo
New: use, push, repr

Builtins Can Take Ruby-Like Blocks (partially done)

cd, env, and shopt Have Their Own Stack
wait and fork builtins Replace () and & Syntax
each { } Runs Processes in Parallel and Replaces xargs

cd

It now takes a block:

cd ~/src {
  echo $PWD
  ls -l
}

# current directory restored here

echo $PWD
ls -l

(This subsumes the functinoality of bash builtins pushd and popd.)

When a block is passed:

push

Append one or more strings to an array.

var array = @(1 '2 two')
push :array three four
echo @array  # prints 4 lines

Builtin Flag Syntax

Oil's builtins accept long flags like --verbose and short flags like -v.

They behave like the popular GNU utilities on Linux distros, except that -long (single hyphen) means the same thing as --long. It's not a shortcut for -l -o -n -g or -l=ong. (This rule is consistent with the Go flags package.)

In addition, all of these are equivalent:

The first is preferred because it's the simplest and shortest.

(Trivia: Oil's flag syntax avoids the issue where set -oo errexit nounset is a confusing equivalent to set -o errexit -o nounset.)

I/O Builtins

Oil uses write and getline along with the CSTR format. echo looks more familiar and is OK in many cases, but isn't strictly necessary.

Shell:

Oil:

echo

More

Future work, not implemented


Generated on Sun Jan 19 22:59:37 PST 2020