Why Sponsor Oils? | source | all docs for version 0.23.0 | all versions | oilshell.org
Warning: Work in progress! Leave feedback on Zulip or Github if you'd like this doc to be updated.
This is an overview of shell builtins that are unique to Oil. A full description of each builtin will be available in the help pages.
What are builtins? They look like external commands, but are included with the shell itself. They don't spawn an external process, and can modify the shell's memory.
append
appends strings to an arrayExample:
var a = :| 1 '2 two' |
append :a three four
echo @a # prints 4 lines
Here's another way to write it:
setvar a = :| @a three four |
Note that you can append to a string like this:
var s = 'foo'
setvar s = "${s}suffix"
(Note: Oil doesn't currently support the equivalent of shell's s+=suffix
.)
pp
pretty prints interpreter statepp cell
- shows the value of a variable, for debuggingpp proc
- shows doc stringsmodule
use
runproc
Done:
Planned, but not implemented:
&
()
PYTHONPATH=. foo.py
xargs
Examples of what we have in mind:
# this replaces an awkward idiom with eval I've seen a lot
shopt -u errexit { # TODO: --unset
false
echo "temporary disable an option"
}
# generalizes the 'NAME=value command' syntax and the 'env' prefix helps parsing
env PYTHONPATH=. {
./foo.py
./bar.py
}
# replaces sleep 5 &
fork { sleep 5 }
# replaces () syntax so we can use it for something else.
forkwait { echo subshell; sleep 5 }
# Probably used for a "syntactic pun" of Python-like "import as" functionality
use lib foo.sh {
myfunc
myalias otherfunc
}
It now takes a block:
cd /tmp {
echo $PWD # prints /tmp
}
echo $PWD # prints the original directory
This subsumes the functionality of bash builtins pushd and popd.
When a block is passed:
cd
doesn't set The OLDPWD
variable (which is used to implement the cd -
shortcut.)pushd
and popd
isn't cleared, as it is with a
normal cd
command.See IO Builtins.
And JSON.