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
echo
push
Builtin Flag Syntax
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:

echo

shopt -s simple_echo changes the echo builtin to accept the following long flags, as well as the -- separator between flags and args.

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.)

More

Future work, not implemented


Generated on Sat Dec 7 23:40:10 PST 2019