1 | ---
|
2 | title: YSH Table of Contents
|
3 | all_docs_url: ..
|
4 | css_files: ../../web/base.css ../../web/manual.css ../../web/ref-index.css
|
5 | preserve_anchor_case: yes
|
6 | ---
|
7 |
|
8 | <div class="doc-ref-header">
|
9 |
|
10 | [Oils Reference](index.html) —
|
11 | [OSH](toc-osh.html) | **YSH Table of Contents** | [Data Notation](toc-data.html)
|
12 |
|
13 | </div>
|
14 |
|
15 | [YSH]($xref) is shell with a familiar syntax, JSON-like data structures, good
|
16 | error handling, and more.
|
17 |
|
18 | <!--
|
19 | <div class="custom-toc">
|
20 |
|
21 | [type-method](#type-method)
|
22 | [builtin-func](#builtin-func)
|
23 | [builtin-cmd](#builtin-cmd)
|
24 | [front-end](#front-end)
|
25 | [cmd-lang](#cmd-lang)
|
26 | [ysh-cmd](#ysh-cmd)
|
27 | [expr-lang](#expr-lang)
|
28 | [word-lang](#word-lang)
|
29 | [mini-lang](#mini-lang)
|
30 | [option](#option)
|
31 | [special-var](#special-var)
|
32 | [plugin](#plugin)
|
33 |
|
34 | </div>
|
35 | -->
|
36 |
|
37 | <h2 id="type-method">
|
38 | Types and Methods <a class="group-link" href="chap-type-method.html">type-method</a>
|
39 | </h2>
|
40 |
|
41 | ```chapter-links-type-method
|
42 | [Atom Types] Null Bool
|
43 | [Number Types] Int Float
|
44 | [Str] X find() replace()
|
45 | trim() trimStart() trimEnd()
|
46 | startsWith() endsWith()
|
47 | upper() lower()
|
48 | search() leftMatch()
|
49 | [List] List/append() pop() extend() indexOf()
|
50 | X insert() X remove() reverse()
|
51 | [Dict] keys() values() X get() X erase()
|
52 | X inc() X accum()
|
53 | [Range]
|
54 | [Eggex]
|
55 | [Match] group() start() end()
|
56 | X groups() X groupDict()
|
57 | [Place] setValue()
|
58 | [Code Types] Expr Command
|
59 | BuiltinFunc BoundFunc
|
60 | X [Func] name() location() toJson()
|
61 | X [Proc] name() location() toJson()
|
62 | X [Module] name() filename()
|
63 | [IO] X eval() X captureStdout()
|
64 | promptVal()
|
65 | X time() X strftime()
|
66 | X glob()
|
67 | X [Guts] heapId()
|
68 | ```
|
69 |
|
70 | <h2 id="builtin-func">
|
71 | Builtin Functions <a class="group-link" href="chap-builtin-func.html">builtin-func</a>
|
72 | </h2>
|
73 |
|
74 | ```chapter-links-builtin-func
|
75 | [Values] len() func/type() X repeat()
|
76 | [Conversions] bool() int() float() str() list() dict()
|
77 | X runes() X encodeRunes()
|
78 | X bytes() X encodeBytes()
|
79 | [Str] X strcmp() X split() shSplit()
|
80 | [List] join() any() all()
|
81 | [Collections] X copy() X deepCopy()
|
82 | [Word] glob() maybe()
|
83 | [Math] abs() max() min() X round() sum()
|
84 | [Serialize] toJson() fromJson()
|
85 | toJson8() fromJson8()
|
86 | X [J8 Decode] J8.Bool() J8.Int() ...
|
87 | [Pattern] _group() _start() _end()
|
88 | [Introspection] shvarGet() getVar() evalExpr()
|
89 | [Hay Config] parseHay() evalHay()
|
90 | X [Hashing] sha1dc() sha256()
|
91 | ```
|
92 |
|
93 | <!-- ideas
|
94 | X [Codecs] quoteUrl() quoteHtml() quoteSh() quoteC()
|
95 | quoteMake() quoteNinja()
|
96 | X [Wok] _field()
|
97 | -->
|
98 |
|
99 | <h2 id="builtin-cmd">
|
100 | Builtin Commands <a class="group-link" href="chap-builtin-cmd.html">builtin-cmd</a>
|
101 | </h2>
|
102 |
|
103 | <!-- linkify_stop_col is 42 -->
|
104 |
|
105 | ```chapter-links-builtin-cmd_42
|
106 | [Memory] cmd/append Add elements to end of array
|
107 | pp asdl cell X gc-stats line proc
|
108 | [Handle Errors] error error 'failed' (status=2)
|
109 | try Run with errexit, set _error
|
110 | failed Test if _error.code !== 0
|
111 | boolstatus Enforce 0 or 1 exit status
|
112 | [Shell State] ysh-cd ysh-shopt compatible, and takes a block
|
113 | shvar Temporary modify global settings
|
114 | ctx Share and update a temporary "context"
|
115 | push-registers Save registers like $?, PIPESTATUS
|
116 | [Modules] runproc Run a proc; use as main entry point
|
117 | module guard against duplicate 'source'
|
118 | is-main false when sourcing a file
|
119 | use change first word lookup
|
120 | [I/O] ysh-read flags --all, -0
|
121 | ysh-echo no -e -n with simple_echo
|
122 | write Like echo, with --, --sep, --end
|
123 | fork forkwait Replace & and (), and takes a block
|
124 | fopen Open multiple streams, takes a block
|
125 | X dbg Only thing that can be used in funcs
|
126 | [Hay Config] hay haynode For DSLs and config files
|
127 | [Completion] compadjust compexport
|
128 | [Data Formats] json read write
|
129 | json8 read write
|
130 | X [Testing] assert takes an expression
|
131 | ```
|
132 |
|
133 | <h2 id="stdlib">
|
134 | Standard Library<a class="group-link" href="chap-stdlib.html">stdlib</a>
|
135 | </h2>
|
136 |
|
137 | <!-- linkify_stop_col is 42 -->
|
138 |
|
139 | ```chapter-links-stdlib_42
|
140 | [Args Parser] parser Parse command line arguments
|
141 | flag
|
142 | arg
|
143 | rest
|
144 | parseArgs()
|
145 | X [Testing] describe Test harness
|
146 | X [Lines] slurp-by combine adjacent lines into cells
|
147 | X [Awk] each-line --j8 --max-jobs (Str, Template, Block) - xargs
|
148 | each-row --max-jobs (Str, Template, Block) - xargs
|
149 | split-by (str=\n, ifs=':', pattern=/s+/)
|
150 | if-split-by
|
151 | chop alias for split-by (pattern=/s+/)
|
152 | must-match (/ <capture d+> </capture w+> /)
|
153 | if-match
|
154 | X [Table Create] table --by-row --by-col (&place); construct/parse a table
|
155 | table/cols cols name age - cols name:Str age:Int
|
156 | types type Str Int
|
157 | attr attr units - secs
|
158 | row emit row
|
159 | table cat concatenate TSV8
|
160 | table align to ssv8
|
161 | table tabify to tsv8
|
162 | table header (cols = :|name age|, types = :|Str Int|, units = :|- secs|)
|
163 | table slice e.g. slice (1, -1) slice (5, 7)
|
164 | table to-tsv lose type info, and error on \t in cells
|
165 | X [Table Ops] where subset of rows; dplyr filter()
|
166 | pick subset of columns ('select' taken by shell)
|
167 | mutate transmute [average = count / sum] - drop the ones that are used?
|
168 | rename (bytes='bytes', path='filename')
|
169 | group-by add a column with a group ID [ext]
|
170 | sort-by sort by columns; dplyr arrange() [ext]
|
171 | summary count, sum, histogram, any, all, reduce(), etc. [ext]
|
172 | ```
|
173 |
|
174 | <!--
|
175 | Naming ideas:
|
176 |
|
177 | X [External Lang] BEGIN END when (awk)
|
178 | rule (make) each (xargs) fs (find)
|
179 | -->
|
180 |
|
181 | <h2 id="front-end">
|
182 | Front End <a class="group-link" href="chap-front-end.html">front-end</a>
|
183 | </h2>
|
184 |
|
185 | ```chapter-links-front-end
|
186 | [Usage] oils-usage ysh-usage
|
187 | [Lexing] ascii-whitespace [ \t\r\n]
|
188 | doc-comment ### multiline-command ...
|
189 | [Tools] cat-em
|
190 | ```
|
191 |
|
192 | <h2 id="cmd-lang">
|
193 | Command Language <a class="group-link" href="chap-cmd-lang.html">cmd-lang</a>
|
194 | </h2>
|
195 |
|
196 | <!-- linkify_stop_col is 33 -->
|
197 |
|
198 | ```chapter-links-cmd-lang_33
|
199 | [YSH Simple] typed-arg json write (x)
|
200 | lazy-expr-arg assert [42 === x]
|
201 | block-arg cd /tmp { echo $PWD }; cd /tmp (; ; blockexpr)
|
202 | [YSH Cond] ysh-case case (x) { *.py { echo 'python' } }
|
203 | ysh-if if (x > 0) { echo }
|
204 | [YSH Iter] ysh-while while (x > 0) { echo }
|
205 | ysh-for for i, item in (mylist) { echo }
|
206 | ```
|
207 |
|
208 | <h2 id="ysh-cmd">
|
209 | YSH Command Language Keywords <a class="group-link" href="chap-ysh-cmd.html">ysh-cmd</a>
|
210 | </h2>
|
211 |
|
212 | ```chapter-links-ysh-cmd_33
|
213 | [Assignment] const var Declare variables
|
214 | setvar setvar a[i] = 42
|
215 | setglobal setglobal d.key = 'foo'
|
216 | [Expression] equal = = 1 + 2*3
|
217 | call call mylist->append(42)
|
218 | [Definitions] proc proc p (s, ...rest) {
|
219 | typed proc p (; typed, ...rest; n=0; b) {
|
220 | func func f(x; opt1, opt2) { return (x + 1) }
|
221 | ysh-return return (myexpr)
|
222 | ```
|
223 |
|
224 | <h2 id="expr-lang">
|
225 | Expression Language and Assignments <a class="group-link" href="chap-expr-lang.html">expr-lang</a>
|
226 | </h2>
|
227 |
|
228 | <!-- linkify_stop_col is 33 -->
|
229 |
|
230 | ```chapter-links-expr-lang_33
|
231 | [Assignment] assign =
|
232 | aug-assign += -= *= /= **= //= %=
|
233 | &= |= ^= <<= >>=
|
234 | [Literals] atom-literal true false null
|
235 | int-literal 42 65_536 0xFF 0o755 0b10
|
236 | float-lit 3.14 1.5e-10
|
237 | X num-suffix 42 K Ki M Mi G Gi T Ti / ms us
|
238 | ysh-string "x is $x" $"x is $x" r'[a-z]\n'
|
239 | u'line\n' b'byte \yff'
|
240 | triple-quoted """ $""" r''' u''' b'''
|
241 | str-template ^"$a and $b" for Str::replace()
|
242 | list-literal ['one', 'two', 3] :| unquoted words |
|
243 | dict-literal {name: 'bob'} {a, b}
|
244 | range 1 .. n+1
|
245 | block-expr ^(echo $PWD)
|
246 | expr-literal ^[1 + 2*3]
|
247 | X expr-sub $[myobj]
|
248 | X expr-splice @[myobj]
|
249 | [Operators] op-precedence Like Python
|
250 | concat s1 ++ s2, L1 ++ L2
|
251 | ysh-equals === !== ~== is, is not
|
252 | ysh-in in, not in
|
253 | ysh-compare < <= > >= (numbers only)
|
254 | ysh-logical not and or
|
255 | ysh-arith + - * / // % **
|
256 | ysh-bitwise ~ & | ^ << >>
|
257 | ysh-ternary '+' if x >= 0 else '-'
|
258 | ysh-index s[0] mylist[3] mydict['key']
|
259 | ysh-attr mydict.key
|
260 | ysh-slice a[1:-1] s[1:-1]
|
261 | func-call f(x, y; ...named)
|
262 | thin-arrow mylist->pop()
|
263 | fat-arrow mystr => startsWith('prefix')
|
264 | match-ops ~ !~ ~~ !~~
|
265 | [Eggex] re-literal / d+ ; re-flags ; ERE /
|
266 | re-primitive %zero 'sq'
|
267 | class-literal [c a-z 'abc' @str_var \\ \xFF \u0100]
|
268 | named-class dot digit space word d s w
|
269 | re-repeat d? d* d+ d{3} d{2,4}
|
270 | re-compound seq1 seq2 alt1|alt2 (expr1 expr2)
|
271 | re-capture <capture d+ as name: int>
|
272 | re-splice Subpattern @subpattern
|
273 | re-flags reg_icase reg_newline
|
274 | X re-multiline ///
|
275 | ```
|
276 |
|
277 | <h2 id="word-lang">
|
278 | Word Language <a class="group-link" href="chap-word-lang.html">word-lang</a>
|
279 | </h2>
|
280 |
|
281 | <!-- linkify_stop_col is 33 -->
|
282 |
|
283 | ```chapter-links-word-lang_33
|
284 | [Quotes] ysh-string "x is $x" $"x is $x" r'[a-z]\n'
|
285 | u'line\n' b'byte \yff'
|
286 | triple-quoted """ $""" r''' u''' b'''
|
287 | X tagged-str "<span id=$x>"html
|
288 | [Substitutions] expr-sub echo $[42 + a[i]]
|
289 | expr-splice echo @[split(x)]
|
290 | var-splice @myarray @ARGV
|
291 | command-sub @(split command)
|
292 | [Formatting] X ysh-printf ${x %.3f}
|
293 | X ysh-format ${x|html}
|
294 | ```
|
295 |
|
296 | <h2 id="mini-lang">
|
297 | Other Mini Languages <a class="group-link" href="chap-mini-lang.html">mini-lang</a>
|
298 | </h2>
|
299 |
|
300 | <!-- linkify_stop_col is 33 -->
|
301 |
|
302 | ```chapter-links-mini-lang_33
|
303 | [Patterns] glob-pat *.py
|
304 | [Other Sublang] braces {alice,bob}@example.com
|
305 | ```
|
306 |
|
307 | <h2 id="option">
|
308 | Global Shell Options <a class="group-link" href="chap-option.html">option</a>
|
309 | </h2>
|
310 |
|
311 | ```chapter-links-option
|
312 | [Groups] strict:all ysh:upgrade ysh:all
|
313 | [YSH Details] opts-redefine opts-internal
|
314 | ```
|
315 |
|
316 | <h2 id="special-var">
|
317 | Special Variables <a class="group-link" href="chap-special-var.html">special-var</a>
|
318 | </h2>
|
319 |
|
320 | ```chapter-links-special-var
|
321 | [YSH Vars] ARGV X ENV X _ESCAPE
|
322 | _this_dir
|
323 | [YSH Status] _error
|
324 | _pipeline_status _process_sub_status
|
325 | [YSH Tracing] SHX_indent SHX_punct SHX_pid_str
|
326 | [YSH read] _reply
|
327 | [History] YSH_HISTFILE
|
328 | [Oils VM] OILS_VERSION
|
329 | OILS_GC_THRESHOLD OILS_GC_ON_EXIT
|
330 | OILS_GC_STATS OILS_GC_STATS_FD
|
331 | ```
|
332 |
|
333 | <!-- ideas
|
334 | X [Wok] _filename _line _line_num
|
335 | X [Builtin Sub] _buffer
|
336 | -->
|
337 |
|
338 | <h2 id="plugin">
|
339 | Plugins and Hooks <a class="group-link" href="chap-plugin.html">plugin</a>
|
340 | </h2>
|
341 |
|
342 | ```chapter-links-plugin
|
343 | [YSH] renderPrompt()
|
344 | ```
|