1 '\" te
2 .\" Copyright (c) 1982-2007 AT&T Knowledge Ventures
3 .\" To view license terms, see http://www.opensource.org/licenses/cpl1.0.txt
4 .\" Portions Copyright (c) 2009, Sun Microsystems, Inc.
5 .TH KSH93 1 "Jun 27, 2018"
6 .SH NAME
7 ksh93, rksh93 \- Korn Shell, a standard and restricted command and programming
8 language
9 .SH SYNOPSIS
10 .LP
11 .nf
12 \fBksh93\fR [\fB\(+-abcefhikmnoprstuvxBCD\fR] [\fB-R\fR \fIfile\fR] [ \fB\(+-o\fR \fIoption\fR] ...
13 [-] [\fIarg\fR ...]
14 .fi
15
16 .LP
17 .nf
18 \fBrksh93\fR [\fB\(+-abcefhikmnoprstuvxBCD\fR] [\fB-R\fR \fIfile\fR] [\fB\(+-o\fR \fIoption\fR] ...
19 [-] [\fIarg\fR ...]
20 .fi
21
22 .SH DESCRIPTION
23 .LP
24 \fBksh93\fR is a command and programming language that executes commands read
25 from a terminal or a file. \fBrksh93\fR is a restricted version of the command
26 interpreter \fBksh93\fR. \fBrksh93\fR is used to set up login names and
27 execution environments whose capabilities are more controlled than those of the
28 standard shell.
29 .sp
30 .LP
31 See \fBInvocation\fR for the meaning of arguments to the shell.
32 .SS "Definitions"
33 .LP
34 A \fImetacharacter\fR is defined as one of the following characters:
35 .sp
36 .in +2
37 .nf
38 ; & ( ) | < > NEWLINE SPACE TAB
39 .fi
40 .in -2
41 .sp
42
43 .sp
44 .LP
45 A \fIblank\fR is a \fBTAB\fR or a \fBSPACE\fR.
46 .sp
47 .LP
48 An \fIidentifier\fR is a sequence of letters, digits, or underscores starting
49 with a letter or underscore. Identifiers are used as components of \fIvariable
50 names\fR.
51 .sp
52 .LP
53 A \fIvname\fR is a sequence of one or more identifiers separated by a period
54 (\fB\&.\fR) and optionally preceded by a period (\fB\&.\fR). \fIvnames\fR are
55 used as function and variable names.
56 .sp
57 .LP
58 A \fIword\fR is a sequence of \fIcharacters\fR from the character set defined
59 by the current locale, excluding non-quoted \fImetacharacters\fR.
60 .sp
61 .LP
62 A \fIcommand\fR is a sequence of characters in the syntax of the shell
63 language. The shell reads each command and carries out the desired action
64 either directly or by invoking separate utilities. A built-in command is a
65 command that is carried out by the shell itself without creating a separate
66 process. Some commands are built-in purely for convenience and are not
67 documented in this manual page. Built-ins that cause side effects in the shell
68 environment and built-ins that are found before performing a path search (see
69 \fBExecution\fR) are documented in this manual page. For historical reasons,
70 some of these built-ins behave differently than other built-ins and are called
71 special built-ins.
72 .SS "Commands"
73 .LP
74 A \fIsimple-command\fR is a list of variable assignments (see \fBVariable
75 Assignments\fR) or a sequence of \fIblank\fR-separated words which can be
76 preceded by a list of variable assignments. See the \fBEnvironment\fR section
77 of this manual page.
78 .sp
79 .LP
80 The first word specifies the name of the command to be executed. Except as
81 specified in this section, the remaining words are passed as arguments to the
82 invoked command. The command name is passed as argument 0. See \fBexec\fR(2).
83 The \fIvalue\fR of a simple-command is its exit status. If it terminates
84 normally, its value is \fB0\fR-\fB255\fR. If it terminates abnormally, its
85 value is \fB256+\fR\fIsignum\fR. The name of the signal corresponding to the
86 exit status can be obtained by way of the \fB-l\fR option of the kill built-in
87 utility.
88 .sp
89 .LP
90 A \fIpipeline\fR is a sequence of one or more commands separated by \fB|\fR.
91 The standard output of each command but the last is connected by a
92 \fBpipe\fR(2) to the standard input of the next command. Each command, except
93 possibly the last, is run as a separate process. The shell waits for the last
112 pipe established to the parent shell. The standard input and output of the
113 spawned pipeline can be written to and read from by the parent shell by
114 applying the redirection operators \fB<&\fR and \fB>&\fR with \fBarg p\fR to
115 commands and by using \fB-p\fR option of the built-in commands \fBread\fR and
116 \fBprint\fR. The symbol \fB&&\fR (\fB||\fR) causes the \fIlist\fR following it
117 to be executed only if the preceding pipeline returns a zero (\fBnon-zero\fR)
118 value. One or more NEWLINEs can appear in a \fIlist\fR instead of a semicolon,
119 to delimit a command. The first \fIitem\fR of the first \fIpipeline\fR of a
120 \fIlist\fR that is a simple command not beginning with a redirection, and not
121 occurring within a \fBwhile\fR, \fBuntil\fR, or \fBif\fR \fIlist\fR , can be
122 preceded by a semicolon. This semicolon is ignored unless the \fBshowme\fR
123 option is enabled as described with the \fBset\fR built-in.
124 .sp
125 .LP
126 A \fIcommand\fR is either a simple-command or one of commands in the following
127 list. Unless otherwise stated, the value returned by a command is that of the
128 last simple-command executed in the command.
129 .sp
130 .ne 2
131 .na
132 \fB\fBfor\fR \fIvname\fR \fB[ in\fR \fIword\fR \fB\&... ] ;do\fR \fIlist\fR
133 \fB;done\fR\fR
134 .ad
135 .sp .6
136 .RS 4n
137 Each time a \fBfor\fR command is executed, \fIvname\fR is set to the next
138 \fIword\fR taken from the \fBin\fR \fIword\fR list. If \fBin\fR \fIword ...\fR
139 is omitted, the \fBfor\fR command executes the \fBdo\fR \fIlist\fR once for
140 each positional parameter that is set starting from 1. Execution ends when
141 there are no more words in the list. See \fBParameter Expansion\fR.
142 .RE
143
144 .sp
145 .ne 2
146 .na
147 \fB\fB(( [\fR\fIexpr1\fR\fB] ; [\fR\fIexpr2\fR] ; [\fIexpr3\fR\fB] )) ;do\fR
148 \fIlist\fR \fB;done\fR\fR
149 .ad
150 .sp .6
151 .RS 4n
152 The arithmetic expression \fIexpr1\fR is evaluated first. The arithmetic
153 expression \fIexpr2\fR is repeatedly evaluated until it evaluates to \fBzero\fR
154 and when \fBnon-zero\fR, \fIlist\fR is executed and the arithmetic expression
155 \fIexpr3\fR evaluated. If any expression is omitted, then it behaves as if it
156 evaluated to \fB1\fR. See \fBArithmetic Evaluation\fR.
157 .RE
158
159 .sp
160 .ne 2
161 .na
162 \fB\fBselect\fR \fIvname\fR [ in \fIword\fR \fB\&... ] ;do\fR \fIlist\fR
163 \fB;done\fR\fR
164 .ad
165 .sp .6
166 .RS 4n
167 A \fBselect\fR command prints on standard error (file descriptor 2) the set of
168 \fIwords\fR, each preceded by a number. If \fBin\fR \fIword...\fR is omitted,
169 the positional parameters starting from \fB1\fR are used instead. See
170 \fBParameter Expansion\fR. The \fBPS3\fR prompt is printed and a line is read
171 from the standard input. If this line consists of the number of one of the
172 listed \fIword\fRs, then the value of the variable \fIvname\fR is set to the
173 \fIword\fR corresponding to this number. If this line is empty, the selection
174 list is printed again. Otherwise the value of the variable \fIvname\fR is set
175 to \fBnull\fR. The contents of the line read from standard input is saved in
176 the variable \fBREPLY\fR. The \fIlist\fR is executed for each selection until a
177 break or \fBEOF\fR is encountered. If the \fBREPLY\fR variable is set to
178 \fBnull\fR by the execution of \fIlist\fR, the selection list is printed before
179 displaying the \fBPS3\fR prompt for the next selection.
180 .RE
181
182 .sp
183 .ne 2
184 .na
185 \fB\fBcase\fR \fIword\fR \fBin [ [(]\fR \fIpattern\fR \fB[ |\fR \fIpattern\fR
186 \fB] ... )\fR \fIlist\fR \fB;; ] ... esac\fR\fR
187 .ad
188 .sp .6
189 .RS 4n
190 A \fBcase\fR command executes the \fIlist\fR associated with the first
191 \fIpattern\fR that matches \fIword\fR. The form of the patterns is the same as
192 that used for file name generation. See \fBFile Name Generation\fR.
193 .sp
194 The \fB;;\fR operator causes execution of \fBcase\fR to terminate. If \fB;&\fR
195 is used in place of \fB;;\fR the next subsequent list, if any, is executed.
196 .RE
197
198 .sp
199 .ne 2
200 .na
201 \fB\fBif\fR \fIlist\fR \fB;then\fR \fIlist\fR \fB[ ;elif\fR \fIlist\fR
202 \fB;then\fR \fIlist\fR ] \fB\&... [ ;else\fR \fIlist\fR \fB]\fR \fB;fi\fR\fR
203 .ad
204 .sp .6
205 .RS 4n
206 The \fIlist\fR following \fBif\fR is executed and, if it returns a \fBzero\fR
207 exit status, the \fIlist\fR following the first \fBthen\fR is executed.
208 Otherwise, the \fIlist\fR following \fBelif\fR is executed, and, if its value
209 is \fBzero\fR, the \fIlist\fR following the next \fBthen\fR is executed.
210 Failing each successive \fBelif\fR \fIlist\fR, the \fBelse\fR \fIlist\fR is
211 executed. If the \fBif\fR \fIlist\fR has \fBnon-zero\fR exit status and there
212 is no \fBelse\fR \fIlist\fR, then the \fBif\fR command returns a \fBzero\fR
213 exit status.
214 .RE
215
216 .sp
217 .ne 2
218 .na
219 \fB\fBwhile\fR \fIlist\fR \fB;do\fR \fIlist\fR \fB;done\fR\fR
220 .ad
221 .br
222 .na
223 \fBuntil \fIlist\fR \fB;do\fR \fIlist\fR \fB;done\fR\fR
224 .ad
225 .sp .6
226 .RS 4n
227 A \fBwhile\fR command repeatedly executes the while \fIlist\fR and, if the exit
228 status of the last command in the list is zero, executes the \fBdo\fR
229 \fIlist\fR, otherwise the loop terminates. If no commands in the \fBdo\fR
230 \fIlist\fR are executed, then the \fBwhile\fR command returns a \fBzero\fR exit
231 status, \fBuntil\fR can be used in place of \fBwhile\fR to negate the loop
232 termination test.
233 .RE
234
235 .sp
236 .ne 2
237 .na
238 \fB\fB((\fR\fIexpression\fR\fB))\fR\fR
239 .ad
240 .sp .6
241 .RS 4n
242 The \fIexpression\fR is evaluated using the rules for arithmetic evaluation
243 described in this manual page. If the value of the arithmetic expression is
244 \fBnon-zero\fR, the exit status is \fB0\fR. Otherwise the exit status is
245 \fB1\fR.
246 .RE
247
248 .sp
249 .ne 2
250 .na
251 \fB\fB(\fR\fIlist\fR\fB;)\fR\fR
252 .ad
253 .sp .6
254 .RS 4n
255 Execute list in a separate environment. If two adjacent open parentheses are
256 needed for nesting, a SPACE must be inserted to avoid evaluation as an
257 arithmetic command as described in this section.
258 .sp
259 \fIlist\fR is simply executed. Unlike the metacharacters, \fB(\fR and \fB)\fR,
260 \fB{\fR and \fB}\fR are \fIreserved words\fR and must occur at the beginning of
261 a line or after a \fB;\fR to be recognized.
262 .RE
263
264 .sp
265 .ne 2
266 .na
267 \fB\fB[[\fR \fIexpression\fR \fB]]\fR\fR
268 .ad
269 .sp .6
270 .RS 4n
271 Evaluates \fIexpression\fR and returns a \fBzero\fR exit status when
272 \fIexpression\fR is true. See \fBConditional Expressions\fR for a description
273 of \fIexpression\fR.
274 .RE
275
276 .sp
277 .ne 2
278 .na
279 \fB\fBfunction\fR \fIvarname\fR \fB{\fR \fIlist\fR \fB;}\fR\fR
280 .ad
281 .br
282 .na
283 \fB\fIvarname\fR \fB() {\fR \fIlist\fR \fB;}\fR\fR
284 .ad
285 .sp .6
286 .RS 4n
287 Define a function which is referenced by \fIvarname\fR. A function whose
288 \fIvarname\fR contains a \fB\&.\fR is called a discipline function and the
289 portion of the \fIvarname\fR preceding the last \fB\&.\fR must refer to an
290 existing variable.
291 .sp
292 The body of the function is the \fIlist\fR of commands between \fB{\fR and
293 \fB}\fR. A function defined with the function \fIvarname\fR syntax can also be
294 used as an argument to the \fB\&.\fR special built-in command to get the
295 equivalent behavior as if the \fIvarname\fR\fB()\fR syntax were used to define
296 it. See \fBFunctions\fR.
297 .RE
298
299 .sp
300 .ne 2
301 .na
302 \fB\fBtime [\fR \fIpipeline\fR \fB]\fR\fR
303 .ad
304 .sp .6
305 .RS 4n
306 If \fIpipeline\fR is omitted, the user and system time for the current shell
307 and completed child processes is printed on standard error. Otherwise,
308 \fIpipeline\fR is executed and the elapsed time as well as the user and system
309 time are printed on standard error. The \fBTIMEFORMAT\fR variable can be set to
310 a format string that specifies how the timing information should be displayed.
311 See \fBShell Variables\fR for a description of the \fBTIMEFORMAT\fR variable.
312 .RE
313
314 .sp
315 .LP
316 The following reserved words are recognized as reserved only when they are the
317 first word of a command and are not quoted:
318 .br
319 .in +2
320 \fBcase\fR
321 .in -2
322 .br
323 .in +2
324 \fBdo\fR
325 .in -2
326 .br
327 .in +2
328 \fBdone\fR
329 .in -2
330 .br
331 .in +2
332 \fBelse\fR
333 .in -2
334 .br
335 .in +2
336 \fBelif\fR
337 .in -2
338 .br
371 .in +2
372 \fBuntil\fR
373 .in -2
374 .br
375 .in +2
376 \fBwhile\fR
377 .in -2
378 .br
379 .in +2
380 \fB{ }\fR
381 .in -2
382 .br
383 .in +2
384 \fB[[ ]]\fR
385 .in -2
386 .br
387 .in +2
388 \fB!\fR
389 .in -2
390 .SS "Variable Assignments"
391 .LP
392 One or more variable assignments can start a simple command or can be arguments
393 to the \fBtypeset\fR, \fBexport\fR, or \fBreadonly\fR special built-in
394 commands. The syntax for an \fIassignment\fR is of the form:
395 .sp
396 .ne 2
397 .na
398 \fB\fIvarname\fR\fB=\fR\fIword\fR\fR
399 .ad
400 .br
401 .na
402 \fB\fIvarname\fR\fB[\fR\fIword\fR\fB]=\fR\fIword\fR\fR
403 .ad
404 .sp .6
405 .RS 4n
406 No space is permitted between \fIvarname\fR and the \fB=\fR or between \fB=\fR
407 and \fIword\fR.
408 .RE
409
410 .sp
411 .ne 2
412 .na
413 \fB\fIvarname\fR\fB=(\fR\fIassignlist\fR\fB)\fR\fR
414 .ad
415 .sp .6
416 .RS 4n
417 No space is permitted between \fIvarname\fR and the \fB=\fR. An
418 \fIassignlist\fR can be one of the following:
419 .sp
420 .ne 2
421 .na
422 \fB\fIword ...\fR\fR
423 .ad
424 .sp .6
425 .RS 4n
426 Indexed array assignment.
427 .RE
428
429 .sp
430 .ne 2
431 .na
432 \fB\fB[\fR\fIword\fR\fB]=\fR\fIword ...\fR\fR
433 .ad
434 .sp .6
435 .RS 4n
436 Associative array assignment. If prefixed by \fBtypeset\fR \fB-a\fR, creates an
437 indexed array instead.
438 .RE
439
440 .sp
441 .ne 2
442 .na
443 \fB\fIassignment ...\fR\fR
444 .ad
445 .sp .6
446 .RS 4n
447 Compound variable assignment. This creates a compound variable \fIvarname\fR
448 with sub-variables of the form \fIvarname.name\fR, where \fIname\fR is the name
449 portion of assignment. The value of \fIvarname\fR contains all the assignment
450 elements. Additional assignments made to sub-variables of \fIvarname\fR are
451 also displayed as part of the value of \fIvarname\fR. If no \fIassignment\fRs
452 are specified, \fIvarname\fR is a compound variable allowing subsequence child
453 elements to be defined.
454 .RE
455
456 .sp
457 .ne 2
458 .na
459 \fB\fBtypeset [\fR\fIoptions\fR] \fIassignment\fR \fB\&...\fR\fR
460 .ad
461 .sp .6
462 .RS 4n
463 Nested variable assignment. Multiple assignments can be specified by separating
464 each of them with a \fB;\fR. The previous value is unset before the assignment.
465 .RE
466
467 In addition, a \fB+=\fR can be used in place of the \fB=\fR to signify adding
468 to or appending to the previous value. When \fB+=\fR is applied to an
469 arithmetic type, \fIword\fR is evaluated as an arithmetic expression and added
470 to the current value. When applied to a string variable, the value defined by
471 \fIword\fR is appended to the value. For compound assignments, the previous
472 value is not unset and the new values are appended to the current ones provided
473 that the types are compatible.
474 .RE
475
476 .SS "Comments"
477 .LP
478 A word beginning with \fB#\fR causes that word and all the following characters
479 up to a NEWLINE to be commented, or ignored.
480 .SS "Aliasing"
481 .LP
482 The first word of each command is replaced by the text of an alias if an alias
483 for this word has been defined. An alias name consists of any number of
484 characters excluding metacharacters, quoting characters, file expansion
485 characters, parameter expansion characters, command substitution characters,
486 and \fB=\fR. The replacement string can contain any valid shell script
487 including the metacharacters listed in the \fBCommands\fR section. The first
488 word of each command in the replaced text, other than any that are in the
489 process of being replaced, are tested for aliases. If the last character of the
490 alias value is a BLANK then the word following the alias is also checked for
491 alias substitution.
492 .sp
493 .LP
494 Aliases can be used to redefine built-in commands but cannot be used to
495 redefine the reserved words listed in the \fBCommands\fR section. Aliases can
496 be created and listed with the alias command and can be removed with the
497 \fBunalias\fR command.
498 .sp
499 .LP
500 Aliasing is performed when scripts are read, not while they are executed. For
501 an alias to take effect, the \fBalias\fR definition command has to be executed
502 before the command which references the alias is read. The following aliases
503 are compiled into the shell but can be unset or redefined:
504 .sp
505 .in +2
506 .nf
507 autoload='typeset -fu'
508 command='command '
509 fc=hist
510 float='typeset -lE'
511 functions='typeset -f'
512 hash='alias -t --'
513 history='hist -l'
514 integer='typeset -li'
515 nameref='typeset -n'
516 nohup='nohup '
517 r='hist -s'
518 redirect='command exec'
519 source='command .'
520 stop='kill -s STOP'
521 suspend='kill -s STOP $$'
522 times='{ { time;} 2>&1;}'
523 type='whence -v'
524 .fi
525 .in -2
526 .sp
527
528 .SS "Tilde Substitution"
529 .LP
530 After alias substitution is performed, each word is checked to see if it begins
531 with an unquoted tilde (\fB~\fR). For tilde substitution, \fIword\fR also
532 refers to the \fIword\fR portion of parameter expansion. See \fBParameter
533 Expansion\fR.
534 .sp
535 .LP
536 If it does, the word up to a \fB/\fR is checked to see if it matches a user
537 name in the password database. If a match is found, the \fB~\fR and the matched
538 login name are replaced by the login directory of the matched user. If no match
539 is found, the original text is left unchanged. A \fB~\fR by itself, or in front
540 of a \fB/\fR, is replaced by \fB$HOME\fR. A \fB~\fR followed by a \fB+\fR or
541 \fB-\fR is replaced by the value of \fB$PWD\fR and \fB$OLDPWD\fR respectively.
542 .sp
543 .LP
544 In addition, when expanding a \fIvariable assignment\fR, tilde substitution is
545 attempted when the value of the assignment begins with a \fB~\fR, and when a
546 \fB~\fR appears after a colon (\fB:\fR). The \fB:\fR also terminates a \fB~\fR
547 login name.
548 .SS "Command Substitution"
549 .LP
550 The standard output from a command enclosed in parentheses preceded by a dollar
551 sign (\fB$\fR) or a pair of grave accents (\fB``\fR) can be used as part or all
552 of a word. Trailing NEWLINEs are removed. In the second (obsolete) form, the
553 string between the quotes is processed for special quoting characters before
554 the command is executed. See \fBQuoting\fR.
555 .sp
556 .LP
557 The command substitution \fB$(cat file)\fR can be replaced by the equivalent
558 but faster \fB$(<file)\fR. The command substitution \fB$(\fR\fIn\fR\fB<#)\fR
559 expands to the current byte offset for file descriptor \fIn\fR.
560 .SS "Arithmetic Substitution"
561 .LP
562 An arithmetic expression enclosed in double parentheses preceded by a dollar
563 sign ( \fB$((\fR\fIarithmetic_expression\fR\fB))\fR) is replaced by the value
564 of the arithmetic expression within the double parentheses.
565 .SS "Process Substitution"
566 .LP
567 Process substitution is only available on versions of the UNIX operating system
568 that support the \fB/dev/fd\fR directory for naming open files.
569 .sp
570 .LP
571 Each command argument of the form \fB<(\fR\fIlist\fR\fB)\fR or
572 \fB>(\fR\fIlist\fR\fB)\fR runs process \fIlist\fR asynchronously connected to
573 some file in \fB/dev/fd\fR. The name of this file becomes the argument to the
574 command. If the form with \fB>\fR is selected then writing on this file
575 provides input for \fIlist\fR. If \fB<\fR is used, then the file passed as an
576 argument contains the output of the \fIlist\fR process.
577 .sp
578 .LP
579 For example,
580 .sp
581 .in +2
582 .nf
583 paste <(cut -f1 \fIfile1\fR) <(cut -f3 \fIfile2\fR) | tee \e
584 >(\fIprocess1\fR) >(\fIprocess2\fR)
585 .fi
586 .in -2
587 .sp
588
589 .sp
590 .LP
591 \fBcut\fRs fields 1 and 3 from the files \fIfile1\fR and \fIfile2\fR
592 respectively, \fBpaste\fRs the results together, and sends it to the processes
593 \fIprocess1\fR and \fIprocess2\fR. It also displays the results to the standard
594 output. The file, which is passed as an argument to the command, is a UNIX
595 \fBpipe\fR(2). Programs that expect to \fBlseek\fR(2) on the file do not work.
596 .SS "Parameter Expansion"
597 .LP
598 A parameter is a variable, one or more digits, or any of the characters
599 \fB*\fR, \fB@\fR, \fB#\fR, \fB?\fR, \fB-\fR, \fB$\fR, and \fB!\fR. A variable
600 is denoted by a \fIvname\fR. To create a variable whose \fIvname\fR contains a
601 \fB\&.\fR, a variable whose \fBvname\fR consists of everything before the
602 last . must already exist. A variable has a value and zero or more attributes.
603 Variables can be assigned values and attributes by using the \fBtypeset\fR
604 special built-in command. The attributes supported by the shell are described
605 later with the \fBtypeset\fR special built-in command. Exported variables pass
606 values and attributes to the environment.
607 .sp
608 .LP
609 The shell supports both indexed and associative arrays. An element of an array
610 variable is referenced by a subscript. A subscript for an indexed array is
611 denoted by an arithmetic expression, (see \fBArithmetic Evaluation\fR), between
612 a \fB[\fR and a \fB]\fR. Use \fBset -A\fR \fIvname value ...\fR to assign
613 values to an indexed array. The value of all subscripts must be in the range of
614 \fB0\fR through \fB1,048,575\fR. Indexed arrays do not need to be declared. Any
615 reference to a variable with a valid subscript is legal and an array is created
616 if necessary.
617 .sp
618 .LP
619 An associative array is created with the \fB-A\fR option to \fBtypeset\fR. A
620 subscript for an associative array is denoted by a string enclosed between
621 \fB[\fR and \fB]\fR.
622 .sp
623 .LP
624 Referencing any array without a subscript is equivalent to referencing the
625 array with subscript \fB0\fR.
626 .sp
627 .LP
628 The value of a variable can be assigned by:
629 .sp
630 .in +2
631 .nf
632 \fIvname\fR=\fIvalue\fR [\fIvname\fR=\fIvalue\fR] ...
633 .fi
634 .in -2
635 .sp
636
637 .sp
638 .LP
639 or
640 .sp
641 .in +2
642 .nf
643 \fIvname\fR[\fIsubscript\fR]=\fIvalue\fR [\fIvname\fR[\fIsubscript\fR]=\fIvalue\fR] ...
644 .fi
645 .in -2
646 .sp
647
648 .sp
649 .LP
650 No space is allowed before or after the \fB=\fR. A \fInameref\fR is a variable
651 that is a reference to another variable. A \fInameref\fR is created with the
652 \fB-n\fR attribute of \fBtypeset\fR. The value of the variable at the time of
653 the \fBtypeset\fR command becomes the variable that is referenced whenever the
654 \fInameref\fR variable is used. The name of a \fInameref\fR cannot contain a
655 dot (\fI\&.\fR). When a variable or function name contains a \fB\&.,\fR and the
656 portion of the name up to the first \fB\&.\fR matches the name of a
657 \fInameref\fR, the variable referred to is obtained by replacing the
658 \fInameref\fR portion with the name of the variable referenced by the
659 \fInameref\fR. If a \fInameref\fR is used as the index of a \fBfor\fR loop, a
660 name reference is established for each item in the list. A \fInameref\fR
661 provides a convenient way to refer to the variable inside a function whose name
662 is passed as an argument to a function. For example, if the name of a variable
663 is passed as the first argument to a function, the command
664 .sp
665 .in +2
666 .nf
667 typeset -n var=$1
668 .fi
669 .in -2
670 .sp
671
672 .sp
673 .LP
674 inside the function causes references and assignments to \fIvar\fR to be
675 references and assignments to the variable whose name has been passed to the
676 function. If either of the floating point attributes, \fB-E\fR, or \fB-F\fR, or
677 the integer attribute, \fB-i\fR, is set for \fIvname\fR, then the \fIvalue\fR
678 is subject to arithmetic evaluation as described in this manual page.
679 Positional parameters, parameters denoted by a number, can be assigned values
680 with the \fBset\fR special built-in command. Parameter \fB$0\fR is set from
681 argument zero when the shell is invoked. The character \fB$\fR is used to
682 introduce substitutable parameters.
683 .sp
684 .ne 2
685 .na
686 \fB\fB${\fR\fIparameter\fR\fB}\fR\fR
687 .ad
688 .sp .6
689 .RS 4n
690 The shell reads all the characters from \fB${\fR to the matching \fB}\fR as
691 part of the same word even if it contains braces or metacharacters. The value,
692 if any, of the parameter is substituted. The braces are required when
693 \fIparameter\fR is followed by a letter, digit, or underscore that is not to be
694 interpreted as part of its name, when the variable name contains a \fB\&.\fR,
695 or when a variable is subscripted. If \fIparameter\fR is one or more digits
696 then it is a positional parameter. A positional parameter of more than one
697 digit must be enclosed in braces. If \fIparameter\fR is \fB*\fR or \fB@\fR,
698 then all the positional parameters, starting with \fB$1\fR, are substituted and
699 separated by a field separator character. If an array \fIvname\fR with
700 subscript \fB*\fR or \fB@\fR is used, then the value for each of the elements
701 is substituted, separated by the first character of the value of \fBIFS\fR.
702 .RE
703
704 .sp
705 .ne 2
706 .na
707 \fB\fB${#\fR\fIparameter\fR\fB}\fR\fR
708 .ad
709 .sp .6
710 .RS 4n
711 If \fIparameter\fR is \fB*\fR or \fB@\fR, the number of positional parameters
712 is substituted. Otherwise, the length of the value of the \fIparameter\fR is
713 substituted.
714 .RE
715
716 .sp
717 .ne 2
718 .na
719 \fB\fB${#\fR\fIvname\fR\fB[*]}\fR\fR
720 .ad
721 .br
722 .na
723 \fB\fB${#\fR\fIvname\fR\fB[@]}\fR\fR
724 .ad
725 .sp .6
726 .RS 4n
727 The number of elements in the array \fIvname\fR is substituted.
728 .RE
729
730 .sp
731 .ne 2
732 .na
733 \fB\fB${!\fR\fIvname\fR\fB}\fR\fR
734 .ad
735 .sp .6
736 .RS 4n
737 Expands to the name of the variable referred to by \fIvname\fR. This is
738 \fIvname\fR except when \fIvname\fR is a name reference.
739 .RE
740
741 .sp
742 .ne 2
743 .na
744 \fB\fB${!\fR\fIvname\fR\fB[\fR\fIsubscript\fR\fB]}\fR\fR
745 .ad
746 .sp .6
747 .RS 4n
748 Expands to name of the subscript unless \fIsubscript\fR is \fB*\fR or \fB@\fR.
749 When \fIsubscript\fR is \fB*\fR, the list of array subscripts for \fIvname\fR
750 is generated. For a variable that is not an array, the value is \fB0\fR if the
751 variable is set. Otherwise it is \fBnull\fR. When \fIsubscript\fR is \fB@\fR,
752 it is the same as \fB$ {\fR\fIvname\fR\fB[\fR\fI*\fR\fB]}\fR, except that when
753 used in double quotes, each array subscript yields a separate argument.
754 .RE
755
756 .sp
757 .ne 2
758 .na
759 \fB\fB${!\fR\fIprefix\fR\fB*}\fR\fR
760 .ad
761 .sp .6
762 .RS 4n
763 Expands to the names of the variables whose names begin with \fIprefix\fR.
764 .RE
765
766 .sp
767 .ne 2
768 .na
769 \fB\fB${\fR\fIparameter\fR\fB:-\fR\fIword\fR\fB}\fR\fR
770 .ad
771 .sp .6
772 .RS 4n
773 If \fIparameter\fR is set and is non-null then substitute its value. Otherwise
774 substitute \fIword\fR.
775 .sp
776 \fIword\fR is not evaluated unless it is to be used as the substituted string.
777 .sp
778 In the following example, \fBpwd\fR is executed only if \fBd\fR is not set or
779 is NULL:
780 .sp
781 .in +2
782 .nf
783 print ${d:-$(pwd)}
784 .fi
785 .in -2
786 .sp
787
788 If the colon (\fB:\fR ) is omitted from the expression, the shell only checks
789 whether \fIparameter\fR is set or not.
790 .RE
791
792 .sp
793 .ne 2
794 .na
795 \fB\fB${\fR\fIparameter\fR\fB:=\fR\fIword\fR\fB}\fR\fR
796 .ad
797 .sp .6
798 .RS 4n
799 If \fIparameter\fR is not set or is \fBnull\fR, set it to \fIword\fR. The value
800 of the parameter is then substituted. Positional parameters cannot be assigned
801 to in this way.
802 .sp
803 \fIword\fR is not evaluated unless it is to be used as the substituted string.
804 .sp
805 In the following example, \fBpwd\fR is executed only if \fBd\fR is not set or
806 is NULL:
807 .sp
808 .in +2
809 .nf
810 print ${d:-$(pwd)}
811 .fi
812 .in -2
813 .sp
814
815 If the colon (\fB:\fR) is omitted from the expression, the shell only checks
816 whether \fIparameter\fR is set or not.
817 .RE
818
819 .sp
820 .ne 2
821 .na
822 \fB\fB${\fR\fIparameter\fR\fB:?\fR\fIword\fR\fB}\fR\fR
823 .ad
824 .sp .6
825 .RS 4n
826 If \fIparameter\fR is set and is non-null, substitute its value. Otherwise,
827 print \fIword\fR and exit from the shell , if the shell is not interactive. If
828 \fIword\fR is omitted then a standard message is printed.
829 .sp
830 \fIword\fR is not evaluated unless it is to be used as the substituted string.
831 .sp
832 In the following example, \fBpwd\fR is executed only if \fBd\fR is not set or
833 is NULL:
834 .sp
835 .in +2
836 .nf
837 print ${d:-$(pwd)}
838 .fi
839 .in -2
840 .sp
841
842 If the colon (\fB:\fR ) is omitted from the expression, the shell only checks
843 whether \fIparameter\fR is set or not.
844 .RE
845
846 .sp
847 .ne 2
848 .na
849 \fB\fB${\fR\fIparameter\fR\fB:+\fR\fIword\fR\fB}\fR\fR
850 .ad
851 .sp .6
852 .RS 4n
853 If \fIparameter\fR is set and is non-null, substitute \fIword\fR. Otherwise
854 substitute nothing.
855 .sp
856 \fIword\fR is not evaluated unless it is to be used as the substituted string.
857 .sp
858 In the following example, \fBpwd\fR is executed only if \fBd\fR is not set or
859 is NULL:
860 .sp
861 .in +2
862 .nf
863 print ${d:-$(pwd)}
864 .fi
865 .in -2
866 .sp
867
868 If the colon (\fB:\fR) is omitted from the expression, the shell only checks
869 whether \fIparameter\fR is set or not.
870 .RE
871
872 .sp
873 .ne 2
874 .na
875 \fB\fB${\fR\fIparameter\fR\fB:\fR\fIoffset\fR:\fIlength\fR}\fR
876 .ad
877 .br
878 .na
879 \fB\fB${\fR\fIparameter\fR\fB:\fR\fIoffset\fR\fB}\fR\fR
880 .ad
881 .sp .6
882 .RS 4n
883 Expands to the portion of the value of \fIparameter\fR starting at the
884 character (counting from \fB0\fR) determined by expanding offset as an
885 arithmetic expression and consisting of the number of characters determined by
886 the arithmetic expression defined by \fIlength\fR.
887 .sp
888 In the second form, the remainder of the value is used. A negative offset
889 counts backwards from the end of \fIparameter\fR.
890 .sp
891 One or more BLANKs is required in front of a minus sign to prevent the shell
892 from interpreting the operator as \fB:-\fR. If parameter is \fB*\fR or \fB@\fR,
893 or is an array name indexed by \fB*\fR or \fB@\fR, then \fIoffset\fR and
894 \fIlength\fR refer to the array index and number of elements respectively. A
895 negative \fIoffset\fR is taken relative to one greater than the highest
896 subscript for indexed arrays. The order for associative arrays is unspecified.
897 .RE
898
899 .sp
900 .ne 2
901 .na
902 \fB\fB${\fR\fIparameter\fR\fB#\fR\fIpattern\fR\fB}\fR\fR
903 .ad
904 .br
905 .na
906 \fB\fB${\fR\fIparameter\fR\fB##\fR\fIpattern\fR\fB}\fR\fR
907 .ad
908 .sp .6
909 .RS 4n
910 If the shell \fIpattern\fR matches the beginning of the value of
911 \fIparameter\fR, then the value of this expansion is the value of the
912 \fIparameter\fR with the matched portion deleted. Otherwise the value of this
913 \fIparameter\fR is substituted. In the first form the smallest matching
914 \fIpattern\fR is deleted and in the second form the largest matching
915 \fIpattern\fR is deleted. When \fIparameter\fR is \fB@\fR, \fB*\fR, or an array
916 variable with subscript \fB@\fR or \fB*\fR, the substring operation is applied
917 to each element in turn.
918 .RE
919
920 .sp
921 .ne 2
922 .na
923 \fB\fB${\fR\fIparameter\fR\fB%\fR\fIpattern\fR\fB}\fR\fR
924 .ad
925 .br
926 .na
927 \fB\fB${\fR\fIparameter\fR\fB%%\fR\fIpattern\fR\fB}\fR\fR
928 .ad
929 .sp .6
930 .RS 4n
931 If the shell \fIpattern\fR matches the end of the value of \fIparameter\fR,
932 then the value of this expansion is the value of the parameter with the matched
933 part deleted. Otherwise substitute the value of \fIparameter\fR. In the first
934 form the smallest matching pattern is deleted, and in the second form the
935 largest matching pattern is deleted. When parameter is \fB@\fR, \fB*\fR, or an
936 array variable with subscript \fB@\fR or \fB*\fR, the substring operation is
937 applied to each element in turn.
938 .RE
939
940 .sp
941 .ne 2
942 .na
943 \fB\fB${\fR\fIparameter\fR\fB/\fR\fIpattern\fR\fB/\fR\fIstring\fR\fB}\fR\fR
944 .ad
945 .br
946 .na
947 \fB\fB${\fR\fIparameter\fR\fB//\fR\fIpattern\fR\fB/\fR\fIstring\fR\fB}\fR\fR
948 .ad
949 .br
950 .na
951 \fB\fB${\fR\fIparameter\fR\fB/#\fR\fIpattern\fR\fB/\fR\fIstring\fR\fB}\fR\fR
952 .ad
953 .br
954 .na
955 \fB\fB${\fR\fIparameter\fR\fB/%\fR\fIpattern\fR\fB/\fR\fIstring\fR\fB}\fR\fR
956 .ad
957 .sp .6
958 .RS 4n
959 Expands \fIparameter\fR and replaces the longest match of \fIpattern\fR with
960 the specified \fIstring\fR. Each occurrence of \fB\e\fR\fIn\fR in \fIstring\fR
961 is replaced by the portion of \fIparameter\fR that matches the \fIn\fR\fBth\fR
962 sub-pattern.
963 .sp
964 When \fIstring\fR is null, the \fIpattern\fR is deleted and the \fB/\fR in
965 front of string can be omitted. When \fIparameter\fR is \fB@\fR, \fB*\fR, or an
966 array variable with subscript \fB@\fR or \fB*\fR, the substitution operation is
967 applied to each element in turn. In this case, the \fIstring\fR portion of
968 \fIword\fR is re-evaluated for each element.
969 .sp
970 In the first form, only the first occurrence of \fIpattern\fR is replaced.
971 .sp
972 In the second form, each match for \fIpattern\fR is replaced by the specified
973 \fIstring\fR.
974 .sp
975 The third form restricts the pattern match to the beginning of the
976 \fIstring\fR.
977 .sp
978 The fourth form restricts the pattern match to the end of the \fIstring\fR.
979 .RE
980
981 .sp
982 .LP
983 The following parameters are automatically set by the shell:
984 .sp
985 .ne 2
986 .na
987 \fB\fB#\fR\fR
988 .ad
989 .RS 19n
990 The number of positional parameters in decimal.
991 .RE
992
993 .sp
994 .ne 2
995 .na
996 \fB\fB-\fR\fR
997 .ad
998 .RS 19n
999 Options supplied to the shell on invocation or by the \fBset\fR command.
1000 .RE
1001
1002 .sp
1003 .ne 2
1004 .na
1005 \fB\fB?\fR\fR
1006 .ad
1007 .RS 19n
1008 The decimal value returned by the last executed command.
1009 .RE
1010
1011 .sp
1012 .ne 2
1013 .na
1014 \fB\fB$\fR\fR
1015 .ad
1016 .RS 19n
1017 The process number of this shell.
1018 .RE
1019
1020 .sp
1021 .ne 2
1022 .na
1023 \fB\fB_\fR\fR
1024 .ad
1025 .RS 19n
1026 Initially, the value of \fB_\fR is the absolute pathname of the shell or script
1027 being executed as passed in the environment. It is subsequently assigned the
1028 last argument of the previous command.
1029 .sp
1030 This parameter is not set for commands which are asynchronous. This parameter
1031 is also used to hold the name of the matching \fBMAIL\fR file when checking for
1032 mail.
1033 .RE
1034
1035 .sp
1036 .ne 2
1037 .na
1038 \fB\fB!\fR\fR
1039 .ad
1040 .RS 19n
1041 The process number of the last background command invoked or the most recent
1042 job put in the background with the \fBbg\fR built-in command.
1043 .RE
1044
1045 .sp
1046 .ne 2
1047 .na
1048 \fB\fB\&.sh.command\fR\fR
1049 .ad
1050 .RS 19n
1051 When processing a \fBDEBUG\fR trap, this variable contains the current command
1052 line that is about to run.
1053 .RE
1054
1055 .sp
1056 .ne 2
1057 .na
1058 \fB\fB\&.sh.edchar\fR\fR
1059 .ad
1060 .RS 19n
1061 This variable contains the value of the keyboard character (or sequence of
1062 characters if the first character is an ESC, \fBASCII 033\fR) that has been
1063 entered when processing a \fBKEYBD\fR trap. If the value is changed as part of
1064 the trap action, then the new value replaces the key (or key sequence) that
1065 caused the trap. See the \fBKey Bindings\fR section of this manual page.
1066 .RE
1067
1068 .sp
1069 .ne 2
1070 .na
1071 \fB\fB\&.sh.edcol\fR\fR
1072 .ad
1073 .RS 19n
1074 The character position of the cursor at the time of the most recent \fBKEYBD\fR
1075 trap.
1076 .RE
1077
1078 .sp
1079 .ne 2
1080 .na
1081 \fB\fB\&.sh.edmode\fR\fR
1082 .ad
1083 .RS 19n
1084 The value is set to ESC when processing a \fBKEYBD\fR trap while in \fBvi\fR
1085 insert mode. Otherwise, \fB\&.sh.edmode\fR is null when processing a
1086 \fBKEYBD\fR trap. See the \fBvi Editing Mode\fR section of this manual page.
1087 .RE
1088
1089 .sp
1090 .ne 2
1091 .na
1092 \fB\fB\&.sh.edtext\fR\fR
1093 .ad
1094 .RS 19n
1095 The characters in the input buffer at the time of the most recent \fBKEYBD\fR
1096 trap. The value is null when not processing a \fBKEYBD\fR trap.
1097 .RE
1098
1099 .sp
1100 .ne 2
1101 .na
1102 \fB\fB\&.sh.file\fR\fR
1103 .ad
1104 .RS 19n
1105 The pathname of the file than contains the current command.
1106 .RE
1107
1108 .sp
1109 .ne 2
1110 .na
1111 \fB\fB\&.sh.fun\fR\fR
1112 .ad
1113 .RS 19n
1114 The name of the current function that is being executed.
1115 .RE
1116
1117 .sp
1118 .ne 2
1119 .na
1120 \fB\fB\&.sh.match\fR\fR
1121 .ad
1122 .RS 19n
1123 An indexed array which stores the most recent match and sub-pattern matches
1124 after conditional pattern matches that match and after variables expansions
1125 using the operators \fB#\fR, \fB%\fR, or \fB/\fR. The \fB0\fRth element stores
1126 the complete match and the \fIi\fRth element stores the \fIi\fRth sub-match.
1127 The \fB\&.sh.match\fR variable is unset when the variable that has expanded is
1128 assigned a new value.
1129 .RE
1130
1131 .sp
1132 .ne 2
1133 .na
1134 \fB\fB\&.sh.name\fR\fR
1135 .ad
1136 .RS 19n
1137 Set to the name of the variable at the time that a discipline function is
1138 invoked.
1139 .RE
1140
1141 .sp
1142 .ne 2
1143 .na
1144 \fB\fB\&.sh.subscript\fR\fR
1145 .ad
1146 .RS 19n
1147 Set to the name subscript of the variable at the time that a discipline
1148 function is invoked.
1149 .RE
1150
1151 .sp
1152 .ne 2
1153 .na
1154 \fB\fB\&.sh.subshell\fR\fR
1155 .ad
1156 .RS 19n
1157 The current depth for sub-shells and command substitution.
1158 .RE
1159
1160 .sp
1161 .ne 2
1162 .na
1163 \fB\fB\&.sh.value\fR\fR
1164 .ad
1165 .RS 19n
1166 Set to the value of the variable at the time that the set or append discipline
1167 function is invoked.
1168 .RE
1169
1170 .sp
1171 .ne 2
1172 .na
1173 \fB\fB\&.sh.version\fR\fR
1174 .ad
1175 .RS 19n
1176 Set to a value that identifies the version of this shell.
1177 .RE
1178
1179 .sp
1180 .ne 2
1181 .na
1182 \fB\fBLINENO\fR\fR
1183 .ad
1184 .RS 19n
1185 The current line number within the script or function being executed.
1186 .RE
1187
1188 .sp
1189 .ne 2
1190 .na
1191 \fB\fBOLDPWD\fR\fR
1192 .ad
1193 .RS 19n
1194 The previous working directory set by the \fBcd\fR command.
1195 .RE
1196
1197 .sp
1198 .ne 2
1199 .na
1200 \fB\fBOPTARG\fR\fR
1201 .ad
1202 .RS 19n
1203 The value of the last option argument processed by the \fBgetopts\fR built-in
1204 command.
1205 .RE
1206
1207 .sp
1208 .ne 2
1209 .na
1210 \fB\fBOPTIND\fR\fR
1211 .ad
1212 .RS 19n
1213 The index of the last option argument processed by the \fBgetopts\fR built-in
1214 command.
1215 .RE
1216
1217 .sp
1218 .ne 2
1219 .na
1220 \fB\fBPPID\fR\fR
1221 .ad
1222 .RS 19n
1223 The process number of the parent of the shell.
1224 .RE
1225
1226 .sp
1227 .ne 2
1228 .na
1229 \fB\fBPWD\fR\fR
1230 .ad
1231 .RS 19n
1232 The present working directory set by the \fBcd\fR command.
1233 .RE
1234
1235 .sp
1236 .ne 2
1237 .na
1238 \fB\fBRANDOM\fR\fR
1239 .ad
1240 .RS 19n
1241 Each time this variable is referenced, a random integer, uniformly distributed
1242 between \fB0\fR and \fB32767\fR, is generated. The sequence of random numbers
1243 can be initialized by assigning a numeric value to \fBRANDOM\fR.
1244 .RE
1245
1246 .sp
1247 .ne 2
1248 .na
1249 \fB\fBREPLY\fR\fR
1250 .ad
1251 .RS 19n
1252 This variable is set by the \fBselect\fR statement and by the \fBread\fR
1253 built-in command when no arguments are supplied.
1254 .RE
1255
1256 .sp
1257 .ne 2
1258 .na
1259 \fB\fBSECONDS\fR\fR
1260 .ad
1261 .RS 19n
1262 Each time this variable is referenced, the number of seconds since shell
1263 invocation is returned. If this variable is assigned a value, then the value
1264 returned upon reference is the value that was assigned plus the number of
1265 seconds since the assignment.
1266 .RE
1267
1268 .sp
1269 .LP
1270 The following variables are used by the shell:
1271 .sp
1272 .ne 2
1273 .na
1274 \fB\fBCDPATH\fR\fR
1275 .ad
1276 .RS 14n
1277 Defines the search path for the \fBcd\fR command.
1278 .RE
1279
1280 .sp
1281 .ne 2
1282 .na
1283 \fB\fBCOLUMNS\fR\fR
1284 .ad
1285 .RS 14n
1286 Defines the width of the edit window for the shell edit modes and for printing
1287 select lists.
1288 .RE
1289
1290 .sp
1291 .ne 2
1292 .na
1293 \fB\fBEDITOR\fR\fR
1294 .ad
1295 .RS 14n
1296 If the \fBVISUAL\fR variable is not set, the value of this variable is checked
1297 for the patterns as described with \fBVISUAL\fR and the corresponding editing
1298 option is turned on.
1299 .sp
1300 See the \fBset\fR command in the \fBSpecial Command\fR section of this manual
1301 page.
1302 .RE
1303
1304 .sp
1305 .ne 2
1306 .na
1307 \fB\fBENV\fR\fR
1308 .ad
1309 .RS 14n
1310 Performs parameter expansion, command substitution, and arithmetic substitution
1311 on the value to generate the pathname of the script that is executed when the
1312 shell is invoked. This file is typically used for alias and function
1313 definitions. The default value is \fB$HOME/.kshrc\fR.
1314 .sp
1315 See the \fBInvocation\fR section of this manual page.
1316 .sp
1317 \fBENV\fR is not set by the shell.
1318 .RE
1319
1320 .sp
1321 .ne 2
1322 .na
1323 \fB\fBFCEDIT\fR\fR
1324 .ad
1325 .RS 14n
1326 Obsolete name for the default editor name for the \fBhist\fR command.
1327 \fBFCEDIT\fR is not used when \fBHISTEDIT\fR is set.
1328 .sp
1329 The shell specifies a default value to \fBFCEDIT\fR.
1330 .RE
1331
1332 .sp
1333 .ne 2
1334 .na
1335 \fB\fBFIGNORE\fR\fR
1336 .ad
1337 .RS 14n
1338 A pattern that defines the set of file names that is ignored when performing
1339 file name matching.
1340 .RE
1341
1342 .sp
1343 .ne 2
1344 .na
1345 \fB\fBFPATH\fR\fR
1346 .ad
1347 .RS 14n
1348 The search path for function definitions. The directories in this path are
1349 searched for a file with the same name as the function or command when a
1350 function with the \fB-u\fR attribute is referenced and when a command is not
1351 found. If an executable file with the name of that command is found, then it is
1352 read and executed in the current environment. Unlike \fBPATH\fR, the current
1353 directory must be represented explicitly by dot (\fB\&.\fR) rather than by
1354 adjacent colon (\fB:\fR) characters or a beginning or ending colon (\fB:\fR).
1355 .RE
1356
1357 .sp
1358 .ne 2
1359 .na
1360 \fB\fBHISTCMD\fR\fR
1361 .ad
1362 .RS 14n
1363 The number of the current command in the history file.
1364 .RE
1365
1366 .sp
1367 .ne 2
1368 .na
1369 \fB\fBHISTEDIT\fR\fR
1370 .ad
1371 .RS 14n
1372 The name for the default editor name for the \fBhist\fR command.
1373 .RE
1374
1375 .sp
1376 .ne 2
1377 .na
1378 \fB\fBHISTFILE\fR\fR
1379 .ad
1380 .RS 14n
1381 If this variable is set when the shell is invoked, the value is the pathname of
1382 the file that is used to store the command history. See the \fBCommand
1383 Re-entry\fR section of this manual page.
1384 .RE
1385
1386 .sp
1387 .ne 2
1388 .na
1389 \fB\fBHISTSIZE\fR\fR
1390 .ad
1391 .RS 14n
1392 If this variable is set when the shell is invoked, then the number of
1393 previously entered commands that are accessible by this shell is greater than
1394 or equal to this number. The default is \fB512\fR.
1395 .RE
1396
1397 .sp
1398 .ne 2
1399 .na
1400 \fB\fBHOME\fR\fR
1401 .ad
1402 .RS 14n
1403 The default argument (home directory) for the \fBcd\fR command.
1404 .sp
1405 \fBHOME\fR is not set by the shell. \fBHOME\fR is set by \fBlogin\fR(1).
1406 .RE
1407
1408 .sp
1409 .ne 2
1410 .na
1411 \fB\fBIFS\fR\fR
1412 .ad
1413 .RS 14n
1414 Internal field separators, normally SPACE, TAB, and NEWLINE that are used to
1415 separate the results of command substitution or parameter expansion and to
1416 separate fields with the built-in command read. The first character of the
1417 \fBIFS\fR variable is used to separate arguments for the \fB"$*"\fR
1418 substitution. See the \fBQuoting\fR section of this manual page.
1419 .sp
1420 Each single occurrence of an \fBIFS\fR character in the string to be split,
1421 that is not in the \fBissspace\fR character class, and any adjacent characters
1422 in \fBIFS\fR that are in the \fBissspace\fR character class, delimit a field.
1423 One or more characters in IFS that belong to the \fBissspace\fR character
1424 class, delimit a field. In addition, if the same \fBissspace\fR character
1425 appears consecutively inside \fBIFS\fR, this character is treated as if it were
1426 not in the \fBissspace\fR class, so that if \fBIFS\fR consists of two tab
1427 characters, then two adjacent tab characters delimit a null field.
1428 .sp
1429 The shell specifies a default value to \fBIFS\fR.
1430 .RE
1431
1432 .sp
1433 .ne 2
1434 .na
1435 \fB\fBLANG\fR\fR
1436 .ad
1437 .RS 14n
1438 This variable determines the locale category for any category not specifically
1439 selected with a variable starting with \fBLC_\fR or \fBLANG\fR.
1440 .RE
1441
1442 .sp
1443 .ne 2
1444 .na
1445 \fB\fBLC_ALL\fR\fR
1446 .ad
1447 .RS 14n
1448 This variable overrides the value of the \fBLANG\fR variable and any other
1449 \fBLC_\fR variable.
1450 .RE
1451
1452 .sp
1453 .ne 2
1454 .na
1455 \fB\fBLC_COLLATE\fR\fR
1456 .ad
1457 .RS 14n
1458 This variable determines the locale category for character collation
1459 information.
1460 .RE
1461
1462 .sp
1463 .ne 2
1464 .na
1465 \fB\fBLC_CTYPE\fR\fR
1466 .ad
1467 .RS 14n
1468 This variable determines the locale category for character handling functions.
1469 It determines the character classes for pattern matching. See the \fBFile Name
1470 Generation\fR section of this manual page.
1471 .RE
1472
1473 .sp
1474 .ne 2
1475 .na
1476 \fB\fBLC_NUMERIC\fR\fR
1477 .ad
1478 .RS 14n
1479 This variable determines the locale category for the decimal point character.
1480 .RE
1481
1482 .sp
1483 .ne 2
1484 .na
1485 \fB\fBLINES\fR\fR
1486 .ad
1487 .RS 14n
1488 If this variable is set, the value is used to determine the column length for
1489 printing select lists. Select lists prints vertically until about two-thirds of
1490 \fBLINES\fR lines are filled.
1491 .RE
1492
1493 .sp
1494 .ne 2
1495 .na
1496 \fB\fBMAIL\fR\fR
1497 .ad
1498 .RS 14n
1499 If this variable is set to the name of a mail file \fBand\fR the \fBMAILPATH\fR
1500 variable is not set, then the shell informs the user of arrival of mail in the
1501 specified file.
1502 .sp
1503 \fBMAIL\fR is not set by the shell. On some systems, \fBMAIL\fR is set by
1504 \fBlogin\fR(1).
1505 .RE
1506
1507 .sp
1508 .ne 2
1509 .na
1510 \fB\fBMAILCHECK\fR\fR
1511 .ad
1512 .RS 14n
1513 Specifies how often in seconds the shell checks for changes in the modification
1514 time of any of the files specified by the \fBMAILPATH\fR or \fBMAIL\fR
1515 variables. The default value is \fB600\fR seconds. When the time has elapsed
1516 the shell checks before issuing the next prompt.
1517 .sp
1518 The shell specifies a default value to \fBMAILCHECK\fR.
1519 .RE
1520
1521 .sp
1522 .ne 2
1523 .na
1524 \fB\fBMAILPATH\fR\fR
1525 .ad
1526 .RS 14n
1527 A colon ( \fB:\fR ) separated list of file names. If this variable is set, then
1528 the shell informs the user of any modifications to the specified files that
1529 have occurred within the last \fBMAILCHECK\fR seconds. Each file name can be
1530 followed by a \fB?\fR and a message that is printed. The message undergoes
1531 parameter expansion, command substitution, and arithmetic substitution with the
1532 variable \fB$_\fR defined as the name of the file that has changed. The default
1533 message is \fByou have mail in $_\fR.
1534 .RE
1535
1536 .sp
1537 .ne 2
1538 .na
1539 \fB\fBPATH\fR\fR
1540 .ad
1541 .RS 14n
1542 The search path for commands. Except in \fB\&.profile\fR, users cannot change
1543 \fBPATH\fR if executing under \fBrksh93\fR. See the \fBExecution\fR section of
1544 this manual page.
1545 .sp
1546 The shell specifies a default value to \fBPATH\fR.
1547 .RE
1548
1549 .sp
1550 .ne 2
1551 .na
1552 \fB\fBPS1\fR\fR
1553 .ad
1554 .RS 14n
1555 The value of this variable is expanded for parameter expansion, command
1556 substitution, and arithmetic substitution to define the primary prompt string
1557 which by default is \fB$\fR. The character \fB!\fR in the primary prompt string
1558 is replaced by the command number. Two successive occurrences of \fB!\fR
1559 produces a single \fB!\fR when the prompt string is printed. See the \fBCommand
1560 Re-entry\fR section of this manual page.
1561 .sp
1562 The shell specifies a default value to \fBPS1\fR.
1563 .RE
1564
1565 .sp
1566 .ne 2
1567 .na
1568 \fB\fBPS2\fR\fR
1569 .ad
1570 .RS 14n
1571 Secondary prompt string, by default, \fB>\fR.
1572 .sp
1573 The shell specifies a default value to \fBPS2\fR.
1574 .RE
1575
1576 .sp
1577 .ne 2
1578 .na
1579 \fB\fBPS3\fR\fR
1580 .ad
1581 .RS 14n
1582 Selection prompt string used within a select loop, by default \fB#?\fR.
1583 .sp
1584 The shell specifies a default value to \fBPS3\fR.
1585 .RE
1586
1587 .sp
1588 .ne 2
1589 .na
1590 \fB\fBPS4\fR\fR
1591 .ad
1592 .RS 14n
1593 The value of this variable is expanded for parameter evaluation, command
1594 substitution, and arithmetic substitution and precedes each line of an
1595 execution trace. By default, \fBPS4\fR is \fB+\fR. When \fBPS4\fR is unset, the
1596 execution trace prompt is also \fB+\fR .
1597 .sp
1598 The shell specifies a default value to \fBPS4\fR.
1599 .RE
1600
1601 .sp
1602 .ne 2
1603 .na
1604 \fB\fBSHELL\fR\fR
1605 .ad
1606 .RS 14n
1607 The pathname of the shell is kept in the environment. At invocation, if the
1608 basename of this variable is \fBrsh\fR, \fBrksh\fR, \fBrksh93\fR, or
1609 \fBkrsh\fR, the shell becomes restricted.
1610 .sp
1611 \fBSHELL\fR is not set by the shell. On some systems, \fBSHELL\fR is set by
1612 \fBlogin\fR(1).
1613 .RE
1614
1615 .sp
1616 .ne 2
1617 .na
1618 \fB\fBTIMEFORMAT\fR\fR
1619 .ad
1620 .RS 14n
1621 The value of this parameter is used as a format string specifying how the
1622 timing information for pipelines prefixed with the \fBtime\fR reserved word
1623 should be displayed. The \fB%\fR character introduces a format sequence that is
1624 expanded to a time value or other information.
1625 .sp
1626 The format sequences and their meanings are as follows.
1627 .sp
1628 .ne 2
1629 .na
1630 \fB\fB%%\fR\fR
1631 .ad
1632 .sp .6
1633 .RS 4n
1634 A literal \fB%\fR.
1635 .RE
1636
1637 .sp
1638 .ne 2
1639 .na
1640 \fB\fB%[\fIp\fR][l]R\fR\fR
1641 .ad
1642 .sp .6
1643 .RS 4n
1644 The elapsed time in seconds.
1645 .RE
1646
1647 .sp
1648 .ne 2
1649 .na
1650 \fB\fB%[\fIp\fR][l]U\fR\fR
1651 .ad
1652 .sp .6
1653 .RS 4n
1654 The number of CPU seconds spent in user mode.
1655 .RE
1656
1657 .sp
1658 .ne 2
1659 .na
1660 \fB\fB%[\fIp\fR][l]S\fR\fR
1661 .ad
1662 .sp .6
1663 .RS 4n
1664 The number of CPU seconds spent in system mode.
1665 .RE
1666
1667 .sp
1668 .ne 2
1669 .na
1670 \fB\fB%P\fR\fR
1671 .ad
1672 .sp .6
1673 .RS 4n
1674 The CPU percentage, computed as \fB(U + S) / R\fR.
1675 .RE
1676
1677 The braces denote optional portions. The optional \fIp\fR is a digit specifying
1678 the \fIprecision\fR, the number of fractional digits after a decimal point. A
1679 value of \fB0\fR causes no decimal point or fraction to be output. At most
1680 three places after the decimal point can be displayed. Values of \fIp\fR
1681 greater than \fB3\fR are treated as \fB3\fR. If \fIp\fR is not specified, the
1682 value \fB3\fR is used.
1683 .sp
1684 The optional \fBl\fR specifies a longer format, including hours if greater than
1685 zero, minutes, and seconds of the form \fIHHhMMmSS.FFs\fR. The value of \fIp\fR
1686 determines whether or not the fraction is included.
1687 .sp
1688 All other characters are output without change and a trailing NEWLINE is added.
1689 If unset, the default value, \fB$'\enreal\et%2lR\enuser\et%2lU\ensys%2lS'\fR,
1690 is used. If the value is null, no timing information is displayed.
1691 .RE
1692
1693 .sp
1694 .ne 2
1695 .na
1696 \fB\fBTMOUT\fR\fR
1697 .ad
1698 .RS 14n
1699 If set to a value greater than zero, \fBTMOUT\fR is the default time-out value
1700 for the \fBread\fR built-in command. The \fBselect\fR compound command
1701 terminates after \fBTMOUT\fR seconds when input is from a terminal. Otherwise,
1702 the shell terminates if a line is not entered within the prescribed number of
1703 seconds while reading from a terminal. The shell can be compiled with a maximum
1704 bound for this value which cannot be exceeded.
1705 .sp
1706 The shell specifies a default value to \fBTMOUT\fR.
1707 .RE
1708
1709 .sp
1710 .ne 2
1711 .na
1712 \fB\fBVISUAL\fR\fR
1713 .ad
1714 .RS 14n
1715 If the value of this variable matches the pattern \fB*[Vv][Ii]*\fR, then the
1716 \fBvi\fR option is turned on. See \fBSpecial Commands\fR. If the value matches
1717 the pattern \fB*gmacs*\fR , the \fBgmacs\fR option is turned on. If the value
1718 matches the pattern \fB*macs*\fR, then the \fBemacs\fR option is turned on. The
1719 value of \fBVISUAL\fR overrides the value of \fBEDITOR\fR.
1720 .RE
1721
1722 .SS "Field Splitting"
1723 .LP
1724 After parameter expansion and command substitution, the results of
1725 substitutions are scanned for the field separator characters (those found in
1726 \fBIFS\fR) and split into distinct fields where such characters are found.
1727 Explicit null fields (\fB""\fR or \fB\&''\fR) are retained. Implicit null
1728 fields, those resulting from parameters that have no values or command
1729 substitutions with no output, are removed.
1730 .sp
1731 .LP
1732 If the \fBbraceexpand\fR (\fB-B\fR) option is set, each of the fields resulting
1733 from \fBIFS\fR are checked to see if they contain one or more of the brace
1734 patterns. Valid brace patterns: \fB{*\fR,\fB*}\fR,
1735 \fB{\fR\fIl1\fR\fB\&..\fR\fIl2\fR\fB}\fR ,
1736 \fB{\fR\fIn1\fR\fB\&..\fR\fIn2\fR\fB}\fR,
1737 \fB{\fR\fIn1\fR\fB\&..\fR\fIn2\fR\fB%\fR\fIfmt\fR\fB}
1738 {\fR\fIn1\fR\fB\&..\fR\fIn2\fR \fB\&..\fR\fIn3\fR\fB}\fR, or
1739 \fB{\fR\fIn1\fR\fB\&..\fR\fIn2\fR \fB\&..\fR\fIn3\fR\fB%\fR\fIfmt\fR\fB}\fR ,
1740 where \fB*\fR represents any character, \fIl1\fR,\fIl2\fR are letters and
1741 \fIn1\fR,\fIn2\fR,\fIn3\fR are signed numbers and \fIfmt\fR is a format
1742 specified as used by \fBprintf\fR. In each case, fields are created by
1743 prepending the characters before the \fB{\fR and appending the characters after
1749 In the first form, a field is created for each string between \fB{\fR and
1750 \fB,,\fR between \fB,\fR and \fB,,\fR and between , and \fB}\fR. The string
1751 represented by \fB*\fR can contain embedded matching { and } without quoting.
1752 Otherwise, each \fB{\fR and \fB}\fR with \fB*\fR must be quoted.
1753 .sp
1754 .LP
1755 In the second form, \fIl1\fR and \fIl2\fR must both be either upper case or
1756 both be lower case characters in the C locale. In this case a field is created
1757 for each character from \fIl1\fR through \fIl2\fR.
1758 .sp
1759 .LP
1760 In the remaining forms, a field is created for each number starting at
1761 \fIn1\fR. This continues until it reaches \fIn2\fR and increments \fIn1\fR by
1762 \fIn3\fR. The cases where \fIn3\fR is not specified behave as if \fIn3\fR were
1763 1 if \fIn1\fR\fB<=\fR\fIn2\fR, and \fB-1\fR otherwise. In forms which specify
1764 \fB%\fR\fIfmt\fR, any format flags, widths and precisions can be specified and
1765 \fIfmt\fR can end in any of the specifiers \fBcdiouxX\fR. For example,
1766 \fB{a,z}{1..5..3%02d}{b..c}x\fR expands to the 8 fields, \fBa01bx, a01cx,
1767 a04bx, a04cx, z01bx, z01cx, z04bx,\fR and \fBz04cx\fR.
1768 .SS "File Name Generation"
1769 .LP
1770 Following splitting, each field is scanned for the characters \fB*\fR, \fB?\fR,
1771 \fB(\fR, and \fB[\fR, unless the \fB-f\fR option has been set. If one of these
1772 characters appears, then the word is regarded as a pattern.
1773 .sp
1774 .LP
1775 Each file name component that contains any pattern character is replaced with a
1776 lexicographically sorted set of names that matches the pattern from that
1777 directory. If no file name is found that matches the pattern, then that
1778 component of the file name is left unchanged unless the pattern is prefixed
1779 with \fB~(N)\fR in which case it is removed. If \fBFIGNORE\fR is set, then each
1780 file name component that matches the pattern defined by the value of
1781 \fBFIGNORE\fR is ignored when generating the matching file names. The names
1782 \fB\&.\fR and \fB\&..\fR are also ignored. If \fBFIGNORE\fR is not set, the
1783 character \fB\&.\fR at the start of each file name component is ignored unless
1784 the first character of the pattern corresponding to this component is the
1785 character \fB\&.\fR itself. For other uses of pattern matching the \fB/\fR and
1786 \fB\&.\fR are not specially treated.
1787 .sp
1788 .ne 2
1789 .na
1790 \fB\fB*\fR\fR
1791 .ad
1792 .RS 11n
1793 Match any string, including the null string. When used for file name expansion,
1794 if the \fBglobstar\fR option is on, two adjacent \fB*\fRs by themselves match
1795 all files and zero or more directories and subdirectories. If the two adjacent
1796 \fB*\fRs are followed by a \fB/\fR, only directories and subdirectories match.
1797 .RE
1798
1799 .sp
1800 .ne 2
1801 .na
1802 \fB\fB?\fR\fR
1803 .ad
1804 .RS 11n
1805 Matches any single character.
1806 .RE
1807
1808 .sp
1809 .ne 2
1810 .na
1811 \fB[\fB\&...\fR]\fR
1812 .ad
1813 .RS 11n
1814 Match any one of the enclosed characters. A pair of characters separated by
1815 \fB-\fR matches any character lexically between the pair, inclusive. If the
1816 first character following the opening \fB[\fR is a \fB!\fR, any character not
1817 enclosed is matched. A \fB-\fR can be included in the character set by putting
1818 it as the first or last character. Within \fB[\fR and \fB]\fR, character
1819 classes can be specified with the syntax \fB[:\fR\fIclass\fR\fB:]\fR where
1820 \fIclass\fR is one of the following classes defined in the \fBANSI-C\fR
1821 standard:
1822 .sp
1823 .in +2
1824 .nf
1825 \fIalnum alpha blank cntrl digit graph
1826 lower print punct space upper
1827 word xdigit\fR
1828 .fi
1829 .in -2
1830 .sp
1831
1832 \fIword\fR is equivalent to \fIalnum\fR plus the character \fB_\fR. Within
1833 \fB[\fR and \fB]\fR, an equivalence class can be specified with the syntax
1834 \fB[=\fR\fIc\fR\fB=]\fR which matches all characters with the same primary
1835 collation weight (as defined by the current locale) as the character \fIc\fR.
1836 Within \fB[\fR and \fB]\fR, [\fI\&.symbol.\fR] matches the collating symbol
1837 \fIsymbol\fR.
1838 .RE
1839
1840 .sp
1841 .LP
1842 A \fIpattern-list\fR is a list of one or more patterns separated from each
1843 other with an \fB&\fR or \fB|\fR. An \fB&\fR signifies that all patterns must
1844 be matched whereas \fB|\fR requires that only one pattern be matched. Composite
1845 patterns can be formed with one or more of the following sub-patterns:
1846 .sp
1847 .ne 2
1848 .na
1849 \fB\fB?(\fR\fIpattern-list\fR\fB)\fR\fR
1850 .ad
1851 .RS 22n
1852 Optionally matches any one of the specified patterns.
1853 .RE
1854
1855 .sp
1856 .ne 2
1857 .na
1858 \fB\fB*(\fR\fIpattern-list\fR\fB)\fR\fR
1859 .ad
1860 .RS 22n
1861 Matches zero or more occurrences of the specified patterns.
1862 .RE
1863
1864 .sp
1865 .ne 2
1866 .na
1867 \fB\fB+(\fR\fIpattern-list\fR\fB)\fR\fR
1868 .ad
1869 .RS 22n
1870 Matches one or more occurrences of the specified patterns.
1871 .RE
1872
1873 .sp
1874 .ne 2
1875 .na
1876 \fB\fB{\fR\fIn\fR\fB(\fR\fIpattern-list\fR\fB)\fR\fR
1877 .ad
1878 .RS 22n
1879 Matches \fIn\fR occurrences of the specified patterns.
1880 .RE
1881
1882 .sp
1883 .ne 2
1884 .na
1885 \fB\fB{\fR\fIm\fR\fB,\fR\fIn\fR\fB(\fR\fIpattern-list\fR\fB)\fR\fR
1886 .ad
1887 .RS 22n
1888 Matches from \fIm\fR to \fIn\fR occurrences of the specified patterns. If
1889 \fIm\fR is omitted, \fB0\fR is used. If \fIn\fR is omitted at least \fIm\fR
1890 occurrences are matched.
1891 .RE
1892
1893 .sp
1894 .ne 2
1895 .na
1896 \fB\fB@(\fR\fIpattern-list\fR\fB)\fR\fR
1897 .ad
1898 .RS 22n
1899 Matches exactly one of the specified patterns.
1900 .RE
1901
1902 .sp
1903 .ne 2
1904 .na
1905 \fB\fB!(\fR\fIpattern-list\fR\fB)\fR\fR
1906 .ad
1907 .RS 22n
1908 Matches anything except one of the specified patterns.
1909 .RE
1910
1911 .sp
1912 .LP
1913 By default, each pattern, or sub-pattern matches the longest string possible
1914 consistent with generating the longest overall match. If more than one match is
1915 possible, the one starting closest to the beginning of the string is chosen.
1916 However, for each of the compound patterns a \fB-\fR can be inserted in front
1917 of the \fB(\fR to cause the shortest match to the specified \fIpattern-list\fR
1918 to be used.
1919 .sp
1920 .LP
1921 When \fIpattern-list\fR is contained within parentheses, the backslash
1922 character \fB\e\fR is treated specially even when inside a character class. All
1923 \fBANSI-C\fR character escapes are recognized and match the specified
1924 character. In addition the following escape sequences are recognized:
1925 .sp
1926 .ne 2
1927 .na
1928 \fB\fB\ed\fR\fR
1929 .ad
1930 .RS 7n
1931 Matches any character in the digit class.
1932 .RE
1933
1934 .sp
1935 .ne 2
1936 .na
1937 \fB\fB\eD\fR\fR
1938 .ad
1939 .RS 7n
1940 Matches any character not in the digit class.
1941 .RE
1942
1943 .sp
1944 .ne 2
1945 .na
1946 \fB\fB\es\fR\fR
1947 .ad
1948 .RS 7n
1949 Matches any character in the space class.
1950 .RE
1951
1952 .sp
1953 .ne 2
1954 .na
1955 \fB\fB\eS\fR\fR
1956 .ad
1957 .RS 7n
1958 Matches any character not in the space class.
1959 .RE
1960
1961 .sp
1962 .ne 2
1963 .na
1964 \fB\fB\ew\fR\fR
1965 .ad
1966 .RS 7n
1967 Matches any character in the word class.
1968 .RE
1969
1970 .sp
1971 .ne 2
1972 .na
1973 \fB\fB\eW\fR\fR
1974 .ad
1975 .RS 7n
1976 Matches any character not in the word class.
1977 .RE
1978
1979 .sp
1980 .LP
1981 A pattern of the form \fB%(\fR\fIpattern-pairs\fR\fB)\fR is a sub-pattern that
1982 can be used to match nested character expressions. Each \fIpattern-pair\fR is a
1983 two character sequence which cannot contain \fB&\fR or \fB|\fR. The first
1984 \fIpattern-pair\fR specifies the starting and ending characters for the match.
1985 Each subsequent \fIpattern-pair\fR represents the beginning and ending
1986 characters of a nested group that is skipped over when counting starting and
1987 ending character matches. The behavior is unspecified when the first character
1988 of a \fIpattern-pair\fR is alphanumeric except for the following:
1989 .sp
1990 .ne 2
1991 .na
1992 \fB\fBD\fR\fR
1993 .ad
1994 .RS 5n
1995 Causes the ending character to terminate the search for this pattern without
1996 finding a match.
1997 .RE
1998
1999 .sp
2000 .ne 2
2001 .na
2002 \fB\fBE\fR\fR
2003 .ad
2004 .RS 5n
2005 Causes the ending character to be interpreted as an escape character.
2006 .RE
2007
2008 .sp
2009 .ne 2
2010 .na
2011 \fB\fBL\fR\fR
2012 .ad
2013 .RS 5n
2014 Causes the ending character to be interpreted as a quote character causing all
2015 characters to be ignored when looking for a match.
2016 .RE
2017
2018 .sp
2019 .ne 2
2020 .na
2021 \fB\fBQ\fR\fR
2022 .ad
2023 .RS 5n
2024 Causes the ending character to be interpreted as a quote character causing all
2025 characters other than any escape character to be ignored when looking for a
2026 match.
2027 .RE
2028
2029 .sp
2030 .LP
2031 \fB%({}Q"E\e)\fR, matches characters starting at \fB{\fR until the matching
2032 \fB}\fR is found not counting any \fB{\fR or \fB}\fR that is inside a double
2033 quoted string or preceded by the escape character \fB\e\fR\&. Without the
2034 \fB{}\fR this pattern matches any C language string.
2035 .sp
2036 .LP
2037 Each sub-pattern in a composite pattern is numbered, starting at \fB1\fR, by
2038 the location of the \fB(\fR within the pattern. The sequence \fB\e\fR\fIn\fR,
2039 where \fIn\fR is a single digit and \fB\e\fR\fIn\fR comes after the \fIn\fRth.
2040 sub-pattern, matches the same string as the sub-pattern itself.
2041 .sp
2042 .LP
2043 A pattern can contain sub-patterns of the form
2044 \fB~(\fR\fIoptions\fR\fB:\fR\fIpattern-list\fR\fB)\fR, where either
2045 \fIoptions\fR or \fB:\fR\fIpattern-list\fR can be omitted. Unlike the other
2046 compound patterns, these sub-patterns are not counted in the numbered
2047 sub-patterns. If \fIoptions\fR is present, it can consist of one or more of the
2048 following:
2049 .sp
2050 .ne 2
2051 .na
2052 \fB\fB+\fR\fR
2053 .ad
2054 .RS 5n
2055 Enable the following options. This is the default.
2056 .RE
2057
2058 .sp
2059 .ne 2
2060 .na
2061 \fB\fB-\fR\fR
2062 .ad
2063 .RS 5n
2064 Disable the following options.
2065 .RE
2066
2067 .sp
2068 .ne 2
2069 .na
2070 \fB\fBE\fR\fR
2071 .ad
2072 .RS 5n
2073 The remainder of the pattern uses extended regular expression syntax like the
2074 \fBegrep\fR(1) command.
2075 .RE
2076
2077 .sp
2078 .ne 2
2079 .na
2080 \fB\fBF\fR\fR
2081 .ad
2082 .RS 5n
2083 The remainder of the pattern uses \fBfgrep\fR(1) expression syntax.
2084 .RE
2085
2086 .sp
2087 .ne 2
2088 .na
2089 \fB\fBg\fR\fR
2090 .ad
2091 .RS 5n
2092 File the longest match (greedy).
2093 .sp
2094 This is the default.
2095 .RE
2096
2097 .sp
2098 .ne 2
2099 .na
2100 \fB\fBG\fR\fR
2101 .ad
2102 .RS 5n
2103 The remainder of the pattern uses basic regular expression syntax like the
2104 \fBgrep\fR(1) command.
2105 .RE
2106
2107 .sp
2108 .ne 2
2109 .na
2110 \fB\fBi\fR\fR
2111 .ad
2112 .RS 5n
2113 Treat the match as case insensitive.
2114 .RE
2115
2116 .sp
2117 .ne 2
2118 .na
2119 \fB\fBK\fR\fR
2120 .ad
2121 .RS 5n
2122 The remainder of the pattern uses shell pattern syntax.
2123 .sp
2124 This is the default.
2125 .RE
2126
2127 .sp
2128 .ne 2
2129 .na
2130 \fB\fBl\fR\fR
2131 .ad
2132 .RS 5n
2133 Left anchor the pattern.
2134 .sp
2135 This is the default for \fBK\fR style patterns.
2136 .RE
2137
2138 .sp
2139 .ne 2
2140 .na
2141 \fB\fBN\fR\fR
2142 .ad
2143 .RS 5n
2144 This is ignored. However, when it is the first letter and is used with file
2145 name generation, and no matches occur, the file pattern expands to the empty
2146 string.
2147 .RE
2148
2149 .sp
2150 .ne 2
2151 .na
2152 \fB\fBr\fR\fR
2153 .ad
2154 .RS 5n
2155 Right anchor the pattern.
2156 .sp
2157 This is the default for \fBK\fR style patterns.
2158 .RE
2159
2160 .sp
2161 .LP
2162 If both \fIoptions\fR and \fB:\fR\fIpattern-list\fR are specified, then the
2163 options apply only to \fIpattern-list\fR. Otherwise, these options remain in
2164 effect until they are disabled by a subsequent \fB~(...)\fR or at the end of
2165 the sub-pattern containing \fB~(...)\fR.
2166 .SS "Quoting"
2167 .LP
2168 Each of the metacharacters listed in the \fBDefinitions\fR has a special
2169 meaning to the shell.
2170 .sp
2171 .ne 2
2172 .na
2173 \fB\fBg\fR\fR
2174 .ad
2175 .RS 5n
2176 File the longest match (greedy). This is the default.
2177 .RE
2178
2179 .sp
2180 .ne 2
2181 .na
2182 \fB\fBi\fR\fR
2183 .ad
2184 .RS 5n
2185 Treat the match as case insensitive.
2186 .RE
2187
2188 .sp
2189 .LP
2190 If both \fIoptions\fR and \fB:\fR\fIpattern-list\fR are specified, then the
2191 options apply only to \fIpattern-list\fR. Otherwise, the options remain in
2192 effect until they are disabled by a subsequent \fB~(...)\fR or at the end of
2193 the sub-pattern containing \fB~(...)\fR.
2194 .sp
2195 .LP
2196 Each of the metacharacters listed in the \fBDefinitions\fR section of this
2197 manual page has a special meaning to the shell and causes termination of a word
2198 unless quoted. A character can be quoted, that is, made to stand for itself, by
2199 preceding it with a backslash (\fB\e\fR). The pair \fB\e\fRNEWLINE is removed.
2200 All characters enclosed between a pair of single quote marks (\fB\&''\fR) that
2201 is not preceded by a \fB$\fR are quoted. A single quote cannot appear within
2202 the single quotes. A single quoted string preceded by an unquoted \fB$\fR is
2203 processed as an \fBANSI-C\fR string except for the following:
2204 .sp
2205 .ne 2
2206 .na
2207 \fB\fB\e0\fR\fR
2208 .ad
2209 .RS 19n
2210 Causes the remainder of the string to be ignored.
2211 .RE
2212
2213 .sp
2214 .ne 2
2215 .na
2216 \fB\fB\ec\fR\fIx\fR\fR
2217 .ad
2218 .RS 19n
2219 Expands to the character CTRL-x.
2220 .RE
2221
2222 .sp
2223 .ne 2
2224 .na
2225 \fB\fB\eC\fR[\fB\&.\fR\fIname\fR\fB\&.\fR]\fR
2226 .ad
2227 .RS 19n
2228 Expands to the collating element \fIname\fR.
2229 .RE
2230
2231 .sp
2232 .ne 2
2233 .na
2234 \fB\fB\ee\fR\fR
2235 .ad
2236 .RS 19n
2237 Equivalent to the escape character (\fBASCII\fR 033),
2238 .RE
2239
2240 .sp
2241 .ne 2
2242 .na
2243 \fB\fB\eE\fR\fR
2244 .ad
2245 .RS 19n
2246 Equivalent to the escape character (\fBASCII\fR 033),
2247 .RE
2248
2249 .sp
2250 .LP
2251 Inside double quote marks (\fB""\fR), parameter and command substitution occur
2252 and \fB\e\fR quotes the characters \fB\e\fR, \fB`\fR, \fB"\fR, and \fB$\fR. A
2253 \fB$\fR in front of a double quoted string is ignored in the \fBC\fR or
2254 \fBPOSIX\fR locale, and might cause the string to be replaced by a locale
2255 specific string otherwise. The meaning of \fB$*\fR and \fB$@\fR is identical
2256 when not quoted or when used as a variable assignment value or as a file name.
2257 However, when used as a command argument, \fB"$*"\fR is equivalent to
2258 \fB"$1\fId\fR$2\fId\fR..."\fR, where \fId\fR is the first character of the IFS
2259 variable, whereas \fB"$@"\fR is equivalent to \fB"$1" "$2" ....\fR Inside grave
2260 quote marks (\fB``\fR), \fB\\fR quotes the characters \fB\e\fR, \fB`\fR, and
2261 \fB$\fR. If the grave quotes occur within double quotes, then \fB\e\fR also
2262 quotes the character \fB"\fR.
2263 .sp
2264 .LP
2265 The special meaning of reserved words or aliases can be removed by quoting any
2266 character of the reserved word. The recognition of function names or built-in
2267 command names cannot be altered by quoting them.
2268 .SS "Arithmetic Evaluation"
2269 .LP
2270 The shell performs arithmetic evaluation for arithmetic substitution, to
2271 evaluate an arithmetic command, to evaluate an indexed array subscript, and to
2272 evaluate arguments to the built-in commands \fBshift\fR and \fBlet\fR.
2273 Arithmetic evaluation is also performed on argument operands of the built-in
2274 command printf that correspond to numeric format specifiers in the format
2275 operand. See \fBprintf\fR(1). Evaluations are performed using double precision
2276 floating point arithmetic or long double precision floating point for systems
2277 that provide this data type. Floating point constants follow the \fBANSI-C\fR
2278 programming language floating point conventions. Integer constants follow the
2279 \fBANSI-C\fR programming language integer constant conventions although only
2280 single byte character constants are recognized and character casts are not
2281 recognized. Constants can be of the form \fB[\fR\fIbase#\fR\fB]\fR\fIn\fR where
2282 \fIbase\fR is a decimal number between two and sixty-four representing the
2283 arithmetic base and \fIn\fR is a number in that base. The digits greater than
2284 \fB9\fR are represented by the lower case letters, the upper case letters,
2285 \fB@\fR, and \fB_\fR respectively. For bases less than or equal to \fB36\fR,
2286 upper and lower case characters can be used interchangeably.
2287 .sp
2288 .LP
2289 An arithmetic expression uses the same syntax, precedence, and associativity of
2290 expression as the C language. All the C language operators that apply to
2291 floating point quantities can be used. In addition, the operator \fB**\fR can
2292 be used for exponentiation. It has higher precedence than multiplication and is
2293 left associative. When the value of an arithmetic variable or subexpression can
2294 be represented as a long integer, all C language integer arithmetic operations
2295 can be performed. Variables can be referenced by name within an arithmetic
2296 expression without using the parameter expansion syntax. When a variable is
2297 referenced, its value is evaluated as an arithmetic expression.
2298 .sp
2299 .LP
2300 Any of the following math library functions that are in the C math library can
2301 be used within an arithmetic expression:
2302 .sp
2303 .in +2
2304 .nf
2305 abs acos acosh asin asinh atan atan2 atanh cbrt
2306 copysign cos cosh erf erfc exp exp2 expm1 fabs
2307 fdim finite floor fma fmax fmod hypot ilogb
2308 int isinf isnan lgamma log log2 logb
2309 nearbyint nextafter nexttoward pow remainder
2310 rint round sin sinh sqrt tan tanh tgamma trunc
2311 .fi
2312 .in -2
2313 .sp
2314
2315 .sp
2316 .LP
2317 An internal representation of a \fIvariable\fR as a double precision floating
2318 point can be specified with the \fB-E [\fR\fIn\fR\fB]\fR or \fB-F
2319 [\fR\fIn\fR\fB]\fR option of the \fBtypeset\fR special built-in command. The
2320 \fB-E\fR option causes the expansion of the value to be represented using
2321 scientific notation when it is expanded. The optional option argument \fIn\fR
2322 defines the number of significant figures. The \fB-F\fR option causes the
2323 expansion to be represented as a floating decimal number when it is expanded.
2324 The optional option argument \fIn\fR defines the number of places after the
2325 decimal point in this case.
2326 .sp
2327 .LP
2328 An internal integer representation of a \fIvariable\fR can be specified with
2329 the \fB-i\fR \fB[\fR\fIn\fR\fB]\fR option of the \fBtypeset\fR special built-in
2330 command. The optional option argument \fIn\fR specifies an arithmetic base to
2331 be used when expanding the variable. If you do not specify an arithmetic base,
2332 base 10 is used.
2333 .sp
2334 .LP
2335 Arithmetic evaluation is performed on the value of each assignment to a
2336 variable with the \fB-E\fR, \fB-F\fR, or \fB-i\fR option. Assigning a floating
2337 point number to a variable whose type is an integer causes the fractional part
2338 to be truncated.
2339 .SS "Prompting"
2340 .LP
2341 When used interactively, the shell prompts with the value of \fBPS1\fR after
2342 expanding it for parameter expansion, command substitution, and arithmetic
2343 substitution, before reading a command. In addition, each single \fB!\fR in the
2344 prompt is replaced by the command number. A \fB!!\fR is required to place
2345 \fB!\fR in the prompt. If at any time a NEWLINE is typed and further input is
2346 needed to complete a command, then the secondary prompt, that is, the value of
2347 \fBPS2\fR, is issued.
2348 .SS "Conditional Expressions"
2349 .LP
2350 A \fBconditional expression\fR is used with the \fB[[\fR compound command to
2351 test attributes of files and to compare strings. Field splitting and file name
2352 generation are not performed on the words between \fB[[\fR and \fB]]\fR.
2353 .sp
2354 .LP
2355 Each expression can be constructed from one or more of the following unary or
2356 binary expressions:
2357 .sp
2358 .ne 2
2359 .na
2360 \fB\fB-a\fR \fIfile\fR\fR
2361 .ad
2362 .RS 21n
2363 True, if \fIfile\fR exists.
2364 .sp
2365 This option is the same as \fB-e\fR. This option is obsolete.
2366 .RE
2367
2368 .sp
2369 .ne 2
2370 .na
2371 \fB\fB-b\fR \fIfile\fR\fR
2372 .ad
2373 .RS 21n
2374 True, if \fIfile\fR exists and is a block special file.
2375 .RE
2376
2377 .sp
2378 .ne 2
2379 .na
2380 \fB\fB-c\fR \fIfile\fR\fR
2381 .ad
2382 .RS 21n
2383 True, if \fIfile\fR exists and is a character special file.
2384 .RE
2385
2386 .sp
2387 .ne 2
2388 .na
2389 \fB\fB-d\fR \fIfile\fR\fR
2390 .ad
2391 .RS 21n
2392 True, if \fIfile\fR exists and is a directory.
2393 .RE
2394
2395 .sp
2396 .ne 2
2397 .na
2398 \fB\fB-e\fR \fIfile\fR\fR
2399 .ad
2400 .RS 21n
2401 True, if \fIfile\fR exists.
2402 .RE
2403
2404 .sp
2405 .ne 2
2406 .na
2407 \fB\fB-f\fR \fIfile\fR\fR
2408 .ad
2409 .RS 21n
2410 True, if \fIfile\fR exists and is an ordinary file.
2411 .RE
2412
2413 .sp
2414 .ne 2
2415 .na
2416 \fB\fB-g\fR \fIfile\fR\fR
2417 .ad
2418 .RS 21n
2419 True, if \fIfile\fR exists and it has its \fBsetgid\fR bit set.
2420 .RE
2421
2422 .sp
2423 .ne 2
2424 .na
2425 \fB\fB-G\fR \fIfile\fR\fR
2426 .ad
2427 .RS 21n
2428 True, if \fIfile\fR exists and its group matches the effective group id of this
2429 process.
2430 .RE
2431
2432 .sp
2433 .ne 2
2434 .na
2435 \fB\fB-h\fR \fIfile\fR\fR
2436 .ad
2437 .RS 21n
2438 True, if \fIfile\fR exists and is a symbolic link.
2439 .RE
2440
2441 .sp
2442 .ne 2
2443 .na
2444 \fB\fB-k\fR \fIfile\fR\fR
2445 .ad
2446 .RS 21n
2447 True, if \fIfile\fR exists and it has its sticky bit set.
2448 .RE
2449
2450 .sp
2451 .ne 2
2452 .na
2453 \fB\fB-L\fR \fIfile\fR\fR
2454 .ad
2455 .RS 21n
2456 True, if \fIfile\fR exists and is a symbolic link.
2457 .RE
2458
2459 .sp
2460 .ne 2
2461 .na
2462 \fB\fB-n\fR \fIstring\fR\fR
2463 .ad
2464 .RS 21n
2465 True, if length of \fIstring\fR is \fBnon-zero\fR.
2466 .RE
2467
2468 .sp
2469 .ne 2
2470 .na
2471 \fB\fB-N\fR \fIfile\fR\fR
2472 .ad
2473 .RS 21n
2474 True, if \fIfile\fR exists and the modification time is greater than the last
2475 access time.
2476 .RE
2477
2478 .sp
2479 .ne 2
2480 .na
2481 \fB\fB-o\fR \fIoption\fR\fR
2482 .ad
2483 .RS 21n
2484 True, if option named \fIoption\fR is on.
2485 .RE
2486
2487 .sp
2488 .ne 2
2489 .na
2490 \fB\fB-o\fR \fI?option\fR\fR
2491 .ad
2492 .RS 21n
2493 True, if option named \fIoption\fR is a valid option name.
2494 .RE
2495
2496 .sp
2497 .ne 2
2498 .na
2499 \fB\fB-O\fR \fIfile\fR\fR
2500 .ad
2501 .RS 21n
2502 True, if \fIfile\fR exists and is owned by the effective user id of this
2503 process.
2504 .RE
2505
2506 .sp
2507 .ne 2
2508 .na
2509 \fB\fB-p\fR \fIfile\fR\fR
2510 .ad
2511 .RS 21n
2512 True, if \fIfile\fR exists and is a \fBFIFO\fR special file or a pipe.
2513 .RE
2514
2515 .sp
2516 .ne 2
2517 .na
2518 \fB\fB-r\fR \fIfile\fR\fR
2519 .ad
2520 .RS 21n
2521 True, if \fIfile\fR exists and is readable by current process.
2522 .RE
2523
2524 .sp
2525 .ne 2
2526 .na
2527 \fB\fB-s\fR \fIfile\fR\fR
2528 .ad
2529 .RS 21n
2530 True, if \fIfile\fR exists and has size greater than zero.
2531 .RE
2532
2533 .sp
2534 .ne 2
2535 .na
2536 \fB\fB-S\fR \fIfile\fR\fR
2537 .ad
2538 .RS 21n
2539 True, if \fIfile\fR exists and is a socket.
2540 .RE
2541
2542 .sp
2543 .ne 2
2544 .na
2545 \fB\fB-t\fR \fIfildes\fR\fR
2546 .ad
2547 .RS 21n
2548 True, if file descriptor number \fIfildes\fR is open and associated with a
2549 terminal device.
2550 .RE
2551
2552 .sp
2553 .ne 2
2554 .na
2555 \fB\fB-u\fR \fIfile\fR\fR
2556 .ad
2557 .RS 21n
2558 True, if \fIfile\fR exists and it has its \fBsetuid\fR bit set.
2559 .RE
2560
2561 .sp
2562 .ne 2
2563 .na
2564 \fB\fB-w\fR \fIfile\fR\fR
2565 .ad
2566 .RS 21n
2567 True, if \fIfile\fR exists and is writable by current process.
2568 .RE
2569
2570 .sp
2571 .ne 2
2572 .na
2573 \fB\fB-x\fR \fIfile\fR\fR
2574 .ad
2575 .RS 21n
2576 True, if \fIfile\fR exists and is executable by current process. If \fIfile\fR
2577 exists and is a directory, then true if the current process has permission to
2578 search in the directory.
2579 .RE
2580
2581 .sp
2582 .ne 2
2583 .na
2584 \fB\fB-z\fR \fIstring\fR\fR
2585 .ad
2586 .RS 21n
2587 True, if length of \fIstring\fR is zero.
2588 .RE
2589
2590 .sp
2591 .ne 2
2592 .na
2593 \fB\fIfile1\fR \fB-ef\fR \fIfile2\fR\fR
2594 .ad
2595 .RS 21n
2596 True, if \fIfile1\fR and \fIfile2\fR exist and refer to the same file.
2597 .RE
2598
2599 .sp
2600 .ne 2
2601 .na
2602 \fB\fIfile1\fR \fB-nt\fR \fIfile2\fR\fR
2603 .ad
2604 .RS 21n
2605 True, if \fIfile1\fR exists and \fIfile2\fR does not, or \fIfile1\fR is newer
2606 than \fIfile2\fR.
2607 .RE
2608
2609 .sp
2610 .ne 2
2611 .na
2612 \fB\fIfile1\fR \fB-ot\fR \fIfile2\fR\fR
2613 .ad
2614 .RS 21n
2615 True, if \fIfile2\fR exists and \fIfile1\fR does not, or \fIfile1\fR is older
2616 than \fIfile2\fR.
2617 .RE
2618
2619 .sp
2620 .ne 2
2621 .na
2622 \fB\fIstring\fR\fR
2623 .ad
2624 .RS 21n
2625 True, if \fIstring\fR is not null.
2626 .RE
2627
2628 .sp
2629 .ne 2
2630 .na
2631 \fB\fIstring\fR \fB==\fR \fIpattern\fR\fR
2632 .ad
2633 .RS 21n
2634 True, if \fIstring\fR matches \fIpattern\fR. Any part of \fIpattern\fR can be
2635 quoted to cause it to be matched as a string. With a successful match to
2636 \fIpattern\fR, the \fB\&.sh.match\fR array variable contains the match and
2637 sub-pattern matches.
2638 .RE
2639
2640 .sp
2641 .ne 2
2642 .na
2643 \fB\fIstring\fR \fB=\fR \fIpattern\fR\fR
2644 .ad
2645 .RS 21n
2646 Same as \fB==\fR, but is obsolete.
2647 .RE
2648
2649 .sp
2650 .ne 2
2651 .na
2652 \fB\fIstring\fR \fB!=\fR \fIpattern\fR\fR
2653 .ad
2654 .RS 21n
2655 True, if \fIstring\fR does not match \fIpattern\fR. When the \fIstring\fR
2656 matches the \fIpattern\fR the \fB\&.sh.match\fR array variable contains the
2657 match and sub-pattern matches.
2658 .RE
2659
2660 .sp
2661 .ne 2
2662 .na
2663 \fB\fIstring\fR \fB=~\fR \fIere\fR\fR
2664 .ad
2665 .RS 21n
2666 True if \fIstring\fR matches the pattern \fB~(E)\fR\fIere\fR where \fIere\fR is
2667 an extended regular expression.
2668 .RE
2669
2670 .sp
2671 .ne 2
2672 .na
2673 \fB\fIstring1\fR \fB<\fR \fIstring2\fR\fR
2674 .ad
2675 .RS 21n
2676 True, if \fIstring1\fR comes before \fIstring2\fR based on \fBASCII\fR value of
2677 their characters.
2678 .RE
2679
2680 .sp
2681 .ne 2
2682 .na
2683 \fB\fIstring1\fR \fB>\fR \fIstring2\fR\fR
2684 .ad
2685 .RS 21n
2686 True, if \fIstring1\fR comes after \fIstring2\fR based on \fBASCII\fR value of
2687 their characters.
2688 .RE
2689
2690 .sp
2691 .LP
2692 In each of the following expressions, if \fIfile\fR is of the form
2693 \fB/dev/fd/\fR\fIn\fR, where \fIn\fR is an integer, the test is applied to the
2694 open file whose descriptor number is \fIn\fR. The following obsolete arithmetic
2695 comparisons are supported:
2696 .sp
2697 .ne 2
2698 .na
2699 \fB\fIexp1\fR \fB-eq\fR \fIexp2\fR\fR
2700 .ad
2701 .RS 17n
2702 True, if \fIexp1\fR is equal to \fIexp2\fR.
2703 .RE
2704
2705 .sp
2706 .ne 2
2707 .na
2708 \fB\fIexp1\fR \fB-ge\fR \fIexp2\fR\fR
2709 .ad
2710 .RS 17n
2711 True, if \fIexp1\fR is greater than or equal to \fIexp2\fR.
2712 .RE
2713
2714 .sp
2715 .ne 2
2716 .na
2717 \fB\fIexp1\fR \fB-gt\fR \fIexp2\fR\fR
2718 .ad
2719 .RS 17n
2720 True, if \fIexp1\fR is greater than \fIexp2\fR.
2721 .RE
2722
2723 .sp
2724 .ne 2
2725 .na
2726 \fB\fIexp1\fR \fB-le\fR \fIexp2\fR\fR
2727 .ad
2728 .RS 17n
2729 True, if \fIexp1\fR is less than or equal to \fIexp2\fR.
2730 .RE
2731
2732 .sp
2733 .ne 2
2734 .na
2735 \fB\fIexp1\fR \fB-lt\fR \fIexp2\fR\fR
2736 .ad
2737 .RS 17n
2738 True, if \fIexp1\fR is less than \fIexp2\fR.
2739 .RE
2740
2741 .sp
2742 .ne 2
2743 .na
2744 \fB\fIexp1\fR \fB-ne\fR \fIexp2\fR\fR
2745 .ad
2746 .RS 17n
2747 True, if \fIexp1\fR is not equal to \fIexp2\fR.
2748 .RE
2749
2750 .sp
2751 .LP
2752 A compound expression can be constructed from these primitives by using any of
2753 the following, listed in decreasing order of precedence:
2754 .sp
2755 .ne 2
2756 .na
2757 \fB\fB(\fR\fIexpression\fR\fB)\fR\fR
2758 .ad
2759 .RS 30n
2760 True, if \fIexpression\fR is true. Used to group expressions.
2761 .RE
2762
2763 .sp
2764 .ne 2
2765 .na
2766 \fB\fB!\fR \fIexpression\fR\fR
2767 .ad
2768 .RS 30n
2769 True, if \fIexpression\fR is false.
2770 .RE
2771
2772 .sp
2773 .ne 2
2774 .na
2775 \fB\fIexpression1\fR \fB&&\fR \fIexpression2\fR\fR
2776 .ad
2777 .RS 30n
2778 True, if \fIexpression1\fR and \fIexpression2\fR are both true.
2779 .RE
2780
2781 .sp
2782 .ne 2
2783 .na
2784 \fB\fIexpression1\fR \fB||\fR \fIexpression2\fR\fR
2785 .ad
2786 .RS 30n
2787 True, if either \fIexpression1\fR or \fIexpression2\fR is true.
2788 .RE
2789
2790 .SS "Input and Output"
2791 .LP
2792 Before a command is executed, its input and output can be redirected using a
2793 special notation interpreted by the shell. The following can appear anywhere in
2794 a simple command or can precede or follow a command and are \fBnot\fR passed on
2795 to the invoked command. Command substitution, parameter expansion, and
2796 arithmetic substitution occur before \fIword\fR or \fIdigit\fR is used except
2797 as noted in this section. File name generation occurs only if the shell is
2798 interactive and the pattern matches a single file. Field splitting is not
2799 performed.
2800 .sp
2801 .LP
2802 In each of the following redirections, if \fIfile\fR is of the form
2803 \fB/dev/sctp/\fR\fIhost\fR\fB/\fR\fIport\fR,
2804 \fB/dev/tcp/\fR\fIhost\fR\fB/\fR\fIport\fR, or
2805 \fB/dev/udp/\fR\fIhost\fR\fB/\fR\fIport\fR, where \fIhost\fR is a hostname or
2806 host address, and \fIport\fR is a service specified by name or an integer port
2807 number, then the redirection attempts to make a \fBtcp\fR, \fBsctp\fR or
2808 \fBudp\fR connection to the corresponding socket.
2809 .sp
2810 .LP
2811 No intervening space is allowed between the characters of redirection
2812 operators.
2813 .sp
2814 .ne 2
2815 .na
2816 \fB\fB<\fR\fIword\fR\fR
2817 .ad
2818 .RS 14n
2819 Use file \fIword\fR as standard input (file descriptor 0).
2820 .RE
2821
2822 .sp
2823 .ne 2
2824 .na
2825 \fB\fB>\fR\fIword\fR\fR
2826 .ad
2827 .RS 14n
2828 Use file \fIword\fR as standard output (file descriptor 1). If the file does
2829 not exist then it is created. If the file exists, and the \fBnoclobber\fR
2830 option is on, this causes an error. Otherwise, it is truncated to zero length.
2831 .RE
2832
2833 .sp
2834 .ne 2
2835 .na
2836 \fB\fB>|\fR\fIword\fR\fR
2837 .ad
2838 .RS 14n
2839 Same as \fB>\fR, except that it overrides the \fBnoclobber\fR option.
2840 .RE
2841
2842 .sp
2843 .ne 2
2844 .na
2845 \fB\fB>>\fR\fIword\fR\fR
2846 .ad
2847 .RS 14n
2848 Use file \fIword\fR as standard output. If the file exists, then output is
2849 appended to it (by first seeking to the end-of-file). Otherwise, the file is
2850 created.
2851 .RE
2852
2853 .sp
2854 .ne 2
2855 .na
2856 \fB\fB<>\fR\fIword\fR\fR
2857 .ad
2858 .RS 14n
2859 Open file \fIword\fR for reading and writing as standard input.
2860 .RE
2861
2862 .sp
2863 .ne 2
2864 .na
2865 \fB\fB<<\fR\fB[-]\fR\fIword\fR\fR
2866 .ad
2867 .RS 14n
2868 The shell input is read up to a line that is the same as \fIword\fR after any
2869 quoting has been removed, or to an end-of-file. No parameter substitution,
2870 command substitution, arithmetic substitution or file name generation is
2871 performed on \fIword\fR. The resulting document, called a \fBhere-document\fR,
2872 becomes the standard input. If any character of \fIword\fR is quoted, then no
2873 interpretation is placed upon the characters of the document. Otherwise,
2874 parameter expansion, command substitution, and arithmetic substitution occur,
2875 \fB\e\fRNEWLINE is ignored, and \fB\e\fR must be used to quote the characters
2876 \fB\e\fR, \fB$\fR, \fB`\fR\&. If \fB-\fR is appended to \fB<<\fR, then all
2877 leading tabs are stripped from \fIword\fR and from the document. If \fB#\fR is
2878 appended to \fB<<\fR, then leading SPACEs and TABs are stripped off the first
2879 line of the document and up to an equivalent indentation is stripped from the
2880 remaining lines and from \fIword\fR. A tab stop is assumed to occur at every 8
2881 columns for the purposes of determining the indentation.
2882 .RE
2883
2884 .sp
2885 .ne 2
2886 .na
2887 \fB\fB<<<\fR\fIword\fR\fR
2888 .ad
2889 .RS 14n
2890 A short form of here document in which \fIword\fR becomes the contents of the
2891 here-document after any parameter expansion, command substitution, and
2892 arithmetic substitution occur.
2893 .RE
2894
2895 .sp
2896 .ne 2
2897 .na
2898 \fB\fB<&\fR\fIdigit\fR\fR
2899 .ad
2900 .RS 14n
2901 The standard input is duplicated from file descriptor \fIdigit\fR, and
2902 similarly for the standard output using \fB>&\fR\fIdigit\fR. See \fBdup\fR(2).
2903 .RE
2904
2905 .sp
2906 .ne 2
2907 .na
2908 \fB\fB<&\fR\fIdigit\fR\fB-\fR\fR
2909 .ad
2910 .RS 14n
2911 The file descriptor specified by \fIdigit\fR is moved to standard input.
2912 Similarly for the standard output using \fB>&\fR\fIdigit\fR\fB-\fR.
2913 .RE
2914
2915 .sp
2916 .ne 2
2917 .na
2918 \fB\fB<&-\fR\fR
2919 .ad
2920 .RS 14n
2921 The standard input is closed. Similarly for the standard output using
2922 \fB>&-\fR.
2923 .RE
2924
2925 .sp
2926 .ne 2
2927 .na
2928 \fB\fB<&p\fR\fR
2929 .ad
2930 .RS 14n
2931 The input from the co-process is moved to standard input.
2932 .RE
2933
2934 .sp
2935 .ne 2
2936 .na
2937 \fB\fB>&p\fR\fR
2938 .ad
2939 .RS 14n
2940 The output to the co-process is moved to standard output.
2941 .RE
2942
2943 .sp
2944 .ne 2
2945 .na
2946 \fB\fB<#((\fR\fIexpr\fR\fB))\fR\fR
2947 .ad
2948 .RS 14n
2949 Evaluate arithmetic expression \fIexpr\fR and position file descriptor 0 to the
2950 resulting value bytes from the start of the file. The variables \fBCUR\fR and
2951 \fBEOF\fR evaluate to the current offset and end-of-file offset respectively
2952 when evaluating \fIexpr\fR.
2953 .RE
2954
2955 .sp
2956 .ne 2
2957 .na
2958 \fB\fB>#((\fR\fIexpr\fR\fB))\fR\fR
2959 .ad
2960 .RS 14n
2961 The same as \fB<#\fR except applies to file descriptor 1.
2962 .RE
2963
2964 .sp
2965 .ne 2
2966 .na
2967 \fB\fB<#\fR\fIpattern\fR\fR
2968 .ad
2969 .RS 14n
2970 Seek forward to the beginning of the next line containing pattern.
2971 .RE
2972
2973 .sp
2974 .ne 2
2975 .na
2976 \fB\fB<##\fR\fIpattern\fR\fR
2977 .ad
2978 .RS 14n
2979 The same as \fB<#\fR, except that the portion of the file that is skipped is
2980 copied to standard output.
2981 .RE
2982
2983 .sp
2984 .LP
2985 If one of the redirection operators is preceded by a digit, with no intervening
2986 space, then the file descriptor number referred to is that specified by the
2987 digit (instead of the default 0 or 1). If one of the redirection operators
2988 other than \fB>&-\fR and the \fB>#\fR and \fB<#\fR forms, is preceded by
2989 \fB{\fR\fIvarname\fR\fB}\fR with no intervening space, then a file descriptor
2990 number \fB> 10\fR is selected by the shell and stored in the variable
2991 \fIvarname\fR. If \fB>&-\fR or the any of the \fB>#\fR and \fB<#\fR forms is
2992 preceded by \fB{\fR\fIvarname\fR\fB}\fR the value of \fIvarname\fR defines the
2993 file descriptor to close or position. For example:
2994 .sp
2995 .in +2
2996 .nf
3020 .sp
3021 .in +2
3022 .nf
3023 \&... 1>\fIfname\fR 2>&1
3024 .fi
3025 .in -2
3026 .sp
3027
3028 .sp
3029 .LP
3030 first associates file descriptor 1 with file \fIfname\fR. It then associates
3031 file descriptor 2 with the file associated with file descriptor 1, that is,
3032 \fIfname\fR. If the order of redirections were reversed, file descriptor 2
3033 would be associated with the terminal (assuming file descriptor 1 had been) and
3034 then file descriptor 1 would be associated with file \fIfname\fR. If a command
3035 is followed by \fB&\fR and job control is not active, the default standard
3036 input for the command is the empty file \fB/dev/null\fR. Otherwise, the
3037 environment for the execution of a command contains the file descriptors of the
3038 invoking shell as modified by input and output specifications.
3039 .SS "Environment"
3040 .LP
3041 The \fIenvironment\fR is a list of name-value pairs that is passed to an
3042 executed program in the same way as a normal argument list. See
3043 \fBenviron\fR(5).
3044 .sp
3045 .LP
3046 The names must be \fIidentifiers\fR and the values are character strings. The
3047 shell interacts with the environment in several ways. On invocation, the shell
3048 scans the environment and creates a variable for each name found, giving it the
3049 corresponding value and attributes and marking it \fBexport\fR. Executed
3050 commands inherit the environment. If the user modifies the values of these
3051 variables or creates new ones, using the \fBexport\fR or \fBtypeset\fR \fB-x\fR
3052 commands, they become part of the environment. The environment seen by any
3053 executed command is thus composed of any name-value pairs originally inherited
3054 by the shell, whose values can be modified by the current shell, plus any
3055 additions which must be noted in \fBexport\fR or \fBtypeset\fR \fB-x\fR
3056 commands. The environment for any simple-command or function can be augmented
3057 by prefixing it with one or more variable assignments. A variable assignment
3058 argument is a word of the form \fIidentifier\fR\fB=\fR\fIvalue\fR. Thus:
3059 .sp
3060 .in +2
3083 assignment arguments are placed in the environment, even if they occur after
3084 the command name.
3085 .sp
3086 .LP
3087 The following example first prints \fBa=b c\fR and then \fBc\fR:
3088 .sp
3089 .in +2
3090 .nf
3091 echo a=b c
3092 set -k
3093 echo a=b c
3094 .fi
3095 .in -2
3096 .sp
3097
3098 .sp
3099 .LP
3100 This feature is intended for use with scripts written for early versions of the
3101 shell and its use in new scripts is strongly discouraged.
3102 .SS "Functions"
3103 .LP
3104 For historical reasons, there are two ways to define functions, the
3105 \fBname()\fR syntax and the \fBfunction\fR \fBname\fR syntax. These are
3106 described in the \fBCommands\fR section of this manual page.
3107 .sp
3108 .LP
3109 Shell functions are read in and stored internally. Alias names are resolved
3110 when the function is read. Functions are executed like commands with the
3111 arguments passed as positional parameters. See the \fBExecution\fR section of
3112 this manual page for details.
3113 .sp
3114 .LP
3115 Functions defined by the \fBfunction\fR \fBname\fR syntax and called by name
3116 execute in the same process as the caller and share all files and present
3117 working directory with the caller. Traps caught by the caller are reset to
3118 their default action inside the function. A trap condition that is not caught
3119 or ignored by the function causes the function to terminate and the condition
3120 to be passed on to the caller. A trap on \fBEXIT\fR set inside a function is
3121 executed in the environment of the caller after the function completes.
3122 Ordinarily, variables are shared between the calling program and the function.
3123 However, the \fBtypeset\fR special built-in command used within a function
3132 built-in are executed in the caller's environment and share all variables and
3133 traps with the caller. Errors within these function executions cause the script
3134 that contains them to abort.
3135 .sp
3136 .LP
3137 The special built-in command \fBreturn\fR is used to return from function
3138 calls.
3139 .sp
3140 .LP
3141 Function names can be listed with the \fB-f\fR or \fB+f\fR option of the
3142 \fBtypeset\fR special built-in command. The text of functions, when available,
3143 is also listed with \fB-f\fR. Functions can be undefined with the \fB-f\fR
3144 option of the \fBunset\fR special built-in command.
3145 .sp
3146 .LP
3147 Ordinarily, functions are unset when the shell executes a shell script.
3148 Functions that need to be defined across separate invocations of the shell
3149 should be placed in a directory and the \fBFPATH\fR variable should contain the
3150 name of this directory. They can also be specified in the \fBENV\fR file.
3151 .SS "Discipline Functions"
3152 .LP
3153 Each variable can have zero or more discipline functions associated with it.
3154 The shell initially understands the discipline names \fBget\fR, \fBset\fR,
3155 \fBappend\fR, and \fBunset\fR but on most systems others can be added at run
3156 time via the C programming interface extension provided by the \fBbuiltin\fR
3157 built-in utility. If the \fBget\fR discipline is defined for a variable, it is
3158 invoked whenever the specified variable is referenced. If the variable
3159 \fB\&.sh.value\fR is assigned a value inside the discipline function, the
3160 referenced variable is evaluated to this value instead. If the \fBset\fR
3161 discipline is defined for a variable, it is invoked whenever the specified
3162 variable is assigned a value. If the \fBappend\fR discipline is defined for a
3163 variable, it is invoked whenever a value is appended to the specified variable.
3164 The variable \fB\&.sh.value\fR is specified the value of the variable before
3165 invoking the discipline, and the variable is assigned the value of
3166 \fB\&.sh.value\fR after the discipline completes. If .\fBsh.value\fR is
3167 \fBunset\fR inside the discipline, then that value is unchanged. If the
3168 \fBunset\fR discipline is defined for a variable, it is invoked whenever the
3169 specified variable is unset. The variable is not unset unless it is unset
3170 explicitly from within this discipline function.
3171 .sp
3172 .LP
3173 The variable \fB\&.sh.name\fR contains the name of the variable for which the
3174 discipline function is called, \fB\&.sh.subscript\fR is the subscript of the
3175 variable, and \fB\&.sh.value\fR contains the value being assigned inside the
3176 \fBset\fR discipline function. For the \fBset\fR discipline, changing
3177 \fB\&.sh.value\fR changes the value that gets assigned.
3178 .SS "Jobs"
3179 .LP
3180 If the monitor option of the \fBset\fR command is turned on, an interactive
3181 shell associates a job with each pipeline. It keeps a table of current jobs,
3182 printed by the \fBjobs\fR command, and assigns them small integer numbers. When
3183 a job is started asynchronously with \fB&\fR, the shell prints a line which
3184 looks like:
3185 .sp
3186 .in +2
3187 .nf
3188 [1] 1234
3189 .fi
3190 .in -2
3191 .sp
3192
3193 .sp
3194 .LP
3195 indicating that the job which was started asynchronously was job number 1 and
3196 had one (top-level) process, whose process id was \fB1234\fR.
3197 .sp
3198 .LP
3199 If you are running a job and wish to stop it, CTRL-z sends a \fBSTOP\fR signal
3200 to the current job. The shell normally displays a message that the job has been
3201 stopped, and displays another prompt. You can then manipulate the state of this
3202 job, putting it in the background with the \fBbg\fR command, or run some other
3203 commands and then eventually bring the job back into the foreground with the
3204 foreground command \fBfg\fR. A CTRL-z takes effect immediately and is like an
3205 interrupt in that pending output and unread input are discarded when it is
3206 typed.
3207 .sp
3208 .LP
3209 A job being run in the background stops if it tries to read from the terminal.
3210 Background jobs are normally allowed to produce output, but this can be
3211 disabled by giving the command \fBsttytostop\fR. If you set this \fBtty\fR
3212 option, then background jobs stop when they try to produce output like they do
3213 when they try to read input.
3214 .sp
3215 .LP
3216 There are several ways to refer to jobs in the shell. A job can be referred to
3217 by the process id of any process of the job or by one of the following:
3218 .sp
3219 .ne 2
3220 .na
3221 \fB\fB%\fR\fInumber\fR\fR
3222 .ad
3223 .RS 12n
3224 The job with the specified number.
3225 .RE
3226
3227 .sp
3228 .ne 2
3229 .na
3230 \fB\fB%\fR\fIstring\fR\fR
3231 .ad
3232 .RS 12n
3233 Any job whose command line begins with \fIstring\fR.
3234 .RE
3235
3236 .sp
3237 .ne 2
3238 .na
3239 \fB\fB%?\fR\fIstring\fR\fR
3240 .ad
3241 .RS 12n
3242 Any job whose command line contains \fIstring\fR.
3243 .RE
3244
3245 .sp
3246 .ne 2
3247 .na
3248 \fB\fB%%\fR\fR
3249 .ad
3250 .RS 12n
3251 Current job.
3252 .RE
3253
3254 .sp
3255 .ne 2
3256 .na
3257 \fB\fB%+\fR\fR
3258 .ad
3259 .RS 12n
3260 Equivalent to \fB%%\fR.
3261 .RE
3262
3263 .sp
3264 .ne 2
3265 .na
3266 \fB\fB%-\fR\fR
3267 .ad
3268 .RS 12n
3269 Previous job.
3270 .RE
3271
3272 .sp
3273 .LP
3274 The shell learns immediately whenever a process changes state. It normally
3275 informs you whenever a job becomes blocked so that no further progress is
3276 possible, but only just before it prints a prompt. This is done so that it does
3277 not otherwise disturb your work. The notify option of the \fBset\fR command
3278 causes the shell to print these job change messages as soon as they occur.
3279 .sp
3280 .LP
3281 When the \fBmonitor\fR option is on, each background job that completes
3282 triggers any trap set for \fBCHLD\fR.
3283 .sp
3284 .LP
3285 When you try to leave the shell while jobs are running or stopped, you are
3286 warned that \fBYou have stopped(running) jobs.\fR You can use the \fBjobs\fR
3287 command to see what they are. If you immediately try to exit again, the shell
3288 does not warn you a second time, and the stopped jobs are terminated. When a
3289 login shell receives a \fBHUP\fR signal, it sends a \fBHUP\fR signal to each
3290 job that has not been disowned with the \fBdisown\fR built-in command.
3291 .SS "Signals"
3292 .LP
3293 The \fBINT\fR and \fBQUIT\fR signals for an invoked command are ignored if the
3294 command is followed by \fB&\fR and the \fBmonitor\fR option is not active.
3295 Otherwise, signals have the values inherited by the shell from its parent. See
3296 the \fBtrap\fR built-in command.
3297 .SS "Execution"
3298 .LP
3299 Each time a command is read, the substitutions are carried out. If the command
3300 name matches one of the ones in the \fBSpecial Built-in Commands\fR section of
3301 this manual page, it is executed within the current shell process. Next, the
3302 command name is checked to see if it matches a user defined function. If it
3303 does, the positional parameters are saved and then reset to the arguments of
3304 the function call. A function is also executed in the current shell process.
3305 When the function completes or issues a return, the positional parameter list
3306 is restored. For functions defined with the \fBfunction\fR \fBname\fR syntax,
3307 any trap set on \fBEXIT\fR within the function is executed. The exit value of a
3308 function is the value of the last command executed. If a command name is not a
3309 special built-in command or a user defined function, but it is one of the
3310 built-in commands, it is executed in the current shell process.
3311 .sp
3312 .LP
3313 The shell variable \fBPATH\fR defines the search path for the directory
3314 containing the command. Alternative directory names are separated by a colon
3315 (\fB:\fR). The default path is \fB/bin:/usr/bin:\fR, specifying \fB/bin\fR,
3316 \fB/usr/bin\fR, and the current directory in that order. The current directory
3317 can be specified by two or more adjacent colons, or by a colon at the beginning
3318 or end of the path list. If the command name contains a slash (\fB/\fR), the
3319 search path is not used. Otherwise, each directory in the path is searched for
3320 an executable file of the specified name that is not a directory. If found, and
3321 if the shell determines that there is a built-in version of a command
3322 corresponding to a specified pathname, this built-in is invoked in the current
3323 process. If found, and this directory is also contained in the value of the
3324 \fBFPATH\fR variable, then this file is loaded into the current shell
3325 environment as if it were the argument to the . command except that only preset
3326 aliases are expanded, and a function of the specified name is executed as
3327 described in this manual page. If not found, and the file \fB\&.paths\fR is
3328 found, and this file contains a line of the form \fBFPATH=\fR\fIpath\fR where
3329 \fIpath\fR is an existing directory, and this directory contains a file of the
3330 specified name, then this file is loaded into the current shell environment as
3331 if it were the argument to the \fB\&. special\fR built-in command and a
3332 function of the specified name is executed. Otherwise, if found, a process is
3333 created and an attempt is made to execute the command using \fBexec\fR(2).
3334 .sp
3335 .LP
3336 When an executable is found, the directory where it is found in is searched for
3337 a file named \fB\&.paths\fR. If this file is found and it contains a line of
3338 the form \fBBUILTIN_LIB=\fR\fIvalue\fR, the library named by \fIvalue\fR is
3339 searched for as if it were an option argument to \fBbuiltin -f\fR, and if it
3340 contains a built-in of the specified name this is executed instead of a command
3341 by this name. Otherwise, if this file is found and it contains a line of the
3342 form \fIname\fR\fB=\fR\fIvalue\fR in the first or second line, then the
3343 environment variable \fIname\fR is modified by prepending the directory
3344 specified by \fIvalue\fR to the directory list. If \fIvalue\fR is not an
3345 absolute directory, then it specifies a directory relative to the directory
3346 that the executable was found. If the environment variable \fIname\fR does not
3347 already exist it is added to the environment list for the specified command.
3348 .sp
3349 .LP
3350 If the file has execute permission but is not an \fBa.out\fR file, it is
3351 assumed to be a file containing shell commands. A separate shell is spawned to
3352 read it. All non-exported variables are removed in this case. If the shell
3353 command file doesn't have read permission, and/or if the \fBsetuid\fR and
3354 \fBsetgid\fR bits are set on the file, then the shell executes an agent whose
3355 job it is to set up the permissions and execute the shell with the shell
3356 command file passed down as an open file. A parenthesized command is executed
3357 in a sub-shell without removing non-exported variables.
3358 .SS "Command Re-entry"
3359 .LP
3360 The text of the last \fBHISTSIZE\fR (default 512) commands entered from a
3361 terminal device is saved in a history file. The file \fB$HOME/.sh_history\fR is
3362 used if the \fBHISTFILE\fR variable is not set or if the file it names is not
3363 writable. A shell can access the commands of all interactive shells which use
3364 the same named \fBHISTFILE\fR. The built-in command \fBhist\fR is used to list
3365 or edit a portion of this file. The portion of the file to be edited or listed
3366 can be selected by number or by giving the first character or characters of the
3367 command. A single command or range of commands can be specified. If you do not
3368 specify an editor program as an argument to \fBhist\fR then the value of the
3369 variable \fBHISTEDIT\fR is used. If \fBHISTEDIT\fR is unset, the obsolete
3370 variable \fBFCEDIT\fR is used. If \fBFCEDIT\fR is not defined, then
3371 \fB/bin/ed\fR is used. The edited commands are printed and executed again upon
3372 leaving the editor unless you quit without writing. The \fB-s\fR option (and in
3373 obsolete versions, the editor name \fB-\fR) is used to skip the editing phase
3374 and to re-execute the command. In this case a substitution parameter of the
3375 form \fIold\fR\fB=\fR\fInew\fRcan be used to modify the command before
3376 execution. For example, with the preset alias \fBr\fR, which is aliased to
3377 \fB\&'hist -s'\fR, typing \fB`r bad=good c'\fR re-executes the most recent
3378 command which starts with the letter \fBc\fR, replacing the first occurrence of
3379 the string bad with the string good.
3380 .SS "Inline Editing Options"
3381 .LP
3382 Normally, each command line entered from a terminal device is simply typed
3383 followed by a NEWLINE (RETURN or LINE FEED). If either the \fBemacs\fR,
3384 \fBgmacs\fR, or \fBvi\fR option is active, the user can edit the command line.
3385 To be in either of these edit modes set the corresponding option. An editing
3386 option is automatically selected each time the \fBVISUAL\fR or \fBEDITOR\fR
3387 variable is assigned a value ending in either of these option names.
3388 .sp
3389 .LP
3390 The editing features require that the user's terminal accept RETURN as carriage
3391 return without line feed and that a SPACE must overwrite the current character
3392 on the screen.
3393 .sp
3394 .LP
3395 Unless the \fBmultiline\fR option is on, the editing modes implement a concept
3396 where the user is looking through a window at the current line. The window
3397 width is the value of \fBCOLUMNS\fR if it is defined, otherwise \fB80\fR. If
3398 the window width is too small to display the prompt and leave at least 8
3399 columns to enter input, the prompt is truncated from the left. If the line is
3400 longer than the window width minus two, a mark is displayed at the end of the
3401 window to notify the user. As the cursor moves and reaches the window
3416 and executable commands defined by the \fBPATH\fR variable that could match the
3417 partial word is displayed. Otherwise, the list of files that match the
3418 specified word is displayed. If the partially entered word does not contain any
3419 file expansion characters, a \fB*\fR is appended before generating these lists.
3420 After displaying the generated list, the input line is redrawn. These
3421 operations are called command name listing and file name listing, respectively.
3422 There are additional operations, referred to as command name completion and
3423 file name completion, which compute the list of matching commands or files, but
3424 instead of printing the list, replace the current word with a complete or
3425 partial match. For file name completion, if the match is unique, a \fB/\fR is
3426 appended if the file is a directory and a space is appended if the file is not
3427 a directory. Otherwise, the longest common prefix for all the matching files
3428 replaces the word. For command name completion, only the portion of the file
3429 names after the last \fB/\fR are used to find the longest command prefix. If
3430 only a single name matches this prefix, then the word is replaced with the
3431 command name followed by a space. When using a \fBTAB\fR for completion that
3432 does not yield a unique match, a subsequent TAB provides a numbered list of
3433 matching alternatives. A specific selection can be made by entering the
3434 selection number followed by a TAB.
3435 .SS "Key Bindings"
3436 .LP
3437 The \fBKEYBD\fR trap can be used to intercept keys as they are typed and change
3438 the characters that are actually seen by the shell. This trap is executed after
3439 each character (or sequence of characters when the first character is ESC) is
3440 entered while reading from a terminal.
3441 .sp
3442 .LP
3443 The variable \fB\&.sh.edchar\fR contains the character or character sequence
3444 which generated the trap. Changing the value of \fB\&.sh.edchar\fR in the trap
3445 action causes the shell to behave as if the new value were entered from the
3446 keyboard rather than the original value. The variable \fB\&.sh.edcol\fR is set
3447 to the input column number of the cursor at the time of the input. The variable
3448 \fB\&.sh.edmode\fR is set to \fBESC\fR when in \fBvi\fR insert mode and is null
3449 otherwise. By prepending \fB${.sh.editmode}\fR to a value assigned to
3450 \fB\&.sh.edchar\fR it causes the shell to change to control mode if it is not
3451 already in this mode.
3452 .sp
3453 .LP
3454 This trap is not invoked for characters entered as arguments to editing
3455 directives, or while reading input for a character search.
3456 .SS "\fBemacs\fR Editing Mode"
3457 .LP
3458 This mode is entered by enabling either the \fBemacs\fR or \fBgmacs\fR option.
3459 The only difference between these two modes is the way they handle \fB^T\fR. To
3460 edit, the user moves the cursor to the point needing correction and then
3461 inserts or deletes characters or words as needed. All the editing commands are
3462 control characters or escape sequences. The notation for control characters is
3463 caret (\fB^\fR) followed by the character.
3464 .sp
3465 .LP
3466 For example, \fB^F\fR is the notation for CTRL/F. This is entered by depressing
3467 \fBf\fR while holding down the CTRL (control) key. The SHIFT key is not
3468 depressed. (The notation \fB^?\fR indicates the DEL (delete) key.)
3469 .sp
3470 .LP
3471 The notation for escape sequences is \fBM-\fR followed by a character. For
3472 example, \fBM-f\fR (pronounced \fBMeta f\fR) is entered by depressing ESC
3473 (\fBASCII 033\fR) followed by \fBf\fR. \fBM-F\fR is the notation for ESC
3474 followed by \fBF\fR.
3475 .sp
3476 .LP
3477 All edit commands operate from any place on the line, not just at the
3478 beginning. The RETURN or the LINE FEED key is not entered after edit commands
3479 except when noted.
3480 .sp
3481 .ne 2
3482 .na
3483 \fB\fB^F\fR\fR
3484 .ad
3485 .RS 13n
3486 Move the cursor forward (right) one character.
3487 .RE
3488
3489 .sp
3490 .ne 2
3491 .na
3492 \fB\fBM-[C\fR\fR
3493 .ad
3494 .RS 13n
3495 Move the cursor forward (right) one character.
3496 .RE
3497
3498 .sp
3499 .ne 2
3500 .na
3501 \fB\fBM-f\fR\fR
3502 .ad
3503 .RS 13n
3504 Move the cursor forward one word. The \fBemacs\fR editor's idea of a word is a
3505 string of characters consisting of only letters, digits and underscores.
3506 .RE
3507
3508 .sp
3509 .ne 2
3510 .na
3511 \fB\fB^B\fR\fR
3512 .ad
3513 .RS 13n
3514 Move the cursor backward (left) one character.
3515 .RE
3516
3517 .sp
3518 .ne 2
3519 .na
3520 \fB\fBM-[D\fR\fR
3521 .ad
3522 .RS 13n
3523 Move the cursor backward (left) one character.
3524 .RE
3525
3526 .sp
3527 .ne 2
3528 .na
3529 \fB\fBM-b\fR\fR
3530 .ad
3531 .RS 13n
3532 Move the cursor backward one word.
3533 .RE
3534
3535 .sp
3536 .ne 2
3537 .na
3538 \fB\fB^A\fR\fR
3539 .ad
3540 .RS 13n
3541 Move the cursor to the beginning of the line.
3542 .RE
3543
3544 .sp
3545 .ne 2
3546 .na
3547 \fB\fBM-[H\fR\fR
3548 .ad
3549 .RS 13n
3550 Move the cursor to the beginning of the line.
3551 .RE
3552
3553 .sp
3554 .ne 2
3555 .na
3556 \fB\fB^E\fR\fR
3557 .ad
3558 .RS 13n
3559 Move the cursor to the end of the line.
3560 .RE
3561
3562 .sp
3563 .ne 2
3564 .na
3565 \fB\fBM-[Y\fR\fR
3566 .ad
3567 .RS 13n
3568 Move the cursor to the end of line.
3569 .RE
3570
3571 .sp
3572 .ne 2
3573 .na
3574 \fB\fB^]\fR\fIchar\fR\fR
3575 .ad
3576 .RS 13n
3577 Move the cursor forward to the character \fIchar\fR on the current line.
3578 .RE
3579
3580 .sp
3581 .ne 2
3582 .na
3583 \fB\fBM-^]\fR\fIchar\fR\fR
3584 .ad
3585 .RS 13n
3586 Move the cursor backwards to the character \fIchar\fR on the current line.
3587 .RE
3588
3589 .sp
3590 .ne 2
3591 .na
3592 \fB\fB^X^X\fR\fR
3593 .ad
3594 .RS 13n
3595 Interchange the cursor and the mark.
3596 .RE
3597
3598 .sp
3599 .ne 2
3600 .na
3601 \fB\fIerase\fR\fR
3602 .ad
3603 .RS 13n
3604 Delete the previous character. The user-defined erase character is defined by
3605 the \fBstty\fR(1) command, and is usually \fB^H\fR or \fB#\fR.
3606 .RE
3607
3608 .sp
3609 .ne 2
3610 .na
3611 \fB\fIlnext\fR\fR
3612 .ad
3613 .RS 13n
3614 Removes the next character's editing features. The user-defined literal next
3615 character is defined by the \fBstty\fR(1) command, or is \fB^V\fR if not
3616 defined.
3617 .RE
3618
3619 .sp
3620 .ne 2
3621 .na
3622 \fB\fB^D\fR\fR
3623 .ad
3624 .RS 13n
3625 Delete the current character.
3626 .RE
3627
3628 .sp
3629 .ne 2
3630 .na
3631 \fB\fBM-d\fR\fR
3632 .ad
3633 .RS 13n
3634 Delete the current word.
3635 .RE
3636
3637 .sp
3638 .ne 2
3639 .na
3640 \fB\fBM-^H\fR\fR
3641 .ad
3642 .RS 13n
3643 MetaBACKSPACE. Delete the previous word.
3644 .RE
3645
3646 .sp
3647 .ne 2
3648 .na
3649 \fB\fBM-h\fR\fR
3650 .ad
3651 .RS 13n
3652 Delete the previous word.
3653 .RE
3654
3655 .sp
3656 .ne 2
3657 .na
3658 \fB\fBM-^?\fR\fR
3659 .ad
3660 .RS 13n
3661 MetaDEL. Delete the previous word. If your interrupt character is \fB^?\fR
3662 (DEL, the default), this command does not work.
3663 .RE
3664
3665 .sp
3666 .ne 2
3667 .na
3668 \fB\fB^T\fR\fR
3669 .ad
3670 .RS 13n
3671 Transpose the current character with the previous character, and advance the
3672 cursor in \fBemacs\fR mode. Transpose two previous characters in \fBgmacs\fR
3673 mode.
3674 .RE
3675
3676 .sp
3677 .ne 2
3678 .na
3679 \fB\fB^C\fR\fR
3680 .ad
3681 .RS 13n
3682 Capitalize the current character.
3683 .RE
3684
3685 .sp
3686 .ne 2
3687 .na
3688 \fB\fBM-c\fR\fR
3689 .ad
3690 .RS 13n
3691 Capitalize the current word.
3692 .RE
3693
3694 .sp
3695 .ne 2
3696 .na
3697 \fB\fBM-l\fR\fR
3698 .ad
3699 .RS 13n
3700 Change the current word to lower case.
3701 .RE
3702
3703 .sp
3704 .ne 2
3705 .na
3706 \fB\fB^K\fR\fR
3707 .ad
3708 .RS 13n
3709 Delete from the cursor to the end of the line. If preceded by a numerical
3710 parameter whose value is less than the current cursor position, delete from
3711 specified position up to the cursor. If preceded by a numerical parameter whose
3712 value is greater than the current cursor position, then delete from cursor up
3713 to specified cursor position.
3714 .RE
3715
3716 .sp
3717 .ne 2
3718 .na
3719 \fB\fB^W\fR\fR
3720 .ad
3721 .RS 13n
3722 Kill from the cursor to the mark.
3723 .RE
3724
3725 .sp
3726 .ne 2
3727 .na
3728 \fB\fBM-p\fR\fR
3729 .ad
3730 .RS 13n
3731 Push the region from the cursor to the mark on the stack.
3732 .RE
3733
3734 .sp
3735 .ne 2
3736 .na
3737 \fB\fIkill\fR\fR
3738 .ad
3739 .RS 13n
3740 Kill the entire current line. The user-defined kill character is defined by the
3741 \fBstty\fR(1) command, usually a \fB^G\fR or \fB@\fR. If two kill characters
3742 are entered in succession, all kill characters from then on cause a line feed.
3743 This is useful when using paper terminals.
3744 .RE
3745
3746 .sp
3747 .ne 2
3748 .na
3749 \fB\fB^Y\fR\fR
3750 .ad
3751 .RS 13n
3752 Restore the last item removed from line. Yank the item back to the line.
3753 .RE
3754
3755 .sp
3756 .ne 2
3757 .na
3758 \fB\fB^L\fR\fR
3759 .ad
3760 .RS 13n
3761 Line feed and print the current line.
3762 .RE
3763
3764 .sp
3765 .ne 2
3766 .na
3767 \fB\fBM-^L\fR\fR
3768 .ad
3769 .RS 13n
3770 Clear the screen.
3771 .RE
3772
3773 .sp
3774 .ne 2
3775 .na
3776 \fB\fB^@\fR\fR
3777 .ad
3778 .RS 13n
3779 Null character. Set mark.
3780 .RE
3781
3782 .sp
3783 .ne 2
3784 .na
3785 \fB\fBM-\fR\fIspace\fR\fR
3786 .ad
3787 .RS 13n
3788 MetaSPACE. Set the mark.
3789 .RE
3790
3791 .sp
3792 .ne 2
3793 .na
3794 \fB\fB^J\fR\fR
3795 .ad
3796 .RS 13n
3797 New line. Execute the current line.
3798 .RE
3799
3800 .sp
3801 .ne 2
3802 .na
3803 \fB\fB^M\fR\fR
3804 .ad
3805 .RS 13n
3806 Return. Execute the current line.
3807 .RE
3808
3809 .sp
3810 .ne 2
3811 .na
3812 \fB\fBEOF\fR\fR
3813 .ad
3814 .RS 13n
3815 End-of-file character, normally \fB^D\fR, is processed as an \fBend-of-file\fR
3816 only if the current line is null.
3817 .RE
3818
3819 .sp
3820 .ne 2
3821 .na
3822 \fB\fB^P\fR\fR
3823 .ad
3824 .RS 13n
3825 Fetch the previous command. Each time \fB^P\fR is entered the previous command
3826 back in time is accessed. Moves back one line when it is not on the first line
3827 of a multi-line command.
3828 .RE
3829
3830 .sp
3831 .ne 2
3832 .na
3833 \fB\fBM-[A\fR\fR
3834 .ad
3835 .RS 13n
3836 Equivalent to \fB^P\fR.
3837 .RE
3838
3839 .sp
3840 .ne 2
3841 .na
3842 \fB\fBM-<\fR\fR
3843 .ad
3844 .RS 13n
3845 Fetch the least recent (oldest) history line.
3846 .RE
3847
3848 .sp
3849 .ne 2
3850 .na
3851 \fB\fBM->\fR\fR
3852 .ad
3853 .RS 13n
3854 Fetch the most recent (youngest) history line.
3855 .RE
3856
3857 .sp
3858 .ne 2
3859 .na
3860 \fB\fB^N\fR\fR
3861 .ad
3862 .RS 13n
3863 Fetch the next command line. Each time \fB^N\fR is entered the next command
3864 line forward in time is accessed.
3865 .RE
3866
3867 .sp
3868 .ne 2
3869 .na
3870 \fB\fBM-[B\fR\fR
3871 .ad
3872 .RS 13n
3873 Equivalent to \fB^N\fR.
3874 .RE
3875
3876 .sp
3877 .ne 2
3878 .na
3879 \fB\fB^R\fR\fIstring\fR\fR
3880 .ad
3881 .RS 13n
3882 Reverse search history for a previous command line containing \fIstring\fR. If
3883 a parameter of zero is specified, the search is forward. \fIstring\fR is
3884 terminated by a RETURN or NEWLINE. If string is preceded by a \fB^\fR, the
3885 matched line must begin with \fIstring\fR. If \fIstring\fR is omitted, then the
3886 next command line containing the most recent \fIstring\fR is accessed. In this
3887 case a parameter of zero reverses the direction of the search.
3888 .RE
3889
3890 .sp
3891 .ne 2
3892 .na
3893 \fB\fB^O\fR\fR
3894 .ad
3895 .RS 13n
3896 Operate. Execute the current line and fetch the next line relative to current
3897 line from the history file.
3898 .RE
3899
3900 .sp
3901 .ne 2
3902 .na
3903 \fB\fBM-\fR\fIdigits\fR\fR
3904 .ad
3905 .RS 13n
3906 Escape. Define numeric parameter. The digits are taken as a parameter to the
3907 next command. The commands that accept a parameter are: \fB^F\fR, \fB^B\fR,
3908 \fBERASE\fR, \fB^C\fR, \fB^D\fR, \fB^K\fR, \fB^R\fR, \fB^P\fR, \fB^N\fR,
3909 \fB^]\fR, \fBM-.\fR, \fBM-\fR, \fBM-^]\fR, \fBM-_\fR, \fBM-=\fR, \fBM-b\fR,
3910 \fBM-c\fR, \fBM-d\fR, \fBM-f\fR, \fBM-h\fR, \fBM-l\fR, and \fBM-^H\fR.
3911 .RE
3912
3913 .sp
3914 .ne 2
3915 .na
3916 \fB\fBM-\fR\fIletter\fR\fR
3917 .ad
3918 .RS 13n
3919 Soft-key. Search the alias list for an alias by the name \fIletter\fR. If an
3920 alias of \fIletter\fR is defined, insert its value on the input queue.
3921 \fIletter\fR must not be one of the metafunctions in this section.
3922 .RE
3923
3924 .sp
3925 .ne 2
3926 .na
3927 \fB\fBM-[\fR\fIletter\fR\fR
3928 .ad
3929 .RS 13n
3930 Soft key. Search the alias list for an alias by the name \fIletter\fR. If an
3931 alias of this name is defined, insert its value on the input queue. This can be
3932 used to program function keys on many terminals.
3933 .RE
3934
3935 .sp
3936 .ne 2
3937 .na
3938 \fB\fBM-.\fR\fR
3939 .ad
3940 .RS 13n
3941 The last word of the previous command is inserted on the line. If preceded by a
3942 numeric parameter, the value of this parameter determines which word to insert
3943 rather than the last word.
3944 .RE
3945
3946 .sp
3947 .ne 2
3948 .na
3949 \fB\fBM-_\fR\fR
3950 .ad
3951 .RS 13n
3952 Same as \fBM-.\fR.
3953 .RE
3954
3955 .sp
3956 .ne 2
3957 .na
3958 \fB\fBM-*\fR\fR
3959 .ad
3960 .RS 13n
3961 Attempt filename generation on the current word. As asterisk is appended if the
3962 word does not match any file or contain any special pattern characters.
3963 .RE
3964
3965 .sp
3966 .ne 2
3967 .na
3968 \fB\fBM-\fRESC\fR
3969 .ad
3970 .RS 13n
3971 Command or file name completion as described in this manual page.
3972 .RE
3973
3974 .sp
3975 .ne 2
3976 .na
3977 \fB\fB^I\fRTAB\fR
3978 .ad
3979 .RS 13n
3980 Attempts command or file name completion as described in this manual page. If a
3981 partial completion occurs, repeating this behaves as if \fBM-=\fR were entered.
3982 If no match is found or entered after SPACE, a TAB is inserted.
3983 .RE
3984
3985 .sp
3986 .ne 2
3987 .na
3988 \fB\fBM-=\fR\fR
3989 .ad
3990 .RS 13n
3991 If not preceded by a numeric parameter, generates the list of matching commands
3992 or file names as described in this manual page. Otherwise, the word under the
3993 cursor is replaced by the item corresponding to the value of the numeric
3994 parameter from the most recently generated command or file list. If the cursor
3995 is not on a word, the word is inserted instead.
3996 .RE
3997
3998 .sp
3999 .ne 2
4000 .na
4001 \fB\fB^U\fR\fR
4002 .ad
4003 .RS 13n
4004 Multiply parameter of next command by \fB4\fR.
4005 .RE
4006
4007 .sp
4008 .ne 2
4009 .na
4010 \fB\fB\e\fR\fR
4011 .ad
4012 .RS 13n
4013 Escape the next character. Editing characters, the user's erase, kill and
4014 interrupt (normally \fB^?\fR) characters can be entered in a command line or in
4015 a search string if preceded by a \fB\e\fR\&. The \fB\e\fR removes the next
4016 character's editing features, if any.
4017 .RE
4018
4019 .sp
4020 .ne 2
4021 .na
4022 \fB\fBM-^V\fR\fR
4023 .ad
4024 .RS 13n
4025 Display the version of the shell.
4026 .RE
4027
4028 .sp
4029 .ne 2
4030 .na
4031 \fB\fBM-#\fR\fR
4032 .ad
4033 .RS 13n
4034 If the line does not begin with a \fB#\fR, a \fB#\fR is inserted at the
4035 beginning of the line and after each NEWLINE, and the line is entered. This
4036 causes a comment to be inserted in the history file. If the line begins with a
4037 \fB#\fR, the \fB#\fR is deleted and one \fB#\fR after each NEWLINE is also
4038 deleted.
4039 .RE
4040
4041 .SS "\fBvi\fR Editing Mode"
4042 .LP
4043 There are two typing modes. Initially, when you enter a command you are in the
4044 input mode. To edit, the user enters control mode by typing ESC (033) and moves
4045 the cursor to the point needing correction and then inserts or deletes
4046 characters or words as needed. Most control commands accept an optional repeat
4047 \fIcount\fR prior to the command.
4048 .sp
4049 .LP
4050 When in vi mode on most systems, canonical processing is initially enabled and
4051 the command is echoed again if the speed is 1200 baud or greater and it
4052 contains any control characters or less than one second has elapsed since the
4053 prompt was printed. The ESC character terminates canonical processing for the
4054 remainder of the command and the user can then modify the command line. This
4055 scheme has the advantages of canonical processing with the type-ahead echoing
4056 of raw mode.
4057 .sp
4058 .LP
4059 If the option \fBviraw\fR is also set, the terminal is always have canonical
4060 processing disabled. This mode is implicit for systems that do not support two
4061 alternate end of line delimiters, and might be helpful for certain terminals.
4062 .SS "Input Edit Commands"
4063 .LP
4064 By default the editor is in input mode.
4065 .sp
4066 .LP
4067 The following input edit commands are supported:
4068 .sp
4069 .ne 2
4070 .na
4071 \fBERASE\fR
4072 .ad
4073 .RS 10n
4074 User defined erase character as defined by the \fBstty\fR command, usually
4075 \fB^H\fR or \fB#\fR. Delete previous character.
4076 .RE
4077
4078 .sp
4079 .ne 2
4080 .na
4081 \fB\fB^W\fR\fR
4082 .ad
4083 .RS 10n
4084 Delete the previous blank separated word. On some systems the \fBviraw\fR
4085 option might be required for this to work.
4086 .RE
4087
4088 .sp
4089 .ne 2
4090 .na
4091 \fBEOF\fR
4092 .ad
4093 .RS 10n
4094 As the first character of the line causes the shell to terminate unless the
4095 \fBignoreeof\fR option is set. Otherwise this character is ignored.
4096 .RE
4097
4098 .sp
4099 .ne 2
4100 .na
4101 \fB\fIlnext\fR\fR
4102 .ad
4103 .RS 10n
4104 User defined literal next character as defined by the \fBstty\fR(1) or \fB^V\fR
4105 if not defined. Removes the next character's editing features, if any. On some
4106 systems the \fBviraw\fR option might be required for this to work.
4107 .RE
4108
4109 .sp
4110 .ne 2
4111 .na
4112 \fB\fB\e\fR\fR
4113 .ad
4114 .RS 10n
4115 Escape the next ERASE or KILL character.
4116 .RE
4117
4118 .sp
4119 .ne 2
4120 .na
4121 \fB\fB^I\fR TAB\fR
4122 .ad
4123 .RS 10n
4124 Attempts command or file name completion as described in this manual page and
4125 returns to input mode. If a partial completion occurs, repeating this behaves
4126 as if \fB=\fR were entered from control mode. If no match is found or entered
4127 after SPACE, a TAB is inserted.
4128 .RE
4129
4130 .SS "Motion Edit Commands"
4131 .LP
4132 The motion edit commands move the cursor.
4133 .sp
4134 .LP
4135 The following motion edit commands are supported:
4136 .sp
4137 .ne 2
4138 .na
4139 \fB\fB[\fR\fIcount\fR\fB]l\fR\fR
4140 .ad
4141 .RS 13n
4142 Move the cursor forward (right) one character.
4143 .RE
4144
4145 .sp
4146 .ne 2
4147 .na
4148 \fB\fB[\fR\fIcount\fR\fB][C\fR\fR
4149 .ad
4150 .RS 13n
4151 Move the cursor forward (right) one character.
4152 .RE
4153
4154 .sp
4155 .ne 2
4156 .na
4157 \fB\fB[\fR\fIcount\fR\fB]w\fR\fR
4158 .ad
4159 .RS 13n
4160 Move the cursor forward one alphanumeric word.
4161 .RE
4162
4163 .sp
4164 .ne 2
4165 .na
4166 \fB\fB[\fR\fIcount\fR\fB]W\fR\fR
4167 .ad
4168 .RS 13n
4169 Move the cursor to the beginning of the next word that follows a blank.
4170 .RE
4171
4172 .sp
4173 .ne 2
4174 .na
4175 \fB\fB[\fR\fIcount\fR\fB]e\fR\fR
4176 .ad
4177 .RS 13n
4178 Move the cursor to the end of the word.
4179 .RE
4180
4181 .sp
4182 .ne 2
4183 .na
4184 \fB\fB[\fR\fIcount\fR\fB]E\fR\fR
4185 .ad
4186 .RS 13n
4187 Move the cursor to the end of the current blank delimited word.
4188 .RE
4189
4190 .sp
4191 .ne 2
4192 .na
4193 \fB\fB[\fR\fIcount\fR\fB]h\fR\fR
4194 .ad
4195 .RS 13n
4196 Move the cursor backward (left) one character.
4197 .RE
4198
4199 .sp
4200 .ne 2
4201 .na
4202 \fB\fB[\fR\fIcount\fR\fB][D\fR\fR
4203 .ad
4204 .RS 13n
4205 Move the cursor backward (left) one character.
4206 .RE
4207
4208 .sp
4209 .ne 2
4210 .na
4211 \fB\fB[\fR\fIcount\fR\fB]b\fR\fR
4212 .ad
4213 .RS 13n
4214 Move the cursor backward one word.
4215 .RE
4216
4217 .sp
4218 .ne 2
4219 .na
4220 \fB\fB[\fR\fIcount\fR\fB]B\fR\fR
4221 .ad
4222 .RS 13n
4223 Move the cursor to the preceding blank separated word.
4224 .RE
4225
4226 .sp
4227 .ne 2
4228 .na
4229 \fB\fB[\fR\fIcount\fR\fB]|\fR\fR
4230 .ad
4231 .RS 13n
4232 Move the cursor to column \fIcount\fR.
4233 .RE
4234
4235 .sp
4236 .ne 2
4237 .na
4238 \fB\fB[\fR\fIcount\fR\fB]f\fR\fIc\fR\fR
4239 .ad
4240 .RS 13n
4241 Find the next character \fIc\fR in the current line.
4242 .RE
4243
4244 .sp
4245 .ne 2
4246 .na
4247 \fB\fB[\fR\fIcount\fR\fB]F\fR\fIc\fR\fR
4248 .ad
4249 .RS 13n
4250 Find the previous character \fIc\fR in the current line.
4251 .RE
4252
4253 .sp
4254 .ne 2
4255 .na
4256 \fB\fB[\fR\fIcount\fR\fB]t\fR\fIC\fR\fR
4257 .ad
4258 .RS 13n
4259 Equivalent to \fBf\fR followed by \fBh\fR.
4260 .RE
4261
4262 .sp
4263 .ne 2
4264 .na
4265 \fB\fB[\fR\fIcount\fR\fB]T\fR\fIc\fR\fR
4266 .ad
4267 .RS 13n
4268 Equivalent to \fBF\fR followed by \fBl\fR.
4269 .RE
4270
4271 .sp
4272 .ne 2
4273 .na
4274 \fB\fB[\fR\fIcount\fR\fB];\fR\fR
4275 .ad
4276 .RS 13n
4277 Repeat \fIcount\fR times the last single character find command: \fBf\fR,
4278 \fBF\fR, \fBt,\fR or \fBT\fR.
4279 .RE
4280
4281 .sp
4282 .ne 2
4283 .na
4284 \fB\fB[\fR\fIcount\fR\fB],\fR\fR
4285 .ad
4286 .RS 13n
4287 Reverse the last single character find command \fIcount\fR times.
4288 .RE
4289
4290 .sp
4291 .ne 2
4292 .na
4293 \fB\fB0\fR\fR
4294 .ad
4295 .RS 13n
4296 Move the cursor to the start of line.
4297 .RE
4298
4299 .sp
4300 .ne 2
4301 .na
4302 \fB\fB^\fR\fR
4303 .ad
4304 .RS 13n
4305 Move the cursor to start of line.
4306 .RE
4307
4308 .sp
4309 .ne 2
4310 .na
4311 \fB\fB[H\fR\fR
4312 .ad
4313 .RS 13n
4314 Move the cursor to the first non-blank character in the line.
4315 .RE
4316
4317 .sp
4318 .ne 2
4319 .na
4320 \fB\fB$\fR\fR
4321 .ad
4322 .RS 13n
4323 Move the cursor to the end of the line.
4324 .RE
4325
4326 .sp
4327 .ne 2
4328 .na
4329 \fB\fB[Y\fR\fR
4330 .ad
4331 .RS 13n
4332 Move the cursor to the end of the line.
4333 .RE
4334
4335 .sp
4336 .ne 2
4337 .na
4338 \fB\fB%\fR\fR
4339 .ad
4340 .RS 13n
4341 Moves to balancing \fB(\fR, \fB)\fR, \fB{\fR, \fB}\fR, \fB[\fR, or \fB]\fR. If
4342 cursor is not on one of the characters described in this section, the remainder
4343 of the line is searched for the first occurrence of one of the characters
4344 first.
4345 .RE
4346
4347 .SS "Search Edit Commands"
4348 .LP
4349 The search edit commands access your command history.
4350 .sp
4351 .LP
4352 The following search edit commands are supported:
4353 .sp
4354 .ne 2
4355 .na
4356 \fB\fB[\fR\fIcount\fR\fB]k\fR\fR
4357 .ad
4358 .RS 13n
4359 Fetch the previous command. Each time \fBk\fR is entered, the previous command
4360 back in time is accessed.
4361 .RE
4362
4363 .sp
4364 .ne 2
4365 .na
4366 \fB\fB[\fR\fIcount\fR\fB]-\fR\fR
4367 .ad
4368 .RS 13n
4369 Fetch the previous command. Each time \fBk\fR is entered, the previous command
4370 back in time is accessed.
4371 .sp
4372 Equivalent to \fBk\fR.
4373 .RE
4374
4375 .sp
4376 .ne 2
4377 .na
4378 \fB\fB[\fR\fIcount\fR\fB][A\fR\fR
4379 .ad
4380 .RS 13n
4381 Fetch the previous command. Each time \fBk\fR is entered, the previous command
4382 back in time is accessed.
4383 .sp
4384 Equivalent to \fBk\fR.
4385 .RE
4386
4387 .sp
4388 .ne 2
4389 .na
4390 \fB\fB[\fR\fIcount\fR\fB]j\fR\fR
4391 .ad
4392 .RS 13n
4393 Fetch the next command. Each time \fBj\fR is entered, the next command forward
4394 in time is accessed.
4395 .RE
4396
4397 .sp
4398 .ne 2
4399 .na
4400 \fB\fB[\fR\fIcount\fR\fB]+\fR\fR
4401 .ad
4402 .RS 13n
4403 Fetch the next command. Each time \fBj\fR is entered, the next command forward
4404 in time is accessed.
4405 .sp
4406 Equivalent to \fBj\fR.
4407 .RE
4408
4409 .sp
4410 .ne 2
4411 .na
4412 \fB\fB[\fR\fIcount\fR\fB][B\fR\fR
4413 .ad
4414 .RS 13n
4415 Fetch the next command. Each time \fBj\fR is entered, the next command forward
4416 in time is accessed.
4417 .sp
4418 Equivalent to \fBj\fR.
4419 .RE
4420
4421 .sp
4422 .ne 2
4423 .na
4424 \fB\fB[\fR\fIcount\fR\fB]G\fR\fR
4425 .ad
4426 .RS 13n
4427 Fetch command number \fIcount\fR. The default is the least recent history
4428 command.
4429 .RE
4430
4431 .sp
4432 .ne 2
4433 .na
4434 \fB\fB/\fR\fIstring\fR\fR
4435 .ad
4436 .RS 13n
4437 Search backward through history for a previous command containing \fIstring\fR.
4438 \fIstring\fR is terminated by a RETURN or NEWLINE. If string is preceded by a
4439 \fB^\fR, the matched line must begin with \fIstring\fR. If \fIstring\fR is
4440 null, the previous string is used.
4441 .RE
4442
4443 .sp
4444 .ne 2
4445 .na
4446 \fB\fB?\fR\fIstring\fR\fR
4447 .ad
4448 .RS 13n
4449 Search forward through history for a previous command containing \fIstring\fR.
4450 \fIstring\fR is terminated by a RETURN or NEWLINE. If string is preceded by a
4451 \fB^\fR, the matched line must begin with \fIstring\fR. If \fIstring\fR is
4452 null, the previous string is used.
4453 .sp
4454 Same as \fI/\fR except that search is in the forward direction.
4455 .RE
4456
4457 .sp
4458 .ne 2
4459 .na
4460 \fB\fBn\fR\fR
4461 .ad
4462 .RS 13n
4463 Search in the backwards direction for the next match of the last pattern to
4464 \fI/\fR or \fI?\fR commands.
4465 .RE
4466
4467 .sp
4468 .ne 2
4469 .na
4470 \fB\fBN\fR\fR
4471 .ad
4472 .RS 13n
4473 Search in the forward direction for next match of the last pattern to \fI/\fR
4474 or \fI?\fR.
4475 .RE
4476
4477 .SS "Text Modification Edit Commands"
4478 .LP
4479 The following commands modify the line:
4480 .sp
4481 .ne 2
4482 .na
4483 \fB\fBa\fR\fR
4484 .ad
4485 .RS 19n
4486 Enter input mode and enter text after the current character.
4487 .RE
4488
4489 .sp
4490 .ne 2
4491 .na
4492 \fB\fBA\fR\fR
4493 .ad
4494 .RS 19n
4495 Append text to the end of the line. Equivalent to \fB$a\fR.
4496 .RE
4497
4498 .sp
4499 .ne 2
4500 .na
4501 \fB\fB[\fR\fIcount\fR\fB]c\fR\fImotion\fR\fR
4502 .ad
4503 .br
4504 .na
4505 \fB\fBc[\fR\fIcount\fR\fB]\fR\fImotion\fR\fR
4506 .ad
4507 .RS 19n
4508 Delete current character through the character that \fImotion\fR would move the
4509 cursor to and enter input mode. If \fImotion\fR is \fBc\fR, the entire line is
4510 deleted and input mode entered.
4511 .RE
4512
4513 .sp
4514 .ne 2
4515 .na
4516 \fB\fBC\fR\fR
4517 .ad
4518 .RS 19n
4519 Delete the current character through the end of line and enter input mode.
4520 Equivalent to \fBc$\fR.
4521 .RE
4522
4523 .sp
4524 .ne 2
4525 .na
4526 \fB\fBS\fR\fR
4527 .ad
4528 .RS 19n
4529 Equivalent to \fBcc\fR.
4530 .RE
4531
4532 .sp
4533 .ne 2
4534 .na
4535 \fB\fB[\fR\fIcount\fR\fB]s\fR\fR
4536 .ad
4537 .RS 19n
4538 Replace characters under the cursor in input mode.
4539 .RE
4540
4541 .sp
4542 .ne 2
4543 .na
4544 \fB\fBD[\fR\fIcount\fR\fB]d\fR\fImotion\fR\fR
4545 .ad
4546 .RS 19n
4547 Delete the current character through the end of line. Equivalent to d$.
4548 .RE
4549
4550 .sp
4551 .ne 2
4552 .na
4553 \fB\fBd[\fR\fIcount\fR\fB]\fR\fImotion\fR\fR
4554 .ad
4555 .RS 19n
4556 Delete current character through the character that \fImotion\fR would move to.
4557 If \fImotion\fR is d , the entire line is deleted.
4558 .RE
4559
4560 .sp
4561 .ne 2
4562 .na
4563 \fB\fBi\fR\fR
4564 .ad
4565 .RS 19n
4566 Enter input mode and insert text before the current character.
4567 .RE
4568
4569 .sp
4570 .ne 2
4571 .na
4572 \fB\fBI\fR\fR
4573 .ad
4574 .RS 19n
4575 Insert text before the beginning of the line. Equivalent to \fB0i\fR.
4576 .RE
4577
4578 .sp
4579 .ne 2
4580 .na
4581 \fB\fB[\fR\fIcount\fR\fB]P\fR\fR
4582 .ad
4583 .RS 19n
4584 Place the previous text modification before the cursor.
4585 .RE
4586
4587 .sp
4588 .ne 2
4589 .na
4590 \fB\fB[\fR\fIcount\fR\fB]p\fR\fR
4591 .ad
4592 .RS 19n
4593 Place the previous text modification after the cursor.
4594 .RE
4595
4596 .sp
4597 .ne 2
4598 .na
4599 \fB\fBR\fR\fR
4600 .ad
4601 .RS 19n
4602 Enter input mode and replace characters on the screen with characters you type
4603 overlay fashion.
4604 .RE
4605
4606 .sp
4607 .ne 2
4608 .na
4609 \fB\fB[\fR\fIcount\fR\fB]r\fR\fIc\fR\fR
4610 .ad
4611 .RS 19n
4612 Replace the \fIcount\fR characters starting at the current cursor position with
4613 \fIc\fR, and advance the cursor.
4614 .RE
4615
4616 .sp
4617 .ne 2
4618 .na
4619 \fB\fB[\fR\fIcount\fR\fB]x\fR\fR
4620 .ad
4621 .RS 19n
4622 Delete current character.
4623 .RE
4624
4625 .sp
4626 .ne 2
4627 .na
4628 \fB\fB[\fIcount\fR]X\fR\fR
4629 .ad
4630 .RS 19n
4631 Delete preceding character.
4632 .RE
4633
4634 .sp
4635 .ne 2
4636 .na
4637 \fB\fB[\fIcount\fR].\fR\fR
4638 .ad
4639 .RS 19n
4640 Repeat the previous text modification command.
4641 .RE
4642
4643 .sp
4644 .ne 2
4645 .na
4646 \fB\fB[\fIcount\fR]~\fR\fR
4647 .ad
4648 .RS 19n
4649 Invert the case of the \fIcount\fR characters starting at the current cursor
4650 position and advance the cursor.
4651 .RE
4652
4653 .sp
4654 .ne 2
4655 .na
4656 \fB\fB[\fIcount\fR]_\fR\fR
4657 .ad
4658 .RS 19n
4659 Causes the \fIcount\fR word of the previous command to be appended and input
4660 mode entered. The last word is used if \fIcount\fR is omitted.
4661 .RE
4662
4663 .sp
4664 .ne 2
4665 .na
4666 \fB\fB*\fR\fR
4667 .ad
4668 .RS 19n
4669 Causes an \fB*\fR to be appended to the current word and file name generation
4670 attempted. If no match is found, it rings the bell. Otherwise, the word is
4671 replaced by the matching pattern and input mode is entered.
4672 .RE
4673
4674 .sp
4675 .ne 2
4676 .na
4677 \fB\fB\e\fR\fR
4678 .ad
4679 .RS 19n
4680 Command or file name completion as described in this manual page.
4681 .RE
4682
4683 .SS "Other Edit Commands"
4684 .LP
4685 The following miscellaneous edit commands are supported:
4686 .sp
4687 .ne 2
4688 .na
4689 \fB\fB[\fR\fIcount\fR\fB]y\fR\fImotion\fR\fR
4690 .ad
4691 .br
4692 .na
4693 \fB\fBy[\fR\fIcount\fR\fB]\fR\fImotion\fR\fR
4694 .ad
4695 .RS 18n
4696 Yank the current character through the character to which \fImotion\fR would
4697 move the cursor. Put the yanked characters in the delete buffer. The text and
4698 cursor position are unchanged.
4699 .RE
4700
4701 .sp
4702 .ne 2
4703 .na
4704 \fB\fByy\fR\fR
4705 .ad
4706 .RS 18n
4707 Yank the current line.
4708 .RE
4709
4710 .sp
4711 .ne 2
4712 .na
4713 \fB\fBY\fR\fR
4714 .ad
4715 .RS 18n
4716 Yank the current line from the current cursor location to the end of the line.
4717 Equivalent to \fBy$\fR.
4718 .RE
4719
4720 .sp
4721 .ne 2
4722 .na
4723 \fB\fBu\fR\fR
4724 .ad
4725 .RS 18n
4726 Undo the last text modifying command.
4727 .RE
4728
4729 .sp
4730 .ne 2
4731 .na
4732 \fB\fBU\fR\fR
4733 .ad
4734 .RS 18n
4735 Undo all the text modifying commands performed on current line.
4736 .RE
4737
4738 .sp
4739 .ne 2
4740 .na
4741 \fB\fB[\fR\fIcount\fR\fB]V\fR\fR
4742 .ad
4743 .RS 18n
4744 Return the command :
4745 .sp
4746 .in +2
4747 .nf
4748 hist -e ${VISUAL:-${EDITOR:-vi}} \fIcount\fR
4749 .fi
4750 .in -2
4751 .sp
4752
4753 in the input buffer. If \fIcount\fR is omitted, the current line is used.
4754 .RE
4755
4756 .sp
4757 .ne 2
4758 .na
4759 \fB\fB^L\fR\fR
4760 .ad
4761 .RS 18n
4762 Line feed and print the current line. This command only works in control mode.
4763 .RE
4764
4765 .sp
4766 .ne 2
4767 .na
4768 \fB\fB^J\fR\fR
4769 .ad
4770 .RS 18n
4771 New line. Execute the current line, regardless of mode.
4772 .RE
4773
4774 .sp
4775 .ne 2
4776 .na
4777 \fB\fB^M\fR\fR
4778 .ad
4779 .RS 18n
4780 Return. Execute the current line, regardless of mode.
4781 .RE
4782
4783 .sp
4784 .ne 2
4785 .na
4786 \fB\fB#\fR\fR
4787 .ad
4788 .RS 18n
4789 If the first character of the command is a \fB#\fR , delete this \fB#\fR and
4790 each \fB#\fR that follows a NEWLINE.
4791 .sp
4792 Otherwise, send the line after inserting a \fB#\fR in front of each line in the
4793 command.
4794 .sp
4795 This is command is useful for causing the current line to be inserted in the
4796 history as a comment and un-commenting previously commented commands in the
4797 history file.
4798 .RE
4799
4800 .sp
4801 .ne 2
4802 .na
4803 \fB\fB[\fR\fIcount\fR\fB]=\fR\fR
4804 .ad
4805 .RS 18n
4806 If \fIcount\fR is not specified, generate the list of matching commands or file
4807 names as described in this manual page.
4808 .sp
4809 Otherwise, replace the word at the current cursor location with the \fIcount\fR
4810 item from the most recently generated command or file list. If the cursor is
4811 not on a word, it is inserted after the current cursor location.
4812 .RE
4813
4814 .sp
4815 .ne 2
4816 .na
4817 \fB\fB@\fR\fIletter\fR\fR
4818 .ad
4819 .RS 18n
4820 Search your alias list for an alias by the name \fIletter\fR. If an alias of
4821 this name is defined, insert its value on the input queue for processing.
4822 .RE
4823
4824 .sp
4825 .ne 2
4826 .na
4827 \fB\fB^V\fR\fR
4828 .ad
4829 .RS 18n
4830 Display version of the shell.
4831 .RE
4832
4833 .SS "Built-in Commands"
4834 .LP
4835 The following simple-commands are executed in the shell process. Input and
4836 output redirection is permitted. Unless otherwise indicated, the output is
4837 written on file descriptor \fB1\fR and the exit status, when there is no syntax
4838 error, is \fB0\fR. Except for \fB:\fR, \fBtrue\fR, \fBfalse\fR, \fBecho\fR,
4839 \fBnewgrp\fR, and \fBlogin\fR, all built-in commands accept \fB--\fR to
4840 indicate the end of options. They also interpret the option \fB--man\fR as a
4841 request to display the manual page onto standard error and \fB-?\fR as a help
4842 request which prints a usage message on standard error.
4843 .sp
4844 .LP
4845 Commands that are preceded by one or two \fB++\fR symbols are special built-in
4846 commands and are treated specially in the following ways:
4847 .RS +4
4848 .TP
4849 1.
4850 Variable assignment lists preceding the command remain in effect when the
4851 command completes.
4852 .RE
4853 .RS +4
4854 .TP
4859 .TP
4860 3.
4861 Errors cause a script that contains them to abort.
4862 .RE
4863 .RS +4
4864 .TP
4865 4.
4866 They are not valid function names.
4867 .RE
4868 .RS +4
4869 .TP
4870 5.
4871 Words following a command preceded by \fB++\fR that are in the format of a
4872 variable assignment are expanded with the same rules as a variable assignment.
4873 This means that tilde substitution is performed after the \fB=\fR sign and
4874 field splitting and file name generation are not performed.
4875 .RE
4876 .sp
4877 .ne 2
4878 .na
4879 \fB\fB+ : [\fR\fIarg ...\fR\fB]\fR\fR
4880 .ad
4881 .sp .6
4882 .RS 4n
4883 The command only expands parameters.
4884 .RE
4885
4886 .sp
4887 .ne 2
4888 .na
4889 \fB\fB+ .\fR \fIname\fR \fB[\fR\fIarg ...\fR\fB]\fR\fR
4890 .ad
4891 .sp .6
4892 .RS 4n
4893 If \fIname\fR is a function defined with the \fBfunction\fR \fBname\fR reserved
4894 word syntax, the function is executed in the current environment (as if it had
4895 been defined with the \fIname()\fR syntax.) Otherwise if \fIname\fR refers to a
4896 file, the file is read in its entirety and the commands are executed in the
4897 current shell environment. The search path specified by PATH is used to find
4898 the directory containing the file. If any arguments \fIarg\fR are specified,
4899 they become the positional parameters while processing the . command and the
4900 original positional parameters are restored upon completion. Otherwise the
4901 positional parameters are unchanged. The exit status is the exit status of the
4902 last command executed.
4903 .RE
4904
4905 .sp
4906 .ne 2
4907 .na
4908 \fB\fB++ alias [\fR\fB-ptx\fR\fB] [\fR\fIname\fR\fB[
4909 =\fR\fIvalue\fR\fB]] ...\fR\fR
4910 .ad
4911 .sp .6
4912 .RS 4n
4913 \fBalias\fR with no arguments prints the list of aliases in the form
4914 \fIname\fR\fB=\fR\fIvalue\fR on standard output. The \fB-p\fR option causes the
4915 word alias to be inserted before each one. When one or more arguments are
4916 specified, an \fIalias\fR is defined for each \fIname\fR whose \fIvalue\fR is
4917 specified. A trailing space in \fIvalue\fR causes the next word to be checked
4918 for alias substitution. The obsolete \fB-t\fR option is used to set and list
4919 tracked aliases. The value of a tracked alias is the full pathname
4920 corresponding to the specified \fIname\fR. The value becomes undefined when the
4921 value of \fBPATH\fR is reset but the alias remains tracked. Without the
4922 \fB-t\fR option, for each \fIname\fR in the argument list for which no
4923 \fIvalue\fR is specified, the name and value of the alias is printed. The
4924 obsolete -x option has no effect. The exit status is \fBnon-zero\fR if a
4925 \fIname\fR is specified, but no value, and no alias has been defined for the
4926 \fIname\fR.
4927 .RE
4928
4929 .sp
4930 .ne 2
4931 .na
4932 \fB\fBbg [\fR \fIjob\fR\fB\&...]\fR\fR
4933 .ad
4934 .sp .6
4935 .RS 4n
4936 This command is only on systems that support job control. Puts each specified
4937 \fIjob\fR into the background. The current job is put in the background if
4938 \fIjob\fR is not specified. See the \fBJobs\fR section of this manual page for
4939 a description of the format of \fIjob\fR.
4940 .RE
4941
4942 .sp
4943 .ne 2
4944 .na
4945 \fB\fB+ break [\fR\fIn\fR\fB]\fR\fR
4946 .ad
4947 .sp .6
4948 .RS 4n
4949 Exit from the enclosing \fBfor\fR, \fBwhile\fR, \fBuntil\fR, or \fBselect\fR
4950 loop, if any. If \fIn\fR is specified, then break \fIn\fR levels.
4951 .RE
4952
4953 .sp
4954 .ne 2
4955 .na
4956 \fB\fBbuiltin [\fR\fB-ds\fR \fB] [\fR\fB-f\fR \fIfile\fR\fB]
4957 [\fR\fIname ...\fR\fB]\fR\fR
4958 .ad
4959 .sp .6
4960 .RS 4n
4961 If \fIname\fR is not specified, and no \fB-f\fR option is specified, the
4962 built-ins are printed on standard output. The \fB-s\fR option prints only the
4963 special built-ins. Otherwise, each \fIname\fR represents the pathname whose
4964 basename is the name of the built-in. The entry point function name is
4965 determined by prepending \fIb\fR to the built-in name. The ISO C/C++ prototype
4966 is \fBb\fR\fImycommand(int argc, char *argv[], void *context)\fR for the
4967 built-in command \fImycommand\fR where \fIargv\fR is an array of \fIargc\fR
4968 elements and \fIcontext\fR is an optional pointer to a \fBShell_t\fR structure
4969 as described in \fB<ast/shell.h>\fR Special built-ins cannot be bound to a
4970 pathname or deleted. The \fB-d\fR option deletes each of the specified
4971 built-ins. On systems that support dynamic loading, the \fB-f\fR option names a
4972 shared library containing the code for built-ins. The shared library prefix
4973 and/or suffix, which depend on the system, can be omitted. Once a library is
4974 loaded, its symbols become available for subsequent invocations of
4975 \fBbuiltin\fR. Multiple libraries can be specified with separate invocations of
4976 the \fBbuiltin\fR command. Libraries are searched in the reverse order in which
4977 they are specified. When a library is loaded, it looks for a function in the
4978 library whose name is \fBlib_init()\fR and invokes this function with an
4979 argument of \fB0\fR.
4980 .RE
4981
4982 .sp
4983 .ne 2
4984 .na
4985 \fB\fBcd\fR \fB[\fR\fB-LP\fR\fB] [\fR\fIarg\fR\fB]\fR\fR
4986 .ad
4987 .br
4988 .na
4989 \fB\fBcd\fR \fB[\fR\fB-LP\fR\fB]\fR \fIold\fR \fInew\fR\fR
4990 .ad
4991 .sp .6
4992 .RS 4n
4993 This command has two forms.
4994 .sp
4995 In the first form it changes the current directory to \fIarg\fR. If \fIarg\fR
4996 is a \fB-\fR, the directory is changed to the previous directory. The shell
4997 variable \fBHOME\fR is the default \fIarg\fR. The variable \fBPWD\fR is set to
4998 the current directory. The shell variable \fBCDPATH\fR defines the search path
4999 for the directory containing \fIarg\fR. Alternative directory names are
5000 separated by a colon (\fB:\fR). The default path is \fBNULL\fR (specifying the
5001 current directory). The current directory is specified by a null path name,
5002 which can appear immediately after the equal sign or between the colon
5003 delimiters anywhere else in the path list. If \fIarg\fR begins with a \fB/\fR,
5004 the search path is not used. Otherwise, each directory in the path is searched
5005 for \fIarg\fR.
5006 .sp
5007 The second form of \fBcd\fR substitutes the string \fInew\fR for the string
5008 \fIold\fR in the current directory name, \fBPWD\fR, and tries to change to this
5009 new directory. By default, symbolic link names are treated literally when
5010 finding the directory name. This is equivalent to the \fB-L\fR option. The
5011 \fB-P\fR option causes symbolic links to be resolved when determining the
5012 directory. The last instance of \fB-L\fR or \fB-P\fR on the command line
5013 determines which method is used. The \fBcd\fR command cannot be executed by
5014 \fBrksh93\fR.
5015 .RE
5016
5017 .sp
5018 .ne 2
5019 .na
5020 \fB\fBcommand\fR \fB[\fR\fB-pvVx\fR\fB]\fR \fIname\fR
5021 \fB[\fR\fIarg ...\fR\fB]\fR\fR
5022 .ad
5023 .sp .6
5024 .RS 4n
5025 Without the \fB-v\fR or \fB-V\fR options, executes \fIname\fR with the
5026 arguments specified by \fIarg\fR.
5027 .sp
5028 The \fB-p\fR option causes a default path to be searched rather than the one
5029 defined by the value of \fBPATH\fR. Functions are not searched when finding
5030 \fIname\fR. In addition, if \fIname\fR refers to a special built-in, none of
5031 the special properties associated with the leading daggers are honored. For
5032 example, the predefined alias \fBredirect='command exec'\fR prevents a script
5033 from terminating when an invalid redirection is specified.
5034 .sp
5035 With the \fB-x\fR option, if command execution would result in a failure
5036 because there are too many arguments, \fBerrno E2BIG\fR, the shell invokes
5037 command \fIname\fR multiple times with a subset of the arguments on each
5038 invocation. Arguments that occur prior to the first word that expands to
5039 multiple arguments and after the last word that expands to multiple arguments
5040 are passed on each invocation. The exit status is the maximum invocation exit
5041 status.
5042 .sp
5043 With the \fB-v\fR option, \fBcommand\fR is equivalent to the built-in
5044 \fBwhence\fR command described in this section. The \fB-V\fR option causes
5045 \fBcommand\fR to act like \fBwhence -v\fR.
5046 .RE
5047
5048 .sp
5049 .ne 2
5050 .na
5051 \fB\fB+continue\fR \fB[\fR\fIn\fR\fB]\fR\fR
5052 .ad
5053 .sp .6
5054 .RS 4n
5055 Resumes the next iteration of the enclosing \fBfor\fR, \fBwhile\fR,
5056 \fBuntil\fR, or \fBselect\fR loop. If \fIn\fR is specified, then resume at the
5057 \fIn\fRth enclosing loop.
5058 .RE
5059
5060 .sp
5061 .ne 2
5062 .na
5063 \fB\fBdisown\fR \fB[\fR\fIjob...\fR\fB]\fR\fR
5064 .ad
5065 .sp .6
5066 .RS 4n
5067 Causes the shell not to send a \fBHUP\fR signal to each specified \fIjob\fR, or
5068 all active jobs if \fIjob\fR is omitted, when a login shell terminates.
5069 .RE
5070
5071 .sp
5072 .ne 2
5073 .na
5074 \fB\fBecho\fR \fB[\fR\fIarg ...\fR\fB]\fR\fR
5075 .ad
5076 .sp .6
5077 .RS 4n
5078 When the first \fIarg\fR does not begin with a \fB-\fR, and none of the
5079 arguments contain a backslash (\fB\e\fR), prints each of its arguments
5080 separated by a SPACE and terminated by a NEWLINE. Otherwise, the behavior of
5081 \fBecho\fR is system dependent and \fBprint\fR or \fBprintf\fR described in
5082 this section should be used. See \fBecho\fR(1) for usage and description.
5083 .RE
5084
5085 .sp
5086 .ne 2
5087 .na
5088 \fB\fB+eval\fR \fB[\fR\fIarg ...\fR\fB]\fR\fR
5089 .ad
5090 .sp .6
5091 .RS 4n
5092 The arguments are read as input to the shell and the resulting commands are
5093 executed.
5094 .RE
5095
5096 .sp
5097 .ne 2
5098 .na
5099 \fB\fB+exec\fR [\fB-c\fR] [\fB-a\fR \fIname ...\fR]
5100 \fB[\fR\fIarg ...\fR\fB]\fR\fR
5101 .ad
5102 .sp .6
5103 .RS 4n
5104 If \fIarg\fR is specified, the command specified by the arguments is executed
5105 in place of this shell without creating a new process. The \fB-c\fR option
5106 causes the environment to be cleared before applying variable assignments
5107 associated with the exec invocation. The \fB-a\fR option causes \fIname\fR
5108 rather than the first \fIarg\fR, to become \fBargv[0]\fR for the new process.
5109 Input and output arguments can appear and affect the current process. If
5110 \fIarg\fR is not specified, the effect of this command is to modify file
5111 descriptors as prescribed by the input/output redirection list. In this case,
5112 any file descriptor numbers greater than \fB2\fR that are opened with this
5113 mechanism are closed when invoking another program.
5114 .RE
5115
5116 .sp
5117 .ne 2
5118 .na
5119 \fB\fB+exit\fR \fB[\fR\fIn\fR\fB]\fR\fR
5120 .ad
5121 .sp .6
5122 .RS 4n
5123 Causes the shell to exit with the exit status specified by \fIn\fR. The value
5124 is the least significant 8 bits of the specified status. If \fIn\fR is omitted,
5125 then the exit status is that of the last command executed. An end-of-file also
5126 causes the shell to exit except for a shell which has the \fBignoreeof\fR
5127 option turned on. See \fBset\fR.
5128 .RE
5129
5130 .sp
5131 .ne 2
5132 .na
5133 \fB\fB++export\fR \fB[\fR\fB-p\fR\fB]\fR
5134 \fB[\fR\fIname\fR\fB[=\fR\fIvalue\fR\fB]] ...\fR\fR
5135 .ad
5136 .sp .6
5137 .RS 4n
5138 If \fIname\fR is not specified, the names and values of each variable with the
5139 export attribute are printed with the values quoted in a manner that allows
5140 them to be re-entered. The \fB-p\fR option causes the word export to be
5141 inserted before each one. Otherwise, the specified \fIname\fRs are marked for
5142 automatic export to the environment of subsequently-executed commands.
5143 .RE
5144
5145 .sp
5146 .ne 2
5147 .na
5148 \fB\fBfalse\fR\fR
5149 .ad
5150 .sp .6
5151 .RS 4n
5152 Does nothing, and exits \fB1\fR. Used with \fBuntil\fR for infinite loops.
5153 .RE
5154
5155 .sp
5156 .ne 2
5157 .na
5158 \fB\fBfg\fR \fB[\fR\fIjob ...\fR\fB]\fR\fR
5159 .ad
5160 .sp .6
5161 .RS 4n
5162 This command is only on systems that support job control. Each \fIjob\fR
5163 specified is brought to the foreground and waited for in the specified order.
5164 Otherwise, the current job is brought into the foreground. See \fBJobs\fR for a
5165 description of the format of \fIjob\fR.
5166 .RE
5167
5168 .sp
5169 .ne 2
5170 .na
5171 \fB\fBgetconf\fR \fB[\fR\fIname\fR \fB[\fR\fIpathname\fR\fB]]\fR\fR
5172 .ad
5173 .sp .6
5174 .RS 4n
5175 Prints the current value of the configuration parameter specified by
5176 \fIname\fR. The configuration parameters are defined by the IEEE POSIX 1003.1
5177 and IEEE POSIX 1003.2 standards. See \fBpathconf\fR(2) and \fBsysconf\fR(3C).
5178 .sp
5179 The \fIpathname\fR argument is required for parameters whose value depends on
5180 the location in the file system. If no arguments are specified, \fBgetconf\fR
5181 prints the names and values of the current configuration parameters. The
5182 pathname \fB/\fR is used for each of the parameters that requires
5183 \fIpathname\fR.
5184 .RE
5185
5186 .sp
5187 .ne 2
5188 .na
5189 \fB\fBgetopts\fR \fB[\fR \fB-a\fR \fIname\fR\fB]\fR \fIoptstring\fR \fIvname\fR
5190 \fB[\fR\fIarg ...\fR\fB]\fR\fR
5191 .ad
5192 .sp .6
5193 .RS 4n
5194 Checks \fIarg\fR for legal options. If \fIarg\fR is omitted, the positional
5195 parameters are used. An option argument begins with a \fB+\fR or a \fB-\fR. An
5196 option that does not begin with \fB+\fR or \fB-\fR or the argument \fB--\fR
5197 ends the options. Options beginning with \fB+\fR are only recognized when
5198 \fIoptstring\fR begins with a \fB+\fR. \fIoptstring\fR contains the letters
5199 that \fBgetopts\fR recognizes. If a letter is followed by a \fB:\fR, that
5200 option is expected to have an argument. The options can be separated from the
5201 argument by blanks. The option \fB-?\fRcauses \fBgetopts\fR to generate a usage
5202 message on standard error. The \fB-a\fR option can be used to specify the name
5203 to use for the usage message, which defaults to $0. \fBgetopts\fR places the
5204 next option letter it finds inside variable \fIvname\fR each time it is
5205 invoked. The option letter is prepended with a \fB+\fR when \fIarg\fR begins
5206 with a \fB+\fR. The index of the next \fIarg\fR is stored in \fBOPTIND\fR. The
5207 option argument, if any, gets stored in \fBOPTARG\fR. A leading : in
5208 \fIoptstring\fR causes \fBgetopts\fR to store the letter of an invalid option
5209 in \fBOPTARG\fR, and to set \fIvname\fR to \fB?\fR for an unknown option and
5210 to: when a required option argument is missing. Otherwise, \fBgetopts\fR prints
5211 an error message. The exit status is \fBnon-zero\fR when there are no more
5212 options. There is no way to specify any of the options \fB:\fR, \fB+\fR,
5213 \fB-\fR, \fB?\fR, \fB[\fR, and \fB]\fR. The option \fB#\fR can only be
5214 specified as the first option.
5215 .RE
5216
5217 .sp
5218 .ne 2
5219 .na
5220 \fB\fBhist\fR \fB[\fR \fB-e\fR \fIename\fR\fB]\fR\fB[\fR\fB-nlr\fR\fB]\fR
5221 \fB[\fR \fIfirst\fR\fB[\fR\fIlast\fR \fB] ]\fR\fR
5222 .ad
5223 .br
5224 .na
5225 \fB\fR
5226 .ad
5227 .br
5228 .na
5229 \fB\fBhist\fR \fB-s\fR \fB[\fR \fIold\fR\fB=\fR\fInew\fR \fB] [\fR
5230 \fIcommand\fR\fB]\fR\fR
5231 .ad
5232 .sp .6
5233 .RS 4n
5234 In the first form, a range of commands from \fIfirst\fR to \fIlast\fR is
5235 selected from the last \fBHISTSIZE\fR commands that were typed at the terminal.
5236 The arguments \fIfirst\fR and \fIlast\fR can be specified as a number or as a
5237 string. A string is used to locate the most recent command starting with the
5238 specified string. A negative number is used as an offset to the current command
5239 number. If the -l option is selected, the commands are listed on standard
5240 output. Otherwise, the editor program \fIename\fR is invoked on a file
5241 containing these keyboard commands. If \fIename\fR is not supplied, then the
5242 value of the variable \fBHISTEDIT\fR is used. If \fBHISTEDIT\fR is not set,
5243 then \fBFCEDIT\fR (default \fB/bin/ed\fR) is used as the editor. When editing
5244 is complete, the edited command(s) is executed if the changes have been saved.
5245 If \fIlast\fR is not specified, then it is set to \fIfirst\fR. If \fIfirst\fR
5246 is not specified, the default is the previous command for editing and \fB-16\fR
5247 for listing. The option \fB-r\fR reverses the order of the commands and the
5248 option \fB-n\fR suppresses command numbers when listing. In the second form,
5249 \fIcommand\fR is interpreted as \fIfirst\fR described in this section and
5250 defaults to the last command executed. The resulting command is executed after
5251 the optional substitution \fIold\fR\fB=\fR\fInew\fR is performed.
5252 .RE
5253
5254 .sp
5255 .ne 2
5256 .na
5257 \fB\fBjobs\fR \fB-lnp\fR \fB[\fR\fIjob ...\fR\fB]\fR\fR
5258 .ad
5259 .sp .6
5260 .RS 4n
5261 Lists information about each specified job, or all active jobs if \fIjob\fR is
5262 omitted. The \fB-l\fR option lists process ids in addition to the normal
5263 information. The \fB-n\fR option only displays jobs that have stopped or exited
5264 since last notified. The \fB-p\fR option causes only the process group to be
5265 listed. See \fBJobs\fR for a description of the format of \fIjob\fR.
5266 .RE
5267
5268 .sp
5269 .ne 2
5270 .na
5271 \fB\fBkill\fR \fB[\fR\fB-s\fR \fIsigname\fR\fB]\fR \fIjob ...\fR\fR
5272 .ad
5273 .br
5274 .na
5275 \fB\fBkill\fR \fB[\fR\fB-n\fR \fIsignum\fR\fB]\fR \fIjob ...\fR\fR
5276 .ad
5277 .br
5278 .na
5279 \fB\fBkill\fR \fB-l\fR \fB[\fR\fIsig ...\fR\fB]\fR\fR
5280 .ad
5281 .sp .6
5282 .RS 4n
5283 Sends either the \fBTERM\fR (terminate) signal or the specified signal to the
5284 specified jobs or processes. Signals are either specified by number with the
5285 \fB-n\fR option or by name with the \fB-s\fR option (as specified in
5286 \fB<signal.h\fR>, stripped of the prefix `\fBSIG\fR with the exception that
5287 \fBSIGCLD\fR is named \fBCHLD\fR). For backward compatibility, the \fBn\fR and
5288 \fBs\fR can be omitted and the number or name placed immediately after the
5289 \fB-\fR. If the signal being sent is \fBTERM\fR (terminate) or \fBHUP\fR (hang
5290 up), then the job or process is sent a \fBCONT\fR (continue) signal if it is
5291 stopped. The argument \fIjob\fR can be the process id of a process that is not
5292 a member of one of the active jobs. See \fBJobs\fR for a description of the
5293 format of \fIjob\fR. In the third form, \fBkill -l\fR, if \fIsig\fR is not
5294 specified, the signal names are listed. Otherwise, for each \fIsig\fR that is a
5295 name, the corresponding signal number is listed. For each \fIsig\fR that is a
5296 number, the signal name corresponding to the least significant 8 bits of
5297 \fIsig\fR is listed.
5298 .RE
5299
5300 .sp
5301 .ne 2
5302 .na
5303 \fB\fBlet\fR \fB[\fR\fIarg ...\fR\fB]\fR\fR
5304 .ad
5305 .sp .6
5306 .RS 4n
5307 Each \fIarg\fR is a separate arithmetic expression to be evaluated. See the
5308 \fBArithmetic Evaluation\fR section of this manual page for a description of
5309 arithmetic expression evaluation. The exit status is \fB0\fR if the value of
5310 the last expression is \fBnon-zero\fR, and \fB1\fR otherwise.
5311 .RE
5312
5313 .sp
5314 .ne 2
5315 .na
5316 \fB\fB+newgrp\fR \fB[\fR\fIarg ...\fR\fB]\fR\fR
5317 .ad
5318 .sp .6
5319 .RS 4n
5320 Equivalent to \fBexec\fR \fB/bin/newgrp\fR \fIarg ...\fR
5321 .RE
5322
5323 .sp
5324 .ne 2
5325 .na
5326 \fB\fBprint\fR [\fB-Renprs\fR] \fB[\fR \fB-u\fR \fIunit\fR\fB] [\fR \fB-f\fR
5327 \fIformat\fR \fB] [\fR \fIarg ...\fR\fB]\fR\fR
5328 .ad
5329 .sp .6
5330 .RS 4n
5331 With no options or with option \fB-\fR or \fB--\fR, each \fIarg\fR is printed
5332 on standard output. The \fB-f\fR option causes the arguments to be printed as
5333 described by \fBprintf\fR. In this case, any \fBe\fR, \fBn\fR, \fBr\fR, or
5334 \fBR\fR options are ignored. Otherwise, unless the \fB-R\fR or \fB-r,\fR are
5335 specified, the following escape conventions are applied:
5336 .sp
5337 .ne 2
5338 .na
5339 \fB\fB\ea\fR\fR
5340 .ad
5341 .RS 8n
5342 Alert character (\fBASCII\fR 07)
5343 .RE
5344
5345 .sp
5346 .ne 2
5347 .na
5348 \fB\fB\eb\fR\fR
5349 .ad
5350 .RS 8n
5351 Backspace character (\fBASCII\fR 010)
5352 .RE
5353
5354 .sp
5355 .ne 2
5356 .na
5357 \fB\fB\ec\fR\fR
5358 .ad
5359 .RS 8n
5360 Causes print to end without processing more arguments and not adding a NEWLINE
5361 .RE
5362
5363 .sp
5364 .ne 2
5365 .na
5366 \fB\fB\ef\fR\fR
5367 .ad
5368 .RS 8n
5369 Form-feed character (\fBASCII\fR 014)
5370 .RE
5371
5372 .sp
5373 .ne 2
5374 .na
5375 \fB\fB\en\fR\fR
5376 .ad
5377 .RS 8n
5378 NEWLINE character (\fBASCII\fR 012)
5379 .RE
5380
5381 .sp
5382 .ne 2
5383 .na
5384 \fB\fB\er\fR\fR
5385 .ad
5386 .RS 8n
5387 RETURN character (\fBASCII\fR 015)
5388 .RE
5389
5390 .sp
5391 .ne 2
5392 .na
5393 \fB\fB\et\fR\fR
5394 .ad
5395 .RS 8n
5396 TAB character (\fBASCII\fR 011)
5397 .RE
5398
5399 .sp
5400 .ne 2
5401 .na
5402 \fB\fB\ev\fR\fR
5403 .ad
5404 .RS 8n
5405 Vertical TAB character (\fBASCII\fR 013)
5406 .RE
5407
5408 .sp
5409 .ne 2
5410 .na
5411 \fB\fB\eE\fR\fR
5412 .ad
5413 .RS 8n
5414 Escape character (\fBASCII\fR 033)
5415 .RE
5416
5417 .sp
5418 .ne 2
5419 .na
5420 \fB\fB\e\e\fR\fR
5421 .ad
5422 .RS 8n
5423 Backslash character \fB\e\fR
5424 .RE
5425
5426 .sp
5427 .ne 2
5428 .na
5429 \fB\fB\e0\fR\fIx\fR\fR
5430 .ad
5431 .RS 8n
5432 Character defined by the 1, 2, or 3-digit octal string specified by \fIx\fR
5433 .RE
5434
5435 The \fB-R\fR option prints all subsequent arguments and options other than
5436 \fB-n\fR. The \fB-e\fR causes the escape conventions to be applied This is the
5437 default behavior. It reverses the effect of an earlier \fB-r\fR. The \fB-p\fR
5438 option causes the arguments to be written onto the pipe of the process spawned
5439 with \fB|&\fR instead of standard output. The \fB-s\fR option causes the
5440 arguments to be written onto the history file instead of standard output. The
5441 \fB-u\fR option can be used to specify a one digit file descriptor unit number
5442 \fIunit\fR on which the output is placed. The default is \fB1\fR. If the option
5443 \fB-n\fR is used, no NEWLINE is added to the output.
5444 .RE
5445
5446 .sp
5447 .ne 2
5448 .na
5449 \fB\fBprintf\fR \fIformat\fR\fB[\fR\fIarg ...\fR\fB]\fR\fR
5450 .ad
5451 .sp .6
5452 .RS 4n
5453 The arguments \fIarg\fR are printed on standard output in accordance with the
5454 \fBANSI-C\fR formatting rules associated with the format string \fIformat\fR.
5455 If the number of arguments exceeds the number of format specifications, the
5456 format string is reused to format remaining arguments. The following extensions
5457 can also be used: A \fB%b\fR format can be used instead of \fB%s\fR to cause
5458 escape sequences in the corresponding \fIarg\fR to be expanded as described in
5459 \fBprint\fR. A \fB%B\fR option causes each of the arguments to be treated as
5460 variable names and the binary value of the variables is printed. This is most
5461 useful for variables with an attribute of b. A \fB%H\fR format can be used
5462 instead of \fB%s\fR to cause characters in \fIarg\fR that are special in
5463 \fBHTML\fR and \fBXML\fR to be output as their entity name. A \fB%P\fR format
5464 can be used instead of \fB%s\fR to cause \fIarg\fR to be interpreted as an
5465 extended regular expression and be printed as a shell pattern. A \fB%R\fR
5466 format can be used instead of \fB%s\fR to cause \fIarg\fR to be interpreted as
5467 a shell pattern and to be printed as an extended regular expression. A \fB%q\fR
5468 format can be used instead of \fB%\fRs to cause the resulting string to be
5469 quoted in a manner than can be input again to the shell. A
5470 \fB%(\fR\fIdate-format\fR\fB)T\fR format can be use to treat an argument as a
5471 date/time string and to format the date/time according to the \fIdate-format\fR
5472 as defined for the \fBdate\fR(1) command. A \fB%Z\fR format outputs a byte
5473 whose value is 0. The precision field of the %d format can be followed by a .
5474 and the output base. In this case, the \fB#\fR flag character causes
5475 \fBbase\fR\fI#\fR to be prepended. The \fB#\fR flag when used with the \fBd\fR
5476 specifier without an output base, causes the output to be displayed in
5477 thousands units with one of the suffixes \fBk\fR \fBM\fR \fBG\fR \fBT\fR
5478 \fBP\fR \fBE\fR to indicate the unit. The \fB#\fR flag when used with the i
5479 specifier causes the output to be displayed in \fB1024\fR with one of the
5480 suffixes \fBKi\fR \fBMi\fR \fBGi\fR \fBTi\fR \fBPi\fR \fBEi\fR to indicate the
5481 unit. The \fB=\fR flag has been added to center the output within the specified
5482 field width.
5483 .RE
5484
5485 .sp
5486 .ne 2
5487 .na
5488 \fB\fBpwd\fR [\fB-LP\fR]\fR
5489 .ad
5490 .sp .6
5491 .RS 4n
5492 Outputs the value of the current working directory. The \fB-L\fR option is the
5493 default. It prints the logical name of the current directory. If the \fB-P\fR
5494 option is specified, all symbolic links are resolved from the name. The last
5495 instance of \fB-L\fR or \fB-P\fR on the command line determines which method is
5496 used.
5497 .RE
5498
5499 .sp
5500 .ne 2
5501 .na
5502 \fB\fBread\fR \fB[\fR\fB-Aprs\fR\fB] [\fR\fB-d\fR \fIdelim\fR\fB] [\fR \fB-n\fR
5503 \fIn\fR\fB] [[\fR \fB-N\fR \fIn\fR\fB] [[\fR\fB-t\fR \fItimeout\fR\fB]
5504 [\fR\fB-u\fR \fIunit\fR\fB] [\fR\fIvname\fR\fB?\fR\fIprompt\fR\fB] [\fR
5505 \fIvname ...\fR \fB]\fR\fR
5506 .ad
5507 .sp .6
5508 .RS 4n
5509 The shell input mechanism. One line is read and is broken up into fields using
5510 the characters in IFS as separators. The escape character, \fB\e\fR, is used to
5511 remove any special meaning for the next character and for line continuation.
5512 The \fB-d\fR option causes the read to continue to the first character of
5513 \fIdelim\fR rather than \fBNEWLINE\fR. The \fB-n\fR option causes at most
5514 \fIn\fR bytes to read rather a full line but returns when reading from a slow
5515 device as soon as any characters have been read. The \fB-N\fR option causes
5516 exactly \fIn\fR to be read unless an end-of-file has been encountered or the
5517 read times out because of the \fB-t\fR option. In raw mode, \fB-r\fR, the
5518 \fB\e\fR character is not treated specially. The first field is assigned to the
5519 first \fIvname\fR, the second field to the second \fIvname\fR, etc., with
5520 leftover fields assigned to the last \fIvname\fR. When \fIvname\fR has the
5521 binary attribute and \fB-n\fR or \fB-N\fR is specified, the bytes that are read
5522 are stored directly into the variable. If the -v is specified, then the value
5523 of the first \fIvname\fR is used as a default value when reading from a
5524 terminal device. The \fB-A\fR option causes the variable \fIvname\fR to be
5525 unset and each field that is read to be stored in successive elements of the
5526 indexed array \fIvname\fR. The \fB-p\fR option causes the input line to be
5527 taken from the input pipe of a process spawned by the shell using \fB|&\fR. If
5528 the \fB-s\fR option is present, the input is saved as a command in the history
5529 file. The option \fB-u\fR can be used to specify a one digit file descriptor
5530 unit \fIunit\fR to read from. The file descriptor can be opened with the
5531 \fBexec\fR special built-in command. The default value of unit \fIn\fR is
5532 \fB0\fR. The option \fB-t\fR is used to specify a time out in seconds when
5533 reading from a terminal or pipe. If \fIvname\fR is omitted, then REPLY is used
5534 as the default \fIvname\fR. An end-of-file with the \fB-p\fR option causes
5535 cleanup for this process so that another can be spawned. If the first argument
5536 contains a \fB?\fR, the remainder of this word is used as a prompt on standard
5537 error when the shell is interactive. The exit status is \fB0\fR unless an
5538 end-of-file is encountered or read has timed out.
5539 .RE
5540
5541 .sp
5542 .ne 2
5543 .na
5544 \fB\fB++readonly\fR \fB[\fR\fB-p\fR\fB] [\fR
5545 \fIvname\fR\fB[=\fR\fIvalue\fR\fB]] ...\fR\fR
5546 .ad
5547 .sp .6
5548 .RS 4n
5549 If \fIvname\fR is not specified, the names and values of each variable with the
5550 read-only attribute is printed with the values quoted in a manner that allows
5551 them to be input again. The \fB-p\fR option causes the word \fBreadonly\fR to
5552 be inserted before each one. Otherwise, the specified \fIvname\fRs are marked
5553 \fBreadonly\fR and these names cannot be changed by subsequent assignment.
5554 .RE
5555
5556 .sp
5557 .ne 2
5558 .na
5559 \fB\fB+return\fR \fB[\fR\fIn\fR\fB]\fR\fR
5560 .ad
5561 .sp .6
5562 .RS 4n
5563 Causes a shell function or script to return to the invoking script with the
5564 exit status specified by \fIn\fR. The value is the least significant 8 bits of
5565 the specified status. If \fBn\fR is omitted, then the return status is that of
5566 the last command executed. If return is invoked while not in a function or a
5567 script, then it behaves the same as exit.
5568 .RE
5569
5570 .sp
5571 .ne 2
5572 .na
5573 \fB\fB+set [ \(+-BCGabefhkmnoprstuvx] [\(+-o [\fR \fIoption\fR \fB] ] ... [
5574 \(+-A\fR \fIvname\fR\fB]\fR \fB[\fR\fIarg...\fR\fB]\fR\fR
5575 .ad
5576 .sp .6
5577 .RS 4n
5578 The \fBset\fR command supports the following options:
5579 .sp
5580 .ne 2
5581 .na
5582 \fB\fB-a\fR\fR
5583 .ad
5584 .sp .6
5585 .RS 4n
5586 All subsequent variables that are defined are automatically exported.
5587 .RE
5588
5589 .sp
5590 .ne 2
5591 .na
5592 \fB\fB-A\fR\fR
5593 .ad
5594 .sp .6
5595 .RS 4n
5596 Array assignment. Unset the variable \fIvname\fR and assign values sequentially
5597 from the \fIarg\fR list. If \fB+A\fR is used, the variable \fIvname\fR is not
5598 unset first.
5599 .RE
5600
5601 .sp
5602 .ne 2
5603 .na
5604 \fB\fB-b\fR\fR
5605 .ad
5606 .sp .6
5607 .RS 4n
5608 Prints job completion messages as soon as a background job changes state rather
5609 than waiting for the next prompt.
5610 .RE
5611
5612 .sp
5613 .ne 2
5614 .na
5615 \fB\fB-B\fR\fR
5616 .ad
5617 .sp .6
5618 .RS 4n
5619 Enable brace pattern field generation. This is the default behavior.
5620 .RE
5621
5622 .sp
5623 .ne 2
5624 .na
5625 \fB\fB-C\fR\fR
5626 .ad
5627 .sp .6
5628 .RS 4n
5629 Prevents redirection (\fB>\fR) from truncating existing files. Files that are
5630 created are opened with the \fBO_EXCL\fR mode. Requires \fB>|\fR to truncate a
5631 file when turned on.
5632 .RE
5633
5634 .sp
5635 .ne 2
5636 .na
5637 \fB\fB-e\fR\fR
5638 .ad
5639 .sp .6
5640 .RS 4n
5641 If a command has a \fBnon-zero\fR exit status, execute the \fBERR\fR trap, if
5642 set, and exit. This mode is disabled while reading profiles.
5643 .RE
5644
5645 .sp
5646 .ne 2
5647 .na
5648 \fB\fB-f\fR\fR
5649 .ad
5650 .sp .6
5651 .RS 4n
5652 Disables file name generation.
5653 .RE
5654
5655 .sp
5656 .ne 2
5657 .na
5658 \fB\fB-G\fR\fR
5659 .ad
5660 .sp .6
5661 .RS 4n
5662 Causes the pattern \fB**\fR by itself to match files and zero or more
5663 directories and subdirectories when used for file name generation. If followed
5664 by a \fB/\fR only directories and subdirectories are matched.
5665 .RE
5666
5667 .sp
5668 .ne 2
5669 .na
5670 \fB\fB-h\fR\fR
5671 .ad
5672 .sp .6
5673 .RS 4n
5674 Each command becomes a tracked alias when first encountered.
5675 .RE
5676
5677 .sp
5678 .ne 2
5679 .na
5680 \fB\fB-k\fR\fR
5681 .ad
5682 .sp .6
5683 .RS 4n
5684 Obsolete. All variable assignment arguments are placed in the environment for a
5685 command, not just those that precede the command name.
5686 .RE
5687
5688 .sp
5689 .ne 2
5690 .na
5691 \fB\fB-m\fR\fR
5692 .ad
5693 .sp .6
5694 .RS 4n
5695 Background jobs run in a separate process group and a line prints upon
5696 completion. The exit status of background jobs is reported in a completion
5697 message. On systems with job control, this option is turned on automatically
5698 for interactive shells.
5699 .RE
5700
5701 .sp
5702 .ne 2
5703 .na
5704 \fB\fB-n\fR\fR
5705 .ad
5706 .sp .6
5707 .RS 4n
5708 Read commands and check them for syntax errors, but do not execute them.
5709 Ignored for interactive shells.
5710 .RE
5711
5712 .sp
5713 .ne 2
5714 .na
5715 \fB\fB-o\fR\fR
5716 .ad
5717 .sp .6
5718 .RS 4n
5719 If no option name is supplied, the list of options and their current settings
5720 are written to standard output. When invoked with a \fB+\fR, the options are
5721 written in a format that can be input again to the shell to restore the
5722 settings. This option can be repeated to enable or disable multiple options.
5723 .sp
5724 The following argument can be one of the following option names:
5725 .sp
5726 .ne 2
5727 .na
5728 \fB\fBallexport\fR\fR
5729 .ad
5730 .sp .6
5731 .RS 4n
5732 Same as \fB-a\fR.
5733 .RE
5734
5735 .sp
5736 .ne 2
5737 .na
5738 \fB\fBbgnice\fR\fR
5739 .ad
5740 .sp .6
5741 .RS 4n
5742 All background jobs are run at a lower priority. This is the default mode.
5743 .RE
5744
5745 .sp
5746 .ne 2
5747 .na
5748 \fB\fBbraceexpand\fR\fR
5749 .ad
5750 .sp .6
5751 .RS 4n
5752 Same as \fB-\fRB.
5753 .RE
5754
5755 .sp
5756 .ne 2
5757 .na
5758 \fB\fBemacs\fR\fR
5759 .ad
5760 .sp .6
5761 .RS 4n
5762 Puts you in an \fBemacs\fR style inline editor for command entry.
5763 .RE
5764
5765 .sp
5766 .ne 2
5767 .na
5768 \fB\fBerrexit\fR\fR
5769 .ad
5770 .sp .6
5771 .RS 4n
5772 Same as \fB-e\fR.
5773 .RE
5774
5775 .sp
5776 .ne 2
5777 .na
5778 \fB\fBglobstar\fR\fR
5779 .ad
5780 .sp .6
5781 .RS 4n
5782 Same as \fB-G\fR.
5783 .RE
5784
5785 .sp
5786 .ne 2
5787 .na
5788 \fB\fBgmacs\fR\fR
5789 .ad
5790 .sp .6
5791 .RS 4n
5792 Puts you in a \fBgmacs\fR style inline editor for command entry.
5793 .RE
5794
5795 .sp
5796 .ne 2
5797 .na
5798 \fB\fBignoreeof\fR\fR
5799 .ad
5800 .sp .6
5801 .RS 4n
5802 The shell does not exit on end-of-file. The command \fBexit\fR must be used.
5803 .RE
5804
5805 .sp
5806 .ne 2
5807 .na
5808 \fB\fBkeyword\fR\fR
5809 .ad
5810 .sp .6
5811 .RS 4n
5812 Same as \fB-k\fR.
5813 .RE
5814
5815 .sp
5816 .ne 2
5817 .na
5818 \fB\fBmarkdirs\fR\fR
5819 .ad
5820 .sp .6
5821 .RS 4n
5822 All directory names resulting from file name generation have a trailing /
5823 appended.
5824 .RE
5825
5826 .sp
5827 .ne 2
5828 .na
5829 \fB\fBmonitor\fR\fR
5830 .ad
5831 .sp .6
5832 .RS 4n
5833 Same as \fB-m\fR.
5834 .RE
5835
5836 .sp
5837 .ne 2
5838 .na
5839 \fB\fBmultiline\fR\fR
5840 .ad
5841 .sp .6
5842 .RS 4n
5843 The built-in editors use multiple lines on the screen for lines that are longer
5844 than the width of the screen. This might not work for all terminals.
5845 .RE
5846
5847 .sp
5848 .ne 2
5849 .na
5850 \fB\fBnoclobber\fR\fR
5851 .ad
5852 .sp .6
5853 .RS 4n
5854 Same as \fB-C\fR.
5855 .RE
5856
5857 .sp
5858 .ne 2
5859 .na
5860 \fB\fBnoexec\fR\fR
5861 .ad
5862 .sp .6
5863 .RS 4n
5864 Same as \fB-n\fR.
5865 .RE
5866
5867 .sp
5868 .ne 2
5869 .na
5870 \fB\fBnoglob\fR\fR
5871 .ad
5872 .sp .6
5873 .RS 4n
5874 Same as \fB-f\fR.
5875 .RE
5876
5877 .sp
5878 .ne 2
5879 .na
5880 \fB\fBnolog\fR\fR
5881 .ad
5882 .sp .6
5883 .RS 4n
5884 Do not save function definitions in the history file.
5885 .RE
5886
5887 .sp
5888 .ne 2
5889 .na
5890 \fB\fBnotify\fR\fR
5891 .ad
5892 .sp .6
5893 .RS 4n
5894 Same as \fB-b\fR.
5895 .RE
5896
5897 .sp
5898 .ne 2
5899 .na
5900 \fB\fBnounset\fR\fR
5901 .ad
5902 .sp .6
5903 .RS 4n
5904 Same as \fB-u\fR.
5905 .RE
5906
5907 .sp
5908 .ne 2
5909 .na
5910 \fB\fBpipefail\fR\fR
5911 .ad
5912 .sp .6
5913 .RS 4n
5914 A pipeline does not complete until all components of the pipeline have
5915 completed, and the return value is the value of the last \fBnon-zero\fR command
5916 to fail or zero if no command has failed.
5917 .RE
5918
5919 .sp
5920 .ne 2
5921 .na
5922 \fB\fBprivileged\fR\fR
5923 .ad
5924 .sp .6
5925 .RS 4n
5926 Same as \fB-p\fR.
5927 .RE
5928
5929 .sp
5930 .ne 2
5931 .na
5932 \fB\fBshowme\fR\fR
5933 .ad
5934 .sp .6
5935 .RS 4n
5936 When enabled, simple commands or pipelines preceded by a a semicolon (\fB;\fR)
5937 is displayed as if the \fBxtrace\fR option were enabled but is not executed.
5938 Otherwise, the leading \fB;\fR is ignored.
5939 .RE
5940
5941 .sp
5942 .ne 2
5943 .na
5944 \fB\fBtrackall\fR\fR
5945 .ad
5946 .sp .6
5947 .RS 4n
5948 Same as \fB-h\fR.
5949 .RE
5950
5951 .sp
5952 .ne 2
5953 .na
5954 \fB\fBverbose\fR\fR
5955 .ad
5956 .sp .6
5957 .RS 4n
5958 Same as \fB-v\fR.
5959 .RE
5960
5961 .sp
5962 .ne 2
5963 .na
5964 \fB\fBvi\fR\fR
5965 .ad
5966 .sp .6
5967 .RS 4n
5968 Puts you in insert mode of a \fBvi\fR style inline editor until you hit the
5969 escape character 033. This puts you in control mode. A return sends the line.
5970 .RE
5971
5972 .sp
5973 .ne 2
5974 .na
5975 \fB\fBviraw\fR\fR
5976 .ad
5977 .sp .6
5978 .RS 4n
5979 Each character is processed as it is typed in \fBvi\fR mode.
5980 .RE
5981
5982 .sp
5983 .ne 2
5984 .na
5985 \fB\fBxtrace\fR\fR
5986 .ad
5987 .sp .6
5988 .RS 4n
5989 Same as \fB-x\fR.
5990 .sp
5991 If no option name is supplied, the current options settings are printed.
5992 .RE
5993
5994 .RE
5995
5996 .sp
5997 .ne 2
5998 .na
5999 \fB\fB-p\fR\fR
6000 .ad
6001 .sp .6
6002 .RS 4n
6003 Disables processing of the \fB$HOME/.profile\fR file and uses the file
6004 \fB/etc/suid_profile\fR instead of the \fBENV\fR file. This mode is on whenever
6005 the effective \fBuid\fR (\fBgid\fR) is not equal to the real \fBuid\fR
6006 (\fBgid\fR). Turning this off causes the effective \fBuid\fR and \fBgid\fR to
6007 be set to the real \fBuid\fR and \fBgid\fR.
6008 .RE
6009
6010 .sp
6011 .ne 2
6012 .na
6013 \fB\fB-r\fR\fR
6014 .ad
6015 .sp .6
6016 .RS 4n
6017 Enables the restricted shell. This option cannot be unset once set.
6018 .RE
6019
6020 .sp
6021 .ne 2
6022 .na
6023 \fB\fB-s\fR\fR
6024 .ad
6025 .sp .6
6026 .RS 4n
6027 Sort the positional parameters lexicographically.
6028 .RE
6029
6030 .sp
6031 .ne 2
6032 .na
6033 \fB\fB-t\fR\fR
6034 .ad
6035 .sp .6
6036 .RS 4n
6037 Obsolete. Exit after reading and executing one command.
6038 .RE
6039
6040 .sp
6041 .ne 2
6042 .na
6043 \fB\fB-u\fR\fR
6044 .ad
6045 .sp .6
6046 .RS 4n
6047 Treat \fBunset\fR parameters as an error when substituting.
6048 .RE
6049
6050 .sp
6051 .ne 2
6052 .na
6053 \fB\fB-v\fR\fR
6054 .ad
6055 .sp .6
6056 .RS 4n
6057 Print shell input lines as they are read.
6058 .RE
6059
6060 .sp
6061 .ne 2
6062 .na
6063 \fB\fB-x\fR\fR
6064 .ad
6065 .sp .6
6066 .RS 4n
6067 Print commands and their arguments as they are executed.
6068 .RE
6069
6070 .sp
6071 .ne 2
6072 .na
6073 \fB\fB--\fR\fR
6074 .ad
6075 .sp .6
6076 .RS 4n
6077 Do not change any of the options. This is useful in setting \fB$1\fR to a value
6078 beginning with \fB-\fR. If no arguments follow this option then the positional
6079 parameters are unset.
6080 .RE
6081
6082 As an obsolete feature, if the first \fIarg\fR is - then the \fB-x\fR and
6083 \fB-v\fR options are turned off and the next \fIarg\fR is treated as the first
6084 argument. Using \fB+\fR rather than \fB-\fR causes these options to be turned
6085 off. These options can also be used upon invocation of the shell. The current
6086 set of options can be found in \fB$-\fR. Unless \fB-A\fR is specified, the
6087 remaining arguments are positional parameters and are assigned, in order, to
6088 \fB$1 $2 \&....\fR If no arguments are specified, then the names and values of
6089 all variables are printed on the standard output.
6090 .RE
6091
6092 .sp
6093 .ne 2
6094 .na
6095 \fB\fB+shift\fR \fB[\fR\fIn\fR\fB]\fR\fR
6096 .ad
6097 .sp .6
6098 .RS 4n
6099 The positional parameters from \fB$\fR\fIn\fR\fB+1 ...\fR are renamed
6100 \fB$1 ...\fR, the default \fIn\fR is \fB1\fR. The parameter \fIn\fR can be any
6101 arithmetic expression that evaluates to a non-negative number less than or
6102 equal to \fB$#\fR.
6103 .RE
6104
6105 .sp
6106 .ne 2
6107 .na
6108 \fB\fBsleep\fR \fIseconds\fR\fR
6109 .ad
6110 .sp .6
6111 .RS 4n
6112 Suspends execution for the number of decimal seconds or fractions of a second
6113 specified by \fIseconds\fR.
6114 .RE
6115
6116 .sp
6117 .ne 2
6118 .na
6119 \fB\fB+trap\fR \fB-p\fR \fB[\fR\fIaction\fR\fB]\fR
6120 \fB[\fR\fIsig\fR\fB] ...\fR\fR
6121 .ad
6122 .sp .6
6123 .RS 4n
6124 The \fB-p\fR option causes the trap action associated with each trap as
6125 specified by the arguments to be printed with appropriate quoting. Otherwise,
6126 \fIaction\fR is processed as if it were an argument to \fBeval\fR when the
6127 shell receives signal(s) \fIsig\fR. Each \fIsig\fR can be specified as a number
6128 or as the name of the signal. Trap commands are executed in order of signal
6129 number. Any attempt to set a trap on a signal that was ignored on entry to the
6130 current shell is ineffective. If \fIaction\fR is omitted and the first
6131 \fIsig\fR is a number, or if \fIaction\fR is \fB-\fR, then the trap(s) for each
6132 \fIsig\fR are reset to their original values. If \fIaction\fR is the null
6133 string then this signal is ignored by the shell and by the commands it invokes.
6134 If \fIsig\fR is \fBERR\fR then \fIaction\fR is executed whenever a command has
6135 a \fBnon-zero\fR exit status. If \fIsig\fR is \fBDEBUG\fR then \fIaction\fR is
6136 executed before each command. The variable \fB\&.sh.command\fR contains the
6137 contents of the current command line when \fIaction\fR is running. If \fIsig\fR
6138 is \fB0\fR or \fBEXIT\fR and the trap statement is executed inside the body of
6139 a function defined with the \fBfunction\fR \fIname\fR syntax, then the command
6140 \fIaction\fR is executed after the function completes. If \fIsig\fR is \fB0\fR
6141 or \fBEXIT\fR for a trap set outside any function then the command \fIaction\fR
6142 is executed on exit from the shell. If \fIsig\fR is \fBKEYBD\fR, then
6143 \fIaction\fR is executed whenever a key is read while in \fBemacs\fR,
6144 \fBgmacs\fR, or \fBvi\fR mode. The \fBtrap\fR command with no arguments prints
6145 a list of commands associated with each signal number.
6146 .RE
6147
6148 .sp
6149 .ne 2
6150 .na
6151 \fB\fBtrue\fR\fR
6152 .ad
6153 .sp .6
6154 .RS 4n
6155 Does nothing, and exits \fB0\fR. Used with while for infinite loops.
6156 .RE
6157
6158 .sp
6159 .ne 2
6160 .na
6161 \fB\fB++typeset [\(+-AHflabnprtux ] [ \(+-EFLRZi[\fR\fIn\fR\fB] ] [\fR
6162 \fIvname\fR\fB[=\fR\fIvalue\fR \fB] ]\fR\fR
6163 .ad
6164 .sp .6
6165 .RS 4n
6166 Sets attributes and values for shell variables and functions. When invoked
6167 inside a function defined with the \fBfunction\fR \fIname\fR syntax, a new
6168 instance of the variable \fIvname\fR is created, and the variable's value and
6169 type are restored when the function completes.
6170 .sp
6171 Using \fB+\fR rather than \fB-\fR causes these options to be turned off. If no
6172 \fIvname\fR arguments are specified, a list of \fIvname\fRs (and optionally the
6173 \fIvalue\fRs) of the variables is printed. Using \fB+\fR rather than \fB-\fR
6174 keeps the values from being printed.) The \fB-p\fR option causes \fBtypeset\fR
6175 followed by the option letters to be printed before each name rather than the
6176 names of the options. If any option other than \fB-p\fR is specified, only
6177 those variables which have all of the specified options are printed. Otherwise,
6178 the \fIvname\fRs and \fIattributes\fR of all variables that have attributes are
6179 printed.
6180 .sp
6181 The following list of attributes can be specified:
6182 .sp
6183 .ne 2
6184 .na
6185 \fB\fB-a\fR\fR
6186 .ad
6187 .RS 6n
6188 Declares \fIvname\fR to be an indexed array. This is optional unless except for
6189 compound variable assignments.
6190 .RE
6191
6192 .sp
6193 .ne 2
6194 .na
6195 \fB\fB-A\fR\fR
6196 .ad
6197 .RS 6n
6198 Declares \fIvname\fR to be an associative array. Sub-scripts are strings rather
6199 than arithmetic expressions.
6200 .RE
6201
6202 .sp
6203 .ne 2
6204 .na
6205 \fB\fB-b\fR\fR
6206 .ad
6207 .RS 6n
6208 The variable can hold any number of bytes of data. The data can be text or
6209 binary. The value is represented by the \fBbase64\fR encoding of the data. If
6210 \fB-Z\fR is also specified, the size in bytes of the data in the buffer is
6211 determined by the size associated with the \fB-Z\fR. If the \fBbase64\fR string
6212 assigned results in more data, it is truncated. Otherwise, it is filled with
6213 bytes whose value is zero. The \fBprintf\fR format \fB%B\fR can be used to
6214 output the actual data in this buffer instead of the \fBbase64\fR encoding of
6215 the data.
6216 .RE
6217
6218 .sp
6219 .ne 2
6220 .na
6221 \fB\fB-E\fR\fR
6222 .ad
6223 .RS 6n
6224 Declares \fIvname\fR to be a double precision floating point number. If \fIn\fR
6225 is \fBnon-zero\fR, it defines the number of significant figures that are used
6226 when expanding \fIvname\fR. Otherwise, ten significant figures is used.
6227 .RE
6228
6229 .sp
6230 .ne 2
6231 .na
6232 \fB\fB-f\fR\fR
6233 .ad
6234 .RS 6n
6235 The names refer to function names rather than variable names. No assignments
6236 can be made and the only other valid options are \fB-t\fR, \fB-u\fR, and
6237 \fB-x.\fR The \fB-t\fR option turns on execution tracing for this function. The
6238 \fB-u\fR option causes this function to be marked undefined. The \fBFPATH\fR
6239 variable is searched to find the function definition when the function is
6240 referenced. If no options other than \fB-f\fR is specified, then the function
6241 definition is displayed on standard output. If \fB+f\fR is specified, then a
6242 line containing the function name followed by a shell comment containing the
6243 line number and path name of the file where this function was defined, if any,
6244 is displayed.
6245 .sp
6246 The \fB-i\fR attribute cannot be specified with \fB-f\fR.
6247 .RE
6248
6249 .sp
6250 .ne 2
6251 .na
6252 \fB\fB-F\fR\fR
6253 .ad
6254 .RS 6n
6255 Declares \fIvname\fR to be a double precision floating point number. If \fIn\fR
6256 is \fBnon-zero\fR, it defines the number of places after the decimal point that
6257 are used when expanding \fIvname\fR. Otherwise ten places after the decimal
6258 point is used.
6259 .RE
6260
6261 .sp
6262 .ne 2
6263 .na
6264 \fB\fB-H\fR\fR
6265 .ad
6266 .RS 6n
6267 This option provides UNIX to hostname file mapping on non-UNIX machines.
6268 .RE
6269
6270 .sp
6271 .ne 2
6272 .na
6273 \fB\fB-i\fR\fR
6274 .ad
6275 .RS 6n
6276 Declares \fIvname\fR to be represented internally as integer. The right hand
6277 side of an assignment is evaluated as an arithmetic expression when assigning
6278 to an integer. If \fIn\fR is \fBnon-zero\fR, it defines the output arithmetic
6279 base, otherwise the output base is ten.
6280 .sp
6281 The \fB-i\fR attribute cannot be specified along with \fB-R\fR, \fB-L\fR,
6282 \fB-Z\fR, or \fB-f\fR.
6283 .RE
6284
6285 .sp
6286 .ne 2
6287 .na
6288 \fB\fB-l\fR\fR
6289 .ad
6290 .RS 6n
6291 All uppercase characters are converted to lowercase. The uppercase option,
6292 \fB-u\fR, is turned off.
6293 .RE
6294
6295 .sp
6296 .ne 2
6297 .na
6298 \fB\fB-L\fR\fR
6299 .ad
6300 .RS 6n
6301 Left justify and remove leading blanks from \fIvalue\fR. If \fIn\fR is
6302 \fBnon-zero\fR, it defines the width of the field, otherwise it is determined
6303 by the width of the value of first assignment. When the variable is assigned
6304 to, it is filled on the right with blanks or truncated, if necessary, to fit
6305 into the field. The \fB-R\fR option is turned off.
6306 .sp
6307 The \fB-i\fR attribute cannot be specified with \fB-L\fR.
6308 .RE
6309
6310 .sp
6311 .ne 2
6312 .na
6313 \fB\fB-n\fR\fR
6314 .ad
6315 .RS 6n
6316 Declares \fIvname\fR to be a reference to the variable whose name is defined by
6317 the value of variable \fIvname\fR. This is usually used to reference a variable
6318 inside a function whose name has been passed as an argument.
6319 .RE
6320
6321 .sp
6322 .ne 2
6323 .na
6324 \fB\fB-R\fR\fR
6325 .ad
6326 .RS 6n
6327 Right justify and fill with leading blanks. If \fIn\fR is \fBnon-zero\fR, it
6328 defines the width of the field, otherwise it is determined by the width of the
6329 value of first assignment. The field is left filled with blanks or truncated
6330 from the end if the variable is reassigned. The \fB-L\fR option is turned off.
6331 .sp
6332 The \fB-i\fR attribute cannot be specified with \fB-R\fR.
6333 .RE
6334
6335 .sp
6336 .ne 2
6337 .na
6338 \fB\fB-r\fR\fR
6339 .ad
6340 .RS 6n
6341 The specified \fIvname\fRs are marked read-only and these names cannot be
6342 changed by subsequent assignment.
6343 .RE
6344
6345 .sp
6346 .ne 2
6347 .na
6348 \fB\fB-t\fR\fR
6349 .ad
6350 .RS 6n
6351 Tags the variables. Tags are user definable and have no special meaning to the
6352 shell.
6353 .RE
6354
6355 .sp
6356 .ne 2
6357 .na
6358 \fB\fB-u\fR\fR
6359 .ad
6360 .RS 6n
6361 All lowercase characters are converted to uppercase. The lowercase option,
6362 \fB-l\fR, is turned off.
6363 .RE
6364
6365 .sp
6366 .ne 2
6367 .na
6368 \fB\fB-x\fR\fR
6369 .ad
6370 .RS 6n
6371 The specified \fIvname\fRs are marked for automatic export to the environment
6372 of subsequently-executed commands. Variables whose names contain a . cannot be
6373 exported.
6374 .RE
6375
6376 .sp
6377 .ne 2
6378 .na
6379 \fB\fB-Z\fR\fR
6380 .ad
6381 .RS 6n
6382 Right justify and fill with leading zeros if the first non-blank character is a
6383 digit and the \fB-L\fR option has not been set. Remove leading zeros if the
6384 \fB-L\fR option is also set. If \fIn\fR is \fBnon-zero\fR, it defines the width
6385 of the field, otherwise it is determined by the width of the value of first
6386 assignment.
6387 .sp
6388 The \fB-i\fR attribute cannot be specified with \fB-Z\fR.
6389 .RE
6390
6391 .RE
6392
6393 .sp
6394 .ne 2
6395 .na
6396 \fB\fBulimit [\fR\fB-HSacdfmnpstv\fR\fB] [\fR \fIlimit\fR\fB]\fR\fR
6397 .ad
6398 .sp .6
6399 .RS 4n
6400 Set or display a resource limit. Many systems do not support one or more of
6401 these limits. The limit for a specified resource is set when \fIlimit\fR is
6402 specified. The value of \fIlimit\fR can be a number in the unit specified with
6403 each resource, or the value unlimited. When more than one resource is
6404 specified, then the limit name and unit is printed before the value.
6405 .sp
6406 If no option is specified, \fB-f\fR is assumed.
6407 .sp
6408 The following are the available resource limits:
6409 .sp
6410 .ne 2
6411 .na
6412 \fB\fB-a\fR\fR
6413 .ad
6414 .RS 6n
6415 Lists all of the current resource limits.
6416 .RE
6417
6418 .sp
6419 .ne 2
6420 .na
6421 \fB\fB-c\fR\fR
6422 .ad
6423 .RS 6n
6424 The number of 512-byte blocks on the size of core dumps.
6425 .RE
6426
6427 .sp
6428 .ne 2
6429 .na
6430 \fB\fB-d\fR\fR
6431 .ad
6432 .RS 6n
6433 The number of Kbytes on the size of the data area.
6434 .RE
6435
6436 .sp
6437 .ne 2
6438 .na
6439 \fB\fB-f\fR\fR
6440 .ad
6441 .RS 6n
6442 The number of 512-byte blocks on files that can be written by the current
6443 process or by child processes (files of any size can be read).
6444 .RE
6445
6446 .sp
6447 .ne 2
6448 .na
6449 \fB\fB-H\fR\fR
6450 .ad
6451 .RS 6n
6452 Specifies a hard limit for the specified resource.
6453 .sp
6454 A hard limit cannot be increased once it is set.
6455 .sp
6456 If neither the \fB-H\fR nor \fB-S\fR option is specified, the limit applies to
6457 both. The current resource limit is printed when \fIlimit\fR is omitted. In
6458 this case, the soft limit is printed unless \fB-H\fR is specified.
6459 .RE
6460
6461 .sp
6462 .ne 2
6463 .na
6464 \fB\fB-m\fR\fR
6465 .ad
6466 .RS 6n
6467 The number of Kbytes on the size of physical memory.
6468 .RE
6469
6470 .sp
6471 .ne 2
6472 .na
6473 \fB\fB-n\fR\fR
6474 .ad
6475 .RS 6n
6476 The number of file descriptors plus 1.
6477 .RE
6478
6479 .sp
6480 .ne 2
6481 .na
6482 \fB\fB-p\fR\fR
6483 .ad
6484 .RS 6n
6485 The number of 512-byte blocks for pipe buffering.
6486 .RE
6487
6488 .sp
6489 .ne 2
6490 .na
6491 \fB\fB-s\fR\fR
6492 .ad
6493 .RS 6n
6494 The number of Kbytes on the size of the stack area.
6495 .RE
6496
6497 .sp
6498 .ne 2
6499 .na
6500 \fB\fB-S\fR\fR
6501 .ad
6502 .RS 6n
6503 Specifies a soft limit for the specified resource.
6504 .sp
6505 A soft limit can be increased up to the value of the hard limit.
6506 .sp
6507 If neither the \fB-H\fR nor \fB-S\fR option is specified, the limit applies to
6508 both. The current resource limit is printed when \fIlimit\fR is omitted. In
6509 this case, the soft limit is printed unless \fB-H\fR is specified.
6510 .RE
6511
6512 .sp
6513 .ne 2
6514 .na
6515 \fB\fB-t\fR\fR
6516 .ad
6517 .RS 6n
6518 The number of CPU seconds to be used by each process.
6519 .RE
6520
6521 .sp
6522 .ne 2
6523 .na
6524 \fB\fB-v\fR\fR
6525 .ad
6526 .RS 6n
6527 The number of Kbytes for virtual memory.
6528 .RE
6529
6530 .RE
6531
6532 .sp
6533 .ne 2
6534 .na
6535 \fB\fBumask\fR \fB[\fR\fB-S\fR\fB]\fR\fB[\fR\fImask\fR\fB]\fR\fR
6536 .ad
6537 .sp .6
6538 .RS 4n
6539 The user file-creation mask is set to \fImask\fR. \fImask\fR can either be an
6540 octal number or a symbolic value as described in \fBchmod\fR(1).
6541 .sp
6542 If a symbolic value is specified, the new \fBumask\fR value is the complement
6543 of the result of applying \fImask\fR to the complement of the previous
6544 \fBumask\fR value. If \fImask\fR is omitted, the current value of the mask is
6545 printed. The \fB-S\fR option causes the mode to be printed as a symbolic value.
6546 Otherwise, the mask is printed in octal.
6547 .sp
6548 See \fBumask\fR(2)
6549 .RE
6550
6551 .sp
6552 .ne 2
6553 .na
6554 \fB\fB+unalias\fR \fB[\fR\fB-a\fR\fB]\fR \fIname\fR\fR
6555 .ad
6556 .sp .6
6557 .RS 4n
6558 The aliases specified by the list of \fIname\fRs are removed from the alias
6559 list. The \fB-a\fR option causes all the aliases to be unset.
6560 .RE
6561
6562 .sp
6563 .ne 2
6564 .na
6565 \fB\fB+unset\fR \fB[\fR\fB-fnv\fR\fB]\fR \fIvname\fR\fR
6566 .ad
6567 .sp .6
6568 .RS 4n
6569 The variables specified by the list of \fIvname\fRs are unassigned, i.e., their
6570 values and attributes are erased. Read-only variables cannot be unset. If the
6571 \fB-f\fR option is set, then the names refer to function names. If the \fB-v\fR
6572 option is set, then the names refer to variable names. The \fB-f\fR option
6573 overrides \fB-v\fR. If \fB-n\fR is set and \fIname\fR is a name reference, then
6574 \fIname\fR is unset rather than the variable that it references. The default is
6575 equivalent to \fB-v\fR. Unsetting \fBLINENO\fR, \fBMAILCHECK\fR, \fBOPTARG\fR,
6576 \fBOPTIND\fR, \fBRANDOM\fR, \fBSECONDS\fR, \fBTMOUT\fR, and \fB_\fR removes
6577 their special meaning even if they are subsequently assigned to.
6578 .RE
6579
6580 .sp
6581 .ne 2
6582 .na
6583 \fB\fBwait\fR \fB[\fR\fIjob\fR\fB]\fR\fR
6584 .ad
6585 .sp .6
6586 .RS 4n
6587 Wait for the specified job and report its termination status. If \fIjob\fR is
6588 not specified, then all currently active child processes are waited for. The
6589 exit status from this command is that of the last process waited for if
6590 \fIjob\fR is specified; otherwise it is zero. See \fBJobs\fR for a description
6591 of the format of \fIjob\fR.
6592 .RE
6593
6594 .sp
6595 .ne 2
6596 .na
6597 \fB\fBwhence\fR \fB[\fR\fB-afpv\fR\fB]\fR \fIname ...\fR\fR
6598 .ad
6599 .sp .6
6600 .RS 4n
6601 For each \fIname\fR, indicate how it would be interpreted if used as a command
6602 name. The \fB-v\fR option produces a more verbose report. The \fB-f\fR option
6603 skips the search for functions. The \fB-p\fR option does a path search for
6604 \fIname\fR even if name is an alias, a function, or a reserved word. The
6605 \fB-a\fR option is similar to the -v option but causes all interpretations of
6606 the specified name to be reported.
6607 .RE
6608
6609 .SS "Invocation"
6610 .LP
6611 If the shell is invoked by \fBexec\fR(2), and the first character of argument
6612 zero (\fB$0\fR) is \fB-\fR, then the shell is assumed to be a login shell and
6613 commands are read from \fB/etc/profile\fR and then from either .\fBprofile\fR
6614 in the current directory or \fB$HOME/.profile\fR, if either file exists. Next,
6615 for interactive shells, commands are read first from \fB/etc/ksh.kshrc\fR, and
6616 then from the file named by performing parameter expansion, command
6617 substitution, and arithmetic substitution on the value of the environment
6618 variable \fBENV\fR if the file exists. If the \fB-s\fR option is not present
6619 and \fIarg\fR and a file by the name of \fIarg\fR exists, then it reads and
6620 executes this script. Otherwise, if the first \fIarg\fR does not contain a
6621 \fB/\fR, a path search is performed on the first \fIarg\fR to determine the
6622 name of the script to execute. The script \fIarg\fR must have execute
6623 permission and any \fBsetuid\fR and \fBsetgid\fR settings are ignored. If the
6624 script is not found on the path, \fIarg\fR is processed as if it named a
6625 built-in command or function.
6626 .sp
6627 .LP
6628 Commands are then read as described, and the following options are interpreted
6629 by the shell when it is invoked:
6630 .sp
6631 .ne 2
6632 .na
6633 \fB\fB-c\fR\fR
6634 .ad
6635 .RS 15n
6636 If the \fB-c\fR option is present, then commands are read from the first
6637 \fIarg\fR. Any remaining arguments become positional parameters starting at
6638 \fB0\fR.
6639 .RE
6640
6641 .sp
6642 .ne 2
6643 .na
6644 \fB\fB-D\fR\fR
6645 .ad
6646 .RS 15n
6647 A list of all double quoted strings that are preceded by a \fB$\fR is printed
6648 on standard output and the shell exits. This set of strings is subject to
6649 language translation when the locale is not C or POSIX. No commands are
6650 executed.
6651 .RE
6652
6653 .sp
6654 .ne 2
6655 .na
6656 \fB\fB-i\fR\fR
6657 .ad
6658 .RS 15n
6659 If the \fB-i\fR option is present or if the shell input and output are attached
6660 to a terminal (as told by \fBtcgetattr\fR(3C), this shell is interactive. In
6661 this case \fBTERM\fR is ignored (so that \fBkill 0\fR does not kill an
6662 interactive shell) and \fBINTR\fR is caught and ignored (so that wait is
6663 interruptible). In all cases, \fBQUIT\fR is ignored by the shell.
6664 .RE
6665
6666 .sp
6667 .ne 2
6668 .na
6669 \fB\fB-R\fR \fIfilename\fR\fR
6670 .ad
6671 .RS 15n
6672 The \fB-R\fR \fIfilename\fR option is used to generate a cross reference
6673 database that can be used by a separate utility to find definitions and
6674 references for variables and commands.
6675 .RE
6676
6677 .sp
6678 .ne 2
6679 .na
6680 \fB\fB-r\fR\fR
6681 .ad
6682 .RS 15n
6683 If the \fB-r\fR option is present, the shell is a restricted shell.
6684 .RE
6685
6686 .sp
6687 .ne 2
6688 .na
6689 \fB\fB-s\fR\fR
6690 .ad
6691 .RS 15n
6692 If the \fB-s\fR option is present or if no arguments remain, then commands are
6693 read from the standard input. Shell output, except for the output of the
6694 \fBSpecial Commands\fR listed, is written to file descriptor 2.
6695 .RE
6696
6697 .sp
6698 .LP
6699 The remaining options and arguments are described under the \fBset\fR command.
6700 An optional \fB-\fR as the first argument is ignored.
6701 .SS "\fBrksh93\fR Only"
6702 .LP
6703 \fBrksh93\fR is used to set up login names and execution environments whose
6704 capabilities are more controlled than those of the standard shell.
6705 .sp
6706 .LP
6707 The actions of \fBrksh93\fR are identical to those of \fBksh93\fR, except that
6708 the following are disallowed:
6709 .RS +4
6710 .TP
6711 .ie t \(bu
6712 .el o
6713 Unsetting the restricted option
6714 .RE
6715 .RS +4
6716 .TP
6717 .ie t \(bu
6718 .el o
6719 Changing directory. See \fBcd\fR(1).
6720 .RE
6721 .RS +4
6722 .TP
6749 .el o
6750 Using \fBcommand\fR \fB-p\fR to invoke a command.
6751 .RE
6752 .sp
6753 .LP
6754 These restrictions are enforced after .\fBprofile\fR and the \fBENV\fR files
6755 are interpreted.
6756 .sp
6757 .LP
6758 When a command to be executed is found to be a shell procedure, \fBrksh93\fR
6759 invokes \fBksh93\fR to execute it. Thus, it is possible to provide to the
6760 end-user shell procedures that have access to the full power of the standard
6761 shell, while imposing a limited menu of commands. This scheme assumes that the
6762 end-user does not have write and execute permissions in the same directory. The
6763 net effect of these rules is that the writer of the .\fBprofile\fR has complete
6764 control over user actions, by performing guaranteed setup actions and leaving
6765 the user in an appropriate directory (probably not the login directory). The
6766 system administrator often sets up a directory of commands, for example,
6767 \fB/usr/rbin\fR, that can be safely invoked by \fBrksh\fR.
6768 .SH USAGE
6769 .LP
6770 See \fBlargefile\fR(5) for the description of the behavior of \fBksh93\fR and
6771 \fBrksh93\fR when encountering files greater than or equal to 2 Gbyte ( 2^31
6772 bytes).
6773 .SH EXIT STATUS
6774 .LP
6775 The following exit values are returned:
6776 .sp
6777 .ne 2
6778 .na
6779 \fB\fBnon-zero\fR\fR
6780 .ad
6781 .sp .6
6782 .RS 4n
6783 Returns \fBnon-zero\fR when errors, such as syntax errors, are detected by the
6784 shell.
6785 .sp
6786 If the shell is being used non-interactively, then execution of the shell file
6787 is abandoned unless the error occurs inside a sub-shell in which case the
6788 sub-shell is abandoned.
6789 .RE
6790
6791 .sp
6792 .ne 2
6793 .na
6794 \fB\fIexit status of last command executed\fR\fR
6795 .ad
6796 .sp .6
6797 .RS 4n
6798 Returns the exit status of the last command executed.
6799 .sp
6800 Run time errors detected by the shell are reported by printing the command or
6801 function name and the error condition. If the line number that the error
6802 occurred on is greater than one, then the line number is also printed in square
6803 brackets (\fB[]\fR) after the command or function name.
6804 .sp
6805 See the \fBksh93 exit\fR command for additional details.
6806 .RE
6807
6808 .SH FILES
6809 .ne 2
6810 .na
6811 \fB\fB/etc/profile\fR\fR
6812 .ad
6813 .sp .6
6814 .RS 4n
6815 The system initialization file, executed for login shells.
6816 .RE
6817
6818 .sp
6819 .ne 2
6820 .na
6821 \fB\fB/etc/ksh.kshrc\fR\fR
6822 .ad
6823 .sp .6
6824 .RS 4n
6825 The system wide startup file, executed for interactive shells.
6826 .RE
6827
6828 .sp
6829 .ne 2
6830 .na
6831 \fB\fB$HOME/.profile\fR\fR
6832 .ad
6833 .sp .6
6834 .RS 4n
6835 The personal initialization file, executed for login shells after
6836 \fB/etc/profile\fR.
6837 .RE
6838
6839 .sp
6840 .ne 2
6841 .na
6842 \fB\fB$HOME/.kshrc\fR\fR
6843 .ad
6844 .sp .6
6845 .RS 4n
6846 Default personal initialization file, executed after \fB/etc/ksh.kshrc\fR, for
6847 interactive shells when \fBENV\fR is not set.
6848 .RE
6849
6850 .sp
6851 .ne 2
6852 .na
6853 \fB\fB/etc/suid-profile\fR\fR
6854 .ad
6855 .sp .6
6856 .RS 4n
6857 Alternative initialization file, executed instead of the personal
6858 initialization file when the real and effective user or group id do not match.
6859 .RE
6860
6861 .sp
6862 .ne 2
6863 .na
6864 \fB\fB/dev/null\fR\fR
6865 .ad
6866 .sp .6
6867 .RS 4n
6868 NULL device.
6869 .RE
6870
6871 .SH AUTHORS
6872 .LP
6873 David Korn, \fBdgk@research.att.com\fR
6874 .SH ATTRIBUTES
6875 .LP
6876 See \fBattributes\fR(5) for descriptions of the following attributes:
6877 .sp
6878
6879 .sp
6880 .TS
6881 box;
6882 c | c
6883 l | l .
6884 ATTRIBUTE TYPE ATTRIBUTE VALUE
6885 _
6886 Interface Stability See below.
6887 .TE
6888
6889 .sp
6890 .LP
6891 The scripting interface is Uncommitted. The environment variables,
6892 \fB\&.paths\fR feature, and editing modes are Volatile.
6893 .SH SEE ALSO
6894 .LP
6895 \fBcat\fR(1), \fBcd\fR(1), \fBchmod\fR(1), \fBcut\fR(1), \fBdate\fR(1),
6896 \fBegrep\fR(1), \fBecho\fR(1), \fBegrep\fR(1), \fBenv\fR(1), \fBfgrep\fR(1),
6897 \fBgrep\fR(1), \fBlogin\fR(1), \fBnewgrp\fR(1), \fBpaste\fR(1),
6898 \fBprintf\fR(1), \fBstty\fR(1), \fBtest\fR(1), \fBumask\fR(1), \fBvi\fR(1),
6899 \fBdup\fR(2), \fBexec\fR(2), \fBfork\fR(2), \fBioctl\fR(2), \fBlseek\fR(2),
6900 \fBpathconf\fR(2), \fBpipe\fR(2), \fBsysconf\fR(3C), \fBulimit\fR(2),
6901 \fBumask\fR(2), \fBrand\fR(3C), \fBtcgetattr\fR(3C), \fBwait\fR(3C),
6902 \fBa.out\fR(4), \fBprofile\fR(4), \fBattributes\fR(5), \fBenviron\fR(5),
6903 \fBlargefile\fR(5), \fBstandards\fR(5)
6904 .sp
6905 .LP
6906 Bolsky, Morris I. and Korn, David G., \fIThe New KornShell Command and
6907 Programming Language\fR, Prentice Hall, 1995.
6908 .sp
6909 .LP
6910 \fIPOSIX-Part 2: Shell and Utilities, IEEE Std 1003.2-1992, ISO/IEC 9945-2\fR,
6911 IEEE, 1993.
6912 .SH NOTES
6913 .LP
6914 \fBksh93\fR scripts should choose shell function names outside the namespace
6915 used by reserved keywords of the ISO C99, C++ and JAVA languages to avoid
6916 collisions with future enhancements to \fBksh93\fR.
6917 .sp
6918 .LP
6919 If a command is executed, and then a command with the same name is installed in
6920 a directory in the search path before the directory where the original command
6921 was found, the shell continues to \fBexec\fR the original command. Use the
6922 \fB-t\fR option of the alias command to correct this situation.
6923 .sp
6924 .LP
6925 Some very old shell scripts contain a caret (\fB^\fR) as a synonym for the pipe
6926 character (\fB|\fR).
6927 .sp
6928 .LP
6929 Using the \fBhist\fR built-in command within a compound command causes the
6930 whole command to disappear from the history file.
6931 .sp
6932 .LP
6933 The built-in command \fB\&.\fR \fIfile\fR reads the whole file before any
|
1 '\" te
2 .\" Copyright (c) 1982-2007 AT&T Knowledge Ventures
3 .\" To view license terms, see http://www.eclipse.org/org/documents/epl-v10.html
4 .\" Portions Copyright (c) 2009, Sun Microsystems, Inc.
5 .\" Portions Copyright 2021 OmniOS Community Edition (OmniOSce) Association.
6 .TH KSH93 1 "Jan 06, 2020"
7 .SH NAME
8 ksh93, rksh93 \- Korn Shell, a standard and restricted command and programming
9 language
10 .SH SYNOPSIS
11 .nf
12 \fBksh93\fR [\fB\(+-abcefhikmnoprstuvxBCD\fR] [\fB-R\fR \fIfile\fR] [ \fB\(+-o\fR \fIoption\fR] ...
13 [-] [\fIarg\fR ...]
14 .fi
15
16 .LP
17 .nf
18 \fBrksh93\fR [\fB\(+-abcefhikmnoprstuvxBCD\fR] [\fB-R\fR \fIfile\fR] [\fB\(+-o\fR \fIoption\fR] ...
19 [-] [\fIarg\fR ...]
20 .fi
21
22 .SH DESCRIPTION
23 \fBksh93\fR is a command and programming language that executes commands read
24 from a terminal or a file. \fBrksh93\fR is a restricted version of the command
25 interpreter \fBksh93\fR. \fBrksh93\fR is used to set up login names and
26 execution environments whose capabilities are more controlled than those of the
27 standard shell.
28 .sp
29 .LP
30 See \fBInvocation\fR for the meaning of arguments to the shell.
31 .SS "Definitions"
32 A \fImetacharacter\fR is defined as one of the following characters:
33 .sp
34 .in +2
35 .nf
36 ; & ( ) | < > NEWLINE SPACE TAB
37 .fi
38 .in -2
39 .sp
40
41 .sp
42 .LP
43 A \fIblank\fR is a \fBTAB\fR or a \fBSPACE\fR.
44 .sp
45 .LP
46 An \fIidentifier\fR is a sequence of letters, digits, or underscores starting
47 with a letter or underscore. Identifiers are used as components of \fIvariable
48 names\fR.
49 .sp
50 .LP
51 A \fIvname\fR is a sequence of one or more identifiers separated by a period
52 (\fB\&.\fR) and optionally preceded by a period (\fB\&.\fR). \fIvnames\fR are
53 used as function and variable names.
54 .sp
55 .LP
56 A \fIword\fR is a sequence of \fIcharacters\fR from the character set defined
57 by the current locale, excluding non-quoted \fImetacharacters\fR.
58 .sp
59 .LP
60 A \fIcommand\fR is a sequence of characters in the syntax of the shell
61 language. The shell reads each command and carries out the desired action
62 either directly or by invoking separate utilities. A built-in command is a
63 command that is carried out by the shell itself without creating a separate
64 process. Some commands are built-in purely for convenience and are not
65 documented in this manual page. Built-ins that cause side effects in the shell
66 environment and built-ins that are found before performing a path search (see
67 \fBExecution\fR) are documented in this manual page. For historical reasons,
68 some of these built-ins behave differently than other built-ins and are called
69 special built-ins.
70 .SS "Commands"
71 A \fIsimple-command\fR is a list of variable assignments (see \fBVariable
72 Assignments\fR) or a sequence of \fIblank\fR-separated words which can be
73 preceded by a list of variable assignments. See the \fBEnvironment\fR section
74 of this manual page.
75 .sp
76 .LP
77 The first word specifies the name of the command to be executed. Except as
78 specified in this section, the remaining words are passed as arguments to the
79 invoked command. The command name is passed as argument 0. See \fBexec\fR(2).
80 The \fIvalue\fR of a simple-command is its exit status. If it terminates
81 normally, its value is \fB0\fR-\fB255\fR. If it terminates abnormally, its
82 value is \fB256+\fR\fIsignum\fR. The name of the signal corresponding to the
83 exit status can be obtained by way of the \fB-l\fR option of the kill built-in
84 utility.
85 .sp
86 .LP
87 A \fIpipeline\fR is a sequence of one or more commands separated by \fB|\fR.
88 The standard output of each command but the last is connected by a
89 \fBpipe\fR(2) to the standard input of the next command. Each command, except
90 possibly the last, is run as a separate process. The shell waits for the last
109 pipe established to the parent shell. The standard input and output of the
110 spawned pipeline can be written to and read from by the parent shell by
111 applying the redirection operators \fB<&\fR and \fB>&\fR with \fBarg p\fR to
112 commands and by using \fB-p\fR option of the built-in commands \fBread\fR and
113 \fBprint\fR. The symbol \fB&&\fR (\fB||\fR) causes the \fIlist\fR following it
114 to be executed only if the preceding pipeline returns a zero (\fBnon-zero\fR)
115 value. One or more NEWLINEs can appear in a \fIlist\fR instead of a semicolon,
116 to delimit a command. The first \fIitem\fR of the first \fIpipeline\fR of a
117 \fIlist\fR that is a simple command not beginning with a redirection, and not
118 occurring within a \fBwhile\fR, \fBuntil\fR, or \fBif\fR \fIlist\fR , can be
119 preceded by a semicolon. This semicolon is ignored unless the \fBshowme\fR
120 option is enabled as described with the \fBset\fR built-in.
121 .sp
122 .LP
123 A \fIcommand\fR is either a simple-command or one of commands in the following
124 list. Unless otherwise stated, the value returned by a command is that of the
125 last simple-command executed in the command.
126 .sp
127 .ne 2
128 .na
129 \fBfor\fR \fIvname\fR \fB[ in\fR \fIword\fR \fB\&... ] ;do\fR \fIlist\fR
130 \fB;done\fR
131 .ad
132 .sp .6
133 .RS 4n
134 Each time a \fBfor\fR command is executed, \fIvname\fR is set to the next
135 \fIword\fR taken from the \fBin\fR \fIword\fR list. If \fBin\fR \fIword ...\fR
136 is omitted, the \fBfor\fR command executes the \fBdo\fR \fIlist\fR once for
137 each positional parameter that is set starting from 1. Execution ends when
138 there are no more words in the list. See \fBParameter Expansion\fR.
139 .RE
140
141 .sp
142 .ne 2
143 .na
144 \fBfor (( [\fR\fIexpr1\fR\fB] ; [\fR\fIexpr2\fR] ; [\fIexpr3\fR\fB] )) ;do\fR
145 \fIlist\fR \fB;done\fR
146 .ad
147 .sp .6
148 .RS 4n
149 The arithmetic expression \fIexpr1\fR is evaluated first. The arithmetic
150 expression \fIexpr2\fR is repeatedly evaluated until it evaluates to \fBzero\fR
151 and when \fBnon-zero\fR, \fIlist\fR is executed and the arithmetic expression
152 \fIexpr3\fR evaluated. If any expression is omitted, then it behaves as if it
153 evaluated to \fB1\fR. See \fBArithmetic Evaluation\fR.
154 .RE
155
156 .sp
157 .ne 2
158 .na
159 \fBselect\fR \fIvname\fR [ in \fIword\fR \fB\&... ] ;do\fR \fIlist\fR
160 \fB;done\fR
161 .ad
162 .sp .6
163 .RS 4n
164 A \fBselect\fR command prints on standard error (file descriptor 2) the set of
165 \fIwords\fR, each preceded by a number. If \fBin\fR \fIword...\fR is omitted,
166 the positional parameters starting from \fB1\fR are used instead. See
167 \fBParameter Expansion\fR. The \fBPS3\fR prompt is printed and a line is read
168 from the standard input. If this line consists of the number of one of the
169 listed \fIword\fRs, then the value of the variable \fIvname\fR is set to the
170 \fIword\fR corresponding to this number. If this line is empty, the selection
171 list is printed again. Otherwise the value of the variable \fIvname\fR is set
172 to \fBnull\fR. The contents of the line read from standard input is saved in
173 the variable \fBREPLY\fR. The \fIlist\fR is executed for each selection until a
174 break or \fBEOF\fR is encountered. If the \fBREPLY\fR variable is set to
175 \fBnull\fR by the execution of \fIlist\fR, the selection list is printed before
176 displaying the \fBPS3\fR prompt for the next selection.
177 .RE
178
179 .sp
180 .ne 2
181 .na
182 \fBcase\fR \fIword\fR \fBin [ [(]\fR \fIpattern\fR \fB[ |\fR \fIpattern\fR
183 \fB] ... )\fR \fIlist\fR \fB;; ] ... esac\fR
184 .ad
185 .sp .6
186 .RS 4n
187 A \fBcase\fR command executes the \fIlist\fR associated with the first
188 \fIpattern\fR that matches \fIword\fR. The form of the patterns is the same as
189 that used for file name generation. See \fBFile Name Generation\fR.
190 .sp
191 The \fB;;\fR operator causes execution of \fBcase\fR to terminate. If \fB;&\fR
192 is used in place of \fB;;\fR the next subsequent list, if any, is executed.
193 .RE
194
195 .sp
196 .ne 2
197 .na
198 \fBif\fR \fIlist\fR \fB;then\fR \fIlist\fR \fB[ ;elif\fR \fIlist\fR
199 \fB;then\fR \fIlist\fR ] \fB\&... [ ;else\fR \fIlist\fR \fB]\fR \fB;fi\fR
200 .ad
201 .sp .6
202 .RS 4n
203 The \fIlist\fR following \fBif\fR is executed and, if it returns a \fBzero\fR
204 exit status, the \fIlist\fR following the first \fBthen\fR is executed.
205 Otherwise, the \fIlist\fR following \fBelif\fR is executed, and, if its value
206 is \fBzero\fR, the \fIlist\fR following the next \fBthen\fR is executed.
207 Failing each successive \fBelif\fR \fIlist\fR, the \fBelse\fR \fIlist\fR is
208 executed. If the \fBif\fR \fIlist\fR has \fBnon-zero\fR exit status and there
209 is no \fBelse\fR \fIlist\fR, then the \fBif\fR command returns a \fBzero\fR
210 exit status.
211 .RE
212
213 .sp
214 .ne 2
215 .na
216 \fBwhile\fR \fIlist\fR \fB;do\fR \fIlist\fR \fB;done\fR
217 .ad
218 .br
219 .na
220 \fBuntil \fIlist\fR \fB;do\fR \fIlist\fR \fB;done\fR
221 .ad
222 .sp .6
223 .RS 4n
224 A \fBwhile\fR command repeatedly executes the while \fIlist\fR and, if the exit
225 status of the last command in the list is zero, executes the \fBdo\fR
226 \fIlist\fR, otherwise the loop terminates. If no commands in the \fBdo\fR
227 \fIlist\fR are executed, then the \fBwhile\fR command returns a \fBzero\fR exit
228 status, \fBuntil\fR can be used in place of \fBwhile\fR to negate the loop
229 termination test.
230 .RE
231
232 .sp
233 .ne 2
234 .na
235 \fB((\fR\fIexpression\fR\fB))\fR
236 .ad
237 .sp .6
238 .RS 4n
239 The \fIexpression\fR is evaluated using the rules for arithmetic evaluation
240 described in this manual page. If the value of the arithmetic expression is
241 \fBnon-zero\fR, the exit status is \fB0\fR. Otherwise the exit status is
242 \fB1\fR.
243 .RE
244
245 .sp
246 .ne 2
247 .na
248 \fB(\fR\fIlist\fR\fB)\fR
249 .ad
250 .sp .6
251 .RS 4n
252 Execute \fIlist\fR in a separate environment. If two adjacent open parentheses
253 are needed for nesting, a SPACE must be inserted to avoid evaluation as an
254 arithmetic command as described in this section.
255 .RE
256
257 .sp
258 .ne 2
259 .na
260 \fB{\fR \fIlist\fR\fB;}
261 .sp
262 .RS 4n
263 \fIlist\fR is simply executed. Unlike the metacharacters, \fB(\fR and \fB)\fR,
264 \fB{\fR and \fB}\fR are \fIreserved words\fR and must occur at the beginning of
265 a line or after a \fB;\fR to be recognized.
266 .RE
267
268 .sp
269 .ne 2
270 .na
271 \fB[[\fR \fIexpression\fR \fB]]\fR
272 .ad
273 .sp .6
274 .RS 4n
275 Evaluates \fIexpression\fR and returns a \fBzero\fR exit status when
276 \fIexpression\fR is true. See \fBConditional Expressions\fR for a description
277 of \fIexpression\fR.
278 .RE
279
280 .sp
281 .ne 2
282 .na
283 \fBfunction\fR \fIvarname\fR \fB{\fR \fIlist\fR \fB;}\fR
284 .ad
285 .br
286 .na
287 \fB\fIvarname\fR \fB() {\fR \fIlist\fR \fB;}\fR
288 .ad
289 .sp .6
290 .RS 4n
291 Define a function which is referenced by \fIvarname\fR. A function whose
292 \fIvarname\fR contains a dot (\fB\&.\fR) is called a discipline function and the
293 portion of the \fIvarname\fR preceding the last \fB\&.\fR must refer to an
294 existing variable.
295 .sp
296 The body of the function is the \fIlist\fR of commands between \fB{\fR and
297 \fB}\fR. A function defined with the function \fIvarname\fR syntax can also be
298 used as an argument to the \fB\&.\fR special built-in command to get the
299 equivalent behavior as if the \fIvarname\fR\fB()\fR syntax were used to define
300 it. See \fBFunctions\fR.
301 .RE
302
303 .sp
304 .ne 2
305 .na
306 \fBnamespace\fR \fIidentifier\fR \fB{\fR \fIlist\fR \fB};\fR
307 .ad
308 .sp .6
309 .RS 4n
310 Defines or uses the name space \fIidentifier\fR and runs the commands in
311 \fIlist\fR in this name space.
312 See \fBName Spaces\fR.
313 .RE
314
315 .sp
316 .ne 2
317 .na
318 \fBtime [\fR \fIpipeline\fR \fB]\fR
319 .ad
320 .sp .6
321 .RS 4n
322 If \fIpipeline\fR is omitted, the user and system time for the current shell
323 and completed child processes is printed on standard error. Otherwise,
324 \fIpipeline\fR is executed and the elapsed time as well as the user and system
325 time are printed on standard error. The \fBTIMEFORMAT\fR variable can be set to
326 a format string that specifies how the timing information should be displayed.
327 See \fBShell Variables\fR for a description of the \fBTIMEFORMAT\fR variable.
328 .RE
329
330 .sp
331 .LP
332 The following reserved words are recognized as reserved only when they are the
333 first word of a command and are not quoted:
334 .sp
335 .in +2
336 \fBcase\fR
337 .in -2
338 .br
339 .in +2
340 \fBdo\fR
341 .in -2
342 .br
343 .in +2
344 \fBdone\fR
345 .in -2
346 .br
347 .in +2
348 \fBelse\fR
349 .in -2
350 .br
351 .in +2
352 \fBelif\fR
353 .in -2
354 .br
387 .in +2
388 \fBuntil\fR
389 .in -2
390 .br
391 .in +2
392 \fBwhile\fR
393 .in -2
394 .br
395 .in +2
396 \fB{ }\fR
397 .in -2
398 .br
399 .in +2
400 \fB[[ ]]\fR
401 .in -2
402 .br
403 .in +2
404 \fB!\fR
405 .in -2
406 .SS "Variable Assignments"
407 One or more variable assignments can start a simple command or can be arguments
408 to the \fBtypeset\fR, \fBenum\fR, \fBexport\fR, or \fBreadonly\fR special
409 built-in commands. The syntax for an \fIassignment\fR is of the form:
410 .sp
411 .ne 2
412 .na
413 \fB\fIvarname\fR\fB=\fR\fIword\fR
414 .ad
415 .br
416 .na
417 \fB\fIvarname\fR\fB[\fR\fIword\fR\fB]=\fR\fIword\fR
418 .ad
419 .sp .6
420 .RS 4n
421 No space is permitted between \fIvarname\fR and the \fB=\fR or between \fB=\fR
422 and \fIword\fR.
423 The variable \fIvarname\fR is unset before the assignment.
424 .RE
425
426 .sp
427 .ne 2
428 .na
429 \fB\fIvarname\fR\fB=(\fR\fIassignlist\fR\fB)\fR
430 .ad
431 .sp .6
432 .RS 4n
433 No space is permitted between \fIvarname\fR and the \fB=\fR. An
434 \fIassignlist\fR can be one of the following:
435 .sp
436 .ne 2
437 .na
438 \fB\fIword ...\fR
439 .ad
440 .sp .6
441 .RS 4n
442 Indexed array assignment.
443 .RE
444
445 .sp
446 .ne 2
447 .na
448 \fB[\fR\fIword\fR\fB]=\fR\fIword ...\fR
449 .ad
450 .sp .6
451 .RS 4n
452 Associative array assignment. If prefixed by \fBtypeset\fR \fB-a\fR, creates an
453 indexed array instead.
454 .RE
455
456 .sp
457 .ne 2
458 .na
459 \fB\fIassignment ...\fR
460 .ad
461 .sp .6
462 .RS 4n
463 Compound variable assignment. This creates a compound variable \fIvarname\fR
464 with sub-variables of the form \fIvarname.name\fR, where \fIname\fR is the name
465 portion of assignment. The value of \fIvarname\fR contains all the assignment
466 elements. Additional assignments made to sub-variables of \fIvarname\fR are
467 also displayed as part of the value of \fIvarname\fR. If no \fIassignment\fRs
468 are specified, \fIvarname\fR is a compound variable allowing subsequence child
469 elements to be defined.
470 .RE
471
472 .sp
473 .ne 2
474 .na
475 \fBtypeset [\fR\fIoptions\fR] \fIassignment\fR \fB\&...\fR
476 .ad
477 .sp .6
478 .RS 4n
479 Nested variable assignment. Multiple assignments can be specified by separating
480 each of them with a \fB;\fR. The previous value is unset before the assignment.
481 .RE
482
483 .sp
484 .ne 2
485 .na
486 \fB.\fR \fIfilename\fR
487 .ad
488 .sp .6
489 .RS 4n
490 Include the assignment commands contained in \fIfilename\fR.
491 .RE
492
493 In addition, a \fB+=\fR can be used in place of the \fB=\fR to signify adding
494 to or appending to the previous value. When \fB+=\fR is applied to an
495 arithmetic type, \fIword\fR is evaluated as an arithmetic expression and added
496 to the current value. When applied to a string variable, the value defined by
497 \fIword\fR is appended to the value. For compound assignments, the previous
498 value is not unset and the new values are appended to the current ones provided
499 that the types are compatible.
500
501 The right hand side of a variable assignment undergoes all the expansion
502 listed below except word splitting, brace expansion, and file name generation.
503 When the left hand side is an assignment is a compound variable and
504 the right hand is the name of a compound variable, the compound variable
505 on the right will be copied or appended to the compound variable on the left.
506
507 .RE
508
509 .SS "Comments"
510 A word beginning with \fB#\fR causes that word and all the following characters
511 up to a NEWLINE to be commented, or ignored.
512 .SS "Aliasing"
513 The first word of each command is replaced by the text of an alias if an alias
514 for this word has been defined. An alias name consists of any number of
515 characters excluding metacharacters, quoting characters, file expansion
516 characters, parameter expansion characters, command substitution characters,
517 the characters \fB/\fR and \fB=\fR. The replacement string can contain any
518 valid shell script including the metacharacters listed in the \fBCommands\fR
519 section. The first word of each command in the replaced text, other than any
520 that are in the process of being replaced, are tested for aliases. If the last
521 character of the alias value is a BLANK then the word following the alias is
522 also checked for alias substitution.
523 .sp
524 .LP
525 Aliases can be used to redefine built-in commands but cannot be used to
526 redefine the reserved words listed in the \fBCommands\fR section. Aliases can
527 be created and listed with the alias command and can be removed with the
528 \fBunalias\fR command.
529 .sp
530 .LP
531 Aliasing is performed when scripts are read, not while they are executed. For
532 an alias to take effect, the \fBalias\fR definition command has to be executed
533 before the command which references the alias is read. The following aliases
534 are compiled into the shell but can be unset or redefined:
535 .sp
536 .in +2
537 .nf
538 autoload='typeset -fu'
539 command='command '
540 compound='typeset -C'
541 fc=hist
542 float='typeset -lE'
543 functions='typeset -f'
544 hash='alias -t --'
545 history='hist -l'
546 integer='typeset -li'
547 nameref='typeset -n'
548 nohup='nohup '
549 r='hist -s'
550 redirect='command exec'
551 source='command .'
552 stop='kill -s STOP'
553 suspend='kill -s STOP $$'
554 times='{ { time;} 2>&1;}'
555 type='whence -v'
556 .fi
557 .in -2
558 .sp
559
560 .SS "Tilde Substitution"
561 After alias substitution is performed, each word is checked to see if it begins
562 with an unquoted tilde (\fB~\fR). For tilde substitution, \fIword\fR also
563 refers to the \fIword\fR portion of parameter expansion. See \fBParameter
564 Expansion\fR.
565 .sp
566 .LP
567 If it does, the word up to a \fB/\fR is checked to see if it matches a user
568 name in the password database. If a match is found, the \fB~\fR and the matched
569 login name are replaced by the login directory of the matched user. If no match
570 is found, the original text is left unchanged. A \fB~\fR by itself, or in front
571 of a \fB/\fR, is replaced by \fB$HOME\fR. A \fB~\fR followed by a \fB+\fR or
572 \fB-\fR is replaced by the value of \fB$PWD\fR and \fB$OLDPWD\fR respectively.
573 .sp
574 .LP
575 In addition, when expanding a \fIvariable assignment\fR, tilde substitution is
576 attempted when the value of the assignment begins with a \fB~\fR, and when a
577 \fB~\fR appears after a colon (\fB:\fR). The \fB:\fR also terminates a \fB~\fR
578 login name.
579 .SS "Command Substitution"
580 The standard output from a command enclosed in parentheses preceded by a dollar
581 sign ( \fB$(\fR\fIlist\fR\fB)\fR ), or in a brace group preceded by a dollar
582 sign ( \fB${\fR \fIlist\fR\fB;}\fR ), or in a pair of grave accents (\fB``\fR)
583 can be used as part or all of a word. Trailing NEWLINEs are removed. In the
584 second case, the \fB{\fR and \fB}\fR are treated as a reserved words so that
585 \fB{\fR must be followed by a blank and \fB}\fR must appear at the beginning of
586 the line or follow a \fB;\fR. In the third (obsolete) form, the string between
587 the quotes is processed for special quoting characters before the command is
588 executed. See \fBQuoting\fR.
589 .sp
590 .LP
591 The command substitution \fB$(cat file)\fR can be replaced by the equivalent
592 but faster \fB$(<file)\fR. The command substitution \fB$(\fR\fIn\fR\fB<#)\fR
593 expands to the current byte offset for file descriptor \fIn\fR. Except for the
594 second form, the command list is run in a subshell so that no side effects are
595 possible. For the second form, the final \fB}\fR will be recognized as a
596 reserved word after any token.
597 .SS "Arithmetic Substitution"
598 An arithmetic expression enclosed in double parentheses preceded by a dollar
599 sign ( \fB$((\fR\fIarithmetic_expression\fR\fB))\fR) is replaced by the value
600 of the arithmetic expression within the double parentheses.
601 .SS "Process Substitution"
602 Each command argument of the form \fB<(\fR\fIlist\fR\fB)\fR or
603 \fB>(\fR\fIlist\fR\fB)\fR runs process \fIlist\fR asynchronously connected to
604 some file in \fB/dev/fd\fR. The name of this file becomes the argument to the
605 command. If the form with \fB>\fR is selected then writing on this file
606 provides input for \fIlist\fR. If \fB<\fR is used, then the file passed as an
607 argument contains the output of the \fIlist\fR process.
608 .sp
609 .LP
610 For example,
611 .sp
612 .in +2
613 .nf
614 paste <(cut -f1 \fIfile1\fR) <(cut -f3 \fIfile2\fR) | tee \e
615 >(\fIprocess1\fR) >(\fIprocess2\fR)
616 .fi
617 .in -2
618 .sp
619
620 .sp
621 .LP
622 \fBcut\fRs fields 1 and 3 from the files \fIfile1\fR and \fIfile2\fR
623 respectively, \fBpaste\fRs the results together, and sends it to the processes
624 \fIprocess1\fR and \fIprocess2\fR. It also displays the results to the standard
625 output. The file, which is passed as an argument to the command, is a UNIX
626 \fBpipe\fR(2). Programs that expect to \fBlseek\fR(2) on the file do not work.
627 .sp
628 Process substitution of the form \fB<\fR(\fIlist\fR\fB)\fR can also be used
629 with the \fB<\fR redirection operator which causes the output of list to be
630 standard input or the input for whatever file descriptor is specified.
631 .SS "Parameter Expansion"
632 A parameter is a variable, one or more digits, or any of the characters
633 \fB*\fR, \fB@\fR, \fB#\fR, \fB?\fR, \fB-\fR, \fB$\fR, and \fB!\fR. A variable
634 is denoted by a \fIvname\fR. To create a variable whose \fIvname\fR contains a
635 \fB\&.\fR, a variable whose \fBvname\fR consists of everything before the
636 last . must already exist. A variable has a value and zero or more attributes.
637 Variables can be assigned values and attributes by using the \fBtypeset\fR
638 special built-in command. The attributes supported by the shell are described
639 later with the \fBtypeset\fR special built-in command. Exported variables pass
640 values and attributes to the environment.
641 .sp
642 .LP
643 The shell supports both indexed and associative arrays. An element of an array
644 variable is referenced by a subscript. A subscript for an indexed array is
645 denoted by an arithmetic expression, (see \fBArithmetic Evaluation\fR), between
646 a \fB[\fR and a \fB]\fR.
647 To assign values to an indexed array, use \fIvname\fR\fB=(\fR\fIvalue\fR
648 \&...\fB)\fR or \fBset -A\fR \fIvname value ...\fR .
649 The value of all subscripts must be in the range of
650 \fB0\fR through \fB4,194,303\fR. A negative subscript is treated as an offset
651 from the maximum current index +1 so that -1 refers to the last element.
652 Indexed arrays can be declared with the \fB-a\fR option to typeset. Indexed
653 arrays need not be declared. Any reference to a variable with a valid
654 subscript is legal and an array will be created if necessary.
655 .sp
656 .LP
657 An associative array is created with the \fB-A\fR option to \fBtypeset\fR. A
658 subscript for an associative array is denoted by a string enclosed between
659 \fB[\fR and \fB]\fR.
660 .sp
661 .LP
662 Referencing any array without a subscript is equivalent to referencing the
663 array with subscript \fB0\fR.
664 .sp
665 .LP
666 The value of a variable can be assigned by:
667 .sp
668 .in +2
669 .nf
670 \fIvname\fR=\fIvalue\fR [\fIvname\fR=\fIvalue\fR] ...
671 .fi
672 .in -2
673 .sp
674
675 .sp
676 .LP
677 or
678 .sp
679 .in +2
680 .nf
681 \fIvname\fR[\fIsubscript\fR]=\fIvalue\fR [\fIvname\fR[\fIsubscript\fR]=\fIvalue\fR] ...
682 .fi
683 .in -2
684 .sp
685 Note that no space is allowed before or after the \fB=\fR.
686 .sp
687 Attributes assigned by the \fItypeset\fR special built-in command apply to all
688 elements of the array.
689 An array element can be a simple variable, a compound variable or an array
690 variable.
691 An element of an indexed array can be either an indexed array or an associative
692 array.
693 An element of an associative array can also be either.
694 To refer to an array element that is part of an array
695 element, concatenate the subscript in brackets. For example, to refer
696 to the \fIfoobar\fR element of an associative array that is defined as the
697 third element of the indexed array, use
698 \fB${\fIvname\fR\fB[\fR\fI3\fR\fB][\fR\fIfoobar\fR\fB]}\fR
699 .sp
700 .LP
701 A \fInameref\fR is a variable that is a reference to another variable. A
702 \fInameref\fR is created with the \fB-n\fR attribute of \fBtypeset\fR. The
703 value of the variable at the time of the \fBtypeset\fR command becomes the
704 variable that is referenced whenever the \fInameref\fR variable is used. The
705 name of a \fInameref\fR cannot contain a dot (\fI\&.\fR). When a variable or
706 function name contains a dot (\fB\&.\fR) and the portion of the name up to the
707 first \fB\&.\fR matches the name of a \fInameref\fR, the variable referred to
708 is obtained by replacing the \fInameref\fR portion with the name of the
709 variable referenced by the \fInameref\fR. If a \fInameref\fR is used as the
710 index of a \fBfor\fR loop, a name reference is established for each item in the
711 list. A \fInameref\fR provides a convenient way to refer to the variable inside
712 a function whose name is passed as an argument to a function. For example, if
713 the name of a variable is passed as the first argument to a function, the
714 command
715 .sp
716 .in +2
717 .nf
718 typeset -n var=$1
719 .fi
720 .in -2
721 .sp
722
723 .sp
724 .LP
725 inside the function causes references and assignments to \fIvar\fR to be
726 references and assignments to the variable whose name has been passed to the
727 function. If any of the floating point attributes, \fB-E\fR,\fB-F\fR or
728 \fB-X\fR, or the integer attribute, \fB-i\fR, is set for \fIvname\fR, then the
729 \fIvalue\fR is subject to arithmetic evaluation as described in this manual
730 page. Positional parameters, parameters denoted by a number, can be assigned
731 values with the \fBset\fR special built-in command. Parameter \fB$0\fR is set
732 from argument zero when the shell is invoked.
733 .sp
734 The character \fB$\fR is used to introduce substitutable parameters.
735 .sp
736 .ne 2
737 .na
738 \fB${\fR\fIparameter\fR\fB}\fR
739 .ad
740 .sp .6
741 .RS 4n
742 The shell reads all the characters from \fB${\fR to the matching \fB}\fR as
743 part of the same word even if it contains braces or metacharacters. The value,
744 if any, of the parameter is substituted. The braces are required when
745 \fIparameter\fR is followed by a letter, digit, or underscore that is not to be
746 interpreted as part of its name or when the variable name contains a dot
747 (\fB\&.\fR). The braces are also required when a variable is subscripted unless
748 it is part of an Arithmetic Expression or a Conditional Expression. If
749 \fIparameter\fR is one or more digits then it is a positional parameter. A
750 positional parameter of more than one digit must be enclosed in braces. If
751 \fIparameter\fR is \fB*\fR or \fB@\fR, then all the positional parameters,
752 starting with \fB$1\fR, are substituted and separated by a field separator
753 character. If an array \fIvname\fR with last subscript \fB*\fR or \fB@\fR is
754 used, or for index arrays of the form \fIsub1\fR \fB\&..\fR \fIsub2\fR is used,
755 then the value for each of the elements between \fIsub1\fR and \fIsub2\fR
756 inclusive (or all elements for \fB*\fR and \fB@\fR) is substituted, separated
757 by the first character of the value of \fBIFS\fR.
758 .RE
759
760 .sp
761 .ne 2
762 .na
763 \fB${#\fR\fIparameter\fR\fB}\fR
764 .ad
765 .sp .6
766 .RS 4n
767 If \fIparameter\fR is \fB*\fR or \fB@\fR, the number of positional parameters
768 is substituted. Otherwise, the length of the value of the \fIparameter\fR is
769 substituted.
770 .RE
771
772 .sp
773 .ne 2
774 .na
775 \fB${#\fR\fIvname\fR\fB[*]}\fR
776 .ad
777 .br
778 .na
779 \fB${#\fR\fIvname\fR\fB[@]}\fR
780 .ad
781 .sp .6
782 .RS 4n
783 The number of elements in the array \fIvname\fR is substituted.
784 .RE
785
786 .ne 2
787 .na
788 \fB${@\fR\fIvname\fR\fB}\fR
789 .ad
790 .sp .6
791 .RS 4n
792 Expands to the type name or attributes of the variable referred to by
793 \fIvname\fR. See \fIType Variables\fR.
794 .RE
795
796 .sp
797 .ne 2
798 .na
799 \fB${!\fR\fIvname\fR\fB}\fR
800 .ad
801 .sp .6
802 .RS 4n
803 Expands to the name of the variable referred to by \fIvname\fR. This is
804 \fIvname\fR except when \fIvname\fR is a name reference.
805 .RE
806
807 .sp
808 .ne 2
809 .na
810 \fB${!\fR\fIvname\fR\fB[\fR\fIsubscript\fR\fB]}\fR
811 .ad
812 .sp .6
813 .RS 4n
814 Expands to name of the subscript unless \fIsubscript\fR is \fB*\fR or \fB@\fR,
815 or of the form \fIsub1\fR \fB..\fR \fIsub2\fR.
816 When \fIsubscript\fR is \fB*\fR, the list of array subscripts for \fIvname\fR
817 is generated. For a variable that is not an array, the value is \fB0\fR if the
818 variable is set, otherwise it is \fBnull\fR. When \fIsubscript\fR is \fB@\fR,
819 it is the same as \fB$ {\fR\fIvname\fR\fB[\fR\fI*\fR\fB]}\fR, except that when
820 used in double quotes, each array subscript yields a separate argument.
821 When subscript is of the form \fIsub1\fR \fB..\fR \fIsub2\fR it expands to the
822 list of subscripts between \fIsub1\fR and \fIsub2\fR inclusive using the same
823 quoting rules as \fB@\fR.
824 .RE
825
826 .sp
827 .ne 2
828 .na
829 \fB${!\fR\fIprefix\fR\fB*}\fR
830 .ad
831 .sp .6
832 .RS 4n
833 Expands to the names of the variables whose names begin with \fIprefix\fR.
834 .RE
835
836 .sp
837 .ne 2
838 .na
839 \fB${\fR\fIparameter\fR\fB:-\fR\fIword\fR\fB}\fR
840 .ad
841 .sp .6
842 .RS 4n
843 If \fIparameter\fR is set and is non-null then substitute its value. Otherwise
844 substitute \fIword\fR.
845 .RE
846
847 .sp
848 .ne 2
849 .na
850 \fB${\fR\fIparameter\fR\fB:=\fR\fIword\fR\fB}\fR
851 .ad
852 .sp .6
853 .RS 4n
854 If \fIparameter\fR is not set or is \fBnull\fR, set it to \fIword\fR. The value
855 of the parameter is then substituted. Positional parameters cannot be assigned
856 to in this way.
857 .RE
858
859 .sp
860 .ne 2
861 .na
862 \fB${\fR\fIparameter\fR\fB:?\fR\fIword\fR\fB}\fR
863 .ad
864 .sp .6
865 .RS 4n
866 If \fIparameter\fR is set and is non-null, substitute its value. Otherwise,
867 print \fIword\fR and exit from the shell , if the shell is not interactive. If
868 \fIword\fR is omitted then a standard message is printed.
869 .RE
870
871 .sp
872 .ne 2
873 .na
874 \fB${\fR\fIparameter\fR\fB:+\fR\fIword\fR\fB}\fR
875 .ad
876 .sp .6
877 .RS 4n
878 If \fIparameter\fR is set and is non-null, substitute \fIword\fR. Otherwise
879 substitute nothing.
880 .RE
881
882 In the above, \fIword\fR is not evaluated unless it is to be used as the
883 substituted string. In the following example, \fBpwd\fR is executed only if
884 \fBd\fR is not set or is NULL:
885 .sp
886 .in +2
887 .nf
888 print ${d:-$(pwd)}
889 .fi
890 .in -2
891 .sp
892
893 If the colon (\fB:\fR) is omitted from the expression, the shell only checks
894 whether \fIparameter\fR is set or not.
895
896 .sp
897 .ne 2
898 .na
899 \fB${\fR\fIparameter\fR\fB:\fR\fIoffset\fR:\fIlength\fR}\fR
900 .ad
901 .br
902 .na
903 \fB${\fR\fIparameter\fR\fB:\fR\fIoffset\fR\fB}\fR
904 .ad
905 .sp .6
906 .RS 4n
907 Expands to the portion of the value of \fIparameter\fR starting at the
908 character (counting from \fB0\fR) determined by expanding offset as an
909 arithmetic expression and consisting of the number of characters determined by
910 the arithmetic expression defined by \fIlength\fR.
911 .sp
912 In the second form, the remainder of the value is used. A negative offset
913 counts backwards from the end of \fIparameter\fR.
914 .sp
915 One or more BLANKs is required in front of a minus sign to prevent the shell
916 from interpreting the operator as \fB:-\fR. If parameter is \fB*\fR or \fB@\fR,
917 or is an array name indexed by \fB*\fR or \fB@\fR, then \fIoffset\fR and
918 \fIlength\fR refer to the array index and number of elements respectively. A
919 negative \fIoffset\fR is taken relative to one greater than the highest
920 subscript for indexed arrays. The order for associative arrays is unspecified.
921 .RE
922
923 .sp
924 .ne 2
925 .na
926 \fB${\fR\fIparameter\fR\fB#\fR\fIpattern\fR\fB}\fR
927 .ad
928 .br
929 .na
930 \fB${\fR\fIparameter\fR\fB##\fR\fIpattern\fR\fB}\fR
931 .ad
932 .sp .6
933 .RS 4n
934 If the shell \fIpattern\fR matches the beginning of the value of
935 \fIparameter\fR, then the value of this expansion is the value of the
936 \fIparameter\fR with the matched portion deleted. Otherwise the value of this
937 \fIparameter\fR is substituted. In the first form the smallest matching
938 \fIpattern\fR is deleted and in the second form the largest matching
939 \fIpattern\fR is deleted. When \fIparameter\fR is \fB@\fR, \fB*\fR, or an array
940 variable with subscript \fB@\fR or \fB*\fR, the substring operation is applied
941 to each element in turn.
942 .RE
943
944 .sp
945 .ne 2
946 .na
947 \fB${\fR\fIparameter\fR\fB%\fR\fIpattern\fR\fB}\fR
948 .ad
949 .br
950 .na
951 \fB${\fR\fIparameter\fR\fB%%\fR\fIpattern\fR\fB}\fR
952 .ad
953 .sp .6
954 .RS 4n
955 If the shell \fIpattern\fR matches the end of the value of \fIparameter\fR,
956 then the value of this expansion is the value of the parameter with the matched
957 part deleted. Otherwise substitute the value of \fIparameter\fR. In the first
958 form the smallest matching pattern is deleted, and in the second form the
959 largest matching pattern is deleted. When parameter is \fB@\fR, \fB*\fR, or an
960 array variable with subscript \fB@\fR or \fB*\fR, the substring operation is
961 applied to each element in turn.
962 .RE
963
964 .sp
965 .ne 2
966 .na
967 \fB${\fR\fIparameter\fR\fB/\fR\fIpattern\fR\fB/\fR\fIstring\fR\fB}\fR
968 .ad
969 .br
970 .na
971 \fB${\fR\fIparameter\fR\fB//\fR\fIpattern\fR\fB/\fR\fIstring\fR\fB}\fR
972 .ad
973 .br
974 .na
975 \fB${\fR\fIparameter\fR\fB/#\fR\fIpattern\fR\fB/\fR\fIstring\fR\fB}\fR
976 .ad
977 .br
978 .na
979 \fB${\fR\fIparameter\fR\fB/%\fR\fIpattern\fR\fB/\fR\fIstring\fR\fB}\fR
980 .ad
981 .sp .6
982 .RS 4n
983 Expands \fIparameter\fR and replaces the longest match of \fIpattern\fR with
984 the specified \fIstring\fR. Each occurrence of \fB\e\fR\fIn\fR in \fIstring\fR
985 is replaced by the portion of \fIparameter\fR that matches the \fIn\fR\fBth\fR
986 sub-pattern.
987 .sp
988 When \fIstring\fR is null, the \fIpattern\fR is deleted and the \fB/\fR in
989 front of string can be omitted. When \fIparameter\fR is \fB@\fR, \fB*\fR, or an
990 array variable with subscript \fB@\fR or \fB*\fR, the substitution operation is
991 applied to each element in turn. In this case, the \fIstring\fR portion of
992 \fIword\fR is re-evaluated for each element.
993 .sp
994 In the first form, only the first occurrence of \fIpattern\fR is replaced.
995 .sp
996 In the second form, each match for \fIpattern\fR is replaced by the specified
997 \fIstring\fR.
998 .sp
999 The third form restricts the pattern match to the beginning of the
1000 \fIstring\fR.
1001 .sp
1002 The fourth form restricts the pattern match to the end of the \fIstring\fR.
1003 .RE
1004
1005 .sp
1006 .LP
1007 The following parameters are automatically set by the shell:
1008 .sp
1009 .ne 2
1010 .na
1011 \fB#\fR
1012 .ad
1013 .RS 19n
1014 The number of positional parameters in decimal.
1015 .RE
1016
1017 .sp
1018 .ne 2
1019 .na
1020 \fB-\fR
1021 .ad
1022 .RS 19n
1023 Options supplied to the shell on invocation or by the \fBset\fR command.
1024 .RE
1025
1026 .sp
1027 .ne 2
1028 .na
1029 \fB?\fR
1030 .ad
1031 .RS 19n
1032 The decimal value returned by the last executed command.
1033 .RE
1034
1035 .sp
1036 .ne 2
1037 .na
1038 \fB$\fR
1039 .ad
1040 .RS 19n
1041 The process number of this shell.
1042 .RE
1043
1044 .sp
1045 .ne 2
1046 .na
1047 \fB_\fR
1048 .ad
1049 .RS 19n
1050 Initially, the value of \fB_\fR is the absolute pathname of the shell or script
1051 being executed as passed in the environment. It is subsequently assigned the
1052 last argument of the previous command.
1053 .sp
1054 This parameter is not set for commands which are asynchronous. This parameter
1055 is also used to hold the name of the matching \fBMAIL\fR file when checking for
1056 mail.
1057 .RE
1058
1059 .sp
1060 .ne 2
1061 .na
1062 \fB!\fR
1063 .ad
1064 .RS 19n
1065 The process id or the pool name and job number of the last background command
1066 invoked or the most recent job put in the background with the
1067 \fBbg\fR built-in command. Background jobs started in a named pool with be
1068 in the form \fIpool\fR.\fInumber\fR where \fIpool\fR is the pool name and
1069 \fInumber\fR is the job number within that pool.
1070 .RE
1071
1072 .sp
1073 .ne 2
1074 .na
1075 \fB\&.sh.command\fR
1076 .ad
1077 .RS 19n
1078 When processing a \fBDEBUG\fR trap, this variable contains the current command
1079 line that is about to run.
1080 .RE
1081
1082 .sp
1083 .ne 2
1084 .na
1085 \fB\&.sh.edchar\fR
1086 .ad
1087 .RS 19n
1088 This variable contains the value of the keyboard character (or sequence of
1089 characters if the first character is an ESC, \fBASCII 033\fR) that has been
1090 entered when processing a \fBKEYBD\fR trap. If the value is changed as part of
1091 the trap action, then the new value replaces the key (or key sequence) that
1092 caused the trap. See the \fBKey Bindings\fR section of this manual page.
1093 .RE
1094
1095 .sp
1096 .ne 2
1097 .na
1098 \fB\&.sh.edcol\fR
1099 .ad
1100 .RS 19n
1101 The character position of the cursor at the time of the most recent \fBKEYBD\fR
1102 trap.
1103 .RE
1104
1105 .sp
1106 .ne 2
1107 .na
1108 \fB\&.sh.edmode\fR
1109 .ad
1110 .RS 19n
1111 The value is set to ESC when processing a \fBKEYBD\fR trap while in \fBvi\fR
1112 insert mode. Otherwise, \fB\&.sh.edmode\fR is null when processing a
1113 \fBKEYBD\fR trap. See the \fBvi Editing Mode\fR section of this manual page.
1114 .RE
1115
1116 .sp
1117 .ne 2
1118 .na
1119 \fB\&.sh.edtext\fR
1120 .ad
1121 .RS 19n
1122 The characters in the input buffer at the time of the most recent \fBKEYBD\fR
1123 trap. The value is null when not processing a \fBKEYBD\fR trap.
1124 .RE
1125
1126 .sp
1127 .ne 2
1128 .na
1129 \fB\&.sh.file\fR
1130 .ad
1131 .RS 19n
1132 The pathname of the file than contains the current command.
1133 .RE
1134
1135 .sp
1136 .ne 2
1137 .na
1138 \fB\&.sh.fun\fR
1139 .ad
1140 .RS 19n
1141 The name of the current function that is being executed.
1142 .RE
1143
1144 .sp
1145 .ne 2
1146 .na
1147 \fB\&.sh.match\fR
1148 .ad
1149 .RS 19n
1150 An indexed array which stores the most recent match and sub-pattern matches
1151 after conditional pattern matches that match and after variables expansions
1152 using the operators \fB#\fR, \fB%\fR, or \fB/\fR. The \fB0\fRth element stores
1153 the complete match and the \fIi\fRth element stores the \fIi\fRth sub-match.
1154 The \fB\&.sh.match\fR variable is unset when the variable that has expanded is
1155 assigned a new value.
1156 .RE
1157
1158 .sp
1159 .ne 2
1160 .na
1161 \fB\&.sh.math\fR
1162 .ad
1163 .RS 19n
1164 Used for defining arithmetic functions (see \fIArithmetic evaluation\fR) and
1165 stores the list of user-defined arithmetic functions.
1166 .RE
1167
1168 .sp
1169 .ne 2
1170 .na
1171 \fB\&.sh.name\fR
1172 .ad
1173 .RS 19n
1174 Set to the name of the variable at the time that a discipline function is
1175 invoked.
1176 .RE
1177
1178 .sp
1179 .ne 2
1180 .na
1181 \fB\&.sh.subscript\fR
1182 .ad
1183 .RS 19n
1184 Set to the name subscript of the variable at the time that a discipline
1185 function is invoked.
1186 .RE
1187
1188 .sp
1189 .ne 2
1190 .na
1191 \fB\&.sh.subshell\fR
1192 .ad
1193 .RS 19n
1194 The current depth for sub-shells and command substitution.
1195 .RE
1196
1197 .sp
1198 .ne 2
1199 .na
1200 \fB\&.sh.value\fR
1201 .ad
1202 .RS 19n
1203 Set to the value of the variable at the time that the set or append discipline
1204 function is invoked. When a user-defined arithmetic function is invoked, the
1205 value of \fB.sh.value\fR is saved and \fB.sh.value\fR is set to long double
1206 precision floating point. \fB.sh.value\fR is restored when the function
1207 returns.
1208 .RE
1209
1210 .sp
1211 .ne 2
1212 .na
1213 \fB\&.sh.version\fR
1214 .ad
1215 .RS 19n
1216 Set to a value that identifies the version of this shell.
1217 .RE
1218
1219 .sp
1220 .ne 2
1221 .na
1222 \fBLINENO\fR
1223 .ad
1224 .RS 19n
1225 The current line number within the script or function being executed.
1226 .RE
1227
1228 .sp
1229 .ne 2
1230 .na
1231 \fBOLDPWD\fR
1232 .ad
1233 .RS 19n
1234 The previous working directory set by the \fBcd\fR command.
1235 .RE
1236
1237 .sp
1238 .ne 2
1239 .na
1240 \fBOPTARG\fR
1241 .ad
1242 .RS 19n
1243 The value of the last option argument processed by the \fBgetopts\fR built-in
1244 command.
1245 .RE
1246
1247 .sp
1248 .ne 2
1249 .na
1250 \fBOPTIND\fR
1251 .ad
1252 .RS 19n
1253 The index of the last option argument processed by the \fBgetopts\fR built-in
1254 command.
1255 .RE
1256
1257 .sp
1258 .ne 2
1259 .na
1260 \fBPPID\fR
1261 .ad
1262 .RS 19n
1263 The process number of the parent of the shell.
1264 .RE
1265
1266 .sp
1267 .ne 2
1268 .na
1269 \fBPWD\fR
1270 .ad
1271 .RS 19n
1272 The present working directory set by the \fBcd\fR command.
1273 .RE
1274
1275 .sp
1276 .ne 2
1277 .na
1278 \fBRANDOM\fR
1279 .ad
1280 .RS 19n
1281 Each time this variable is referenced, a random integer, uniformly distributed
1282 between \fB0\fR and \fB32767\fR, is generated. The sequence of random numbers
1283 can be initialized by assigning a numeric value to \fBRANDOM\fR.
1284 .RE
1285
1286 .sp
1287 .ne 2
1288 .na
1289 \fBREPLY\fR
1290 .ad
1291 .RS 19n
1292 This variable is set by the \fBselect\fR statement and by the \fBread\fR
1293 built-in command when no arguments are supplied.
1294 .RE
1295
1296 .sp
1297 .ne 2
1298 .na
1299 \fBSECONDS\fR
1300 .ad
1301 .RS 19n
1302 Each time this variable is referenced, the number of seconds since shell
1303 invocation is returned. If this variable is assigned a value, then the value
1304 returned upon reference is the value that was assigned plus the number of
1305 seconds since the assignment.
1306 .RE
1307
1308 .sp
1309 .ne 2
1310 .na
1311 \fBSHLVL\fR
1312 .ad
1313 .RS 19n
1314 An integer variable the is incremented each time the shell is invoked and is
1315 exported. If \fBSHLVL\fR is not in the environment when the shell is invoked,
1316 it is set to 1.
1317 .RE
1318
1319 .sp
1320 .LP
1321 The following variables are used by the shell:
1322 .sp
1323 .ne 2
1324 .na
1325 \fBCDPATH\fR
1326 .ad
1327 .RS 14n
1328 Defines the search path for the \fBcd\fR command.
1329 .RE
1330
1331 .sp
1332 .ne 2
1333 .na
1334 \fBCOLUMNS\fR
1335 .ad
1336 .RS 14n
1337 Defines the width of the edit window for the shell edit modes and for printing
1338 select lists.
1339 .RE
1340
1341 .sp
1342 .ne 2
1343 .na
1344 \fBEDITOR\fR
1345 .ad
1346 .RS 14n
1347 If the \fBVISUAL\fR variable is not set, the value of this variable is checked
1348 for the patterns as described with \fBVISUAL\fR and the corresponding editing
1349 option is turned on.
1350 .sp
1351 See the \fBset\fR command in the \fBSpecial Command\fR section of this manual
1352 page.
1353 .RE
1354
1355 .sp
1356 .ne 2
1357 .na
1358 \fBENV\fR
1359 .ad
1360 .RS 14n
1361 Performs parameter expansion, command substitution, and arithmetic substitution
1362 on the value to generate the pathname of the script that is executed when the
1363 shell is invoked. This file is typically used for alias and function
1364 definitions. The default value is \fB$HOME/.kshrc\fR.
1365 .sp
1366 See the \fBInvocation\fR section of this manual page.
1367 .sp
1368 \fBENV\fR is not set by the shell.
1369 .RE
1370
1371 .sp
1372 .ne 2
1373 .na
1374 \fBFCEDIT\fR
1375 .ad
1376 .RS 14n
1377 Obsolete name for the default editor name for the \fBhist\fR command.
1378 \fBFCEDIT\fR is not used when \fBHISTEDIT\fR is set.
1379 .sp
1380 The shell specifies a default value to \fBFCEDIT\fR.
1381 .RE
1382
1383 .sp
1384 .ne 2
1385 .na
1386 \fBFIGNORE\fR
1387 .ad
1388 .RS 14n
1389 A pattern that defines the set of file names that is ignored when performing
1390 file name matching.
1391 .RE
1392
1393 .sp
1394 .ne 2
1395 .na
1396 \fBFPATH\fR
1397 .ad
1398 .RS 14n
1399 The search path for function definitions. The directories in this path are
1400 searched for a file with the same name as the function or command when a
1401 function with the \fB-u\fR attribute is referenced and when a command is not
1402 found. If an executable file with the name of that command is found, then it is
1403 read and executed in the current environment. Unlike \fBPATH\fR, the current
1404 directory must be represented explicitly by dot (\fB\&.\fR) rather than by
1405 adjacent colon (\fB:\fR) characters or a beginning or ending colon (\fB:\fR).
1406 .RE
1407
1408 .sp
1409 .ne 2
1410 .na
1411 \fBHISTCMD\fR
1412 .ad
1413 .RS 14n
1414 The number of the current command in the history file.
1415 .RE
1416
1417 .sp
1418 .ne 2
1419 .na
1420 \fBHISTEDIT\fR
1421 .ad
1422 .RS 14n
1423 The name for the default editor name for the \fBhist\fR command.
1424 .RE
1425
1426 .sp
1427 .ne 2
1428 .na
1429 \fBHISTFILE\fR
1430 .ad
1431 .RS 14n
1432 If this variable is set when the shell is invoked, the value is the pathname of
1433 the file that is used to store the command history. See the \fBCommand
1434 Re-entry\fR section of this manual page.
1435 .RE
1436
1437 .sp
1438 .ne 2
1439 .na
1440 \fBHISTSIZE\fR
1441 .ad
1442 .RS 14n
1443 If this variable is set when the shell is invoked, then the number of
1444 previously entered commands that are accessible by this shell is greater than
1445 or equal to this number. The default is \fB512\fR.
1446 .RE
1447
1448 .sp
1449 .ne 2
1450 .na
1451 \fBHOME\fR
1452 .ad
1453 .RS 14n
1454 The default argument (home directory) for the \fBcd\fR command.
1455 .sp
1456 \fBHOME\fR is not set by the shell. \fBHOME\fR is set by \fBlogin\fR(1).
1457 .RE
1458
1459 .sp
1460 .ne 2
1461 .na
1462 \fBIFS\fR
1463 .ad
1464 .RS 14n
1465 Internal field separators, normally SPACE, TAB, and NEWLINE that are used to
1466 separate the results of command substitution or parameter expansion and to
1467 separate fields with the built-in command read. The first character of the
1468 \fBIFS\fR variable is used to separate arguments for the \fB"$*"\fR
1469 substitution. See the \fBQuoting\fR section of this manual page.
1470 .sp
1471 Each single occurrence of an \fBIFS\fR character in the string to be split,
1472 that is not in the \fBissspace\fR character class, and any adjacent characters
1473 in \fBIFS\fR that are in the \fBissspace\fR character class, delimit a field.
1474 One or more characters in IFS that belong to the \fBissspace\fR character
1475 class, delimit a field. In addition, if the same \fBissspace\fR character
1476 appears consecutively inside \fBIFS\fR, this character is treated as if it were
1477 not in the \fBissspace\fR class, so that if \fBIFS\fR consists of two tab
1478 characters, then two adjacent tab characters delimit a null field.
1479 .sp
1480 The shell specifies a default value to \fBIFS\fR.
1481 .RE
1482
1483 .sp
1484 .ne 2
1485 .na
1486 \fBJOBMAX\fR
1487 .ad
1488 .RS 14n
1489 This variable defines the maximum number running background jobs that can run
1490 at a time. When this limit is reached, the shell will wait for a job to
1491 complete before staring a new job.
1492 .RE
1493
1494 .sp
1495 .ne 2
1496 .na
1497 \fBLANG\fR
1498 .ad
1499 .RS 14n
1500 This variable determines the locale category for any category not specifically
1501 selected with a variable starting with \fBLC_\fR or \fBLANG\fR.
1502 .RE
1503
1504 .sp
1505 .ne 2
1506 .na
1507 \fBLC_ALL\fR
1508 .ad
1509 .RS 14n
1510 This variable overrides the value of the \fBLANG\fR variable and any other
1511 \fBLC_\fR variable.
1512 .RE
1513
1514 .sp
1515 .ne 2
1516 .na
1517 \fBLC_COLLATE\fR
1518 .ad
1519 .RS 14n
1520 This variable determines the locale category for character collation
1521 information.
1522 .RE
1523
1524 .sp
1525 .ne 2
1526 .na
1527 \fBLC_CTYPE\fR
1528 .ad
1529 .RS 14n
1530 This variable determines the locale category for character handling functions.
1531 It determines the character classes for pattern matching. See the \fBFile Name
1532 Generation\fR section of this manual page.
1533 .RE
1534
1535 .sp
1536 .ne 2
1537 .na
1538 \fBLC_NUMERIC\fR
1539 .ad
1540 .RS 14n
1541 This variable determines the locale category for the decimal point character.
1542 .RE
1543
1544 .sp
1545 .ne 2
1546 .na
1547 \fBLINES\fR
1548 .ad
1549 .RS 14n
1550 If this variable is set, the value is used to determine the column length for
1551 printing select lists. Select lists prints vertically until about two-thirds of
1552 \fBLINES\fR lines are filled.
1553 .RE
1554
1555 .sp
1556 .ne 2
1557 .na
1558 \fBMAIL\fR
1559 .ad
1560 .RS 14n
1561 If this variable is set to the name of a mail file \fBand\fR the \fBMAILPATH\fR
1562 variable is not set, then the shell informs the user of arrival of mail in the
1563 specified file.
1564 .sp
1565 \fBMAIL\fR is not set by the shell. On some systems, \fBMAIL\fR is set by
1566 \fBlogin\fR(1).
1567 .RE
1568
1569 .sp
1570 .ne 2
1571 .na
1572 \fBMAILCHECK\fR
1573 .ad
1574 .RS 14n
1575 Specifies how often in seconds the shell checks for changes in the modification
1576 time of any of the files specified by the \fBMAILPATH\fR or \fBMAIL\fR
1577 variables. The default value is \fB600\fR seconds. When the time has elapsed
1578 the shell checks before issuing the next prompt.
1579 .sp
1580 The shell specifies a default value to \fBMAILCHECK\fR.
1581 .RE
1582
1583 .sp
1584 .ne 2
1585 .na
1586 \fBMAILPATH\fR
1587 .ad
1588 .RS 14n
1589 A colon ( \fB:\fR ) separated list of file names. If this variable is set, then
1590 the shell informs the user of any modifications to the specified files that
1591 have occurred within the last \fBMAILCHECK\fR seconds. Each file name can be
1592 followed by a \fB?\fR and a message that is printed. The message undergoes
1593 parameter expansion, command substitution, and arithmetic substitution with the
1594 variable \fB$_\fR defined as the name of the file that has changed. The default
1595 message is \fByou have mail in $_\fR.
1596 .RE
1597
1598 .sp
1599 .ne 2
1600 .na
1601 \fBPATH\fR
1602 .ad
1603 .RS 14n
1604 The search path for commands. Except in \fB\&.profile\fR, users cannot change
1605 \fBPATH\fR if executing under \fBrksh93\fR. See the \fBExecution\fR section of
1606 this manual page.
1607 .sp
1608 The shell specifies a default value to \fBPATH\fR.
1609 .RE
1610
1611 .sp
1612 .ne 2
1613 .na
1614 \fBPS1\fR
1615 .ad
1616 .RS 14n
1617 The value of this variable is expanded for parameter expansion, command
1618 substitution, and arithmetic substitution to define the primary prompt string
1619 which by default is \fB$\fR. The character \fB!\fR in the primary prompt string
1620 is replaced by the command number. Two successive occurrences of \fB!\fR
1621 produces a single \fB!\fR when the prompt string is printed. See the \fBCommand
1622 Re-entry\fR section of this manual page.
1623 .sp
1624 The shell specifies a default value to \fBPS1\fR.
1625 .RE
1626
1627 .sp
1628 .ne 2
1629 .na
1630 \fBPS2\fR
1631 .ad
1632 .RS 14n
1633 Secondary prompt string, by default, \fB>\fR.
1634 .sp
1635 The shell specifies a default value to \fBPS2\fR.
1636 .RE
1637
1638 .sp
1639 .ne 2
1640 .na
1641 \fBPS3\fR
1642 .ad
1643 .RS 14n
1644 Selection prompt string used within a select loop, by default \fB#?\fR.
1645 .sp
1646 The shell specifies a default value to \fBPS3\fR.
1647 .RE
1648
1649 .sp
1650 .ne 2
1651 .na
1652 \fBPS4\fR
1653 .ad
1654 .RS 14n
1655 The value of this variable is expanded for parameter evaluation, command
1656 substitution, and arithmetic substitution and precedes each line of an
1657 execution trace. By default, \fBPS4\fR is \fB+\fR. When \fBPS4\fR is unset, the
1658 execution trace prompt is also \fB+\fR .
1659 .sp
1660 The shell specifies a default value to \fBPS4\fR.
1661 .RE
1662
1663 .sp
1664 .ne 2
1665 .na
1666 \fBSHELL\fR
1667 .ad
1668 .RS 14n
1669 The pathname of the shell is kept in the environment. At invocation, if the
1670 basename of this variable is \fBrsh\fR, \fBrksh\fR, \fBrksh93\fR, or
1671 \fBkrsh\fR, the shell becomes restricted.
1672 .sp
1673 \fBSHELL\fR is not set by the shell. On some systems, \fBSHELL\fR is set by
1674 \fBlogin\fR(1).
1675 .RE
1676
1677 .sp
1678 .ne 2
1679 .na
1680 \fBTIMEFORMAT\fR
1681 .ad
1682 .RS 14n
1683 The value of this parameter is used as a format string specifying how the
1684 timing information for pipelines prefixed with the \fBtime\fR reserved word
1685 should be displayed. The \fB%\fR character introduces a format sequence that is
1686 expanded to a time value or other information.
1687 .sp
1688 The format sequences and their meanings are as follows.
1689 .sp
1690 .ne 2
1691 .na
1692 \fB%%\fR
1693 .ad
1694 .sp .6
1695 .RS 4n
1696 A literal \fB%\fR.
1697 .RE
1698
1699 .sp
1700 .ne 2
1701 .na
1702 \fB%[\fIp\fR][l]R\fR
1703 .ad
1704 .sp .6
1705 .RS 4n
1706 The elapsed time in seconds.
1707 .RE
1708
1709 .sp
1710 .ne 2
1711 .na
1712 \fB%[\fIp\fR][l]U\fR
1713 .ad
1714 .sp .6
1715 .RS 4n
1716 The number of CPU seconds spent in user mode.
1717 .RE
1718
1719 .sp
1720 .ne 2
1721 .na
1722 \fB%[\fIp\fR][l]S\fR
1723 .ad
1724 .sp .6
1725 .RS 4n
1726 The number of CPU seconds spent in system mode.
1727 .RE
1728
1729 .sp
1730 .ne 2
1731 .na
1732 \fB%P\fR
1733 .ad
1734 .sp .6
1735 .RS 4n
1736 The CPU percentage, computed as \fB(U + S) / R\fR.
1737 .RE
1738
1739 The braces denote optional portions. The optional \fIp\fR is a digit specifying
1740 the \fIprecision\fR, the number of fractional digits after a decimal point. A
1741 value of \fB0\fR causes no decimal point or fraction to be output. At most
1742 three places after the decimal point can be displayed. Values of \fIp\fR
1743 greater than \fB3\fR are treated as \fB3\fR. If \fIp\fR is not specified, the
1744 value \fB3\fR is used.
1745 .sp
1746 The optional \fBl\fR specifies a longer format, including hours if greater than
1747 zero, minutes, and seconds of the form \fIHHhMMmSS.FFs\fR. The value of \fIp\fR
1748 determines whether or not the fraction is included.
1749 .sp
1750 All other characters are output without change and a trailing NEWLINE is added.
1751 If unset, the default value, \fB$'\enreal\et%2lR\enuser\et%2lU\ensys%2lS'\fR,
1752 is used. If the value is null, no timing information is displayed.
1753 .RE
1754
1755 .sp
1756 .ne 2
1757 .na
1758 \fBTMOUT\fR
1759 .ad
1760 .RS 14n
1761 If set to a value greater than zero, \fBTMOUT\fR is the default time-out value
1762 for the \fBread\fR built-in command. The \fBselect\fR compound command
1763 terminates after \fBTMOUT\fR seconds when input is from a terminal. Otherwise,
1764 the shell terminates if a line is not entered within the prescribed number of
1765 seconds while reading from a terminal. The shell can be compiled with a maximum
1766 bound for this value which cannot be exceeded.
1767 .sp
1768 The shell specifies a default value to \fBTMOUT\fR.
1769 .RE
1770
1771 .sp
1772 .ne 2
1773 .na
1774 \fBVISUAL\fR
1775 .ad
1776 .RS 14n
1777 If the value of this variable matches the pattern \fB*[Vv][Ii]*\fR, then the
1778 \fBvi\fR option is turned on. See \fBSpecial Commands\fR. If the value matches
1779 the pattern \fB*gmacs*\fR , the \fBgmacs\fR option is turned on. If the value
1780 matches the pattern \fB*macs*\fR, then the \fBemacs\fR option is turned on. The
1781 value of \fBVISUAL\fR overrides the value of \fBEDITOR\fR.
1782 .RE
1783
1784 .SS "Field Splitting"
1785 After parameter expansion and command substitution, the results of
1786 substitutions are scanned for the field separator characters (those found in
1787 \fBIFS\fR) and split into distinct fields where such characters are found.
1788 Explicit null fields (\fB""\fR or \fB\&''\fR) are retained. Implicit null
1789 fields, those resulting from parameters that have no values or command
1790 substitutions with no output, are removed.
1791 .sp
1792 .LP
1793 If the \fBbraceexpand\fR (\fB-B\fR) option is set, each of the fields resulting
1794 from \fBIFS\fR are checked to see if they contain one or more of the brace
1795 patterns. Valid brace patterns: \fB{*\fR,\fB*}\fR,
1796 \fB{\fR\fIl1\fR\fB\&..\fR\fIl2\fR\fB}\fR ,
1797 \fB{\fR\fIn1\fR\fB\&..\fR\fIn2\fR\fB}\fR,
1798 \fB{\fR\fIn1\fR\fB\&..\fR\fIn2\fR\fB%\fR\fIfmt\fR\fB}
1799 {\fR\fIn1\fR\fB\&..\fR\fIn2\fR \fB\&..\fR\fIn3\fR\fB}\fR, or
1800 \fB{\fR\fIn1\fR\fB\&..\fR\fIn2\fR \fB\&..\fR\fIn3\fR\fB%\fR\fIfmt\fR\fB}\fR ,
1801 where \fB*\fR represents any character, \fIl1\fR,\fIl2\fR are letters and
1802 \fIn1\fR,\fIn2\fR,\fIn3\fR are signed numbers and \fIfmt\fR is a format
1803 specified as used by \fBprintf\fR. In each case, fields are created by
1804 prepending the characters before the \fB{\fR and appending the characters after
1810 In the first form, a field is created for each string between \fB{\fR and
1811 \fB,,\fR between \fB,\fR and \fB,,\fR and between , and \fB}\fR. The string
1812 represented by \fB*\fR can contain embedded matching { and } without quoting.
1813 Otherwise, each \fB{\fR and \fB}\fR with \fB*\fR must be quoted.
1814 .sp
1815 .LP
1816 In the second form, \fIl1\fR and \fIl2\fR must both be either upper case or
1817 both be lower case characters in the C locale. In this case a field is created
1818 for each character from \fIl1\fR through \fIl2\fR.
1819 .sp
1820 .LP
1821 In the remaining forms, a field is created for each number starting at
1822 \fIn1\fR. This continues until it reaches \fIn2\fR and increments \fIn1\fR by
1823 \fIn3\fR. The cases where \fIn3\fR is not specified behave as if \fIn3\fR were
1824 1 if \fIn1\fR\fB<=\fR\fIn2\fR, and \fB-1\fR otherwise. In forms which specify
1825 \fB%\fR\fIfmt\fR, any format flags, widths and precisions can be specified and
1826 \fIfmt\fR can end in any of the specifiers \fBcdiouxX\fR. For example,
1827 \fB{a,z}{1..5..3%02d}{b..c}x\fR expands to the 8 fields, \fBa01bx, a01cx,
1828 a04bx, a04cx, z01bx, z01cx, z04bx,\fR and \fBz04cx\fR.
1829 .SS "File Name Generation"
1830 Following splitting, each field is scanned for the characters \fB*\fR, \fB?\fR,
1831 \fB(\fR, and \fB[\fR, unless the \fB-f\fR option has been set. If one of these
1832 characters appears, then the word is regarded as a pattern.
1833 .sp
1834 .LP
1835 Each file name component that contains any pattern character is replaced with a
1836 lexicographically sorted set of names that matches the pattern from that
1837 directory. If no file name is found that matches the pattern, then that
1838 component of the file name is left unchanged unless the pattern is prefixed
1839 with \fB~(N)\fR in which case it is removed. If \fBFIGNORE\fR is set, then each
1840 file name component that matches the pattern defined by the value of
1841 \fBFIGNORE\fR is ignored when generating the matching file names. The names
1842 \fB\&.\fR and \fB\&..\fR are also ignored. If \fBFIGNORE\fR is not set, the
1843 character \fB\&.\fR at the start of each file name component is ignored unless
1844 the first character of the pattern corresponding to this component is the
1845 character \fB\&.\fR itself. For other uses of pattern matching the \fB/\fR and
1846 \fB\&.\fR are not specially treated.
1847 .sp
1848 .ne 2
1849 .na
1850 \fB*\fR
1851 .ad
1852 .RS 11n
1853 Match any string, including the null string. When used for file name expansion,
1854 if the \fBglobstar\fR option is on, two adjacent \fB*\fRs by themselves match
1855 all files and zero or more directories and subdirectories. If the two adjacent
1856 \fB*\fRs are followed by a \fB/\fR, only directories and subdirectories match.
1857 .RE
1858
1859 .sp
1860 .ne 2
1861 .na
1862 \fB?\fR
1863 .ad
1864 .RS 11n
1865 Matches any single character.
1866 .RE
1867
1868 .sp
1869 .ne 2
1870 .na
1871 \fB[\fB\&...\fR]\fR
1872 .ad
1873 .RS 11n
1874 Match any one of the enclosed characters. A pair of characters separated by
1875 \fB-\fR matches any character lexically between the pair, inclusive. If the
1876 first character following the opening \fB[\fR is a \fB!\fR or \fB^\fR, any
1877 character not enclosed is matched. A \fB-\fR can be included in the character
1878 set by putting it as the first or last character. Within \fB[\fR and \fB]\fR,
1879 character classes can be specified with the syntax \fB[:\fR\fIclass\fR\fB:]\fR
1880 where \fIclass\fR is one of the following classes defined in the \fBANSI-C\fR
1881 standard:
1882 .sp
1883 .in +2
1884 .nf
1885 \fIalnum alpha blank cntrl digit graph
1886 lower print punct space upper
1887 word xdigit\fR
1888 .fi
1889 .in -2
1890 .sp
1891
1892 \fIword\fR is equivalent to \fIalnum\fR plus the character \fB_\fR. Within
1893 \fB[\fR and \fB]\fR, an equivalence class can be specified with the syntax
1894 \fB[=\fR\fIc\fR\fB=]\fR which matches all characters with the same primary
1895 collation weight (as defined by the current locale) as the character \fIc\fR.
1896 Within \fB[\fR and \fB]\fR, [\fI\&.symbol.\fR] matches the collating symbol
1897 \fIsymbol\fR.
1898 .RE
1899
1900 .sp
1901 .LP
1902 A \fIpattern-list\fR is a list of one or more patterns separated from each
1903 other with an \fB&\fR or \fB|\fR. An \fB&\fR signifies that all patterns must
1904 be matched whereas \fB|\fR requires that only one pattern be matched. Composite
1905 patterns can be formed with one or more of the following sub-patterns:
1906 .sp
1907 .ne 2
1908 .na
1909 \fB?(\fR\fIpattern-list\fR\fB)\fR
1910 .ad
1911 .RS 22n
1912 Optionally matches any one of the specified patterns.
1913 .RE
1914
1915 .sp
1916 .ne 2
1917 .na
1918 \fB*(\fR\fIpattern-list\fR\fB)\fR
1919 .ad
1920 .RS 22n
1921 Matches zero or more occurrences of the specified patterns.
1922 .RE
1923
1924 .sp
1925 .ne 2
1926 .na
1927 \fB+(\fR\fIpattern-list\fR\fB)\fR
1928 .ad
1929 .RS 22n
1930 Matches one or more occurrences of the specified patterns.
1931 .RE
1932
1933 .sp
1934 .ne 2
1935 .na
1936 \fB{\fR\fIn\fR\fB(\fR\fIpattern-list\fR\fB)\fR
1937 .ad
1938 .RS 22n
1939 Matches \fIn\fR occurrences of the specified patterns.
1940 .RE
1941
1942 .sp
1943 .ne 2
1944 .na
1945 \fB{\fR\fIm\fR\fB,\fR\fIn\fR\fB(\fR\fIpattern-list\fR\fB)\fR
1946 .ad
1947 .RS 22n
1948 Matches from \fIm\fR to \fIn\fR occurrences of the specified patterns. If
1949 \fIm\fR is omitted, \fB0\fR is used. If \fIn\fR is omitted at least \fIm\fR
1950 occurrences are matched.
1951 .RE
1952
1953 .sp
1954 .ne 2
1955 .na
1956 \fB@(\fR\fIpattern-list\fR\fB)\fR
1957 .ad
1958 .RS 22n
1959 Matches exactly one of the specified patterns.
1960 .RE
1961
1962 .sp
1963 .ne 2
1964 .na
1965 \fB!(\fR\fIpattern-list\fR\fB)\fR
1966 .ad
1967 .RS 22n
1968 Matches anything except one of the specified patterns.
1969 .RE
1970
1971 .sp
1972 .LP
1973 By default, each pattern, or sub-pattern matches the longest string possible
1974 consistent with generating the longest overall match. If more than one match is
1975 possible, the one starting closest to the beginning of the string is chosen.
1976 However, for each of the compound patterns a \fB-\fR can be inserted in front
1977 of the \fB(\fR to cause the shortest match to the specified \fIpattern-list\fR
1978 to be used.
1979 .sp
1980 .LP
1981 When \fIpattern-list\fR is contained within parentheses, the backslash
1982 character \fB\e\fR is treated specially even when inside a character class. All
1983 \fBANSI-C\fR character escapes are recognized and match the specified
1984 character. In addition the following escape sequences are recognized:
1985 .sp
1986 .ne 2
1987 .na
1988 \fB\ed\fR
1989 .ad
1990 .RS 7n
1991 Matches any character in the digit class.
1992 .RE
1993
1994 .sp
1995 .ne 2
1996 .na
1997 \fB\eD\fR
1998 .ad
1999 .RS 7n
2000 Matches any character not in the digit class.
2001 .RE
2002
2003 .sp
2004 .ne 2
2005 .na
2006 \fB\es\fR
2007 .ad
2008 .RS 7n
2009 Matches any character in the space class.
2010 .RE
2011
2012 .sp
2013 .ne 2
2014 .na
2015 \fB\eS\fR
2016 .ad
2017 .RS 7n
2018 Matches any character not in the space class.
2019 .RE
2020
2021 .sp
2022 .ne 2
2023 .na
2024 \fB\ew\fR
2025 .ad
2026 .RS 7n
2027 Matches any character in the word class.
2028 .RE
2029
2030 .sp
2031 .ne 2
2032 .na
2033 \fB\eW\fR
2034 .ad
2035 .RS 7n
2036 Matches any character not in the word class.
2037 .RE
2038
2039 .sp
2040 .LP
2041 A pattern of the form \fB%(\fR\fIpattern-pairs\fR\fB)\fR is a sub-pattern that
2042 can be used to match nested character expressions. Each \fIpattern-pair\fR is a
2043 two character sequence which cannot contain \fB&\fR or \fB|\fR. The first
2044 \fIpattern-pair\fR specifies the starting and ending characters for the match.
2045 Each subsequent \fIpattern-pair\fR represents the beginning and ending
2046 characters of a nested group that is skipped over when counting starting and
2047 ending character matches. The behavior is unspecified when the first character
2048 of a \fIpattern-pair\fR is alphanumeric except for the following:
2049 .sp
2050 .ne 2
2051 .na
2052 \fBD\fR
2053 .ad
2054 .RS 5n
2055 Causes the ending character to terminate the search for this pattern without
2056 finding a match.
2057 .RE
2058
2059 .sp
2060 .ne 2
2061 .na
2062 \fBE\fR
2063 .ad
2064 .RS 5n
2065 Causes the ending character to be interpreted as an escape character.
2066 .RE
2067
2068 .sp
2069 .ne 2
2070 .na
2071 \fBL\fR
2072 .ad
2073 .RS 5n
2074 Causes the ending character to be interpreted as a quote character causing all
2075 characters to be ignored when looking for a match.
2076 .RE
2077
2078 .sp
2079 .ne 2
2080 .na
2081 \fBQ\fR
2082 .ad
2083 .RS 5n
2084 Causes the ending character to be interpreted as a quote character causing all
2085 characters other than any escape character to be ignored when looking for a
2086 match.
2087 .RE
2088
2089 .sp
2090 .LP
2091 \fB%({}Q"E\e)\fR, matches characters starting at \fB{\fR until the matching
2092 \fB}\fR is found not counting any \fB{\fR or \fB}\fR that is inside a double
2093 quoted string or preceded by the escape character \fB\e\fR\&. Without the
2094 \fB{}\fR this pattern matches any C language string.
2095 .sp
2096 .LP
2097 Each sub-pattern in a composite pattern is numbered, starting at \fB1\fR, by
2098 the location of the \fB(\fR within the pattern. The sequence \fB\e\fR\fIn\fR,
2099 where \fIn\fR is a single digit and \fB\e\fR\fIn\fR comes after the \fIn\fRth.
2100 sub-pattern, matches the same string as the sub-pattern itself.
2101 .sp
2102 .LP
2103 A pattern can contain sub-patterns of the form
2104 \fB~(\fR\fIoptions\fR\fB:\fR\fIpattern-list\fR\fB)\fR, where either
2105 \fIoptions\fR or \fB:\fR\fIpattern-list\fR can be omitted. Unlike the other
2106 compound patterns, these sub-patterns are not counted in the numbered
2107 sub-patterns. \fB:\fR\fIpattern-list\fR must be omitted for options
2108 \fBF, G, N\fR and \fBV\fR below.
2109 If \fIoptions\fR is present, it can consist of one or more of the
2110 following:
2111 .sp
2112 .ne 2
2113 .na
2114 \fB+\fR
2115 .ad
2116 .RS 5n
2117 Enable the following options. This is the default.
2118 .RE
2119
2120 .sp
2121 .ne 2
2122 .na
2123 \fB-\fR
2124 .ad
2125 .RS 5n
2126 Disable the following options.
2127 .RE
2128
2129 .sp
2130 .ne 2
2131 .na
2132 \fBE\fR
2133 .ad
2134 .RS 5n
2135 The remainder of the pattern uses extended regular expression syntax like the
2136 \fBegrep\fR(1) command.
2137 .RE
2138
2139 .sp
2140 .ne 2
2141 .na
2142 \fBF\fR
2143 .ad
2144 .RS 5n
2145 The remainder of the pattern uses \fBfgrep\fR(1) expression syntax.
2146 .RE
2147
2148 .sp
2149 .ne 2
2150 .na
2151 \fBg\fR
2152 .ad
2153 .RS 5n
2154 File the longest match (greedy).
2155 .sp
2156 This is the default.
2157 .RE
2158
2159 .sp
2160 .ne 2
2161 .na
2162 \fBG\fR
2163 .ad
2164 .RS 5n
2165 The remainder of the pattern uses basic regular expression syntax like the
2166 \fBgrep\fR(1) command.
2167 .RE
2168
2169 .sp
2170 .ne 2
2171 .na
2172 \fBi\fR
2173 .ad
2174 .RS 5n
2175 Treat the match as case insensitive.
2176 .RE
2177
2178 .sp
2179 .ne 2
2180 .na
2181 \fBK\fR
2182 .ad
2183 .RS 5n
2184 The remainder of the pattern uses shell pattern syntax.
2185 .sp
2186 This is the default.
2187 .RE
2188
2189 .sp
2190 .ne 2
2191 .na
2192 \fBl\fR
2193 .ad
2194 .RS 5n
2195 Left anchor the pattern.
2196 .sp
2197 This is the default for \fBK\fR style patterns.
2198 .RE
2199
2200 .sp
2201 .ne 2
2202 .na
2203 \fBN\fR
2204 .ad
2205 .RS 5n
2206 This is ignored. However, when it is the first letter and is used with file
2207 name generation, and no matches occur, the file pattern expands to the empty
2208 string.
2209 .RE
2210
2211 .sp
2212 .ne 2
2213 .na
2214 \fBr\fR
2215 .ad
2216 .RS 5n
2217 Right anchor the pattern.
2218 .sp
2219 This is the default for \fBK\fR style patterns.
2220 .RE
2221
2222 .sp
2223 .ne 2
2224 .na
2225 \fBX\fR
2226 .ad
2227 .RS 5n
2228 The remainder of the pattern uses augmented regular expression syntax.
2229 .RE
2230
2231 .sp
2232 .ne 2
2233 .na
2234 \fBP\fR
2235 .ad
2236 .RS 5n
2237 The remainder of the pattern uses \fIperl\fR(1) regular expression syntax. Not
2238 all perl regular expression syntax is currently implemented.
2239 .RE
2240
2241 .sp
2242 .ne 2
2243 .na
2244 \fBV\fR
2245 .ad
2246 .RS 5n
2247 The remainder of the pattern uses System V regular expression syntax.
2248 .RE
2249
2250 .sp
2251 .LP
2252 If both \fIoptions\fR and \fB:\fR\fIpattern-list\fR are specified, then the
2253 options apply only to \fIpattern-list\fR. Otherwise, these options remain in
2254 effect until they are disabled by a subsequent \fB~(...)\fR or at the end of
2255 the sub-pattern containing \fB~(...)\fR.
2256 .SS "Quoting"
2257 Each of the metacharacters listed in the \fBDefinitions\fR section of this
2258 manual page has a special meaning to the shell and causes termination of a word
2259 unless quoted. A character can be quoted, that is, made to stand for itself, by
2260 preceding it with a backslash (\fB\e\fR). The pair \fB\e\fRNEWLINE is removed.
2261 All characters enclosed between a pair of single quote marks (\fB\&''\fR) that
2262 is not preceded by a \fB$\fR are quoted. A single quote cannot appear within
2263 the single quotes. A single quoted string preceded by an unquoted \fB$\fR is
2264 processed as an \fBANSI-C\fR string except for the following:
2265 .sp
2266 .ne 2
2267 .na
2268 \fB\e0\fR
2269 .ad
2270 .RS 19n
2271 Causes the remainder of the string to be ignored.
2272 .RE
2273
2274 .sp
2275 .ne 2
2276 .na
2277 \fB\ec\fR\fIx\fR
2278 .ad
2279 .RS 19n
2280 Expands to the character CTRL-x.
2281 .RE
2282
2283 .sp
2284 .ne 2
2285 .na
2286 \fB\eC\fR[\fB\&.\fR\fIname\fR\fB\&.\fR]\fR
2287 .ad
2288 .RS 19n
2289 Expands to the collating element \fIname\fR.
2290 .RE
2291
2292 .sp
2293 .ne 2
2294 .na
2295 \fB\ee\fR
2296 .ad
2297 .RS 19n
2298 Equivalent to the escape character (\fBASCII\fR 033),
2299 .RE
2300
2301 .sp
2302 .ne 2
2303 .na
2304 \fB\eE\fR
2305 .ad
2306 .RS 19n
2307 Equivalent to the escape character (\fBASCII\fR 033),
2308 .RE
2309
2310 .sp
2311 .LP
2312 Inside double quote marks (\fB""\fR), parameter and command substitution occur
2313 and \fB\e\fR quotes the characters \fB\e\fR, \fB`\fR, \fB"\fR, and \fB$\fR. A
2314 \fB$\fR in front of a double quoted string is ignored in the \fBC\fR or
2315 \fBPOSIX\fR locale, and might cause the string to be replaced by a locale
2316 specific string otherwise. The meaning of \fB$*\fR and \fB$@\fR is identical
2317 when not quoted or when used as a variable assignment value or as a file name.
2318 However, when used as a command argument, \fB"$*"\fR is equivalent to
2319 \fB"$1\fId\fR$2\fId\fR..."\fR, where \fId\fR is the first character of the IFS
2320 variable, whereas \fB"$@"\fR is equivalent to \fB"$1" "$2" ....\fR Inside grave
2321 quote marks (\fB``\fR), \fB\\\fR quotes the characters \fB\e\fR, \fB`\fR, and
2322 \fB$\fR. If the grave quotes occur within double quotes, then \fB\e\fR also
2323 quotes the character \fB"\fR.
2324 .sp
2325 .LP
2326 The special meaning of reserved words or aliases can be removed by quoting any
2327 character of the reserved word. The recognition of function names or built-in
2328 command names cannot be altered by quoting them.
2329 .SS "Arithmetic Evaluation"
2330 The shell performs arithmetic evaluation for arithmetic substitution, to
2331 evaluate an arithmetic command, to evaluate an indexed array subscript, and to
2332 evaluate arguments to the built-in commands \fBshift\fR and \fBlet\fR.
2333 Arithmetic evaluation is also performed on argument operands of the built-in
2334 command printf that correspond to numeric format specifiers in the format
2335 operand. See \fBprintf\fR(1). Evaluations are performed using double precision
2336 floating point arithmetic or long double precision floating point for systems
2337 that provide this data type. Floating point constants follow the \fBANSI-C\fR
2338 programming language floating point conventions. The floating point constants
2339 \fBNan\fR and \fBInf\fR can be used to represent "not a number" and
2340 infinity respectively. Integer constants follow the \fBANSI-C\fR programming
2341 language integer constant conventions although only single byte character
2342 constants are recognized and character casts are not recognized. Constants can
2343 be of the form \fB[\fR\fIbase#\fR\fB]\fR\fIn\fR where \fIbase\fR is a decimal
2344 number between two and sixty-four representing the arithmetic base and \fIn\fR
2345 is a number in that base. The digits greater than \fB9\fR are represented by
2346 the lower case letters, the upper case letters, \fB@\fR, and \fB_\fR
2347 respectively. For bases less than or equal to \fB36\fR, upper and lower case
2348 characters can be used interchangeably.
2349 .sp
2350 .LP
2351 An arithmetic expression uses the same syntax, precedence, and associativity of
2352 expression as the C language. All the C language operators that apply to
2353 floating point quantities can be used. In addition, the operator \fB**\fR can
2354 be used for exponentiation. It has higher precedence than multiplication and is
2355 left associative. When the value of an arithmetic variable or subexpression can
2356 be represented as a long integer, all C language integer arithmetic operations
2357 can be performed. Variables can be referenced by name within an arithmetic
2358 expression without using the parameter expansion syntax. When a variable is
2359 referenced, its value is evaluated as an arithmetic expression.
2360 .sp
2361 .LP
2362 Any of the following math library functions that are in the C math library can
2363 be used within an arithmetic expression:
2364 .sp
2365 .in +2
2366 .nf
2367 rint round sin sinh sqrt tan tanh tgamma trunc abs acos
2368 acosh asin asinh atan atan2 atanh cbrt ceil copysign cos
2369 cosh erf erfc exp exp2 expm1 fabs fpclassify fdim finite
2370 floor fma fmax fmin fmod hypot ilogb int isfinite sinf isnan
2371 isnormal issubnormal issubor- dered iszero j0 j1 jn lgamma
2372 log log10 log2 logb nearbyint nextafter nexttoward pow
2373 remainder rint round scanb signbit sin sinh sqrt tan tanh
2374 tgamma trunc y0 y1 yn
2375 .fi
2376 .in -2
2377 .sp
2378
2379 .sp
2380 .LP
2381 In addition, arithmetic functions can be defined as shell functions with a
2382 variant of the \fBfunction\fR \fIname\fR syntax:
2383
2384 \fBfunction .sh.math.\fR\fIname\fR \fIident\fR ... \fB{\fR \fIlist\fR \fB;}\fR
2385 .RS 5
2386 where \fIname\fR is the function name used in the arithmetic expression and
2387 each identified \fIident\fR is a name reference to the long double precision
2388 floating point argument. The value of \fB.sh.value\fR when the function returns
2389 is the value of this function. User defined functions can take up to 3
2390 arguments and override C math library functions.
2391 .RE
2392
2393 .sp
2394 .LP
2395 An internal representation of a \fIvariable\fR as a double precision floating
2396 point can be specified with the \fB-E [\fR\fIn\fR\fB]\fR, \fB-F
2397 [\fR\fIn\fR\fB]\fR, or \fB-X [\fR\fIn\fR\fB]\fR options of the \fBtypeset\fR
2398 special built-in command. The
2399 \fB-E\fR option causes the expansion of the value to be represented using
2400 scientific notation when it is expanded. The optional option argument \fIn\fR
2401 defines the number of significant figures. The \fB-F\fR option causes the
2402 expansion to be represented as a floating decimal number when it is expanded.
2403 The optional option argument \fIn\fR defines the number of places after the
2404 decimal point in this case. The \fB-X\fR option causes the expansion to be
2405 represented using the \fB%a\fR format defined by ISO C-99. The optional option
2406 argument n defines the number of places after the decimal (or radix) point in
2407 this case.
2408
2409 .sp
2410 .LP
2411 An internal integer representation of a \fIvariable\fR can be specified with
2412 the \fB-i\fR \fB[\fR\fIn\fR\fB]\fR option of the \fBtypeset\fR special built-in
2413 command. The optional option argument \fIn\fR specifies an arithmetic base to
2414 be used when expanding the variable. If you do not specify an arithmetic base,
2415 base 10 is used.
2416 .sp
2417 .LP
2418 Arithmetic evaluation is performed on the value of each assignment to a
2419 variable with the \fB-E\fR, \fB-F\fR, \fB-X\fR or \fB-i\fR option. Assigning a
2420 floating point number to a variable whose type is an integer causes the
2421 fractional part to be truncated.
2422 .SS "Prompting"
2423 When used interactively, the shell prompts with the value of \fBPS1\fR after
2424 expanding it for parameter expansion, command substitution, and arithmetic
2425 substitution, before reading a command. In addition, each single \fB!\fR in the
2426 prompt is replaced by the command number. A \fB!!\fR is required to place
2427 \fB!\fR in the prompt. If at any time a NEWLINE is typed and further input is
2428 needed to complete a command, then the secondary prompt, that is, the value of
2429 \fBPS2\fR, is issued.
2430 .SS "Conditional Expressions"
2431 A \fBconditional expression\fR is used with the \fB[[\fR compound command to
2432 test attributes of files and to compare strings. Field splitting and file name
2433 generation are not performed on the words between \fB[[\fR and \fB]]\fR.
2434 .sp
2435 .LP
2436 Each expression can be constructed from one or more of the following unary or
2437 binary expressions:
2438 .sp
2439 .ne 2
2440 .na
2441 \fB-a\fR \fIfile\fR
2442 .ad
2443 .RS 21n
2444 True, if \fIfile\fR exists.
2445 .sp
2446 This option is the same as \fB-e\fR. This option is obsolete.
2447 .RE
2448
2449 .sp
2450 .ne 2
2451 .na
2452 \fB-b\fR \fIfile\fR
2453 .ad
2454 .RS 21n
2455 True, if \fIfile\fR exists and is a block special file.
2456 .RE
2457
2458 .sp
2459 .ne 2
2460 .na
2461 \fB-c\fR \fIfile\fR
2462 .ad
2463 .RS 21n
2464 True, if \fIfile\fR exists and is a character special file.
2465 .RE
2466
2467 .sp
2468 .ne 2
2469 .na
2470 \fB-d\fR \fIfile\fR
2471 .ad
2472 .RS 21n
2473 True, if \fIfile\fR exists and is a directory.
2474 .RE
2475
2476 .sp
2477 .ne 2
2478 .na
2479 \fB-e\fR \fIfile\fR
2480 .ad
2481 .RS 21n
2482 True, if \fIfile\fR exists.
2483 .RE
2484
2485 .sp
2486 .ne 2
2487 .na
2488 \fB-f\fR \fIfile\fR
2489 .ad
2490 .RS 21n
2491 True, if \fIfile\fR exists and is an ordinary file.
2492 .RE
2493
2494 .sp
2495 .ne 2
2496 .na
2497 \fB-g\fR \fIfile\fR
2498 .ad
2499 .RS 21n
2500 True, if \fIfile\fR exists and it has its \fBsetgid\fR bit set.
2501 .RE
2502
2503 .sp
2504 .ne 2
2505 .na
2506 \fB-G\fR \fIfile\fR
2507 .ad
2508 .RS 21n
2509 True, if \fIfile\fR exists and its group matches the effective group id of this
2510 process.
2511 .RE
2512
2513 .sp
2514 .ne 2
2515 .na
2516 \fB-h\fR \fIfile\fR
2517 .ad
2518 .RS 21n
2519 True, if \fIfile\fR exists and is a symbolic link.
2520 .RE
2521
2522 .sp
2523 .ne 2
2524 .na
2525 \fB-k\fR \fIfile\fR
2526 .ad
2527 .RS 21n
2528 True, if \fIfile\fR exists and it has its sticky bit set.
2529 .RE
2530
2531 .sp
2532 .ne 2
2533 .na
2534 \fB-L\fR \fIfile\fR
2535 .ad
2536 .RS 21n
2537 True, if \fIfile\fR exists and is a symbolic link.
2538 .RE
2539
2540 .sp
2541 .ne 2
2542 .na
2543 \fB-n\fR \fIstring\fR
2544 .ad
2545 .RS 21n
2546 True, if length of \fIstring\fR is \fBnon-zero\fR.
2547 .RE
2548
2549 .sp
2550 .ne 2
2551 .na
2552 \fB-N\fR \fIfile\fR
2553 .ad
2554 .RS 21n
2555 True, if \fIfile\fR exists and the modification time is greater than the last
2556 access time.
2557 .RE
2558
2559 .sp
2560 .ne 2
2561 .na
2562 \fB-o\fR \fIoption\fR
2563 .ad
2564 .RS 21n
2565 True, if option named \fIoption\fR is on.
2566 .RE
2567
2568 .sp
2569 .ne 2
2570 .na
2571 \fB-o\fR \fI?option\fR
2572 .ad
2573 .RS 21n
2574 True, if option named \fIoption\fR is a valid option name.
2575 .RE
2576
2577 .sp
2578 .ne 2
2579 .na
2580 \fB-O\fR \fIfile\fR
2581 .ad
2582 .RS 21n
2583 True, if \fIfile\fR exists and is owned by the effective user id of this
2584 process.
2585 .RE
2586
2587 .sp
2588 .ne 2
2589 .na
2590 \fB-p\fR \fIfile\fR
2591 .ad
2592 .RS 21n
2593 True, if \fIfile\fR exists and is a \fBFIFO\fR special file or a pipe.
2594 .RE
2595
2596 .sp
2597 .ne 2
2598 .na
2599 \fB-r\fR \fIfile\fR
2600 .ad
2601 .RS 21n
2602 True, if \fIfile\fR exists and is readable by current process.
2603 .RE
2604
2605 .sp
2606 .ne 2
2607 .na
2608 \fB-R\fR \fIname\fR
2609 .ad
2610 .RS 21n
2611 True if variable \fIname\fR is a name reference.
2612 .RE
2613
2614 .sp
2615 .ne 2
2616 .na
2617 \fB-s\fR \fIfile\fR
2618 .ad
2619 .RS 21n
2620 True, if \fIfile\fR exists and has size greater than zero.
2621 .RE
2622
2623 .sp
2624 .ne 2
2625 .na
2626 \fB-S\fR \fIfile\fR
2627 .ad
2628 .RS 21n
2629 True, if \fIfile\fR exists and is a socket.
2630 .RE
2631
2632 .sp
2633 .ne 2
2634 .na
2635 \fB-t\fR \fIfildes\fR
2636 .ad
2637 .RS 21n
2638 True, if file descriptor number \fIfildes\fR is open and associated with a
2639 terminal device.
2640 .RE
2641
2642 .sp
2643 .ne 2
2644 .na
2645 \fB-u\fR \fIfile\fR
2646 .ad
2647 .RS 21n
2648 True, if \fIfile\fR exists and it has its \fBsetuid\fR bit set.
2649 .RE
2650
2651 .sp
2652 .ne 2
2653 .na
2654 \fB-v\fR \fIname\fR
2655 .ad
2656 .RS 21n
2657 True, if variable \fIname\fR is a valid variable name and is set.
2658 .RE
2659
2660 .sp
2661 .ne 2
2662 .na
2663 \fB-w\fR \fIfile\fR
2664 .ad
2665 .RS 21n
2666 True, if \fIfile\fR exists and is writable by current process.
2667 .RE
2668
2669 .sp
2670 .ne 2
2671 .na
2672 \fB-x\fR \fIfile\fR
2673 .ad
2674 .RS 21n
2675 True, if \fIfile\fR exists and is executable by current process. If \fIfile\fR
2676 exists and is a directory, then true if the current process has permission to
2677 search in the directory.
2678 .RE
2679
2680 .sp
2681 .ne 2
2682 .na
2683 \fB-z\fR \fIstring\fR
2684 .ad
2685 .RS 21n
2686 True, if length of \fIstring\fR is zero.
2687 .RE
2688
2689 .sp
2690 .ne 2
2691 .na
2692 \fB\fIfile1\fR \fB-ef\fR \fIfile2\fR
2693 .ad
2694 .RS 21n
2695 True, if \fIfile1\fR and \fIfile2\fR exist and refer to the same file.
2696 .RE
2697
2698 .sp
2699 .ne 2
2700 .na
2701 \fB\fIfile1\fR \fB-nt\fR \fIfile2\fR
2702 .ad
2703 .RS 21n
2704 True, if \fIfile1\fR exists and \fIfile2\fR does not, or \fIfile1\fR is newer
2705 than \fIfile2\fR.
2706 .RE
2707
2708 .sp
2709 .ne 2
2710 .na
2711 \fB\fIfile1\fR \fB-ot\fR \fIfile2\fR
2712 .ad
2713 .RS 21n
2714 True, if \fIfile2\fR exists and \fIfile1\fR does not, or \fIfile1\fR is older
2715 than \fIfile2\fR.
2716 .RE
2717
2718 .sp
2719 .ne 2
2720 .na
2721 \fB\fIstring\fR
2722 .ad
2723 .RS 21n
2724 True, if \fIstring\fR is not null.
2725 .RE
2726
2727 .sp
2728 .ne 2
2729 .na
2730 \fB\fIstring\fR \fB==\fR \fIpattern\fR
2731 .ad
2732 .RS 21n
2733 True, if \fIstring\fR matches \fIpattern\fR. Any part of \fIpattern\fR can be
2734 quoted to cause it to be matched as a string. With a successful match to
2735 \fIpattern\fR, the \fB\&.sh.match\fR array variable contains the match and
2736 sub-pattern matches.
2737 .RE
2738
2739 .sp
2740 .ne 2
2741 .na
2742 \fB\fIstring\fR \fB=\fR \fIpattern\fR
2743 .ad
2744 .RS 21n
2745 Same as \fB==\fR, but is obsolete.
2746 .RE
2747
2748 .sp
2749 .ne 2
2750 .na
2751 \fB\fIstring\fR \fB!=\fR \fIpattern\fR
2752 .ad
2753 .RS 21n
2754 True, if \fIstring\fR does not match \fIpattern\fR. When the \fIstring\fR
2755 matches the \fIpattern\fR the \fB\&.sh.match\fR array variable contains the
2756 match and sub-pattern matches.
2757 .RE
2758
2759 .sp
2760 .ne 2
2761 .na
2762 \fB\fIstring\fR \fB=~\fR \fIere\fR
2763 .ad
2764 .RS 21n
2765 True if \fIstring\fR matches the pattern \fB~(E)\fR\fIere\fR where \fIere\fR is
2766 an extended regular expression.
2767 .RE
2768
2769 .sp
2770 .ne 2
2771 .na
2772 \fB\fIstring1\fR \fB<\fR \fIstring2\fR
2773 .ad
2774 .RS 21n
2775 True, if \fIstring1\fR comes before \fIstring2\fR based on \fBASCII\fR value of
2776 their characters.
2777 .RE
2778
2779 .sp
2780 .ne 2
2781 .na
2782 \fB\fIstring1\fR \fB>\fR \fIstring2\fR
2783 .ad
2784 .RS 21n
2785 True, if \fIstring1\fR comes after \fIstring2\fR based on \fBASCII\fR value of
2786 their characters.
2787 .RE
2788
2789 .sp
2790 In each of the above expressions, if \fIfile\fR is of the form
2791 \fB/dev/fd/\fR\fIn\fR, where \fIn\fR is an integer, the test is applied to the
2792 open file whose descriptor number is \fIn\fR.
2793 .sp
2794 .LP
2795 The following obsolete arithmetic comparisons are also supported:
2796 .sp
2797 .ne 2
2798 .na
2799 \fB\fIexp1\fR \fB-eq\fR \fIexp2\fR
2800 .ad
2801 .RS 17n
2802 True, if \fIexp1\fR is equal to \fIexp2\fR.
2803 .RE
2804
2805 .sp
2806 .ne 2
2807 .na
2808 \fB\fIexp1\fR \fB-ge\fR \fIexp2\fR
2809 .ad
2810 .RS 17n
2811 True, if \fIexp1\fR is greater than or equal to \fIexp2\fR.
2812 .RE
2813
2814 .sp
2815 .ne 2
2816 .na
2817 \fB\fIexp1\fR \fB-gt\fR \fIexp2\fR
2818 .ad
2819 .RS 17n
2820 True, if \fIexp1\fR is greater than \fIexp2\fR.
2821 .RE
2822
2823 .sp
2824 .ne 2
2825 .na
2826 \fB\fIexp1\fR \fB-le\fR \fIexp2\fR
2827 .ad
2828 .RS 17n
2829 True, if \fIexp1\fR is less than or equal to \fIexp2\fR.
2830 .RE
2831
2832 .sp
2833 .ne 2
2834 .na
2835 \fB\fIexp1\fR \fB-lt\fR \fIexp2\fR
2836 .ad
2837 .RS 17n
2838 True, if \fIexp1\fR is less than \fIexp2\fR.
2839 .RE
2840
2841 .sp
2842 .ne 2
2843 .na
2844 \fB\fIexp1\fR \fB-ne\fR \fIexp2\fR
2845 .ad
2846 .RS 17n
2847 True, if \fIexp1\fR is not equal to \fIexp2\fR.
2848 .RE
2849
2850 .sp
2851 .LP
2852 A compound expression can be constructed from these primitives by using any of
2853 the following, listed in decreasing order of precedence:
2854 .sp
2855 .ne 2
2856 .na
2857 \fB(\fR\fIexpression\fR\fB)\fR
2858 .ad
2859 .RS 30n
2860 True, if \fIexpression\fR is true. Used to group expressions.
2861 .RE
2862
2863 .sp
2864 .ne 2
2865 .na
2866 \fB!\fR \fIexpression\fR
2867 .ad
2868 .RS 30n
2869 True, if \fIexpression\fR is false.
2870 .RE
2871
2872 .sp
2873 .ne 2
2874 .na
2875 \fB\fIexpression1\fR \fB&&\fR \fIexpression2\fR
2876 .ad
2877 .RS 30n
2878 True, if \fIexpression1\fR and \fIexpression2\fR are both true.
2879 .RE
2880
2881 .sp
2882 .ne 2
2883 .na
2884 \fB\fIexpression1\fR \fB||\fR \fIexpression2\fR
2885 .ad
2886 .RS 30n
2887 True, if either \fIexpression1\fR or \fIexpression2\fR is true.
2888 .RE
2889
2890 .SS "Input and Output"
2891 Before a command is executed, its input and output can be redirected using a
2892 special notation interpreted by the shell. The following can appear anywhere in
2893 a simple command or can precede or follow a command and are \fBnot\fR passed on
2894 to the invoked command. Command substitution, parameter expansion, and
2895 arithmetic substitution occur before \fIword\fR or \fIdigit\fR is used except
2896 as noted in this section. File name generation occurs only if the shell is
2897 interactive and the pattern matches a single file. Field splitting is not
2898 performed.
2899 .sp
2900 .LP
2901 In each of the following redirections, if \fIfile\fR is of the form
2902 \fB/dev/sctp/\fR\fIhost\fR\fB/\fR\fIport\fR,
2903 \fB/dev/tcp/\fR\fIhost\fR\fB/\fR\fIport\fR, or
2904 \fB/dev/udp/\fR\fIhost\fR\fB/\fR\fIport\fR, where \fIhost\fR is a hostname or
2905 host address, and \fIport\fR is a service specified by name or an integer port
2906 number, then the redirection attempts to make a \fBtcp\fR, \fBsctp\fR or
2907 \fBudp\fR connection to the corresponding socket.
2908 .sp
2909 .LP
2910 No intervening space is allowed between the characters of redirection
2911 operators.
2912 .sp
2913 .ne 2
2914 .na
2915 \fB<\fR\fIword\fR
2916 .ad
2917 .RS 14n
2918 Use file \fIword\fR as standard input (file descriptor 0).
2919 .RE
2920
2921 .sp
2922 .ne 2
2923 .na
2924 \fB>\fR\fIword\fR
2925 .ad
2926 .RS 14n
2927 Use file \fIword\fR as standard output (file descriptor 1). If the file does
2928 not exist then it is created. If the file exists, and the \fBnoclobber\fR
2929 option is on, this causes an error. Otherwise, it is truncated to zero length.
2930 .RE
2931
2932 .sp
2933 .ne 2
2934 .na
2935 \fB>|\fR\fIword\fR
2936 .ad
2937 .RS 14n
2938 Same as \fB>\fR, except that it overrides the \fBnoclobber\fR option.
2939 .RE
2940
2941 .sp
2942 .ne 2
2943 .na
2944 \fB>;\fR\fIword\fR
2945 .ad
2946 .RS 14n
2947 Write output to a temporary file. If the command completes successfully rename
2948 it to word, otherwise, delete the temporary file. >;word cannot be used with
2949 the \fBexec\fR(2) built-in.
2950 .RE
2951
2952 .sp
2953 .ne 2
2954 .na
2955 \fB>>\fR\fIword\fR
2956 .ad
2957 .RS 14n
2958 Use file \fIword\fR as standard output. If the file exists, then output is
2959 appended to it (by first seeking to the end-of-file). Otherwise, the file is
2960 created.
2961 .RE
2962
2963 .sp
2964 .ne 2
2965 .na
2966 \fB<>\fR\fIword\fR
2967 .ad
2968 .RS 14n
2969 Open file \fIword\fR for reading and writing as standard input.
2970 .RE
2971
2972 .sp
2973 .ne 2
2974 .na
2975 \fB<<\fR\fB[-]\fR\fIword\fR
2976 .ad
2977 .RS 14n
2978 The shell input is read up to a line that is the same as \fIword\fR after any
2979 quoting has been removed, or to an end-of-file. No parameter substitution,
2980 command substitution, arithmetic substitution or file name generation is
2981 performed on \fIword\fR. The resulting document, called a \fBhere-document\fR,
2982 becomes the standard input. If any character of \fIword\fR is quoted, then no
2983 interpretation is placed upon the characters of the document. Otherwise,
2984 parameter expansion, command substitution, and arithmetic substitution occur,
2985 \fB\e\fRNEWLINE is ignored, and \fB\e\fR must be used to quote the characters
2986 \fB\e\fR, \fB$\fR, \fB`\fR\&. If \fB-\fR is appended to \fB<<\fR, then all
2987 leading tabs are stripped from \fIword\fR and from the document. If \fB#\fR is
2988 appended to \fB<<\fR, then leading SPACEs and TABs are stripped off the first
2989 line of the document and up to an equivalent indentation is stripped from the
2990 remaining lines and from \fIword\fR. A tab stop is assumed to occur at every 8
2991 columns for the purposes of determining the indentation.
2992 .RE
2993
2994 .sp
2995 .ne 2
2996 .na
2997 \fB<<<\fR\fIword\fR
2998 .ad
2999 .RS 14n
3000 A short form of here document in which \fIword\fR becomes the contents of the
3001 here-document after any parameter expansion, command substitution, and
3002 arithmetic substitution occur.
3003 .RE
3004
3005 .sp
3006 .ne 2
3007 .na
3008 \fB<&\fR\fIdigit\fR
3009 .ad
3010 .RS 14n
3011 The standard input is duplicated from file descriptor \fIdigit\fR, and
3012 similarly for the standard output using \fB>&\fR\fIdigit\fR. See \fBdup\fR(2).
3013 .RE
3014
3015 .sp
3016 .ne 2
3017 .na
3018 \fB<&\fR\fIdigit\fR\fB-\fR
3019 .ad
3020 .RS 14n
3021 The file descriptor specified by \fIdigit\fR is moved to standard input.
3022 Similarly for the standard output using \fB>&\fR\fIdigit\fR\fB-\fR.
3023 .RE
3024
3025 .sp
3026 .ne 2
3027 .na
3028 \fB<&-\fR
3029 .ad
3030 .RS 14n
3031 The standard input is closed. Similarly for the standard output using
3032 \fB>&-\fR.
3033 .RE
3034
3035 .sp
3036 .ne 2
3037 .na
3038 \fB<&p\fR
3039 .ad
3040 .RS 14n
3041 The input from the co-process is moved to standard input.
3042 .RE
3043
3044 .sp
3045 .ne 2
3046 .na
3047 \fB>&p\fR
3048 .ad
3049 .RS 14n
3050 The output to the co-process is moved to standard output.
3051 .RE
3052
3053 .sp
3054 .ne 2
3055 .na
3056 \fB<#((\fR\fIexpr\fR\fB))\fR
3057 .ad
3058 .RS 14n
3059 Evaluate arithmetic expression \fIexpr\fR and position file descriptor 0 to the
3060 resulting value bytes from the start of the file. The variables \fBCUR\fR and
3061 \fBEOF\fR evaluate to the current offset and end-of-file offset respectively
3062 when evaluating \fIexpr\fR.
3063 .RE
3064
3065 .sp
3066 .ne 2
3067 .na
3068 \fB>#((\fR\fIexpr\fR\fB))\fR
3069 .ad
3070 .RS 14n
3071 The same as \fB<#\fR except applies to file descriptor 1.
3072 .RE
3073
3074 .sp
3075 .ne 2
3076 .na
3077 \fB<#\fR\fIpattern\fR
3078 .ad
3079 .RS 14n
3080 Seek forward to the beginning of the next line containing pattern.
3081 .RE
3082
3083 .sp
3084 .ne 2
3085 .na
3086 \fB<##\fR\fIpattern\fR
3087 .ad
3088 .RS 14n
3089 The same as \fB<#\fR, except that the portion of the file that is skipped is
3090 copied to standard output.
3091 .RE
3092
3093 .sp
3094 .LP
3095 If one of the redirection operators is preceded by a digit, with no intervening
3096 space, then the file descriptor number referred to is that specified by the
3097 digit (instead of the default 0 or 1). If one of the redirection operators
3098 other than \fB>&-\fR and the \fB>#\fR and \fB<#\fR forms, is preceded by
3099 \fB{\fR\fIvarname\fR\fB}\fR with no intervening space, then a file descriptor
3100 number \fB> 10\fR is selected by the shell and stored in the variable
3101 \fIvarname\fR. If \fB>&-\fR or the any of the \fB>#\fR and \fB<#\fR forms is
3102 preceded by \fB{\fR\fIvarname\fR\fB}\fR the value of \fIvarname\fR defines the
3103 file descriptor to close or position. For example:
3104 .sp
3105 .in +2
3106 .nf
3130 .sp
3131 .in +2
3132 .nf
3133 \&... 1>\fIfname\fR 2>&1
3134 .fi
3135 .in -2
3136 .sp
3137
3138 .sp
3139 .LP
3140 first associates file descriptor 1 with file \fIfname\fR. It then associates
3141 file descriptor 2 with the file associated with file descriptor 1, that is,
3142 \fIfname\fR. If the order of redirections were reversed, file descriptor 2
3143 would be associated with the terminal (assuming file descriptor 1 had been) and
3144 then file descriptor 1 would be associated with file \fIfname\fR. If a command
3145 is followed by \fB&\fR and job control is not active, the default standard
3146 input for the command is the empty file \fB/dev/null\fR. Otherwise, the
3147 environment for the execution of a command contains the file descriptors of the
3148 invoking shell as modified by input and output specifications.
3149 .SS "Environment"
3150 The \fIenvironment\fR is a list of name-value pairs that is passed to an
3151 executed program in the same way as a normal argument list. See
3152 \fBenviron\fR(5).
3153 .sp
3154 .LP
3155 The names must be \fIidentifiers\fR and the values are character strings. The
3156 shell interacts with the environment in several ways. On invocation, the shell
3157 scans the environment and creates a variable for each name found, giving it the
3158 corresponding value and attributes and marking it \fBexport\fR. Executed
3159 commands inherit the environment. If the user modifies the values of these
3160 variables or creates new ones, using the \fBexport\fR or \fBtypeset\fR \fB-x\fR
3161 commands, they become part of the environment. The environment seen by any
3162 executed command is thus composed of any name-value pairs originally inherited
3163 by the shell, whose values can be modified by the current shell, plus any
3164 additions which must be noted in \fBexport\fR or \fBtypeset\fR \fB-x\fR
3165 commands. The environment for any simple-command or function can be augmented
3166 by prefixing it with one or more variable assignments. A variable assignment
3167 argument is a word of the form \fIidentifier\fR\fB=\fR\fIvalue\fR. Thus:
3168 .sp
3169 .in +2
3192 assignment arguments are placed in the environment, even if they occur after
3193 the command name.
3194 .sp
3195 .LP
3196 The following example first prints \fBa=b c\fR and then \fBc\fR:
3197 .sp
3198 .in +2
3199 .nf
3200 echo a=b c
3201 set -k
3202 echo a=b c
3203 .fi
3204 .in -2
3205 .sp
3206
3207 .sp
3208 .LP
3209 This feature is intended for use with scripts written for early versions of the
3210 shell and its use in new scripts is strongly discouraged.
3211 .SS "Functions"
3212 For historical reasons, there are two ways to define functions, the
3213 \fBname()\fR syntax and the \fBfunction\fR \fBname\fR syntax. These are
3214 described in the \fBCommands\fR section of this manual page.
3215 .sp
3216 .LP
3217 Shell functions are read in and stored internally. Alias names are resolved
3218 when the function is read. Functions are executed like commands with the
3219 arguments passed as positional parameters. See the \fBExecution\fR section of
3220 this manual page for details.
3221 .sp
3222 .LP
3223 Functions defined by the \fBfunction\fR \fBname\fR syntax and called by name
3224 execute in the same process as the caller and share all files and present
3225 working directory with the caller. Traps caught by the caller are reset to
3226 their default action inside the function. A trap condition that is not caught
3227 or ignored by the function causes the function to terminate and the condition
3228 to be passed on to the caller. A trap on \fBEXIT\fR set inside a function is
3229 executed in the environment of the caller after the function completes.
3230 Ordinarily, variables are shared between the calling program and the function.
3231 However, the \fBtypeset\fR special built-in command used within a function
3240 built-in are executed in the caller's environment and share all variables and
3241 traps with the caller. Errors within these function executions cause the script
3242 that contains them to abort.
3243 .sp
3244 .LP
3245 The special built-in command \fBreturn\fR is used to return from function
3246 calls.
3247 .sp
3248 .LP
3249 Function names can be listed with the \fB-f\fR or \fB+f\fR option of the
3250 \fBtypeset\fR special built-in command. The text of functions, when available,
3251 is also listed with \fB-f\fR. Functions can be undefined with the \fB-f\fR
3252 option of the \fBunset\fR special built-in command.
3253 .sp
3254 .LP
3255 Ordinarily, functions are unset when the shell executes a shell script.
3256 Functions that need to be defined across separate invocations of the shell
3257 should be placed in a directory and the \fBFPATH\fR variable should contain the
3258 name of this directory. They can also be specified in the \fBENV\fR file.
3259 .SS "Discipline Functions"
3260 Each variable can have zero or more discipline functions associated with it.
3261 The shell initially understands the discipline names \fBget\fR, \fBset\fR,
3262 \fBappend\fR, and \fBunset\fR but on most systems others can be added at run
3263 time via the C programming interface extension provided by the \fBbuiltin\fR
3264 built-in utility. If the \fBget\fR discipline is defined for a variable, it is
3265 invoked whenever the specified variable is referenced. If the variable
3266 \fB\&.sh.value\fR is assigned a value inside the discipline function, the
3267 referenced variable is evaluated to this value instead. If the \fBset\fR
3268 discipline is defined for a variable, it is invoked whenever the specified
3269 variable is assigned a value. If the \fBappend\fR discipline is defined for a
3270 variable, it is invoked whenever a value is appended to the specified variable.
3271 The variable \fB\&.sh.value\fR is specified the value of the variable before
3272 invoking the discipline, and the variable is assigned the value of
3273 \fB\&.sh.value\fR after the discipline completes. If .\fBsh.value\fR is
3274 \fBunset\fR inside the discipline, then that value is unchanged. If the
3275 \fBunset\fR discipline is defined for a variable, it is invoked whenever the
3276 specified variable is unset. The variable is not unset unless it is unset
3277 explicitly from within this discipline function.
3278 .sp
3279 .LP
3280 The variable \fB\&.sh.name\fR contains the name of the variable for which the
3281 discipline function is called, \fB\&.sh.subscript\fR is the subscript of the
3282 variable, and \fB\&.sh.value\fR contains the value being assigned inside the
3283 \fBset\fR discipline function. For the \fBset\fR discipline, changing
3284 \fB\&.sh.value\fR changes the value that gets assigned.
3285 The variable \fB_\fR is a reference to the variable including the subscript if
3286 any. For the set discipline, changing \fB\&.sh.value\fR will change the value
3287 that gets assigned. Finally, the expansion \fB${\fR \fIvar.name\fR\fB}\fR,
3288 when name is the name of a discipline, and there is no variable of this name,
3289 is equivalent to the command substitution \fB${\fR\fIvar.name\fR\fB;}\fR.
3290
3291 .SS "Name Spaces"
3292 Commands and functions that are executed as part of the \fIlist\fR
3293 of a \fBnamespace\fR command that modify variables or create new ones, create
3294 a new variable whose name is the name of the name space as given by
3295 \fIidentifier\fR preceded by two dots (\fB\&..\fR).
3296 When a variable whose name is \fIname\fR is referenced, it is first searched
3297 for using \fB.\fR\fIidentifier\fR\fB.\fR\fIname\fR\fB.\fR
3298 Similarly, a function defined by a command in the \fBnamespace\fR \fIlist\fR
3299 is created using the name space name preceded by two dots (\fB\&..\fR).
3300 .PP
3301 When the \fIlist\fR of a \fBnamespace\fR command contains a \fBnamespace\fR
3302 command, the names of variables and functions that are created consist
3303 of the variable or function name preceded by the list of \fIidentifier\fRs
3304 each preceded by two dots (\fB\&..\fR).
3305 .PP
3306 Outside of a name space, a variable or function created inside a
3307 name space can be referenced by preceding it with the name space name.
3308 .PP
3309 By default, variables staring with \fB.sh\fR are in the \fBsh\fR name space.
3310
3311 .SS "Typed Variables"
3312 Typed variables provide a way to create data structure and objects. A type can
3313 be defined either by a shared library, by the \fBenum\fR built-in command
3314 described below, or by using the new \fB-T\fR option of the \fBtypeset\fR
3315 built-in command. With the \fB-T\fR option of \fBtypeset\fR, the type name,
3316 specified as an option argument to \fB-T\fR, is set with a compound variable
3317 assignment that defines the type. Function definitions can appear inside the
3318 compound variable assignment and these become discipline functions for this
3319 type and can be invoked or redefined by each instance of the type. The function
3320 name \fBcreate\fR is treated specially. It is invoked for each instance of the
3321 type that is created but is not inherited and cannot be redefined for each
3322 instance.
3323
3324 When a type is defined a special built-in command of that name is added. These
3325 built-ins are declaration commands and follow the same expansion rules as all
3326 the special built-in commands defined below that are preceded by a dot
3327 (\fB\&.\fR). These commands can subsequently be used inside further type
3328 definitions. The man page for these commands can be generated by using the
3329 \fB--man\fR option or any of the other \fB--\fR options described with
3330 \fBgetopts\fR. The \fB-r, -a, -A, -h\fR and \fB-S\fR options of \fBtypeset\fR
3331 are permitted with each of these new built-ins.
3332
3333 An instance of a type is created by invoking the type name
3334 followed by one or more instance names.
3335 Each instance of the type is initialized with a copy of the sub-variables
3336 except for sub-variables that are defined with the \fB-s\fR
3337 option. Variables defined with \fB-S\fR are shared by all instances of the
3338 type. Each instance can change the value of any sub-variable and can also
3339 define new discipline functions of the same names as those defined by the type
3340 definition as well as any standard discipline names. No additional
3341 sub-variables can be defined for any instance.
3342
3343 When defining a type, if the value of a sub-variable is not set and the
3344 \fB-r\fR attribute is specified, it causes the sub-variable to be a required
3345 sub-variable. Whenever an instance of a type is created, all required
3346 sub-variables must be specified. These sub-variables become readonly in each
3347 instance.
3348
3349 When \fBunset\fR is invoked on a sub-variable within a type, and the \fB-r\fR
3350 attribute has not been specified for this field, the value is reset to the
3351 default value associative with the type. Invoking \fBunset\fR on a type
3352 instance not contained within another type deletes all sub-variables and the
3353 variable itself.
3354
3355 A type definition can be derived from another type definition by defining the
3356 first sub-variable name as \fB_\fR and defining its type as the base type. Any
3357 remaining definitions will be additions and modifications that apply to the new
3358 type. If the new type name is the same is that of the base type, the type will
3359 be replaced and the original type will no longer be accessible.
3360
3361 The \fBtypeset\fR command with \fB-T\fR and no option argument or operands will
3362 write all the type definitions to standard output in a form that that can be
3363 read in to create all the types.
3364
3365 .SS "Jobs"
3366 If the monitor option of the \fBset\fR command is turned on, an interactive
3367 shell associates a job with each pipeline. It keeps a table of current jobs,
3368 printed by the \fBjobs\fR command, and assigns them small integer numbers. When
3369 a job is started asynchronously with \fB&\fR, the shell prints a line which
3370 looks like:
3371 .sp
3372 .in +2
3373 .nf
3374 [1] 1234
3375 .fi
3376 .in -2
3377 .sp
3378
3379 .sp
3380 .LP
3381 indicating that the job which was started asynchronously was job number 1 and
3382 had one (top-level) process, whose process id was \fB1234\fR.
3383 .sp
3384 .LP
3385 If you are running a job and wish to stop it, CTRL-z sends a \fBSTOP\fR signal
3386 to the current job. The shell normally displays a message that the job has been
3387 stopped, and displays another prompt. You can then manipulate the state of this
3388 job, putting it in the background with the \fBbg\fR command, or run some other
3389 commands and then eventually bring the job back into the foreground with the
3390 foreground command \fBfg\fR. A CTRL-z takes effect immediately and is like an
3391 interrupt in that pending output and unread input are discarded when it is
3392 typed.
3393 .sp
3394 .LP
3395 A job being run in the background stops if it tries to read from the terminal.
3396 Background jobs are normally allowed to produce output, but this can be
3397 disabled by giving the command \fBsttytostop\fR. If you set this \fBtty\fR
3398 option, then background jobs stop when they try to produce output like they do
3399 when they try to read input.
3400 .sp
3401 .LP
3402 A job pool is a collection of jobs started with \fIlist\fR \fB&\fR associated
3403 with a name.
3404 .sp
3405 .LP
3406 There are several ways to refer to jobs in the shell. A job can be referred to
3407 by the process id of any process of the job or by one of the following:
3408 .sp
3409 .ne 2
3410 .na
3411 \fB%\fR\fInumber\fR
3412 .ad
3413 .RS 12n
3414 The job with the specified number.
3415 .RE
3416
3417 .sp
3418 .ne 2
3419 .na
3420 \fIpool\fR
3421 .ad
3422 .RS 12n
3423 All the jobs in the job pool named by \fIpool\fR.
3424 .RE
3425
3426 .sp
3427 .ne 2
3428 .na
3429 \fIpool\fR\fB.\fR\fInumber\fR
3430 .ad
3431 .RS 12n
3432 The job number \fInumber\fR in the pool named by \fIpool\fR.
3433 .RE
3434
3435 .sp
3436 .ne 2
3437 .na
3438 \fB%\fR\fIstring\fR
3439 .ad
3440 .RS 12n
3441 Any job whose command line begins with \fIstring\fR.
3442 .RE
3443
3444 .sp
3445 .ne 2
3446 .na
3447 \fB%?\fR\fIstring\fR
3448 .ad
3449 .RS 12n
3450 Any job whose command line contains \fIstring\fR.
3451 .RE
3452
3453 .sp
3454 .ne 2
3455 .na
3456 \fB%%\fR
3457 .ad
3458 .RS 12n
3459 Current job.
3460 .RE
3461
3462 .sp
3463 .ne 2
3464 .na
3465 \fB%+\fR
3466 .ad
3467 .RS 12n
3468 Equivalent to \fB%%\fR.
3469 .RE
3470
3471 .sp
3472 .ne 2
3473 .na
3474 \fB%-\fR
3475 .ad
3476 .RS 12n
3477 Previous job.
3478 .RE
3479
3480 .sp
3481 .ne 2
3482 In addition, unless noted otherwise, wherever a job can be specified,
3483 the name of a background job pool can be used to represent all the
3484 jobs in that pool.
3485 .na
3486 .ad
3487
3488 .sp
3489 .LP
3490 The shell learns immediately whenever a process changes state. It normally
3491 informs you whenever a job becomes blocked so that no further progress is
3492 possible, but only just before it prints a prompt. This is done so that it does
3493 not otherwise disturb your work. The notify option of the \fBset\fR command
3494 causes the shell to print these job change messages as soon as they occur.
3495 .sp
3496 .LP
3497 When the \fBmonitor\fR option is on, each background job that completes
3498 triggers any trap set for \fBCHLD\fR.
3499 .sp
3500 .LP
3501 When you try to leave the shell while jobs are running or stopped, you are
3502 warned that \fBYou have stopped(running) jobs.\fR You can use the \fBjobs\fR
3503 command to see what they are. If you immediately try to exit again, the shell
3504 does not warn you a second time, and the stopped jobs are terminated. When a
3505 login shell receives a \fBHUP\fR signal, it sends a \fBHUP\fR signal to each
3506 job that has not been disowned with the \fBdisown\fR built-in command.
3507 .SS "Signals"
3508 The \fBINT\fR and \fBQUIT\fR signals for an invoked command are ignored if the
3509 command is followed by \fB&\fR and the \fBmonitor\fR option is not active.
3510 Otherwise, signals have the values inherited by the shell from its parent. See
3511 the \fBtrap\fR built-in command.
3512 .SS "Execution"
3513 Each time a command is read, the substitutions are carried out. If the command
3514 name matches one of the ones in the \fBSpecial Built-in Commands\fR section of
3515 this manual page, it is executed within the current shell process. Next, the
3516 command name is checked to see if it matches a user defined function. If it
3517 does, the positional parameters are saved and then reset to the arguments of
3518 the function call. A function is also executed in the current shell process.
3519 When the function completes or issues a return, the positional parameter list
3520 is restored. For functions defined with the \fBfunction\fR \fBname\fR syntax,
3521 any trap set on \fBEXIT\fR within the function is executed. The exit value of a
3522 function is the value of the last command executed. If a command name is not a
3523 special built-in command or a user defined function, but it is one of the
3524 built-in commands, it is executed in the current shell process.
3525 .sp
3526 .LP
3527 The shell variables \fBPATH\fR and \fBFPATH\fR define the search path for the
3528 directory containing the command. Alternative directory names are separated by
3529 a colon (\fB:\fR). The default path is \fB/bin:/usr/bin:\fR, specifying
3530 \fB/bin\fR, \fB/usr/bin\fR, and the current directory in that order. The
3531 current directory can be specified by two or more adjacent colons, or by a
3532 colon at the beginning or end of the path list. If the command name contains a
3533 slash (\fB/\fR), the search path is not used. Otherwise, each directory in the
3534 list of directories defined by \fBPATH\fR and \fBFPATH\fR is checked in order.
3535 If the directory being searched is contained in the value of the \fBFPATH\fR
3536 variable and contains a file whose name matches the command being searched,
3537 then this file is loaded into the current shell environment as if it were the
3538 argument to the . command except that only preset aliases are expanded, and a
3539 function of the specified name is executed as described in this manual page.
3540 .sp
3541 .LP
3542 If this directory is not in \fBFPATH\fR, the shell first determines whether
3543 there is a built-in version of a command corresponding to a given pathname and,
3544 if so, it is invoked in the current process. If no built-in is found, the shell
3545 checks for a file named \fB\&.paths\fR in this directory. If found and there is
3546 a line of the form:
3547 .sp
3548 .in +2
3549 \fBFPATH=\fR\fIpath\fR
3550 .in -2
3551 .sp
3552 where \fIpath\fR is an existing directory, then that directory is searched
3553 immediately after the current directory as if it were found in the \fBFPATH\fR
3554 variable. If \fIpath\fR does not begin with \fB/\fR, it is checked for relative
3555 to the directory being searched.
3556 .sp
3557 .LP
3558 The \fB\&.paths\fR file is then checked for a line of the form:
3559 .sp
3560 .in +2
3561 \fBPLUGIN_LIB=\fR\fIlibname\fR [ \fB:\fR \fIlibname\fR \fB]\fR ...
3562 .in -2
3563 .sp
3564 Each library named by \fIlibname\fR will be searched for as if it were an
3565 option argument to \fBbuiltin -f\fR and, if it contains a built-in of the
3566 specified name, this is executed instead of a command by this name.
3567 .sp
3568 .LP
3569 Any built-in loaded from a library found this way will be associated with the
3570 directory containing the \fB.paths\fR file so it will only execute if not found
3571 in an earlier directory.
3572 .sp
3573 .LP
3574 Finally, the directory will be checked for a file of the given name.
3575 If the file has execute permission but is not an \fBa.out\fR file, it is
3576 assumed to be a file containing shell commands. A separate shell is spawned to
3577 read it. All non-exported variables are removed in this case. If the shell
3578 command file doesn't have read permission, and/or if the \fBsetuid\fR and
3579 \fBsetgid\fR bits are set on the file, then the shell executes an agent whose
3580 job it is to set up the permissions and execute the shell with the shell
3581 command file passed down as an open file.
3582
3583 If the \fB.paths\fR contains a line of the form:
3584 .sp
3585 .in +2
3586 \fBname=\fR\fIvalue\fR
3587 .in -2
3588 .sp
3589 in the
3590 first or second line, then the environment variable \fIname\fR is modified by
3591 prepending the directory specified by \fIvalue\fR to the directory list. If
3592 \fIvalue\fR is not an absolute directory, then it specifies a directory
3593 relative to the directory in which the executable was found. If the environment
3594 variable \fIname\fR does not already exist it will be added to the environment
3595 list for the specified command.
3596
3597 A parenthesized command is executed in a sub-shell without removing
3598 non-exported variables.
3599
3600 .SS "Command Re-entry"
3601 The text of the last \fBHISTSIZE\fR (default 512) commands entered from a
3602 terminal device is saved in a history file. The file \fB$HOME/.sh_history\fR is
3603 used if the \fBHISTFILE\fR variable is not set or if the file it names is not
3604 writable. A shell can access the commands of all interactive shells which use
3605 the same named \fBHISTFILE\fR. The built-in command \fBhist\fR is used to list
3606 or edit a portion of this file. The portion of the file to be edited or listed
3607 can be selected by number or by giving the first character or characters of the
3608 command. A single command or range of commands can be specified. If you do not
3609 specify an editor program as an argument to \fBhist\fR then the value of the
3610 variable \fBHISTEDIT\fR is used. If \fBHISTEDIT\fR is unset, the obsolete
3611 variable \fBFCEDIT\fR is used. If \fBFCEDIT\fR is not defined, then
3612 \fB/bin/ed\fR is used. The edited commands are printed and executed again upon
3613 leaving the editor unless you quit without writing. The \fB-s\fR option (and in
3614 obsolete versions, the editor name \fB-\fR) is used to skip the editing phase
3615 and to re-execute the command. In this case a substitution parameter of the
3616 form \fIold\fR\fB=\fR\fInew\fRcan be used to modify the command before
3617 execution. For example, with the preset alias \fBr\fR, which is aliased to
3618 \fB\&'hist -s'\fR, typing \fB`r bad=good c'\fR re-executes the most recent
3619 command which starts with the letter \fBc\fR, replacing the first occurrence of
3620 the string bad with the string good.
3621 .SS "Inline Editing Options"
3622 Normally, each command line entered from a terminal device is simply typed
3623 followed by a NEWLINE (RETURN or LINE FEED). If either the \fBemacs\fR,
3624 \fBgmacs\fR, or \fBvi\fR option is active, the user can edit the command line.
3625 To be in either of these edit modes set the corresponding option. An editing
3626 option is automatically selected each time the \fBVISUAL\fR or \fBEDITOR\fR
3627 variable is assigned a value ending in either of these option names.
3628 .sp
3629 .LP
3630 The editing features require that the user's terminal accept RETURN as carriage
3631 return without line feed and that a SPACE must overwrite the current character
3632 on the screen.
3633 .sp
3634 .LP
3635 Unless the \fBmultiline\fR option is on, the editing modes implement a concept
3636 where the user is looking through a window at the current line. The window
3637 width is the value of \fBCOLUMNS\fR if it is defined, otherwise \fB80\fR. If
3638 the window width is too small to display the prompt and leave at least 8
3639 columns to enter input, the prompt is truncated from the left. If the line is
3640 longer than the window width minus two, a mark is displayed at the end of the
3641 window to notify the user. As the cursor moves and reaches the window
3656 and executable commands defined by the \fBPATH\fR variable that could match the
3657 partial word is displayed. Otherwise, the list of files that match the
3658 specified word is displayed. If the partially entered word does not contain any
3659 file expansion characters, a \fB*\fR is appended before generating these lists.
3660 After displaying the generated list, the input line is redrawn. These
3661 operations are called command name listing and file name listing, respectively.
3662 There are additional operations, referred to as command name completion and
3663 file name completion, which compute the list of matching commands or files, but
3664 instead of printing the list, replace the current word with a complete or
3665 partial match. For file name completion, if the match is unique, a \fB/\fR is
3666 appended if the file is a directory and a space is appended if the file is not
3667 a directory. Otherwise, the longest common prefix for all the matching files
3668 replaces the word. For command name completion, only the portion of the file
3669 names after the last \fB/\fR are used to find the longest command prefix. If
3670 only a single name matches this prefix, then the word is replaced with the
3671 command name followed by a space. When using a \fBTAB\fR for completion that
3672 does not yield a unique match, a subsequent TAB provides a numbered list of
3673 matching alternatives. A specific selection can be made by entering the
3674 selection number followed by a TAB.
3675 .SS "Key Bindings"
3676 The \fBKEYBD\fR trap can be used to intercept keys as they are typed and change
3677 the characters that are actually seen by the shell. This trap is executed after
3678 each character (or sequence of characters when the first character is ESC) is
3679 entered while reading from a terminal.
3680 .sp
3681 .LP
3682 The variable \fB\&.sh.edchar\fR contains the character or character sequence
3683 which generated the trap. Changing the value of \fB\&.sh.edchar\fR in the trap
3684 action causes the shell to behave as if the new value were entered from the
3685 keyboard rather than the original value. The variable \fB\&.sh.edcol\fR is set
3686 to the input column number of the cursor at the time of the input. The variable
3687 \fB\&.sh.edmode\fR is set to \fBESC\fR when in \fBvi\fR insert mode and is null
3688 otherwise. By prepending \fB${.sh.editmode}\fR to a value assigned to
3689 \fB\&.sh.edchar\fR it causes the shell to change to control mode if it is not
3690 already in this mode.
3691 .sp
3692 .LP
3693 This trap is not invoked for characters entered as arguments to editing
3694 directives, or while reading input for a character search.
3695 .SS "\fBemacs\fR Editing Mode"
3696 This mode is entered by enabling either the \fBemacs\fR or \fBgmacs\fR option.
3697 The only difference between these two modes is the way they handle \fB^T\fR. To
3698 edit, the user moves the cursor to the point needing correction and then
3699 inserts or deletes characters or words as needed. All the editing commands are
3700 control characters or escape sequences. The notation for control characters is
3701 caret (\fB^\fR) followed by the character.
3702 .sp
3703 .LP
3704 For example, \fB^F\fR is the notation for CTRL/F. This is entered by depressing
3705 \fBf\fR while holding down the CTRL (control) key. The SHIFT key is not
3706 depressed. (The notation \fB^?\fR indicates the DEL (delete) key.)
3707 .sp
3708 .LP
3709 The notation for escape sequences is \fBM-\fR followed by a character. For
3710 example, \fBM-f\fR (pronounced \fBMeta f\fR) is entered by depressing ESC
3711 (\fBASCII 033\fR) followed by \fBf\fR. \fBM-F\fR is the notation for ESC
3712 followed by \fBF\fR.
3713 .sp
3714 .LP
3715 All edit commands operate from any place on the line, not just at the
3716 beginning. The RETURN or the LINE FEED key is not entered after edit commands
3717 except when noted.
3718 .sp
3719 .ne 2
3720 .na
3721 \fB^F\fR
3722 .ad
3723 .RS 13n
3724 Move the cursor forward (right) one character.
3725 .RE
3726
3727 .sp
3728 .ne 2
3729 .na
3730 \fBM-[C\fR
3731 .ad
3732 .RS 13n
3733 Move the cursor forward (right) one character.
3734 .RE
3735
3736 .sp
3737 .ne 2
3738 .na
3739 \fBM-f\fR
3740 .ad
3741 .RS 13n
3742 Move the cursor forward one word. The \fBemacs\fR editor's idea of a word is a
3743 string of characters consisting of only letters, digits and underscores.
3744 .RE
3745
3746 .sp
3747 .ne 2
3748 .na
3749 \fB^B\fR
3750 .ad
3751 .RS 13n
3752 Move the cursor backward (left) one character.
3753 .RE
3754
3755 .sp
3756 .ne 2
3757 .na
3758 \fBM-[D\fR
3759 .ad
3760 .RS 13n
3761 Move the cursor backward (left) one character.
3762 .RE
3763
3764 .sp
3765 .ne 2
3766 .na
3767 \fBM-b\fR
3768 .ad
3769 .RS 13n
3770 Move the cursor backward one word.
3771 .RE
3772
3773 .sp
3774 .ne 2
3775 .na
3776 \fB^A\fR
3777 .ad
3778 .RS 13n
3779 Move the cursor to the beginning of the line.
3780 .RE
3781
3782 .sp
3783 .ne 2
3784 .na
3785 \fBM-[H\fR
3786 .ad
3787 .RS 13n
3788 Move the cursor to the beginning of the line.
3789 .RE
3790
3791 .sp
3792 .ne 2
3793 .na
3794 \fB^E\fR
3795 .ad
3796 .RS 13n
3797 Move the cursor to the end of the line.
3798 .RE
3799
3800 .sp
3801 .ne 2
3802 .na
3803 \fBM-[Y\fR
3804 .ad
3805 .RS 13n
3806 Move the cursor to the end of line.
3807 .RE
3808
3809 .sp
3810 .ne 2
3811 .na
3812 \fB^]\fR\fIchar\fR
3813 .ad
3814 .RS 13n
3815 Move the cursor forward to the character \fIchar\fR on the current line.
3816 .RE
3817
3818 .sp
3819 .ne 2
3820 .na
3821 \fBM-^]\fR\fIchar\fR
3822 .ad
3823 .RS 13n
3824 Move the cursor backwards to the character \fIchar\fR on the current line.
3825 .RE
3826
3827 .sp
3828 .ne 2
3829 .na
3830 \fB^X^X\fR
3831 .ad
3832 .RS 13n
3833 Interchange the cursor and the mark.
3834 .RE
3835
3836 .sp
3837 .ne 2
3838 .na
3839 \fB\fIerase\fR
3840 .ad
3841 .RS 13n
3842 Delete the previous character. The user-defined erase character is defined by
3843 the \fBstty\fR(1) command, and is usually \fB^H\fR or \fB#\fR.
3844 .RE
3845
3846 .sp
3847 .ne 2
3848 .na
3849 \fB\fIlnext\fR
3850 .ad
3851 .RS 13n
3852 Removes the next character's editing features. The user-defined literal next
3853 character is defined by the \fBstty\fR(1) command, or is \fB^V\fR if not
3854 defined.
3855 .RE
3856
3857 .sp
3858 .ne 2
3859 .na
3860 \fB^D\fR
3861 .ad
3862 .RS 13n
3863 Delete the current character.
3864 .RE
3865
3866 .sp
3867 .ne 2
3868 .na
3869 \fBM-d\fR
3870 .ad
3871 .RS 13n
3872 Delete the current word.
3873 .RE
3874
3875 .sp
3876 .ne 2
3877 .na
3878 \fBM-^H\fR
3879 .ad
3880 .RS 13n
3881 MetaBACKSPACE. Delete the previous word.
3882 .RE
3883
3884 .sp
3885 .ne 2
3886 .na
3887 \fBM-h\fR
3888 .ad
3889 .RS 13n
3890 Delete the previous word.
3891 .RE
3892
3893 .sp
3894 .ne 2
3895 .na
3896 \fBM-^?\fR
3897 .ad
3898 .RS 13n
3899 MetaDEL. Delete the previous word. If your interrupt character is \fB^?\fR
3900 (DEL, the default), this command does not work.
3901 .RE
3902
3903 .sp
3904 .ne 2
3905 .na
3906 \fB^T\fR
3907 .ad
3908 .RS 13n
3909 Transpose the current character with the previous character, and advance the
3910 cursor in \fBemacs\fR mode. Transpose two previous characters in \fBgmacs\fR
3911 mode.
3912 .RE
3913
3914 .sp
3915 .ne 2
3916 .na
3917 \fB^C\fR
3918 .ad
3919 .RS 13n
3920 Capitalize the current character.
3921 .RE
3922
3923 .sp
3924 .ne 2
3925 .na
3926 \fBM-c\fR
3927 .ad
3928 .RS 13n
3929 Capitalize the current word.
3930 .RE
3931
3932 .sp
3933 .ne 2
3934 .na
3935 \fBM-l\fR
3936 .ad
3937 .RS 13n
3938 Change the current word to lower case.
3939 .RE
3940
3941 .sp
3942 .ne 2
3943 .na
3944 \fB^K\fR
3945 .ad
3946 .RS 13n
3947 Delete from the cursor to the end of the line. If preceded by a numerical
3948 parameter whose value is less than the current cursor position, delete from
3949 specified position up to the cursor. If preceded by a numerical parameter whose
3950 value is greater than the current cursor position, then delete from cursor up
3951 to specified cursor position.
3952 .RE
3953
3954 .sp
3955 .ne 2
3956 .na
3957 \fB^W\fR
3958 .ad
3959 .RS 13n
3960 Kill from the cursor to the mark.
3961 .RE
3962
3963 .sp
3964 .ne 2
3965 .na
3966 \fBM-p\fR
3967 .ad
3968 .RS 13n
3969 Push the region from the cursor to the mark on the stack.
3970 .RE
3971
3972 .sp
3973 .ne 2
3974 .na
3975 \fB\fIkill\fR
3976 .ad
3977 .RS 13n
3978 Kill the entire current line. The user-defined kill character is defined by the
3979 \fBstty\fR(1) command, usually a \fB^G\fR or \fB@\fR. If two kill characters
3980 are entered in succession, all kill characters from then on cause a line feed.
3981 This is useful when using paper terminals.
3982 .RE
3983
3984 .sp
3985 .ne 2
3986 .na
3987 \fB^Y\fR
3988 .ad
3989 .RS 13n
3990 Restore the last item removed from line. Yank the item back to the line.
3991 .RE
3992
3993 .sp
3994 .ne 2
3995 .na
3996 \fB^L\fR
3997 .ad
3998 .RS 13n
3999 Line feed and print the current line.
4000 .RE
4001
4002 .sp
4003 .ne 2
4004 .na
4005 \fBM-^L\fR
4006 .ad
4007 .RS 13n
4008 Clear the screen.
4009 .RE
4010
4011 .sp
4012 .ne 2
4013 .na
4014 \fB^@\fR
4015 .ad
4016 .RS 13n
4017 Null character. Set mark.
4018 .RE
4019
4020 .sp
4021 .ne 2
4022 .na
4023 \fBM-\fR\fIspace\fR
4024 .ad
4025 .RS 13n
4026 MetaSPACE. Set the mark.
4027 .RE
4028
4029 .sp
4030 .ne 2
4031 .na
4032 \fB^J\fR
4033 .ad
4034 .RS 13n
4035 New line. Execute the current line.
4036 .RE
4037
4038 .sp
4039 .ne 2
4040 .na
4041 \fB^M\fR
4042 .ad
4043 .RS 13n
4044 Return. Execute the current line.
4045 .RE
4046
4047 .sp
4048 .ne 2
4049 .na
4050 \fBEOF\fR
4051 .ad
4052 .RS 13n
4053 End-of-file character, normally \fB^D\fR, is processed as an \fBend-of-file\fR
4054 only if the current line is null.
4055 .RE
4056
4057 .sp
4058 .ne 2
4059 .na
4060 \fB^P\fR
4061 .ad
4062 .RS 13n
4063 Fetch the previous command. Each time \fB^P\fR is entered the previous command
4064 back in time is accessed. Moves back one line when it is not on the first line
4065 of a multi-line command.
4066 .RE
4067
4068 .sp
4069 .ne 2
4070 .na
4071 \fBM-[A\fR
4072 .ad
4073 .RS 13n
4074 Equivalent to \fB^P\fR.
4075 .RE
4076
4077 .sp
4078 .ne 2
4079 .na
4080 \fBM-<\fR
4081 .ad
4082 .RS 13n
4083 Fetch the least recent (oldest) history line.
4084 .RE
4085
4086 .sp
4087 .ne 2
4088 .na
4089 \fBM->\fR
4090 .ad
4091 .RS 13n
4092 Fetch the most recent (youngest) history line.
4093 .RE
4094
4095 .sp
4096 .ne 2
4097 .na
4098 \fB^N\fR
4099 .ad
4100 .RS 13n
4101 Fetch the next command line. Each time \fB^N\fR is entered the next command
4102 line forward in time is accessed.
4103 .RE
4104
4105 .sp
4106 .ne 2
4107 .na
4108 \fBM-[B\fR
4109 .ad
4110 .RS 13n
4111 Equivalent to \fB^N\fR.
4112 .RE
4113
4114 .sp
4115 .ne 2
4116 .na
4117 \fB^R\fR\fIstring\fR
4118 .ad
4119 .RS 13n
4120 Reverse search history for a previous command line containing \fIstring\fR. If
4121 a parameter of zero is specified, the search is forward. \fIstring\fR is
4122 terminated by a RETURN or NEWLINE. If string is preceded by a \fB^\fR, the
4123 matched line must begin with \fIstring\fR. If \fIstring\fR is omitted, then the
4124 next command line containing the most recent \fIstring\fR is accessed. In this
4125 case a parameter of zero reverses the direction of the search.
4126 .RE
4127
4128 .sp
4129 .ne 2
4130 .na
4131 \fB^O\fR
4132 .ad
4133 .RS 13n
4134 Operate. Execute the current line and fetch the next line relative to current
4135 line from the history file.
4136 .RE
4137
4138 .sp
4139 .ne 2
4140 .na
4141 \fBM-\fR\fIdigits\fR
4142 .ad
4143 .RS 13n
4144 Escape. Define numeric parameter. The digits are taken as a parameter to the
4145 next command. The commands that accept a parameter are: \fB^F\fR, \fB^B\fR,
4146 \fBERASE\fR, \fB^C\fR, \fB^D\fR, \fB^K\fR, \fB^R\fR, \fB^P\fR, \fB^N\fR,
4147 \fB^]\fR, \fBM-.\fR, \fBM-\fR, \fBM-^]\fR, \fBM-_\fR, \fBM-=\fR, \fBM-b\fR,
4148 \fBM-c\fR, \fBM-d\fR, \fBM-f\fR, \fBM-h\fR, \fBM-l\fR, and \fBM-^H\fR.
4149 .RE
4150
4151 .sp
4152 .ne 2
4153 .na
4154 \fBM-\fR\fIletter\fR
4155 .ad
4156 .RS 13n
4157 Soft-key. Search the alias list for an alias by the name \fIletter\fR. If an
4158 alias of \fIletter\fR is defined, insert its value on the input queue.
4159 \fIletter\fR must not be one of the metafunctions in this section.
4160 .RE
4161
4162 .sp
4163 .ne 2
4164 .na
4165 \fBM-[\fR\fIletter\fR
4166 .ad
4167 .RS 13n
4168 Soft key. Search the alias list for an alias by the name \fIletter\fR. If an
4169 alias of this name is defined, insert its value on the input queue. This can be
4170 used to program function keys on many terminals.
4171 .RE
4172
4173 .sp
4174 .ne 2
4175 .na
4176 \fBM-.\fR
4177 .ad
4178 .RS 13n
4179 The last word of the previous command is inserted on the line. If preceded by a
4180 numeric parameter, the value of this parameter determines which word to insert
4181 rather than the last word.
4182 .RE
4183
4184 .sp
4185 .ne 2
4186 .na
4187 \fBM-_\fR
4188 .ad
4189 .RS 13n
4190 Same as \fBM-.\fR.
4191 .RE
4192
4193 .sp
4194 .ne 2
4195 .na
4196 \fBM-*\fR
4197 .ad
4198 .RS 13n
4199 Attempt filename generation on the current word. As asterisk is appended if the
4200 word does not match any file or contain any special pattern characters.
4201 .RE
4202
4203 .sp
4204 .ne 2
4205 .na
4206 \fBM-\fRESC\fR
4207 .ad
4208 .RS 13n
4209 Command or file name completion as described in this manual page.
4210 .RE
4211
4212 .sp
4213 .ne 2
4214 .na
4215 \fB^I\fRTAB\fR
4216 .ad
4217 .RS 13n
4218 Attempts command or file name completion as described in this manual page. If a
4219 partial completion occurs, repeating this behaves as if \fBM-=\fR were entered.
4220 If no match is found or entered after SPACE, a TAB is inserted.
4221 .RE
4222
4223 .sp
4224 .ne 2
4225 .na
4226 \fBM-=\fR
4227 .ad
4228 .RS 13n
4229 If not preceded by a numeric parameter, generates the list of matching commands
4230 or file names as described in this manual page. Otherwise, the word under the
4231 cursor is replaced by the item corresponding to the value of the numeric
4232 parameter from the most recently generated command or file list. If the cursor
4233 is not on a word, the word is inserted instead.
4234 .RE
4235
4236 .sp
4237 .ne 2
4238 .na
4239 \fB^U\fR
4240 .ad
4241 .RS 13n
4242 Multiply parameter of next command by \fB4\fR.
4243 .RE
4244
4245 .sp
4246 .ne 2
4247 .na
4248 \fB\e\fR
4249 .ad
4250 .RS 13n
4251 Escape the next character. Editing characters, the user's erase, kill and
4252 interrupt (normally \fB^?\fR) characters can be entered in a command line or in
4253 a search string if preceded by a \fB\e\fR\&. The \fB\e\fR removes the next
4254 character's editing features, if any.
4255 .RE
4256
4257 .sp
4258 .ne 2
4259 .na
4260 \fBM-^V\fR
4261 .ad
4262 .RS 13n
4263 Display the version of the shell.
4264 .RE
4265
4266 .sp
4267 .ne 2
4268 .na
4269 \fBM-#\fR
4270 .ad
4271 .RS 13n
4272 If the line does not begin with a \fB#\fR, a \fB#\fR is inserted at the
4273 beginning of the line and after each NEWLINE, and the line is entered. This
4274 causes a comment to be inserted in the history file. If the line begins with a
4275 \fB#\fR, the \fB#\fR is deleted and one \fB#\fR after each NEWLINE is also
4276 deleted.
4277 .RE
4278
4279 .SS "\fBvi\fR Editing Mode"
4280 There are two typing modes. Initially, when you enter a command you are in the
4281 input mode. To edit, the user enters control mode by typing ESC (033) and moves
4282 the cursor to the point needing correction and then inserts or deletes
4283 characters or words as needed. Most control commands accept an optional repeat
4284 \fIcount\fR prior to the command.
4285 .sp
4286 .LP
4287 When in vi mode on most systems, canonical processing is initially enabled and
4288 the command is echoed again if the speed is 1200 baud or greater and it
4289 contains any control characters or less than one second has elapsed since the
4290 prompt was printed. The ESC character terminates canonical processing for the
4291 remainder of the command and the user can then modify the command line. This
4292 scheme has the advantages of canonical processing with the type-ahead echoing
4293 of raw mode.
4294 .sp
4295 .LP
4296 If the option \fBviraw\fR is also set, the terminal is always have canonical
4297 processing disabled. This mode is implicit for systems that do not support two
4298 alternate end of line delimiters, and might be helpful for certain terminals.
4299 .SS "Input Edit Commands"
4300 By default the editor is in input mode.
4301 .sp
4302 .LP
4303 The following input edit commands are supported:
4304 .sp
4305 .ne 2
4306 .na
4307 \fBERASE\fR
4308 .ad
4309 .RS 10n
4310 User defined erase character as defined by the \fBstty\fR command, usually
4311 \fB^H\fR or \fB#\fR. Delete previous character.
4312 .RE
4313
4314 .sp
4315 .ne 2
4316 .na
4317 \fB^W\fR
4318 .ad
4319 .RS 10n
4320 Delete the previous blank separated word. On some systems the \fBviraw\fR
4321 option might be required for this to work.
4322 .RE
4323
4324 .sp
4325 .ne 2
4326 .na
4327 \fBEOF\fR
4328 .ad
4329 .RS 10n
4330 As the first character of the line causes the shell to terminate unless the
4331 \fBignoreeof\fR option is set. Otherwise this character is ignored.
4332 .RE
4333
4334 .sp
4335 .ne 2
4336 .na
4337 \fB\fIlnext\fR
4338 .ad
4339 .RS 10n
4340 User defined literal next character as defined by the \fBstty\fR(1) or \fB^V\fR
4341 if not defined. Removes the next character's editing features, if any. On some
4342 systems the \fBviraw\fR option might be required for this to work.
4343 .RE
4344
4345 .sp
4346 .ne 2
4347 .na
4348 \fB\e\fR
4349 .ad
4350 .RS 10n
4351 Escape the next ERASE or KILL character.
4352 .RE
4353
4354 .sp
4355 .ne 2
4356 .na
4357 \fB^I\fR TAB\fR
4358 .ad
4359 .RS 10n
4360 Attempts command or file name completion as described in this manual page and
4361 returns to input mode. If a partial completion occurs, repeating this behaves
4362 as if \fB=\fR were entered from control mode. If no match is found or entered
4363 after SPACE, a TAB is inserted.
4364 .RE
4365
4366 .SS "Motion Edit Commands"
4367 The motion edit commands move the cursor.
4368 .sp
4369 .LP
4370 The following motion edit commands are supported:
4371 .sp
4372 .ne 2
4373 .na
4374 \fB[\fR\fIcount\fR\fB]l\fR
4375 .ad
4376 .RS 13n
4377 Move the cursor forward (right) one character.
4378 .RE
4379
4380 .sp
4381 .ne 2
4382 .na
4383 \fB[\fR\fIcount\fR\fB][C\fR
4384 .ad
4385 .RS 13n
4386 Move the cursor forward (right) one character.
4387 .RE
4388
4389 .sp
4390 .ne 2
4391 .na
4392 \fB[\fR\fIcount\fR\fB]w\fR
4393 .ad
4394 .RS 13n
4395 Move the cursor forward one alphanumeric word.
4396 .RE
4397
4398 .sp
4399 .ne 2
4400 .na
4401 \fB[\fR\fIcount\fR\fB]W\fR
4402 .ad
4403 .RS 13n
4404 Move the cursor to the beginning of the next word that follows a blank.
4405 .RE
4406
4407 .sp
4408 .ne 2
4409 .na
4410 \fB[\fR\fIcount\fR\fB]e\fR
4411 .ad
4412 .RS 13n
4413 Move the cursor to the end of the word.
4414 .RE
4415
4416 .sp
4417 .ne 2
4418 .na
4419 \fB[\fR\fIcount\fR\fB]E\fR
4420 .ad
4421 .RS 13n
4422 Move the cursor to the end of the current blank delimited word.
4423 .RE
4424
4425 .sp
4426 .ne 2
4427 .na
4428 \fB[\fR\fIcount\fR\fB]h\fR
4429 .ad
4430 .RS 13n
4431 Move the cursor backward (left) one character.
4432 .RE
4433
4434 .sp
4435 .ne 2
4436 .na
4437 \fB[\fR\fIcount\fR\fB][D\fR
4438 .ad
4439 .RS 13n
4440 Move the cursor backward (left) one character.
4441 .RE
4442
4443 .sp
4444 .ne 2
4445 .na
4446 \fB[\fR\fIcount\fR\fB]b\fR
4447 .ad
4448 .RS 13n
4449 Move the cursor backward one word.
4450 .RE
4451
4452 .sp
4453 .ne 2
4454 .na
4455 \fB[\fR\fIcount\fR\fB]B\fR
4456 .ad
4457 .RS 13n
4458 Move the cursor to the preceding blank separated word.
4459 .RE
4460
4461 .sp
4462 .ne 2
4463 .na
4464 \fB[\fR\fIcount\fR\fB]|\fR
4465 .ad
4466 .RS 13n
4467 Move the cursor to column \fIcount\fR.
4468 .RE
4469
4470 .sp
4471 .ne 2
4472 .na
4473 \fB[\fR\fIcount\fR\fB]f\fR\fIc\fR
4474 .ad
4475 .RS 13n
4476 Find the next character \fIc\fR in the current line.
4477 .RE
4478
4479 .sp
4480 .ne 2
4481 .na
4482 \fB[\fR\fIcount\fR\fB]F\fR\fIc\fR
4483 .ad
4484 .RS 13n
4485 Find the previous character \fIc\fR in the current line.
4486 .RE
4487
4488 .sp
4489 .ne 2
4490 .na
4491 \fB[\fR\fIcount\fR\fB]t\fR\fIC\fR
4492 .ad
4493 .RS 13n
4494 Equivalent to \fBf\fR followed by \fBh\fR.
4495 .RE
4496
4497 .sp
4498 .ne 2
4499 .na
4500 \fB[\fR\fIcount\fR\fB]T\fR\fIc\fR
4501 .ad
4502 .RS 13n
4503 Equivalent to \fBF\fR followed by \fBl\fR.
4504 .RE
4505
4506 .sp
4507 .ne 2
4508 .na
4509 \fB[\fR\fIcount\fR\fB];\fR
4510 .ad
4511 .RS 13n
4512 Repeat \fIcount\fR times the last single character find command: \fBf\fR,
4513 \fBF\fR, \fBt,\fR or \fBT\fR.
4514 .RE
4515
4516 .sp
4517 .ne 2
4518 .na
4519 \fB[\fR\fIcount\fR\fB],\fR
4520 .ad
4521 .RS 13n
4522 Reverse the last single character find command \fIcount\fR times.
4523 .RE
4524
4525 .sp
4526 .ne 2
4527 .na
4528 \fB0\fR
4529 .ad
4530 .RS 13n
4531 Move the cursor to the start of line.
4532 .RE
4533
4534 .sp
4535 .ne 2
4536 .na
4537 \fB^\fR
4538 .ad
4539 .RS 13n
4540 Move the cursor to start of line.
4541 .RE
4542
4543 .sp
4544 .ne 2
4545 .na
4546 \fB[H\fR
4547 .ad
4548 .RS 13n
4549 Move the cursor to the first non-blank character in the line.
4550 .RE
4551
4552 .sp
4553 .ne 2
4554 .na
4555 \fB$\fR
4556 .ad
4557 .RS 13n
4558 Move the cursor to the end of the line.
4559 .RE
4560
4561 .sp
4562 .ne 2
4563 .na
4564 \fB[Y\fR
4565 .ad
4566 .RS 13n
4567 Move the cursor to the end of the line.
4568 .RE
4569
4570 .sp
4571 .ne 2
4572 .na
4573 \fB%\fR
4574 .ad
4575 .RS 13n
4576 Moves to balancing \fB(\fR, \fB)\fR, \fB{\fR, \fB}\fR, \fB[\fR, or \fB]\fR. If
4577 cursor is not on one of the characters described in this section, the remainder
4578 of the line is searched for the first occurrence of one of the characters
4579 first.
4580 .RE
4581
4582 .SS "Search Edit Commands"
4583 The search edit commands access your command history.
4584 .sp
4585 .LP
4586 The following search edit commands are supported:
4587 .sp
4588 .ne 2
4589 .na
4590 \fB[\fR\fIcount\fR\fB]k\fR
4591 .ad
4592 .RS 13n
4593 Fetch the previous command. Each time \fBk\fR is entered, the previous command
4594 back in time is accessed.
4595 .RE
4596
4597 .sp
4598 .ne 2
4599 .na
4600 \fB[\fR\fIcount\fR\fB]-\fR
4601 .ad
4602 .RS 13n
4603 Fetch the previous command. Each time \fBk\fR is entered, the previous command
4604 back in time is accessed.
4605 .sp
4606 Equivalent to \fBk\fR.
4607 .RE
4608
4609 .sp
4610 .ne 2
4611 .na
4612 \fB[\fR\fIcount\fR\fB][A\fR
4613 .ad
4614 .RS 13n
4615 Fetch the previous command. Each time \fBk\fR is entered, the previous command
4616 back in time is accessed.
4617 .sp
4618 Equivalent to \fBk\fR.
4619 .RE
4620
4621 .sp
4622 .ne 2
4623 .na
4624 \fB[\fR\fIcount\fR\fB]j\fR
4625 .ad
4626 .RS 13n
4627 Fetch the next command. Each time \fBj\fR is entered, the next command forward
4628 in time is accessed.
4629 .RE
4630
4631 .sp
4632 .ne 2
4633 .na
4634 \fB[\fR\fIcount\fR\fB]+\fR
4635 .ad
4636 .RS 13n
4637 Fetch the next command. Each time \fBj\fR is entered, the next command forward
4638 in time is accessed.
4639 .sp
4640 Equivalent to \fBj\fR.
4641 .RE
4642
4643 .sp
4644 .ne 2
4645 .na
4646 \fB[\fR\fIcount\fR\fB][B\fR
4647 .ad
4648 .RS 13n
4649 Fetch the next command. Each time \fBj\fR is entered, the next command forward
4650 in time is accessed.
4651 .sp
4652 Equivalent to \fBj\fR.
4653 .RE
4654
4655 .sp
4656 .ne 2
4657 .na
4658 \fB[\fR\fIcount\fR\fB]G\fR
4659 .ad
4660 .RS 13n
4661 Fetch command number \fIcount\fR. The default is the least recent history
4662 command.
4663 .RE
4664
4665 .sp
4666 .ne 2
4667 .na
4668 \fB/\fR\fIstring\fR
4669 .ad
4670 .RS 13n
4671 Search backward through history for a previous command containing \fIstring\fR.
4672 \fIstring\fR is terminated by a RETURN or NEWLINE. If string is preceded by a
4673 \fB^\fR, the matched line must begin with \fIstring\fR. If \fIstring\fR is
4674 null, the previous string is used.
4675 .RE
4676
4677 .sp
4678 .ne 2
4679 .na
4680 \fB?\fR\fIstring\fR
4681 .ad
4682 .RS 13n
4683 Search forward through history for a previous command containing \fIstring\fR.
4684 \fIstring\fR is terminated by a RETURN or NEWLINE. If string is preceded by a
4685 \fB^\fR, the matched line must begin with \fIstring\fR. If \fIstring\fR is
4686 null, the previous string is used.
4687 .sp
4688 Same as \fI/\fR except that search is in the forward direction.
4689 .RE
4690
4691 .sp
4692 .ne 2
4693 .na
4694 \fBn\fR
4695 .ad
4696 .RS 13n
4697 Search in the backwards direction for the next match of the last pattern to
4698 \fI/\fR or \fI?\fR commands.
4699 .RE
4700
4701 .sp
4702 .ne 2
4703 .na
4704 \fBN\fR
4705 .ad
4706 .RS 13n
4707 Search in the forward direction for next match of the last pattern to \fI/\fR
4708 or \fI?\fR.
4709 .RE
4710
4711 .SS "Text Modification Edit Commands"
4712 The following commands modify the line:
4713 .sp
4714 .ne 2
4715 .na
4716 \fBa\fR
4717 .ad
4718 .RS 19n
4719 Enter input mode and enter text after the current character.
4720 .RE
4721
4722 .sp
4723 .ne 2
4724 .na
4725 \fBA\fR
4726 .ad
4727 .RS 19n
4728 Append text to the end of the line. Equivalent to \fB$a\fR.
4729 .RE
4730
4731 .sp
4732 .ne 2
4733 .na
4734 \fB[\fR\fIcount\fR\fB]c\fR\fImotion\fR
4735 .ad
4736 .br
4737 .na
4738 \fBc[\fR\fIcount\fR\fB]\fR\fImotion\fR
4739 .ad
4740 .RS 19n
4741 Delete current character through the character that \fImotion\fR would move the
4742 cursor to and enter input mode. If \fImotion\fR is \fBc\fR, the entire line is
4743 deleted and input mode entered.
4744 .RE
4745
4746 .sp
4747 .ne 2
4748 .na
4749 \fBC\fR
4750 .ad
4751 .RS 19n
4752 Delete the current character through the end of line and enter input mode.
4753 Equivalent to \fBc$\fR.
4754 .RE
4755
4756 .sp
4757 .ne 2
4758 .na
4759 \fBS\fR
4760 .ad
4761 .RS 19n
4762 Equivalent to \fBcc\fR.
4763 .RE
4764
4765 .sp
4766 .ne 2
4767 .na
4768 \fB[\fR\fIcount\fR\fB]s\fR
4769 .ad
4770 .RS 19n
4771 Replace characters under the cursor in input mode.
4772 .RE
4773
4774 .sp
4775 .ne 2
4776 .na
4777 \fBD[\fR\fIcount\fR\fB]d\fR\fImotion\fR
4778 .ad
4779 .RS 19n
4780 Delete the current character through the end of line. Equivalent to d$.
4781 .RE
4782
4783 .sp
4784 .ne 2
4785 .na
4786 \fBd[\fR\fIcount\fR\fB]\fR\fImotion\fR
4787 .ad
4788 .RS 19n
4789 Delete current character through the character that \fImotion\fR would move to.
4790 If \fImotion\fR is d , the entire line is deleted.
4791 .RE
4792
4793 .sp
4794 .ne 2
4795 .na
4796 \fBi\fR
4797 .ad
4798 .RS 19n
4799 Enter input mode and insert text before the current character.
4800 .RE
4801
4802 .sp
4803 .ne 2
4804 .na
4805 \fBI\fR
4806 .ad
4807 .RS 19n
4808 Insert text before the beginning of the line. Equivalent to \fB0i\fR.
4809 .RE
4810
4811 .sp
4812 .ne 2
4813 .na
4814 \fB[\fR\fIcount\fR\fB]P\fR
4815 .ad
4816 .RS 19n
4817 Place the previous text modification before the cursor.
4818 .RE
4819
4820 .sp
4821 .ne 2
4822 .na
4823 \fB[\fR\fIcount\fR\fB]p\fR
4824 .ad
4825 .RS 19n
4826 Place the previous text modification after the cursor.
4827 .RE
4828
4829 .sp
4830 .ne 2
4831 .na
4832 \fBR\fR
4833 .ad
4834 .RS 19n
4835 Enter input mode and replace characters on the screen with characters you type
4836 overlay fashion.
4837 .RE
4838
4839 .sp
4840 .ne 2
4841 .na
4842 \fB[\fR\fIcount\fR\fB]r\fR\fIc\fR
4843 .ad
4844 .RS 19n
4845 Replace the \fIcount\fR characters starting at the current cursor position with
4846 \fIc\fR, and advance the cursor.
4847 .RE
4848
4849 .sp
4850 .ne 2
4851 .na
4852 \fB[\fR\fIcount\fR\fB]x\fR
4853 .ad
4854 .RS 19n
4855 Delete current character.
4856 .RE
4857
4858 .sp
4859 .ne 2
4860 .na
4861 \fB[\fIcount\fR]X\fR
4862 .ad
4863 .RS 19n
4864 Delete preceding character.
4865 .RE
4866
4867 .sp
4868 .ne 2
4869 .na
4870 \fB[\fIcount\fR].\fR
4871 .ad
4872 .RS 19n
4873 Repeat the previous text modification command.
4874 .RE
4875
4876 .sp
4877 .ne 2
4878 .na
4879 \fB[\fIcount\fR]~\fR
4880 .ad
4881 .RS 19n
4882 Invert the case of the \fIcount\fR characters starting at the current cursor
4883 position and advance the cursor.
4884 .RE
4885
4886 .sp
4887 .ne 2
4888 .na
4889 \fB[\fIcount\fR]_\fR
4890 .ad
4891 .RS 19n
4892 Causes the \fIcount\fR word of the previous command to be appended and input
4893 mode entered. The last word is used if \fIcount\fR is omitted.
4894 .RE
4895
4896 .sp
4897 .ne 2
4898 .na
4899 \fB*\fR
4900 .ad
4901 .RS 19n
4902 Causes an \fB*\fR to be appended to the current word and file name generation
4903 attempted. If no match is found, it rings the bell. Otherwise, the word is
4904 replaced by the matching pattern and input mode is entered.
4905 .RE
4906
4907 .sp
4908 .ne 2
4909 .na
4910 \fB\e\fR
4911 .ad
4912 .RS 19n
4913 Command or file name completion as described in this manual page.
4914 .RE
4915
4916 .SS "Other Edit Commands"
4917 The following miscellaneous edit commands are supported:
4918 .sp
4919 .ne 2
4920 .na
4921 \fB[\fR\fIcount\fR\fB]y\fR\fImotion\fR
4922 .ad
4923 .br
4924 .na
4925 \fBy[\fR\fIcount\fR\fB]\fR\fImotion\fR
4926 .ad
4927 .RS 18n
4928 Yank the current character through the character to which \fImotion\fR would
4929 move the cursor. Put the yanked characters in the delete buffer. The text and
4930 cursor position are unchanged.
4931 .RE
4932
4933 .sp
4934 .ne 2
4935 .na
4936 \fByy\fR
4937 .ad
4938 .RS 18n
4939 Yank the current line.
4940 .RE
4941
4942 .sp
4943 .ne 2
4944 .na
4945 \fBY\fR
4946 .ad
4947 .RS 18n
4948 Yank the current line from the current cursor location to the end of the line.
4949 Equivalent to \fBy$\fR.
4950 .RE
4951
4952 .sp
4953 .ne 2
4954 .na
4955 \fBu\fR
4956 .ad
4957 .RS 18n
4958 Undo the last text modifying command.
4959 .RE
4960
4961 .sp
4962 .ne 2
4963 .na
4964 \fBU\fR
4965 .ad
4966 .RS 18n
4967 Undo all the text modifying commands performed on current line.
4968 .RE
4969
4970 .sp
4971 .ne 2
4972 .na
4973 \fB[\fR\fIcount\fR\fB]V\fR
4974 .ad
4975 .RS 18n
4976 Return the command :
4977 .sp
4978 .in +2
4979 .nf
4980 hist -e ${VISUAL:-${EDITOR:-vi}} \fIcount\fR
4981 .fi
4982 .in -2
4983 .sp
4984
4985 in the input buffer. If \fIcount\fR is omitted, the current line is used.
4986 .RE
4987
4988 .sp
4989 .ne 2
4990 .na
4991 \fB^L\fR
4992 .ad
4993 .RS 18n
4994 Line feed and print the current line. This command only works in control mode.
4995 .RE
4996
4997 .sp
4998 .ne 2
4999 .na
5000 \fB^J\fR
5001 .ad
5002 .RS 18n
5003 New line. Execute the current line, regardless of mode.
5004 .RE
5005
5006 .sp
5007 .ne 2
5008 .na
5009 \fB^M\fR
5010 .ad
5011 .RS 18n
5012 Return. Execute the current line, regardless of mode.
5013 .RE
5014
5015 .sp
5016 .ne 2
5017 .na
5018 \fB#\fR
5019 .ad
5020 .RS 18n
5021 If the first character of the command is a \fB#\fR , delete this \fB#\fR and
5022 each \fB#\fR that follows a NEWLINE.
5023 .sp
5024 Otherwise, send the line after inserting a \fB#\fR in front of each line in the
5025 command.
5026 .sp
5027 This is command is useful for causing the current line to be inserted in the
5028 history as a comment and un-commenting previously commented commands in the
5029 history file.
5030 .RE
5031
5032 .sp
5033 .ne 2
5034 .na
5035 \fB[\fR\fIcount\fR\fB]=\fR
5036 .ad
5037 .RS 18n
5038 If \fIcount\fR is not specified, generate the list of matching commands or file
5039 names as described in this manual page.
5040 .sp
5041 Otherwise, replace the word at the current cursor location with the \fIcount\fR
5042 item from the most recently generated command or file list. If the cursor is
5043 not on a word, it is inserted after the current cursor location.
5044 .RE
5045
5046 .sp
5047 .ne 2
5048 .na
5049 \fB@\fR\fIletter\fR
5050 .ad
5051 .RS 18n
5052 Search your alias list for an alias by the name \fIletter\fR. If an alias of
5053 this name is defined, insert its value on the input queue for processing.
5054 .RE
5055
5056 .sp
5057 .ne 2
5058 .na
5059 \fB^V\fR
5060 .ad
5061 .RS 18n
5062 Display version of the shell.
5063 .RE
5064
5065 .SS "Built-in Commands"
5066 The following simple-commands are executed in the shell process. Input and
5067 output redirection is permitted. Unless otherwise indicated, the output is
5068 written on file descriptor \fB1\fR and the exit status, when there is no syntax
5069 error, is \fB0\fR. Except for \fB:\fR, \fBtrue\fR, \fBfalse\fR, \fBecho\fR,
5070 \fBnewgrp\fR, and \fBlogin\fR, all built-in commands accept \fB--\fR to
5071 indicate the end of options. They also interpret the option \fB--man\fR as a
5072 request to display the manual page onto standard error and \fB-?\fR as a help
5073 request which prints a usage message on standard error.
5074 .sp
5075 .LP
5076 Commands that are preceded by one or two \fB++\fR symbols are special built-in
5077 commands and are treated specially in the following ways:
5078 .RS +4
5079 .TP
5080 1.
5081 Variable assignment lists preceding the command remain in effect when the
5082 command completes.
5083 .RE
5084 .RS +4
5085 .TP
5090 .TP
5091 3.
5092 Errors cause a script that contains them to abort.
5093 .RE
5094 .RS +4
5095 .TP
5096 4.
5097 They are not valid function names.
5098 .RE
5099 .RS +4
5100 .TP
5101 5.
5102 Words following a command preceded by \fB++\fR that are in the format of a
5103 variable assignment are expanded with the same rules as a variable assignment.
5104 This means that tilde substitution is performed after the \fB=\fR sign and
5105 field splitting and file name generation are not performed.
5106 .RE
5107 .sp
5108 .ne 2
5109 .na
5110 \fB+ : [\fR\fIarg ...\fR\fB]\fR
5111 .ad
5112 .sp .6
5113 .RS 4n
5114 The command only expands parameters.
5115 .RE
5116
5117 .sp
5118 .ne 2
5119 .na
5120 \fB+ .\fR \fIname\fR \fB[\fR\fIarg ...\fR\fB]\fR
5121 .ad
5122 .sp .6
5123 .RS 4n
5124 If \fIname\fR is a function defined with the \fBfunction\fR \fBname\fR reserved
5125 word syntax, the function is executed in the current environment (as if it had
5126 been defined with the \fIname()\fR syntax.) Otherwise if \fIname\fR refers to a
5127 file, the file is read in its entirety and the commands are executed in the
5128 current shell environment. The search path specified by PATH is used to find
5129 the directory containing the file. If any arguments \fIarg\fR are specified,
5130 they become the positional parameters while processing the . command and the
5131 original positional parameters are restored upon completion. Otherwise the
5132 positional parameters are unchanged. The exit status is the exit status of the
5133 last command executed.
5134 .RE
5135
5136 .sp
5137 .ne 2
5138 .na
5139 \fB++ alias [\fR\fB-ptx\fR\fB] [\fR\fIname\fR\fB[
5140 =\fR\fIvalue\fR\fB]] ...\fR
5141 .ad
5142 .sp .6
5143 .RS 4n
5144 \fBalias\fR with no arguments prints the list of aliases in the form
5145 \fIname\fR\fB=\fR\fIvalue\fR on standard output. The \fB-p\fR option causes the
5146 word alias to be inserted before each one. When one or more arguments are
5147 specified, an \fIalias\fR is defined for each \fIname\fR whose \fIvalue\fR is
5148 specified. A trailing space in \fIvalue\fR causes the next word to be checked
5149 for alias substitution. The obsolete \fB-t\fR option is used to set and list
5150 tracked aliases. The value of a tracked alias is the full pathname
5151 corresponding to the specified \fIname\fR. The value becomes undefined when the
5152 value of \fBPATH\fR is reset but the alias remains tracked. Without the
5153 \fB-t\fR option, for each \fIname\fR in the argument list for which no
5154 \fIvalue\fR is specified, the name and value of the alias is printed. The
5155 obsolete -x option has no effect. The exit status is \fBnon-zero\fR if a
5156 \fIname\fR is specified, but no value, and no alias has been defined for the
5157 \fIname\fR.
5158 .RE
5159
5160 .sp
5161 .ne 2
5162 .na
5163 \fBbg [\fR \fIjob\fR\fB\&...]\fR
5164 .ad
5165 .sp .6
5166 .RS 4n
5167 This command is only on systems that support job control. Puts each specified
5168 \fIjob\fR into the background. The current job is put in the background if
5169 \fIjob\fR is not specified. See the \fBJobs\fR section of this manual page for
5170 a description of the format of \fIjob\fR.
5171 .RE
5172
5173 .sp
5174 .ne 2
5175 .na
5176 \fB+ break [\fR\fIn\fR\fB]\fR
5177 .ad
5178 .sp .6
5179 .RS 4n
5180 Exit from the enclosing \fBfor\fR, \fBwhile\fR, \fBuntil\fR, or \fBselect\fR
5181 loop, if any. If \fIn\fR is specified, then break \fIn\fR levels.
5182 .RE
5183
5184 .sp
5185 .ne 2
5186 .na
5187 \fBbuiltin [\fR\fB-ds\fR \fB] [\fR\fB-f\fR \fIfile\fR\fB]
5188 [\fR\fIname ...\fR\fB]\fR
5189 .ad
5190 .sp .6
5191 .RS 4n
5192 If \fIname\fR is not specified, and no \fB-f\fR option is specified, the
5193 built-ins are printed on standard output. The \fB-s\fR option prints only the
5194 special built-ins. Otherwise, each \fIname\fR represents the pathname whose
5195 basename is the name of the built-in. The entry point function name is
5196 determined by prepending \fIb_\fR to the built-in name. A built-in specified by
5197 a pathname will only be executed when that pathname would be found during the
5198 path search. Built-ins found in libraries loaded via the \fB.paths\fR file will
5199 be associate with the pathname of the directory containing the \fB.paths\fR
5200 file.
5201 .sp
5202 The ISO C/C++ prototype
5203 is \fBb\fR\fImycommand(int argc, char *argv[], void *context)\fR for the
5204 built-in command \fImycommand\fR where \fIargv\fR is an array of \fIargc\fR
5205 elements and \fIcontext\fR is an optional pointer to a \fBShell_t\fR structure
5206 as described in \fB<ast/shell.h>\fR Special built-ins cannot be bound to a
5207 pathname or deleted. The \fB-d\fR option deletes each of the specified
5208 built-ins. On systems that support dynamic loading, the \fB-f\fR option names a
5209 shared library containing the code for built-ins. The shared library prefix
5210 and/or suffix, which depend on the system, can be omitted. Once a library is
5211 loaded, its symbols become available for subsequent invocations of
5212 \fBbuiltin\fR. Multiple libraries can be specified with separate invocations of
5213 the \fBbuiltin\fR command. Libraries are searched in the reverse order in which
5214 they are specified. When a library is loaded, it looks for a function in the
5215 library whose name is \fBlib_init()\fR and invokes this function with an
5216 argument of \fB0\fR.
5217 .RE
5218
5219 .sp
5220 .ne 2
5221 .na
5222 \fBcd\fR \fB[\fR\fB-LP\fR\fB] [\fR\fIarg\fR\fB]\fR
5223 .ad
5224 .br
5225 .na
5226 \fBcd\fR \fB[\fR\fB-LP\fR\fB]\fR \fIold\fR \fInew\fR
5227 .ad
5228 .sp .6
5229 .RS 4n
5230 This command has two forms.
5231 .sp
5232 In the first form it changes the current directory to \fIarg\fR. If \fIarg\fR
5233 is a \fB-\fR, the directory is changed to the previous directory. The shell
5234 variable \fBHOME\fR is the default \fIarg\fR. The variable \fBPWD\fR is set to
5235 the current directory. The shell variable \fBCDPATH\fR defines the search path
5236 for the directory containing \fIarg\fR. Alternative directory names are
5237 separated by a colon (\fB:\fR). The default path is \fBNULL\fR (specifying the
5238 current directory). The current directory is specified by a null path name,
5239 which can appear immediately after the equal sign or between the colon
5240 delimiters anywhere else in the path list. If \fIarg\fR begins with a \fB/\fR,
5241 the search path is not used. Otherwise, each directory in the path is searched
5242 for \fIarg\fR.
5243 .sp
5244 The second form of \fBcd\fR substitutes the string \fInew\fR for the string
5245 \fIold\fR in the current directory name, \fBPWD\fR, and tries to change to this
5246 new directory. By default, symbolic link names are treated literally when
5247 finding the directory name. This is equivalent to the \fB-L\fR option. The
5248 \fB-P\fR option causes symbolic links to be resolved when determining the
5249 directory. The last instance of \fB-L\fR or \fB-P\fR on the command line
5250 determines which method is used. The \fBcd\fR command cannot be executed by
5251 \fBrksh93\fR.
5252 .RE
5253
5254 .sp
5255 .ne 2
5256 .na
5257 \fBcommand\fR \fB[\fR\fB-pvVx\fR\fB]\fR \fIname\fR
5258 \fB[\fR\fIarg ...\fR\fB]\fR
5259 .ad
5260 .sp .6
5261 .RS 4n
5262 Without the \fB-v\fR or \fB-V\fR options, executes \fIname\fR with the
5263 arguments specified by \fIarg\fR.
5264 .sp
5265 The \fB-p\fR option causes a default path to be searched rather than the one
5266 defined by the value of \fBPATH\fR. Functions are not searched when finding
5267 \fIname\fR. In addition, if \fIname\fR refers to a special built-in, none of
5268 the special properties associated with the leading daggers are honored. For
5269 example, the predefined alias \fBredirect='command exec'\fR prevents a script
5270 from terminating when an invalid redirection is specified.
5271 .sp
5272 With the \fB-x\fR option, if command execution would result in a failure
5273 because there are too many arguments, \fBerrno E2BIG\fR, the shell invokes
5274 command \fIname\fR multiple times with a subset of the arguments on each
5275 invocation. Arguments that occur prior to the first word that expands to
5276 multiple arguments and after the last word that expands to multiple arguments
5277 are passed on each invocation. The exit status is the maximum invocation exit
5278 status.
5279 .sp
5280 With the \fB-v\fR option, \fBcommand\fR is equivalent to the built-in
5281 \fBwhence\fR command described in this section. The \fB-V\fR option causes
5282 \fBcommand\fR to act like \fBwhence -v\fR.
5283 .RE
5284
5285 .sp
5286 .ne 2
5287 .na
5288 \fB+continue\fR \fB[\fR\fIn\fR\fB]\fR
5289 .ad
5290 .sp .6
5291 .RS 4n
5292 Resumes the next iteration of the enclosing \fBfor\fR, \fBwhile\fR,
5293 \fBuntil\fR, or \fBselect\fR loop. If \fIn\fR is specified, then resume at the
5294 \fIn\fRth enclosing loop.
5295 .RE
5296
5297 .sp
5298 .ne 2
5299 .na
5300 \fBdisown\fR \fB[\fR\fIjob...\fR\fB]\fR
5301 .ad
5302 .sp .6
5303 .RS 4n
5304 Causes the shell not to send a \fBHUP\fR signal to each specified \fIjob\fR, or
5305 all active jobs if \fIjob\fR is omitted, when a login shell terminates.
5306 .RE
5307
5308 .sp
5309 .ne 2
5310 .na
5311 \fBecho\fR \fB[\fR\fIarg ...\fR\fB]\fR
5312 .ad
5313 .sp .6
5314 .RS 4n
5315 When the first \fIarg\fR does not begin with a \fB-\fR, and none of the
5316 arguments contain a backslash (\fB\e\fR), prints each of its arguments
5317 separated by a SPACE and terminated by a NEWLINE. Otherwise, the behavior of
5318 \fBecho\fR is system dependent and \fBprint\fR or \fBprintf\fR described in
5319 this section should be used. See \fBecho\fR(1) for usage and description.
5320 .RE
5321
5322 .sp
5323 .ne 2
5324 .na
5325 \fB++enum [ -i ]\fR \fItype\fR\fB[\fR=(\fIvalue\fR ...) \fB]\fR
5326 .ad
5327 .sp .6
5328 .RS 4n
5329 Creates a declaration command named type that is an integer type that allows
5330 one of the specified values as enumeration names. If \fI=(value ...)\fR is
5331 omitted, then type must be an indexed array variable with at least two elements
5332 and the values are taken from this array variable. If \fB-i\fR is specified
5333 the values are case insensitive.
5334 .RE
5335
5336 .sp
5337 .ne 2
5338 .na
5339 \fB+eval\fR \fB[\fR\fIarg ...\fR\fB]\fR
5340 .ad
5341 .sp .6
5342 .RS 4n
5343 The arguments are read as input to the shell and the resulting commands are
5344 executed.
5345 .RE
5346
5347 .sp
5348 .ne 2
5349 .na
5350 \fB+exec\fR [\fB-c\fR] [\fB-a\fR \fIname ...\fR]
5351 \fB[\fR\fIarg ...\fR\fB]\fR
5352 .ad
5353 .sp .6
5354 .RS 4n
5355 If \fIarg\fR is specified, the command specified by the arguments is executed
5356 in place of this shell without creating a new process. The \fB-c\fR option
5357 causes the environment to be cleared before applying variable assignments
5358 associated with the exec invocation. The \fB-a\fR option causes \fIname\fR
5359 rather than the first \fIarg\fR, to become \fBargv[0]\fR for the new process.
5360 Input and output arguments can appear and affect the current process. If
5361 \fIarg\fR is not specified, the effect of this command is to modify file
5362 descriptors as prescribed by the input/output redirection list. In this case,
5363 any file descriptor numbers greater than \fB2\fR that are opened with this
5364 mechanism are closed when invoking another program.
5365 .RE
5366
5367 .sp
5368 .ne 2
5369 .na
5370 \fB+exit\fR \fB[\fR\fIn\fR\fB]\fR
5371 .ad
5372 .sp .6
5373 .RS 4n
5374 Causes the shell to exit with the exit status specified by \fIn\fR. The value
5375 is the least significant 8 bits of the specified status. If \fIn\fR is omitted,
5376 then the exit status is that of the last command executed. An end-of-file also
5377 causes the shell to exit except for a shell which has the \fBignoreeof\fR
5378 option turned on. See \fBset\fR.
5379 .RE
5380
5381 .sp
5382 .ne 2
5383 .na
5384 \fB++export\fR \fB[\fR\fB-p\fR\fB]\fR
5385 \fB[\fR\fIname\fR\fB[=\fR\fIvalue\fR\fB]] ...\fR
5386 .ad
5387 .sp .6
5388 .RS 4n
5389 If \fIname\fR is not specified, the names and values of each variable with the
5390 export attribute are printed with the values quoted in a manner that allows
5391 them to be re-entered. The \fBexport\fR command is the same as \fBtypeset -x\fR
5392 except that if you use \fBexport\fR within a function, no local variable is
5393 created. The \fB-p\fR option causes the word export to be inserted before each
5394 one. Otherwise, the specified \fIname\fRs are marked for automatic export to
5395 the environment of subsequently-executed commands.
5396 .RE
5397
5398 .sp
5399 .ne 2
5400 .na
5401 \fBfalse\fR
5402 .ad
5403 .sp .6
5404 .RS 4n
5405 Does nothing, and exits \fB1\fR. Used with \fBuntil\fR for infinite loops.
5406 .RE
5407
5408 .sp
5409 .ne 2
5410 .na
5411 \fBfg\fR \fB[\fR\fIjob ...\fR\fB]\fR
5412 .ad
5413 .sp .6
5414 .RS 4n
5415 This command is only on systems that support job control. Each \fIjob\fR
5416 specified is brought to the foreground and waited for in the specified order.
5417 Otherwise, the current job is brought into the foreground. See \fBJobs\fR for a
5418 description of the format of \fIjob\fR.
5419 .RE
5420
5421 .sp
5422 .ne 2
5423 .na
5424 \fBgetconf\fR \fB[\fR\fIname\fR \fB[\fR\fIpathname\fR\fB]]\fR
5425 .ad
5426 .sp .6
5427 .RS 4n
5428 Prints the current value of the configuration parameter specified by
5429 \fIname\fR. The configuration parameters are defined by the IEEE POSIX 1003.1
5430 and IEEE POSIX 1003.2 standards. See \fBpathconf\fR(2) and \fBsysconf\fR(3C).
5431 .sp
5432 The \fIpathname\fR argument is required for parameters whose value depends on
5433 the location in the file system. If no arguments are specified, \fBgetconf\fR
5434 prints the names and values of the current configuration parameters. The
5435 pathname \fB/\fR is used for each of the parameters that requires
5436 \fIpathname\fR.
5437 .RE
5438
5439 .sp
5440 .ne 2
5441 .na
5442 \fBgetopts\fR \fB[\fR \fB-a\fR \fIname\fR\fB]\fR \fIoptstring\fR \fIvname\fR
5443 \fB[\fR\fIarg ...\fR\fB]\fR
5444 .ad
5445 .sp .6
5446 .RS 4n
5447 Checks \fIarg\fR for legal options. If \fIarg\fR is omitted, the positional
5448 parameters are used. An option argument begins with a \fB+\fR or a \fB-\fR. An
5449 option that does not begin with \fB+\fR or \fB-\fR or the argument \fB--\fR
5450 ends the options. Options beginning with \fB+\fR are only recognized when
5451 \fIoptstring\fR begins with a \fB+\fR. \fIoptstring\fR contains the letters
5452 that \fBgetopts\fR recognizes. If a letter is followed by a \fB:\fR, that
5453 option is expected to have an argument. The options can be separated from the
5454 argument by blanks. The option \fB-?\fRcauses \fBgetopts\fR to generate a usage
5455 message on standard error. The \fB-a\fR option can be used to specify the name
5456 to use for the usage message, which defaults to $0. \fBgetopts\fR places the
5457 next option letter it finds inside variable \fIvname\fR each time it is
5458 invoked. The option letter is prepended with a \fB+\fR when \fIarg\fR begins
5459 with a \fB+\fR. The index of the next \fIarg\fR is stored in \fBOPTIND\fR. The
5460 option argument, if any, gets stored in \fBOPTARG\fR. A leading : in
5461 \fIoptstring\fR causes \fBgetopts\fR to store the letter of an invalid option
5462 in \fBOPTARG\fR, and to set \fIvname\fR to \fB?\fR for an unknown option and
5463 to: when a required option argument is missing. Otherwise, \fBgetopts\fR prints
5464 an error message. The exit status is \fBnon-zero\fR when there are no more
5465 options. There is no way to specify any of the options \fB:\fR, \fB+\fR,
5466 \fB-\fR, \fB?\fR, \fB[\fR, and \fB]\fR. The option \fB#\fR can only be
5467 specified as the first option.
5468 .RE
5469
5470 .sp
5471 .ne 2
5472 .na
5473 \fBhist\fR \fB[\fR \fB-e\fR \fIename\fR\fB]\fR\fB[\fR\fB-nlr\fR\fB]\fR
5474 \fB[\fR \fIfirst\fR\fB[\fR\fIlast\fR \fB] ]\fR
5475 .ad
5476 .br
5477 .na
5478 \fB\fR
5479 .ad
5480 .br
5481 .na
5482 \fBhist\fR \fB-s\fR \fB[\fR \fIold\fR\fB=\fR\fInew\fR \fB] [\fR
5483 \fIcommand\fR\fB]\fR
5484 .ad
5485 .sp .6
5486 .RS 4n
5487 In the first form, a range of commands from \fIfirst\fR to \fIlast\fR is
5488 selected from the last \fBHISTSIZE\fR commands that were typed at the terminal.
5489 The arguments \fIfirst\fR and \fIlast\fR can be specified as a number or as a
5490 string. A string is used to locate the most recent command starting with the
5491 specified string. A negative number is used as an offset to the current command
5492 number. If the -l option is selected, the commands are listed on standard
5493 output. Otherwise, the editor program \fIename\fR is invoked on a file
5494 containing these keyboard commands. If \fIename\fR is not supplied, then the
5495 value of the variable \fBHISTEDIT\fR is used. If \fBHISTEDIT\fR is not set,
5496 then \fBFCEDIT\fR (default \fB/bin/ed\fR) is used as the editor. When editing
5497 is complete, the edited command(s) is executed if the changes have been saved.
5498 If \fIlast\fR is not specified, then it is set to \fIfirst\fR. If \fIfirst\fR
5499 is not specified, the default is the previous command for editing and \fB-16\fR
5500 for listing. The option \fB-r\fR reverses the order of the commands and the
5501 option \fB-n\fR suppresses command numbers when listing. In the second form,
5502 \fIcommand\fR is interpreted as \fIfirst\fR described in this section and
5503 defaults to the last command executed. The resulting command is executed after
5504 the optional substitution \fIold\fR\fB=\fR\fInew\fR is performed.
5505 .RE
5506
5507 .sp
5508 .ne 2
5509 .na
5510 \fBjobs\fR \fB-lnp\fR \fB[\fR\fIjob ...\fR\fB]\fR
5511 .ad
5512 .sp .6
5513 .RS 4n
5514 Lists information about each specified job, or all active jobs if \fIjob\fR is
5515 omitted. The \fB-l\fR option lists process ids in addition to the normal
5516 information. The \fB-n\fR option only displays jobs that have stopped or exited
5517 since last notified. The \fB-p\fR option causes only the process group to be
5518 listed. See \fBJobs\fR for a description of the format of \fIjob\fR.
5519 .RE
5520
5521 .sp
5522 .ne 2
5523 .na
5524 \fBkill\fR \fB[\fR\fB-s\fR \fIsigname\fR\fB]\fR \fIjob ...\fR
5525 .ad
5526 .br
5527 .na
5528 \fBkill\fR \fB[\fR\fB-n\fR \fIsignum\fR\fB]\fR \fIjob ...\fR
5529 .ad
5530 .br
5531 .na
5532 \fBkill\fR \fB-Ll\fR \fB[\fR\fIsig ...\fR\fB]\fR
5533 .ad
5534 .sp .6
5535 .RS 4n
5536 Sends either the \fBTERM\fR (terminate) signal or the specified signal to the
5537 specified jobs or processes. Signals are either specified by number with the
5538 \fB-n\fR option or by name with the \fB-s\fR option (as specified in
5539 \fB<signal.h\fR>, stripped of the prefix `\fBSIG\fR with the exception that
5540 \fBSIGCLD\fR is named \fBCHLD\fR). For backward compatibility, the \fBn\fR and
5541 \fBs\fR can be omitted and the number or name placed immediately after the
5542 \fB-\fR. If the signal being sent is \fBTERM\fR (terminate) or \fBHUP\fR (hang
5543 up), then the job or process is sent a \fBCONT\fR (continue) signal if it is
5544 stopped. The argument \fIjob\fR can be the process id of a process that is not
5545 a member of one of the active jobs. See \fBJobs\fR for a description of the
5546 format of \fIjob\fR. In the third form, \fBkill -l\fR or \fBkill -L\fR, if
5547 \fIsig\fR is not specified, the signal names are listed. The \fB-l\fR option
5548 lists only the signal names whereas \fB-L\fR lists each signal name and
5549 corresponding number. Otherwise, for each \fIsig\fR that is a name, the
5550 corresponding signal number is listed. For each \fIsig\fR that is a number, the
5551 signal name corresponding to the least significant 8 bits of \fIsig\fR is
5552 listed.
5553 .RE
5554
5555 .sp
5556 .ne 2
5557 .na
5558 \fBlet\fR \fB[\fR\fIarg ...\fR\fB]\fR
5559 .ad
5560 .sp .6
5561 .RS 4n
5562 Each \fIarg\fR is a separate arithmetic expression to be evaluated.
5563 \fBlet\fR only recognizes octal constants starting with \fB0\fR when the
5564 \fBset\fR option \fBletoctal\fR is on. See the \fBArithmetic Evaluation\fR
5565 section of this manual page for a description of arithmetic expression
5566 evaluation. The exit status is \fB0\fR if the value of the last expression is
5567 \fBnon-zero\fR, and \fB1\fR otherwise.
5568 .RE
5569
5570 .sp
5571 .ne 2
5572 .na
5573 \fB+newgrp\fR \fB[\fR\fIarg ...\fR\fB]\fR
5574 .ad
5575 .sp .6
5576 .RS 4n
5577 Equivalent to \fBexec\fR \fB/bin/newgrp\fR \fIarg ...\fR
5578 .RE
5579
5580 .sp
5581 .ne 2
5582 .na
5583 \fBprint\fR [\fB-CRenprsv\fR] \fB[\fR \fB-u\fR \fIunit\fR\fB] [\fR \fB-f\fR
5584 \fIformat\fR \fB] [\fR \fIarg ...\fR\fB]\fR
5585 .ad
5586 .sp .6
5587 .RS 4n
5588 With no options or with option \fB-\fR or \fB--\fR, each \fIarg\fR is printed
5589 on standard output. The \fB-f\fR option causes the arguments to be printed as
5590 described by \fBprintf\fR. In this case, any \fBe\fR, \fBn\fR, \fBr\fR, or
5591 \fBR\fR options are ignored. Otherwise, unless the \fB-R\fR or \fB-r,\fR are
5592 specified, the following escape conventions are applied:
5593 .sp
5594 .ne 2
5595 .na
5596 \fB\ea\fR
5597 .ad
5598 .RS 8n
5599 Alert character (\fBASCII\fR 07)
5600 .RE
5601
5602 .sp
5603 .ne 2
5604 .na
5605 \fB\eb\fR
5606 .ad
5607 .RS 8n
5608 Backspace character (\fBASCII\fR 010)
5609 .RE
5610
5611 .sp
5612 .ne 2
5613 .na
5614 \fB\ec\fR
5615 .ad
5616 .RS 8n
5617 Causes print to end without processing more arguments and not adding a NEWLINE
5618 .RE
5619
5620 .sp
5621 .ne 2
5622 .na
5623 \fB\ef\fR
5624 .ad
5625 .RS 8n
5626 Form-feed character (\fBASCII\fR 014)
5627 .RE
5628
5629 .sp
5630 .ne 2
5631 .na
5632 \fB\en\fR
5633 .ad
5634 .RS 8n
5635 NEWLINE character (\fBASCII\fR 012)
5636 .RE
5637
5638 .sp
5639 .ne 2
5640 .na
5641 \fB\er\fR
5642 .ad
5643 .RS 8n
5644 RETURN character (\fBASCII\fR 015)
5645 .RE
5646
5647 .sp
5648 .ne 2
5649 .na
5650 \fB\et\fR
5651 .ad
5652 .RS 8n
5653 TAB character (\fBASCII\fR 011)
5654 .RE
5655
5656 .sp
5657 .ne 2
5658 .na
5659 \fB\ev\fR
5660 .ad
5661 .RS 8n
5662 Vertical TAB character (\fBASCII\fR 013)
5663 .RE
5664
5665 .sp
5666 .ne 2
5667 .na
5668 \fB\eE\fR
5669 .ad
5670 .RS 8n
5671 Escape character (\fBASCII\fR 033)
5672 .RE
5673
5674 .sp
5675 .ne 2
5676 .na
5677 \fB\e\e\fR
5678 .ad
5679 .RS 8n
5680 Backslash character \fB\e\fR
5681 .RE
5682
5683 .sp
5684 .ne 2
5685 .na
5686 \fB\e0\fR\fIx\fR
5687 .ad
5688 .RS 8n
5689 Character defined by the 1, 2, or 3-digit octal string specified by \fIx\fR
5690 .RE
5691
5692 The \fB-R\fR option prints all subsequent arguments and options other than
5693 \fB-n\fR. The \fB-e\fR causes the escape conventions to be applied This is the
5694 default behavior. It reverses the effect of an earlier \fB-r\fR. The \fB-p\fR
5695 option causes the arguments to be written onto the pipe of the process spawned
5696 with \fB|&\fR instead of standard output. The \fB-v\fR option treats each
5697 \fIarg\fR as a variable name and writes the value in the \fBprintf %B\fR
5698 format. The \fB-C\fR option treats each \fIarg\fR as a variable name and
5699 writes the values in the \fBprintf %#B\fR format.
5700 The \fB-s\fR option causes the arguments to be written onto the history file
5701 instead of standard output. The \fB-u\fR option can be used to specify a one
5702 digit file descriptor unit number \fIunit\fR on which the output is placed. The
5703 default is \fB1\fR. If the option \fB-n\fR is used, no NEWLINE is added to the
5704 output.
5705 .RE
5706
5707 .sp
5708 .ne 2
5709 .na
5710 \fBprintf\fR \fIformat\fR\fB [\fR\fIarg ...\fR\fB]\fR
5711 .ad
5712 .sp .6
5713 .RS 4n
5714 The arguments \fIarg\fR are printed on standard output in accordance with the
5715 \fBANSI-C\fR formatting rules associated with the format string \fIformat\fR.
5716 If the number of arguments exceeds the number of format specifications, the
5717 format string is reused to format remaining arguments. The following extensions
5718 can also be used:
5719
5720 .sp
5721 .ne 2
5722 .na
5723 \fB%b\fR
5724 .ad
5725 .sp .6
5726 .RS 4n
5727 A \fB%b\fR format can be used instead of \fB%s\fR to cause
5728 escape sequences in the corresponding \fIarg\fR to be expanded as described in
5729 \fBprint\fR.
5730 .RE
5731
5732 .sp
5733 .ne 2
5734 .na
5735 \fB%B\fR
5736 .ad
5737 .sp .6
5738 .RS 4n
5739 A \fB%B\fR option causes each of the arguments to be treated as
5740 variable names and the binary value of the variables is printed. This is most
5741 useful for variables with an attribute of b.
5742 .RE
5743
5744 .sp
5745 .ne 2
5746 .na
5747 \fB%H\fR
5748 .ad
5749 .sp .6
5750 .RS 4n
5751 A \fB%H\fR format can be used
5752 instead of \fB%s\fR to cause characters in \fIarg\fR that are special in
5753 \fBHTML\fR and \fBXML\fR to be output as their entity name. The alternate
5754 flag \fB#\fR formats the output for use as a URI.
5755 .RE
5756
5757 .sp
5758 .ne 2
5759 .na
5760 \fB%P\fR
5761 .ad
5762 .sp .6
5763 .RS 4n
5764 A \fB%P\fR format can be used instead of \fB%s\fR to cause \fIarg\fR to be
5765 interpreted as an extended regular expression and be printed as a shell
5766 pattern.
5767 .RE
5768
5769
5770 .sp
5771 .ne 2
5772 .na
5773 \fB%R\fR
5774 .ad
5775 .sp .6
5776 .RS 4n
5777 A \fB%R\fR
5778 format can be used instead of \fB%s\fR to cause \fIarg\fR to be interpreted as
5779 a shell pattern and to be printed as an extended regular expression.
5780 .RE
5781
5782 .sp
5783 .ne 2
5784 .na
5785 \fB%q\fR
5786 .ad
5787 .sp .6
5788 .RS 4n
5789 A \fB%q\fR format can be used instead of \fB%\fRs to cause the resulting string
5790 to be quoted in a manner than can be input again to the shell. When \fBq\fR is
5791 preceded by the alternative format specifier, \fB#\fR, the string is quoted in
5792 manner suitable as a field in a \fB.csv\fR format file.
5793 .RE
5794
5795 .sp
5796 .ne 2
5797 .na
5798 \fB%(\fIdate-format\fR\fB)\fR
5799 .ad
5800 .sp .6
5801 .RS 4n
5802 A \fB%(\fR\fIdate-format\fR\fB)T\fR format can be use to treat an argument as a
5803 date/time string and to format the date/time according to the \fIdate-format\fR
5804 as defined for the \fBdate\fR(1) command.
5805 .RE
5806
5807
5808 .sp
5809 .ne 2
5810 .na
5811 \fB%Z\fR
5812 .ad
5813 .sp .6
5814 .RS 4n
5815 A \fB%Z\fR format outputs a byte whose value is 0.
5816 .RE
5817
5818 .sp
5819 .ne 2
5820 .na
5821 \fB%d\fR
5822 .ad
5823 .sp .6
5824 .RS 4n
5825 The precision field of the %d format can be followed by a . and the output
5826 base. In this case, the \fB#\fR flag character causes \fBbase\fR\fI#\fR to be
5827 prepended.
5828 .RE
5829
5830 .sp
5831 .ne 2
5832 .na
5833 \fB#\fR
5834 .ad
5835 .sp .6
5836 .RS 4n
5837 The \fB#\fR flag, when used with the \fB%d\fR format without an output base,
5838 displays the output in powers of 1000 indicated by one of the following
5839 suffixes: \fBk M G T P E\fR, and when used with the \fB%i\fR format displays
5840 the output in powers of 1024 indicated by one of the following suffixes:
5841 \fBKi Mi Gi Ti Pi Ei\fR.
5842
5843 .RE
5844
5845 .sp
5846 .ne 2
5847 .na
5848 \fB=\fR
5849 .ad
5850 .sp .6
5851 .RS 4n
5852 The \fB=\fR flag centers the output within the specified field width.
5853 .RE
5854
5855 .sp
5856 .ne 2
5857 .na
5858 \fBL\fR
5859 .ad
5860 .sp .6
5861 .RS 4n
5862 The \fBL\fR flag, when used with the \fB%c\fR or \fB%s\fR
5863 formats, treats precision as character width instead of byte count.
5864 .RE
5865
5866 .sp
5867 .ne 2
5868 .na
5869 \fB,\fR
5870 .ad
5871 .sp .6
5872 .RS 4n
5873 The \fB,\fR flag, when used with the \fB%d\fR or \fB%f\fR
5874 formats, separates groups of digits with the grouping delimiter
5875 (, in groups of 3 in the C locale).
5876 .RE
5877
5878
5879 .RE
5880
5881 .sp
5882 .ne 2
5883 .na
5884 \fBpwd\fR [\fB-LP\fR]\fR
5885 .ad
5886 .sp .6
5887 .RS 4n
5888 Outputs the value of the current working directory. The \fB-L\fR option is the
5889 default. It prints the logical name of the current directory. If the \fB-P\fR
5890 option is specified, all symbolic links are resolved from the name. The last
5891 instance of \fB-L\fR or \fB-P\fR on the command line determines which method is
5892 used.
5893 .RE
5894
5895 .sp
5896 .ne 2
5897 .na
5898 \fBread\fR \fB[\fR\fB-ACSprsv\fR\fB] [\fR\fB-d\fR \fIdelim\fR\fB] [\fR \fB-n\fR
5899 \fIn\fR\fB] [[\fR \fB-N\fR \fIn\fR\fB] [[\fR\fB-t\fR \fItimeout\fR\fB]
5900 [\fR\fB-u\fR \fIunit\fR\fB] [\fR\fIvname\fR\fB?\fR\fIprompt\fR\fB] [\fR
5901 \fIvname ...\fR \fB]\fR
5902 .ad
5903 .sp .6
5904 .RS 4n
5905 The shell input mechanism. One line is read and is broken up into fields using
5906 the characters in IFS as separators. The escape character, \fB\e\fR, is used to
5907 remove any special meaning for the next character and for line continuation.
5908 The \fB-d\fR option causes the read to continue to the first character of
5909 \fIdelim\fR rather than \fBNEWLINE\fR. The \fB-n\fR option causes at most
5910 \fIn\fR bytes to read rather a full line but returns when reading from a slow
5911 device as soon as any characters have been read. The \fB-N\fR option causes
5912 exactly \fIn\fR to be read unless an end-of-file has been encountered or the
5913 read times out because of the \fB-t\fR option. In raw mode, \fB-r\fR, the
5914 \fB\e\fR character is not treated specially. The first field is assigned to the
5915 first \fIvname\fR, the second field to the second \fIvname\fR, etc., with
5916 leftover fields assigned to the last \fIvname\fR. When \fIvname\fR has the
5917 binary attribute and \fB-n\fR or \fB-N\fR is specified, the bytes that are read
5918 are stored directly into the variable. If the -v is specified, then the value
5919 of the first \fIvname\fR is used as a default value when reading from a
5920 terminal device. The \fB-A\fR option causes the variable \fIvname\fR to be
5921 unset and each field that is read to be stored in successive elements of the
5922 indexed array \fIvname\fR. The \fB-C\fR option causes the variable vname to be
5923 read as a compound variable. Blanks will be ignored when finding the beginning
5924 open parenthesis. The \fB-S\fR option causes the line to be treated like a
5925 record in a .csv format file so that double quotes can be used to allow the
5926 delimiter character and the new-line character to appear within a field.
5927 The \fB-p\fR option causes the input line to be
5928 taken from the input pipe of a process spawned by the shell using \fB|&\fR. If
5929 the \fB-s\fR option is present, the input is saved as a command in the history
5930 file. The option \fB-u\fR can be used to specify a one digit file descriptor
5931 unit \fIunit\fR to read from. The file descriptor can be opened with the
5932 \fBexec\fR special built-in command. The default value of unit \fIn\fR is
5933 \fB0\fR. The option \fB-t\fR is used to specify a time out in seconds when
5934 reading from a terminal or pipe. If \fIvname\fR is omitted, then REPLY is used
5935 as the default \fIvname\fR. An end-of-file with the \fB-p\fR option causes
5936 cleanup for this process so that another can be spawned. If the first argument
5937 contains a \fB?\fR, the remainder of this word is used as a prompt on standard
5938 error when the shell is interactive. The exit status is \fB0\fR unless an
5939 end-of-file is encountered or read has timed out.
5940 .RE
5941
5942 .sp
5943 .ne 2
5944 .na
5945 \fB++readonly\fR \fB[\fR\fB-p\fR\fB] [\fR
5946 \fIvname\fR\fB[=\fR\fIvalue\fR\fB]] ...\fR
5947 .ad
5948 .sp .6
5949 .RS 4n
5950 If \fIvname\fR is not specified, the names and values of each variable with the
5951 read-only attribute is printed with the values quoted in a manner that allows
5952 them to be input again. The \fB-p\fR option causes the word \fBreadonly\fR to
5953 be inserted before each one. Otherwise, the specified \fIvname\fRs are marked
5954 \fBreadonly\fR and these names cannot be changed by subsequent assignment.
5955 .RE
5956
5957 .sp
5958 .ne 2
5959 .na
5960 \fB+return\fR \fB[\fR\fIn\fR\fB]\fR
5961 .ad
5962 .sp .6
5963 .RS 4n
5964 Causes a shell function or script to return to the invoking script with the
5965 exit status specified by \fIn\fR. The value is the least significant 8 bits of
5966 the specified status. If \fBn\fR is omitted, then the return status is that of
5967 the last command executed. If return is invoked while not in a function or a
5968 script, then it behaves the same as exit.
5969 .RE
5970
5971 .sp
5972 .ne 2
5973 .na
5974 \fB+set [ \(+-BCGabefhkmnoprstuvx] [\(+-o [\fR \fIoption\fR \fB] ] ... [
5975 \(+-A\fR \fIvname\fR\fB]\fR \fB[\fR\fIarg...\fR\fB]\fR
5976 .ad
5977 .sp .6
5978 .RS 4n
5979 The \fBset\fR command supports the following options:
5980 .sp
5981 .ne 2
5982 .na
5983 \fB-a\fR
5984 .ad
5985 .sp .6
5986 .RS 4n
5987 All subsequent variables that are defined are automatically exported.
5988 .RE
5989
5990 .sp
5991 .ne 2
5992 .na
5993 \fB-A\fR
5994 .ad
5995 .sp .6
5996 .RS 4n
5997 Array assignment. Unset the variable \fIvname\fR and assign values sequentially
5998 from the \fIarg\fR list. If \fB+A\fR is used, the variable \fIvname\fR is not
5999 unset first.
6000 .RE
6001
6002 .sp
6003 .ne 2
6004 .na
6005 \fB-b\fR
6006 .ad
6007 .sp .6
6008 .RS 4n
6009 Prints job completion messages as soon as a background job changes state rather
6010 than waiting for the next prompt.
6011 .RE
6012
6013 .sp
6014 .ne 2
6015 .na
6016 \fB-B\fR
6017 .ad
6018 .sp .6
6019 .RS 4n
6020 Enable brace pattern field generation. This is the default behavior.
6021 .RE
6022
6023 .sp
6024 .ne 2
6025 .na
6026 \fB-C\fR
6027 .ad
6028 .sp .6
6029 .RS 4n
6030 Prevents redirection (\fB>\fR) from truncating existing files. Files that are
6031 created are opened with the \fBO_EXCL\fR mode. Requires \fB>|\fR to truncate a
6032 file when turned on.
6033 .RE
6034
6035 .sp
6036 .ne 2
6037 .na
6038 \fB-e\fR
6039 .ad
6040 .sp .6
6041 .RS 4n
6042 Unless contained in a \fB||\fR or \fB&&\fR command, or the command following an
6043 \fBif\fR, \fBwhile\fR or \fBuntil\fR command or in the pipeline following
6044 \fB!\fR, if a command has a non-zero exit status, execute the \fBERR\fR trap,
6045 if set, and exit. This mode is disabled while reading profiles.
6046 .RE
6047
6048 .sp
6049 .ne 2
6050 .na
6051 \fB-f\fR
6052 .ad
6053 .sp .6
6054 .RS 4n
6055 Disables file name generation.
6056 .RE
6057
6058 .sp
6059 .ne 2
6060 .na
6061 \fB-G\fR
6062 .ad
6063 .sp .6
6064 .RS 4n
6065 Causes the pattern \fB**\fR by itself to match files and zero or more
6066 directories and subdirectories when used for file name generation. If followed
6067 by a \fB/\fR only directories and subdirectories are matched.
6068 .RE
6069
6070 .sp
6071 .ne 2
6072 .na
6073 \fB-h\fR
6074 .ad
6075 .sp .6
6076 .RS 4n
6077 Each command becomes a tracked alias when first encountered.
6078 .RE
6079
6080 .sp
6081 .ne 2
6082 .na
6083 \fB-k\fR
6084 .ad
6085 .sp .6
6086 .RS 4n
6087 Obsolete. All variable assignment arguments are placed in the environment for a
6088 command, not just those that precede the command name.
6089 .RE
6090
6091 .sp
6092 .ne 2
6093 .na
6094 \fB-m\fR
6095 .ad
6096 .sp .6
6097 .RS 4n
6098 Background jobs run in a separate process group and a line prints upon
6099 completion. The exit status of background jobs is reported in a completion
6100 message. On systems with job control, this option is turned on automatically
6101 for interactive shells.
6102 .RE
6103
6104 .sp
6105 .ne 2
6106 .na
6107 \fB-n\fR
6108 .ad
6109 .sp .6
6110 .RS 4n
6111 Read commands and check them for syntax errors, but do not execute them.
6112 Ignored for interactive shells.
6113 .RE
6114
6115 .sp
6116 .ne 2
6117 .na
6118 \fB-o\fR
6119 .ad
6120 .sp .6
6121 .RS 4n
6122 If no option name is supplied, the list of options and their current settings
6123 are written to standard output. When invoked with a \fB+\fR, the options are
6124 written in a format that can be input again to the shell to restore the
6125 settings. This option can be repeated to enable or disable multiple options.
6126 .sp
6127 The following argument can be one of the following option names:
6128 .sp
6129 .ne 2
6130 .na
6131 \fBallexport\fR
6132 .ad
6133 .sp .6
6134 .RS 4n
6135 Same as \fB-a\fR.
6136 .RE
6137
6138 .sp
6139 .ne 2
6140 .na
6141 \fBbgnice\fR
6142 .ad
6143 .sp .6
6144 .RS 4n
6145 All background jobs are run at a lower priority. This is the default mode.
6146 .RE
6147
6148 .sp
6149 .ne 2
6150 .na
6151 \fBbraceexpand\fR
6152 .ad
6153 .sp .6
6154 .RS 4n
6155 Same as \fB-\fRB.
6156 .RE
6157
6158 .sp
6159 .ne 2
6160 .na
6161 \fBemacs\fR
6162 .ad
6163 .sp .6
6164 .RS 4n
6165 Puts you in an \fBemacs\fR style inline editor for command entry.
6166 .RE
6167
6168 .sp
6169 .ne 2
6170 .na
6171 \fBerrexit\fR
6172 .ad
6173 .sp .6
6174 .RS 4n
6175 Same as \fB-e\fR.
6176 .RE
6177
6178 .sp
6179 .ne 2
6180 .na
6181 \fBglobstar\fR
6182 .ad
6183 .sp .6
6184 .RS 4n
6185 Same as \fB-G\fR.
6186 .RE
6187
6188 .sp
6189 .ne 2
6190 .na
6191 \fBgmacs\fR
6192 .ad
6193 .sp .6
6194 .RS 4n
6195 Puts you in a \fBgmacs\fR style inline editor for command entry.
6196 .RE
6197
6198 .sp
6199 .ne 2
6200 .na
6201 \fBignoreeof\fR
6202 .ad
6203 .sp .6
6204 .RS 4n
6205 The shell does not exit on end-of-file. The command \fBexit\fR must be used.
6206 .RE
6207
6208 .sp
6209 .ne 2
6210 .na
6211 \fBkeyword\fR
6212 .ad
6213 .sp .6
6214 .RS 4n
6215 Same as \fB-k\fR.
6216 .RE
6217
6218 .sp
6219 .ne 2
6220 .na
6221 \fBletoctal\fR
6222 .ad
6223 .sp .6
6224 .RS 4n
6225 The \fBlet\fR command allows octal constants starting with \fB0\fR.
6226 .RE
6227
6228 .sp
6229 .ne 2
6230 .na
6231 \fBmarkdirs\fR
6232 .ad
6233 .sp .6
6234 .RS 4n
6235 All directory names resulting from file name generation have a trailing /
6236 appended.
6237 .RE
6238
6239 .sp
6240 .ne 2
6241 .na
6242 \fBmonitor\fR
6243 .ad
6244 .sp .6
6245 .RS 4n
6246 Same as \fB-m\fR.
6247 .RE
6248
6249 .sp
6250 .ne 2
6251 .na
6252 \fBmultiline\fR
6253 .ad
6254 .sp .6
6255 .RS 4n
6256 The built-in editors use multiple lines on the screen for lines that are longer
6257 than the width of the screen. This might not work for all terminals.
6258 .RE
6259
6260 .sp
6261 .ne 2
6262 .na
6263 \fBnoclobber\fR
6264 .ad
6265 .sp .6
6266 .RS 4n
6267 Same as \fB-C\fR.
6268 .RE
6269
6270 .sp
6271 .ne 2
6272 .na
6273 \fBnoexec\fR
6274 .ad
6275 .sp .6
6276 .RS 4n
6277 Same as \fB-n\fR.
6278 .RE
6279
6280 .sp
6281 .ne 2
6282 .na
6283 \fBnoglob\fR
6284 .ad
6285 .sp .6
6286 .RS 4n
6287 Same as \fB-f\fR.
6288 .RE
6289
6290 .sp
6291 .ne 2
6292 .na
6293 \fBnolog\fR
6294 .ad
6295 .sp .6
6296 .RS 4n
6297 Do not save function definitions in the history file.
6298 .RE
6299
6300 .sp
6301 .ne 2
6302 .na
6303 \fBnotify\fR
6304 .ad
6305 .sp .6
6306 .RS 4n
6307 Same as \fB-b\fR.
6308 .RE
6309
6310 .sp
6311 .ne 2
6312 .na
6313 \fBnounset\fR
6314 .ad
6315 .sp .6
6316 .RS 4n
6317 Same as \fB-u\fR.
6318 .RE
6319
6320 .sp
6321 .ne 2
6322 .na
6323 \fBpipefail\fR
6324 .ad
6325 .sp .6
6326 .RS 4n
6327 A pipeline does not complete until all components of the pipeline have
6328 completed, and the return value is the value of the last \fBnon-zero\fR command
6329 to fail or zero if no command has failed.
6330 .RE
6331
6332 .sp
6333 .ne 2
6334 .na
6335 \fBprivileged\fR
6336 .ad
6337 .sp .6
6338 .RS 4n
6339 Same as \fB-p\fR.
6340 .RE
6341
6342 .sp
6343 .ne 2
6344 .na
6345 \fBshowme\fR
6346 .ad
6347 .sp .6
6348 .RS 4n
6349 When enabled, simple commands or pipelines preceded by a a semicolon (\fB;\fR)
6350 is displayed as if the \fBxtrace\fR option were enabled but is not executed.
6351 Otherwise, the leading \fB;\fR is ignored.
6352 .RE
6353
6354 .sp
6355 .ne 2
6356 .na
6357 \fBtrackall\fR
6358 .ad
6359 .sp .6
6360 .RS 4n
6361 Same as \fB-h\fR.
6362 .RE
6363
6364 .sp
6365 .ne 2
6366 .na
6367 \fBverbose\fR
6368 .ad
6369 .sp .6
6370 .RS 4n
6371 Same as \fB-v\fR.
6372 .RE
6373
6374 .sp
6375 .ne 2
6376 .na
6377 \fBvi\fR
6378 .ad
6379 .sp .6
6380 .RS 4n
6381 Puts you in insert mode of a \fBvi\fR style inline editor until you hit the
6382 escape character 033. This puts you in control mode. A return sends the line.
6383 .RE
6384
6385 .sp
6386 .ne 2
6387 .na
6388 \fBviraw\fR
6389 .ad
6390 .sp .6
6391 .RS 4n
6392 Each character is processed as it is typed in \fBvi\fR mode.
6393 .RE
6394
6395 .sp
6396 .ne 2
6397 .na
6398 \fBxtrace\fR
6399 .ad
6400 .sp .6
6401 .RS 4n
6402 Same as \fB-x\fR.
6403 .sp
6404 If no option name is supplied, the current options settings are printed.
6405 .RE
6406
6407 .RE
6408
6409 .sp
6410 .ne 2
6411 .na
6412 \fB-p\fR
6413 .ad
6414 .sp .6
6415 .RS 4n
6416 Disables processing of the \fB$HOME/.profile\fR file and uses the file
6417 \fB/etc/suid_profile\fR instead of the \fBENV\fR file. This mode is on whenever
6418 the effective \fBuid\fR (\fBgid\fR) is not equal to the real \fBuid\fR
6419 (\fBgid\fR). Turning this off causes the effective \fBuid\fR and \fBgid\fR to
6420 be set to the real \fBuid\fR and \fBgid\fR.
6421 .RE
6422
6423 .sp
6424 .ne 2
6425 .na
6426 \fB-r\fR
6427 .ad
6428 .sp .6
6429 .RS 4n
6430 Enables the restricted shell. This option cannot be unset once set.
6431 .RE
6432
6433 .sp
6434 .ne 2
6435 .na
6436 \fB-s\fR
6437 .ad
6438 .sp .6
6439 .RS 4n
6440 Sort the positional parameters lexicographically.
6441 .RE
6442
6443 .sp
6444 .ne 2
6445 .na
6446 \fB-t\fR
6447 .ad
6448 .sp .6
6449 .RS 4n
6450 Obsolete. Exit after reading and executing one command.
6451 .RE
6452
6453 .sp
6454 .ne 2
6455 .na
6456 \fB-u\fR
6457 .ad
6458 .sp .6
6459 .RS 4n
6460 Treat \fBunset\fR parameters as an error when substituting.
6461 .RE
6462
6463 .sp
6464 .ne 2
6465 .na
6466 \fB-v\fR
6467 .ad
6468 .sp .6
6469 .RS 4n
6470 Print shell input lines as they are read.
6471 .RE
6472
6473 .sp
6474 .ne 2
6475 .na
6476 \fB-x\fR
6477 .ad
6478 .sp .6
6479 .RS 4n
6480 Print commands and their arguments as they are executed.
6481 .RE
6482
6483 .sp
6484 .ne 2
6485 .na
6486 \fB--\fR
6487 .ad
6488 .sp .6
6489 .RS 4n
6490 Do not change any of the options. This is useful in setting \fB$1\fR to a value
6491 beginning with \fB-\fR. If no arguments follow this option then the positional
6492 parameters are unset.
6493 .RE
6494
6495 As an obsolete feature, if the first \fIarg\fR is - then the \fB-x\fR and
6496 \fB-v\fR options are turned off and the next \fIarg\fR is treated as the first
6497 argument. Using \fB+\fR rather than \fB-\fR causes these options to be turned
6498 off. These options can also be used upon invocation of the shell. The current
6499 set of options can be found in \fB$-\fR. Unless \fB-A\fR is specified, the
6500 remaining arguments are positional parameters and are assigned, in order, to
6501 \fB$1 $2 \&....\fR If no arguments are specified, then the names and values of
6502 all variables are printed on the standard output.
6503 .RE
6504
6505 .sp
6506 .ne 2
6507 .na
6508 \fB+shift\fR \fB[\fR\fIn\fR\fB]\fR
6509 .ad
6510 .sp .6
6511 .RS 4n
6512 The positional parameters from \fB$\fR\fIn\fR\fB+1 ...\fR are renamed
6513 \fB$1 ...\fR, the default \fIn\fR is \fB1\fR. The parameter \fIn\fR can be any
6514 arithmetic expression that evaluates to a non-negative number less than or
6515 equal to \fB$#\fR.
6516 .RE
6517
6518 .sp
6519 .ne 2
6520 .na
6521 \fBsleep\fR \fIseconds\fR
6522 .ad
6523 .sp .6
6524 .RS 4n
6525 Suspends execution for the number of decimal seconds or fractions of a second
6526 specified by \fIseconds\fR.
6527 .RE
6528
6529 .sp
6530 .ne 2
6531 .na
6532 \fB+trap\fR \fB-p\fR \fB[\fR\fIaction\fR\fB]\fR
6533 \fB[\fR\fIsig\fR\fB] ...\fR
6534 .ad
6535 .sp .6
6536 .RS 4n
6537 The \fB-p\fR option causes the trap action associated with each trap as
6538 specified by the arguments to be printed with appropriate quoting. Otherwise,
6539 \fIaction\fR is processed as if it were an argument to \fBeval\fR when the
6540 shell receives signal(s) \fIsig\fR. Each \fIsig\fR can be specified as a number
6541 or as the name of the signal. Trap commands are executed in order of signal
6542 number. Any attempt to set a trap on a signal that was ignored on entry to the
6543 current shell is ineffective. If \fIaction\fR is omitted and the first
6544 \fIsig\fR is a number, or if \fIaction\fR is \fB-\fR, then the trap(s) for each
6545 \fIsig\fR are reset to their original values. If \fIaction\fR is the null
6546 string then this signal is ignored by the shell and by the commands it invokes.
6547 If \fIsig\fR is \fBERR\fR then \fIaction\fR is executed whenever a command has
6548 a \fBnon-zero\fR exit status. If \fIsig\fR is \fBDEBUG\fR then \fIaction\fR is
6549 executed before each command. The variable \fB\&.sh.command\fR contains the
6550 contents of the current command line when \fIaction\fR is running. If \fIsig\fR
6551 is \fB0\fR or \fBEXIT\fR and the trap statement is executed inside the body of
6552 a function defined with the \fBfunction\fR \fIname\fR syntax, then the command
6553 \fIaction\fR is executed after the function completes. If \fIsig\fR is \fB0\fR
6554 or \fBEXIT\fR for a trap set outside any function then the command \fIaction\fR
6555 is executed on exit from the shell. If \fIsig\fR is \fBKEYBD\fR, then
6556 \fIaction\fR is executed whenever a key is read while in \fBemacs\fR,
6557 \fBgmacs\fR, or \fBvi\fR mode. The \fBtrap\fR command with no arguments prints
6558 a list of commands associated with each signal number.
6559 .RE
6560
6561 .sp
6562 .ne 2
6563 .na
6564 \fBtrue\fR
6565 .ad
6566 .sp .6
6567 .RS 4n
6568 Does nothing, and exits \fB0\fR. Used with while for infinite loops.
6569 .RE
6570
6571 .sp
6572 .ne 2
6573 .na
6574 \fB++typeset [\(+-ACHSfblmnprtux ] [ \(+-EFLRXZi[\fR\fIn\fR\fB] ]
6575 [ \(+-M \fB[ \fImapname\fR \fB] ]
6576 [ -T [ \fR\fItname\fR\fB=(\fR\fIassign_list\fR\fB) ] ]
6577 [ -h \fR\fIstr\fR\fB ]
6578 [ -a [\fR\fItype\fR\fB] ]
6579 [ \fR\fIvname\fR\fB[=\fR\fIvalue\fR \fB] ]\fR
6580 .ad
6581 .sp .6
6582 .RS 4n
6583 Sets attributes and values for shell variables and functions. When invoked
6584 inside a function defined with the \fBfunction\fR \fIname\fR syntax, a new
6585 instance of the variable \fIvname\fR is created, and the variable's value and
6586 type are restored when the function completes.
6587 .sp
6588 Using \fB+\fR rather than \fB-\fR causes these options to be turned off. If no
6589 \fIvname\fR arguments are specified, a list of \fIvname\fRs (and optionally the
6590 \fIvalue\fRs) of the variables is printed. Using \fB+\fR rather than \fB-\fR
6591 keeps the values from being printed.) The \fB-p\fR option causes \fBtypeset\fR
6592 followed by the option letters to be printed before each name rather than the
6593 names of the options. If any option other than \fB-p\fR is specified, only
6594 those variables which have all of the specified options are printed. Otherwise,
6595 the \fIvname\fRs and \fIattributes\fR of all variables that have attributes are
6596 printed.
6597 .sp
6598 The following list of attributes can be specified:
6599 .sp
6600 .ne 2
6601 .na
6602 \fB-a\fR
6603 .ad
6604 .RS 6n
6605 Declares \fIvname\fR to be an indexed array. This is optional unless except for
6606 compound variable assignments.
6607 .RE
6608
6609 .sp
6610 .ne 2
6611 .na
6612 \fB-A\fR
6613 .ad
6614 .RS 6n
6615 Declares \fIvname\fR to be an associative array. Sub-scripts are strings rather
6616 than arithmetic expressions.
6617 .RE
6618
6619 .sp
6620 .ne 2
6621 .na
6622 \fB-b\fR
6623 .ad
6624 .RS 6n
6625 The variable can hold any number of bytes of data. The data can be text or
6626 binary. The value is represented by the \fBbase64\fR encoding of the data. If
6627 \fB-Z\fR is also specified, the size in bytes of the data in the buffer is
6628 determined by the size associated with the \fB-Z\fR. If the \fBbase64\fR string
6629 assigned results in more data, it is truncated. Otherwise, it is filled with
6630 bytes whose value is zero. The \fBprintf\fR format \fB%B\fR can be used to
6631 output the actual data in this buffer instead of the \fBbase64\fR encoding of
6632 the data.
6633 .RE
6634
6635 .sp
6636 .ne 2
6637 .na
6638 \fB-C\fR
6639 .ad
6640 .RS 6n
6641 Causes each \fIvname\fR to be a compound variable. If \fIvalue\fR names
6642 a compound variable it is copied into \fIvname\fR. Otherwise, it unsets each
6643 vname.
6644 .RE
6645
6646 .sp
6647 .ne 2
6648 .na
6649 \fB-E\fR
6650 .ad
6651 .RS 6n
6652 Declares \fIvname\fR to be a double precision floating point number. If \fIn\fR
6653 is \fBnon-zero\fR, it defines the number of significant figures that are used
6654 when expanding \fIvname\fR. Otherwise, ten significant figures is used.
6655 .RE
6656
6657 .sp
6658 .ne 2
6659 .na
6660 \fB-f\fR
6661 .ad
6662 .RS 6n
6663 The names refer to function names rather than variable names. No assignments
6664 can be made and the only other valid options are \fB-t\fR, \fB-u\fR, and
6665 \fB-x.\fR The \fB-t\fR option turns on execution tracing for this function. The
6666 \fB-u\fR option causes this function to be marked undefined. The \fBFPATH\fR
6667 variable is searched to find the function definition when the function is
6668 referenced. If no options other than \fB-f\fR is specified, then the function
6669 definition is displayed on standard output. If \fB+f\fR is specified, then a
6670 line containing the function name followed by a shell comment containing the
6671 line number and path name of the file where this function was defined, if any,
6672 is displayed.
6673 The names refer to function names rather than variable names.
6674 No assignments can be made and the only other valid options are
6675 \fB-S, -t, -u\fR and \fB-x\fR.
6676 The \fB-S\fR can be used with discipline functions defined in a type to
6677 indicate that the function is static. For a static function, the same method
6678 will be used by all instances of that type no matter which instance references
6679 it. In addition, it can only use value of variables from the original type
6680 definition. These discipline functions cannot be redefined in any type
6681 instance.
6682 The \fB-t\fR option turns on execution tracing for this function.
6683 The \fB-u\fR option causes this function to be marked undefined.
6684 The \fBFPATH\fR variable will be searched to find the function definition
6685 when the function is referenced.
6686 If no options other than \fB-f\fR is specified, then the function definition
6687 will be displayed on standard output. If \fB+f\fR is specified, then a line
6688 containing the function name followed by a shell comment containing the line
6689 number and path name of the file where this function was defined, if any, is
6690 displayed. The exit status can be used to determine whether the function is
6691 defined so that \fBtypeset -f .sh.math.\fR \fIname\fR will return 0 when math
6692 function \fIname\fR is defined and non-zero otherwise.
6693 .sp
6694 The \fB-i\fR attribute cannot be specified with \fB-f\fR.
6695 .RE
6696
6697 .sp
6698 .ne 2
6699 .na
6700 \fB-F\fR
6701 .ad
6702 .RS 6n
6703 Declares \fIvname\fR to be a double precision floating point number. If \fIn\fR
6704 is \fBnon-zero\fR, it defines the number of places after the decimal point that
6705 are used when expanding \fIvname\fR. Otherwise ten places after the decimal
6706 point is used.
6707 .RE
6708
6709 .sp
6710 .ne 2
6711 .na
6712 \fB-h\fR
6713 .ad
6714 .RS 6n
6715 Used within type definitions to add information when generating information
6716 about the sub-variable on the man page. It is ignored when used outside of a
6717 type definition. When used with \fB-f\fR the information is associated with the
6718 corresponding discipline function.
6719 .RE
6720
6721 .sp
6722 .ne 2
6723 .na
6724 \fB-H\fR
6725 .ad
6726 .RS 6n
6727 This option provides UNIX to hostname file mapping on non-UNIX machines.
6728 .RE
6729
6730 .sp
6731 .ne 2
6732 .na
6733 \fB-i\fR
6734 .ad
6735 .RS 6n
6736 Declares \fIvname\fR to be represented internally as integer. The right hand
6737 side of an assignment is evaluated as an arithmetic expression when assigning
6738 to an integer. If \fIn\fR is \fBnon-zero\fR, it defines the output arithmetic
6739 base, otherwise the output base is ten.
6740 .sp
6741 The \fB-i\fR attribute cannot be specified along with \fB-R\fR, \fB-L\fR,
6742 \fB-Z\fR, or \fB-f\fR.
6743 .RE
6744
6745 .sp
6746 .ne 2
6747 .na
6748 \fB-l\fR
6749 .ad
6750 .RS 6n
6751 Used with \fB-i, -E\fR or \fB-F\fR to indicate long integer, or long float.
6752 Otherwise, all upper-case characters are converted to lower-case.
6753 The upper-case option, \fB-u\fR, is turned off.
6754 Equivalent to \fB-M tolower\fR.
6755 .RE
6756
6757 .sp
6758 .ne 2
6759 .na
6760 \fB-L\fR
6761 .ad
6762 .RS 6n
6763 Left justify and remove leading blanks from \fIvalue\fR. If \fIn\fR is
6764 \fBnon-zero\fR, it defines the width of the field, otherwise it is determined
6765 by the width of the value of first assignment. When the variable is assigned
6766 to, it is filled on the right with blanks or truncated, if necessary, to fit
6767 into the field. The \fB-R\fR option is turned off.
6768 .sp
6769 The \fB-i\fR attribute cannot be specified with \fB-L\fR.
6770 .RE
6771
6772 .sp
6773 .ne 2
6774 .na
6775 \fB-m\fR
6776 .ad
6777 .RS 6n
6778 moves or renames the variable. The value is the name of a variable whose value
6779 will be moved to \fIvname\fR. The original variable will be unset. Cannot be
6780 used with any other options.
6781 .RE
6782
6783 .sp
6784 .ne 2
6785 .na
6786 \fB-M\fR
6787 .ad
6788 .RS 6n
6789 Use the character mapping \fImapping\fR such as \fBtolower\fR
6790 and \fBtoupper\fR when assigning a value to each of the specified operands.
6791 When \fImapping\fR is specified and there are not operands, all variables
6792 that use this mapping are written to standard output.
6793 When \fImapping\fR is omitted and there are no operands, all mapped
6794 variables are written to standard output.
6795 .RE
6796
6797 .sp
6798 .ne 2
6799 .na
6800 \fB-n\fR
6801 .ad
6802 .RS 6n
6803 Declares \fIvname\fR to be a reference to the variable whose name is defined by
6804 the value of variable \fIvname\fR. This is usually used to reference a variable
6805 inside a function whose name has been passed as an argument.
6806 .RE
6807
6808 .sp
6809 .ne 2
6810 .na
6811 \fB-p\fR
6812 .ad
6813 .RS 6n
6814 The name, attributes and values for the given \fIvname\fR
6815 are written on standard output in a form that can be used as shell input.
6816 If \fB+p\fR is specified, then the values are not displayed.
6817 .RE
6818
6819 .sp
6820 .ne 2
6821 .na
6822 \fB-R\fR
6823 .ad
6824 .RS 6n
6825 Right justify and fill with leading blanks. If \fIn\fR is \fBnon-zero\fR, it
6826 defines the width of the field, otherwise it is determined by the width of the
6827 value of first assignment. The field is left filled with blanks or truncated
6828 from the end if the variable is reassigned. The \fB-L\fR option is turned off.
6829 .sp
6830 The \fB-i\fR attribute cannot be specified with \fB-R\fR.
6831 .RE
6832
6833 .sp
6834 .ne 2
6835 .na
6836 \fB-r\fR
6837 .ad
6838 .RS 6n
6839 The specified \fIvname\fRs are marked read-only and these names cannot be
6840 changed by subsequent assignment.
6841 .RE
6842
6843 .sp
6844 .ne 2
6845 .na
6846 \fB-S\fR
6847 .ad
6848 .RS 6n
6849 When used within the \fIassign_list\fR of a type definition, it causes the
6850 specified sub-variable to be shared by all instances of the type. When used
6851 inside a function defined with the \fBfunction\fR reserved word, the specified
6852 variables will have \fIfunction static\fR scope. Otherwise, the variable is
6853 unset prior to processing the assignment list.
6854 .RE
6855
6856 .sp
6857 .ne 2
6858 .na
6859 \fB-t\fR
6860 .ad
6861 .RS 6n
6862 Tags the variables. Tags are user definable and have no special meaning to the
6863 shell.
6864 .RE
6865
6866 .sp
6867 .ne 2
6868 .na
6869 \fB-T\fR
6870 .ad
6871 .RS 6n
6872 If followed by \fItname\fR, it creates a type named by \fItname\fR using the
6873 compound assignment \fIassign_list\fR to \fItname\fR. Otherwise, it writes all
6874 the type definitions to standard output.
6875 .RE
6876
6877 .sp
6878 .ne 2
6879 .na
6880 \fB-u\fR
6881 .ad
6882 .RS 6n
6883 When given along with \fB-i\fR specifies unsigned integer.
6884 Otherwise, all lower-case characters are converted to upper-case.
6885 The lower-case option, \fB-l\fR, is turned off.
6886 Equivalent to \fB-M toupper\fR.
6887 .RE
6888
6889 .sp
6890 .ne 2
6891 .na
6892 \fB-x\fR
6893 .ad
6894 .RS 6n
6895 The specified \fIvname\fRs are marked for automatic export to the environment
6896 of subsequently-executed commands. Variables whose names contain a \fB.\fR
6897 cannot be exported.
6898 .RE
6899
6900 .sp
6901 .ne 2
6902 .na
6903 \fB-X\fR
6904 .ad
6905 .RS 6n
6906 Declares \fIvname\fR to be a double precision floating point number
6907 and expands using the \fB%a\fR format of ISO-C99.
6908 If \fIn\fR is non-zero, it defines the number of hex digits after
6909 the radix point that is used when expanding \fIvname\fR.
6910 The default is 10.
6911 .RE
6912
6913 .sp
6914 .ne 2
6915 .na
6916 \fB-Z\fR
6917 .ad
6918 .RS 6n
6919 Right justify and fill with leading zeros if the first non-blank character is a
6920 digit and the \fB-L\fR option has not been set. Remove leading zeros if the
6921 \fB-L\fR option is also set. If \fIn\fR is \fBnon-zero\fR, it defines the width
6922 of the field, otherwise it is determined by the width of the value of first
6923 assignment.
6924 .sp
6925 The \fB-i\fR attribute cannot be specified with \fB-Z\fR.
6926 .RE
6927
6928 .RE
6929
6930 .sp
6931 .ne 2
6932 .na
6933 \fBulimit [\fR\fB-HSacdfmnpstv\fR\fB] [\fR \fIlimit\fR\fB]\fR
6934 .ad
6935 .sp .6
6936 .RS 4n
6937 Set or display a resource limit. Many systems do not support one or more of
6938 these limits. The limit for a specified resource is set when \fIlimit\fR is
6939 specified. The value of \fIlimit\fR can be a number in the unit specified with
6940 each resource, or the value unlimited. When more than one resource is
6941 specified, then the limit name and unit is printed before the value.
6942 .sp
6943 If no option is specified, \fB-f\fR is assumed.
6944 .sp
6945 The following are the available resource limits:
6946 .sp
6947 .ne 2
6948 .na
6949 \fB-a\fR
6950 .ad
6951 .RS 6n
6952 Lists all of the current resource limits.
6953 .RE
6954
6955 .sp
6956 .ne 2
6957 .na
6958 \fB-c\fR
6959 .ad
6960 .RS 6n
6961 The number of 512-byte blocks on the size of core dumps.
6962 .RE
6963
6964 .sp
6965 .ne 2
6966 .na
6967 \fB-d\fR
6968 .ad
6969 .RS 6n
6970 The number of Kbytes on the size of the data area.
6971 .RE
6972
6973 .sp
6974 .ne 2
6975 .na
6976 \fB-f\fR
6977 .ad
6978 .RS 6n
6979 The number of 512-byte blocks on files that can be written by the current
6980 process or by child processes (files of any size can be read).
6981 .RE
6982
6983 .sp
6984 .ne 2
6985 .na
6986 \fB-H\fR
6987 .ad
6988 .RS 6n
6989 Specifies a hard limit for the specified resource.
6990 .sp
6991 A hard limit cannot be increased once it is set.
6992 .sp
6993 If neither the \fB-H\fR nor \fB-S\fR option is specified, the limit applies to
6994 both. The current resource limit is printed when \fIlimit\fR is omitted. In
6995 this case, the soft limit is printed unless \fB-H\fR is specified.
6996 .RE
6997
6998 .sp
6999 .ne 2
7000 .na
7001 \fB-m\fR
7002 .ad
7003 .RS 6n
7004 The number of Kbytes on the size of physical memory.
7005 .RE
7006
7007 .sp
7008 .ne 2
7009 .na
7010 \fB-n\fR
7011 .ad
7012 .RS 6n
7013 The number of file descriptors plus 1.
7014 .RE
7015
7016 .sp
7017 .ne 2
7018 .na
7019 \fB-p\fR
7020 .ad
7021 .RS 6n
7022 The number of 512-byte blocks for pipe buffering.
7023 .RE
7024
7025 .sp
7026 .ne 2
7027 .na
7028 \fB-s\fR
7029 .ad
7030 .RS 6n
7031 The number of Kbytes on the size of the stack area.
7032 .RE
7033
7034 .sp
7035 .ne 2
7036 .na
7037 \fB-S\fR
7038 .ad
7039 .RS 6n
7040 Specifies a soft limit for the specified resource.
7041 .sp
7042 A soft limit can be increased up to the value of the hard limit.
7043 .sp
7044 If neither the \fB-H\fR nor \fB-S\fR option is specified, the limit applies to
7045 both. The current resource limit is printed when \fIlimit\fR is omitted. In
7046 this case, the soft limit is printed unless \fB-H\fR is specified.
7047 .RE
7048
7049 .sp
7050 .ne 2
7051 .na
7052 \fB-t\fR
7053 .ad
7054 .RS 6n
7055 The number of CPU seconds to be used by each process.
7056 .RE
7057
7058 .sp
7059 .ne 2
7060 .na
7061 \fB-v\fR
7062 .ad
7063 .RS 6n
7064 The number of Kbytes for virtual memory.
7065 .RE
7066
7067 .RE
7068
7069 .sp
7070 .ne 2
7071 .na
7072 \fBumask\fR \fB[\fR\fB-S\fR\fB]\fR\fB[\fR\fImask\fR\fB]\fR
7073 .ad
7074 .sp .6
7075 .RS 4n
7076 The user file-creation mask is set to \fImask\fR. \fImask\fR can either be an
7077 octal number or a symbolic value as described in \fBchmod\fR(1).
7078 .sp
7079 If a symbolic value is specified, the new \fBumask\fR value is the complement
7080 of the result of applying \fImask\fR to the complement of the previous
7081 \fBumask\fR value. If \fImask\fR is omitted, the current value of the mask is
7082 printed. The \fB-S\fR option causes the mode to be printed as a symbolic value.
7083 Otherwise, the mask is printed in octal.
7084 .sp
7085 See \fBumask\fR(2)
7086 .RE
7087
7088 .sp
7089 .ne 2
7090 .na
7091 \fB+unalias\fR \fB[\fR\fB-a\fR\fB]\fR \fIname\fR
7092 .ad
7093 .sp .6
7094 .RS 4n
7095 The aliases specified by the list of \fIname\fRs are removed from the alias
7096 list. The \fB-a\fR option causes all the aliases to be unset.
7097 .RE
7098
7099 .sp
7100 .ne 2
7101 .na
7102 \fB+unset\fR \fB[\fR\fB-fnv\fR\fB]\fR \fIvname\fR
7103 .ad
7104 .sp .6
7105 .RS 4n
7106 The variables specified by the list of \fIvname\fRs are unassigned, i.e., their
7107 values and attributes are erased. Read-only variables cannot be unset. If the
7108 \fB-f\fR option is set, then the names refer to function names. If the \fB-v\fR
7109 option is set, then the names refer to variable names. The \fB-f\fR option
7110 overrides \fB-v\fR. If \fB-n\fR is set and \fIname\fR is a name reference, then
7111 \fIname\fR is unset rather than the variable that it references. The default is
7112 equivalent to \fB-v\fR. Unsetting \fBLINENO\fR, \fBMAILCHECK\fR, \fBOPTARG\fR,
7113 \fBOPTIND\fR, \fBRANDOM\fR, \fBSECONDS\fR, \fBTMOUT\fR, and \fB_\fR removes
7114 their special meaning even if they are subsequently assigned to.
7115 .RE
7116
7117 .sp
7118 .ne 2
7119 .na
7120 \fBwait\fR \fB[\fR\fIjob\fR\fB]\fR
7121 .ad
7122 .sp .6
7123 .RS 4n
7124 Wait for the specified job and report its termination status. If \fIjob\fR is
7125 not specified, then all currently active child processes are waited for. The
7126 exit status from this command is that of the last process waited for if
7127 \fIjob\fR is specified; otherwise it is zero. See \fBJobs\fR for a description
7128 of the format of \fIjob\fR.
7129 .RE
7130
7131 .sp
7132 .ne 2
7133 .na
7134 \fBwhence\fR \fB[\fR\fB-afpv\fR\fB]\fR \fIname ...\fR
7135 .ad
7136 .sp .6
7137 .RS 4n
7138 For each \fIname\fR, indicate how it would be interpreted if used as a command
7139 name. The \fB-v\fR option produces a more verbose report. The \fB-f\fR option
7140 skips the search for functions. The \fB-p\fR option does a path search for
7141 \fIname\fR even if name is an alias, a function, or a reserved word. The
7142 \fB-a\fR option is similar to the -v option but causes all interpretations of
7143 the specified name to be reported.
7144 .RE
7145
7146 .SS "Invocation"
7147 If the shell is invoked by \fBexec\fR(2), and the first character of argument
7148 zero (\fB$0\fR) is \fB-\fR, then the shell is assumed to be a login shell and
7149 commands are read from \fB/etc/profile\fR and then from either .\fBprofile\fR
7150 in the current directory or \fB$HOME/.profile\fR, if either file exists. Next,
7151 for interactive shells, commands are read first from \fB/etc/ksh.kshrc\fR, and
7152 then from the file named by performing parameter expansion, command
7153 substitution, and arithmetic substitution on the value of the environment
7154 variable \fBENV\fR if the file exists. If the \fB-s\fR option is not present
7155 and \fIarg\fR and a file by the name of \fIarg\fR exists, then it reads and
7156 executes this script. Otherwise, if the first \fIarg\fR does not contain a
7157 \fB/\fR, a path search is performed on the first \fIarg\fR to determine the
7158 name of the script to execute. The script \fIarg\fR must have execute
7159 permission and any \fBsetuid\fR and \fBsetgid\fR settings are ignored. If the
7160 script is not found on the path, \fIarg\fR is processed as if it named a
7161 built-in command or function.
7162 .sp
7163 .LP
7164 Commands are then read as described, and the following options are interpreted
7165 by the shell when it is invoked:
7166 .sp
7167 .ne 2
7168 .na
7169 \fB-c\fR
7170 .ad
7171 .RS 15n
7172 If the \fB-c\fR option is present, then commands are read from the first
7173 \fIarg\fR. Any remaining arguments become positional parameters starting at
7174 \fB0\fR.
7175 .RE
7176
7177 .sp
7178 .ne 2
7179 .na
7180 \fB-D\fR
7181 .ad
7182 .RS 15n
7183 A list of all double quoted strings that are preceded by a \fB$\fR is printed
7184 on standard output and the shell exits. This set of strings is subject to
7185 language translation when the locale is not C or POSIX. No commands are
7186 executed.
7187 .RE
7188
7189 .sp
7190 .ne 2
7191 .na
7192 \fB-E\fR
7193 .ad
7194 .RS 15n
7195 Reads the file named by the \fBENV\fR variable or by \fB$HOME/.kshrc\fR if
7196 not defined after the profiles.
7197 .RE
7198
7199 .sp
7200 .ne 2
7201 .na
7202 \fB-i\fR
7203 .ad
7204 .RS 15n
7205 If the \fB-i\fR option is present or if the shell input and output are attached
7206 to a terminal (as told by \fBtcgetattr\fR(3C), this shell is interactive. In
7207 this case \fBTERM\fR is ignored (so that \fBkill 0\fR does not kill an
7208 interactive shell) and \fBINTR\fR is caught and ignored (so that wait is
7209 interruptible). In all cases, \fBQUIT\fR is ignored by the shell.
7210 .RE
7211
7212 .sp
7213 .ne 2
7214 .na
7215 \fB-P\fR
7216 .ad
7217 .RS 15n
7218 If \fB-P\fR or \fB-o\fR profile is present, the shell is a profile shell
7219 (see \fBpfexec\fR(1)).
7220 .RE
7221
7222 .sp
7223 .ne 2
7224 .na
7225 \fB-R\fR \fIfilename\fR
7226 .ad
7227 .RS 15n
7228 The \fB-R\fR \fIfilename\fR option is used to generate a cross reference
7229 database that can be used by a separate utility to find definitions and
7230 references for variables and commands.
7231 .RE
7232
7233 .sp
7234 .ne 2
7235 .na
7236 \fB-r\fR
7237 .ad
7238 .RS 15n
7239 If the \fB-r\fR option is present, the shell is a restricted shell.
7240 .RE
7241
7242 .sp
7243 .ne 2
7244 .na
7245 \fB-s\fR
7246 .ad
7247 .RS 15n
7248 If the \fB-s\fR option is present or if no arguments remain, then commands are
7249 read from the standard input. Shell output, except for the output of the
7250 \fBSpecial Commands\fR listed, is written to file descriptor 2.
7251 .RE
7252
7253 .sp
7254 .LP
7255 The remaining options and arguments are described under the \fBset\fR command.
7256 An optional \fB-\fR as the first argument is ignored.
7257 .SS "\fBrksh93\fR Only"
7258 \fBrksh93\fR is used to set up login names and execution environments whose
7259 capabilities are more controlled than those of the standard shell.
7260 .sp
7261 .LP
7262 The actions of \fBrksh93\fR are identical to those of \fBksh93\fR, except that
7263 the following are disallowed:
7264 .RS +4
7265 .TP
7266 .ie t \(bu
7267 .el o
7268 Unsetting the restricted option
7269 .RE
7270 .RS +4
7271 .TP
7272 .ie t \(bu
7273 .el o
7274 Changing directory. See \fBcd\fR(1).
7275 .RE
7276 .RS +4
7277 .TP
7304 .el o
7305 Using \fBcommand\fR \fB-p\fR to invoke a command.
7306 .RE
7307 .sp
7308 .LP
7309 These restrictions are enforced after .\fBprofile\fR and the \fBENV\fR files
7310 are interpreted.
7311 .sp
7312 .LP
7313 When a command to be executed is found to be a shell procedure, \fBrksh93\fR
7314 invokes \fBksh93\fR to execute it. Thus, it is possible to provide to the
7315 end-user shell procedures that have access to the full power of the standard
7316 shell, while imposing a limited menu of commands. This scheme assumes that the
7317 end-user does not have write and execute permissions in the same directory. The
7318 net effect of these rules is that the writer of the .\fBprofile\fR has complete
7319 control over user actions, by performing guaranteed setup actions and leaving
7320 the user in an appropriate directory (probably not the login directory). The
7321 system administrator often sets up a directory of commands, for example,
7322 \fB/usr/rbin\fR, that can be safely invoked by \fBrksh\fR.
7323 .SH USAGE
7324 See \fBlargefile\fR(5) for the description of the behavior of \fBksh93\fR and
7325 \fBrksh93\fR when encountering files greater than or equal to 2 Gbyte ( 2^31
7326 bytes).
7327 .SH EXIT STATUS
7328 The following exit values are returned:
7329 .sp
7330 .ne 2
7331 .na
7332 \fBnon-zero\fR
7333 .ad
7334 .sp .6
7335 .RS 4n
7336 Returns \fBnon-zero\fR when errors, such as syntax errors, are detected by the
7337 shell.
7338 .sp
7339 If the shell is being used non-interactively, then execution of the shell file
7340 is abandoned unless the error occurs inside a sub-shell in which case the
7341 sub-shell is abandoned.
7342 .RE
7343
7344 .sp
7345 .ne 2
7346 .na
7347 \fB\fIexit status of last command executed\fR
7348 .ad
7349 .sp .6
7350 .RS 4n
7351 Returns the exit status of the last command executed.
7352 .sp
7353 Run time errors detected by the shell are reported by printing the command or
7354 function name and the error condition. If the line number that the error
7355 occurred on is greater than one, then the line number is also printed in square
7356 brackets (\fB[]\fR) after the command or function name.
7357 .sp
7358 See the \fBksh93 exit\fR command for additional details.
7359 .RE
7360
7361 .SH FILES
7362 .ne 2
7363 .na
7364 \fB/etc/profile\fR
7365 .ad
7366 .sp .6
7367 .RS 4n
7368 The system initialization file, executed for login shells.
7369 .RE
7370
7371 .sp
7372 .ne 2
7373 .na
7374 \fB/etc/ksh.kshrc\fR
7375 .ad
7376 .sp .6
7377 .RS 4n
7378 The system wide startup file, executed for interactive shells.
7379 .RE
7380
7381 .sp
7382 .ne 2
7383 .na
7384 \fB$HOME/.profile\fR
7385 .ad
7386 .sp .6
7387 .RS 4n
7388 The personal initialization file, executed for login shells after
7389 \fB/etc/profile\fR.
7390 .RE
7391
7392 .sp
7393 .ne 2
7394 .na
7395 \fB$HOME/.kshrc\fR
7396 .ad
7397 .sp .6
7398 .RS 4n
7399 Default personal initialization file, executed after \fB/etc/ksh.kshrc\fR, for
7400 interactive shells when \fBENV\fR is not set.
7401 .RE
7402
7403 .sp
7404 .ne 2
7405 .na
7406 \fB/etc/suid-profile\fR
7407 .ad
7408 .sp .6
7409 .RS 4n
7410 Alternative initialization file, executed instead of the personal
7411 initialization file when the real and effective user or group id do not match.
7412 .RE
7413
7414 .sp
7415 .ne 2
7416 .na
7417 \fB/dev/null\fR
7418 .ad
7419 .sp .6
7420 .RS 4n
7421 NULL device.
7422 .RE
7423
7424 .SH AUTHORS
7425 David Korn, \fBdgk@research.att.com\fR
7426 .SH ATTRIBUTES
7427 See \fBattributes\fR(5) for descriptions of the following attributes:
7428 .sp
7429
7430 .sp
7431 .TS
7432 box;
7433 c | c
7434 l | l .
7435 ATTRIBUTE TYPE ATTRIBUTE VALUE
7436 _
7437 Interface Stability See below.
7438 .TE
7439
7440 .sp
7441 .LP
7442 The scripting interface is Uncommitted. The environment variables,
7443 \fB\&.paths\fR feature, and editing modes are Volatile.
7444 .SH SEE ALSO
7445 \fBcat\fR(1), \fBcd\fR(1), \fBchmod\fR(1), \fBcut\fR(1), \fBdate\fR(1),
7446 \fBegrep\fR(1), \fBecho\fR(1), \fBegrep\fR(1), \fBenv\fR(1), \fBfgrep\fR(1),
7447 \fBgrep\fR(1), \fBlogin\fR(1), \fBnewgrp\fR(1), \fBpaste\fR(1), \fBpfexec\fR(1),
7448 \fBprintf\fR(1), \fBstty\fR(1), \fBtest\fR(1), \fBumask\fR(1), \fBvi\fR(1),
7449 \fBdup\fR(2), \fBexec\fR(2), \fBfork\fR(2), \fBioctl\fR(2), \fBlseek\fR(2),
7450 \fBpathconf\fR(2), \fBpipe\fR(2), \fBsysconf\fR(3C), \fBulimit\fR(2),
7451 \fBumask\fR(2), \fBrand\fR(3C), \fBtcgetattr\fR(3C), \fBwait\fR(3C),
7452 \fBa.out\fR(4), \fBprofile\fR(4), \fBattributes\fR(5), \fBenviron\fR(5),
7453 \fBlargefile\fR(5), \fBstandards\fR(5)
7454 .sp
7455 .LP
7456 Bolsky, Morris I. and Korn, David G., \fIThe New KornShell Command and
7457 Programming Language\fR, Prentice Hall, 1995.
7458 .sp
7459 .LP
7460 \fIPOSIX-Part 2: Shell and Utilities, IEEE Std 1003.2-1992, ISO/IEC 9945-2\fR,
7461 IEEE, 1993.
7462 .SH NOTES
7463 \fBksh93\fR scripts should choose shell function names outside the namespace
7464 used by reserved keywords of the ISO C99, C++ and JAVA languages to avoid
7465 collisions with future enhancements to \fBksh93\fR.
7466 .sp
7467 .LP
7468 If a command is executed, and then a command with the same name is installed in
7469 a directory in the search path before the directory where the original command
7470 was found, the shell continues to \fBexec\fR the original command. Use the
7471 \fB-t\fR option of the alias command to correct this situation.
7472 .sp
7473 .LP
7474 Some very old shell scripts contain a caret (\fB^\fR) as a synonym for the pipe
7475 character (\fB|\fR).
7476 .sp
7477 .LP
7478 Using the \fBhist\fR built-in command within a compound command causes the
7479 whole command to disappear from the history file.
7480 .sp
7481 .LP
7482 The built-in command \fB\&.\fR \fIfile\fR reads the whole file before any
|