View
@@ -0,0 +1,119 @@
Oil Quick Reference
- Below is a list of topics, organized into [Sections].
- View it on the web at
https://www.oilshell.org/release/0.0.0/doc/oil-quick-ref.html
INTRO
[Overview] overview cmd-vs-expr
[Usage] ovm-usage oil-usage config startup line-editing
COMMAND LANGUAGE
[Commands] simple-command semicolon ;
[Conditional] match match-expr if if-expr
not !! and && or ||
true false
[Iteration] while while-expr for for-expr
[Control Flow] break continue return
[Grouping] func proc do shell
[Concurrency] pipe | |+
fork X proc-sub
[Redirects] redir > < <> >+
block-redir redir > /dev/null then !2 > !1 { ls / }
here-doc << >>
desc !0 !1 !2 !stdin !stdout !stderr
[Other] expr ( time coproc
ASSIGNING VARIABLES
[Keywords] var const set unset export
shift # for compatibility
[Operators] assign str = 'xyz'
X append str += 'abc' array += [c d]
lazy FILES => $[find ~/src -name '*.py']
inspired by make
[Compound Data] array array = [a b c $str] set array[x] = 'b'
boolarray = [T F T (myBool)] # or true false?
intarray = [1 2 3 (myInt)]
floatarray = [1.0 2.0 3.0 (myFloat)]
strarray = ['1' '2.0' '3.0']
X assoc assoc = {a: 1, b:2 }
split @split(myStr)
join $join(myArray)
splice [a @middle b]
OIL EXTENSIONS
[Functions] func
types Int Float Str Array<Int> Array<Float> Array<Str>
[Blocks] cd {} redir {} with {}
[Data Frames] Literals and Operators
[Pipelines] nonlinear graph {} structured-data |>
[Modules] use (static modules)
[Other Tools] fs-expr -- like find
parallel -- like xargs
[Wok] begin end when -- like awk
[Boil] rule -- like make
LIBRARIES
[Files] fd = open('foo.txt', 'w') # replacement for exec {fd}>foo.txt
close(fd) echo foo > !fd readline < !fd
[Testing] test-framework
[Serialization] json csv
[Math] libm vectorized? At least min([1 2 3]) max([4 5 6])
WORD LANGUAGE
[Quotes] quotes 'abc\n' r'\n' "$var"
here-string '''mytext''' """$myvar""" r''' r"""
[Substitutions] com-sub $[command] @[split-command]
expr-sub $(var) $(1 + 2)
func-splice $strFunc(1, 2+3) @arrayFunc(3)
tilde-sub ~/src
X proc-sub diff !1[sort L.txt] !1[sort R.txt]
ls with !1 > !0[sort] then !2 > err.txt
[Special Vars] special-vars $Status $NumArgs $PPID $IFS ...
[Var Ops] op-test x or 'default'
X op-unary $(x | strip suffix) etc.
X op-str $(x | sub('y', 'z'))
X op-slice @a[0:1]
OTHER SHELL SUBLANGUAGES
[Expression] arith-intro Contexts where math is allowed
num-literals 0xFF 0755 etc.
math 1 + 2*3
arith-logical not a and b
bitwise ~a ^ b This might change
arith-assign set a *= 2
fs-expr test(:f)
comprehension [x for x in range(3) if x % 2 == 0]
{x: 1 for a in range(3)}
Set {x for a in range(3)}
[Patterns] glob *.py
X extglob @glob[*.py *.sh]
regex (foo ~ [a-z]+)
[Brace Expand] braces {alice,bob}@example.com
BUILTIN COMMANDS
[I/O] readline echo (formatted input/output)
read write (raw input/output)
X readarray X mapfile X select
[Run Code] source source-sh eval eval-sh
[Set Options] setoption
[Working Dir] cd pwd
[Completion] complete X compgen X compopt
[Shell Process] exec exit X logout
umask X ulimit X trap X times
[Child Process] jobs wait fork
X fg X bg X disown
X [Word Lookup] command builtin
X [Introspection] help hash type caller
X [Interactive] bind history fc
X [External] test [ $a = $b ]
[Compat Only] pushd popd dirs
SHELL OPTIONS
[Declarations] parsing modes, languages? 'future' for compat
[Compatiblity] word-split?
[Parsing]
[Execution] errors (nounset, errexit, pipefail, ...)
globbing (noglob, failglob, ...)
debugging (xtrace, verbose, ...)
[OSH Options] strict sane
View
@@ -3,6 +3,24 @@
## This file gets converted to HTML and do a directory of .txt files for use in
## OSH.
## IDEA
## This is a short, dense, and slightly opinionated overview of OSH, a
## bash-compatible shell.
## I'm writing a single text file that serves as all of:
## - the online HTML manual
## - in-shell help
## - the man page.
##
## Format:
## - Flat namespace of tags: #let #pipe etc.
## - SINGLE FILE. Must be short enough for a single file.
##
## - Some parts can also be turned into man pages, e.g. #osh-usage and #oil-usage.
##
## Idea: Examples from SPEC TESTS. Hm. You could have a file#label spec test
## or something.
## Format of this file
##
## Lines that begin with two or more # signs are special.
View

This file was deleted.

Oops, something went wrong.