/
osh-quick-ref-toc.txt
199 lines (182 loc) · 8.72 KB
/
osh-quick-ref-toc.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
OSH Quick Reference
- Below is a list of topics, organized into [Sections].
- The X prefix means "unimplemented".
- HTML version: https://www.oilshell.org/release/0.7.pre2/doc/osh-quick-ref.html
INTRO
[Overview] overview osh-vs-oil command-vs-expr
[Usage] bundle-usage osh-usage oil-usage config startup
line-editing prompt
[Lexing] comments # line-continuation \
[Oil Lexing] single-command %%% docstring ###
COMMAND LANGUAGE
[Commands] simple-command semicolon ;
[Conditional] case if true false colon :
bang ! and && or || dbracket [[
[Iteration] while until for for-expr-sh ((
[Control Flow] break continue return exit
[Grouping] function block { subshell (
[Concurrency] pipe | X |&
ampersand &
[Redirects] redir-file > >> >| < <> X &>
redir-desc >& <&
here-doc << <<- <<<
[Other] dparen (( time X coproc X select
[Oil Keywords] func do pass fs
(Change parsing so they can't be builtins)
ASSIGNING VARIABLES
[Operators] assign str='xyz'
append str+='abc'
[Compound Data] array array=(a b c) array[1]=B "${a[@]}"
assoc assoc=(['a']=1 ['b']=2) assoc['x']=b
[Builtins] local readonly export unset shift
declare typeset X let
[Oil Keywords] var setvar auto
OIL EXPRESSION LANGUAGE
X [Data Types] Str r'\' c"\n" multiline r""" c'''
Bool true false
Int 1_000_000
Float 3.14
Array<> @[ls -l] @[T F F] @[1 2 3] @[1.5 2.5]
Dict<> {name: 'oil'} {['name']: 'oil'} {name}
List [1, 'str', false] (for JSON compatibility)
Null null
Regex $/ d+ /
Func func(x) { return x+1 }
X [Comprehension] Array, List, Dict
X [Operators] unary -a
binary a+b base^exp a xor b p div q
ternary a if cond else b
subscript a[b, c] a[start:end]
chain pass a => f(y, z) => var new
getattr d->key is like d['key'] or d.key
scope-attr module::name
X [Functions] func-decl func inc(a Int, b Int = 1) Int { ... }
cmd-call call f(x, y); echo $foo
word-call echo $strfunc(x, y) @arrayfunc(z)
WORD LANGUAGE
[Quotes] quotes 'abc' $'\n' "$var"
[Substitutions] com-sub $(command) `command`
var-sub ${var}
arith-sub $((1 + 2)) $[1 + 2]
tilde-sub ~/src
proc-sub diff <(sort L.txt) <(sort R.txt)
[Special Vars] special-vars $@ $* $# $? $- $$ $!
[Var Ops] op-test ${x:-default}
op-unary ${x%%suffix} etc.
op-str ${x//y/z}
op-slice ${a[@]:0:1}
op-format ${x@P}
X [Oil Word] oil-printf ${x %.3f}
oil-format ${x|html}
OTHER SHELL SUBLANGUAGES
[Arithmetic] arith-context Where legacy arithmetic is allowed
num-literals 0xFF 0755 etc.
math 1 + 2*3
arith-logical !a && b
bitwise ~a ^ b
arith-assign a *= 2
[Boolean] dbracket [[ vs. the test builtin
bool-expr [[ ! $x && $y || $z ]]
test ! $x -a $y -o $z
bool-infix [[ $a -nt $b ]] [[ $x == $y ]]
bool-path [[ -d /etc ]]
bool-str [[ -z '' ]]
bool-other [[ -o errexit ]]
[Patterns] glob *.py
extglob @(*.py|*.sh)
regex [[ foo =~ [a-z]+ ]]
[Brace Expand] braces {alice,bob}@example.com
[History] histsub !$ !! !n
BUILTIN COMMANDS
[I/O] read echo
X readarray X mapfile
[Run Code] source . eval trap
[Set Options] set shopt
[Working Dir] cd pwd pushd popd dirs
[Completion] complete compgen compopt compadjust
[Shell Process] exec X logout
umask X ulimit X times
[Child Process] jobs wait ampersand &
fg X bg X disown
[External] test [ printf getopts X kill
[Introspection] help hash type X caller
[Word Lookup] command builtin
[Interactive] alias unalias history X fc X bind
X [Unsupported] enable
X [Oil Builtins] log die common functions
dirname basename simple optimization
cd shopt env compatible, and takes a block
fork wait replaces & and (), takes a block
use source with namespace, file-relative
push sugar for 'do array.push( @(a b) )'
SHELL OPTIONS
[Errors] nounset errexit pipefail
[Globbing] noglob failglob nullglob
[Debugging] xtrace X verbose X extdebug
[Interactive] emacs vi
[Other] X noclobber
[OSH Strict] all:strict All options starting with 'strict-'
strict-argv No empty argv
strict-array Arrays don't decay to strings
strict-arith Fatal parse errors (on by default)
strict-errexit Fail earlier, at command sub
strict-control-flow Do we need this? Special builtins?
strict-word-eval Expose unicode and slicing errors
X strict-tilde Tilde subst can result in error
X strict-backslash Parse the sublanguage more strictly
X strict-glob Parse the sublanguage more strictly
X strict-eval-builtin Single arg
X strict-trap Function name only
X [Oil Semantics] all:oil All options below, plus POSIX and bash
static-word-eval No splitting, static globbing
longopts test -file, shopt -unset, etc.
oil-echo No -e or -n, one arg per line
oil-test-builtin Only file tests (no strings), remove [
X [Oil Syntax] all:oil-parse
oil-parse-at echo @array @arrayfunc(x, y)
oil-parse-brace cd ~/src { ... }
oil-parse-equals x = 's' (for cleaner config snippets)
oil-parse-paren if (x > 0) ...
oil-parse-set instead of setvar
ENVIRONMENT VARIABLES
[Shell Options] SHELLOPTS X BASHOPTS
[Other Vars] HOME PATH IFS
[Oil Paths] ?builtins ?completion_plugins ?coprocesses
SPECIAL VARIABLES
[Oil] ARGV
X [Platform] HOSTNAME OSTYPE BASH_VERSION @BASH_VERSINFO
[Call Stack] @BASH_SOURCE @FUNCNAME @BASH_LINENO
X @BASH_ARGV X @BASH_ARGC
[Tracing] LINENO SOURCE_NAME
[Process State] X BASHPID X PPID UID EUID
X [Process Stack] BASH_SUBSHELL SHLVL
X [Shell State] BASH_CMDS @DIRSTACK
[Completion] @COMP_WORDS COMP_CWORD COMP_LINE COMP_POINT
COMP_WORDBREAKS @COMPREPLY X COMP_KEY
X COMP_TYPE COMP_ARGV
[cd] PWD OLDPWD X CDPATH
[getopts] OPTIND OPTARG X OPTERR
[read] REPLY IFS
[Functions] X RANDOM X SECONDS
[Other] BASH_REMATCH @PIPESTATUS
PLUGINS AND HOOKS
[Signals] SIGTERM X SIGINT X SIGABRT SIG...
[Traps] EXIT X ERR X DEBUG X RETURN
[Words] PS1 X PS2 X PS3 PS4
[Completion] complete
[Other] X command_not_found PROMPT_COMMAND
OIL EXTENSIONS
X [awk] BEGIN END when
X [make] rule (builtin)
X [xargs] each (builtin)
X [find] fs
OIL LIBRARIES
X [Builtin Funcs] join() split() $IFS algorithm or awk algorithm
read(n) better than read -n, no short reads?
write() replaces echo -n
posix::read() raw bindings?
strftime()
X [getopts] ?
X [Testing] check ?
X [Data Formats] json csv tsv2 struct (binary)
X [Hash Functions]