OILS / doc / ref / toc-osh.md View on Github | oils.pub

243 lines, 210 significant
1---
2title: OSH Table of Contents
3all_docs_url: ..
4css_files: ../../web/base.css ../../web/manual.css ../../web/ref-index.css
5preserve_anchor_case: yes
6---
7
8<div class="doc-ref-header">
9
10[Oils Reference](index.html) &mdash;
11**OSH Table of Contents** | [YSH](toc-ysh.html) | [Data Notation](toc-data.html)
12
13</div>
14
15[OSH]($xref) is a POSIX- and [bash]($xref)-compatible shell.
16
17<!--
18<div class="custom-toc">
19
20[OSH Types](#type-method) <br/>
21[Builtin Commands](#builtin-cmd) <br/>
22[Front End](#front-end) <br/>
23[Command Language](#cmd-lang) <br/>
24[OSH Assignment](#osh-assign) <br/>
25[Word Language](#word-lang) <br/>
26[Mini Languages](#mini-lang) <br/>
27[Shell Options](#option) <br/>
28[Special Variables](#special-var) <br/>
29[Plugins and Hooks](#plugin) <br/>
30
31[type-method](#type-method) &nbsp;
32[builtin-cmd](#builtin-cmd) &nbsp;
33[front-end](#front-end) &nbsp;
34[cmd-lang](#cmd-lang) &nbsp;
35[osh-assign](#osh-assign) &nbsp;
36[word-lang](#word-lang) &nbsp;
37[mini-lang](#mini-lang) &nbsp;
38[option](#option) &nbsp;
39[special-var](#special-var) &nbsp;
40[plugin](#plugin)
41
42</div>
43-->
44
45<h2 id="type-method">
46 OSH Types <a class="group-link" href="chap-type-method.html">type-method</a>
47</h2>
48
49```chapter-links-type-method
50 [OSH] BashArray BashAssoc
51```
52
53<h2 id="builtin-cmd">
54 Builtin Commands <a class="group-link" href="chap-builtin-cmd.html">builtin-cmd</a>
55</h2>
56
57```chapter-links-builtin-cmd
58 [I/O] read echo printf
59 readarray mapfile
60 [Run Code] source . cmd/eval trap
61 [Set Options] set shopt
62 [Working Dir] cd chdir pwd
63 pushd popd dirs
64 [Completion] complete compgen compopt compadjust compexport
65 [Shell Process] exec X logout
66 umask ulimit times
67 [Child Process] jobs wait
68 fg X bg X kill X disown
69 [External] test [ getopts
70 [Conditional] cmd/true cmd/false colon :
71 [Introspection] help hash cmd/type X caller
72 [Word Lookup] command builtin
73 [Interactive] alias unalias history fc X bind
74X [Unsupported] enable
75```
76
77<h2 id="stdlib">
78 Standard Library <a class="group-link" href="chap-stdlib.html">stdlib</a>
79</h2>
80
81```chapter-links-stdlib
82 [two] log die
83 [no-quotes] nq-assert nq-run
84 nq-capture nq-capture-2
85 nq-redir nq-redir-2
86 [bash-strict]
87 [task-five]
88```
89
90<h2 id="front-end">
91 Front End <a class="group-link" href="chap-front-end.html">front-end</a>
92</h2>
93
94```chapter-links-front-end
95 [Usage] oils-usage osh-usage shell-flags
96 config startup line-editing
97 exit-codes
98 [Lexing] comment # line-continuation \ ascii-whitespace [ \t\r\n]
99```
100
101<h2 id="cmd-lang">
102 Command Language <a class="group-link" href="chap-cmd-lang.html">cmd-lang</a>
103</h2>
104
105```chapter-links-cmd-lang
106 [Commands] simple-command command-lookup-order
107 prefix-binding semicolon ;
108 [Conditional] case if dbracket [[
109 bang ! and && or ||
110 [Iteration] while until for for-expr-sh ((
111 [Control Flow] break continue return exit
112 [Grouping] sh-func sh-block { subshell (
113 [Concurrency] pipe | X pipe-amp |& ampersand &
114 [Redirects] redir-file > >> >| < <> not impl: &>
115 redir-desc >& <&
116 here-doc << <<-
117 here-str <<<
118 [Other Command] dparen (( time X coproc X select
119```
120
121<h2 id="osh-assign">
122 Assignments and Expressions <a class="group-link" href="chap-osh-assign.html">osh-assign</a>
123</h2>
124
125```chapter-links-osh-assign
126 [Literals] sh-init-list a=(v1 [i]=v2 [k]+=v3) a+=(v1 [i]=v2 [k]+=v3)
127 sh-array array[123]=v "${array[@]}"
128 sh-assoc assoc['k']=v "${assoc[@]}" "${!assoc[@]}"
129 [Operators] sh-assign str='xyz'
130 sh-append str+='abc'
131 [Builtins] local readonly export unset shift
132 declare typeset X let
133```
134
135<h2 id="word-lang">
136 Word Language <a class="group-link" href="chap-word-lang.html">word-lang</a>
137</h2>
138
139<!-- linkify_stop_col is 33 -->
140
141```chapter-links-word-lang_33
142 [Glob] osh-glob *.py
143 [Joining] osh-word-join 'single'\'$myvar"double $x"
144 [Quotes] osh-string 'abc' $'line\n' "$var"
145 [Substitutions] command-sub $(date) `date`
146 var-sub ${var} $0 $9
147 arith-sub $((1 + 2))
148 tilde-sub ~/src
149 proc-sub diff <(sort L.txt) <(sort R.txt)
150 [Var Ops] op-bracket ${a[i+1]}, ${a[*]}
151 op-indirect ${!x}
152 op-test ${x:-default}
153 op-strip ${x%%suffix} etc.
154 op-patsub ${x//y/z}
155 op-slice ${a[@]:0:1}
156 op-format ${x@P} ${x@Q} etc.
157```
158
159<h2 id="mini-lang">
160 Other Mini Languages <a class="group-link" href="chap-mini-lang.html">mini-lang</a>
161</h2>
162
163<!-- linkify_stop_col is 33 -->
164
165```chapter-links-mini-lang_33
166 [Arithmetic] arith-context Where legacy arithmetic is allowed
167 sh-numbers 0xFF 0755 etc.
168 sh-arith 1 + 2*3 a *= 2
169 sh-logical !a && b
170 sh-bitwise ~a ^ b
171 [Boolean] bool-expr [[ ! $x && $y || $z ]]
172 test ! $x -a $y -o $z
173 bool-infix $a -nt $b $x == $y
174 bool-path -d /etc
175 bool-str -n foo -z ''
176 bool-other -o errexit -v name[index]
177 [Patterns] glob-pat *.py
178 extglob ,(*.py|*.sh)
179 regex [[ foo =~ [a-z]+ ]]
180 [Other Sublang] braces {alice,bob}@example.com
181 histsub !$ !! !n
182 char-escapes \t \c \x00 \u03bc
183```
184
185<h2 id="option">
186 Global Shell Options <a class="group-link" href="chap-option.html">option</a>
187</h2>
188
189<!-- linkify_stop_col is 20 since we only want section links -->
190
191```chapter-links-option_22
192 [Errors] nounset -u errexit -e inherit_errexit pipefail
193 [Globbing] noglob -f nullglob failglob X dotglob
194 dashglob (true)
195 [Other Option] noclobber -C
196 [Debugging] errtrace -E extdebug X verbose xtrace -x
197 [Interactive] emacs vi
198 [Compat] eval_unsafe_arith ignore_flags_not_impl
199 ignore_shopt_not_impl
200 [Optimize] rewrite_extern
201```
202
203<h2 id="special-var">
204 Special Variables <a class="group-link" href="chap-special-var.html">special-var</a>
205</h2>
206
207```chapter-links-special-var
208 [Oils VM] OILS_VERSION LIB_OSH
209 [libc locale] osh-locale
210 [Interactive] OILS_COMP_UI HISTFILE
211 [POSIX Special] $@ $* $# $? $- $$ $! $0 $9
212 [Shell Vars] IFS X LANG X GLOBIGNORE
213 [Shell Options] SHELLOPTS X BASHOPTS
214 [Other Env] HOME PATH
215 [Other Special] BASH_REMATCH @PIPESTATUS
216 [Platform] HOSTNAME OSTYPE
217 [Call Stack] @BASH_SOURCE @FUNCNAME @BASH_LINENO
218 X @BASH_ARGV X @BASH_ARGC
219 [Tracing] LINENO
220 [Process State] UID EUID PPID X BASHPID
221X [Process Stack] BASH_SUBSHELL SHLVL
222X [Shell State] BASH_CMDS @DIRSTACK
223 [Completion] @COMP_WORDS COMP_CWORD COMP_LINE COMP_POINT
224 COMP_WORDBREAKS @COMPREPLY X COMP_KEY
225 X COMP_TYPE COMP_ARGV
226 [cd] PWD OLDPWD X CDPATH
227 [getopts] OPTIND OPTARG X OPTERR
228 [read] REPLY
229 [Functions] X RANDOM SECONDS
230```
231
232<h2 id="plugin">
233 Plugins and Hooks <a class="group-link" href="chap-plugin.html">plugin</a>
234</h2>
235
236```chapter-links-plugin
237 [Signals] SIGTERM SIGINT SIGQUIT
238 SIGTTIN SIGTTOU SIGWINCH
239 [Traps] DEBUG ERR EXIT X RETURN
240 [Words] PS1 X PS2 X PS3 PS4
241 [Completion] complete
242 [Other Plugin] PROMPT_COMMAND X command_not_found
243```