1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
3 "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd"
5 <!ENTITY % ISOnum PUBLIC
6 "ISO 8879:1986//ENTITIES Numeric and Special Graphic//EN//XML"
8 <!ENTITY % ISOpub PUBLIC
9 "ISO 8879:1986//ENTITIES Publishing//EN//XML"
17 <refentrytitle>POSH</refentrytitle>
18 <manvolnum>1</manvolnum>
19 <refmiscinfo class='date'>January 24, 2011</refmiscinfo>
20 <refmiscinfo class='manual'>User commands</refmiscinfo>
22 <refnamediv id='name'>
23 <refname>posh</refname>
24 <refpurpose>Policy-compliant Ordinary SHell</refpurpose>
26 <refsynopsisdiv id='synopsis'>
28 <command>posh</command>
29 <arg choice='opt'>+-aCefilnuvx </arg>
30 <arg choice='opt'>+-o <replaceable>option</replaceable></arg>
31 <arg choice='opt'><arg choice='opt'><arg choice='plain'>-c <replaceable>command-string</replaceable></arg><group choice='plain'><arg choice='opt'><replaceable>command-name</replaceable></arg><arg choice='plain'>-s </arg><arg choice='plain'><replaceable>file</replaceable></arg></group></arg><arg choice='opt' rep='repeat'><replaceable>argument</replaceable></arg></arg>
35 <refsect1 id='description'><title>DESCRIPTION</title>
37 <emphasis remap='B'>posh</emphasis> is a reimplementation of the Bourne shell, a command
38 interpreter for both interactive and script use.
41 <refsect2 id='shell_startup'><title>Shell Startup</title>
43 The following options can be specified only on the command line:
45 <variablelist remap='.IP'>
47 <term><option>-c</option> <replaceable>command-string</replaceable></term>
50 the shell executes the command(s) contained in <emphasis remap='I'>command-string</emphasis>
55 <term><option>-i</option></term>
58 interactive mode — see below
63 <term><option>-l</option></term>
66 login shell — see below
67 interactive mode — see below
72 <term><option>-s</option></term>
75 the shell reads commands from standard input; all non-option arguments
76 are positional parameters
80 </variablelist> <!-- .IP (gather_variableliist) -->
83 In addition to the above, the options described in the
84 <command>set</command> builtin
85 command can also be used on the command line.
89 If neither the <option>-c</option> nor the <option>-s</option> options are specified, the
90 first non-option argument specifies the name of a file the shell reads
91 commands from; if there are no non-option arguments, the shell reads
92 commands from standard input.
93 The name of the shell (<emphasis remap='I'>i.e.</emphasis>, the contents of the <emphasis remap='B'>$0</emphasis>) parameter
94 is determined as follows: if the <option>-c</option> option is used and there is
95 a non-option argument, it is used as the name; if commands are being
96 read from a file, the file is used as the name; otherwise the name
97 the shell was called with (<emphasis remap='I'>i.e.</emphasis>, argv[0]) is used.
100 <para>A shell is <emphasis remap='B'>interactive</emphasis> if the <option>-i</option> option is used or
101 if both standard input and standard error are attached to a tty.
102 An interactive shell has job control enabled (if available),
103 ignores the INT, QUIT and TERM signals, and prints prompts before
104 reading input (see <envar>PS1</envar> and <envar>PS2</envar> parameters).</para>
106 <para>A shell is <emphasis remap='B'>privileged</emphasis> if the <option>-p</option> option is used or if
107 the real user-id or group-id does not match the effective user-id
108 or group-id (see <citerefentry><refentrytitle>getuid</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
109 <citerefentry><refentrytitle>getgid</refentrytitle><manvolnum>2</manvolnum></citerefentry>).
110 A privileged shell does not process $HOME/.profile.
111 Instead the file /etc/suid_profile is processed.
112 Clearing the privileged option causes the shell to set its effective
113 user-id (group-id) to its real user-id (group-id).</para>
115 <para>If the basename of the name the shell is called with (<emphasis remap='I'>i.e.</emphasis>, argv[0])
116 starts with <emphasis remap='B'>-</emphasis> or if the <option>-l</option> option is used, the shell is assumed
117 to be a login shell and the shell reads and executes the contents of
118 <filename>/etc/profile</filename> and
119 <filename>$HOME/.profile</filename> if they exist and are readable.</para>
121 <para>The exit status of the shell is 127 if the command file specified
122 on the command line could not be opened, or non-zero if a fatal syntax
123 error occurred during the execution of a script.
124 In the absence of fatal errors, the exit status is that of the last
125 command executed, or zero, if no command is executed.</para>
128 <refsect2 id='command_syntax'><title>Command Syntax</title>
129 <!-- {{{ words and tokens -->
130 <para>The shell begins parsing its input by breaking it into words.
131 Words, which are sequences of characters, are delimited by unquoted
132 white-space characters (space, tab and newline) or meta-characters
133 (<token><</token>, <token>></token>,
134 <token>|</token>, <token>;</token>, <token>&</token>,
135 <token>(</token> and <token>)</token>).
136 Aside from delimiting words, spaces and tabs are ignored, while
137 newlines usually delimit commands.
138 The meta-characters are used in building the following tokens:
139 <token><</token>, <token><&</token>,
140 <token><<</token>, <token>></token>,
141 <token>>&</token>, <token>>></token>, etc. are
142 used to specify redirections (see Input/Output Redirection below);
143 <token>|</token> is used to create pipelines;
144 <token>;</token> is used to separate commands;
145 <token>&</token> is used to create asynchronous pipelines;
146 <token>&&</token> and <token>||</token> are used to specify conditional execution;
147 <token>;;</token> is used in <token>case</token> statements;
149 <token>(</token> ... <token>)</token> are used to create subshells.</para>
151 <para>White-space and meta-characters can be quoted individually using
152 backslash (<emphasis remap='B'>\</emphasis>), or in groups using double (<emphasis remap='B'>"</emphasis>) or single (<emphasis remap='B'>'</emphasis>)
154 Note that the following characters are also treated specially by the shell and
155 must be quoted if they are to represent themselves:
156 <emphasis remap='B'>\</emphasis>, <emphasis remap='B'>"</emphasis>, <emphasis remap='B'>'</emphasis>, <emphasis remap='B'>#</emphasis>, <emphasis remap='B'>$</emphasis>, <emphasis remap='B'>`</emphasis>, <emphasis remap='B'>~</emphasis>, <emphasis remap='B'>{</emphasis>,
157 <emphasis remap='B'>}</emphasis>, <emphasis remap='B'>*</emphasis>, <emphasis remap='B'>?</emphasis> and <emphasis remap='B'>[</emphasis>.
158 The first three of these are the above mentioned quoting characters
160 <emphasis remap='B'>#</emphasis>, if used at the beginning of a word, introduces a comment — everything
161 after the <emphasis remap='B'>#</emphasis> up to the nearest newline is ignored;
162 <emphasis remap='B'>$</emphasis> is used to introduce parameter, command and arithmetic substitutions
163 (see Substitution below);
164 <emphasis remap='B'>`</emphasis> introduces an old-style command substitution
165 (see Substitution below);
166 <emphasis remap='B'>~</emphasis> begins a directory expansion (see Tilde Expansion below);
167 <emphasis remap='B'>{</emphasis> and <emphasis remap='B'>}</emphasis> delimit <citerefentry><refentrytitle>csh</refentrytitle><manvolnum>1</manvolnum></citerefentry> style alternations
168 (see Brace Expansion below);
169 and, finally, <emphasis remap='B'>*</emphasis>, <emphasis remap='B'>?</emphasis> and <emphasis remap='B'>[</emphasis> are used in file name generation
170 (see File Name Patterns below).</para>
172 <!-- {{{ simple\-command -->
174 <para>As words and tokens are parsed, the shell builds commands, of which
175 there are two basic types: <emphasis remap='I'>simple-commands</emphasis>, typically programs
176 that are executed, and <emphasis remap='I'>compound-commands</emphasis>, such as <emphasis remap='B'>for</emphasis> and
177 <emphasis remap='B'>if</emphasis> statements, grouping constructs and function definitions.</para>
179 <para>A simple-command consists of some combination of parameter assignments (see
180 Parameters below), input/output redirections (see Input/Output Redirections
181 below), and command words; the only restriction is that parameter assignments
182 come before any command words.
183 The command words, if any, define the command that is to be executed and its
185 The command may be a shell built-in command, a function or an <emphasis remap='I'>external
186 command</emphasis>, <emphasis remap='I'>i.e.</emphasis>, a separate executable file that is located using the
187 <envar>PATH</envar> parameter (see Command Execution below).
188 Note that all command constructs have an <emphasis remap='I'>exit status</emphasis>: for external
189 commands, this is related to the status returned by <citerefentry><refentrytitle>wait</refentrytitle><manvolnum>2</manvolnum></citerefentry> (if the
190 command could not be found, the exit status is 127, if it could not be
191 executed, the exit status is 126);
192 the exit status of other command constructs (built-in commands, functions,
193 compound-commands, pipelines, lists, <emphasis remap='I'>etc.</emphasis>) are all well defined and are
194 described where the construct is described.
195 The exit status of a command consisting only of parameter assignments is that
196 of the last command substitution performed during the parameter assignment
197 or zero if there were no command substitutions.</para>
199 <!-- {{{ pipeline -->
201 <para>Commands can be chained together using the <emphasis remap='B'>|</emphasis> token to
202 form <emphasis remap='I'>pipelines</emphasis>, in which the standard output of each command but
203 the last is piped (see <citerefentry><refentrytitle>pipe</refentrytitle><manvolnum>2</manvolnum></citerefentry>) to the standard input of the following
205 The exit status of a pipeline is that of its last command.
206 A pipeline may be prefixed by the <emphasis remap='B'>!</emphasis> reserved word which
207 causes the exit status of the pipeline to be logically
208 complemented: if the original status was 0 the complemented status will
209 be 1, and if the original status was not 0, then the complemented
210 status will be 0.</para>
214 <para><emphasis remap='I'>Lists</emphasis> of commands can be created by separating pipelines by
215 any of the following tokens: <emphasis remap='B'>&&</emphasis>, <emphasis remap='B'>||</emphasis>, <emphasis remap='B'>&</emphasis>, <emphasis remap='B'>|&</emphasis> and <emphasis remap='B'>;</emphasis>.
216 The first two are for conditional execution: <emphasis remap='I'>cmd1</emphasis> <emphasis remap='B'>&&</emphasis> <emphasis remap='I'>cmd2</emphasis>
217 executes <emphasis remap='I'>cmd2</emphasis> only if the exit status of <emphasis remap='I'>cmd1</emphasis> is zero;
218 <emphasis remap='B'>||</emphasis> is the opposite — <emphasis remap='I'>cmd2</emphasis> is executed only if the exit status
219 of <emphasis remap='I'>cmd1</emphasis> is non-zero.
220 <emphasis remap='B'>&&</emphasis> and <emphasis remap='B'>||</emphasis> have equal precedence which is higher than that of
221 <emphasis remap='B'>&</emphasis>, <emphasis remap='B'>|&</emphasis> and <emphasis remap='B'>;</emphasis>, which also have equal precedence.
222 The <emphasis remap='B'>&</emphasis> token causes the preceding command to be executed asynchronously,
223 that is, the shell starts the command, but does not wait for it to complete
224 (the shell does keep track of the status of asynchronous commands — see
226 When an asynchronous command is started when job control is disabled
227 (<emphasis remap='I'>i.e.</emphasis>, in most scripts), the command is started with signals INT
228 and QUIT ignored and with input redirected from /dev/null
229 (however, redirections specified in the asynchronous command have precedence).
230 Note that a command must follow the <emphasis remap='B'>&&</emphasis> and <emphasis remap='B'>||</emphasis> operators, while
231 a command need not follow <emphasis remap='B'>&</emphasis>, <emphasis remap='B'>|&</emphasis> and <emphasis remap='B'>;</emphasis>.
232 The exit status of a list is that of the last command executed, with the
233 exception of asynchronous lists, for which the exit status is 0.</para>
235 <!-- {{{ compound\-commands -->
237 <para>Compound commands are created using the following reserved words — these
238 words are only recognized if they are unquoted and if they are used as
239 the first word of a command (<emphasis remap='I'>i.e.</emphasis>, they can't be preceded by parameter
240 assignments or redirections):</para>
243 <informaltable pgwide='0' frame='none'>
244 <tgroup cols='5' align='center'>
245 <colspec colname='c1'/>
246 <colspec colname='c2'/>
247 <colspec colname='c3'/>
248 <colspec colname='c4'/>
249 <colspec colname='c5'/>
252 <entry align='center'>case</entry>
253 <entry align='right'>else</entry>
258 <entry align='left'>do</entry>
259 <entry align='left'>esac</entry>
260 <entry align='left'>if</entry>
261 <entry align='left'>time</entry>
262 <entry align='left'>[[</entry>
265 <entry align='left'>done</entry>
266 <entry align='left'>fi</entry>
267 <entry align='left'>in</entry>
268 <entry align='left'>until</entry>
269 <entry align='left'>{</entry>
272 <entry align='left'>elif</entry>
273 <entry align='left'>for</entry>
274 <entry align='left'>select</entry>
275 <entry align='left'>while</entry>
276 <entry align='left'>}</entry>
283 <para><emphasis remap='B'>Note:</emphasis> Some shells (but not this one) execute control structure commands
284 in a subshell when one or more of their file descriptors are redirected, so
285 any environment changes inside them may fail.
286 To be portable, the <emphasis remap='B'>exec</emphasis> statement should be used instead to redirect
287 file descriptors before the control structure.</para>
289 <para>In the following compound command descriptions, command lists (denoted as
290 <emphasis remap='I'>list</emphasis>) that are followed by reserved words must end with a
291 semi-colon, a newline or a (syntactically correct) reserved word.
294 <emphasis remap='B'>{ echo foo; echo bar; }</emphasis>
296 <emphasis remap='B'>{ echo foo; echo bar<newline>}</emphasis>
298 <emphasis remap='B'>{ { echo foo; echo bar; } }</emphasis>
302 <emphasis remap='B'>{ echo foo; echo bar }</emphasis>
305 <!-- {{{ ( list ) -->
306 <variablelist remap='.IP'>
308 <term><emphasis remap='B'>(</emphasis> <emphasis remap='I'>list</emphasis> <emphasis remap='B'>)</emphasis></term>
310 <para>Execute <emphasis remap='I'>list</emphasis> in a subshell. There is no implicit way to pass
311 environment changes from a subshell back to its parent.</para>
313 <!-- {{{ { list } -->
317 <term><emphasis remap='B'>{</emphasis> <emphasis remap='I'>list</emphasis> <emphasis remap='B'>}</emphasis></term>
319 <para>Compound construct; <emphasis remap='I'>list</emphasis> is executed, but not in a subshell.
320 Note that <emphasis remap='B'>{</emphasis> and <emphasis remap='B'>}</emphasis> are reserved words, not meta-characters.</para>
322 <!-- {{{ case word in [ [ ( ] pattern [ | pattern ] ... ) list ;; ] ... esac -->
326 <term><emphasis remap='B'>case</emphasis> <emphasis remap='I'>word</emphasis> <emphasis remap='B'>in</emphasis> [ [<emphasis remap='B'>(</emphasis>] <emphasis remap='I'>pattern</emphasis> [<emphasis remap='B'>|</emphasis> <emphasis remap='I'>pattern</emphasis>] ... <emphasis remap='B'>)</emphasis> <emphasis remap='I'>list</emphasis> <emphasis remap='B'>;;</emphasis> ] ... <emphasis remap='B'>esac</emphasis></term>
328 <para>The <emphasis remap='B'>case</emphasis> statement attempts to match <emphasis remap='I'>word</emphasis> against the specified
329 <emphasis remap='I'>pattern</emphasis>s; the <emphasis remap='I'>list</emphasis> associated with the first successfully matched
330 pattern is executed. Patterns used in <emphasis remap='B'>case</emphasis> statements are the same as
331 those used for file name patterns except that the restrictions regarding
332 <emphasis remap='B'>.</emphasis> and <emphasis remap='B'>/</emphasis> are dropped. Note that any unquoted space before and
333 after a pattern is stripped; any space with a pattern must be quoted. Both the
334 word and the patterns are subject to parameter, command, and arithmetic
335 substitution as well as tilde substitution.
336 For historical reasons, open and close braces may be used instead
337 of <emphasis remap='B'>in</emphasis> and <emphasis remap='B'>esac</emphasis> (<emphasis remap='I'>e.g.</emphasis>, <emphasis remap='B'>case $foo { *) echo bar; }</emphasis>).
338 The exit status of a <emphasis remap='B'>case</emphasis> statement is that of the executed <emphasis remap='I'>list</emphasis>;
339 if no <emphasis remap='I'>list</emphasis> is executed, the exit status is zero.</para>
341 <!-- {{{ for name [ in word ... term ] do list done -->
345 <term><emphasis remap='B'>for</emphasis> <emphasis remap='I'>name</emphasis> [ <emphasis remap='B'>in</emphasis> <emphasis remap='I'>word</emphasis> ... <emphasis remap='I'>term</emphasis> ] <emphasis remap='B'>do</emphasis> <emphasis remap='I'>list</emphasis> <emphasis remap='B'>done</emphasis></term>
347 <para>where <emphasis remap='I'>term</emphasis> is either a newline or a <emphasis remap='B'>;</emphasis>.
348 For each <emphasis remap='I'>word</emphasis> in the specified word list, the parameter <emphasis remap='I'>name</emphasis> is
349 set to the word and <emphasis remap='I'>list</emphasis> is executed. If <emphasis remap='B'>in</emphasis> is not used to
350 specify a word list, the positional parameters (<emphasis remap='B'>"$1"</emphasis>, <emphasis remap='B'>"$2"</emphasis>,
351 <emphasis remap='I'>etc.</emphasis>) are used instead.
352 For historical reasons, open and close braces may be used instead
353 of <emphasis remap='B'>do</emphasis> and <emphasis remap='B'>done</emphasis> (<emphasis remap='I'>e.g.</emphasis>, <emphasis remap='B'>for i; { echo $i; }</emphasis>).
354 The exit status of a <emphasis remap='B'>for</emphasis> statement is the last exit status
355 of <emphasis remap='I'>list</emphasis>; if <emphasis remap='I'>list</emphasis> is never executed, the exit status is zero.</para>
357 <!-- {{{ if list then list [ elif list then list ] ... [ else list ] fi -->
361 <term><emphasis remap='B'>if</emphasis> <emphasis remap='I'>list</emphasis> <emphasis remap='B'>then</emphasis> <emphasis remap='I'>list</emphasis> [<emphasis remap='B'>elif</emphasis> <emphasis remap='I'>list</emphasis> <emphasis remap='B'>then</emphasis> <emphasis remap='I'>list</emphasis>] ... [<emphasis remap='B'>else</emphasis> <emphasis remap='I'>list</emphasis>] <emphasis remap='B'>fi</emphasis></term>
363 <para>If the exit status of the first <emphasis remap='I'>list</emphasis> is zero, the second <emphasis remap='I'>list</emphasis>
364 is executed; otherwise the <emphasis remap='I'>list</emphasis> following the <emphasis remap='B'>elif</emphasis>, if any, is
365 executed with similar consequences. If all the lists following the <emphasis remap='B'>if</emphasis>
366 and <emphasis remap='B'>elif</emphasis>s fail (<emphasis remap='I'>i.e.</emphasis>, exit with non-zero status), the <emphasis remap='I'>list</emphasis>
367 following the <emphasis remap='B'>else</emphasis> is executed.
368 The exit status of an <emphasis remap='B'>if</emphasis> statement is that
369 of non-conditional <emphasis remap='I'>list</emphasis> that is executed; if no non-conditional
370 <emphasis remap='I'>list</emphasis> is executed, the exit status is zero.</para>
372 <!-- {{{ select name [ in word ... ] do list done -->
374 <!-- {{{ until list do list done -->
378 <term><emphasis remap='B'>until</emphasis> <emphasis remap='I'>list</emphasis> <emphasis remap='B'>do</emphasis> <emphasis remap='I'>list</emphasis> <emphasis remap='B'>done</emphasis></term>
380 <para>This works like <emphasis remap='B'>while</emphasis>, except that the body is executed only while the
381 exit status of the first <emphasis remap='I'>list</emphasis> is non-zero.</para>
383 <!-- {{{ while list do list done -->
387 <term><emphasis remap='B'>while</emphasis> <emphasis remap='I'>list</emphasis> <emphasis remap='B'>do</emphasis> <emphasis remap='I'>list</emphasis> <emphasis remap='B'>done</emphasis></term>
389 <para>A <emphasis remap='B'>while</emphasis> is a prechecked loop. Its body is executed as often
390 as the exit status of the first <emphasis remap='I'>list</emphasis> is zero.
391 The exit status of a <emphasis remap='B'>while</emphasis> statement is the last exit status
392 of the <emphasis remap='I'>list</emphasis> in the body of the loop; if the body is not executed,
393 the exit status is zero.</para>
397 <!-- {{{ name () command -->
399 <term><emphasis remap='I'>name</emphasis> <emphasis remap='B'>()</emphasis> <emphasis remap='I'>command</emphasis></term>
401 <para>Defines the function <emphasis remap='I'>name</emphasis>.
403 Note that redirections specified after a function definition are
404 performed whenever the function is executed, not when the function
405 definition is executed.</para>
406 <!-- {{{ time [\-p] [ pipeline ] -->
410 <term><emphasis remap='B'>time</emphasis> [ <option>-p</option> ] [ <emphasis remap='I'>pipeline</emphasis> ]</term>
412 <para>The <emphasis remap='B'>time</emphasis> reserved word is described in the Command Execution section.</para>
414 <!-- {{{ (( expression )) -->
416 <!-- {{{ [[ expression ]] -->
423 </variablelist> <!-- .IP (gather_variableliist) -->
426 <refsect2 id='quoting'><title>Quoting</title>
427 <para>Quoting is used to prevent the shell from treating characters or words
429 There are three methods of quoting: First, <emphasis remap='B'>\</emphasis> quotes
430 the following character, unless it is at the end of a line, in which
431 case both the <emphasis remap='B'>\</emphasis> and the newline are stripped.
432 Second, a single quote (<emphasis remap='B'>'</emphasis>) quotes everything up to the next single
433 quote (this may span lines).
434 Third, a double quote (<emphasis remap='B'>"</emphasis>) quotes all characters,
435 except <emphasis remap='B'>$</emphasis>, <emphasis remap='B'>`</emphasis> and <emphasis remap='B'>\</emphasis>, up to the next unquoted double quote.
436 <emphasis remap='B'>$</emphasis> and <emphasis remap='B'>`</emphasis> inside double quotes have their usual meaning (<emphasis remap='I'>i.e.</emphasis>,
437 parameter, command or arithmetic substitution) except no field splitting
438 is carried out on the results of double-quoted substitutions.
439 If a <emphasis remap='B'>\</emphasis> inside a double-quoted string is followed by <emphasis remap='B'>\</emphasis>, <emphasis remap='B'>$</emphasis>,
440 <emphasis remap='B'>`</emphasis> or <emphasis remap='B'>"</emphasis>, it is replaced by the second character; if it is
441 followed by a newline, both the <emphasis remap='B'>\</emphasis> and the newline are stripped;
442 otherwise, both the <emphasis remap='B'>\</emphasis> and the character following are unchanged.</para>
444 <para>Note: see POSIX Mode below for a special rule regarding sequences
445 of the form <emphasis remap='B'>"</emphasis>...<emphasis remap='B'>`</emphasis>...<emphasis remap='B'>\"</emphasis>...<emphasis remap='B'>`</emphasis>..<emphasis remap='B'>"</emphasis>.</para>
447 <!-- {{{ Substitution -->
450 <refsect2 id='substitution'><title>Substitution</title>
451 <para>The first step the shell takes in executing a simple-command is to
452 perform substitutions on the words of the command.
453 There are three kinds of substitution: parameter, command and arithmetic.
454 Parameter substitutions, which are described in detail in the next section,
455 take the form <emphasis remap='B'>$name</emphasis> or <emphasis remap='B'>${</emphasis>...<emphasis remap='B'>}</emphasis>; command substitutions take
456 the form <emphasis remap='B'>$(</emphasis><emphasis remap='I'>command</emphasis><emphasis remap='B'>)</emphasis> or <emphasis remap='B'>`</emphasis><emphasis remap='I'>command</emphasis><emphasis remap='B'>`</emphasis>;
457 and arithmetic substitutions take the form <emphasis remap='B'>$((</emphasis><emphasis remap='I'>expression</emphasis><emphasis remap='B'>))</emphasis>.</para>
459 <para>If a substitution appears outside of double quotes, the results of the
460 substitution are generally subject to word or field splitting according to
461 the current value of the <emphasis remap='B'>IFS</emphasis> parameter.
462 The <emphasis remap='B'>IFS</emphasis> parameter specifies a list of characters which
463 are used to break a string up into several words;
464 any characters from the set space, tab and newline that appear in the
465 IFS characters are called <emphasis remap='I'>IFS white space</emphasis>.
466 Sequences of one or more IFS white space characters, in combination with
467 zero or one non-IFS white space characters delimit a field.
468 As a special case, leading and trailing IFS white space is stripped (<emphasis remap='I'>i.e.</emphasis>,
469 no leading or trailing empty field is created by it); leading or trailing
470 non-IFS white space does create an empty field.
471 Example: if <emphasis remap='B'>IFS</emphasis> is set to `<space>:', the sequence of characters
472 `<space>A<space>:<space><space>B::D' contains four fields: `A', `B', `' and `D'.
473 Note that if the <emphasis remap='B'>IFS</emphasis> parameter is set to the null string, no
474 field splitting is done; if the parameter is unset, the default value
475 of space, tab and newline is used.</para>
477 <para>The results of substitution are, unless otherwise specified, also subject
478 to brace expansion and file name expansion (see the relevant sections
481 <para>A command substitution is replaced by the output generated by the specified
482 command, which is run in a subshell.
483 For <emphasis remap='B'>$(</emphasis><emphasis remap='I'>command</emphasis><emphasis remap='B'>)</emphasis> substitutions, normal quoting rules
484 are used when <emphasis remap='I'>command</emphasis> is parsed, however, for the
485 <emphasis remap='B'>`</emphasis><emphasis remap='I'>command</emphasis><emphasis remap='B'>`</emphasis> form, a <emphasis remap='B'>\</emphasis> followed by any of
486 <emphasis remap='B'>$</emphasis>, <emphasis remap='B'>`</emphasis> or <emphasis remap='B'>\</emphasis> is stripped (a <emphasis remap='B'>\</emphasis> followed by any other
487 character is unchanged).
488 As a special case in command substitutions, a command of the form
489 <emphasis remap='B'><</emphasis> <emphasis remap='I'>file</emphasis> is interpreted to mean substitute the contents
490 of <emphasis remap='I'>file</emphasis> ($(< foo) has the same effect as $(cat foo), but it
491 is carried out more efficiently because no process is started).
493 <!-- todo: fix this( $(..) parenthesis counting). -->
494 NOTE: <emphasis remap='B'>$(</emphasis><emphasis remap='I'>command</emphasis><emphasis remap='B'>)</emphasis> expressions are currently parsed by
495 finding the matching parenthesis, regardless of quoting. This will hopefully
496 be fixed soon.</para>
498 <para>Arithmetic substitutions are replaced by the value of the specified
500 For example, the command <emphasis remap='B'>echo $((2+3*4))</emphasis> prints 14.
501 See Arithmetic Expressions for a description of an <emphasis remap='I'>expression</emphasis>.</para>
503 <!-- {{{ Parameters -->
506 <refsect2 id='parameters'><title>Parameters</title>
507 <para>Parameters are shell variables; they can be assigned values and
508 their values can be accessed using a parameter substitution.
509 A parameter name is either one of the special single punctuation or digit
510 character parameters described below, or a letter followed by zero or more
511 letters or digits (`_' counts as a letter).
512 The later form can be treated as arrays by appending an array
513 index of the form: <emphasis remap='B'>[</emphasis><emphasis remap='I'>expr</emphasis><emphasis remap='B'>]</emphasis> where <emphasis remap='I'>expr</emphasis> is
514 an arithmetic expression.
515 Array indices are currently limited to the range 0 through 1023, inclusive.
516 Parameter substitutions take the form <emphasis remap='B'>$</emphasis><emphasis remap='I'>name</emphasis>,
517 <emphasis remap='B'>${</emphasis><emphasis remap='I'>name</emphasis><emphasis remap='B'>}</emphasis> or
518 <emphasis remap='B'>${</emphasis><emphasis remap='I'>name</emphasis><emphasis remap='B'>[</emphasis><emphasis remap='I'>expr</emphasis><emphasis remap='B'>]}</emphasis>, where <emphasis remap='I'>name</emphasis> is a
520 If substitution is performed on a parameter (or an array parameter element)
521 that is not set, a null
522 string is substituted unless the <emphasis remap='B'>nounset</emphasis> option (<userinput>set -o nounset</userinput>
523 or <userinput>set -u</userinput>) is set, in which case an error occurs.</para>
525 <!-- {{{ parameter assignment -->
526 <para>Parameters can be assigned values in a number of ways.
527 First, the shell implicitly sets some parameters like <emphasis remap='B'>#</emphasis>, <envar>PWD</envar>,
528 etc.; this is the only way the special single character parameters are
530 Second, parameters are imported from the shell's environment at startup.
531 Third, parameters can be assigned values on the command line, for example,
532 `<emphasis remap='B'>FOO=bar</emphasis>' sets the parameter FOO to bar; multiple parameter
533 assignments can be given on a single command line and they can
534 be followed by a simple-command, in which case the assignments are
535 in effect only for the duration of the command (such assignments are
536 also exported, see below for implications of this).
537 Note that both the parameter name and the <emphasis remap='B'>=</emphasis> must be unquoted for
538 the shell to recognize a parameter assignment.
539 The fourth way of setting a parameter is with the
540 <emphasis remap='B'>export</emphasis> and
541 <emphasis remap='B'>readonly</emphasis>
542 commands; see their descriptions in the Command Execution
544 Fifth, <emphasis remap='B'>for</emphasis> and <emphasis remap='B'>select</emphasis> loops set parameters as well as
545 the <emphasis remap='B'>getopts</emphasis>, <emphasis remap='B'>read</emphasis> and <userinput>set -A</userinput> commands.
546 Lastly, parameters can be assigned values using assignment operators
547 inside arithmetic expressions (see Arithmetic Expressions below) or
548 using the <emphasis remap='B'>${</emphasis><emphasis remap='I'>name</emphasis><emphasis remap='B'>=</emphasis><emphasis remap='I'>value</emphasis><emphasis remap='B'>}</emphasis> form
549 of parameter substitution (see below).</para>
552 <!-- {{{ environment -->
553 <para>Parameters with the export attribute (set using the <emphasis remap='B'>export</emphasis>
554 command, or by parameter assignments followed by simple
555 commands) are put in the environment (see <citerefentry><refentrytitle>environ</refentrytitle><manvolnum>5</manvolnum></citerefentry>) of commands
556 run by the shell as <emphasis remap='I'>name</emphasis><emphasis remap='B'>=</emphasis><emphasis remap='I'>value</emphasis> pairs.
557 The order in which parameters appear in the environment of a command
559 When the shell starts up, it extracts parameters and their values from its
560 environment and automatically sets the export attribute for those parameters.</para>
562 <!-- {{{ ${name[:][\-+=?]word} -->
564 <para>Modifiers can be applied to the <emphasis remap='B'>${</emphasis><emphasis remap='I'>name</emphasis><emphasis remap='B'>}</emphasis> form of parameter
566 <variablelist remap='.IP'>
568 <term><emphasis remap='B'>${</emphasis><emphasis remap='I'>name</emphasis><emphasis remap='B'>:-</emphasis><emphasis remap='I'>word</emphasis><emphasis remap='B'>}</emphasis></term>
570 <para>if <emphasis remap='I'>name</emphasis> is set and not null, it is substituted, otherwise <emphasis remap='I'>word</emphasis> is
575 <term><emphasis remap='B'>${</emphasis><emphasis remap='I'>name</emphasis><emphasis remap='B'>:+</emphasis><emphasis remap='I'>word</emphasis><emphasis remap='B'>}</emphasis></term>
577 <para>if <emphasis remap='I'>name</emphasis> is set and not null, <emphasis remap='I'>word</emphasis> is substituted, otherwise nothing is substituted.</para>
581 <term><emphasis remap='B'>${</emphasis><emphasis remap='I'>name</emphasis><emphasis remap='B'>:=</emphasis><emphasis remap='I'>word</emphasis><emphasis remap='B'>}</emphasis></term>
583 <para>if <emphasis remap='I'>name</emphasis> is set and not null, it is substituted, otherwise it is
584 assigned <emphasis remap='I'>word</emphasis> and the resulting value of <emphasis remap='I'>name</emphasis> is substituted.</para>
588 <term><emphasis remap='B'>${</emphasis><emphasis remap='I'>name</emphasis><emphasis remap='B'>:?</emphasis><emphasis remap='I'>word</emphasis><emphasis remap='B'>}</emphasis></term>
590 <para>if <emphasis remap='I'>name</emphasis> is set and not null, it is substituted, otherwise <emphasis remap='I'>word</emphasis>
591 is printed on standard error (preceded by <emphasis remap='I'>name</emphasis>:) and an error occurs
592 (normally causing termination of a shell script, function or .-script).
593 If word is omitted the string `parameter null or not set' is used instead.</para>
596 </variablelist> <!-- .IP (gather_variableliist) -->
598 <para>In the above modifiers, the <emphasis remap='B'>:</emphasis> can be omitted, in which case the
599 conditions only depend on <emphasis remap='I'>name</emphasis> being set (as opposed to set and
601 If <emphasis remap='I'>word</emphasis> is needed, parameter, command, arithmetic and tilde substitution
602 are performed on it; if <emphasis remap='I'>word</emphasis> is not needed, it is not evaluated.</para>
605 <para>The following forms of parameter substitution can also be used:</para>
606 <!-- {{{ ${#name} -->
607 <variablelist remap='.IP'>
609 <term><emphasis remap='B'>${#</emphasis><emphasis remap='I'>name</emphasis><emphasis remap='B'>}</emphasis></term>
611 <para>The number of positional parameters if <emphasis remap='I'>name</emphasis> is <emphasis remap='B'>*</emphasis>, <emphasis remap='B'>@</emphasis> or
613 or the length of the string value of parameter <emphasis remap='I'>name</emphasis>.</para>
615 <!-- {{{ ${#name[*]}, ${#name[@]} -->
619 <term><emphasis remap='B'>${#</emphasis><emphasis remap='I'>name</emphasis><emphasis remap='B'>[*]}</emphasis>, <emphasis remap='B'>${#</emphasis><emphasis remap='I'>name</emphasis><emphasis remap='B'>[@]}</emphasis></term>
621 <para>The number of elements in the array <emphasis remap='I'>name</emphasis>.</para>
623 <!-- {{{ ${name#pattern}, ${name##pattern} -->
627 <term><emphasis remap='B'>${</emphasis><emphasis remap='I'>name</emphasis><emphasis remap='B'>#</emphasis><emphasis remap='I'>pattern</emphasis><emphasis remap='B'>}</emphasis>, <emphasis remap='B'>${</emphasis><emphasis remap='I'>name</emphasis><emphasis remap='B'>##</emphasis><emphasis remap='I'>pattern</emphasis><emphasis remap='B'>}</emphasis></term>
629 <para>If <emphasis remap='I'>pattern</emphasis> matches the beginning of the value of parameter <emphasis remap='I'>name</emphasis>,
630 the matched text is deleted from the result of substitution. A single
631 <emphasis remap='B'>#</emphasis> results in the shortest match, two <emphasis remap='B'>#</emphasis>'s results in the
632 longest match.</para>
634 <!-- {{{ ${name%pattern}, ${name%%pattern} -->
638 <term><emphasis remap='B'>${</emphasis><emphasis remap='I'>name</emphasis><emphasis remap='B'>%</emphasis><emphasis remap='I'>pattern</emphasis><emphasis remap='B'>}</emphasis>, <emphasis remap='B'>${</emphasis><emphasis remap='I'>name</emphasis><emphasis remap='B'>%%</emphasis><emphasis remap='I'>pattern</emphasis><emphasis remap='B'>}</emphasis></term>
640 <para>Like <emphasis remap='B'>${</emphasis>..<emphasis remap='B'>#</emphasis>..<emphasis remap='B'>}</emphasis> substitution, but it deletes from the end of the
643 <!-- {{{ special shell parameters -->
646 </variablelist> <!-- .IP (gather_variableliist) -->
648 <para>The following special parameters are implicitly set by the shell and cannot be
649 set directly using assignments:</para>
651 <variablelist remap='.IP'>
653 <term><emphasis remap='B'>!</emphasis></term>
655 <para>Process id of the last background process started. If no background
656 processes have been started, the parameter is not set.</para>
662 <term><emphasis remap='B'>#</emphasis></term>
664 <para>The number of positional parameters (<emphasis remap='I'>i.e.</emphasis>, <emphasis remap='B'>$1</emphasis>, <emphasis remap='B'>$2</emphasis>,
665 <emphasis remap='I'>etc.</emphasis>).</para>
671 <term><emphasis remap='B'>$</emphasis></term>
673 <para>The process ID of the shell, or the PID of the original shell if
674 it is a subshell.</para>
680 <term><emphasis remap='B'>-</emphasis></term>
682 <para>The concatenation of the current single letter options
683 (see <emphasis remap='B'>set</emphasis> command below for list of options).</para>
689 <term><emphasis remap='B'>?</emphasis></term>
691 <para>The exit status of the last non-asynchronous command executed.
692 If the last command was killed by a signal, <emphasis remap='B'>$?</emphasis> is set to 128 plus
693 the signal number.</para>
697 <term><varname>0</varname></term>
699 <para>The name the shell was invoked with (that is,
700 <varname>argv[0]</varname>), or the
701 <command><replaceable>command-name</replaceable></command>
702 if it was invoked with the <option>-c</option>
704 <command><replaceable>command-name</replaceable></command>
706 <filename><replaceable>file</replaceable></filename> argument, if it was
708 If the <option>posix</option> option is not set, <emphasis remap='B'>$0</emphasis> is the name of the current
709 function or script.</para>
713 <term><varname>1</varname> ... <varname>9</varname></term>
715 <para>The first nine positional parameters that were supplied to the shell,
716 function or <command>.</command>-script.
717 Further positional parameters may be accessed using
718 <varname>${<replaceable>number</replaceable>}</varname>.</para>
722 <term><varname>*</varname></term>
724 <para>All positional parameters (except parameter 0),
725 <emphasis remap='I'>i.e.</emphasis>, <emphasis remap='B'>$1 $2 $3</emphasis>....
726 If used outside of double quotes, parameters are separate words
727 (which are subjected to word splitting); if used within double quotes,
728 parameters are separated by the first character of the <emphasis remap='B'>IFS</emphasis> parameter
729 (or the empty string if <emphasis remap='B'>IFS</emphasis> is null).</para>
735 <term><varname>@</varname></term>
737 <para>Same as <emphasis remap='B'>$*</emphasis>, unless it is used inside double quotes, in which case
738 a separate word is generated for each positional parameter - if there
739 are no positional parameters, no word is generated ("$@" can be used
740 to access arguments, verbatim, without loosing null arguments or
741 splitting arguments with spaces).</para>
744 <!-- {{{ general shell parameters -->
747 </variablelist> <!-- .IP (gather_variableliist) -->
749 <para>The following parameters are set and/or used by the shell:</para>
753 <variablelist remap='.IP'>
755 <term>"<emphasis remap='B'>CDPATH</emphasis>"</term>
757 <para>Search path for the <emphasis remap='B'>cd</emphasis> built-in command. Works the same way as
758 <envar>PATH</envar> for those directories not beginning with <emphasis remap='B'>/</emphasis> in <emphasis remap='B'>cd</emphasis>
760 Note that if CDPATH is set and does not contain <literal>.</literal> nor an empty path,
761 the current directory is not searched.</para>
767 <term><envar>COLUMNS</envar></term>
769 <para>Set to the number of columns on the terminal or window.
770 Currently set to the <emphasis remap='B'>cols</emphasis> value as reported by <citerefentry><refentrytitle>stty</refentrytitle><manvolnum>1</manvolnum></citerefentry> if that
772 This parameter is used by the interactive line editing modes, and by
773 <emphasis remap='B'>select</emphasis>, <userinput>set -o</userinput> and <userinput>kill -l</userinput> commands
774 to format information in columns.</para>
781 <term><emphasis remap='B'>ERRNO</emphasis></term>
783 <para>Integer value of the shell's errno variable — indicates the reason
784 the last system call failed.</para>
785 <!-- todo: ERRNO variable -->
787 <para>Not implemented yet.</para>
789 <!-- {{{ EXECSHELL -->
793 <term><emphasis remap='B'>EXECSHELL</emphasis></term>
795 <para>If set, this parameter is assumed to contain the shell that is to be
796 used to execute commands that <citerefentry><refentrytitle>execve</refentrytitle><manvolnum>2</manvolnum></citerefentry> fails to execute and
797 which do not start with a `<emphasis remap='B'>#!</emphasis> <emphasis remap='I'>shell</emphasis>' sequence.</para>
803 <term><emphasis remap='B'>FCEDIT</emphasis></term>
805 <para>The editor used by the <emphasis remap='B'>fc</emphasis> command (see below).</para>
811 <term><emphasis remap='B'>FPATH</emphasis></term>
813 <para>Like <envar>PATH</envar>, but used when an undefined function is executed to locate
814 the file defining the function.
815 It is also searched when a command can't be found using <envar>PATH</envar>.
816 See Functions below for more information.</para>
818 <!-- {{{ HISTFILE -->
820 <!-- {{{ HISTSIZE -->
826 <term><envar>HOME</envar></term>
828 <para>The default directory for the <emphasis remap='B'>cd</emphasis> command and the value
829 substituted for an unqualified <emphasis remap='B'>~</emphasis> (see Tilde Expansion below).</para>
835 <term><emphasis remap='B'>IFS</emphasis></term>
837 <para>Internal field separator, used during substitution and by the <emphasis remap='B'>read</emphasis>
838 command, to split values into distinct arguments; normally set to
839 space, tab and newline. See Substitution above for details.
841 <emphasis remap='B'>Note:</emphasis> this parameter is not imported from the environment
842 when the shell is started.</para>
846 <term><emphasis remap='B'>POSH_VERSION</emphasis></term>
848 <para>The version of posh (readonly).</para>
854 <term><emphasis remap='B'>LINENO</emphasis></term>
856 <para>The line number of the function or shell script that is currently being
863 <term><envar>LINES</envar></term>
865 <para>Set to the number of lines on the terminal or window.</para>
866 <!-- Currently set to the \fBrows\fP value as reported by \fIstty\fP(1) if that -->
867 <!-- value is non\-zero. -->
868 <!-- todo: LINES variable -->
870 <para>Not implemented yet.</para>
874 <!-- {{{ MAILCHECK -->
876 <!-- {{{ MAILPATH -->
882 <term><envar>OLDPWD</envar></term>
884 <para>The previous working directory.
885 Unset if <emphasis remap='B'>cd</emphasis> has not successfully changed directories since the
886 shell started, or if the shell doesn't know where it is.</para>
892 <term><envar>OPTARG</envar></term>
894 <para>When using <emphasis remap='B'>getopts</emphasis>, it contains the argument for a parsed option,
895 if it requires one.</para>
901 <term><envar>OPTIND</envar></term>
903 <para>The index of the last argument processed when using <emphasis remap='B'>getopts</emphasis>.
904 Assigning 1 to this parameter causes <emphasis remap='B'>getopts</emphasis> to
905 process arguments from the beginning the next time it is invoked.</para>
911 <term><envar>PATH</envar></term>
913 <para>A colon separated list of directories that are searched when looking
914 for commands and <literal>.</literal>'d files.
915 An empty string resulting from a leading or trailing colon, or two adjacent
916 colons is treated as a `.', the current directory.</para>
922 <term><envar>PPID</envar></term>
924 <para>The process ID of the shell's parent (readonly).</para>
928 <term><envar>PS1</envar></term>
930 <para>The primary prompt for interactive shells.
931 The prompt is printed verbatim (<emphasis remap='I'>i.e.</emphasis>, no substitutions are done).
933 ‘<literal>$ </literal>’ for non-root users, `<emphasis remap='B'># </emphasis>' for root..</para>
939 <term><envar>PS2</envar></term>
941 <para>Secondary prompt string, by default `<emphasis remap='B'>></emphasis> ', used when more input is
942 needed to complete a command.</para>
950 <term><envar>PS4</envar></term>
952 <para>Used to prefix commands that are printed during execution tracing
953 (see <userinput>set -x</userinput> command below).
954 The prompt is printed verbatim (<emphasis remap='I'>i.e.</emphasis>, no substitutions are done).
955 Default is `<emphasis remap='B'>+ </emphasis>'.</para>
961 <term><envar>PWD</envar></term>
963 <para>The current working directory. Maybe unset or null if shell doesn't
964 know where it is.</para>
972 <term><emphasis remap='B'>REPLY</emphasis></term>
974 <para>Default parameter for the <emphasis remap='B'>read</emphasis> command if no names are given.
975 Also used in <emphasis remap='B'>select</emphasis> loops to store the value that is read from
976 standard input.</para>
986 <term><envar>TMPDIR</envar></term>
988 <para>The directory shell temporary files are created in. If this parameter
989 is not set, or does not contain the absolute path of a writable
990 directory, temporary files are created in <filename>/tmp</filename>.</para>
996 <!-- {{{ Tilde Expansion -->
999 </variablelist> <!-- .IP (gather_variableliist) -->
1002 <refsect2 id='tilde_expansion'><title>Tilde Expansion</title>
1003 <para>Tilde expansion, which is done in parallel with parameter substitution,
1004 is done on words starting with an unquoted <emphasis remap='B'>~</emphasis>. The characters
1005 following the tilde, up to the first <emphasis remap='B'>/</emphasis>, if any, are assumed to be
1006 a login name. If the login name is empty, <emphasis remap='B'>+</emphasis> or <emphasis remap='B'>-</emphasis>, the
1007 value of the <envar>HOME</envar>, <envar>PWD</envar>, or <emphasis remap='B'>OLDPWD</emphasis> parameter is
1008 substituted, respectively. Otherwise, the password file is searched for
1009 the login name, and the tilde expression is substituted with the
1010 user's home directory. If the login name is not found in the password
1011 file or if any quoting or parameter substitution occurs in the login name,
1012 no substitution is performed.</para>
1014 <para>In parameter assignments (those preceding a simple-command or those
1015 occurring in the arguments of <emphasis remap='B'>alias</emphasis>, <emphasis remap='B'>export</emphasis>,
1016 and <emphasis remap='B'>readonly</emphasis>,
1017 tilde expansion is done after any unquoted colon
1018 (<emphasis remap='B'>:</emphasis>), and login names are also delimited by colons.</para>
1020 <para>The home directory of previously expanded login names are cached and
1021 re-used. The <userinput>alias -d</userinput> command may be used to list, change and
1022 add to this cache (<emphasis remap='I'>e.g.</emphasis>, `alias -d fac=/usr/local/facilities; cd
1025 <!-- {{{ Brace Expansion -->
1027 <!-- {{{ File Name Patterns -->
1030 <refsect2 id='file_name_patterns'><title>File Name Patterns</title>
1032 <para>A file name pattern is a word containing one or more unquoted <emphasis remap='B'>?</emphasis> or
1033 <emphasis remap='B'>*</emphasis> characters or <emphasis remap='B'>[</emphasis>..<emphasis remap='B'>]</emphasis> sequences. Once brace expansion has
1034 been performed, the shell replaces file name patterns with the sorted names
1035 of all the files that match the pattern (if no files match, the word is
1036 left unchanged). The pattern elements have the following meaning:</para>
1037 <variablelist remap='.IP'>
1039 <term>"<emphasis remap='B'>?</emphasis>"</term>
1041 <para>matches any single character.</para>
1045 <term><emphasis remap='B'>*</emphasis></term>
1047 <para>matches any sequence of characters.</para>
1051 <term><emphasis remap='B'>[</emphasis>..<emphasis remap='B'>]</emphasis></term>
1053 <para>matches any of the characters inside the brackets. Ranges of characters
1054 can be specified by separating two characters by a <emphasis remap='B'>-</emphasis>, <emphasis remap='I'>e.g.</emphasis>,
1055 <emphasis remap='B'>[a0-9]</emphasis> matches the letter <emphasis remap='B'>a</emphasis> or any digit.
1056 In order to represent itself, a
1057 <emphasis remap='B'>-</emphasis> must either be quoted or the first or last character in the character
1058 list. Similarly, a <emphasis remap='B'>]</emphasis> must be quoted or the first character in the list
1059 if it is represent itself instead of the end of the list. Also, a <emphasis remap='B'>!</emphasis>
1060 appearing at the start of the list has special meaning (see below), so to
1061 represent itself it must be quoted or appear later in the list.</para>
1065 <term><emphasis remap='B'>[!</emphasis>..<emphasis remap='B'>]</emphasis></term>
1067 <para>like <emphasis remap='B'>[</emphasis>..<emphasis remap='B'>]</emphasis>, except it matches any character not inside the brackets.</para>
1070 </variablelist> <!-- .IP (gather_variableliist) -->
1072 <para>Note that posh currently never matches <literal>.</literal> and <literal>..</literal>, but the original
1073 ksh, Bourne sh and bash do, so this may have to change (too bad).</para>
1075 <para>Note that none of the above pattern elements match either a period (<literal>.</literal>)
1076 at the start of a file name or a slash (<emphasis remap='B'>/</emphasis>), even if they are explicitly
1077 used in a <emphasis remap='B'>[</emphasis>..<emphasis remap='B'>]</emphasis> sequence; also, the names <literal>.</literal> and <literal>..</literal>
1078 are never matched, even by the pattern <emphasis remap='B'>.*</emphasis>.</para>
1080 <!-- todo: implement this ([[:alpha:]], \fIetc.\fP) -->
1081 <para>The POSIX character classes (<emphasis remap='I'>i.e.</emphasis>,
1082 <emphasis remap='B'>[:</emphasis><emphasis remap='I'>class-name</emphasis><emphasis remap='B'>:]</emphasis> inside a <emphasis remap='B'>[</emphasis>..<emphasis remap='B'>]</emphasis> expression)
1083 are not yet implemented.</para>
1085 <!-- {{{ Input/Output Redirection -->
1088 <refsect2 id='inputoutput_redirection'><title>Input/Output Redirection</title>
1089 <para>When a command is executed, its standard input, standard output and
1090 standard error (file descriptors 0, 1 and 2, respectively) are normally
1091 inherited from the shell.
1092 Three exceptions to this are commands in pipelines, for which standard input
1093 and/or standard output are those set up by the pipeline, asynchronous commands
1094 created when job control is disabled, for which standard input is initially
1095 set to be from <filename>/dev/null</filename>, and commands for which any of the following
1096 redirections have been specified:</para>
1097 <variablelist remap='.IP'>
1099 <term>"<emphasis remap='B'>></emphasis> <emphasis remap='I'>file</emphasis>"</term>
1101 <para>standard output is redirected to <emphasis remap='I'>file</emphasis>. If <emphasis remap='I'>file</emphasis> does not exist,
1102 it is created; if it does exist, is a regular file and the <emphasis remap='B'>noclobber</emphasis>
1103 option is set, an error occurs, otherwise the file is truncated.
1104 Note that this means the command <emphasis remap='I'>cmd < foo > foo</emphasis> will open
1105 <emphasis remap='I'>foo</emphasis> for reading and then truncate it when it opens it for writing,
1106 before <emphasis remap='I'>cmd</emphasis> gets a chance to actually read <emphasis remap='I'>foo</emphasis>.</para>
1110 <term>"<emphasis remap='B'>>|</emphasis> <emphasis remap='I'>file</emphasis>"</term>
1112 <para>same as <emphasis remap='B'>></emphasis>, except the file is truncated, even if the <emphasis remap='B'>noclobber</emphasis>
1113 option is set.</para>
1117 <term>"<emphasis remap='B'>>></emphasis> <emphasis remap='I'>file</emphasis>"</term>
1119 <para>same as <emphasis remap='B'>></emphasis>, except the file an existing file is appended to instead
1120 of being truncated. Also, the file is opened in append mode, so writes
1121 always go to the end of the file (see <citerefentry><refentrytitle>open</refentrytitle><manvolnum>2</manvolnum></citerefentry>).</para>
1125 <term>"<emphasis remap='B'><</emphasis> <emphasis remap='I'>file</emphasis>"</term>
1127 <para>standard input is redirected from <emphasis remap='I'>file</emphasis>, which is opened for reading.</para>
1131 <term>"<emphasis remap='B'><></emphasis> <emphasis remap='I'>file</emphasis>"</term>
1133 <para>same as <emphasis remap='B'><</emphasis>, except the file is opened for reading and writing.</para>
1137 <term>"<emphasis remap='B'><<</emphasis> <emphasis remap='I'>marker</emphasis>"</term>
1139 <para>after reading the command line containing this kind of redirection (called a
1140 here document), the shell copies lines from the command source into a temporary
1141 file until a line matching <emphasis remap='I'>marker</emphasis> is read.
1142 When the command is executed, standard input is redirected from the temporary
1144 If <emphasis remap='I'>marker</emphasis> contains no quoted characters, the contents of the
1145 temporary file are processed as if enclosed in double quotes each time
1146 the command is executed, so parameter, command and arithmetic substitutions
1147 are performed, along with backslash (<emphasis remap='B'>\</emphasis>) escapes for
1148 <emphasis remap='B'>$</emphasis>, <emphasis remap='B'>`</emphasis>, <emphasis remap='B'>\</emphasis> and <emphasis remap='B'>\newline</emphasis>.
1149 If multiple here documents are used on the same command line, they are
1150 saved in order.</para>
1154 <term>"<emphasis remap='B'><<-</emphasis> <emphasis remap='I'>marker</emphasis>"</term>
1156 <para>same as <emphasis remap='B'><<</emphasis>, except leading tabs are stripped from lines in the
1157 here document.</para>
1161 <term>"<emphasis remap='B'><&</emphasis> <emphasis remap='I'>fd</emphasis>"</term>
1163 <para>standard input is duplicated from file descriptor <emphasis remap='I'>fd</emphasis>.
1164 <emphasis remap='I'>fd</emphasis> can be a single digit, indicating the number of an existing
1165 file descriptor, the letter <emphasis remap='B'>p</emphasis>, indicating the file descriptor
1166 associated with the output of the current co-process, or
1167 the character <emphasis remap='B'>-</emphasis>, indicating standard input is to be closed.</para>
1171 <term>"<emphasis remap='B'>>&</emphasis> <emphasis remap='I'>fd</emphasis>"</term>
1173 <para>same as <emphasis remap='B'><&</emphasis>, except the operation is done on standard output.</para>
1176 </variablelist> <!-- .IP (gather_variableliist) -->
1178 <para>In any of the above redirections, the file descriptor that is redirected
1179 (<emphasis remap='I'>i.e.</emphasis>, standard input or standard output) can be explicitly given by
1180 preceding the redirection with a single digit.
1181 Parameter, command and arithmetic substitutions, tilde substitutions and
1182 (if the shell is interactive) file name generation are all performed
1183 on the <emphasis remap='I'>file</emphasis>, <emphasis remap='I'>marker</emphasis> and <emphasis remap='I'>fd</emphasis> arguments of redirections.
1184 Note however, that the results of any file name generation are only used
1185 if a single file is matched; if multiple files match, the word with the
1186 unexpanded file name generation characters is used.</para>
1188 <para>For simple-commands, redirections may appear anywhere in the command, for
1189 compound-commands (<emphasis remap='B'>if</emphasis> statements, <emphasis remap='I'>etc.</emphasis>), any redirections must
1191 Redirections are processed after pipelines are created and in the order they
1194 <emphasis remap='B'>cat /foo/bar 2>&1 > /dev/null | cat -n</emphasis>
1196 will print an error with a line number prepended to it.</para>
1198 <!-- {{{ Arithmetic Expressions -->
1201 <refsect2 id='arithmetic_expressions'><title>Arithmetic Expressions</title>
1202 <para>Integer arithmetic expressions can be used
1203 inside <emphasis remap='B'>$((</emphasis>..<emphasis remap='B'>))</emphasis> expressions,
1204 inside array references (<emphasis remap='I'>e.g.</emphasis>, <emphasis remap='I'>name</emphasis><emphasis remap='B'>[</emphasis><emphasis remap='I'>expr</emphasis><emphasis remap='B'>]</emphasis>),
1205 as numeric arguments to the <emphasis remap='B'>test</emphasis> command,
1206 and as the value of an assignment to an integer parameter.</para>
1208 <para>Expression may contain alpha-numeric parameter identifiers, array
1209 references, and integer constants and may be combined with the
1210 following C operators (listed and grouped in increasing order of precedence).</para>
1211 <variablelist remap='TP'>
1213 <term>Unary operators:</term>
1215 <para><emphasis remap='B'>+ - ! ~ ++ --</emphasis></para>
1219 <term>Binary operators:</term>
1221 <para><emphasis remap='B'>,</emphasis>
1223 <emphasis remap='B'>= *= /= %= += -= <<= >>= &= ^= |=</emphasis>
1225 <emphasis remap='B'>||</emphasis>
1227 <emphasis remap='B'>&&</emphasis>
1229 <emphasis remap='B'>|</emphasis>
1231 <emphasis remap='B'>^</emphasis>
1233 <emphasis remap='B'>&</emphasis>
1235 <emphasis remap='B'>== !=</emphasis>
1237 <emphasis remap='B'>< <= >= ></emphasis>
1239 <emphasis remap='B'><< >></emphasis>
1241 <emphasis remap='B'>+ -</emphasis>
1243 <emphasis remap='B'>* / %</emphasis></para>
1247 <term>Ternary operator:</term>
1249 <para><emphasis remap='B'>?:</emphasis> (precedence is immediately higher than assignment)</para>
1253 <term>Grouping operators:</term>
1255 <para><emphasis remap='B'>( )</emphasis></para>
1258 </variablelist> <!-- .TP -->
1260 <para>Integer constants may be specified with arbitrary bases using the notation
1261 <emphasis remap='I'>base</emphasis><emphasis remap='B'>#</emphasis><emphasis remap='I'>number</emphasis>, where <emphasis remap='I'>base</emphasis> is a decimal integer specifying
1262 the base, and <emphasis remap='I'>number</emphasis> is a number in the specified base.</para>
1264 <para>The operators are evaluated as follows:</para>
1266 <variablelist remap='.IP'>
1268 <term>"unary <emphasis remap='B'>+</emphasis>"</term>
1270 <para>result is the argument (included for completeness).</para>
1274 <term>"unary <emphasis remap='B'>-</emphasis>"</term>
1276 <para>negation.</para>
1280 <term>"<emphasis remap='B'>!</emphasis>"</term>
1282 <para>logical not; the result is 1 if argument is zero, 0 if not.</para>
1286 <term>"<emphasis remap='B'>~</emphasis>"</term>
1288 <para>arithmetic (bit-wise) not.</para>
1292 <term>"<emphasis remap='B'>++</emphasis>"</term>
1294 <para>increment; must be applied to a parameter (not a literal or other
1295 expression) - the parameter is incremented by 1.
1296 When used as a prefix operator, the result is the incremented value of
1297 the parameter, when used as a postfix operator, the result is the
1298 original value of the parameter.</para>
1302 <term>"<emphasis remap='B'>++</emphasis>"</term>
1304 <para>similar to <emphasis remap='B'>++</emphasis>,
1305 except the parameter is decremented by 1.</para>
1309 <term>"<emphasis remap='B'>,</emphasis>"</term>
1311 <para>separates two arithmetic expressions; the left hand side is evaluated first,
1312 then the right. The result is value of the expression on the right hand side.</para>
1316 <term>"<emphasis remap='B'>=</emphasis>"</term>
1318 <para>assignment; variable on the left is set to the value on the right.</para>
1322 <term>"<emphasis remap='B'>*= /= %= += -= <<= >>= &= ^= |=</emphasis>"</term>
1324 <para>assignment operators; <emphasis remap='I'><var> <op></emphasis><emphasis remap='B'>=</emphasis> <emphasis remap='I'><expr></emphasis> is the same as
1325 <emphasis remap='I'><var></emphasis> <emphasis remap='B'>=</emphasis> <emphasis remap='I'><var> <op></emphasis> <emphasis remap='B'>(</emphasis> <emphasis remap='I'><expr></emphasis> <emphasis remap='B'>)</emphasis>.</para>
1329 <term>"<emphasis remap='B'>||</emphasis>"</term>
1331 <para>logical or; the result is 1 if either argument is non-zero, 0 if not.
1332 The right argument is evaluated only if the left argument is zero.</para>
1336 <term>"<emphasis remap='B'>&&</emphasis>"</term>
1338 <para>logical and; the result is 1 if both arguments are non-zero, 0 if not.
1339 The right argument is evaluated only if the left argument is non-zero.</para>
1343 <term>"<emphasis remap='B'>|</emphasis>"</term>
1345 <para>arithmetic (bit-wise) or.</para>
1349 <term>"<emphasis remap='B'>^</emphasis>"</term>
1351 <para>arithmetic (bit-wise) exclusive-or.</para>
1355 <term>"<emphasis remap='B'>&</emphasis>"</term>
1357 <para>arithmetic (bit-wise) and.</para>
1361 <term>"<emphasis remap='B'>==</emphasis>"</term>
1363 <para>equal; the result is 1 if both arguments are equal, 0 if not.</para>
1367 <term>"<emphasis remap='B'>!=</emphasis>"</term>
1369 <para>not equal; the result is 0 if both arguments are equal, 1 if not.</para>
1373 <term>"<emphasis remap='B'><</emphasis>"</term>
1375 <para>less than; the result is 1 if the left argument is less than the right,
1380 <term>"<emphasis remap='B'><= >= ></emphasis>"</term>
1382 <para>less than or equal, greater than or equal, greater than. See <.</para>
1386 <term>"<emphasis remap='B'><< >></emphasis>"</term>
1388 <para>shift left (right); the result is the left argument with its bits shifted
1389 left (right) by the amount given in the right argument.</para>
1393 <term>"<emphasis remap='B'>+ - * /</emphasis>"</term>
1395 <para>addition, subtraction, multiplication, and division.</para>
1399 <term>"<emphasis remap='B'>%</emphasis>"</term>
1401 <para>remainder; the result is the remainder of the division of the left argument
1402 by the right. The sign of the result is unspecified if either argument
1407 <term>"<emphasis remap='I'><arg1></emphasis> <emphasis remap='B'>?</emphasis> <emphasis remap='I'><arg2></emphasis> <emphasis remap='B'>:</emphasis> <emphasis remap='I'><arg3></emphasis>"</term>
1409 <para>if <emphasis remap='I'><arg1></emphasis> is non-zero, the result is <emphasis remap='I'><arg2></emphasis>,
1410 otherwise <emphasis remap='I'><arg3></emphasis>.</para>
1413 <!-- {{{ Co\-Processes -->
1415 <!-- {{{ Functions -->
1418 </variablelist> <!-- .IP (gather_variableliist) -->
1421 <refsect2 id='functions'><title>Functions</title>
1423 Functions are defined using the Bourne/POSIX shell
1424 <emphasis remap='I'>name</emphasis><emphasis
1425 remap='B'>()</emphasis> syntax.
1426 Functions are like <literal>.</literal>-scripts in that they are executed in
1427 the current environment, however, unlike <literal>.</literal>-scripts, shell arguments
1428 (<emphasis remap='I'>i.e.</emphasis>, positional parameters, <emphasis remap='B'>$1</emphasis>, <emphasis remap='I'>etc.</emphasis>) are never visible
1430 When the shell is determining the location of a command, functions are
1431 searched after special built-in commands, and before regular and non-regular
1432 built-ins, and before the <envar>PATH</envar> is searched.
1436 An existing function may be deleted using <userinput>unset -f</userinput> <emphasis remap='I'>function-name</emphasis>.
1440 Since functions are executed in the current shell environment, parameter
1441 assignments made inside functions are visible after the function completes.
1445 The exit status of a function is that of the last command
1446 executed in the function. A function can be made to finish
1447 immediately using the <emphasis remap='B'>return</emphasis>
1448 command; this may also be used to explicitly specify the
1453 <refsect2 id='command_execution'>
1454 <title>Command Execution</title>
1456 After evaluation of command line arguments, redirections and
1457 parameter assignments, the type of command is determined: a
1458 special built-in, a function, a regular built-in or the name
1459 of a file to execute found using the <envar>PATH</envar>
1460 parameter. The checks are made in the above order.
1461 Special built-in commands differ from other commands in that
1462 the <envar>PATH</envar> parameter is not used to find them,
1463 an error during their execution can cause a non-interactive
1464 shell to exit and parameter assignments that are specified
1465 before the command are kept after the command completes.
1466 Just to confuse things, if the posix option is turned off
1467 (see <command>set</command> command below) some
1468 special commands are very special in that no field splitting,
1469 file globbing, brace expansion nor tilde expansion is performed
1470 on arguments that look like assignments. Regular built-in
1471 commands are different only in that the <envar>PATH</envar>
1472 parameter is not used to find them.
1476 <refsect2 id='job_control'><title>Job Control</title>
1477 <para>Job control refers to the shell's ability to monitor and control <emphasis remap='B'>jobs</emphasis>,
1478 which are processes or groups of processes created for commands or pipelines.
1479 At a minimum, the shell keeps track of the status of the background
1480 (<emphasis remap='I'>i.e.</emphasis>, asynchronous) jobs that currently exist; this information can be
1481 displayed using the <command>jobs</command> command.
1482 If job control is fully enabled (using <userinput>set -m</userinput> or
1483 <userinput>set -o monitor</userinput>), as it is for interactive shells,
1484 the processes of a job are placed in their own process group,
1485 foreground jobs can be stopped by typing the suspend character from the
1486 terminal (normally ^Z),
1487 jobs can be restarted in either the foreground
1488 or background, using the <command>fg</command>
1489 and <command>bg</command> commands, respectively,
1490 and the state of the terminal is saved or restored when a foreground
1491 job is stopped or restarted, respectively.
1494 <para>Note that only commands that create processes (<emphasis remap='I'>e.g.</emphasis>,
1495 asynchronous commands, subshell commands, and non-built-in,
1496 non-function commands) can be stopped; commands like <emphasis remap='B'>read</emphasis> cannot be.
1499 <para>When a job is created, it is assigned a job-number.
1500 For interactive shells, this number is printed inside <emphasis remap='B'>[</emphasis>..<emphasis remap='B'>]</emphasis>,
1501 followed by the process-ids of the processes in the job when an asynchronous
1503 A job may be referred to in <emphasis remap='B'>bg</emphasis>, <emphasis remap='B'>fg</emphasis>, <emphasis remap='B'>jobs</emphasis>, <emphasis remap='B'>kill</emphasis> and
1504 <emphasis remap='B'>wait</emphasis> commands either by the process id of the last process in the
1505 command pipeline (as stored in the <emphasis remap='B'>$!</emphasis> parameter) or by prefixing the
1506 job-number with a percent sign (<emphasis remap='B'>%</emphasis>).
1507 Other percent sequences can also be used to refer to jobs:
1512 <informaltable pgwide='0' frame='none'>
1513 <tgroup cols='4' align='center'>
1514 <colspec colname='c1'/>
1515 <colspec colname='c2'/>
1516 <colspec colname='c3'/>
1517 <colspec colname='c4'/>
1521 <entry align='right'>%+</entry>
1522 <entry namest='c3' nameend='c4'>The most recently stopped job, or, if there are no stopped jobs, the oldest
1523 running job.</entry>
1528 <entry>%%, <emphasis remap='P->B'>%</emphasis></entry>
1529 <entry align='left'>%%, <emphasis remap='P->B'>%</emphasis></entry>
1530 <entry align='left'>Same as <emphasis remap='B'>%+</emphasis>.</entry>
1534 <entry align='left'>%-</entry>
1535 <entry align='left'>The job that would be the <emphasis remap='B'>%+</emphasis> job, if the later did not exist.</entry>
1538 <entry>%<emphasis remap='I'>n</emphasis></entry>
1539 <entry align='left'>%<emphasis remap='I'>n</emphasis></entry>
1540 <entry align='left'>The job with job-number <emphasis remap='I'>n</emphasis>.</entry>
1543 <entry>%?<emphasis remap='I'>string</emphasis></entry>
1544 <entry align='left'>%?<emphasis remap='I'>string</emphasis></entry>
1545 <entry align='left'>The job containing the string <emphasis remap='I'>string</emphasis> (an error occurs if multiple jobs
1546 are matched).</entry>
1549 <entry>%<emphasis remap='I'>string</emphasis></entry>
1550 <entry align='left'>%<emphasis remap='I'>string</emphasis></entry>
1551 <entry align='left'>The job starting with string <emphasis remap='I'>string</emphasis> (an error occurs if multiple jobs
1552 are matched).</entry>
1559 When a job changes state (<emphasis remap='I'>e.g.</emphasis>,
1560 a background job finishes or foreground
1561 job is stopped), the shell prints the following status information:
1562 <emphasis remap='B'>[</emphasis><emphasis remap='I'>number</emphasis><emphasis remap='B'>]</emphasis>
1563 <emphasis remap='I'>flag status command</emphasis>
1566 <variablelist remap='.IP'>
1568 <term>" <emphasis remap='I'>number</emphasis>"</term>
1571 is the job-number of the job.
1576 <term>" <emphasis remap='I'>flag</emphasis>"</term>
1579 is <emphasis remap='B'>+</emphasis> or <emphasis remap='B'>-</emphasis> if the job is the <emphasis remap='B'>%+</emphasis> or <emphasis remap='B'>%-</emphasis> job,
1580 respectively, or space if it is neither.
1585 <term>" <emphasis remap='I'>status</emphasis>"</term>
1588 indicates the current state of the job and can be
1592 </variablelist> <!-- .IP (gather_variableliist) -->
1594 <variablelist remap='.IP'>
1596 <term>"<emphasis remap='B'>Running</emphasis>"</term>
1599 the job has neither stopped or exited (note that running does not
1600 necessarily mean consuming CPU time — the process could be blocked waiting
1606 <term>"<emphasis remap='B'>Done</emphasis> [<emphasis remap='B'>(</emphasis><emphasis remap='I'>number</emphasis><emphasis remap='B'>)</emphasis>]"</term>
1609 the job exited. <emphasis remap='I'>number</emphasis> is the exit status of the job, which is
1610 omitted if the status is zero.
1615 <term>"<emphasis remap='B'>Stopped</emphasis> [<emphasis remap='B'>(</emphasis><emphasis remap='I'>signal</emphasis><emphasis remap='B'>)</emphasis>]"</term>
1618 the job was stopped by the indicated <emphasis remap='I'>signal</emphasis> (if no signal is given,
1619 the job was stopped by SIGTSTP).
1624 <term>"<emphasis remap='I'>signal-description</emphasis> [<emphasis remap='B'>(core dumped)</emphasis>]"</term>
1627 the job was killed by a signal (<emphasis remap='I'>e.g.</emphasis>, Memory fault,
1628 Hangup, <emphasis remap='I'>etc.</emphasis> — use
1629 <userinput>kill -l</userinput> for a list of signal descriptions).
1630 The <emphasis remap='B'>(core dumped)</emphasis> message indicates the process created a core file.
1635 <term>" <emphasis remap='I'>command</emphasis>"</term>
1638 is the command that created the process.
1639 If there are multiple processes in the job, then each process will
1640 have a line showing its <emphasis remap='I'>command</emphasis> and possibly its <emphasis remap='I'>status</emphasis>,
1641 if it is different from the status of the previous process.
1645 </variablelist> <!-- .IP (gather_variableliist) -->
1648 When an attempt is made to exit the shell while there are jobs in
1649 the stopped state, the shell warns the user that there are stopped jobs
1651 If another attempt is immediately made to exit the shell, the stopped
1652 jobs are sent a <emphasis remap='B'>HUP</emphasis> signal and the shell exits.
1653 Similarly, if the <option>nohup</option> option is not set and there are running
1654 jobs when an attempt is made to exit a login shell, the shell warns the
1655 user and does not exit.
1656 If another attempt is immediately made to exit the shell, the running
1657 jobs are sent a <emphasis remap='B'>HUP</emphasis> signal and the shell exits.
1662 <refsect1 id='builtins'><title>BUILTIN UTILITIES</title>
1664 posh implements the following builtin utilities:
1667 <itemizedlist mark='opencircle'>
1792 <refsect1 id='files'><title>FILES</title>
1806 <refsect1 id='bugs'><title>BUGS</title>
1808 Any bugs in posh should be reported via the Debian BTS.
1809 Legitimate bugs are inconsistencies between manpage and behavior,
1810 and inconsistencies between behavior and Debian policy
1811 (currently SUSv3 compliance with the following exceptions: echo
1812 -n, binary -a and -o to test, local scoping).
1816 <refsect1 id='version'><title>VERSION</title>
1818 This page documents the Policy-compliant Ordinary SHell.
1822 <refsect1 id='authors'><title>AUTHORS</title>
1824 This shell is based on pdksh.
1828 <refsect1 id='see_also'><title>SEE ALSO</title>
1830 <citerefentry><refentrytitle>awk</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
1831 <citerefentry><refentrytitle>ksh</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
1832 <citerefentry><refentrytitle>dash</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
1833 <citerefentry><refentrytitle>ed</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
1834 <citerefentry><refentrytitle>getconf</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
1835 <citerefentry><refentrytitle>getopt</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
1836 <citerefentry><refentrytitle>sed</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
1837 <citerefentry><refentrytitle>stty</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
1838 <citerefentry><refentrytitle>vi</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
1839 <citerefentry><refentrytitle>dup</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
1840 <citerefentry><refentrytitle>execve</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
1841 <citerefentry><refentrytitle>getgid</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
1842 <citerefentry><refentrytitle>getuid</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
1843 <citerefentry><refentrytitle>open</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
1844 <citerefentry><refentrytitle>pipe</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
1845 <citerefentry><refentrytitle>wait</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
1846 <citerefentry><refentrytitle>getopt</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
1847 <citerefentry><refentrytitle>rand</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
1848 <citerefentry><refentrytitle>signal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
1849 <citerefentry><refentrytitle>system</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
1850 <citerefentry><refentrytitle>environ</refentrytitle><manvolnum>5</manvolnum></citerefentry>