source | all docs for version 0.8.0 | all versions | oilshell.org
Warning: Work in progress! Leave feedback on Zulip or Github if you'd like this doc to be updated.
Shell has these concepts.
Sigils:
echo $var
echo "$@"
Sigil Pairs:
echo ${var}
echo $(hostname) #
echo $((1 + 2 ))
Oil extends them.
Like Python, JS. See Oil language definition.
[[ ]] and []
echo -e and $''
remaining dynamic parsing in shell
arithmetic is still somewhat dynamic -- replaced by Oil expressions
assignment builtins support dynamism, replaced by var
and setvar
set
, and maybe =Another concept is parsing modes.
shopt -s all:oil # most important thing, turns on many options
if ( ) {
}
echo @array
set x = 1
builtin set -o errexit
equals:
x = 1
equivalent to
const x = 1
This is for Oil as a configuration language.
See Command vs. Expression Mode.
echo hi
Expression mode in three places:
echo @array
myprog --flag=$f(x, y)
var z = f(x+1, y)
Control FLow:
if grep foo if (foo) {} # replaces if [ -n $foo ]; then
while
for
switch/case -- for translation to C++ like mycpp match/case
Sigils:
Sigil Pairs:
${x} for word evaluation
$(( )) for shell arithmetic is deprecated
$(bare words) for command sub
%(bare words) for shell arrays
%[1 2 3] for typed arrays
%{ } for table literals / embedded TSV
$// for regexes
c'' c"" r'' r"" for strings
:{} for blocks
:() for unevaluated expressions
Table example:
var people = %{
name age:Int
bob 10_000
'andy c' 15_000
}
var people = {name: %(bob 'andy c'), age: %[10_000 15_000]}
Sigil pairs often change the lexer mode.