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 a = @(1 '2 two')
push :a three four
echo @a # prints 4 lines

push is a shortcut for:

setvar a = @( @a three four )

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 Sat Jul 18 02:28:24 PDT 2020