Bash-4.0 patchlevel 38
[platform/upstream/bash.git] / doc / bash.1
1 .\"
2 .\" MAN PAGE COMMENTS to
3 .\"
4 .\"     Chet Ramey
5 .\"     Case Western Reserve University
6 .\"     chet@po.cwru.edu
7 .\"
8 .\"     Last Change: Sat Feb  7 20:50:40 EST 2009
9 .\"
10 .\" bash_builtins, strip all but Built-Ins section
11 .if \n(zZ=1 .ig zZ
12 .if \n(zY=1 .ig zY
13 .TH BASH 1 "2009 February 7" "GNU Bash-4.0"
14 .\"
15 .\" There's some problem with having a `@'
16 .\" in a tagged paragraph with the BSD man macros.
17 .\" It has to do with `@' appearing in the }1 macro.
18 .\" This is a problem on 4.3 BSD and Ultrix, but Sun
19 .\" appears to have fixed it.
20 .\" If you're seeing the characters
21 .\" `@u-3p' appearing before the lines reading
22 .\" `possible-hostname-completions
23 .\" and `complete-hostname' down in READLINE,
24 .\" then uncomment this redefinition.
25 .\"
26 .de }1
27 .ds ]X \&\\*(]B\\
28 .nr )E 0
29 .if !"\\$1"" .nr )I \\$1n
30 .}f
31 .ll \\n(LLu
32 .in \\n()Ru+\\n(INu+\\n()Iu
33 .ti \\n(INu
34 .ie !\\n()Iu+\\n()Ru-\w\a\\*(]X\au-3p \{\\*(]X
35 .br\}
36 .el \\*(]X\h\a|\\n()Iu+\\n()Ru\a\c
37 .}f
38 ..
39 .\"
40 .\" File Name macro.  This used to be `.PN', for Path Name,
41 .\" but Sun doesn't seem to like that very much.
42 .\"
43 .de FN
44 \fI\|\\$1\|\fP
45 ..
46 .SH NAME
47 bash \- GNU Bourne-Again SHell
48 .SH SYNOPSIS
49 .B bash
50 [options]
51 [file]
52 .SH COPYRIGHT
53 .if n Bash is Copyright (C) 1989-2009 by the Free Software Foundation, Inc.
54 .if t Bash is Copyright \(co 1989-2009 by the Free Software Foundation, Inc.
55 .SH DESCRIPTION
56 .B Bash
57 is an \fBsh\fR-compatible command language interpreter that
58 executes commands read from the standard input or from a file.
59 .B Bash
60 also incorporates useful features from the \fIKorn\fP and \fIC\fP
61 shells (\fBksh\fP and \fBcsh\fP).
62 .PP
63 .B Bash
64 is intended to be a conformant implementation of the
65 Shell and Utilities portion of the IEEE POSIX specification
66 (IEEE Standard 1003.1).
67 .B Bash
68 can be configured to be POSIX-conformant by default.
69 .SH OPTIONS
70 In addition to the single-character shell options documented in the
71 description of the \fBset\fR builtin command, \fBbash\fR
72 interprets the following options when it is invoked:
73 .PP
74 .PD 0
75 .TP 10
76 .BI \-c "\| string\^"
77 If the
78 .B \-c
79 option is present, then commands are read from
80 .IR string .
81 If there are arguments after the
82 .IR string ,
83 they are assigned to the positional parameters, starting with
84 .BR $0 .
85 .TP
86 .B \-i
87 If the
88 .B \-i
89 option is present, the shell is
90 .IR interactive .
91 .TP
92 .B \-l
93 Make
94 .B bash
95 act as if it had been invoked as a login shell (see
96 .SM
97 .B INVOCATION
98 below).
99 .TP
100 .B \-r
101 If the
102 .B \-r
103 option is present, the shell becomes
104 .I restricted
105 (see
106 .SM
107 .B "RESTRICTED SHELL"
108 below).
109 .TP
110 .B \-s
111 If the
112 .B \-s
113 option is present, or if no arguments remain after option
114 processing, then commands are read from the standard input.
115 This option allows the positional parameters to be set
116 when invoking an interactive shell.
117 .TP
118 .B \-D
119 A list of all double-quoted strings preceded by \fB$\fP
120 is printed on the standard output.
121 These are the strings that
122 are subject to language translation when the current locale
123 is not \fBC\fP or \fBPOSIX\fP.
124 This implies the \fB\-n\fP option; no commands will be executed.
125 .TP
126 .B [\-+]O [\fIshopt_option\fP]
127 \fIshopt_option\fP is one of the shell options accepted by the
128 \fBshopt\fP builtin (see
129 .SM
130 .B SHELL BUILTIN COMMANDS
131 below).
132 If \fIshopt_option\fP is present, \fB\-O\fP sets the value of that option;
133 \fB+O\fP unsets it.
134 If \fIshopt_option\fP is not supplied, the names and values of the shell
135 options accepted by \fBshopt\fP are printed on the standard output.
136 If the invocation option is \fB+O\fP, the output is displayed in a format
137 that may be reused as input.
138 .TP
139 .B \-\-
140 A
141 .B \-\-
142 signals the end of options and disables further option processing.
143 Any arguments after the
144 .B \-\-
145 are treated as filenames and arguments.  An argument of
146 .B \-
147 is equivalent to \fB\-\-\fP.
148 .PD
149 .PP
150 .B Bash
151 also interprets a number of multi-character options.
152 These options must appear on the command line before the
153 single-character options to be recognized.
154 .PP
155 .PD 0
156 .TP
157 .B \-\-debugger
158 Arrange for the debugger profile to be executed before the shell
159 starts.
160 Turns on extended debugging mode (see the description of the
161 .B extdebug
162 option to the
163 .B shopt
164 builtin below)
165 and shell function tracing (see the description of the
166 \fB\-o functrace\fP option to the
167 .B set
168 builtin below).
169 .TP
170 .B \-\-dump\-po\-strings
171 Equivalent to \fB\-D\fP, but the output is in the GNU \fIgettext\fP
172 \fBpo\fP (portable object) file format.
173 .TP
174 .B \-\-dump\-strings
175 Equivalent to \fB\-D\fP.
176 .TP
177 .B \-\-help
178 Display a usage message on standard output and exit successfully.
179 .TP
180 \fB\-\-init\-file\fP \fIfile\fP
181 .PD 0
182 .TP
183 \fB\-\-rcfile\fP \fIfile\fP
184 .PD
185 Execute commands from
186 .I file
187 instead of the standard personal initialization file
188 .I ~/.bashrc
189 if the shell is interactive (see
190 .SM
191 .B INVOCATION
192 below).
193 .TP
194 .B \-\-login
195 Equivalent to \fB\-l\fP.
196 .TP
197 .B \-\-noediting
198 Do not use the GNU
199 .B readline
200 library to read command lines when the shell is interactive.
201 .TP
202 .B \-\-noprofile
203 Do not read either the system-wide startup file
204 .FN /etc/profile
205 or any of the personal initialization files
206 .IR ~/.bash_profile ,
207 .IR ~/.bash_login ,
208 or
209 .IR ~/.profile .
210 By default,
211 .B bash
212 reads these files when it is invoked as a login shell (see
213 .SM
214 .B INVOCATION
215 below).
216 .TP
217 .B \-\-norc
218 Do not read and execute the personal initialization file
219 .I ~/.bashrc
220 if the shell is interactive.
221 This option is on by default if the shell is invoked as
222 .BR sh .
223 .TP
224 .B \-\-posix
225 Change the behavior of \fBbash\fP where the default operation differs
226 from the POSIX standard to match the standard (\fIposix mode\fP).
227 .TP
228 .B \-\-restricted
229 The shell becomes restricted (see
230 .SM
231 .B "RESTRICTED SHELL"
232 below).
233 .TP
234 .B \-\-verbose
235 Equivalent to  \fB\-v\fP.
236 .TP
237 .B \-\-version
238 Show version information for this instance of
239 .B bash
240 on the standard output and exit successfully.
241 .PD
242 .SH ARGUMENTS
243 If arguments remain after option processing, and neither the
244 .B \-c
245 nor the
246 .B \-s
247 option has been supplied, the first argument is assumed to
248 be the name of a file containing shell commands.
249 If
250 .B bash
251 is invoked in this fashion, 
252 .B $0
253 is set to the name of the file, and the positional parameters
254 are set to the remaining arguments.
255 .B Bash
256 reads and executes commands from this file, then exits.
257 \fBBash\fP's exit status is the exit status of the last command
258 executed in the script.
259 If no commands are executed, the exit status is 0.
260 An attempt is first made to open the file in the current directory, and,
261 if no file is found, then the shell searches the directories in
262 .SM
263 .B PATH
264 for the script.
265 .SH INVOCATION
266 A \fIlogin shell\fP is one whose first character of argument zero is a
267 .BR \- ,
268 or one started with the 
269 .B \-\-login
270 option.
271 .PP
272 An \fIinteractive\fP shell is one started without non-option arguments
273 and without the
274 .B \-c
275 option
276 whose standard input and error are
277 both connected to terminals (as determined by
278 .IR isatty (3)),
279 or one started with the
280 .B \-i
281 option.
282 .SM
283 .B PS1
284 is set and
285 .B $\-
286 includes
287 .B i
288 if
289 .B bash
290 is interactive,
291 allowing a shell script or a startup file to test this state.
292 .PP
293 The following paragraphs describe how
294 .B bash
295 executes its startup files.
296 If any of the files exist but cannot be read,
297 .B bash
298 reports an error.
299 Tildes are expanded in file names as described below under
300 .B "Tilde Expansion"
301 in the
302 .SM
303 .B EXPANSION
304 section.
305 .PP
306 When
307 .B bash
308 is invoked as an interactive login shell, or as a non-interactive shell
309 with the \fB\-\-login\fP option, it first reads and
310 executes commands from the file \fI/etc/profile\fP, if that
311 file exists.
312 After reading that file, it looks for \fI~/.bash_profile\fP,
313 \fI~/.bash_login\fP, and \fI~/.profile\fP, in that order, and reads
314 and executes commands from the first one that exists and is readable.
315 The
316 .B \-\-noprofile
317 option may be used when the shell is started to inhibit this behavior.
318 .PP
319 When a login shell exits,
320 .B bash
321 reads and executes commands from the file \fI~/.bash_logout\fP, if it
322 exists.
323 .PP
324 When an interactive shell that is not a login shell is started,
325 .B bash
326 reads and executes commands from \fI~/.bashrc\fP, if that file exists.
327 This may be inhibited by using the
328 .B \-\-norc
329 option.
330 The \fB\-\-rcfile\fP \fIfile\fP option will force
331 .B bash
332 to read and execute commands from \fIfile\fP instead of \fI~/.bashrc\fP.
333 .PP
334 When
335 .B bash
336 is started non-interactively, to run a shell script, for example, it
337 looks for the variable
338 .SM
339 .B BASH_ENV
340 in the environment, expands its value if it appears there, and uses the
341 expanded value as the name of a file to read and execute.
342 .B Bash
343 behaves as if the following command were executed:
344 .sp .5
345 .RS
346 .if t \f(CWif [ \-n "$BASH_ENV" ]; then . "$BASH_ENV"; fi\fP
347 .if n if [ \-n "$BASH_ENV" ]; then . "$BASH_ENV"; fi
348 .RE
349 .sp .5
350 but the value of the
351 .SM
352 .B PATH
353 variable is not used to search for the file name.
354 .PP
355 If
356 .B bash
357 is invoked with the name
358 .BR sh ,
359 it tries to mimic the startup behavior of historical versions of
360 .B sh
361 as closely as possible,
362 while conforming to the POSIX standard as well.
363 When invoked as an interactive login shell, or a non-interactive
364 shell with the \fB\-\-login\fP option, it first attempts to
365 read and execute commands from
366 .I /etc/profile
367 and
368 .IR ~/.profile ,
369 in that order.
370 The
371 .B \-\-noprofile
372 option may be used to inhibit this behavior.
373 When invoked as an interactive shell with the name
374 .BR sh ,
375 .B bash
376 looks for the variable
377 .SM
378 .BR ENV ,
379 expands its value if it is defined, and uses the
380 expanded value as the name of a file to read and execute.
381 Since a shell invoked as
382 .B sh
383 does not attempt to read and execute commands from any other startup
384 files, the
385 .B \-\-rcfile
386 option has no effect.
387 A non-interactive shell invoked with the name
388 .B sh
389 does not attempt to read any other startup files. 
390 When invoked as
391 .BR sh ,
392 .B bash
393 enters
394 .I posix
395 mode after the startup files are read.
396 .PP
397 When
398 .B bash
399 is started in
400 .I posix
401 mode, as with the
402 .B \-\-posix
403 command line option, it follows the POSIX standard for startup files.
404 In this mode, interactive shells expand the
405 .SM
406 .B ENV
407 variable and commands are read and executed from the file
408 whose name is the expanded value.
409 No other startup files are read.
410 .PP
411 .B Bash
412 attempts to determine when it is being run with its standard input
413 connected to a a network connection, as if by the remote shell
414 daemon, usually \fIrshd\fP, or the secure shell daemon \fIsshd\fP.
415 If
416 .B bash
417 determines it is being run in this fashion, it reads and executes
418 commands from \fI~/.bashrc\fP, if that file exists and is readable.
419 It will not do this if invoked as \fBsh\fP.
420 The
421 .B \-\-norc
422 option may be used to inhibit this behavior, and the
423 .B \-\-rcfile
424 option may be used to force another file to be read, but
425 \fIrshd\fP does not generally invoke the shell with those options
426 or allow them to be specified.
427 .PP
428 If the shell is started with the effective user (group) id not equal to the
429 real user (group) id, and the \fB\-p\fP option is not supplied, no startup
430 files are read, shell functions are not inherited from the environment, the
431 .SM
432 .B SHELLOPTS
433 variable, if it appears in the environment, is ignored,
434 and the effective user id is set to the real user id.
435 If the \fB\-p\fP option is supplied at invocation, the startup behavior is
436 the same, but the effective user id is not reset.
437 .SH DEFINITIONS
438 .PP
439 The following definitions are used throughout the rest of this
440 document.
441 .PD 0
442 .TP
443 .B blank 
444 A space or tab.
445 .TP
446 .B word
447 A sequence of characters considered as a single unit by the shell.
448 Also known as a
449 .BR token .
450 .TP
451 .B name
452
453 .I word
454 consisting only of alphanumeric characters and underscores, and
455 beginning with an alphabetic character or an underscore.  Also
456 referred to as an
457 .BR identifier .
458 .TP
459 .B metacharacter
460 A character that, when unquoted, separates words.  One of the following:
461 .br
462 .RS
463 .PP
464 .if t \fB|  &  ;  (  )  <  >  space  tab\fP
465 .if n \fB|  & ; ( ) < > space tab\fP
466 .RE
467 .PP
468 .TP
469 .B control operator
470 A \fItoken\fP that performs a control function.  It is one of the following
471 symbols:
472 .RS
473 .PP
474 .if t \fB\(bv\(bv  &  &&  ;  ;;  (  )  |  |&    <newline>\fP
475 .if n \fB|| & && ; ;; ( ) | |& <newline>\fP
476 .RE
477 .PD
478 .SH "RESERVED WORDS"
479 \fIReserved words\fP are words that have a special meaning to the shell.
480 The following words are recognized as reserved when unquoted and either
481 the first word of a simple command (see
482 .SM
483 .B SHELL GRAMMAR
484 below) or the third word of a 
485 .B case 
486 or
487 .B for
488 command:
489 .if t .RS
490 .PP
491 .B
492 .if n ! case  do done elif else esac fi for function if in select then until while { } time [[ ]]
493 .if t !    case    do    done    elif    else    esac    fi    for    function    if    in    select    then    until    while    {    }    time    [[    ]]
494 .if t .RE
495 .SH "SHELL GRAMMAR"
496 .SS Simple Commands
497 .PP
498 A \fIsimple command\fP is a sequence of optional variable assignments
499 followed by \fBblank\fP-separated words and redirections, and
500 terminated by a \fIcontrol operator\fP.  The first word
501 specifies the command to be executed, and is passed as argument zero.
502 The remaining words are passed as arguments to the invoked command.
503 .PP
504 The return value of a \fIsimple command\fP is its exit status, or
505 128+\fIn\^\fP if the command is terminated by signal
506 .IR n .
507 .SS Pipelines
508 .PP
509 A \fIpipeline\fP is a sequence of one or more commands separated by
510 one of the control operators
511 .B |
512 or \fB|&\fP.
513 The format for a pipeline is:
514 .RS
515 .PP
516 [\fBtime\fP [\fB\-p\fP]] [ ! ] \fIcommand\fP [ [\fB|\fP\(bv\fB|&\fP] \fIcommand2\fP ... ]
517 .RE
518 .PP
519 The standard output of
520 .I command
521 is connected via a pipe to the standard input of
522 .IR command2 .
523 This connection is performed before any redirections specified by the
524 command (see
525 .SM
526 .B REDIRECTION
527 below).
528 If \fB|&\fP is used, the standard error of \fIcommand\fP is connected to
529 \fIcommand2\fP's standard input through the pipe; it is shorthand for
530 \fB2>&1 |\fP.
531 This implicit redirection of the standard error is performed after any
532 redirections specified by the command.
533 .PP
534 The return status of a pipeline is the exit status of the last
535 command, unless the \fBpipefail\fP option is enabled.
536 If \fBpipefail\fP is enabled, the pipeline's return status is the
537 value of the last (rightmost) command to exit with a non-zero status,
538 or zero if all commands exit successfully.
539 If the reserved word
540 .B !
541 precedes a pipeline, the exit status of that pipeline is the logical
542 negation of the exit status as described above.
543 The shell waits for all commands in the pipeline to
544 terminate before returning a value.
545 .PP
546 If the
547 .B time
548 reserved word precedes a pipeline, the elapsed as well as user and
549 system time consumed by its execution are reported when the pipeline
550 terminates.
551 The \fB\-p\fP option changes the output format to that specified by POSIX.
552 The
553 .SM
554 .B TIMEFORMAT
555 variable may be set to a format string that specifies how the timing
556 information should be displayed; see the description of
557 .SM
558 .B TIMEFORMAT
559 under
560 .B "Shell Variables"
561 below.
562 .PP
563 Each command in a pipeline is executed as a separate process (i.e., in a
564 subshell).
565 .SS Lists
566 .PP
567 A \fIlist\fP is a sequence of one or more pipelines separated by one
568 of the operators
569 .BR ; ,
570 .BR & ,
571 .BR && ,
572 or
573 .BR \(bv\(bv ,
574 and optionally terminated by one of
575 .BR ; ,
576 .BR & ,
577 or
578 .BR <newline> .
579 .PP
580 Of these list operators,
581 .B &&
582 and
583 .B \(bv\(bv
584 have equal precedence, followed by
585 .B ;
586 and
587 .BR & ,
588 which have equal precedence.
589 .PP
590 A sequence of one or more newlines may appear in a \fIlist\fP instead
591 of a semicolon to delimit commands.
592 .PP
593 If a command is terminated by the control operator
594 .BR & ,
595 the shell executes the command in the \fIbackground\fP
596 in a subshell.  The shell does not wait for the command to
597 finish, and the return status is 0.  Commands separated by a
598 .B ;
599 are executed sequentially; the shell waits for each
600 command to terminate in turn.  The return status is the
601 exit status of the last command executed.
602 .PP
603 AND and OR lists are sequences of one of more pipelines separated by the
604 \fB&&\fP and \fB\(bv\(bv\fP control operators, respectively.
605 AND and OR lists are executed with left associativity.
606 An AND list has the form
607 .RS
608 .PP
609 \fIcommand1\fP \fB&&\fP \fIcommand2\fP
610 .RE
611 .PP
612 .I command2
613 is executed if, and only if,
614 .I command1
615 returns an exit status of zero.
616 .PP
617 An OR list has the form
618 .RS
619 .PP
620 \fIcommand1\fP \fB\(bv\(bv\fP \fIcommand2\fP
621 .PP
622 .RE
623 .PP
624 .I command2
625 is executed if and only if
626 .I command1
627 returns a non-zero exit status.
628 The return status of
629 AND and OR lists is the exit status of the last command
630 executed in the list.
631 .SS Compound Commands
632 .PP
633 A \fIcompound command\fP is one of the following:
634 .TP
635 (\fIlist\fP)
636 \fIlist\fP is executed in a subshell environment (see
637 .SM
638 \fBCOMMAND EXECUTION ENVIRONMENT\fP
639 below).
640 Variable assignments and builtin
641 commands that affect the shell's environment do not remain in effect
642 after the command completes.  The return status is the exit status of
643 \fIlist\fP.
644 .TP
645 { \fIlist\fP; }
646 \fIlist\fP is simply executed in the current shell environment.
647 \fIlist\fP must be terminated with a newline or semicolon.
648 This is known as a \fIgroup command\fP.
649 The return status is the exit status of
650 \fIlist\fP.
651 Note that unlike the metacharacters \fB(\fP and \fB)\fP, \fB{\fP and
652 \fB}\fP are \fIreserved words\fP and must occur where a reserved
653 word is permitted to be recognized.  Since they do not cause a word
654 break, they must be separated from \fIlist\fP by whitespace or another
655 shell metacharacter.
656 .TP
657 ((\fIexpression\fP))
658 The \fIexpression\fP is evaluated according to the rules described
659 below under
660 .SM
661 .BR "ARITHMETIC EVALUATION" .
662 If the value of the expression is non-zero, the return status is 0;
663 otherwise the return status is 1.  This is exactly equivalent to
664 \fBlet "\fIexpression\fP"\fR.
665 .TP
666 \fB[[\fP \fIexpression\fP \fB]]\fP
667 Return a status of 0 or 1 depending on the evaluation of
668 the conditional expression \fIexpression\fP.
669 Expressions are composed of the primaries described below under
670 .SM
671 .BR "CONDITIONAL EXPRESSIONS" .
672 Word splitting and pathname expansion are not performed on the words
673 between the \fB[[\fP and \fB]]\fP; tilde expansion, parameter and
674 variable expansion, arithmetic expansion, command substitution, process
675 substitution, and quote removal are performed.
676 Conditional operators such as \fB\-f\fP must be unquoted to be recognized
677 as primaries.
678 .if t .sp 0.5
679 .if n .sp 1
680 When the \fB==\fP and \fB!=\fP operators are used, the string to the
681 right of the operator is considered a pattern and matched according
682 to the rules described below under \fBPattern Matching\fP.
683 If the shell option
684 .B nocasematch
685 is enabled, the match is performed without regard to the case
686 of alphabetic characters.
687 The return value is 0 if the string matches (\fB==\fP) or does not match
688 (\fB!=\fP) the pattern, and 1 otherwise.
689 Any part of the pattern may be quoted to force it to be matched as a
690 string.
691 .if t .sp 0.5
692 .if n .sp 1
693 An additional binary operator, \fB=~\fP, is available, with the same
694 precedence as \fB==\fP and \fB!=\fP.
695 When it is used, the string to the right of the operator is considered
696 an extended regular expression and matched accordingly (as in \fIregex\fP(3)).  
697 The return value is 0 if the string matches
698 the pattern, and 1 otherwise.
699 If the regular expression is syntactically incorrect, the conditional
700 expression's return value is 2.
701 If the shell option
702 .B nocasematch
703 is enabled, the match is performed without regard to the case
704 of alphabetic characters.
705 Any part of the pattern may be quoted to force it to be matched as a
706 string.
707 Substrings matched by parenthesized subexpressions within the regular
708 expression are saved in the array variable \fBBASH_REMATCH\fP.
709 The element of \fBBASH_REMATCH\fP with index 0 is the portion of the string
710 matching the entire regular expression.
711 The element of \fBBASH_REMATCH\fP with index \fIn\fP is the portion of the
712 string matching the \fIn\fPth parenthesized subexpression.
713 .if t .sp 0.5
714 .if n .sp 1
715 Expressions may be combined using the following operators, listed
716 in decreasing order of precedence:
717 .if t .sp 0.5
718 .if n .sp 1
719 .RS
720 .PD 0
721 .TP
722 .B ( \fIexpression\fP )
723 Returns the value of \fIexpression\fP.
724 This may be used to override the normal precedence of operators.
725 .TP
726 .B ! \fIexpression\fP
727 True if
728 .I expression
729 is false.
730 .TP
731 \fIexpression1\fP \fB&&\fP \fIexpression2\fP
732 True if both
733 .I expression1
734 and
735 .I expression2
736 are true.
737 .TP
738 .if t \fIexpression1\fP \fB\(bv\(bv\fP \fIexpression2\fP
739 .if n \fIexpression1\fP \fB||\fP \fIexpression2\fP
740 True if either
741 .I expression1
742 or
743 .I expression2
744 is true.
745 .PD
746 .LP
747 The \fB&&\fP and
748 .if t \fB\(bv\(bv\fP
749 .if n \fB||\fP
750 operators do not evaluate \fIexpression2\fP if the value of
751 \fIexpression1\fP is sufficient to determine the return value of
752 the entire conditional expression.
753 .RE
754 .TP
755 \fBfor\fP \fIname\fP [ \fBin\fP \fIword\fP ] ; \fBdo\fP \fIlist\fP ; \fBdone\fP
756 The list of words following \fBin\fP is expanded, generating a list
757 of items.
758 The variable \fIname\fP is set to each element of this list
759 in turn, and \fIlist\fP is executed each time.
760 If the \fBin\fP \fIword\fP is omitted, the \fBfor\fP command executes
761 \fIlist\fP once for each positional parameter that is set (see
762 .SM
763 .B PARAMETERS
764 below).
765 The return status is the exit status of the last command that executes.
766 If the expansion of the items following \fBin\fP results in an empty
767 list, no commands are executed, and the return status is 0.
768 .TP
769 \fBfor\fP (( \fIexpr1\fP ; \fIexpr2\fP ; \fIexpr3\fP )) ; \fBdo\fP \fIlist\fP ; \fBdone\fP
770 First, the arithmetic expression \fIexpr1\fP is evaluated according
771 to the rules described below under
772 .SM
773 .BR "ARITHMETIC EVALUATION" .
774 The arithmetic expression \fIexpr2\fP is then evaluated repeatedly
775 until it evaluates to zero.
776 Each time \fIexpr2\fP evaluates to a non-zero value, \fIlist\fP is
777 executed and the arithmetic expression \fIexpr3\fP is evaluated.
778 If any expression is omitted, it behaves as if it evaluates to 1.
779 The return value is the exit status of the last command in \fIlist\fP
780 that is executed, or false if any of the expressions is invalid.
781 .TP
782 \fBselect\fP \fIname\fP [ \fBin\fP \fIword\fP ] ; \fBdo\fP \fIlist\fP ; \fBdone\fP
783 The list of words following \fBin\fP is expanded, generating a list
784 of items.  The set of expanded words is printed on the standard
785 error, each preceded by a number.  If the \fBin\fP
786 \fIword\fP is omitted, the positional parameters are printed (see
787 .SM
788 .B PARAMETERS
789 below).  The
790 .B PS3
791 prompt is then displayed and a line read from the standard input.
792 If the line consists of a number corresponding to one of
793 the displayed words, then the value of
794 .I name
795 is set to that word.  If the line is empty, the words and prompt
796 are displayed again.  If EOF is read, the command completes.  Any
797 other value read causes
798 .I name
799 to be set to null.  The line read is saved in the variable
800 .BR REPLY .
801 The
802 .I list
803 is executed after each selection until a
804 .B break
805 command is executed.
806 The exit status of
807 .B select
808 is the exit status of the last command executed in
809 .IR list ,
810 or zero if no commands were executed.
811 .TP
812 \fBcase\fP \fIword\fP \fBin\fP [ [(] \fIpattern\fP [ \fB|\fP \fIpattern\fP ] \
813 ... ) \fIlist\fP ;; ] ... \fBesac\fP
814 A \fBcase\fP command first expands \fIword\fP, and tries to match
815 it against each \fIpattern\fP in turn, using the same matching rules
816 as for pathname expansion (see
817 .B Pathname Expansion
818 below).
819 The \fIword\fP is expanded using tilde
820 expansion, parameter and variable expansion, arithmetic substitution,
821 command substitution, process substitution and quote removal.
822 Each \fIpattern\fP examined is expanded using tilde
823 expansion, parameter and variable expansion, arithmetic substitution,
824 command substitution, and process substitution.
825 If the shell option
826 .B nocasematch
827 is enabled, the match is performed without regard to the case
828 of alphabetic characters.
829 When a match is found, the corresponding \fIlist\fP is executed.
830 If the \fB;;\fP operator is used, no subsequent matches are attempted after
831 the first pattern match.
832 Using \fB;&\fP in place of \fB;;\fP causes execution to continue with
833 the \fIlist\fP associated with the next set of patterns.
834 Using \fB;;&\fP in place of \fB;;\fP causes the shell to test the next
835 pattern list in the statement, if any, and execute any associated \fIlist\fP
836 on a successful match.
837 The exit status is zero if no
838 pattern matches.  Otherwise, it is the exit status of the
839 last command executed in \fIlist\fP.
840 .TP
841 \fBif\fP \fIlist\fP; \fBthen\fP \fIlist;\fP \
842 [ \fBelif\fP \fIlist\fP; \fBthen\fP \fIlist\fP; ] ... \
843 [ \fBelse\fP \fIlist\fP; ] \fBfi\fP
844 The
845 .B if 
846 .I list
847 is executed.  If its exit status is zero, the
848 \fBthen\fP \fIlist\fP is executed.  Otherwise, each \fBelif\fP
849 \fIlist\fP is executed in turn, and if its exit status is zero,
850 the corresponding \fBthen\fP \fIlist\fP is executed and the
851 command completes.  Otherwise, the \fBelse\fP \fIlist\fP is
852 executed, if present.  The exit status is the exit status of the
853 last command executed, or zero if no condition tested true.
854 .TP
855 \fBwhile\fP \fIlist\fP; \fBdo\fP \fIlist\fP; \fBdone\fP
856 .PD 0
857 .TP
858 \fBuntil\fP \fIlist\fP; \fBdo\fP \fIlist\fP; \fBdone\fP
859 .PD
860 The \fBwhile\fP command continuously executes the \fBdo\fP
861 \fIlist\fP as long as the last command in \fIlist\fP returns
862 an exit status of zero.  The \fBuntil\fP command is identical
863 to the \fBwhile\fP command, except that the test is negated;
864 the
865 .B do
866 .I list
867 is executed as long as the last command in
868 .I list
869 returns a non-zero exit status.
870 The exit status of the \fBwhile\fP and \fBuntil\fP commands
871 is the exit status
872 of the last \fBdo\fP \fIlist\fP command executed, or zero if
873 none was executed.
874 .SS Coprocesses
875 .PP
876 A \fIcoprocess\fP is a shell command preceded by the \fBcoproc\fP reserved
877 word.
878 A coprocess is executed asynchronously in a subshell, as if the command
879 had been terminated with the \fB&\fP control operator, with a two-way pipe
880 established between the executing shell and the coprocess.
881 .PP
882 The format for a coprocess is:
883 .RS
884 .PP
885 \fBcoproc\fP [\fINAME\fP] \fIcommand\fP [\fIredirections\fP]
886 .RE
887 .PP
888 This creates a coprocess named \fINAME\fP.
889 If \fINAME\fP is not supplied, the default name is \fICOPROC\fP.
890 \fINAME\fP must not be supplied if \fIcommand\fP is a \fIsimple
891 command\fP (see above); otherwise, it is interpreted as the first word
892 of the simple command.
893 When the coproc is executed, the shell creates an array variable (see
894 .B Arrays
895 below) named \fINAME\fP in the context of the executing shell.
896 The standard output of
897 .I command
898 is connected via a pipe to a file descriptor in the executing shell,
899 and that file descriptor is assigned to \fINAME\fP[0].
900 The standard input of
901 .I command
902 is connected via a pipe to a file descriptor in the executing shell,
903 and that file descriptor is assigned to \fINAME\fP[1].
904 This pipe is established before any redirections specified by the
905 command (see
906 .SM
907 .B REDIRECTION
908 below).
909 The file descriptors can be utilized as arguments to shell commands
910 and redirections using standard word expansions.
911 The process id of the shell spawned to execute the coprocess is
912 available as the value of the variable \fINAME\fP_PID.
913 The \fBwait\fP
914 builtin command may be used to wait for the coprocess to terminate.
915 .PP
916 The return status of a coprocess is the exit status of \fIcommand\fP.
917 .SS Shell Function Definitions
918 .PP
919 A shell function is an object that is called like a simple command and
920 executes a compound command with a new set of positional parameters.
921 Shell functions are declared as follows:
922 .TP
923 [ \fBfunction\fP ] \fIname\fP () \fIcompound\-command\fP [\fIredirection\fP]
924 This defines a function named \fIname\fP.
925 The reserved word \fBfunction\fP is optional.
926 If the \fBfunction\fP reserved word is supplied, the parentheses are optional.
927 The \fIbody\fP of the function is the compound command
928 .I compound\-command 
929 (see \fBCompound Commands\fP above).
930 That command is usually a \fIlist\fP of commands between { and }, but
931 may be any command listed under \fBCompound Commands\fP above.
932 \fIcompound\-command\fP is executed whenever \fIname\fP is specified as the
933 name of a simple command.
934 Any redirections (see
935 .SM
936 .B REDIRECTION
937 below) specified when a function is defined are performed
938 when the function is executed.
939 The exit status of a function definition is zero unless a syntax error
940 occurs or a readonly function with the same name already exists.
941 When executed, the exit status of a function is the exit status of the
942 last command executed in the body.  (See
943 .SM
944 .B FUNCTIONS
945 below.)
946 .SH COMMENTS
947 In a non-interactive shell, or an interactive shell in which the
948 .B interactive_comments
949 option to the
950 .B shopt
951 builtin is enabled (see
952 .SM
953 .B "SHELL BUILTIN COMMANDS"
954 below), a word beginning with
955 .B #
956 causes that word and all remaining characters on that line to
957 be ignored.  An interactive shell without the
958 .B interactive_comments
959 option enabled does not allow comments.  The
960 .B interactive_comments
961 option is on by default in interactive shells.
962 .SH QUOTING
963 \fIQuoting\fP is used to remove the special meaning of certain
964 characters or words to the shell.  Quoting can be used to 
965 disable special treatment for special characters, to prevent
966 reserved words from being recognized as such, and to prevent
967 parameter expansion.
968 .PP
969 Each of the \fImetacharacters\fP listed above under
970 .SM
971 .B DEFINITIONS
972 has special meaning to the shell and must be quoted if it is to
973 represent itself.
974 .PP
975 When the command history expansion facilities are being used
976 (see
977 .SM
978 .B HISTORY EXPANSION
979 below), the
980 \fIhistory expansion\fP character, usually \fB!\fP, must be quoted
981 to prevent history expansion.
982 .PP
983 There are three quoting mechanisms: the
984 .IR "escape character" ,
985 single quotes, and double quotes.
986 .PP
987 A non-quoted backslash (\fB\e\fP) is the
988 .IR "escape character" .
989 It preserves the literal value of the next character that follows,
990 with the exception of <newline>.  If a \fB\e\fP<newline> pair
991 appears, and the backslash is not itself quoted, the \fB\e\fP<newline>
992 is treated as a line continuation (that is, it is removed from the
993 input stream and effectively ignored).
994 .PP
995 Enclosing characters in single quotes preserves the literal value
996 of each character within the quotes.  A single quote may not occur
997 between single quotes, even when preceded by a backslash.
998 .PP
999 Enclosing characters in double quotes preserves the literal value
1000 of all characters within the quotes, with the exception of
1001 .BR $ ,
1002 .BR \` ,
1003 .BR \e ,
1004 and, when history expansion is enabled,
1005 .BR ! .
1006 The characters
1007 .B $
1008 and
1009 .B \`
1010 retain their special meaning within double quotes.  The backslash
1011 retains its special meaning only when followed by one of the following
1012 characters:
1013 .BR $ ,
1014 .BR \` ,
1015 \^\fB"\fP\^,
1016 .BR \e ,
1017 or
1018 .BR <newline> .
1019 A double quote may be quoted within double quotes by preceding it with
1020 a backslash.
1021 If enabled, history expansion will be performed unless an
1022 .B !
1023 appearing in double quotes is escaped using a backslash.
1024 The backslash preceding the
1025 .B !
1026 is not removed.
1027 .PP
1028 The special parameters
1029 .B *
1030 and
1031 .B @
1032 have special meaning when in double
1033 quotes (see
1034 .SM
1035 .B PARAMETERS
1036 below).
1037 .PP
1038 Words of the form \fB$\fP\(aq\fIstring\fP\(aq are treated specially.  The
1039 word expands to \fIstring\fP, with backslash-escaped characters replaced
1040 as specified by the ANSI C standard.  Backslash escape sequences, if
1041 present, are decoded as follows:
1042 .RS
1043 .PD 0
1044 .TP
1045 .B \ea
1046 alert (bell)
1047 .TP
1048 .B \eb
1049 backspace
1050 .TP
1051 .B \ee
1052 an escape character
1053 .TP   
1054 .B \ef
1055 form feed
1056 .TP  
1057 .B \en
1058 new line
1059 .TP     
1060 .B \er
1061 carriage return
1062 .TP
1063 .B \et
1064 horizontal tab
1065 .TP   
1066 .B \ev
1067 vertical tab
1068 .TP
1069 .B \e\e
1070 backslash
1071 .TP
1072 .B \e\(aq
1073 single quote
1074 .TP   
1075 .B \e\fInnn\fP
1076 the eight-bit character whose value is the octal value \fInnn\fP
1077 (one to three digits)
1078 .TP
1079 .B \ex\fIHH\fP
1080 the eight-bit character whose value is the hexadecimal value \fIHH\fP
1081 (one or two hex digits)
1082 .TP
1083 .B \ec\fIx\fP
1084 a control-\fIx\fP character
1085 .PD
1086 .RE
1087 .LP
1088 The expanded result is single-quoted, as if the dollar sign had
1089 not been present.
1090 .PP
1091 A double-quoted string preceded by a dollar sign (\fB$\fP) will cause
1092 the string to be translated according to the current locale.
1093 If the current locale is \fBC\fP or \fBPOSIX\fP, the dollar sign
1094 is ignored.
1095 If the string is translated and replaced, the replacement is
1096 double-quoted.
1097 .SH PARAMETERS
1098 A
1099 .I parameter
1100 is an entity that stores values.
1101 It can be a
1102 .IR name ,
1103 a number, or one of the special characters listed below under
1104 .BR "Special Parameters" .
1105 A
1106 .I variable
1107 is a parameter denoted by a
1108 .IR name .
1109 A variable has a \fIvalue\fP and zero or more \fIattributes\fP.
1110 Attributes are assigned using the
1111 .B declare
1112 builtin command (see
1113 .B declare
1114 below in
1115 .SM
1116 .BR "SHELL BUILTIN COMMANDS" ).
1117 .PP
1118 A parameter is set if it has been assigned a value.  The null string is
1119 a valid value.  Once a variable is set, it may be unset only by using
1120 the
1121 .B unset
1122 builtin command (see
1123 .SM
1124 .B SHELL BUILTIN COMMANDS
1125 below).
1126 .PP
1127 A
1128 .I variable
1129 may be assigned to by a statement of the form
1130 .RS
1131 .PP
1132 \fIname\fP=[\fIvalue\fP]
1133 .RE
1134 .PP
1135 If
1136 .I value
1137 is not given, the variable is assigned the null string.  All
1138 .I values
1139 undergo tilde expansion, parameter and variable expansion,
1140 command substitution, arithmetic expansion, and quote
1141 removal (see
1142 .SM
1143 .B EXPANSION
1144 below).  If the variable has its
1145 .B integer
1146 attribute set, then
1147 .I value
1148 is evaluated as an arithmetic expression even if the $((...)) expansion is
1149 not used (see
1150 .B "Arithmetic Expansion"
1151 below).
1152 Word splitting is not performed, with the exception
1153 of \fB"$@"\fP as explained below under
1154 .BR "Special Parameters" .
1155 Pathname expansion is not performed.
1156 Assignment statements may also appear as arguments to the
1157 .BR alias ,
1158 .BR declare ,
1159 .BR typeset ,
1160 .BR export ,
1161 .BR readonly ,
1162 and
1163 .B local
1164 builtin commands.
1165 .PP
1166 In the context where an assignment statement is assigning a value
1167 to a shell variable or array index, the += operator can be used to
1168 append to or add to the variable's previous value.
1169 When += is applied to a variable for which the integer attribute has been
1170 set, \fIvalue\fP is evaluated as an arithmetic expression and added to the
1171 variable's current value, which is also evaluated.
1172 When += is applied to an array variable using compound assignment (see
1173 .B Arrays
1174 below), the
1175 variable's value is not unset (as it is when using =), and new values are
1176 appended to the array beginning at one greater than the array's maximum index
1177 (for indexed arrays) or added as additional key\-value pairs in an
1178 associative array.
1179 When applied to a string-valued variable, \fIvalue\fP is expanded and
1180 appended to the variable's value.
1181 .SS Positional Parameters
1182 .PP
1183 A
1184 .I positional parameter
1185 is a parameter denoted by one or more
1186 digits, other than the single digit 0.  Positional parameters are
1187 assigned from the shell's arguments when it is invoked,
1188 and may be reassigned using the
1189 .B set
1190 builtin command.  Positional parameters may not be assigned to
1191 with assignment statements.  The positional parameters are
1192 temporarily replaced when a shell function is executed (see
1193 .SM
1194 .B FUNCTIONS
1195 below).
1196 .PP
1197 When a positional parameter consisting of more than a single
1198 digit is expanded, it must be enclosed in braces (see
1199 .SM
1200 .B EXPANSION
1201 below).
1202 .SS Special Parameters
1203 .PP
1204 The shell treats several parameters specially.  These parameters may
1205 only be referenced; assignment to them is not allowed.
1206 .PD 0
1207 .TP
1208 .B *
1209 Expands to the positional parameters, starting from one.  When the
1210 expansion occurs within double quotes, it expands to a single word
1211 with the value of each parameter separated by the first character
1212 of the 
1213 .SM
1214 .B IFS
1215 special variable.  That is, "\fB$*\fP" is equivalent
1216 to "\fB$1\fP\fIc\fP\fB$2\fP\fIc\fP\fB...\fP", where
1217 .I c
1218 is the first character of the value of the
1219 .SM
1220 .B IFS
1221 variable.  If
1222 .SM
1223 .B IFS
1224 is unset, the parameters are separated by spaces.
1225 If
1226 .SM
1227 .B IFS
1228 is null, the parameters are joined without intervening separators.
1229 .TP
1230 .B @
1231 Expands to the positional parameters, starting from one.  When the
1232 expansion occurs within double quotes, each parameter expands to a
1233 separate word.  That is, "\fB$@\fP" is equivalent to
1234 "\fB$1\fP" "\fB$2\fP" ...
1235 If the double-quoted expansion occurs within a word, the expansion of
1236 the first parameter is joined with the beginning part of the original
1237 word, and the expansion of the last parameter is joined with the last
1238 part of the original word.
1239 When there are no positional parameters, "\fB$@\fP" and 
1240 .B $@
1241 expand to nothing (i.e., they are removed).
1242 .TP
1243 .B #
1244 Expands to the number of positional parameters in decimal.
1245 .TP
1246 .B ?
1247 Expands to the exit status of the most recently executed foreground
1248 pipeline.
1249 .TP
1250 .B \-
1251 Expands to the current option flags as specified upon invocation, 
1252 by the
1253 .B set
1254 builtin command, or those set by the shell itself
1255 (such as the
1256 .B \-i
1257 option).
1258 .TP
1259 .B $
1260 Expands to the process ID of the shell.  In a () subshell, it
1261 expands to the process ID of the current shell, not the
1262 subshell.
1263 .TP
1264 .B !
1265 Expands to the process ID of the most recently executed background
1266 (asynchronous) command.
1267 .TP
1268 .B 0
1269 Expands to the name of the shell or shell script.  This is set at
1270 shell initialization.  If
1271 .B bash
1272 is invoked with a file of commands,
1273 .B $0
1274 is set to the name of that file.  If
1275 .B bash
1276 is started with the
1277 .B \-c
1278 option, then
1279 .B $0
1280 is set to the first argument after the string to be
1281 executed, if one is present.  Otherwise, it is set
1282 to the file name used to invoke
1283 .BR bash ,
1284 as given by argument zero.
1285 .TP
1286 .B _
1287 At shell startup, set to the absolute pathname used to invoke the
1288 shell or shell script being executed as passed in the environment
1289 or argument list.
1290 Subsequently, expands to the last argument to the previous command,
1291 after expansion.
1292 Also set to the full pathname used to invoke each command executed
1293 and placed in the environment exported to that command.
1294 When checking mail, this parameter holds the name of the mail file
1295 currently being checked.
1296 .PD
1297 .SS Shell Variables
1298 .PP
1299 The following variables are set by the shell:
1300 .PP
1301 .PD 0
1302 .TP
1303 .B BASH
1304 Expands to the full file name used to invoke this instance of
1305 .BR bash .
1306 .TP
1307 .B BASHPID
1308 Expands to the process id of the current \fBbash\fP process.
1309 This differs from \fB$$\fP under certain circumstances, such as subshells
1310 that do not require \fBbash\fP to be re-initialized.
1311 .TP
1312 .B BASH_ALIASES
1313 An associative array variable whose members correspond to the internal
1314 list of aliases as maintained by the \fBalias\fP builtin
1315 Elements added to this array appear in the alias list; unsetting array
1316 elements cause aliases to be removed from the alias list.
1317 .TP
1318 .B BASH_ARGC
1319 An array variable whose values are the number of parameters in each
1320 frame of the current \fBbash\fP execution call stack.
1321 The number of
1322 parameters to the current subroutine (shell function or script executed
1323 with \fB.\fP or \fBsource\fP) is at the top of the stack.
1324 When a subroutine is executed, the number of parameters passed is pushed onto
1325 \fBBASH_ARGC\fP.
1326 The shell sets \fBBASH_ARGC\fP only when in extended debugging mode
1327 (see the description of the
1328 .B extdebug
1329 option to the
1330 .B shopt
1331 builtin below)
1332 .TP
1333 .B BASH_ARGV
1334 An array variable containing all of the parameters in the current \fBbash\fP
1335 execution call stack.  The final parameter of the last subroutine call
1336 is at the top of the stack; the first parameter of the initial call is
1337 at the bottom.  When a subroutine is executed, the parameters supplied
1338 are pushed onto \fBBASH_ARGV\fP.
1339 The shell sets \fBBASH_ARGV\fP only when in extended debugging mode
1340 (see the description of the
1341 .B extdebug
1342 option to the
1343 .B shopt
1344 builtin below)
1345 .TP
1346 .B BASH_CMDS
1347 An associative array variable whose members correspond to the internal
1348 hash table of commands as maintained by the \fBhash\fP builtin.
1349 Elements added to this array appear in the hash table; unsetting array
1350 elements cause commands to be removed from the hash table.
1351 .TP
1352 .B BASH_COMMAND
1353 The command currently being executed or about to be executed, unless the
1354 shell is executing a command as the result of a trap,
1355 in which case it is the command executing at the time of the trap.
1356 .TP
1357 .B BASH_EXECUTION_STRING
1358 The command argument to the \fB\-c\fP invocation option.
1359 .TP
1360 .B BASH_LINENO
1361 An array variable whose members are the line numbers in source files
1362 corresponding to each member of \fBFUNCNAME\fP.
1363 \fB${BASH_LINENO[\fP\fI$i\fP\fB]}\fP is the line number in the source
1364 file where \fB${FUNCNAME[\fP\fI$i\fP\fB]}\fP was called
1365 (or \fB${BASH_LINENO[\fP\fI$i-1\fP\fB]}\fP if referenced within another
1366 shell function).
1367 The corresponding source file name is \fB${BASH_SOURCE[\fP\fI$i\fP\fB]}\fP.
1368 Use \fBLINENO\fP to obtain the current line number.
1369 .TP
1370 .B BASH_REMATCH
1371 An array variable whose members are assigned by the \fB=~\fP binary
1372 operator to the \fB[[\fP conditional command.
1373 The element with index 0 is the portion of the string
1374 matching the entire regular expression.
1375 The element with index \fIn\fP is the portion of the
1376 string matching the \fIn\fPth parenthesized subexpression.
1377 This variable is read-only.
1378 .TP
1379 .B BASH_SOURCE
1380 An array variable whose members are the source filenames corresponding
1381 to the elements in the \fBFUNCNAME\fP array variable.
1382 .TP
1383 .B BASH_SUBSHELL
1384 Incremented by one each time a subshell or subshell environment is spawned.
1385 The initial value is 0.
1386 .TP
1387 .B BASH_VERSINFO
1388 A readonly array variable whose members hold version information for
1389 this instance of
1390 .BR bash .
1391 The values assigned to the array members are as follows:
1392 .sp .5
1393 .RS
1394 .PD 0
1395 .TP 24
1396 .B BASH_VERSINFO[\fR0\fP]
1397 The major version number (the \fIrelease\fP).
1398 .TP
1399 .B BASH_VERSINFO[\fR1\fP]
1400 The minor version number (the \fIversion\fP).
1401 .TP
1402 .B BASH_VERSINFO[\fR2\fP]
1403 The patch level.
1404 .TP
1405 .B BASH_VERSINFO[\fR3\fP]
1406 The build version.
1407 .TP
1408 .B BASH_VERSINFO[\fR4\fP]
1409 The release status (e.g., \fIbeta1\fP).
1410 .TP
1411 .B BASH_VERSINFO[\fR5\fP]
1412 The value of \fBMACHTYPE\fP.
1413 .PD
1414 .RE
1415 .TP
1416 .B BASH_VERSION
1417 Expands to a string describing the version of this instance of
1418 .BR bash .
1419 .TP
1420 .B COMP_CWORD
1421 An index into \fB${COMP_WORDS}\fP of the word containing the current
1422 cursor position.
1423 This variable is available only in shell functions invoked by the
1424 programmable completion facilities (see \fBProgrammable Completion\fP
1425 below).
1426 .TP
1427 .B COMP_KEY
1428 The key (or final key of a key sequence) used to invoke the current
1429 completion function.
1430 .TP
1431 .B COMP_LINE
1432 The current command line.
1433 This variable is available only in shell functions and external
1434 commands invoked by the
1435 programmable completion facilities (see \fBProgrammable Completion\fP
1436 below).
1437 .TP
1438 .B COMP_POINT
1439 The index of the current cursor position relative to the beginning of
1440 the current command.
1441 If the current cursor position is at the end of the current command,
1442 the value of this variable is equal to \fB${#COMP_LINE}\fP.
1443 This variable is available only in shell functions and external
1444 commands invoked by the
1445 programmable completion facilities (see \fBProgrammable Completion\fP
1446 below).
1447 .TP
1448 .B COMP_TYPE
1449 Set to an integer value corresponding to the type of completion attempted
1450 that caused a completion function to be called:
1451 \fITAB\fP, for normal completion,
1452 \fI?\fP, for listing completions after successive tabs,
1453 \fI!\fP, for listing alternatives on partial word completion,
1454 \fI@\fP, to list completions if the word is not unmodified,
1455 or
1456 \fI%\fP, for menu completion.
1457 This variable is available only in shell functions and external
1458 commands invoked by the
1459 programmable completion facilities (see \fBProgrammable Completion\fP
1460 below).
1461 .TP
1462 .B COMP_WORDBREAKS
1463 The set of characters that the \fBreadline\fP library treats as word
1464 separators when performing word completion.
1465 If
1466 .SM
1467 .B COMP_WORDBREAKS
1468 is unset, it loses its special properties, even if it is
1469 subsequently reset.
1470 .TP
1471 .B COMP_WORDS
1472 An array variable (see \fBArrays\fP below) consisting of the individual
1473 words in the current command line.
1474 The line is split into words as \fBreadline\fP would split it, using
1475 \fBCOMP_WORDBREAKS\fP as described above.
1476 This variable is available only in shell functions invoked by the
1477 programmable completion facilities (see \fBProgrammable Completion\fP
1478 below).
1479 .TP
1480 .B DIRSTACK
1481 An array variable (see
1482 .B Arrays
1483 below) containing the current contents of the directory stack.
1484 Directories appear in the stack in the order they are displayed by the
1485 .B dirs
1486 builtin.
1487 Assigning to members of this array variable may be used to modify
1488 directories already in the stack, but the
1489 .B pushd
1490 and
1491 .B popd
1492 builtins must be used to add and remove directories.
1493 Assignment to this variable will not change the current directory.
1494 If
1495 .SM
1496 .B DIRSTACK
1497 is unset, it loses its special properties, even if it is
1498 subsequently reset.
1499 .TP
1500 .B EUID
1501 Expands to the effective user ID of the current user, initialized at
1502 shell startup.  This variable is readonly.
1503 .TP
1504 .B FUNCNAME
1505 An array variable containing the names of all shell functions
1506 currently in the execution call stack.
1507 The element with index 0 is the name of any currently-executing
1508 shell function.
1509 The bottom-most element is
1510 .if t \f(CW"main"\fP.
1511 .if n "main".
1512 This variable exists only when a shell function is executing.
1513 Assignments to
1514 .SM
1515 .B FUNCNAME
1516 have no effect and return an error status.
1517 If
1518 .SM
1519 .B FUNCNAME
1520 is unset, it loses its special properties, even if it is
1521 subsequently reset.
1522 .TP
1523 .B GROUPS
1524 An array variable containing the list of groups of which the current
1525 user is a member.
1526 Assignments to    
1527 .SM
1528 .B GROUPS
1529 have no effect and return an error status.
1530 If
1531 .SM
1532 .B GROUPS
1533 is unset, it loses its special properties, even if it is
1534 subsequently reset.
1535 .TP
1536 .B HISTCMD
1537 The history number, or index in the history list, of the current
1538 command.
1539 If
1540 .SM
1541 .B HISTCMD
1542 is unset, it loses its special properties, even if it is
1543 subsequently reset.
1544 .TP
1545 .B HOSTNAME
1546 Automatically set to the name of the current host.
1547 .TP
1548 .B HOSTTYPE
1549 Automatically set to a string that uniquely
1550 describes the type of machine on which
1551 .B bash
1552 is executing.
1553 The default is system-dependent.
1554 .TP
1555 .B LINENO
1556 Each time this parameter is referenced, the shell substitutes
1557 a decimal number representing the current sequential line number
1558 (starting with 1) within a script or function.  When not in a
1559 script or function, the value substituted is not guaranteed to
1560 be meaningful.
1561 If
1562 .SM
1563 .B LINENO
1564 is unset, it loses its special properties, even if it is
1565 subsequently reset.
1566 .TP
1567 .B MACHTYPE
1568 Automatically set to a string that fully describes the system
1569 type on which
1570 .B bash
1571 is executing, in the standard GNU \fIcpu-company-system\fP format.
1572 The default is system-dependent.
1573 .TP
1574 .B OLDPWD
1575 The previous working directory as set by the
1576 .B cd
1577 command.
1578 .TP
1579 .B OPTARG
1580 The value of the last option argument processed by the
1581 .B getopts
1582 builtin command (see
1583 .SM
1584 .B SHELL BUILTIN COMMANDS
1585 below).
1586 .TP
1587 .B OPTIND
1588 The index of the next argument to be processed by the
1589 .B getopts
1590 builtin command (see
1591 .SM
1592 .B SHELL BUILTIN COMMANDS
1593 below).
1594 .TP
1595 .B OSTYPE
1596 Automatically set to a string that
1597 describes the operating system on which
1598 .B bash
1599 is executing.
1600 The default is system-dependent.
1601 .TP
1602 .B PIPESTATUS
1603 An array variable (see
1604 .B Arrays
1605 below) containing a list of exit status values from the processes
1606 in the most-recently-executed foreground pipeline (which may
1607 contain only a single command).
1608 .TP
1609 .B PPID
1610 The process ID of the shell's parent.  This variable is readonly.
1611 .TP
1612 .B PWD
1613 The current working directory as set by the
1614 .B cd
1615 command.
1616 .TP
1617 .B RANDOM
1618 Each time this parameter is referenced, a random integer between
1619 0 and 32767 is
1620 generated.  The sequence of random numbers may be initialized by assigning
1621 a value to
1622 .SM
1623 .BR RANDOM .
1624 If
1625 .SM
1626 .B RANDOM
1627 is unset, it loses its special properties, even if it is
1628 subsequently reset.
1629 .TP
1630 .B REPLY
1631 Set to the line of input read by the
1632 .B read
1633 builtin command when no arguments are supplied.
1634 .TP
1635 .B SECONDS
1636 Each time this parameter is
1637 referenced, the number of seconds since shell invocation is returned.  If a
1638 value is assigned to 
1639 .SM
1640 .BR SECONDS ,
1641 the value returned upon subsequent
1642 references is
1643 the number of seconds since the assignment plus the value assigned.
1644 If
1645 .SM
1646 .B SECONDS
1647 is unset, it loses its special properties, even if it is
1648 subsequently reset.
1649 .TP
1650 .B SHELLOPTS
1651 A colon-separated list of enabled shell options.  Each word in
1652 the list is a valid argument for the
1653 .B \-o
1654 option to the
1655 .B set
1656 builtin command (see
1657 .SM
1658 .B "SHELL BUILTIN COMMANDS"
1659 below).  The options appearing in
1660 .SM
1661 .B SHELLOPTS
1662 are those reported as
1663 .I on
1664 by \fBset \-o\fP.
1665 If this variable is in the environment when
1666 .B bash
1667 starts up, each shell option in the list will be enabled before
1668 reading any startup files.
1669 This variable is read-only.
1670 .TP
1671 .B SHLVL
1672 Incremented by one each time an instance of
1673 .B bash
1674 is started.
1675 .TP
1676 .B UID
1677 Expands to the user ID of the current user, initialized at shell startup.
1678 This variable is readonly.
1679 .PD
1680 .PP
1681 The following variables are used by the shell.  In some cases,
1682 .B bash
1683 assigns a default value to a variable; these cases are noted
1684 below.
1685 .PP
1686 .PD 0
1687 .TP
1688 .B BASH_ENV
1689 If this parameter is set when \fBbash\fP is executing a shell script,
1690 its value is interpreted as a filename containing commands to
1691 initialize the shell, as in
1692 .IR ~/.bashrc .
1693 The value of
1694 .SM
1695 .B BASH_ENV
1696 is subjected to parameter expansion, command substitution, and arithmetic
1697 expansion before being interpreted as a file name.
1698 .SM
1699 .B PATH
1700 is not used to search for the resultant file name.
1701 .TP
1702 .B CDPATH
1703 The search path for the
1704 .B cd
1705 command.
1706 This is a colon-separated list of directories in which the shell looks
1707 for destination directories specified by the
1708 .B cd
1709 command.
1710 A sample value is
1711 .if t \f(CW".:~:/usr"\fP.
1712 .if n ".:~:/usr".
1713 .TP
1714 .B COLUMNS
1715 Used by the \fBselect\fP builtin command to determine the terminal width
1716 when printing selection lists.  Automatically set upon receipt of a SIGWINCH.
1717 .TP
1718 .B COMPREPLY
1719 An array variable from which \fBbash\fP reads the possible completions
1720 generated by a shell function invoked by the programmable completion
1721 facility (see \fBProgrammable Completion\fP below).
1722 .TP
1723 .B EMACS
1724 If \fBbash\fP finds this variable in the environment when the shell starts
1725 with value
1726 .if t \f(CWt\fP,
1727 .if n "t",
1728 it assumes that the shell is running in an emacs shell buffer and disables
1729 line editing.
1730 .TP
1731 .B FCEDIT
1732 The default editor for the
1733 .B fc
1734 builtin command.
1735 .TP
1736 .B FIGNORE
1737 A colon-separated list of suffixes to ignore when performing
1738 filename completion (see
1739 .SM
1740 .B READLINE
1741 below).
1742 A filename whose suffix matches one of the entries in 
1743 .SM
1744 .B FIGNORE
1745 is excluded from the list of matched filenames.
1746 A sample value is
1747 .if t \f(CW".o:~"\fP.
1748 .if n ".o:~".
1749 .TP
1750 .B GLOBIGNORE
1751 A colon-separated list of patterns defining the set of filenames to
1752 be ignored by pathname expansion.
1753 If a filename matched by a pathname expansion pattern also matches one
1754 of the patterns in
1755 .SM
1756 .BR GLOBIGNORE ,
1757 it is removed from the list of matches.
1758 .TP
1759 .B HISTCONTROL
1760 A colon-separated list of values controlling how commands are saved on
1761 the history list.
1762 If the list of values includes
1763 .IR ignorespace ,
1764 lines which begin with a
1765 .B space
1766 character are not saved in the history list.
1767 A value of 
1768 .I ignoredups
1769 causes lines matching the previous history entry to not be saved.
1770 A value of
1771 .I ignoreboth
1772 is shorthand for \fIignorespace\fP and \fIignoredups\fP.
1773 A value of
1774 .IR erasedups
1775 causes all previous lines matching the current line to be removed from
1776 the history list before that line is saved.
1777 Any value not in the above list is ignored.
1778 If \fBHISTCONTROL\fP is unset, or does not include a valid value,
1779 all lines read by the shell parser are saved on the history list,
1780 subject to the value of
1781 .BR HISTIGNORE .
1782 The second and subsequent lines of a multi-line compound command are
1783 not tested, and are added to the history regardless of the value of
1784 .BR HISTCONTROL .
1785 .TP
1786 .B HISTFILE
1787 The name of the file in which command history is saved (see
1788 .SM
1789 .B HISTORY
1790 below).  The default value is \fI~/.bash_history\fP.  If unset, the
1791 command history is not saved when an interactive shell exits.
1792 .TP
1793 .B HISTFILESIZE
1794 The maximum number of lines contained in the history file.  When this
1795 variable is assigned a value, the history file is truncated, if
1796 necessary, by removing the oldest entries,
1797 to contain no more than that number of lines.  The default
1798 value is 500.  The history file is also truncated to this size after
1799 writing it when an interactive shell exits.
1800 .TP
1801 .B HISTIGNORE
1802 A colon-separated list of patterns used to decide which command lines
1803 should be saved on the history list.  Each pattern is anchored at the
1804 beginning of the line and must match the complete line (no implicit
1805 `\fB*\fP' is appended).  Each pattern is tested against the line
1806 after the checks specified by
1807 .B HISTCONTROL
1808 are applied.
1809 In addition to the normal shell pattern matching characters, `\fB&\fP'
1810 matches the previous history line.  `\fB&\fP' may be escaped using a
1811 backslash; the backslash is removed before attempting a match.
1812 The second and subsequent lines of a multi-line compound command are
1813 not tested, and are added to the history regardless of the value of
1814 .BR HISTIGNORE .
1815 .TP
1816 .B HISTSIZE
1817 The number of commands to remember in the command history (see
1818 .SM
1819 .B HISTORY
1820 below).  The default value is 500.
1821 .TP
1822 .B HISTTIMEFORMAT
1823 If this variable is set and not null, its value is used as a format string
1824 for \fIstrftime\fP(3) to print the time stamp associated with each history
1825 entry displayed by the \fBhistory\fP builtin.
1826 If this variable is set, time stamps are written to the history file so
1827 they may be preserved across shell sessions.
1828 This uses the history comment character to distinguish timestamps from
1829 other history lines.
1830 .TP
1831 .B HOME
1832 The home directory of the current user; the default argument for the
1833 \fBcd\fP builtin command.
1834 The value of this variable is also used when performing tilde expansion.
1835 .TP
1836 .B HOSTFILE
1837 Contains the name of a file in the same format as
1838 .FN /etc/hosts
1839 that should be read when the shell needs to complete a
1840 hostname.
1841 The list of possible hostname completions may be changed while the
1842 shell is running;
1843 the next time hostname completion is attempted after the
1844 value is changed,
1845 .B bash
1846 adds the contents of the new file to the existing list.
1847 If
1848 .SM
1849 .B HOSTFILE
1850 is set, but has no value, \fBbash\fP attempts to read
1851 .FN /etc/hosts
1852 to obtain the list of possible hostname completions.
1853 When
1854 .SM
1855 .B HOSTFILE
1856 is unset, the hostname list is cleared.
1857 .TP
1858 .B IFS
1859 The
1860 .I Internal Field Separator
1861 that is used
1862 for word splitting after expansion and to
1863 split lines into words with the
1864 .B read
1865 builtin command.  The default value is
1866 ``<space><tab><newline>''.
1867 .TP
1868 .B IGNOREEOF
1869 Controls the
1870 action of an interactive shell on receipt of an
1871 .SM
1872 .B EOF
1873 character as the sole input.  If set, the value is the number of
1874 consecutive
1875 .SM
1876 .B EOF
1877 characters which must be
1878 typed as the first characters on an input line before
1879 .B bash
1880 exits.  If the variable exists but does not have a numeric value, or
1881 has no value, the default value is 10.  If it does not exist,
1882 .SM
1883 .B EOF
1884 signifies the end of input to the shell.
1885 .TP
1886 .B INPUTRC
1887 The filename for the
1888 .B readline
1889 startup file, overriding the default of
1890 .FN ~/.inputrc
1891 (see
1892 .SM
1893 .B READLINE
1894 below).
1895 .TP
1896 .B LANG
1897 Used to determine the locale category for any category not specifically
1898 selected with a variable starting with \fBLC_\fP.
1899 .TP
1900 .B LC_ALL
1901 This variable overrides the value of \fBLANG\fP and any other
1902 \fBLC_\fP variable specifying a locale category.
1903 .TP
1904 .B LC_COLLATE
1905 This variable determines the collation order used when sorting the
1906 results of pathname expansion, and determines the behavior of range
1907 expressions, equivalence classes, and collating sequences within
1908 pathname expansion and pattern matching.
1909 .TP
1910 .B LC_CTYPE
1911 This variable determines the interpretation of characters and the
1912 behavior of character classes within pathname expansion and pattern
1913 matching.
1914 .TP
1915 .B LC_MESSAGES
1916 This variable determines the locale used to translate double-quoted
1917 strings preceded by a \fB$\fP.
1918 .TP
1919 .B LC_NUMERIC
1920 This variable determines the locale category used for number formatting.
1921 .TP
1922 .B LINES
1923 Used by the \fBselect\fP builtin command to determine the column length
1924 for printing selection lists.  Automatically set upon receipt of a SIGWINCH.
1925 .TP
1926 .B MAIL
1927 If this parameter is set to a file name and the
1928 .SM
1929 .B MAILPATH
1930 variable is not set,
1931 .B bash
1932 informs the user of the arrival of mail in the specified file.
1933 .TP
1934 .B MAILCHECK
1935 Specifies how
1936 often (in seconds)
1937 .B bash
1938 checks for mail.  The default is 60 seconds.  When it is time to check
1939 for mail, the shell does so before displaying the primary prompt.
1940 If this variable is unset, or set to a value that is not a number
1941 greater than or equal to zero, the shell disables mail checking.
1942 .TP
1943 .B MAILPATH
1944 A colon-separated list of file names to be checked for mail. 
1945 The message to be printed when mail arrives in a particular file
1946 may be specified by separating the file name from the message with a `?'.
1947 When used in the text of the message, \fB$_\fP expands to the name of
1948 the current mailfile. 
1949 Example:
1950 .RS
1951 .PP
1952 \fBMAILPATH\fP=\(aq/var/mail/bfox?"You have mail":~/shell\-mail?"$_ has mail!"\(aq
1953 .PP
1954 .B Bash
1955 supplies a default value for this variable, but the location of the user
1956 mail files that it uses is system dependent (e.g., /var/mail/\fB$USER\fP).
1957 .RE
1958 .TP
1959 .B OPTERR
1960 If set to the value 1,
1961 .B bash
1962 displays error messages generated by the
1963 .B getopts
1964 builtin command (see
1965 .SM
1966 .B SHELL BUILTIN COMMANDS
1967 below).
1968 .SM
1969 .B OPTERR
1970 is initialized to 1 each time the shell is invoked or a shell
1971 script is executed.
1972 .TP
1973 .B PATH
1974 The search path for commands.  It
1975 is a colon-separated list of directories in which
1976 the shell looks for commands (see
1977 .SM
1978 .B COMMAND EXECUTION
1979 below).
1980 A zero-length (null) directory name in the value of \fBPATH\fP indicates the
1981 current directory.
1982 A null directory name may appear as two adjacent colons, or as an initial
1983 or trailing colon.
1984 The default path is system-dependent,
1985 and is set by the administrator who installs
1986 .BR bash .
1987 A common value is
1988 .if t \f(CW/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin\fP.
1989 .if n ``/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin''.
1990 .TP
1991 .B POSIXLY_CORRECT
1992 If this variable is in the environment when \fBbash\fP starts, the shell
1993 enters \fIposix mode\fP before reading the startup files, as if the
1994 .B \-\-posix
1995 invocation option had been supplied.  If it is set while the shell is
1996 running, \fBbash\fP enables \fIposix mode\fP, as if the command
1997 .if t \f(CWset -o posix\fP
1998 .if n \fIset -o posix\fP
1999 had been executed.
2000 .TP
2001 .B PROMPT_COMMAND
2002 If set, the value is executed as a command prior to issuing each primary
2003 prompt.
2004 .TP
2005 .B PROMPT_DIRTRIM
2006 If set to a number greater than zero, the value is used as the number of
2007 trailing directory components to retain when expanding the \fB\ew\fB and
2008 \fB\eW\fP prompt string escapes (see
2009 .SM
2010 .B PROMPTING
2011 below).  Characters removed are replaced with an ellipsis.
2012 .TP
2013 .B PS1
2014 The value of this parameter is expanded (see
2015 .SM
2016 .B PROMPTING
2017 below) and used as the primary prompt string.  The default value is
2018 ``\fB\es\-\ev\e$ \fP''.
2019 .TP
2020 .B PS2
2021 The value of this parameter is expanded as with
2022 .B PS1
2023 and used as the secondary prompt string.  The default is
2024 ``\fB> \fP''.
2025 .TP
2026 .B PS3
2027 The value of this parameter is used as the prompt for the
2028 .B select
2029 command (see
2030 .SM
2031 .B SHELL GRAMMAR
2032 above).
2033 .TP
2034 .B PS4
2035 The value of this parameter is expanded as with
2036 .B PS1
2037 and the value is printed before each command
2038 .B bash
2039 displays during an execution trace.  The first character of
2040 .SM
2041 .B PS4
2042 is replicated multiple times, as necessary, to indicate multiple
2043 levels of indirection.  The default is ``\fB+ \fP''.
2044 .TP
2045 .B SHELL
2046 The full pathname to the shell is kept in this environment variable.
2047 If it is not set when the shell starts,
2048 .B bash
2049 assigns to it the full pathname of the current user's login shell.
2050 .TP
2051 .B TIMEFORMAT
2052 The value of this parameter is used as a format string specifying
2053 how the timing information for pipelines prefixed with the
2054 .B time
2055 reserved word should be displayed.
2056 The \fB%\fP character introduces an escape sequence that is
2057 expanded to a time value or other information.
2058 The escape sequences and their meanings are as follows; the
2059 braces denote optional portions.
2060 .sp .5
2061 .RS
2062 .PD 0
2063 .TP 10
2064 .B %%
2065 A literal \fB%\fP.
2066 .TP
2067 .B %[\fIp\fP][l]R
2068 The elapsed time in seconds.
2069 .TP
2070 .B %[\fIp\fP][l]U
2071 The number of CPU seconds spent in user mode.
2072 .TP
2073 .B %[\fIp\fP][l]S
2074 The number of CPU seconds spent in system mode.
2075 .TP
2076 .B %P
2077 The CPU percentage, computed as (%U + %S) / %R.
2078 .PD
2079 .RE
2080 .IP
2081 The optional \fIp\fP is a digit specifying the \fIprecision\fP,
2082 the number of fractional digits after a decimal point.
2083 A value of 0 causes no decimal point or fraction to be output.
2084 At most three places after the decimal point may be specified;
2085 values of \fIp\fP greater than 3 are changed to 3.
2086 If \fIp\fP is not specified, the value 3 is used.
2087 .IP
2088 The optional \fBl\fP specifies a longer format, including
2089 minutes, of the form \fIMM\fPm\fISS\fP.\fIFF\fPs.
2090 The value of \fIp\fP determines whether or not the fraction is
2091 included.
2092 .IP
2093 If this variable is not set, \fBbash\fP acts as if it had the
2094 value \fB$\(aq\enreal\et%3lR\enuser\et%3lU\ensys\t%3lS\(aq\fP.
2095 If the value is null, no timing information is displayed.
2096 A trailing newline is added when the format string is displayed.
2097 .TP
2098 .B TMOUT
2099 If set to a value greater than zero, \fBTMOUT\fP is treated as the
2100 default timeout for the \fBread\fP builtin.
2101 The \fBselect\fP command terminates if input does not arrive
2102 after \fBTMOUT\fP seconds when input is coming from a terminal.
2103 In an interactive shell, the value is interpreted as the
2104 number of seconds to wait for input after issuing the primary prompt.
2105 .B Bash
2106 terminates after waiting for that number of seconds if input does
2107 not arrive.
2108 .TP
2109 .B TMPDIR
2110 If set, \fBBash\fP uses its value as the name of a directory in which
2111 \fBBash\fP creates temporary files for the shell's use.
2112 .TP
2113 .B auto_resume
2114 This variable controls how the shell interacts with the user and
2115 job control.  If this variable is set, single word simple
2116 commands without redirections are treated as candidates for resumption
2117 of an existing stopped job.  There is no ambiguity allowed; if there is
2118 more than one job beginning with the string typed, the job most recently
2119 accessed is selected.  The
2120 .I name
2121 of a stopped job, in this context, is the command line used to
2122 start it.
2123 If set to the value
2124 .IR exact ,
2125 the string supplied must match the name of a stopped job exactly;
2126 if set to
2127 .IR substring ,
2128 the string supplied needs to match a substring of the name of a
2129 stopped job.  The
2130 .I substring
2131 value provides functionality analogous to the
2132 .B %?
2133 job identifier (see
2134 .SM
2135 .B JOB CONTROL
2136 below).  If set to any other value, the supplied string must
2137 be a prefix of a stopped job's name; this provides functionality
2138 analogous to the \fB%\fP\fIstring\fP job identifier.
2139 .TP
2140 .B histchars
2141 The two or three characters which control history expansion
2142 and tokenization (see
2143 .SM
2144 .B HISTORY EXPANSION
2145 below).  The first character is the \fIhistory expansion\fP character,
2146 the character which signals the start of a history
2147 expansion, normally `\fB!\fP'.
2148 The second character is the \fIquick substitution\fP
2149 character, which is used as shorthand for re-running the previous
2150 command entered, substituting one string for another in the command.
2151 The default is `\fB^\fP'.
2152 The optional third character is the character
2153 which indicates that the remainder of the line is a comment when found
2154 as the first character of a word, normally `\fB#\fP'.  The history
2155 comment character causes history substitution to be skipped for the
2156 remaining words on the line.  It does not necessarily cause the shell
2157 parser to treat the rest of the line as a comment.
2158 .PD
2159 .SS Arrays
2160 .B Bash
2161 provides one-dimensional indexed and associative array variables.
2162 Any variable may be used as an indexed array; the
2163 .B declare
2164 builtin will explicitly declare an array.
2165 There is no maximum
2166 limit on the size of an array, nor any requirement that members
2167 be indexed or assigned contiguously.
2168 Indexed arrays are referenced using integers (including arithmetic
2169 expressions)  and are zero-based; associative arrays are referenced
2170 using arbitrary strings.
2171 .PP
2172 An indexed array is created automatically if any variable is assigned to
2173 using the syntax \fIname\fP[\fIsubscript\fP]=\fIvalue\fP.  The
2174 .I subscript
2175 is treated as an arithmetic expression that must evaluate to a number
2176 greater than or equal to zero.  To explicitly declare an indexed array,
2177 use
2178 .B declare \-a \fIname\fP
2179 (see
2180 .SM
2181 .B SHELL BUILTIN COMMANDS
2182 below).
2183 .B declare \-a \fIname\fP[\fIsubscript\fP]
2184 is also accepted; the \fIsubscript\fP is ignored.
2185 .PP
2186 Associative arrays are created using
2187 .BR "declare \-A \fIname\fP" .
2188 .PP
2189 Attributes may be
2190 specified for an array variable using the
2191 .B declare
2192 and
2193 .B readonly
2194 builtins.  Each attribute applies to all members of an array.
2195 .PP
2196 Arrays are assigned to using compound assignments of the form
2197 \fIname\fP=\fB(\fPvalue\fI1\fP ... value\fIn\fP\fB)\fP, where each
2198 \fIvalue\fP is of the form [\fIsubscript\fP]=\fIstring\fP.
2199 Indexed array assignments do not require the bracket and subscript.
2200 When assigning to indexed arrays, if the optional brackets and subscript
2201 are supplied, that index is assigned to;
2202 otherwise the index of the element assigned is the last index assigned
2203 to by the statement plus one.  Indexing starts at zero.
2204 .PP
2205 When assigning to an associative array, the subscript is required.
2206 .PP
2207 This syntax is also accepted by the
2208 .B declare
2209 builtin.  Individual array elements may be assigned to using the
2210 \fIname\fP[\fIsubscript\fP]=\fIvalue\fP syntax introduced above.
2211 .PP
2212 Any element of an array may be referenced using
2213 ${\fIname\fP[\fIsubscript\fP]}.  The braces are required to avoid
2214 conflicts with pathname expansion.  If
2215 \fIsubscript\fP is \fB@\fP or \fB*\fP, the word expands to
2216 all members of \fIname\fP.  These subscripts differ only when the
2217 word appears within double quotes.  If the word is double-quoted,
2218 ${\fIname\fP[*]} expands to a single
2219 word with the value of each array member separated by the first
2220 character of the
2221 .SM
2222 .B IFS
2223 special variable, and ${\fIname\fP[@]} expands each element of
2224 \fIname\fP to a separate word.  When there are no array members,
2225 ${\fIname\fP[@]} expands to nothing.
2226 If the double-quoted expansion occurs within a word, the expansion of
2227 the first parameter is joined with the beginning part of the original
2228 word, and the expansion of the last parameter is joined with the last
2229 part of the original word.
2230 This is analogous to the expansion
2231 of the special parameters \fB*\fP and \fB@\fP (see
2232 .B Special Parameters
2233 above).  ${#\fIname\fP[\fIsubscript\fP]} expands to the length of
2234 ${\fIname\fP[\fIsubscript\fP]}.  If \fIsubscript\fP is \fB*\fP or
2235 \fB@\fP, the expansion is the number of elements in the array.
2236 Referencing an array variable without a subscript is equivalent to
2237 referencing the array with a subscript of 0.
2238 .PP
2239 The
2240 .B unset
2241 builtin is used to destroy arrays.  \fBunset\fP \fIname\fP[\fIsubscript\fP]
2242 destroys the array element at index \fIsubscript\fP.
2243 Care must be taken to avoid unwanted side effects caused by filename
2244 generation.
2245 \fBunset\fP \fIname\fP, where \fIname\fP is an array, or
2246 \fBunset\fP \fIname\fP[\fIsubscript\fP], where
2247 \fIsubscript\fP is \fB*\fP or \fB@\fP, removes the entire array.
2248 .PP
2249 The
2250 .BR declare ,
2251 .BR local ,
2252 and
2253 .B readonly
2254 builtins each accept a
2255 .B \-a
2256 option to specify an indexed array and a
2257 .B \-A
2258 option to specify an associative array.
2259 The
2260 .B read
2261 builtin accepts a
2262 .B \-a
2263 option to assign a list of words read from the standard input
2264 to an array.  The
2265 .B set
2266 and
2267 .B declare
2268 builtins display array values in a way that allows them to be
2269 reused as assignments.
2270 .SH EXPANSION
2271 Expansion is performed on the command line after it has been split into
2272 words.  There are seven kinds of expansion performed:
2273 .IR "brace expansion" ,
2274 .IR "tilde expansion" ,
2275 .IR "parameter and variable expansion" ,
2276 .IR "command substitution" ,
2277 .IR "arithmetic expansion" ,
2278 .IR "word splitting" ,
2279 and
2280 .IR "pathname expansion" .
2281 .PP
2282 The order of expansions is: brace expansion, tilde expansion,
2283 parameter, variable and arithmetic expansion and
2284 command substitution
2285 (done in a left-to-right fashion), word splitting, and pathname
2286 expansion.
2287 .PP
2288 On systems that can support it, there is an additional expansion
2289 available: \fIprocess substitution\fP.
2290 .PP
2291 Only brace expansion, word splitting, and pathname expansion
2292 can change the number of words of the expansion; other expansions
2293 expand a single word to a single word.
2294 The only exceptions to this are the expansions of
2295 "\fB$@\fP" and "\fB${\fP\fIname\fP\fB[@]}\fP"
2296 as explained above (see
2297 .SM
2298 .BR PARAMETERS ).
2299 .SS Brace Expansion
2300 .PP
2301 .I "Brace expansion"
2302 is a mechanism by which arbitrary strings
2303 may be generated.  This mechanism is similar to
2304 \fIpathname expansion\fP, but the filenames generated
2305 need not exist.  Patterns to be brace expanded take
2306 the form of an optional
2307 .IR preamble ,
2308 followed by either a series of comma-separated strings or
2309 a sequence expression between a pair of braces, followed by
2310 an optional
2311 .IR postscript .
2312 The preamble is prefixed to each string contained
2313 within the braces, and the postscript is then appended
2314 to each resulting string, expanding left to right.
2315 .PP
2316 Brace expansions may be nested.  The results of each expanded
2317 string are not sorted; left to right order is preserved.
2318 For example, a\fB{\fPd,c,b\fB}\fPe expands into `ade ace abe'.
2319 .PP
2320 A sequence expression takes the form
2321 \fB{\fP\fIx\fP\fB..\fP\fIy\fP\fB[..\fP\fIincr\fP\fB]}\fP,
2322 where \fIx\fP and \fIy\fP are either integers or single characters,
2323 and \fIincr\fP, an optional increment, is an integer.
2324 When integers are supplied, the expression expands to each number between
2325 \fIx\fP and \fIy\fP, inclusive.
2326 Supplied integers may be prefixed with \fI0\fP to force each term to have the
2327 same width.  When either \fIx\fP or \fPy\fP begins with a zero, the shell
2328 attempts to force all generated terms to contain the same number of digits,
2329 zero-padding where necessary.
2330 When characters are supplied, the expression expands to each character
2331 lexicographically between \fIx\fP and \fIy\fP, inclusive.  Note that
2332 both \fIx\fP and \fIy\fP must be of the same type.
2333 When the increment is supplied, it is used as the difference between
2334 each term.  The default increment is 1 or -1 as appropriate.
2335 .PP
2336 Brace expansion is performed before any other expansions,
2337 and any characters special to other expansions are preserved
2338 in the result.  It is strictly textual.
2339 .B Bash
2340 does not apply any syntactic interpretation to the context of the
2341 expansion or the text between the braces.
2342 .PP
2343 A correctly-formed brace expansion must contain unquoted opening
2344 and closing braces, and at least one unquoted comma or a valid
2345 sequence expression.
2346 Any incorrectly formed brace expansion is left unchanged.
2347 A \fB{\fP or \fB,\fP may be quoted with a backslash to prevent its
2348 being considered part of a brace expression.
2349 To avoid conflicts with parameter expansion, the string \fB${\fP
2350 is not considered eligible for brace expansion.
2351 .PP
2352 This construct is typically used as shorthand when the common
2353 prefix of the strings to be generated is longer than in the
2354 above example:
2355 .RS
2356 .PP
2357 mkdir /usr/local/src/bash/{old,new,dist,bugs}
2358 .RE
2359 or
2360 .RS
2361 chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}
2362 .RE
2363 .PP
2364 Brace expansion introduces a slight incompatibility with
2365 historical versions of
2366 .BR sh .
2367 .B sh
2368 does not treat opening or closing braces specially when they
2369 appear as part of a word, and preserves them in the output.
2370 .B Bash
2371 removes braces from words as a consequence of brace
2372 expansion.  For example, a word entered to
2373 .B sh
2374 as \fIfile{1,2}\fP
2375 appears identically in the output.  The same word is
2376 output as
2377 .I file1 file2
2378 after expansion by
2379 .BR bash .
2380 If strict compatibility with
2381 .B sh
2382 is desired, start
2383 .B bash
2384 with the
2385 .B +B 
2386 option or disable brace expansion with the
2387 .B +B
2388 option to the
2389 .B set
2390 command (see
2391 .SM
2392 .B SHELL BUILTIN COMMANDS
2393 below).
2394 .SS Tilde Expansion
2395 .PP
2396 If a word begins with an unquoted tilde character (`\fB~\fP'), all of
2397 the characters preceding the first unquoted slash (or all characters,
2398 if there is no unquoted slash) are considered a \fItilde-prefix\fP.
2399 If none of the characters in the tilde-prefix are quoted, the
2400 characters in the tilde-prefix following the tilde are treated as a
2401 possible \fIlogin name\fP.
2402 If this login name is the null string, the tilde is replaced with the
2403 value of the shell parameter
2404 .SM
2405 .BR HOME .
2406 If
2407 .SM
2408 .B HOME
2409 is unset, the home directory of the user executing the shell is
2410 substituted instead.
2411 Otherwise, the tilde-prefix is replaced with the home directory
2412 associated with the specified login name.
2413 .PP
2414 If the tilde-prefix is a `~+', the value of the shell variable
2415 .SM
2416 .B PWD
2417 replaces the tilde-prefix.
2418 If the tilde-prefix is a `~\-', the value of the shell variable
2419 .SM
2420 .BR OLDPWD ,
2421 if it is set, is substituted.
2422 If the characters following the tilde in the tilde-prefix consist
2423 of a number \fIN\fP, optionally prefixed
2424 by a `+' or a `\-', the tilde-prefix is replaced with the corresponding
2425 element from the directory stack, as it would be displayed by the
2426 .B dirs
2427 builtin invoked with the tilde-prefix as an argument.
2428 If the characters following the tilde in the tilde-prefix consist of a
2429 number without a leading `+' or `\-', `+' is assumed.
2430 .PP
2431 If the login name is invalid, or the tilde expansion fails, the word
2432 is unchanged.
2433 .PP
2434 Each variable assignment is checked for unquoted tilde-prefixes immediately
2435 following a
2436 .B :
2437 or the first
2438 .BR = .
2439 In these cases, tilde expansion is also performed.
2440 Consequently, one may use file names with tildes in assignments to
2441 .SM
2442 .BR PATH ,
2443 .SM
2444 .BR MAILPATH ,
2445 and
2446 .SM
2447 .BR CDPATH ,
2448 and the shell assigns the expanded value.
2449 .SS Parameter Expansion
2450 .PP
2451 The `\fB$\fP' character introduces parameter expansion,
2452 command substitution, or arithmetic expansion.  The parameter name
2453 or symbol to be expanded may be enclosed in braces, which
2454 are optional but serve to protect the variable to be expanded from
2455 characters immediately following it which could be
2456 interpreted as part of the name.
2457 .PP
2458 When braces are used, the matching ending brace is the first `\fB}\fP'
2459 not escaped by a backslash or within a quoted string, and not within an
2460 embedded arithmetic expansion, command substitution, or parameter
2461 expansion.
2462 .PP
2463 .PD 0
2464 .TP
2465 ${\fIparameter\fP}
2466 The value of \fIparameter\fP is substituted.  The braces are required
2467 when
2468 .I parameter
2469 is a positional parameter with more than one digit,
2470 or when
2471 .I parameter
2472 is followed by a character which is not to be
2473 interpreted as part of its name.
2474 .PD
2475 .PP
2476 If the first character of \fIparameter\fP is an exclamation point,
2477 a level of variable indirection is introduced.
2478 \fBBash\fP uses the value of the variable formed from the rest of
2479 \fIparameter\fP as the name of the variable; this variable is then
2480 expanded and that value is used in the rest of the substitution, rather
2481 than the value of \fIparameter\fP itself.
2482 This is known as \fIindirect expansion\fP.
2483 The exceptions to this are the expansions of ${!\fIprefix\fP*} and
2484 ${\fB!\fP\fIname\fP[\fI@\fP]} described below.
2485 The exclamation point must immediately follow the left brace in order to
2486 introduce indirection.
2487 .PP
2488 In each of the cases below, \fIword\fP is subject to tilde expansion,
2489 parameter expansion, command substitution, and arithmetic expansion.
2490 .PP
2491 When not performing substring expansion, using the forms documented below,
2492 \fBbash\fP tests for a parameter that is unset or null.  Omitting the colon
2493 results in a test only for a parameter that is unset.
2494 .PP
2495 .PD 0
2496 .TP
2497 ${\fIparameter\fP\fB:\-\fP\fIword\fP}
2498 \fBUse Default Values\fP.  If
2499 .I parameter
2500 is unset or null, the expansion of
2501 .I word
2502 is substituted.  Otherwise, the value of
2503 .I parameter
2504 is substituted.
2505 .TP
2506 ${\fIparameter\fP\fB:=\fP\fIword\fP}
2507 \fBAssign Default Values\fP.
2508 If
2509 .I parameter
2510 is unset or null, the expansion of
2511 .I word
2512 is assigned to
2513 .IR parameter .
2514 The value of
2515 .I parameter
2516 is then substituted.  Positional parameters and special parameters may
2517 not be assigned to in this way.
2518 .TP
2519 ${\fIparameter\fP\fB:?\fP\fIword\fP}
2520 \fBDisplay Error if Null or Unset\fP.
2521 If
2522 .I parameter
2523 is null or unset, the expansion of \fIword\fP (or a message to that effect
2524 if
2525 .I word
2526 is not present) is written to the standard error and the shell, if it
2527 is not interactive, exits.  Otherwise, the value of \fIparameter\fP is
2528 substituted.
2529 .TP
2530 ${\fIparameter\fP\fB:+\fP\fIword\fP}
2531 \fBUse Alternate Value\fP.
2532 If
2533 .I parameter
2534 is null or unset, nothing is substituted, otherwise the expansion of
2535 .I word
2536 is substituted.
2537 .TP
2538 ${\fIparameter\fP\fB:\fP\fIoffset\fP}
2539 .PD 0
2540 .TP
2541 ${\fIparameter\fP\fB:\fP\fIoffset\fP\fB:\fP\fIlength\fP}
2542 .PD
2543 \fBSubstring Expansion.\fP
2544 Expands to up to \fIlength\fP characters of \fIparameter\fP
2545 starting at the character specified by \fIoffset\fP.
2546 If \fIlength\fP is omitted, expands to the substring of
2547 \fIparameter\fP starting at the character specified by \fIoffset\fP.
2548 \fIlength\fP and \fIoffset\fP are arithmetic expressions (see
2549 .SM
2550 .B
2551 ARITHMETIC EVALUATION
2552 below).
2553 \fIlength\fP must evaluate to a number greater than or equal to zero.
2554 If \fIoffset\fP evaluates to a number less than zero, the value
2555 is used as an offset from the end of the value of \fIparameter\fP.
2556 If \fIparameter\fP is \fB@\fP, the result is \fIlength\fP positional
2557 parameters beginning at \fIoffset\fP.
2558 If \fIparameter\fP is an indexed array name subscripted by @ or *,
2559 the result is the \fIlength\fP
2560 members of the array beginning with ${\fIparameter\fP[\fIoffset\fP]}.
2561 A negative \fIoffset\fP is taken relative to one greater than the maximum
2562 index of the specified array.
2563 Substring expansion applied to an associative array produces undefined
2564 results.
2565 Note that a negative offset must be separated from the colon by at least
2566 one space to avoid being confused with the :- expansion.
2567 Substring indexing is zero-based unless the positional parameters 
2568 are used, in which case the indexing starts at 1 by default.
2569 If \fIoffset\fP is 0, and the positional parameters are used, \fB$0\fP is
2570 prefixed to the list.
2571 .TP
2572 ${\fB!\fP\fIprefix\fP\fB*\fP}
2573 .PD 0
2574 .TP
2575 ${\fB!\fP\fIprefix\fP\fB@\fP}
2576 .PD
2577 \fBNames matching prefix.\fP
2578 Expands to the names of variables whose names begin with \fIprefix\fP,
2579 separated by the first character of the
2580 .SM
2581 .B IFS
2582 special variable.
2583 When \fI@\fP is used and the expansion appears within double quotes, each
2584 variable name expands to a separate word.
2585 .TP
2586 ${\fB!\fP\fIname\fP[\fI@\fP]}
2587 .PD 0
2588 .TP
2589 ${\fB!\fP\fIname\fP[\fI*\fP]}
2590 .PD
2591 \fBList of array keys.\fP
2592 If \fIname\fP is an array variable, expands to the list of array indices
2593 (keys) assigned in \fIname\fP.
2594 If \fIname\fP is not an array, expands to 0 if \fIname\fP is set and null
2595 otherwise.
2596 When \fI@\fP is used and the expansion appears within double quotes, each
2597 key expands to a separate word.
2598 .TP
2599 ${\fB#\fP\fIparameter\fP}
2600 \fBParameter length.\fP
2601 The length in characters of the value of \fIparameter\fP is substituted.
2602 If
2603 .I parameter
2604 is
2605 .B *
2606 or 
2607 .BR @ ,
2608 the value substituted is the number of positional parameters.
2609 If
2610 .I parameter
2611 is an array name subscripted by
2612 .B *
2613 or
2614 .BR @ ,
2615 the value substituted is the number of elements in the array.
2616 .TP
2617 ${\fIparameter\fP\fB#\fP\fIword\fP}
2618 .PD 0
2619 .TP
2620 ${\fIparameter\fP\fB##\fP\fIword\fP}
2621 .PD
2622 \fBRemove matching prefix pattern.\fP
2623 The 
2624 .I word
2625 is expanded to produce a pattern just as in pathname
2626 expansion.  If the pattern matches the beginning of
2627 the value of
2628 .IR parameter ,
2629 then the result of the expansion is the expanded value of
2630 .I parameter
2631 with the shortest matching pattern (the ``\fB#\fP'' case) or the
2632 longest matching pattern (the ``\fB##\fP'' case) deleted.
2633 If
2634 .I parameter
2635 is
2636 .B @
2637 or
2638 .BR * ,
2639 the pattern removal operation is applied to each positional
2640 parameter in turn, and the expansion is the resultant list.
2641 If
2642 .I parameter
2643 is an array variable subscripted with
2644 .B @
2645 or
2646 .BR * ,
2647 the pattern removal operation is applied to each member of the
2648 array in turn, and the expansion is the resultant list.
2649 .TP
2650 ${\fIparameter\fP\fB%\fP\fIword\fP}
2651 .PD 0
2652 .TP
2653 ${\fIparameter\fP\fB%%\fP\fIword\fP}
2654 .PD
2655 \fBRemove matching suffix pattern.\fP
2656 The \fIword\fP is expanded to produce a pattern just as in
2657 pathname expansion.
2658 If the pattern matches a trailing portion of the expanded value of
2659 .IR parameter ,
2660 then the result of the expansion is the expanded value of
2661 .I parameter
2662 with the shortest matching pattern (the ``\fB%\fP'' case) or the
2663 longest matching pattern (the ``\fB%%\fP'' case) deleted.
2664 If
2665 .I parameter
2666 is
2667 .B @
2668 or
2669 .BR * ,
2670 the pattern removal operation is applied to each positional
2671 parameter in turn, and the expansion is the resultant list.
2672 If
2673 .I parameter
2674 is an array variable subscripted with
2675 .B @
2676 or
2677 .BR * ,
2678 the pattern removal operation is applied to each member of the
2679 array in turn, and the expansion is the resultant list.
2680 .TP
2681 ${\fIparameter\fP\fB/\fP\fIpattern\fP\fB/\fP\fIstring\fP}
2682 \fBPattern substitution.\fP
2683 The \fIpattern\fP is expanded to produce a pattern just as in
2684 pathname expansion.
2685 \fIParameter\fP is expanded and the longest match of \fIpattern\fP
2686 against its value is replaced with \fIstring\fP.
2687 If \fIpattern\fP begins with \fB/\fP, all matches of \fIpattern\fP are
2688 replaced with \fIstring\fP.  Normally only the first match is replaced.
2689 If \fIpattern\fP begins with \fB#\fP, it must match at the beginning
2690 of the expanded value of \fIparameter\fP.
2691 If \fIpattern\fP begins with \fB%\fP, it must match at the end
2692 of the expanded value of \fIparameter\fP.
2693 If \fIstring\fP is null, matches of \fIpattern\fP are deleted
2694 and the \fB/\fP following \fIpattern\fP may be omitted.
2695 If
2696 .I parameter
2697 is
2698 .B @
2699 or
2700 .BR * ,
2701 the substitution operation is applied to each positional
2702 parameter in turn, and the expansion is the resultant list.
2703 If
2704 .I parameter
2705 is an array variable subscripted with
2706 .B @
2707 or
2708 .BR * ,
2709 the substitution operation is applied to each member of the
2710 array in turn, and the expansion is the resultant list.
2711 .TP
2712 ${\fIparameter\fP\fB^\fP\fIpattern\fP}
2713 .PD 0
2714 .TP
2715 ${\fIparameter\fP\fB^^\fP\fIpattern\fP}
2716 .TP
2717 ${\fIparameter\fP\fB,\fP\fIpattern\fP}
2718 .TP
2719 ${\fIparameter\fP\fB,,\fP\fIpattern\fP}
2720 .PD
2721 \fBCase modification.\fP
2722 This expansion modifies the case of alphabetic characters in \fIparameter\fP.
2723 The \fIpattern\fP is expanded to produce a pattern just as in
2724 pathname expansion.
2725 The \fB^\fP operator converts lowercase letters matching \fIpattern\fP
2726 to uppercase; the \fB,\fP operator converts matching uppercase letters
2727 to lowercase.
2728 The \fB^^\fP and \fB,,\fP expansions convert each matched character in the
2729 expanded value; the \fB^\fP and \fB,\fP expansions match and convert only
2730 the first character in the expanded value..
2731 If \fIpattern\fP is omitted, it is treated like a \fB?\fP, which matches
2732 every character.
2733 If
2734 .I parameter
2735 is
2736 .B @
2737 or
2738 .BR * ,
2739 the case modification operation is applied to each positional
2740 parameter in turn, and the expansion is the resultant list.
2741 If
2742 .I parameter
2743 is an array variable subscripted with
2744 .B @
2745 or
2746 .BR * ,
2747 the case modification operation is applied to each member of the
2748 array in turn, and the expansion is the resultant list.
2749 .SS Command Substitution
2750 .PP
2751 \fICommand substitution\fP allows the output of a command to replace
2752 the command name.  There are two forms:
2753 .PP
2754 .RS
2755 .PP
2756 \fB$(\fP\fIcommand\fP\|\fB)\fP
2757 .RE
2758 or
2759 .RS
2760 \fB\`\fP\fIcommand\fP\fB\`\fP
2761 .RE
2762 .PP
2763 .B Bash
2764 performs the expansion by executing \fIcommand\fP and
2765 replacing the command substitution with the standard output of the
2766 command, with any trailing newlines deleted.
2767 Embedded newlines are not deleted, but they may be removed during
2768 word splitting.
2769 The command substitution \fB$(cat \fIfile\fP)\fR can be replaced by
2770 the equivalent but faster \fB$(< \fIfile\fP)\fR.
2771 .PP
2772 When the old-style backquote form of substitution is used,
2773 backslash retains its literal meaning except when followed by
2774 .BR $ ,
2775 .BR \` ,
2776 or
2777 .BR \e .
2778 The first backquote not preceded by a backslash terminates the
2779 command substitution.
2780 When using the $(\^\fIcommand\fP\|) form, all characters between the
2781 parentheses make up the command; none are treated specially.
2782 .PP
2783 Command substitutions may be nested.  To nest when using the backquoted form,
2784 escape the inner backquotes with backslashes.
2785 .PP
2786 If the substitution appears within double quotes, word splitting and
2787 pathname expansion are not performed on the results.
2788 .SS Arithmetic Expansion
2789 .PP
2790 Arithmetic expansion allows the evaluation of an arithmetic expression
2791 and the substitution of the result.  The format for arithmetic expansion is:
2792 .RS
2793 .PP
2794 \fB$((\fP\fIexpression\fP\fB))\fP
2795 .RE
2796 .PP
2797 The
2798 .I expression
2799 is treated as if it were within double quotes, but a double quote
2800 inside the parentheses is not treated specially.
2801 All tokens in the expression undergo parameter expansion, string
2802 expansion, command substitution, and quote removal.
2803 Arithmetic expansions may be nested.
2804 .PP
2805 The evaluation is performed according to the rules listed below under
2806 .SM
2807 .BR "ARITHMETIC EVALUATION" .
2808 If
2809 .I expression
2810 is invalid,
2811 .B bash
2812 prints a message indicating failure and no substitution occurs.
2813 .SS Process Substitution
2814 .PP
2815 \fIProcess substitution\fP is supported on systems that support named
2816 pipes (\fIFIFOs\fP) or the \fB/dev/fd\fP method of naming open files.
2817 It takes the form of
2818 \fB<(\fP\fIlist\^\fP\fB)\fP
2819 or
2820 \fB>(\fP\fIlist\^\fP\fB)\fP.
2821 The process \fIlist\fP is run with its input or output connected to a
2822 \fIFIFO\fP or some file in \fB/dev/fd\fP.  The name of this file is
2823 passed as an argument to the current command as the result of the
2824 expansion.  If the \fB>(\fP\fIlist\^\fP\fB)\fP form is used, writing to
2825 the file will provide input for \fIlist\fP.  If the
2826 \fB<(\fP\fIlist\^\fP\fB)\fP form is used, the file passed as an
2827 argument should be read to obtain the output of \fIlist\fP.
2828 .PP
2829 When available, process substitution is performed
2830 simultaneously with parameter and variable expansion, 
2831 command substitution,
2832 and arithmetic expansion.
2833 .SS Word Splitting
2834 .PP
2835 The shell scans the results of
2836 parameter expansion,
2837 command substitution,
2838 and
2839 arithmetic expansion
2840 that did not occur within double quotes for
2841 .IR "word splitting" .
2842 .PP
2843 The shell treats each character of
2844 .SM
2845 .B IFS
2846 as a delimiter, and splits the results of the other
2847 expansions into words on these characters.  If
2848 .SM
2849 .B IFS
2850 is unset, or its
2851 value is exactly
2852 .BR <space><tab><newline> ,
2853 the default, then
2854 sequences of
2855 .BR <space> ,
2856 .BR <tab> ,
2857 and
2858 .B <newline>
2859 at the beginning and end of the results of the previous
2860 expansions are ignored, and
2861 any sequence of
2862 .SM
2863 .B IFS
2864 characters not at the beginning or end serves to delimit words.
2865 If
2866 .SM
2867 .B IFS
2868 has a value other than the default, then sequences of
2869 the whitespace characters
2870 .B space
2871 and
2872 .B tab
2873 are ignored at the beginning and end of the
2874 word, as long as the whitespace character is in the
2875 value of
2876 .SM
2877 .BR IFS
2878 (an
2879 .SM
2880 .B IFS
2881 whitespace character).
2882 Any character in
2883 .SM
2884 .B IFS
2885 that is not
2886 .SM
2887 .B IFS
2888 whitespace, along with any adjacent
2889 .SM
2890 .B IFS
2891 whitespace characters, delimits a field.
2892 A sequence of
2893 .SM
2894 .B IFS
2895 whitespace characters is also treated as a delimiter.
2896 If the value of
2897 .SM
2898 .B IFS
2899 is null, no word splitting occurs.
2900 .PP
2901 Explicit null arguments (\^\f3"\^"\fP or \^\f3\(aq\^\(aq\fP\^) are retained.
2902 Unquoted implicit null arguments, resulting from the expansion of
2903 parameters that have no values, are removed.
2904 If a parameter with no value is expanded within double quotes, a
2905 null argument results and is retained.
2906 .PP
2907 Note that if no expansion occurs, no splitting
2908 is performed.
2909 .SS Pathname Expansion
2910 .PP
2911 After word splitting,
2912 unless the
2913 .B \-f
2914 option has been set,
2915 .B bash
2916 scans each word for the characters
2917 .BR * ,
2918 .BR ? ,
2919 and
2920 .BR [ .
2921 If one of these characters appears, then the word is
2922 regarded as a
2923 .IR pattern ,
2924 and replaced with an alphabetically sorted list of
2925 file names matching the pattern.
2926 If no matching file names are found,
2927 and the shell option
2928 .B nullglob
2929 is not enabled, the word is left unchanged.
2930 If the 
2931 .B nullglob
2932 option is set, and no matches are found,
2933 the word is removed.
2934 If the
2935 .B failglob
2936 shell option is set, and no matches are found, an error message
2937 is printed and the command is not executed.
2938 If the shell option
2939 .B nocaseglob
2940 is enabled, the match is performed without regard to the case
2941 of alphabetic characters.
2942 When a pattern is used for pathname expansion,
2943 the character
2944 .B ``.''
2945 at the start of a name or immediately following a slash
2946 must be matched explicitly, unless the shell option
2947 .B dotglob
2948 is set.
2949 When matching a pathname, the slash character must always be
2950 matched explicitly.
2951 In other cases, the
2952 .B ``.''
2953 character is not treated specially.
2954 See the description of
2955 .B shopt
2956 below under
2957 .SM
2958 .B SHELL BUILTIN COMMANDS
2959 for a description of the
2960 .BR nocaseglob ,
2961 .BR nullglob ,
2962 .BR failglob ,
2963 and
2964 .B dotglob
2965 shell options.
2966 .PP
2967 The
2968 .SM
2969 .B GLOBIGNORE
2970 shell variable may be used to restrict the set of file names matching a
2971 .IR pattern .
2972 If
2973 .SM
2974 .B GLOBIGNORE
2975 is set, each matching file name that also matches one of the patterns in
2976 .SM
2977 .B GLOBIGNORE
2978 is removed from the list of matches.
2979 The file names
2980 .B ``.''
2981 and
2982 .B ``..''
2983 are always ignored when
2984 .SM
2985 .B GLOBIGNORE
2986 is set and not null.  However, setting
2987 .SM
2988 .B GLOBIGNORE
2989 to a non-null value has the effect of enabling the
2990 .B dotglob
2991 shell option, so all other file names beginning with a
2992 .B ``.''
2993 will match.
2994 To get the old behavior of ignoring file names beginning with a
2995 .BR ``.'' ,
2996 make
2997 .B ``.*''
2998 one of the patterns in
2999 .SM
3000 .BR GLOBIGNORE .
3001 The
3002 .B dotglob
3003 option is disabled when
3004 .SM
3005 .B GLOBIGNORE
3006 is unset.
3007 .PP
3008 \fBPattern Matching\fP
3009 .PP
3010 Any character that appears in a pattern, other than the special pattern
3011 characters described below, matches itself.  The NUL character may not
3012 occur in a pattern.  A backslash escapes the following character; the
3013 escaping backslash is discarded when matching.
3014 The special pattern characters must be quoted if
3015 they are to be matched literally.
3016 .PP
3017 The special pattern characters have the following meanings:
3018 .PP
3019 .PD 0
3020 .TP
3021 .B *
3022 Matches any string, including the null string.
3023 When the \fBglobstar\fP shell option is enabled, and \fB*\fP is used in
3024 a filename expansion context, two adjacent \fB*\fPs used as a single
3025 pattern will match all files and zero or more directories and
3026 subdirectories.
3027 If followed by a \fB/\fP, two adjacent \fB*\fPs will match only directories
3028 and subdirectories.
3029 .TP
3030 .B ?
3031 Matches any single character.
3032 .TP
3033 .B [...]
3034 Matches any one of the enclosed characters.  A pair of characters
3035 separated by a hyphen denotes a
3036 \fIrange expression\fP;
3037 any character that sorts between those two characters, inclusive,
3038 using the current locale's collating sequence and character set,
3039 is matched.  If the first character following the
3040 .B [
3041 is a
3042 .B !
3043 or a
3044 .B ^
3045 then any character not enclosed is matched.
3046 The sorting order of characters in range expressions is determined by
3047 the current locale and the value of the \fBLC_COLLATE\fP shell variable,
3048 if set.
3049
3050 .B \-
3051 may be matched by including it as the first or last character
3052 in the set.
3053 A
3054 .B ]
3055 may be matched by including it as the first character
3056 in the set.
3057 .br
3058 .if t .sp 0.5
3059 .if n .sp 1
3060 Within
3061 .B [
3062 and
3063 .BR ] ,
3064 \fIcharacter classes\fP can be specified using the syntax
3065 \fB[:\fP\fIclass\fP\fB:]\fP, where \fIclass\fP is one of the
3066 following classes defined in the POSIX standard:
3067 .PP
3068 .RS
3069 .B
3070 .if n alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit
3071 .if t alnum   alpha   ascii   blank   cntrl   digit   graph   lower   print   punct   space   upper   word   xdigit
3072 .br
3073 A character class matches any character belonging to that class.
3074 The \fBword\fP character class matches letters, digits, and the character _.
3075 .br
3076 .if t .sp 0.5
3077 .if n .sp 1
3078 Within
3079 .B [
3080 and 
3081 .BR ] ,
3082 an \fIequivalence class\fP can be specified using the syntax
3083 \fB[=\fP\fIc\fP\fB=]\fP, which matches all characters with the
3084 same collation weight (as defined by the current locale) as
3085 the character \fIc\fP.
3086 .br
3087 .if t .sp 0.5
3088 .if n .sp 1
3089 Within
3090 .B [
3091 and 
3092 .BR ] ,
3093 the syntax \fB[.\fP\fIsymbol\fP\fB.]\fP matches the collating symbol
3094 \fIsymbol\fP.
3095 .RE
3096 .PD
3097 .PP
3098 If the \fBextglob\fP shell option is enabled using the \fBshopt\fP
3099 builtin, several extended pattern matching operators are recognized.
3100 In the following description, a \fIpattern-list\fP is a list of one
3101 or more patterns separated by a \fB|\fP.
3102 Composite patterns may be formed using one or more of the following
3103 sub-patterns:
3104 .sp 1
3105 .PD 0
3106 .RS
3107 .TP
3108 \fB?(\fP\^\fIpattern-list\^\fP\fB)\fP
3109 Matches zero or one occurrence of the given patterns
3110 .TP
3111 \fB*(\fP\^\fIpattern-list\^\fP\fB)\fP
3112 Matches zero or more occurrences of the given patterns
3113 .TP
3114 \fB+(\fP\^\fIpattern-list\^\fP\fB)\fP
3115 Matches one or more occurrences of the given patterns
3116 .TP
3117 \fB@(\fP\^\fIpattern-list\^\fP\fB)\fP
3118 Matches one of the given patterns
3119 .TP
3120 \fB!(\fP\^\fIpattern-list\^\fP\fB)\fP
3121 Matches anything except one of the given patterns
3122 .RE
3123 .PD
3124 .SS Quote Removal
3125 .PP
3126 After the preceding expansions, all unquoted occurrences of the
3127 characters
3128 .BR \e ,
3129 .BR \(aq ,
3130 and \^\f3"\fP\^ that did not result from one of the above
3131 expansions are removed.
3132 .SH REDIRECTION
3133 Before a command is executed, its input and output
3134 may be
3135 .I redirected
3136 using a special notation interpreted by the shell.
3137 Redirection may also be used to open and close files for the
3138 current shell execution environment.  The following redirection
3139 operators may precede or appear anywhere within a
3140 .I simple command
3141 or may follow a
3142 .IR command .
3143 Redirections are processed in the order they appear, from
3144 left to right.
3145 .PP
3146 In the following descriptions, if the file descriptor number is
3147 omitted, and the first character of the redirection operator is
3148 .BR < ,
3149 the redirection refers to the standard input (file descriptor
3150 0).  If the first character of the redirection operator is
3151 .BR > ,
3152 the redirection refers to the standard output (file descriptor
3153 1).
3154 .PP
3155 The word following the redirection operator in the following
3156 descriptions, unless otherwise noted, is subjected to brace expansion,
3157 tilde expansion, parameter expansion, command substitution, arithmetic
3158 expansion, quote removal, pathname expansion, and word splitting.
3159 If it expands to more than one word,
3160 .B bash
3161 reports an error.
3162 .PP
3163 Note that the order of redirections is significant.  For example, 
3164 the command
3165 .RS
3166 .PP
3167 ls \fB>\fP dirlist 2\fB>&\fP1
3168 .RE
3169 .PP
3170 directs both standard output and standard error to the file 
3171 .IR dirlist ,
3172 while the command
3173 .RS
3174 .PP
3175 ls 2\fB>&\fP1 \fB>\fP dirlist
3176 .RE
3177 .PP
3178 directs only the standard output to file
3179 .IR dirlist ,
3180 because the standard error was duplicated from the standard output
3181 before the standard output was redirected to
3182 .IR dirlist .
3183 .PP
3184 \fBBash\fP handles several filenames specially when they are used in
3185 redirections, as described in the following table:
3186 .RS
3187 .PP
3188 .PD 0
3189 .TP
3190 .B /dev/fd/\fIfd\fP
3191 If \fIfd\fP is a valid integer, file descriptor \fIfd\fP is duplicated.
3192 .TP
3193 .B /dev/stdin
3194 File descriptor 0 is duplicated.
3195 .TP
3196 .B /dev/stdout
3197 File descriptor 1 is duplicated.
3198 .TP
3199 .B /dev/stderr
3200 File descriptor 2 is duplicated.
3201 .TP
3202 .B /dev/tcp/\fIhost\fP/\fIport\fP
3203 If \fIhost\fP is a valid hostname or Internet address, and \fIport\fP
3204 is an integer port number or service name, \fBbash\fP attempts to open
3205 a TCP connection to the corresponding socket.
3206 .TP
3207 .B /dev/udp/\fIhost\fP/\fIport\fP
3208 If \fIhost\fP is a valid hostname or Internet address, and \fIport\fP
3209 is an integer port number or service name, \fBbash\fP attempts to open
3210 a UDP connection to the corresponding socket.
3211 .PD
3212 .RE
3213 .PP
3214 A failure to open or create a file causes the redirection to fail.
3215 .PP
3216 Redirections using file descriptors greater than 9 should be used with
3217 care, as they may conflict with file descriptors the shell uses
3218 internally.
3219 .SS Redirecting Input
3220 .PP
3221 Redirection of input causes the file whose name results from
3222 the expansion of
3223 .I word
3224 to be opened for reading on file descriptor
3225 .IR n ,
3226 or the standard input (file descriptor 0) if
3227 .I n
3228 is not specified.
3229 .PP
3230 The general format for redirecting input is:
3231 .RS
3232 .PP
3233 [\fIn\fP]\fB<\fP\fIword\fP
3234 .RE
3235 .SS Redirecting Output
3236 .PP
3237 Redirection of output causes the file whose name results from
3238 the expansion of
3239 .I word
3240 to be opened for writing on file descriptor
3241 .IR n ,
3242 or the standard output (file descriptor 1) if
3243 .I n
3244 is not specified.  If the file does not exist it is created;
3245 if it does exist it is truncated to zero size.
3246 .PP
3247 The general format for redirecting output is:
3248 .RS
3249 .PP
3250 [\fIn\fP]\fB>\fP\fIword\fP
3251 .RE
3252 .PP
3253 If the redirection operator is
3254 .BR > ,
3255 and the
3256 .B noclobber
3257 option to the
3258 .B set
3259 builtin has been enabled, the redirection will fail if the file
3260 whose name results from the expansion of \fIword\fP exists and is
3261 a regular file.
3262 If the redirection operator is
3263 .BR >| ,
3264 or the redirection operator is
3265 .B >
3266 and the
3267 .B noclobber
3268 option to the
3269 .B set
3270 builtin command is not enabled, the redirection is attempted even
3271 if the file named by \fIword\fP exists.
3272 .SS Appending Redirected Output
3273 .PP
3274 Redirection of output in this fashion
3275 causes the file whose name results from
3276 the expansion of
3277 .I word
3278 to be opened for appending on file descriptor
3279 .IR n ,
3280 or the standard output (file descriptor 1) if
3281 .I n
3282 is not specified.  If the file does not exist it is created.
3283 .PP
3284 The general format for appending output is:
3285 .RS
3286 .PP
3287 [\fIn\fP]\fB>>\fP\fIword\fP
3288 .RE
3289 .PP
3290 .SS Redirecting Standard Output and Standard Error
3291 .PP
3292 This construct allows both the
3293 standard output (file descriptor 1) and
3294 the standard error output (file descriptor 2)
3295 to be redirected to the file whose name is the
3296 expansion of
3297 .IR word .
3298 .PP
3299 There are two formats for redirecting standard output and
3300 standard error:
3301 .RS
3302 .PP
3303 \fB&>\fP\fIword\fP
3304 .RE
3305 and
3306 .RS
3307 \fB>&\fP\fIword\fP
3308 .RE
3309 .PP
3310 Of the two forms, the first is preferred.
3311 This is semantically equivalent to
3312 .RS
3313 .PP
3314 \fB>\fP\fIword\fP 2\fB>&\fP1
3315 .RE
3316 .PP
3317 .SS Appending Standard Output and Standard Error
3318 .PP
3319 This construct allows both the
3320 standard output (file descriptor 1) and
3321 the standard error output (file descriptor 2)
3322 to be appended to the file whose name is the
3323 expansion of
3324 .IR word .
3325 .PP
3326 The format for appending standard output and standard error is:
3327 .RS
3328 .PP
3329 \fB&>>\fP\fIword\fP
3330 .RE
3331 .PP
3332 This is semantically equivalent to
3333 .RS
3334 .PP
3335 \fB>>\fP\fIword\fP 2\fB>&\fP1
3336 .RE
3337 .SS Here Documents
3338 .PP
3339 This type of redirection instructs the shell to read input from the
3340 current source until a line containing only
3341 .I delimiter
3342 (with no trailing blanks)
3343 is seen.  All of
3344 the lines read up to that point are then used as the standard
3345 input for a command.
3346 .PP
3347 The format of here-documents is:
3348 .RS
3349 .PP
3350 .nf
3351 \fB<<\fP[\fB\-\fP]\fIword\fP
3352         \fIhere-document\fP
3353 \fIdelimiter\fP
3354 .fi
3355 .RE
3356 .PP
3357 No parameter expansion, command substitution, arithmetic expansion,
3358 or pathname expansion is performed on
3359 .IR word .
3360 If any characters in
3361 .I word
3362 are quoted, the
3363 .I delimiter
3364 is the result of quote removal on
3365 .IR word ,
3366 and the lines in the here-document are not expanded.
3367 If \fIword\fP is unquoted,
3368 all lines of the here-document are subjected to parameter expansion,
3369 command substitution, and arithmetic expansion.  In the latter
3370 case, the character sequence
3371 .B \e<newline>
3372 is ignored, and
3373 .B \e
3374 must be used to quote the characters
3375 .BR \e ,
3376 .BR $ ,
3377 and
3378 .BR \` .
3379 .PP
3380 If the redirection operator is
3381 .BR <<\- ,
3382 then all leading tab characters are stripped from input lines and the
3383 line containing
3384 .IR delimiter .
3385 This allows
3386 here-documents within shell scripts to be indented in a
3387 natural fashion.
3388 .SS "Here Strings"
3389 A variant of here documents, the format is:
3390 .RS
3391 .PP
3392 .nf
3393 \fB<<<\fP\fIword\fP
3394 .fi
3395 .RE
3396 .PP
3397 The \fIword\fP is expanded and supplied to the command on its standard
3398 input.
3399 .SS "Duplicating File Descriptors"
3400 .PP
3401 The redirection operator
3402 .RS
3403 .PP
3404 [\fIn\fP]\fB<&\fP\fIword\fP
3405 .RE
3406 .PP
3407 is used to duplicate input file descriptors.
3408 If
3409 .I word
3410 expands to one or more digits, the file descriptor denoted by
3411 .I n
3412 is made to be a copy of that file descriptor.
3413 If the digits in
3414 .I word
3415 do not specify a file descriptor open for input, a redirection error occurs.
3416 If
3417 .I word
3418 evaluates to
3419 .BR \- ,
3420 file descriptor
3421 .I n
3422 is closed.  If
3423 .I n
3424 is not specified, the standard input (file descriptor 0) is used.
3425 .PP
3426 The operator
3427 .RS
3428 .PP
3429 [\fIn\fP]\fB>&\fP\fIword\fP
3430 .RE
3431 .PP
3432 is used similarly to duplicate output file descriptors.  If
3433 .I n
3434 is not specified, the standard output (file descriptor 1) is used.
3435 If the digits in
3436 .I word
3437 do not specify a file descriptor open for output, a redirection error occurs.
3438 As a special case, if \fIn\fP is omitted, and \fIword\fP does not
3439 expand to one or more digits, the standard output and standard
3440 error are redirected as described previously.
3441 .SS "Moving File Descriptors"
3442 .PP
3443 The redirection operator
3444 .RS
3445 .PP
3446 [\fIn\fP]\fB<&\fP\fIdigit\fP\fB\-\fP
3447 .RE
3448 .PP
3449 moves the file descriptor \fIdigit\fP to file descriptor
3450 .IR n ,
3451 or the standard input (file descriptor 0) if \fIn\fP is not specified.
3452 \fIdigit\fP is closed after being duplicated to \fIn\fP.
3453 .PP
3454 Similarly, the redirection operator
3455 .RS
3456 .PP
3457 [\fIn\fP]\fB>&\fP\fIdigit\fP\fB\-\fP
3458 .RE
3459 .PP
3460 moves the file descriptor \fIdigit\fP to file descriptor
3461 .IR n ,
3462 or the standard output (file descriptor 1) if \fIn\fP is not specified.
3463 .SS "Opening File Descriptors for Reading and Writing"
3464 .PP
3465 The redirection operator
3466 .RS
3467 .PP
3468 [\fIn\fP]\fB<>\fP\fIword\fP
3469 .RE
3470 .PP
3471 causes the file whose name is the expansion of
3472 .I word
3473 to be opened for both reading and writing on file descriptor
3474 .IR n ,
3475 or on file descriptor 0 if
3476 .I n
3477 is not specified.  If the file does not exist, it is created.
3478 .SH ALIASES
3479 \fIAliases\fP allow a string to be substituted for a word when it is used
3480 as the first word of a simple command.
3481 The shell maintains a list of aliases that may be set and unset with the
3482 .B alias
3483 and
3484 .B unalias
3485 builtin commands (see
3486 .SM
3487 .B SHELL BUILTIN COMMANDS
3488 below).
3489 The first word of each simple command, if unquoted,
3490 is checked to see if it has an
3491 alias.  If so, that word is replaced by the text of the alias.
3492 The characters \fB/\fP, \fB$\fP, \fB\`\fP, and \fB=\fP and
3493 any of the shell \fImetacharacters\fP or quoting characters
3494 listed above may not appear in an alias name.
3495 The replacement text may contain any valid shell input,
3496 including shell metacharacters.
3497 The first word of the replacement text is tested
3498 for aliases, but a word that is identical to an alias being expanded
3499 is not expanded a second time.
3500 This means that one may alias
3501 .B ls
3502 to
3503 .BR "ls \-F" ,
3504 for instance, and
3505 .B bash
3506 does not try to recursively expand the replacement text.
3507 If the last character of the alias value is a
3508 .IR blank ,
3509 then the next command
3510 word following the alias is also checked for alias expansion.
3511 .PP
3512 Aliases are created and listed with the
3513 .B alias
3514 command, and removed with the
3515 .B unalias
3516 command.
3517 .PP
3518 There is no mechanism for using arguments in the replacement text.
3519 If arguments are needed, a shell function should be used (see
3520 .SM
3521 .B FUNCTIONS
3522 below).
3523 .PP
3524 Aliases are not expanded when the shell is not interactive, unless
3525 the
3526 .B expand_aliases
3527 shell option is set using
3528 .B shopt
3529 (see the description of
3530 .B shopt
3531 under
3532 .SM
3533 \fBSHELL BUILTIN COMMANDS\fP
3534 below).
3535 .PP
3536 The rules concerning the definition and use of aliases are
3537 somewhat confusing.
3538 .B Bash
3539 always reads at least one complete line
3540 of input before executing any
3541 of the commands on that line.  Aliases are expanded when a
3542 command is read, not when it is executed.  Therefore, an
3543 alias definition appearing on the same line as another
3544 command does not take effect until the next line of input is read.
3545 The commands following the alias definition
3546 on that line are not affected by the new alias.
3547 This behavior is also an issue when functions are executed.
3548 Aliases are expanded when a function definition is read,
3549 not when the function is executed, because a function definition
3550 is itself a compound command.  As a consequence, aliases
3551 defined in a function are not available until after that
3552 function is executed.  To be safe, always put
3553 alias definitions on a separate line, and do not use
3554 .B alias
3555 in compound commands.
3556 .PP
3557 For almost every purpose, aliases are superseded by
3558 shell functions.
3559 .SH FUNCTIONS
3560 A shell function, defined as described above under
3561 .SM
3562 .BR "SHELL GRAMMAR" ,
3563 stores a series of commands for later execution.
3564 When the name of a shell function is used as a simple command name,
3565 the list of commands associated with that function name is executed.
3566 Functions are executed in the context of the
3567 current shell; no new process is created to interpret
3568 them (contrast this with the execution of a shell script).
3569 When a function is executed, the arguments to the
3570 function become the positional parameters
3571 during its execution.
3572 The special parameter
3573 .B #
3574 is updated to reflect the change.  Special parameter 0
3575 is unchanged.
3576 The first element of the
3577 .SM
3578 .B FUNCNAME
3579 variable is set to the name of the function while the function
3580 is executing.
3581 All other aspects of the shell execution
3582 environment are identical between a function and its caller
3583 with the exception that the
3584 .SM
3585 .B DEBUG
3586 and
3587 .B RETURN
3588 traps (see the description of the
3589 .B trap
3590 builtin under
3591 .SM
3592 .B SHELL BUILTIN COMMANDS
3593 below) are not inherited unless the function has been given the
3594 \fBtrace\fP attribute (see the description of the
3595 .SM
3596 .B declare
3597 builtin below) or the
3598 \fB\-o functrace\fP shell option has been enabled with
3599 the \fBset\fP builtin
3600 (in which case all functions inherit the \fBDEBUG\fP and \fBRETURN\fP traps).
3601 .PP
3602 Variables local to the function may be declared with the
3603 .B local
3604 builtin command.  Ordinarily, variables and their values
3605 are shared between the function and its caller.
3606 .PP
3607 If the builtin command
3608 .B return
3609 is executed in a function, the function completes and
3610 execution resumes with the next command after the function
3611 call.
3612 Any command associated with the \fBRETURN\fP trap is executed
3613 before execution resumes.
3614 When a function completes, the values of the
3615 positional parameters and the special parameter
3616 .B #
3617 are restored to the values they had prior to the function's
3618 execution.
3619 .PP
3620 Function names and definitions may be listed with the
3621 .B \-f
3622 option to the
3623 .B declare
3624 or
3625 .B typeset
3626 builtin commands.  The
3627 .B \-F
3628 option to
3629 .B declare
3630 or
3631 .B typeset
3632 will list the function names only
3633 (and optionally the source file and line number, if the \fBextdebug\fP
3634 shell option is enabled).
3635 Functions may be exported so that subshells
3636 automatically have them defined with the
3637 .B \-f
3638 option to the 
3639 .B export
3640 builtin.
3641 A function definition may be deleted using the \fB\-f\fP option to
3642 the
3643 .B unset
3644 builtin.
3645 Note that shell functions and variables with the same name may result
3646 in multiple identically-named entries in the environment passed to the
3647 shell's children.
3648 Care should be taken in cases where this may cause a problem.
3649 .PP
3650 Functions may be recursive.  No limit is imposed on the number
3651 of recursive calls.
3652 .SH "ARITHMETIC EVALUATION"
3653 The shell allows arithmetic expressions to be evaluated, under
3654 certain circumstances (see the \fBlet\fP and \fBdeclare\fP builtin
3655 commands and \fBArithmetic Expansion\fP).
3656 Evaluation is done in fixed-width integers with no check for overflow,
3657 though division by 0 is trapped and flagged as an error.
3658 The operators and their precedence, associativity, and values
3659 are the same as in the C language.
3660 The following list of operators is grouped into levels of
3661 equal-precedence operators.
3662 The levels are listed in order of decreasing precedence.
3663 .PP
3664 .PD 0
3665 .TP
3666 .B \fIid\fP++ \fIid\fP\-\-
3667 variable post-increment and post-decrement
3668 .TP
3669 .B ++\fIid\fP \-\-\fIid\fP
3670 variable pre-increment and pre-decrement
3671 .TP
3672 .B \- +
3673 unary minus and plus
3674 .TP
3675 .B ! ~
3676 logical and bitwise negation
3677 .TP
3678 .B **
3679 exponentiation
3680 .TP
3681 .B * / %
3682 multiplication, division, remainder
3683 .TP
3684 .B + \-
3685 addition, subtraction
3686 .TP
3687 .B << >>
3688 left and right bitwise shifts
3689 .TP
3690 .B <= >= < >
3691 comparison
3692 .TP
3693 .B == !=
3694 equality and inequality
3695 .TP
3696 .B &
3697 bitwise AND
3698 .TP
3699 .B ^
3700 bitwise exclusive OR
3701 .TP
3702 .B |
3703 bitwise OR
3704 .TP
3705 .B &&
3706 logical AND
3707 .TP
3708 .B ||
3709 logical OR
3710 .TP
3711 .B \fIexpr\fP?\fIexpr\fP:\fIexpr\fP
3712 conditional operator
3713 .TP
3714 .B = *= /= %= += \-= <<= >>= &= ^= |=
3715 assignment
3716 .TP
3717 .B \fIexpr1\fP , \fIexpr2\fP
3718 comma
3719 .PD
3720 .PP
3721 Shell variables are allowed as operands; parameter expansion is
3722 performed before the expression is evaluated.
3723 Within an expression, shell variables may also be referenced by name
3724 without using the parameter expansion syntax.
3725 A shell variable that is null or unset evaluates to 0 when referenced
3726 by name without using the parameter expansion syntax.
3727 The value of a variable is evaluated as an arithmetic expression
3728 when it is referenced, or when a variable which has been given the
3729 \fIinteger\fP attribute using \fBdeclare -i\fP is assigned a value.
3730 A null value evaluates to 0.
3731 A shell variable need not have its integer attribute
3732 turned on to be used in an expression.
3733 .PP
3734 Constants with a leading 0 are interpreted as octal numbers.
3735 A leading 0x or 0X denotes hexadecimal.
3736 Otherwise, numbers take the form [\fIbase#\fP]n, where \fIbase\fP
3737 is a decimal number between 2 and 64 representing the arithmetic
3738 base, and \fIn\fP is a number in that base.
3739 If \fIbase#\fP is omitted, then base 10 is used.
3740 The digits greater than 9 are represented by the lowercase letters,
3741 the uppercase letters, @, and _, in that order.
3742 If \fIbase\fP is less than or equal to 36, lowercase and uppercase
3743 letters may be used interchangeably to represent numbers between 10
3744 and 35.
3745 .PP
3746 Operators are evaluated in order of precedence.  Sub-expressions in
3747 parentheses are evaluated first and may override the precedence
3748 rules above.
3749 .SH "CONDITIONAL EXPRESSIONS"
3750 Conditional expressions are used by the \fB[[\fP compound command and
3751 the \fBtest\fP and \fB[\fP builtin commands to test file attributes
3752 and perform string and arithmetic comparisons.
3753 Expressions are formed from the following unary or binary primaries.
3754 If any \fIfile\fP argument to one of the primaries is of the form
3755 \fI/dev/fd/n\fP, then file descriptor \fIn\fP is checked.
3756 If the \fIfile\fP argument to one of the primaries is one of
3757 \fI/dev/stdin\fP, \fI/dev/stdout\fP, or \fI/dev/stderr\fP, file
3758 descriptor 0, 1, or 2, respectively, is checked.
3759 .PP
3760 Unless otherwise specified, primaries that operate on files follow symbolic
3761 links and operate on the target of the link, rather than the link itself.
3762 .sp 1
3763 .PD 0
3764 .TP
3765 .B \-a \fIfile\fP
3766 True if \fIfile\fP exists.
3767 .TP
3768 .B \-b \fIfile\fP
3769 True if \fIfile\fP exists and is a block special file.
3770 .TP
3771 .B \-c \fIfile\fP
3772 True if \fIfile\fP exists and is a character special file.
3773 .TP
3774 .B \-d \fIfile\fP
3775 True if \fIfile\fP exists and is a directory.
3776 .TP
3777 .B \-e \fIfile\fP
3778 True if \fIfile\fP exists.
3779 .TP
3780 .B \-f \fIfile\fP
3781 True if \fIfile\fP exists and is a regular file.
3782 .TP
3783 .B \-g \fIfile\fP
3784 True if \fIfile\fP exists and is set-group-id.
3785 .TP
3786 .B \-h \fIfile\fP
3787 True if \fIfile\fP exists and is a symbolic link.
3788 .TP
3789 .B \-k \fIfile\fP
3790 True if \fIfile\fP exists and its ``sticky'' bit is set.
3791 .TP
3792 .B \-p \fIfile\fP
3793 True if \fIfile\fP exists and is a named pipe (FIFO).
3794 .TP
3795 .B \-r \fIfile\fP
3796 True if \fIfile\fP exists and is readable.
3797 .TP
3798 .B \-s \fIfile\fP
3799 True if \fIfile\fP exists and has a size greater than zero.
3800 .TP
3801 .B \-t \fIfd\fP
3802 True if file descriptor
3803 .I fd
3804 is open and refers to a terminal.
3805 .TP
3806 .B \-u \fIfile\fP
3807 True if \fIfile\fP exists and its set-user-id bit is set.
3808 .TP
3809 .B \-w \fIfile\fP
3810 True if \fIfile\fP exists and is writable.
3811 .TP
3812 .B \-x \fIfile\fP
3813 True if \fIfile\fP exists and is executable.
3814 .TP
3815 .B \-O \fIfile\fP
3816 True if \fIfile\fP exists and is owned by the effective user id.
3817 .TP
3818 .B \-G \fIfile\fP
3819 True if \fIfile\fP exists and is owned by the effective group id.
3820 .TP
3821 .B \-L \fIfile\fP
3822 True if \fIfile\fP exists and is a symbolic link.
3823 .TP
3824 .B \-S \fIfile\fP
3825 True if \fIfile\fP exists and is a socket.
3826 .TP
3827 .B \-N \fIfile\fP
3828 True if \fIfile\fP exists and has been modified since it was last read.
3829 .TP
3830 \fIfile1\fP \-\fBnt\fP \fIfile2\fP
3831 True if \fIfile1\fP is newer (according to modification date) than \fIfile2\fP,
3832 or if \fIfile1\fP exists and \fPfile2\fP does not.
3833 .TP
3834 \fIfile1\fP \-\fBot\fP \fIfile2\fP
3835 True if \fIfile1\fP is older than \fIfile2\fP, or if \fIfile2\fP exists
3836 and \fIfile1\fP does not.
3837 .TP
3838 \fIfile1\fP \fB\-ef\fP \fIfile2\fP
3839 True if \fIfile1\fP and \fIfile2\fP refer to the same device and
3840 inode numbers.
3841 .TP
3842 .B \-o \fIoptname\fP
3843 True if shell option
3844 .I optname
3845 is enabled.
3846 See the list of options under the description of the
3847 .B \-o
3848 option to the
3849 .B set
3850 builtin below.
3851 .TP
3852 .B \-z \fIstring\fP
3853 True if the length of \fIstring\fP is zero.
3854 .TP
3855 \fIstring\fP
3856 .PD 0
3857 .TP
3858 .B \-n \fIstring\fP
3859 .PD
3860 True if the length of
3861 .I string
3862 is non-zero.
3863 .TP
3864 \fIstring1\fP \fB==\fP \fIstring2\fP
3865 True if the strings are equal.  \fB=\fP may be used in place of
3866 \fB==\fP for strict POSIX compliance.
3867 .TP
3868 \fIstring1\fP \fB!=\fP \fIstring2\fP
3869 True if the strings are not equal.
3870 .TP
3871 \fIstring1\fP \fB<\fP \fIstring2\fP
3872 True if \fIstring1\fP sorts before \fIstring2\fP lexicographically
3873 in the current locale.
3874 .TP
3875 \fIstring1\fP \fB>\fP \fIstring2\fP
3876 True if \fIstring1\fP sorts after \fIstring2\fP lexicographically
3877 in the current locale.
3878 .TP
3879 .I \fIarg1\fP \fBOP\fP \fIarg2\fP
3880 .SM
3881 .B OP
3882 is one of
3883 .BR \-eq ,
3884 .BR \-ne ,
3885 .BR \-lt ,
3886 .BR \-le ,
3887 .BR \-gt ,
3888 or
3889 .BR \-ge .
3890 These arithmetic binary operators return true if \fIarg1\fP
3891 is equal to, not equal to, less than, less than or equal to,
3892 greater than, or greater than or equal to \fIarg2\fP, respectively.
3893 .I Arg1
3894 and
3895 .I arg2
3896 may be positive or negative integers.
3897 .PD
3898 .SH "SIMPLE COMMAND EXPANSION"
3899 When a simple command is executed, the shell performs the following
3900 expansions, assignments, and redirections, from left to right.
3901 .IP 1.
3902 The words that the parser has marked as variable assignments (those
3903 preceding the command name) and redirections are saved for later
3904 processing.
3905 .IP 2.
3906 The words that are not variable assignments or redirections are
3907 expanded.  If any words remain after expansion, the first word
3908 is taken to be the name of the command and the remaining words are
3909 the arguments.
3910 .IP 3.
3911 Redirections are performed as described above under
3912 .SM
3913 .BR REDIRECTION .
3914 .IP 4.
3915 The text after the \fB=\fP in each variable assignment undergoes tilde
3916 expansion, parameter expansion, command substitution, arithmetic expansion,
3917 and quote removal before being assigned to the variable.
3918 .PP
3919 If no command name results, the variable assignments affect the current
3920 shell environment.  Otherwise, the variables are added to the environment
3921 of the executed command and do not affect the current shell environment.
3922 If any of the assignments attempts to assign a value to a readonly variable,
3923 an error occurs, and the command exits with a non-zero status.
3924 .PP
3925 If no command name results, redirections are performed, but do not
3926 affect the current shell environment.  A redirection error causes the
3927 command to exit with a non-zero status.
3928 .PP
3929 If there is a command name left after expansion, execution proceeds as
3930 described below.  Otherwise, the command exits.  If one of the expansions
3931 contained a command substitution, the exit status of the command is
3932 the exit status of the last command substitution performed.  If there
3933 were no command substitutions, the command exits with a status of zero.
3934 .SH "COMMAND EXECUTION"
3935 After a command has been split into words, if it results in a
3936 simple command and an optional list of arguments, the following
3937 actions are taken.
3938 .PP
3939 If the command name contains no slashes, the shell attempts to
3940 locate it.  If there exists a shell function by that name, that
3941 function is invoked as described above in
3942 .SM
3943 .BR FUNCTIONS .
3944 If the name does not match a function, the shell searches for
3945 it in the list of shell builtins.  If a match is found, that
3946 builtin is invoked.
3947 .PP
3948 If the name is neither a shell function nor a builtin,
3949 and contains no slashes,
3950 .B bash
3951 searches each element of the
3952 .SM
3953 .B PATH
3954 for a directory containing an executable file by that name.
3955 .B Bash
3956 uses a hash table to remember the full pathnames of executable
3957 files (see
3958 .B hash
3959 under
3960 .SM
3961 .B "SHELL BUILTIN COMMANDS"
3962 below).
3963 A full search of the directories in
3964 .SM
3965 .B PATH
3966 is performed only if the command is not found in the hash table.
3967 If the search is unsuccessful, the shell searches for a defined shell
3968 function named \fBcommand_not_found_handle\fP.
3969 If that function exists, it is invoked with the original command and
3970 the original command's arguments as its arguments, and the function's
3971 exit status becomes the exit status of the shell.
3972 If that function is not defined, the shell prints an error
3973 message and returns an exit status of 127.
3974 .PP
3975 If the search is successful, or if the command name contains
3976 one or more slashes, the shell executes the named program in a
3977 separate execution environment.
3978 Argument 0 is set to the name given, and the remaining arguments
3979 to the command are set to the arguments given, if any.
3980 .PP
3981 If this execution fails because the file is not in executable
3982 format, and the file is not a directory, it is assumed to be
3983 a \fIshell script\fP, a file
3984 containing shell commands.  A subshell is spawned to execute
3985 it.  This subshell reinitializes itself, so
3986 that the effect is as if a new shell had been invoked
3987 to handle the script, with the exception that the locations of
3988 commands remembered by the parent (see
3989 .B hash
3990 below under
3991 .SM
3992 \fBSHELL BUILTIN COMMANDS\fP)
3993 are retained by the child.
3994 .PP
3995 If the program is a file beginning with
3996 .BR #! ,
3997 the remainder of the first line specifies an interpreter
3998 for the program.  The shell executes the
3999 specified interpreter on operating systems that do not
4000 handle this executable format themselves.  The arguments to the 
4001 interpreter consist of a single optional argument following the
4002 interpreter name on the first line of the program, followed
4003 by the name of the program, followed by the command
4004 arguments, if any.
4005 .SH COMMAND EXECUTION ENVIRONMENT
4006 The shell has an \fIexecution environment\fP, which consists of the
4007 following:
4008 .sp 1
4009 .IP \(bu
4010 open files inherited by the shell at invocation, as modified by
4011 redirections supplied to the \fBexec\fP builtin
4012 .IP \(bu
4013 the current working directory as set by \fBcd\fP, \fBpushd\fP, or
4014 \fBpopd\fP, or inherited by the shell at invocation
4015 .IP \(bu
4016 the file creation mode mask as set by \fBumask\fP or inherited from
4017 the shell's parent
4018 .IP \(bu
4019 current traps set by \fBtrap\fP
4020 .IP \(bu
4021 shell parameters that are set by variable assignment or with \fBset\fP
4022 or inherited from the shell's parent in the environment
4023 .IP \(bu
4024 shell functions defined during execution or inherited from the shell's
4025 parent in the environment
4026 .IP \(bu
4027 options enabled at invocation (either by default or with command-line
4028 arguments) or by \fBset\fP
4029 .IP \(bu
4030 options enabled by \fBshopt\fP
4031 .IP \(bu
4032 shell aliases defined with \fBalias\fP
4033 .IP \(bu
4034 various process IDs, including those of background jobs, the value
4035 of \fB$$\fP, and the value of \fB$PPID\fP
4036 .PP
4037 When a simple command other than a builtin or shell function
4038 is to be executed, it
4039 is invoked in a separate execution environment that consists of
4040 the following.  Unless otherwise noted, the values are inherited
4041 from the shell.
4042 .sp 1
4043 .IP \(bu
4044 the shell's open files, plus any modifications and additions specified
4045 by redirections to the command
4046 .IP \(bu
4047 the current working directory
4048 .IP \(bu
4049 the file creation mode mask
4050 .IP \(bu
4051 shell variables and functions marked for export, along with variables
4052 exported for the command, passed in the environment
4053 .IP \(bu
4054 traps caught by the shell are reset to the values inherited from the
4055 shell's parent, and traps ignored by the shell are ignored
4056 .PP
4057 A command invoked in this separate environment cannot affect the
4058 shell's execution environment. 
4059 .PP
4060 Command substitution, commands grouped with parentheses,
4061 and asynchronous commands are invoked in a
4062 subshell environment that is a duplicate of the shell environment,
4063 except that traps caught by the shell are reset to the values
4064 that the shell inherited from its parent at invocation.  Builtin
4065 commands that are invoked as part of a pipeline are also executed in a
4066 subshell environment.  Changes made to the subshell environment
4067 cannot affect the shell's execution environment.
4068 .PP
4069 Subshells spawned to execute command substitutions inherit the value of
4070 the \fB\-e\fP option from the parent shell.  When not in posix mode,
4071 Bash clears the \fB\-e\fP option in such subshells.
4072 .PP
4073 If a command is followed by a \fB&\fP and job control is not active, the
4074 default standard input for the command is the empty file \fI/dev/null\fP.
4075 Otherwise, the invoked command inherits the file descriptors of the calling
4076 shell as modified by redirections.
4077 .SH ENVIRONMENT
4078 When a program is invoked it is given an array of strings
4079 called the
4080 .IR environment .
4081 This is a list of 
4082 \fIname\fP\-\fIvalue\fP pairs, of the form
4083 .IR "name\fR=\fPvalue" .
4084 .PP
4085 The shell provides several ways to manipulate the environment.
4086 On invocation, the shell scans its own environment and
4087 creates a parameter for each name found, automatically marking
4088 it for
4089 .I export
4090 to child processes.  Executed commands inherit the environment.
4091 The
4092 .B export
4093 and
4094 .B declare \-x
4095 commands allow parameters and functions to be added to and
4096 deleted from the environment.  If the value of a parameter
4097 in the environment is modified, the new value becomes part
4098 of the environment, replacing the old.  The environment
4099 inherited by any executed command consists of the shell's
4100 initial environment, whose values may be modified in the shell,
4101 less any pairs removed by the
4102 .B unset
4103 command, plus any additions via the
4104 .B export
4105 and
4106 .B declare \-x
4107 commands.
4108 .PP
4109 The environment for any
4110 .I simple command
4111 or function may be augmented temporarily by prefixing it with
4112 parameter assignments, as described above in
4113 .SM
4114 .BR PARAMETERS .
4115 These assignment statements affect only the environment seen
4116 by that command.
4117 .PP
4118 If the 
4119 .B \-k
4120 option is set (see the
4121 .B set
4122 builtin command below), then
4123 .I all
4124 parameter assignments are placed in the environment for a command,
4125 not just those that precede the command name.
4126 .PP
4127 When
4128 .B bash
4129 invokes an external command, the variable
4130 .B _
4131 is set to the full file name of the command and passed to that
4132 command in its environment.
4133 .SH "EXIT STATUS"
4134 .PP
4135 The exit status of an executed command is the value returned by the
4136 \fIwaitpid\fP system call or equivalent function.  Exit statuses
4137 fall between 0 and 255, though, as explained below, the shell may
4138 use values above 125 specially.  Exit statuses from shell builtins and
4139 compound commands are also limited to this range. Under certain
4140 circumstances, the shell will use special values to indicate specific
4141 failure modes.
4142 .PP
4143 For the shell's purposes, a command which exits with a 
4144 zero exit status has succeeded.  An exit status of zero
4145 indicates success.  A non-zero exit status indicates failure.
4146 When a command terminates on a fatal signal \fIN\fP, \fBbash\fP uses
4147 the value of 128+\fIN\fP as the exit status.
4148 .PP
4149 If a command is not found, the child process created to
4150 execute it returns a status of 127.  If a command is found
4151 but is not executable, the return status is 126.
4152 .PP
4153 If a command fails because of an error during expansion or redirection,
4154 the exit status is greater than zero.
4155 .PP
4156 Shell builtin commands return a status of 0 (\fItrue\fP) if
4157 successful, and non-zero (\fIfalse\fP) if an error occurs
4158 while they execute. 
4159 All builtins return an exit status of 2 to indicate incorrect usage.
4160 .PP
4161 \fBBash\fP itself returns the exit status of the last command
4162 executed, unless a syntax error occurs, in which case it exits
4163 with a non-zero value.  See also the \fBexit\fP builtin
4164 command below.
4165 .SH SIGNALS
4166 When \fBbash\fP is interactive, in the absence of any traps, it ignores
4167 .SM
4168 .B SIGTERM
4169 (so that \fBkill 0\fP does not kill an interactive shell),
4170 and
4171 .SM
4172 .B SIGINT
4173 is caught and handled (so that the \fBwait\fP builtin is interruptible).
4174 In all cases, \fBbash\fP ignores
4175 .SM
4176 .BR SIGQUIT .
4177 If job control is in effect,
4178 .B bash
4179 ignores
4180 .SM
4181 .BR SIGTTIN ,
4182 .SM
4183 .BR SIGTTOU ,
4184 and
4185 .SM
4186 .BR SIGTSTP .
4187 .PP
4188 Non-builtin commands run by \fBbash\fP have signal handlers
4189 set to the values inherited by the shell from its parent.
4190 When job control is not in effect, asynchronous commands
4191 ignore
4192 .SM
4193 .B SIGINT
4194 and
4195 .SM
4196 .B SIGQUIT
4197 in addition to these inherited handlers.
4198 Commands run as a result of command substitution ignore the
4199 keyboard-generated job control signals
4200 .SM
4201 .BR SIGTTIN ,
4202 .SM
4203 .BR SIGTTOU ,
4204 and
4205 .SM
4206 .BR SIGTSTP .
4207 .PP
4208 The shell exits by default upon receipt of a
4209 .SM
4210 .BR SIGHUP .
4211 Before exiting, an interactive shell resends the
4212 .SM
4213 .B SIGHUP
4214 to all jobs, running or stopped.
4215 Stopped jobs are sent
4216 .SM
4217 .B SIGCONT
4218 to ensure that they receive the
4219 .SM
4220 .BR SIGHUP .
4221 To prevent the shell from
4222 sending the signal to a particular job, it should be removed from the
4223 jobs table with the 
4224 .B disown
4225 builtin (see
4226 .SM
4227 .B "SHELL BUILTIN COMMANDS"
4228 below) or marked 
4229 to not receive
4230 .SM
4231 .B SIGHUP
4232 using
4233 .BR "disown \-h" .
4234 .PP
4235 If the
4236 .B huponexit
4237 shell option has been set with
4238 .BR shopt ,
4239 .B bash
4240 sends a 
4241 .SM
4242 .B SIGHUP
4243 to all jobs when an interactive login shell exits.
4244 .PP
4245 If \fBbash\fP is waiting for a command to complete and receives a signal
4246 for which a trap has been set, the trap will not be executed until
4247 the command completes. 
4248 When \fBbash\fP is waiting for an asynchronous command via the \fBwait\fP
4249 builtin, the reception of a signal for which a trap has been set will
4250 cause the \fBwait\fP builtin to return immediately with an exit status
4251 greater than 128, immediately after which the trap is executed.
4252 .SH "JOB CONTROL"
4253 .I Job control
4254 refers to the ability to selectively stop (\fIsuspend\fP)
4255 the execution of processes and continue (\fIresume\fP)
4256 their execution at a later point.  A user typically employs
4257 this facility via an interactive interface supplied jointly
4258 by the system's terminal driver and
4259 .BR bash .
4260 .PP
4261 The shell associates a
4262 .I job
4263 with each pipeline.  It keeps a table of currently executing
4264 jobs, which may be listed with the
4265 .B jobs
4266 command.  When
4267 .B bash
4268 starts a job asynchronously (in the
4269 .IR background ),
4270 it prints a line that looks like:
4271 .RS
4272 .PP
4273 [1] 25647
4274 .RE
4275 .PP
4276 indicating that this job is job number 1 and that the process ID
4277 of the last process in the pipeline associated with this job is 25647.
4278 All of the processes in a single pipeline are members of the same job.
4279 .B Bash
4280 uses the
4281 .I job
4282 abstraction as the basis for job control.
4283 .PP
4284 To facilitate the implementation of the user interface to job
4285 control, the operating system maintains the notion of a \fIcurrent terminal
4286 process group ID\fP.  Members of this process group (processes whose
4287 process group ID is equal to the current terminal process group ID)
4288 receive keyboard-generated signals such as
4289 .SM
4290 .BR SIGINT .
4291 These processes are said to be in the
4292 .IR foreground .
4293 .I Background
4294 processes are those whose process group ID differs from the terminal's;
4295 such processes are immune to keyboard-generated signals.
4296 Only foreground processes are allowed to read from or write to the
4297 terminal.  Background processes which attempt to read from (write to) the
4298 terminal are sent a 
4299 .SM
4300 .B SIGTTIN (SIGTTOU)
4301 signal by the terminal driver, 
4302 which, unless caught, suspends the process.
4303 .PP
4304 If the operating system on which
4305 .B bash
4306 is running supports
4307 job control,
4308 .B bash
4309 contains facilities to use it.
4310 Typing the
4311 .I suspend
4312 character (typically
4313 .BR ^Z ,
4314 Control-Z) while a process is running
4315 causes that process to be stopped and returns control to 
4316 .BR bash .
4317 Typing the
4318 .I "delayed suspend"
4319 character (typically
4320 .BR ^Y ,
4321 Control-Y) causes the process to be stopped when it
4322 attempts to read input from the terminal, and control to
4323 be returned to
4324 .BR bash .
4325 The user may then manipulate the state of this job, using the
4326 .B bg
4327 command to continue it in the background, the
4328 .B fg
4329 command to continue it in the foreground, or
4330 the
4331 .B kill
4332 command to kill it.  A \fB^Z\fP takes effect immediately,
4333 and has the additional side effect of causing pending output
4334 and typeahead to be discarded.
4335 .PP
4336 There are a number of ways to refer to a job in the shell.
4337 The character
4338 .B %
4339 introduces a job specification (\fIjobspec\fP).  Job number
4340 .I n
4341 may be referred to as
4342 .BR %n .
4343 A job may also be referred to using a prefix of the name used to
4344 start it, or using a substring that appears in its command line.
4345 For example,
4346 .B %ce
4347 refers to a stopped
4348 .B ce
4349 job.  If a prefix matches more than one job,
4350 .B bash
4351 reports an error.  Using
4352 .BR %?ce ,
4353 on the other hand, refers to any job containing the string
4354 .B ce
4355 in its command line.  If the substring matches more than one job,
4356 .B bash
4357 reports an error.  The symbols
4358 .B %%
4359 and
4360 .B %+
4361 refer to the shell's notion of the
4362 .IR "current job" ,
4363 which is the last job stopped while it was in
4364 the foreground or started in the background.
4365 The 
4366 .I "previous job"
4367 may be referenced using
4368 .BR %\- .
4369 If there is only a single job, \fB%+\fP and \fB%\-\fP can both be used
4370 to refer to that job.
4371 In output pertaining to jobs (e.g., the output of the
4372 .B jobs
4373 command), the current job is always flagged with a
4374 .BR + ,
4375 and the previous job with a
4376 .BR \- .
4377 A single % (with no accompanying job specification) also refers to the
4378 current job.
4379 .PP
4380 Simply naming a job can be used to bring it into the
4381 foreground:
4382 .B %1
4383 is a synonym for
4384 \fB``fg %1''\fP,
4385 bringing job 1 from the background into the foreground.
4386 Similarly,
4387 .B ``%1 &''
4388 resumes job 1 in the background, equivalent to
4389 \fB``bg %1''\fP.
4390 .PP
4391 The shell learns immediately whenever a job changes state.
4392 Normally,
4393 .B bash
4394 waits until it is about to print a prompt before reporting
4395 changes in a job's status so as to not interrupt
4396 any other output.  If the 
4397 .B \-b
4398 option to the
4399 .B set
4400 builtin command
4401 is enabled,
4402 .B bash
4403 reports such changes immediately.
4404 Any trap on
4405 .SM
4406 .B SIGCHLD
4407 is executed for each child that exits.
4408 .PP
4409 If an attempt to exit
4410 .B bash
4411 is made while jobs are stopped (or, if the \fBcheckjobs\fP shell option has
4412 been enabled using the \fBshopt\fP builtin, running), the shell prints a
4413 warning message, and, if the \fBcheckjobs\fP option is enabled, lists the
4414 jobs and their statuses.
4415 The
4416 .B jobs
4417 command may then be used to inspect their status. 
4418 If a second attempt to exit is made without an intervening command,
4419 the shell does not print another warning, and any stopped
4420 jobs are terminated.
4421 .SH PROMPTING
4422 When executing interactively, 
4423 .B bash
4424 displays the primary prompt
4425 .SM
4426 .B PS1
4427 when it is ready to read a command, and the secondary prompt
4428 .SM
4429 .B PS2
4430 when it needs more input to complete a command.
4431 .B Bash
4432 allows these prompt strings to be customized by inserting a number of
4433 backslash-escaped special characters that are decoded as follows:
4434 .RS
4435 .PD 0
4436 .TP
4437 .B \ea
4438 an ASCII bell character (07)
4439 .TP
4440 .B \ed
4441 the date in "Weekday Month Date" format (e.g., "Tue May 26")
4442 .TP
4443 .B \eD{\fIformat\fP}
4444 the \fIformat\fP is passed to \fIstrftime\fP(3) and the result is inserted
4445 into the prompt string; an empty \fIformat\fP results in a locale-specific
4446 time representation.  The braces are required
4447 .TP
4448 .B \ee
4449 an ASCII escape character (033)
4450 .TP
4451 .B \eh
4452 the hostname up to the first `.'
4453 .TP
4454 .B \eH
4455 the hostname
4456 .TP
4457 .B \ej
4458 the number of jobs currently managed by the shell
4459 .TP
4460 .B \el
4461 the basename of the shell's terminal device name
4462 .TP
4463 .B \en
4464 newline
4465 .TP
4466 .B \er
4467 carriage return
4468 .TP
4469 .B \es
4470 the name of the shell, the basename of
4471 .B $0
4472 (the portion following the final slash)
4473 .TP
4474 .B \et
4475 the current time in 24-hour HH:MM:SS format
4476 .TP
4477 .B \eT
4478 the current time in 12-hour HH:MM:SS format
4479 .TP
4480 .B \e@
4481 the current time in 12-hour am/pm format
4482 .TP
4483 .B \eA
4484 the current time in 24-hour HH:MM format
4485 .TP
4486 .B \eu
4487 the username of the current user
4488 .TP
4489 .B \ev
4490 the version of \fBbash\fP (e.g., 2.00)
4491 .TP
4492 .B \eV
4493 the release of \fBbash\fP, version + patch level (e.g., 2.00.0)
4494 .TP
4495 .B \ew
4496 the current working directory, with \fB$HOME\fP abbreviated with a tilde
4497 (uses the \fB$PROMPT_DIRTRIM\fP variable)
4498 .TP
4499 .B \eW
4500 the basename of the current working directory, with \fB$HOME\fP
4501 abbreviated with a tilde
4502 .TP
4503 .B \e!
4504 the history number of this command
4505 .TP
4506 .B \e#
4507 the command number of this command
4508 .TP
4509 .B \e$
4510 if the effective UID is 0, a
4511 .BR # ,
4512 otherwise a
4513 .B $
4514 .TP
4515 .B \e\fInnn\fP
4516 the character corresponding to the octal number \fInnn\fP
4517 .TP
4518 .B \e\e
4519 a backslash
4520 .TP
4521 .B \e[
4522 begin a sequence of non-printing characters, which could be used to
4523 embed a terminal control sequence into the prompt
4524 .TP
4525 .B \e]
4526 end a sequence of non-printing characters
4527 .PD
4528 .RE
4529 .PP
4530 The command number and the history number are usually different:
4531 the history number of a command is its position in the history
4532 list, which may include commands restored from the history file
4533 (see
4534 .SM
4535 .B HISTORY
4536 below), while the command number is the position in the sequence
4537 of commands executed during the current shell session.
4538 After the string is decoded, it is expanded via
4539 parameter expansion, command substitution, arithmetic
4540 expansion, and quote removal, subject to the value of the
4541 .B promptvars
4542 shell option (see the description of the
4543 .B shopt
4544 command under
4545 .SM
4546 .B "SHELL BUILTIN COMMANDS"
4547 below).
4548 .SH READLINE
4549 This is the library that handles reading input when using an interactive
4550 shell, unless the
4551 .B \-\-noediting
4552 option is given at shell invocation.
4553 Line editing is also used when using the \fB\-e\fP option to the
4554 \fBread\fP builtin.
4555 By default, the line editing commands are similar to those of emacs.
4556 A vi-style line editing interface is also available.
4557 Line editing can be enabled at any time using the
4558 .B \-o emacs
4559 or
4560 .B \-o vi
4561 options to the
4562 .B set
4563 builtin (see
4564 .SM
4565 .B SHELL BUILTIN COMMANDS
4566 below).
4567 To turn off line editing after the shell is running, use the
4568 .B +o emacs
4569 or
4570 .B +o vi
4571 options to the
4572 .B set
4573 builtin.
4574 .SS "Readline Notation"
4575 .PP
4576 In this section, the emacs-style notation is used to denote
4577 keystrokes.  Control keys are denoted by C\-\fIkey\fR, e.g., C\-n
4578 means Control\-N.  Similarly, 
4579 .I meta
4580 keys are denoted by M\-\fIkey\fR, so M\-x means Meta\-X.  (On keyboards
4581 without a 
4582 .I meta
4583 key, M\-\fIx\fP means ESC \fIx\fP, i.e., press the Escape key
4584 then the
4585 .I x
4586 key.  This makes ESC the \fImeta prefix\fP.
4587 The combination M\-C\-\fIx\fP means ESC\-Control\-\fIx\fP,
4588 or press the Escape key
4589 then hold the Control key while pressing the
4590 .I x
4591 key.)
4592 .PP
4593 Readline commands may be given numeric
4594 .IR arguments ,
4595 which normally act as a repeat count.
4596 Sometimes, however, it is the sign of the argument that is significant.
4597 Passing a negative argument to a command that acts in the forward
4598 direction (e.g., \fBkill\-line\fP) causes that command to act in a
4599 backward direction. 
4600 Commands whose behavior with arguments deviates from this are noted
4601 below.
4602 .PP
4603 When a command is described as \fIkilling\fP text, the text
4604 deleted is saved for possible future retrieval
4605 (\fIyanking\fP).  The killed text is saved in a
4606 \fIkill ring\fP.  Consecutive kills cause the text to be
4607 accumulated into one unit, which can be yanked all at once. 
4608 Commands which do not kill text separate the chunks of text
4609 on the kill ring.
4610 .SS "Readline Initialization"
4611 .PP
4612 Readline is customized by putting commands in an initialization
4613 file (the \fIinputrc\fP file).
4614 The name of this file is taken from the value of the
4615 .SM
4616 .B INPUTRC
4617 variable.  If that variable is unset, the default is
4618 .IR ~/.inputrc .
4619 When a program which uses the readline library starts up, the
4620 initialization file is read, and the key bindings and variables
4621 are set.
4622 There are only a few basic constructs allowed in the
4623 readline initialization file.
4624 Blank lines are ignored.
4625 Lines beginning with a \fB#\fP are comments.
4626 Lines beginning with a \fB$\fP indicate conditional constructs.
4627 Other lines denote key bindings and variable settings.
4628 .PP
4629 The default key-bindings may be changed with an
4630 .I inputrc 
4631 file.
4632 Other programs that use this library may add their own commands
4633 and bindings.
4634 .PP
4635 For example, placing
4636 .RS
4637 .PP
4638 M\-Control\-u: universal\-argument
4639 .RE
4640 or
4641 .RS
4642 C\-Meta\-u: universal\-argument
4643 .RE
4644 into the 
4645 .I inputrc
4646 would make M\-C\-u execute the readline command
4647 .IR universal\-argument .
4648 .PP
4649 The following symbolic character names are recognized:
4650 .IR RUBOUT ,
4651 .IR DEL ,
4652 .IR ESC ,
4653 .IR LFD ,
4654 .IR NEWLINE ,
4655 .IR RET ,
4656 .IR RETURN ,
4657 .IR SPC ,
4658 .IR SPACE ,
4659 and
4660 .IR TAB .
4661 .PP
4662 In addition to command names, readline allows keys to be bound
4663 to a string that is inserted when the key is pressed (a \fImacro\fP).
4664 .SS "Readline Key Bindings"
4665 .PP
4666 The syntax for controlling key bindings in the
4667 .I inputrc
4668 file is simple.  All that is required is the name of the
4669 command or the text of a macro and a key sequence to which
4670 it should be bound. The name may be specified in one of two ways:
4671 as a symbolic key name, possibly with \fIMeta\-\fP or \fIControl\-\fP
4672 prefixes, or as a key sequence.
4673 .PP
4674 When using the form \fBkeyname\fP:\^\fIfunction\-name\fP or \fImacro\fP,
4675 .I keyname
4676 is the name of a key spelled out in English.  For example:
4677 .sp
4678 .RS
4679 Control-u: universal\-argument
4680 .br
4681 Meta-Rubout: backward-kill-word
4682 .br
4683 Control-o: "> output"
4684 .RE
4685 .LP
4686 In the above example,
4687 .I C\-u
4688 is bound to the function
4689 .BR universal\-argument ,
4690 .I M\-DEL
4691 is bound to the function
4692 .BR backward\-kill\-word ,
4693 and
4694 .I C\-o
4695 is bound to run the macro
4696 expressed on the right hand side (that is, to insert the text
4697 .if t \f(CW> output\fP
4698 .if n ``> output''
4699 into the line).
4700 .PP
4701 In the second form, \fB"keyseq"\fP:\^\fIfunction\-name\fP or \fImacro\fP,
4702 .B keyseq
4703 differs from
4704 .B keyname
4705 above in that strings denoting
4706 an entire key sequence may be specified by placing the sequence
4707 within double quotes.  Some GNU Emacs style key escapes can be
4708 used, as in the following example, but the symbolic character names
4709 are not recognized.
4710 .sp
4711 .RS
4712 "\eC\-u": universal\-argument
4713 .br
4714 "\eC\-x\eC\-r": re\-read\-init\-file
4715 .br
4716 "\ee[11~": "Function Key 1"
4717 .RE
4718 .PP
4719 In this example,
4720 .I C\-u
4721 is again bound to the function
4722 .BR universal\-argument .
4723 .I "C\-x C\-r"
4724 is bound to the function
4725 .BR re\-read\-init\-file ,
4726 and 
4727 .I "ESC [ 1 1 ~"
4728 is bound to insert the text
4729 .if t \f(CWFunction Key 1\fP.
4730 .if n ``Function Key 1''.
4731 .PP
4732 The full set of GNU Emacs style escape sequences is
4733 .RS
4734 .PD 0
4735 .TP
4736 .B \eC\-
4737 control prefix
4738 .TP
4739 .B \eM\-
4740 meta prefix
4741 .TP
4742 .B \ee
4743 an escape character
4744 .TP
4745 .B \e\e
4746 backslash
4747 .TP
4748 .B \e"
4749 literal "
4750 .TP
4751 .B \e\(aq
4752 literal \(aq
4753 .RE
4754 .PD
4755 .PP
4756 In addition to the GNU Emacs style escape sequences, a second
4757 set of backslash escapes is available:
4758 .RS
4759 .PD 0
4760 .TP
4761 .B \ea
4762 alert (bell)
4763 .TP
4764 .B \eb
4765 backspace
4766 .TP
4767 .B \ed
4768 delete
4769 .TP
4770 .B \ef
4771 form feed
4772 .TP
4773 .B \en
4774 newline
4775 .TP
4776 .B \er
4777 carriage return
4778 .TP
4779 .B \et
4780 horizontal tab
4781 .TP
4782 .B \ev
4783 vertical tab
4784 .TP
4785 .B \e\fInnn\fP
4786 the eight-bit character whose value is the octal value \fInnn\fP
4787 (one to three digits)
4788 .TP
4789 .B \ex\fIHH\fP
4790 the eight-bit character whose value is the hexadecimal value \fIHH\fP
4791 (one or two hex digits)
4792 .RE
4793 .PD
4794 .PP
4795 When entering the text of a macro, single or double quotes must
4796 be used to indicate a macro definition.
4797 Unquoted text is assumed to be a function name.
4798 In the macro body, the backslash escapes described above are expanded.
4799 Backslash will quote any other character in the macro text,
4800 including " and \(aq.
4801 .PP
4802 .B Bash
4803 allows the current readline key bindings to be displayed or modified
4804 with the
4805 .B bind
4806 builtin command.  The editing mode may be switched during interactive
4807 use by using the
4808 .B \-o
4809 option to the
4810 .B set
4811 builtin command (see
4812 .SM
4813 .B SHELL BUILTIN COMMANDS
4814 below).
4815 .SS "Readline Variables"
4816 .PP
4817 Readline has variables that can be used to further customize its
4818 behavior.  A variable may be set in the
4819 .I inputrc
4820 file with a statement of the form
4821 .RS
4822 .PP
4823 \fBset\fP \fIvariable\-name\fP \fIvalue\fP
4824 .RE
4825 .PP
4826 Except where noted, readline variables can take the values
4827 .B On
4828 or
4829 .B Off
4830 (without regard to case).
4831 Unrecognized variable names are ignored.
4832 When a variable value is read, empty or null values, "on" (case-insensitive),
4833 and "1" are equivalent to \fBOn\fP.  All other values are equivalent to
4834 \fBOff\fP.
4835 The variables and their default values are:
4836 .PP
4837 .PD 0
4838 .TP
4839 .B bell\-style (audible)
4840 Controls what happens when readline wants to ring the terminal bell.
4841 If set to \fBnone\fP, readline never rings the bell.  If set to
4842 \fBvisible\fP, readline uses a visible bell if one is available.
4843 If set to \fBaudible\fP, readline attempts to ring the terminal's bell.
4844 .TP
4845 .B bind\-tty\-special\-chars (On)
4846 If set to \fBOn\fP, readline attempts to bind the control characters
4847 treated specially by the kernel's terminal driver to their readline
4848 equivalents.
4849 .TP
4850 .B comment\-begin (``#'')
4851 The string that is inserted when the readline
4852 .B insert\-comment
4853 command is executed.
4854 This command is bound to
4855 .B M\-#
4856 in emacs mode and to
4857 .B #
4858 in vi command mode.
4859 .TP
4860 .B completion\-ignore\-case (Off)
4861 If set to \fBOn\fP, readline performs filename matching and completion
4862 in a case\-insensitive fashion.
4863 .TP
4864 .B completion\-prefix\-display\-length (0)
4865 The length in characters of the common prefix of a list of possible
4866 completions that is displayed without modification.  When set to a
4867 value greater than zero, common prefixes longer than this value are
4868 replaced with an ellipsis when displaying possible completions.
4869 .TP
4870 .B completion\-query\-items (100)
4871 This determines when the user is queried about viewing
4872 the number of possible completions
4873 generated by the \fBpossible\-completions\fP command.
4874 It may be set to any integer value greater than or equal to
4875 zero.  If the number of possible completions is greater than
4876 or equal to the value of this variable, the user is asked whether
4877 or not he wishes to view them; otherwise they are simply listed
4878 on the terminal.
4879 .TP
4880 .B convert\-meta (On)
4881 If set to \fBOn\fP, readline will convert characters with the
4882 eighth bit set to an ASCII key sequence
4883 by stripping the eighth bit and prefixing an
4884 escape character (in effect, using escape as the \fImeta prefix\fP).
4885 .TP
4886 .B disable\-completion (Off)
4887 If set to \fBOn\fP, readline will inhibit word completion.  Completion
4888 characters will be inserted into the line as if they had been
4889 mapped to \fBself-insert\fP.
4890 .TP
4891 .B editing\-mode (emacs)
4892 Controls whether readline begins with a set of key bindings similar
4893 to \fIemacs\fP or \fIvi\fP.
4894 .B editing\-mode
4895 can be set to either
4896 .B emacs
4897 or
4898 .BR vi .
4899 .TP
4900 .B enable\-keypad (Off)
4901 When set to \fBOn\fP, readline will try to enable the application
4902 keypad when it is called.  Some systems need this to enable the
4903 arrow keys.
4904 .TP
4905 .B expand\-tilde (Off)
4906 If set to \fBon\fP, tilde expansion is performed when readline
4907 attempts word completion.
4908 .TP
4909 .B history\-preserve\-point (Off)
4910 If set to \fBon\fP, the history code attempts to place point at the
4911 same location on each history line retrieved with \fBprevious-history\fP
4912 or \fBnext-history\fP.
4913 .TP
4914 .B history\-size (0)
4915 Set the maximum number of history entries saved in the history list.  If
4916 set to zero, the number of entries in the history list is not limited.
4917 .TP
4918 .B horizontal\-scroll\-mode (Off)
4919 When set to \fBOn\fP, makes readline use a single line for display,
4920 scrolling the input horizontally on a single screen line when it
4921 becomes longer than the screen width rather than wrapping to a new line.
4922 .TP
4923 .B input\-meta (Off)
4924 If set to \fBOn\fP, readline will enable eight-bit input (that is,
4925 it will not strip the high bit from the characters it reads),
4926 regardless of what the terminal claims it can support.  The name
4927 .B meta\-flag
4928 is a synonym for this variable.
4929 .TP
4930 .B isearch\-terminators (``C\-[C\-J'')
4931 The string of characters that should terminate an incremental
4932 search without subsequently executing the character as a command.
4933 If this variable has not been given a value, the characters
4934 \fIESC\fP and \fIC\-J\fP will terminate an incremental search.
4935 .TP
4936 .B keymap (emacs)
4937 Set the current readline keymap.  The set of valid keymap names is
4938 \fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi,
4939 vi\-command\fP, and
4940 .IR vi\-insert .
4941 \fIvi\fP is equivalent to \fIvi\-command\fP; \fIemacs\fP is
4942 equivalent to \fIemacs\-standard\fP.  The default value is
4943 .IR emacs ;
4944 the value of
4945 .B editing\-mode
4946 also affects the default keymap.
4947 .TP
4948 .B mark\-directories (On)
4949 If set to \fBOn\fP, completed directory names have a slash
4950 appended.
4951 .TP
4952 .B mark\-modified\-lines (Off)
4953 If set to \fBOn\fP, history lines that have been modified are displayed
4954 with a preceding asterisk (\fB*\fP).
4955 .TP
4956 .B mark\-symlinked\-directories (Off)
4957 If set to \fBOn\fP, completed names which are symbolic links to directories
4958 have a slash appended (subject to the value of
4959 \fBmark\-directories\fP).
4960 .TP
4961 .B match\-hidden\-files (On)
4962 This variable, when set to \fBOn\fP, causes readline to match files whose
4963 names begin with a `.' (hidden files) when performing filename 
4964 completion, unless the leading `.' is
4965 supplied by the user in the filename to be completed.
4966 .TP
4967 .B output\-meta (Off)
4968 If set to \fBOn\fP, readline will display characters with the
4969 eighth bit set directly rather than as a meta-prefixed escape
4970 sequence.
4971 .TP
4972 .B page\-completions (On)
4973 If set to \fBOn\fP, readline uses an internal \fImore\fP-like pager
4974 to display a screenful of possible completions at a time.
4975 .TP
4976 .B print\-completions\-horizontally (Off)
4977 If set to \fBOn\fP, readline will display completions with matches
4978 sorted horizontally in alphabetical order, rather than down the screen.
4979 .TP 
4980 .B revert\-all\-at\-newline (Off)
4981 If set to \fBon\fP, readline will undo all changes to history lines 
4982 before returning when \fBaccept\-line\fP is executed.  By default,
4983 history lines may be modified and retain individual undo lists across
4984 calls to \fBreadline\fP.
4985 .TP
4986 .B show\-all\-if\-ambiguous (Off)
4987 This alters the default behavior of the completion functions.  If
4988 set to
4989 .BR on ,
4990 words which have more than one possible completion cause the
4991 matches to be listed immediately instead of ringing the bell.
4992 .TP
4993 .B show\-all\-if\-unmodified (Off)
4994 This alters the default behavior of the completion functions in
4995 a fashion similar to \fBshow\-all\-if\-ambiguous\fP.
4996 If set to
4997 .BR on ,
4998 words which have more than one possible completion without any
4999 possible partial completion (the possible completions don't share
5000 a common prefix) cause the matches to be listed immediately instead
5001 of ringing the bell.
5002 .TP
5003 .B visible\-stats (Off)
5004 If set to \fBOn\fP, a character denoting a file's type as reported
5005 by \fIstat\fP(2) is appended to the filename when listing possible
5006 completions.
5007 .PD
5008 .SS "Readline Conditional Constructs"
5009 .PP
5010 Readline implements a facility similar in spirit to the conditional
5011 compilation features of the C preprocessor which allows key
5012 bindings and variable settings to be performed as the result
5013 of tests.  There are four parser directives used.
5014 .IP \fB$if\fP
5015 The 
5016 .B $if
5017 construct allows bindings to be made based on the
5018 editing mode, the terminal being used, or the application using
5019 readline.  The text of the test extends to the end of the line;
5020 no characters are required to isolate it.
5021 .RS
5022 .IP \fBmode\fP
5023 The \fBmode=\fP form of the \fB$if\fP directive is used to test
5024 whether readline is in emacs or vi mode.
5025 This may be used in conjunction
5026 with the \fBset keymap\fP command, for instance, to set bindings in
5027 the \fIemacs\-standard\fP and \fIemacs\-ctlx\fP keymaps only if
5028 readline is starting out in emacs mode.
5029 .IP \fBterm\fP
5030 The \fBterm=\fP form may be used to include terminal-specific
5031 key bindings, perhaps to bind the key sequences output by the
5032 terminal's function keys.  The word on the right side of the
5033 .B =
5034 is tested against the both full name of the terminal and the portion
5035 of the terminal name before the first \fB\-\fP.  This allows
5036 .I sun
5037 to match both
5038 .I sun
5039 and
5040 .IR sun\-cmd ,
5041 for instance.
5042 .IP \fBapplication\fP
5043 The \fBapplication\fP construct is used to include
5044 application-specific settings.  Each program using the readline
5045 library sets the \fIapplication name\fP, and an initialization
5046 file can test for a particular value.
5047 This could be used to bind key sequences to functions useful for
5048 a specific program.  For instance, the following command adds a
5049 key sequence that quotes the current or previous word in Bash:
5050 .sp 1
5051 .RS
5052 .nf
5053 \fB$if\fP Bash
5054 # Quote the current or previous word
5055 "\eC\-xq": "\eeb\e"\eef\e""
5056 \fB$endif\fP
5057 .fi
5058 .RE
5059 .RE
5060 .IP \fB$endif\fP
5061 This command, as seen in the previous example, terminates an
5062 \fB$if\fP command.
5063 .IP \fB$else\fP
5064 Commands in this branch of the \fB$if\fP directive are executed if
5065 the test fails.
5066 .IP \fB$include\fP
5067 This directive takes a single filename as an argument and reads commands
5068 and bindings from that file.  For example, the following directive
5069 would read \fI/etc/inputrc\fP:
5070 .sp 1
5071 .RS
5072 .nf
5073 \fB$include\fP \^ \fI/etc/inputrc\fP
5074 .fi
5075 .RE
5076 .SS Searching
5077 .PP
5078 Readline provides commands for searching through the command history
5079 (see
5080 .SM
5081 .B HISTORY
5082 below) for lines containing a specified string.
5083 There are two search modes:
5084 .I incremental
5085 and
5086 .IR non-incremental .
5087 .PP
5088 Incremental searches begin before the user has finished typing the
5089 search string.
5090 As each character of the search string is typed, readline displays
5091 the next entry from the history matching the string typed so far.
5092 An incremental search requires only as many characters as needed to
5093 find the desired history entry.
5094 The characters present in the value of the \fBisearch-terminators\fP
5095 variable are used to terminate an incremental search.
5096 If that variable has not been assigned a value the Escape and
5097 Control-J characters will terminate an incremental search.
5098 Control-G will abort an incremental search and restore the original
5099 line.
5100 When the search is terminated, the history entry containing the
5101 search string becomes the current line.
5102 .PP
5103 To find other matching entries in the history list, type Control-S or
5104 Control-R as appropriate.
5105 This will search backward or forward in the history for the next
5106 entry matching the search string typed so far.
5107 Any other key sequence bound to a readline command will terminate
5108 the search and execute that command.
5109 For instance, a \fInewline\fP will terminate the search and accept
5110 the line, thereby executing the command from the history list.
5111 .PP
5112 Readline remembers the last incremental search string.  If two
5113 Control-Rs are typed without any intervening characters defining a
5114 new search string, any remembered search string is used.
5115 .PP
5116 Non-incremental searches read the entire search string before starting
5117 to search for matching history lines.  The search string may be
5118 typed by the user or be part of the contents of the current line.
5119 .SS "Readline Command Names"
5120 .PP
5121 The following is a list of the names of the commands and the default
5122 key sequences to which they are bound.
5123 Command names without an accompanying key sequence are unbound by default.
5124 In the following descriptions, \fIpoint\fP refers to the current cursor
5125 position, and \fImark\fP refers to a cursor position saved by the
5126 \fBset\-mark\fP command.
5127 The text between the point and mark is referred to as the \fIregion\fP.
5128 .SS Commands for Moving
5129 .PP
5130 .PD 0
5131 .TP
5132 .B beginning\-of\-line (C\-a)
5133 Move to the start of the current line.
5134 .TP
5135 .B end\-of\-line (C\-e)
5136 Move to the end of the line.
5137 .TP
5138 .B forward\-char (C\-f)
5139 Move forward a character.
5140 .TP
5141 .B backward\-char (C\-b)
5142 Move back a character.
5143 .TP
5144 .B forward\-word (M\-f)
5145 Move forward to the end of the next word.  Words are composed of
5146 alphanumeric characters (letters and digits).
5147 .TP
5148 .B backward\-word (M\-b)
5149 Move back to the start of the current or previous word.
5150 Words are composed of alphanumeric characters (letters and digits).
5151 .TP
5152 .B shell\-forward\-word
5153 Move forward to the end of the next word.
5154 Words are delimited by non-quoted shell metacharacters.
5155 .TP
5156 .B shell\-backward\-word
5157 Move back to the start of the current or previous word.
5158 Words are delimited by non-quoted shell metacharacters.
5159 .TP
5160 .B clear\-screen (C\-l)
5161 Clear the screen leaving the current line at the top of the screen.
5162 With an argument, refresh the current line without clearing the
5163 screen.
5164 .TP
5165 .B redraw\-current\-line
5166 Refresh the current line.
5167 .PD
5168 .SS Commands for Manipulating the History
5169 .PP
5170 .PD 0
5171 .TP
5172 .B accept\-line (Newline, Return)
5173 Accept the line regardless of where the cursor is.  If this line is
5174 non-empty, add it to the history list according to the state of the
5175 .SM
5176 .B HISTCONTROL
5177 variable.  If the line is a modified history
5178 line, then restore the history line to its original state.
5179 .TP
5180 .B previous\-history (C\-p)
5181 Fetch the previous command from the history list, moving back in
5182 the list.
5183 .TP
5184 .B next\-history (C\-n)
5185 Fetch the next command from the history list, moving forward in the
5186 list.
5187 .TP
5188 .B beginning\-of\-history (M\-<)
5189 Move to the first line in the history.
5190 .TP
5191 .B end\-of\-history (M\->)
5192 Move to the end of the input history, i.e., the line currently being
5193 entered.
5194 .TP
5195 .B reverse\-search\-history (C\-r)
5196 Search backward starting at the current line and moving `up' through
5197 the history as necessary.  This is an incremental search.
5198 .TP
5199 .B forward\-search\-history (C\-s)
5200 Search forward starting at the current line and moving `down' through
5201 the history as necessary.  This is an incremental search.
5202 .TP
5203 .B non\-incremental\-reverse\-search\-history (M\-p)
5204 Search backward through the history starting at the current line
5205 using a non-incremental search for a string supplied by the user.
5206 .TP
5207 .B non\-incremental\-forward\-search\-history (M\-n)
5208 Search forward through the history using a non-incremental search for
5209 a string supplied by the user.
5210 .TP
5211 .B history\-search\-forward
5212 Search forward through the history for the string of characters
5213 between the start of the current line and the point.
5214 This is a non-incremental search.
5215 .TP
5216 .B history\-search\-backward
5217 Search backward through the history for the string of characters
5218 between the start of the current line and the point.
5219 This is a non-incremental search.
5220 .TP
5221 .B yank\-nth\-arg (M\-C\-y)
5222 Insert the first argument to the previous command (usually
5223 the second word on the previous line) at point.
5224 With an argument
5225 .IR n ,
5226 insert the \fIn\fPth word from the previous command (the words
5227 in the previous command begin with word 0).  A negative argument
5228 inserts the \fIn\fPth word from the end of the previous command.
5229 Once the argument \fIn\fP is computed, the argument is extracted
5230 as if the "!\fIn\fP" history expansion had been specified.
5231 .TP
5232 .B
5233 yank\-last\-arg (M\-.\^, M\-_\^)
5234 Insert the last argument to the previous command (the last word of
5235 the previous history entry).  With an argument,
5236 behave exactly like \fByank\-nth\-arg\fP.
5237 Successive calls to \fByank\-last\-arg\fP move back through the history
5238 list, inserting the last argument of each line in turn.
5239 The history expansion facilities are used to extract the last argument,
5240 as if the "!$" history expansion had been specified.
5241 .TP
5242 .B shell\-expand\-line (M\-C\-e)
5243 Expand the line as the shell does.  This
5244 performs alias and history expansion as well as all of the shell
5245 word expansions.  See
5246 .SM
5247 .B HISTORY EXPANSION
5248 below for a description of history expansion.
5249 .TP
5250 .B history\-expand\-line (M\-^)
5251 Perform history expansion on the current line.
5252 See
5253 .SM
5254 .B HISTORY EXPANSION
5255 below for a description of history expansion.
5256 .TP
5257 .B magic\-space
5258 Perform history expansion on the current line and insert a space.
5259 See
5260 .SM
5261 .B HISTORY EXPANSION
5262 below for a description of history expansion.
5263 .TP
5264 .B alias\-expand\-line
5265 Perform alias expansion on the current line.
5266 See
5267 .SM
5268 .B ALIASES
5269 above for a description of alias expansion.
5270 .TP
5271 .B history\-and\-alias\-expand\-line
5272 Perform history and alias expansion on the current line.
5273 .TP
5274 .B insert\-last\-argument (M\-.\^, M\-_\^)
5275 A synonym for \fByank\-last\-arg\fP.
5276 .TP
5277 .B operate\-and\-get\-next (C\-o)
5278 Accept the current line for execution and fetch the next line
5279 relative to the current line from the history for editing.  Any
5280 argument is ignored.
5281 .TP
5282 .B edit\-and\-execute\-command (C\-xC\-e)
5283 Invoke an editor on the current command line, and execute the result as shell
5284 commands.
5285 \fBBash\fP attempts to invoke
5286 .SM
5287 .BR $VISUAL ,
5288 .SM
5289 .BR $EDITOR ,
5290 and \fIemacs\fP as the editor, in that order.
5291 .PD
5292 .SS Commands for Changing Text
5293 .PP
5294 .PD 0
5295 .TP
5296 .B delete\-char (C\-d)
5297 Delete the character at point.  If point is at the
5298 beginning of the line, there are no characters in the line, and
5299 the last character typed was not bound to \fBdelete\-char\fP,
5300 then return
5301 .SM
5302 .BR EOF .
5303 .TP
5304 .B backward\-delete\-char (Rubout)
5305 Delete the character behind the cursor.  When given a numeric argument,
5306 save the deleted text on the kill ring.
5307 .TP
5308 .B forward\-backward\-delete\-char
5309 Delete the character under the cursor, unless the cursor is at the
5310 end of the line, in which case the character behind the cursor is
5311 deleted.
5312 .TP
5313 .B quoted\-insert (C\-q, C\-v)
5314 Add the next character typed to the line verbatim.  This is
5315 how to insert characters like \fBC\-q\fP, for example.
5316 .TP
5317 .B tab\-insert (C\-v TAB)
5318 Insert a tab character.
5319 .TP
5320 .B self\-insert (a,\ b,\ A,\ 1,\ !,\ ...)
5321 Insert the character typed.
5322 .TP
5323 .B transpose\-chars (C\-t)
5324 Drag the character before point forward over the character at point,
5325 moving point forward as well.
5326 If point is at the end of the line, then this transposes
5327 the two characters before point.
5328 Negative arguments have no effect.
5329 .TP
5330 .B transpose\-words (M\-t)
5331 Drag the word before point past the word after point,
5332 moving point over that word as well.
5333 If point is at the end of the line, this transposes
5334 the last two words on the line.   
5335 .TP
5336 .B upcase\-word (M\-u)
5337 Uppercase the current (or following) word.  With a negative argument,
5338 uppercase the previous word, but do not move point.
5339 .TP
5340 .B downcase\-word (M\-l)
5341 Lowercase the current (or following) word.  With a negative argument,
5342 lowercase the previous word, but do not move point.
5343 .TP
5344 .B capitalize\-word (M\-c)
5345 Capitalize the current (or following) word.  With a negative argument,
5346 capitalize the previous word, but do not move point.
5347 .TP
5348 .B overwrite\-mode
5349 Toggle overwrite mode.  With an explicit positive numeric argument,
5350 switches to overwrite mode.  With an explicit non-positive numeric
5351 argument, switches to insert mode.  This command affects only
5352 \fBemacs\fP mode; \fBvi\fP mode does overwrite differently.
5353 Each call to \fIreadline()\fP starts in insert mode.
5354 In overwrite mode, characters bound to \fBself\-insert\fP replace   
5355 the text at point rather than pushing the text to the right.
5356 Characters bound to \fBbackward\-delete\-char\fP replace the character
5357 before point with a space.  By default, this command is unbound.
5358 .PD
5359 .SS Killing and Yanking
5360 .PP
5361 .PD 0
5362 .TP
5363 .B kill\-line (C\-k)
5364 Kill the text from point to the end of the line.
5365 .TP
5366 .B backward\-kill\-line (C\-x Rubout)
5367 Kill backward to the beginning of the line.
5368 .TP
5369 .B unix\-line\-discard (C\-u)
5370 Kill backward from point to the beginning of the line.
5371 The killed text is saved on the kill-ring.
5372 .\" There is no real difference between this and backward-kill-line
5373 .TP
5374 .B kill\-whole\-line
5375 Kill all characters on the current line, no matter where point is.
5376 .TP
5377 .B kill\-word  (M\-d)
5378 Kill from point to the end of the current word, or if between
5379 words, to the end of the next word.
5380 Word boundaries are the same as those used by \fBforward\-word\fP.
5381 .TP
5382 .B backward\-kill\-word (M\-Rubout)
5383 Kill the word behind point.
5384 Word boundaries are the same as those used by \fBbackward\-word\fP.
5385 .TP
5386 .B shell\-kill\-word  (M\-d)
5387 Kill from point to the end of the current word, or if between
5388 words, to the end of the next word.
5389 Word boundaries are the same as those used by \fBshell\-forward\-word\fP.
5390 .TP
5391 .B shell\-backward\-kill\-word (M\-Rubout)
5392 Kill the word behind point.
5393 Word boundaries are the same as those used by \fBshell\-backward\-word\fP.
5394 .TP
5395 .B unix\-word\-rubout (C\-w)
5396 Kill the word behind point, using white space as a word boundary.
5397 The killed text is saved on the kill-ring.
5398 .TP
5399 .B unix\-filename\-rubout
5400 Kill the word behind point, using white space and the slash character
5401 as the word boundaries.
5402 The killed text is saved on the kill-ring.
5403 .TP
5404 .B delete\-horizontal\-space (M\-\e)
5405 Delete all spaces and tabs around point.
5406 .TP
5407 .B kill\-region
5408 Kill the text in the current region.
5409 .TP
5410 .B copy\-region\-as\-kill
5411 Copy the text in the region to the kill buffer.
5412 .TP
5413 .B copy\-backward\-word
5414 Copy the word before point to the kill buffer.
5415 The word boundaries are the same as \fBbackward\-word\fP.
5416 .TP
5417 .B copy\-forward\-word
5418 Copy the word following point to the kill buffer.
5419 The word boundaries are the same as \fBforward\-word\fP.
5420 .TP
5421 .B yank (C\-y)
5422 Yank the top of the kill ring into the buffer at point.
5423 .TP
5424 .B yank\-pop (M\-y)
5425 Rotate the kill ring, and yank the new top.  Only works following
5426 .B yank
5427 or
5428 .BR yank\-pop .
5429 .PD
5430 .SS Numeric Arguments
5431 .PP
5432 .PD 0
5433 .TP
5434 .B digit\-argument (M\-0, M\-1, ..., M\-\-)
5435 Add this digit to the argument already accumulating, or start a new
5436 argument.  M\-\- starts a negative argument.
5437 .TP
5438 .B universal\-argument
5439 This is another way to specify an argument.
5440 If this command is followed by one or more digits, optionally with a
5441 leading minus sign, those digits define the argument.
5442 If the command is followed by digits, executing
5443 .B universal\-argument
5444 again ends the numeric argument, but is otherwise ignored.
5445 As a special case, if this command is immediately followed by a
5446 character that is neither a digit or minus sign, the argument count
5447 for the next command is multiplied by four.
5448 The argument count is initially one, so executing this function the
5449 first time makes the argument count four, a second time makes the
5450 argument count sixteen, and so on.
5451 .PD
5452 .SS Completing
5453 .PP
5454 .PD 0
5455 .TP
5456 .B complete (TAB)
5457 Attempt to perform completion on the text before point.
5458 .B Bash
5459 attempts completion treating the text as a variable (if the
5460 text begins with \fB$\fP), username (if the text begins with
5461 \fB~\fP), hostname (if the text begins with \fB@\fP), or
5462 command (including aliases and functions) in turn.  If none
5463 of these produces a match, filename completion is attempted.
5464 .TP
5465 .B possible\-completions (M\-?)
5466 List the possible completions of the text before point.
5467 .TP
5468 .B insert\-completions (M\-*)
5469 Insert all completions of the text before point
5470 that would have been generated by
5471 \fBpossible\-completions\fP.
5472 .TP
5473 .B menu\-complete
5474 Similar to \fBcomplete\fP, but replaces the word to be completed
5475 with a single match from the list of possible completions.
5476 Repeated execution of \fBmenu\-complete\fP steps through the list
5477 of possible completions, inserting each match in turn.
5478 At the end of the list of completions, the bell is rung
5479 (subject to the setting of \fBbell\-style\fP)
5480 and the original text is restored.
5481 An argument of \fIn\fP moves \fIn\fP positions forward in the list
5482 of matches; a negative argument may be used to move backward
5483 through the list.
5484 This command is intended to be bound to \fBTAB\fP, but is unbound
5485 by default.
5486 .TP
5487 .B delete\-char\-or\-list
5488 Deletes the character under the cursor if not at the beginning or
5489 end of the line (like \fBdelete\-char\fP).
5490 If at the end of the line, behaves identically to
5491 \fBpossible\-completions\fP.
5492 This command is unbound by default.
5493 .TP
5494 .B complete\-filename (M\-/)
5495 Attempt filename completion on the text before point.
5496 .TP
5497 .B possible\-filename\-completions (C\-x /)
5498 List the possible completions of the text before point,
5499 treating it as a filename.
5500 .TP
5501 .B complete\-username (M\-~)
5502 Attempt completion on the text before point, treating
5503 it as a username.
5504 .TP
5505 .B possible\-username\-completions (C\-x ~)
5506 List the possible completions of the text before point,
5507 treating it as a username.
5508 .TP
5509 .B complete\-variable (M\-$)
5510 Attempt completion on the text before point, treating
5511 it as a shell variable.
5512 .TP
5513 .B possible\-variable\-completions (C\-x $)
5514 List the possible completions of the text before point,
5515 treating it as a shell variable.
5516 .TP
5517 .B complete\-hostname (M\-@)
5518 Attempt completion on the text before point, treating
5519 it as a hostname.
5520 .TP
5521 .B possible\-hostname\-completions (C\-x @)
5522 List the possible completions of the text before point,
5523 treating it as a hostname.
5524 .TP
5525 .B complete\-command (M\-!)
5526 Attempt completion on the text before point, treating
5527 it as a command name.  Command completion attempts to
5528 match the text against aliases, reserved words, shell
5529 functions, shell builtins, and finally executable filenames,
5530 in that order.
5531 .TP
5532 .B possible\-command\-completions (C\-x !)
5533 List the possible completions of the text before point,
5534 treating it as a command name.
5535 .TP
5536 .B dynamic\-complete\-history (M\-TAB)
5537 Attempt completion on the text before point, comparing
5538 the text against lines from the history list for possible
5539 completion matches.
5540 .TP
5541 .B dabbrev\-expand
5542 Attempt menu completion on the text before point, comparing
5543 the text against lines from the history list for possible
5544 completion matches.
5545 .TP
5546 .B complete\-into\-braces (M\-{)
5547 Perform filename completion and insert the list of possible completions
5548 enclosed within braces so the list is available to the shell (see
5549 .B Brace Expansion
5550 above).
5551 .PD
5552 .SS Keyboard Macros
5553 .PP
5554 .PD 0
5555 .TP
5556 .B start\-kbd\-macro (C\-x (\^)
5557 Begin saving the characters typed into the current keyboard macro.
5558 .TP
5559 .B end\-kbd\-macro (C\-x )\^)
5560 Stop saving the characters typed into the current keyboard macro
5561 and store the definition.
5562 .TP
5563 .B call\-last\-kbd\-macro (C\-x e)
5564 Re-execute the last keyboard macro defined, by making the characters
5565 in the macro appear as if typed at the keyboard.
5566 .PD
5567 .SS Miscellaneous
5568 .PP
5569 .PD 0
5570 .TP
5571 .B re\-read\-init\-file (C\-x C\-r)
5572 Read in the contents of the \fIinputrc\fP file, and incorporate
5573 any bindings or variable assignments found there.
5574 .TP
5575 .B abort (C\-g)
5576 Abort the current editing command and
5577 ring the terminal's bell (subject to the setting of
5578 .BR bell\-style ).
5579 .TP
5580 .B do\-uppercase\-version (M\-a, M\-b, M\-\fIx\fP, ...)
5581 If the metafied character \fIx\fP is lowercase, run the command
5582 that is bound to the corresponding uppercase character.
5583 .TP
5584 .B prefix\-meta (ESC)
5585 Metafy the next character typed.
5586 .SM
5587 .B ESC
5588 .B f
5589 is equivalent to
5590 .BR Meta\-f .
5591 .TP
5592 .B undo (C\-_, C\-x C\-u)
5593 Incremental undo, separately remembered for each line.
5594 .TP
5595 .B revert\-line (M\-r)
5596 Undo all changes made to this line.  This is like executing the
5597 .B undo
5598 command enough times to return the line to its initial state.
5599 .TP
5600 .B tilde\-expand (M\-&)
5601 Perform tilde expansion on the current word.
5602 .TP
5603 .B set\-mark (C\-@, M\-<space>)
5604 Set the mark to the point.  If a
5605 numeric argument is supplied, the mark is set to that position.
5606 .TP
5607 .B exchange\-point\-and\-mark (C\-x C\-x)
5608 Swap the point with the mark.  The current cursor position is set to
5609 the saved position, and the old cursor position is saved as the mark.
5610 .TP
5611 .B character\-search (C\-])
5612 A character is read and point is moved to the next occurrence of that
5613 character.  A negative count searches for previous occurrences.
5614 .TP
5615 .B character\-search\-backward (M\-C\-])
5616 A character is read and point is moved to the previous occurrence of that
5617 character.  A negative count searches for subsequent occurrences.
5618 .TP
5619 .B insert\-comment (M\-#)
5620 Without a numeric argument, the value of the readline
5621 .B comment\-begin
5622 variable is inserted at the beginning of the current line.
5623 If a numeric argument is supplied, this command acts as a toggle:  if
5624 the characters at the beginning of the line do not match the value
5625 of \fBcomment\-begin\fP, the value is inserted, otherwise
5626 the characters in \fBcomment\-begin\fP are deleted from the beginning of 
5627 the line.
5628 In either case, the line is accepted as if a newline had been typed.
5629 The default value of
5630 \fBcomment\-begin\fP causes this command to make the current line
5631 a shell comment.
5632 If a numeric argument causes the comment character to be removed, the line
5633 will be executed by the shell.
5634 .TP
5635 .B glob\-complete\-word (M\-g)
5636 The word before point is treated as a pattern for pathname expansion,
5637 with an asterisk implicitly appended.  This pattern is used to
5638 generate a list of matching file names for possible completions.
5639 .TP
5640 .B glob\-expand\-word (C\-x *)
5641 The word before point is treated as a pattern for pathname expansion,
5642 and the list of matching file names is inserted, replacing the word.
5643 If a numeric argument is supplied, an asterisk is appended before
5644 pathname expansion.
5645 .TP
5646 .B glob\-list\-expansions (C\-x g)
5647 The list of expansions that would have been generated by
5648 .B glob\-expand\-word
5649 is displayed, and the line is redrawn.
5650 If a numeric argument is supplied, an asterisk is appended before
5651 pathname expansion.
5652 .TP
5653 .B dump\-functions
5654 Print all of the functions and their key bindings to the
5655 readline output stream.  If a numeric argument is supplied,
5656 the output is formatted in such a way that it can be made part
5657 of an \fIinputrc\fP file.
5658 .TP
5659 .B dump\-variables
5660 Print all of the settable readline variables and their values to the
5661 readline output stream.  If a numeric argument is supplied,
5662 the output is formatted in such a way that it can be made part
5663 of an \fIinputrc\fP file.
5664 .TP
5665 .B dump\-macros
5666 Print all of the readline key sequences bound to macros and the
5667 strings they output.  If a numeric argument is supplied,
5668 the output is formatted in such a way that it can be made part
5669 of an \fIinputrc\fP file.
5670 .TP
5671 .B display\-shell\-version (C\-x C\-v)
5672 Display version information about the current instance of
5673 .BR bash .
5674 .PD
5675 .SS Programmable Completion
5676 .PP
5677 When word completion is attempted for an argument to a command for
5678 which a completion specification (a \fIcompspec\fP) has been defined
5679 using the \fBcomplete\fP builtin (see
5680 .SM
5681 .B "SHELL BUILTIN COMMANDS"
5682 below), the programmable completion facilities are invoked.
5683 .PP
5684 First, the command name is identified.
5685 If a compspec has been defined for that command, the
5686 compspec is used to generate the list of possible completions for the word.
5687 If the command word is a full pathname, a compspec for the full
5688 pathname is searched for first.
5689 If no compspec is found for the full pathname, an attempt is made to
5690 find a compspec for the portion following the final slash.
5691 .PP
5692 Once a compspec has been found, it is used to generate the list of
5693 matching words.
5694 If a compspec is not found, the default \fBbash\fP completion as
5695 described above under \fBCompleting\fP is performed.
5696 .PP
5697 First, the actions specified by the compspec are used.
5698 Only matches which are prefixed by the word being completed are
5699 returned.
5700 When the
5701 .B \-f
5702 or
5703 .B \-d
5704 option is used for filename or directory name completion, the shell
5705 variable
5706 .SM
5707 .B FIGNORE
5708 is used to filter the matches.
5709 .PP
5710 Any completions specified by a filename expansion pattern to the
5711 \fB\-G\fP option are generated next.
5712 The words generated by the pattern need not match the word
5713 being completed.
5714 The
5715 .SM
5716 .B GLOBIGNORE
5717 shell variable is not used to filter the matches, but the
5718 .SM
5719 .B FIGNORE
5720 variable is used.
5721 .PP
5722 Next, the string specified as the argument to the \fB\-W\fP option
5723 is considered.
5724 The string is first split using the characters in the
5725 .SM
5726 .B IFS
5727 special variable as delimiters.
5728 Shell quoting is honored.
5729 Each word is then expanded using
5730 brace expansion, tilde expansion, parameter and variable expansion,
5731 command substitution, and arithmetic expansion,
5732 as described above under 
5733 .SM
5734 .BR EXPANSION .
5735 The results are split using the rules described above under
5736 \fBWord Splitting\fP.
5737 The results of the expansion are prefix-matched against the word being
5738 completed, and the matching words become the possible completions.
5739 .PP
5740 After these matches have been generated, any shell function or command
5741 specified with the \fB\-F\fP and \fB\-C\fP options is invoked.
5742 When the command or function is invoked, the
5743 .SM
5744 .BR COMP_LINE ,
5745 .SM
5746 .BR COMP_POINT ,
5747 .SM
5748 .BR COMP_KEY ,
5749 and
5750 .SM
5751 .B COMP_TYPE
5752 variables are assigned values as described above under
5753 \fBShell Variables\fP.
5754 If a shell function is being invoked, the 
5755 .SM
5756 .B COMP_WORDS
5757 and
5758 .SM
5759 .B COMP_CWORD
5760 variables are also set.
5761 When the function or command is invoked, the first argument is the
5762 name of the command whose arguments are being completed, the
5763 second argument is the word being completed, and the third argument
5764 is the word preceding the word being completed on the current command line.
5765 No filtering of the generated completions against the word being completed
5766 is performed; the function or command has complete freedom in generating
5767 the matches.
5768 .PP
5769 Any function specified with \fB\-F\fP is invoked first.
5770 The function may use any of the shell facilities, including the
5771 \fBcompgen\fP builtin described below, to generate the matches.
5772 It must put the possible completions in the
5773 .SM
5774 .B COMPREPLY
5775 array variable.
5776 .PP
5777 Next, any command specified with the \fB\-C\fP option is invoked
5778 in an environment equivalent to command substitution.
5779 It should print a list of completions, one per line, to the
5780 standard output.
5781 Backslash may be used to escape a newline, if necessary.
5782 .PP
5783 After all of the possible completions are generated, any filter
5784 specified with the \fB\-X\fP option is applied to the list.
5785 The filter is a pattern as used for pathname expansion; a \fB&\fP
5786 in the pattern is replaced with the text of the word being completed.
5787 A literal \fB&\fP may be escaped with a backslash; the backslash
5788 is removed before attempting a match.
5789 Any completion that matches the pattern will be removed from the list.
5790 A leading \fB!\fP negates the pattern; in this case any completion
5791 not matching the pattern will be removed.
5792 .PP
5793 Finally, any prefix and suffix specified with the \fB\-P\fP and \fB\-S\fP
5794 options are added to each member of the completion list, and the result is
5795 returned to the readline completion code as the list of possible
5796 completions.
5797 .PP
5798 If the previously-applied actions do not generate any matches, and the
5799 \fB\-o dirnames\fP option was supplied to \fBcomplete\fP when the
5800 compspec was defined, directory name completion is attempted.
5801 .PP
5802 If the \fB\-o plusdirs\fP option was supplied to \fBcomplete\fP when the
5803 compspec was defined, directory name completion is attempted and any
5804 matches are added to the results of the other actions.
5805 .PP
5806 By default, if a compspec is found, whatever it generates is returned
5807 to the completion code as the full set of possible completions.
5808 The default \fBbash\fP completions are not attempted, and the readline
5809 default of filename completion is disabled.
5810 If the \fB\-o bashdefault\fP option was supplied to \fBcomplete\fP when
5811 the compspec was defined, the \fBbash\fP default completions are attempted
5812 if the compspec generates no matches.
5813 If the \fB\-o default\fP option was supplied to \fBcomplete\fP when the
5814 compspec was defined, readline's default completion will be performed
5815 if the compspec (and, if attempted, the default \fBbash\fP completions)
5816 generate no matches.
5817 .PP
5818 When a compspec indicates that directory name completion is desired,
5819 the programmable completion functions force readline to append a slash
5820 to completed names which are symbolic links to directories, subject to  
5821 the value of the \fBmark\-directories\fP readline variable, regardless
5822 of the setting of the \fBmark-symlinked\-directories\fP readline variable.
5823 .SH HISTORY
5824 When the
5825 .B \-o history
5826 option to the
5827 .B set
5828 builtin is enabled, the shell provides access to the
5829 \fIcommand history\fP,
5830 the list of commands previously typed.
5831 The value of the \fBHISTSIZE\fP variable is used as the
5832 number of commands to save in a history list.
5833 The text of the last
5834 .SM
5835 .B HISTSIZE
5836 commands (default 500) is saved.  The shell
5837 stores each command in the history list prior to parameter and
5838 variable expansion (see
5839 .SM
5840 .B EXPANSION
5841 above) but after history expansion is performed, subject to the
5842 values of the shell variables
5843 .SM
5844 .B HISTIGNORE
5845 and
5846 .SM
5847 .BR HISTCONTROL .
5848 .PP
5849 On startup, the history is initialized from the file named by
5850 the variable
5851 .SM
5852 .B HISTFILE
5853 (default \fI~/.bash_history\fP).
5854 The file named by the value of
5855 .SM
5856 .B HISTFILE
5857 is truncated, if necessary, to contain no more than
5858 the number of lines specified by the value of
5859 .SM
5860 .BR HISTFILESIZE .
5861 When the history file is read,
5862 lines beginning with the history comment character followed immediately
5863 by a digit are interpreted as timestamps for the preceding history line.
5864 These timestamps are optionally displayed depending on the value of the
5865 .SM
5866 .B HISTTIMEFORMAT
5867 variable.
5868 When an interactive shell exits, the last
5869 .SM
5870 .B $HISTSIZE
5871 lines are copied from the history list to
5872 .SM
5873 .BR $HISTFILE .
5874 If the
5875 .B histappend
5876 shell option is enabled
5877 (see the description of
5878 .B shopt
5879 under
5880 .SM
5881 .B "SHELL BUILTIN COMMANDS"
5882 below), the lines are appended to the history file,
5883 otherwise the history file is overwritten.
5884 If
5885 .SM
5886 .B HISTFILE
5887 is unset, or if the history file is unwritable, the history is
5888 not saved.
5889 If the
5890 .SM
5891 .HISTTIMEFORMAT
5892 variable is set, time stamps are written to the history file, marked
5893 with the history comment character, so
5894 they may be preserved across shell sessions.
5895 This uses the history comment character to distinguish timestamps from
5896 other history lines.
5897 After saving the history, the history file is truncated
5898 to contain no more than
5899 .SM
5900 .B HISTFILESIZE
5901 lines.  If
5902 .SM
5903 .B HISTFILESIZE
5904 is not set, no truncation is performed.
5905 .PP
5906 The builtin command
5907 .B fc
5908 (see
5909 .SM
5910 .B SHELL BUILTIN COMMANDS
5911 below) may be used to list or edit and re-execute a portion of
5912 the history list.
5913 The
5914 .B history
5915 builtin may be used to display or modify the history list and
5916 manipulate the history file.
5917 When using command-line editing, search commands
5918 are available in each editing mode that provide access to the
5919 history list.
5920 .PP
5921 The shell allows control over which commands are saved on the history
5922 list.  The
5923 .SM
5924 .B HISTCONTROL
5925 and
5926 .SM
5927 .B HISTIGNORE
5928 variables may be set to cause the shell to save only a subset of the
5929 commands entered.
5930 The
5931 .B cmdhist
5932 shell option, if enabled, causes the shell to attempt to save each
5933 line of a multi-line command in the same history entry, adding
5934 semicolons where necessary to preserve syntactic correctness.
5935 The
5936 .B lithist
5937 shell option causes the shell to save the command with embedded newlines
5938 instead of semicolons.  See the description of the
5939 .B shopt
5940 builtin below under
5941 .SM
5942 .B "SHELL BUILTIN COMMANDS"
5943 for information on setting and unsetting shell options.
5944 .SH "HISTORY EXPANSION"
5945 .PP
5946 The shell supports a history expansion feature that
5947 is similar to the history expansion in
5948 .BR csh.
5949 This section describes what syntax features are available.  This
5950 feature is enabled by default for interactive shells, and can be
5951 disabled using the
5952 .B \+H
5953 option to the
5954 .B set
5955 builtin command (see
5956 .SM
5957 .B SHELL BUILTIN COMMANDS
5958 below).  Non-interactive shells do not perform history expansion
5959 by default.
5960 .PP
5961 History expansions introduce words from the history list into
5962 the input stream, making it easy to repeat commands, insert the
5963 arguments to a previous command into the current input line, or
5964 fix errors in previous commands quickly.
5965 .PP
5966 History expansion is performed immediately after a complete line
5967 is read, before the shell breaks it into words.
5968 It takes place in two parts.
5969 The first is to determine which line from the history list
5970 to use during substitution.
5971 The second is to select portions of that line for inclusion into
5972 the current one.
5973 The line selected from the history is the \fIevent\fP,
5974 and the portions of that line that are acted upon are \fIwords\fP.
5975 Various \fImodifiers\fP are available to manipulate the selected words.
5976 The line is broken into words in the same fashion as when reading input,
5977 so that several \fImetacharacter\fP-separated words surrounded by
5978 quotes are considered one word.
5979 History expansions are introduced by the appearance of the
5980 history expansion character, which is \^\fB!\fP\^ by default.
5981 Only backslash (\^\fB\e\fP\^) and single quotes can quote
5982 the history expansion character.
5983 .PP
5984 Several characters inhibit history expansion if found immediately
5985 following the history expansion character, even if it is unquoted:
5986 space, tab, newline, carriage return, and \fB=\fP.
5987 If the \fBextglob\fP shell option is enabled, \fB(\fP will also
5988 inhibit expansion.
5989 .PP
5990 Several shell options settable with the
5991 .B shopt
5992 builtin may be used to tailor the behavior of history expansion.
5993 If the
5994 .B histverify
5995 shell option is enabled (see the description of the
5996 .B shopt
5997 builtin), and
5998 .B readline
5999 is being used, history substitutions are not immediately passed to
6000 the shell parser.
6001 Instead, the expanded line is reloaded into the
6002 .B readline
6003 editing buffer for further modification.
6004 If
6005 .B readline
6006 is being used, and the
6007 .B histreedit
6008 shell option is enabled, a failed history substitution will be reloaded
6009 into the
6010 .B readline
6011 editing buffer for correction.
6012 The
6013 .B \-p
6014 option to the
6015 .B history
6016 builtin command may be used to see what a history expansion will
6017 do before using it.
6018 The
6019 .B \-s
6020 option to the
6021 .B history
6022 builtin may be used to add commands to the end of the history list
6023 without actually executing them, so that they are available for
6024 subsequent recall.
6025 .PP
6026 The shell allows control of the various characters used by the
6027 history expansion mechanism (see the description of
6028 .B histchars
6029 above under
6030 .BR "Shell Variables" ).
6031 The shell uses
6032 the history comment character to mark history timestamps when
6033 writing the history file.
6034 .SS Event Designators
6035 .PP
6036 An event designator is a reference to a command line entry in the
6037 history list.
6038 .PP
6039 .PD 0
6040 .TP
6041 .B !
6042 Start a history substitution, except when followed by a
6043 .BR blank ,
6044 newline, carriage return, =
6045 or ( (when the \fBextglob\fP shell option is enabled using
6046 the \fBshopt\fP builtin).
6047 .TP
6048 .B !\fIn\fR
6049 Refer to command line
6050 .IR n .
6051 .TP
6052 .B !\-\fIn\fR
6053 Refer to the current command line minus
6054 .IR n .
6055 .TP
6056 .B !!
6057 Refer to the previous command.  This is a synonym for `!\-1'.
6058 .TP
6059 .B !\fIstring\fR
6060 Refer to the most recent command starting with 
6061 .IR string .
6062 .TP
6063 .B !?\fIstring\fR\fB[?]\fR
6064 Refer to the most recent command containing
6065 .IR string .
6066 The trailing \fB?\fP may be omitted if
6067 .I string
6068 is followed immediately by a newline.
6069 .TP
6070 .B \d\s+2^\s-2\u\fIstring1\fP\d\s+2^\s-2\u\fIstring2\fP\d\s+2^\s-2\u
6071 Quick substitution.  Repeat the last command, replacing
6072 .I string1
6073 with
6074 .IR string2 .
6075 Equivalent to
6076 ``!!:s/\fIstring1\fP/\fIstring2\fP/''
6077 (see \fBModifiers\fP below).
6078 .TP
6079 .B !#
6080 The entire command line typed so far.
6081 .PD
6082 .SS Word Designators
6083 .PP
6084 Word designators are used to select desired words from the event.
6085
6086 .B :
6087 separates the event specification from the word designator.
6088 It may be omitted if the word designator begins with a
6089 .BR ^ ,
6090 .BR $ ,
6091 .BR * ,
6092 .BR \- ,
6093 or
6094 .BR % .
6095 Words are numbered from the beginning of the line,
6096 with the first word being denoted by 0 (zero).
6097 Words are inserted into the current line separated by single spaces.
6098 .PP
6099 .PD 0
6100 .TP
6101 .B 0 (zero)
6102 The zeroth word.  For the shell, this is the command
6103 word.
6104 .TP
6105 .I n
6106 The \fIn\fRth word.
6107 .TP
6108 .B ^
6109 The first argument.  That is, word 1.
6110 .TP
6111 .B $
6112 The last argument.
6113 .TP
6114 .B %
6115 The word matched by the most recent `?\fIstring\fR?' search.
6116 .TP
6117 .I x\fB\-\fPy
6118 A range of words; `\-\fIy\fR' abbreviates `0\-\fIy\fR'.
6119 .TP
6120 .B *
6121 All of the words but the zeroth.  This is a synonym
6122 for `\fI1\-$\fP'.  It is not an error to use
6123 .B *
6124 if there is just one
6125 word in the event; the empty string is returned in that case.
6126 .TP
6127 .B x*
6128 Abbreviates \fIx\-$\fP.
6129 .TP
6130 .B x\-
6131 Abbreviates \fIx\-$\fP like \fBx*\fP, but omits the last word.
6132 .PD
6133 .PP
6134 If a word designator is supplied without an event specification, the
6135 previous command is used as the event.
6136 .SS Modifiers
6137 .PP
6138 After the optional word designator, there may appear a sequence of
6139 one or more of the following modifiers, each preceded by a `:'.
6140 .PP
6141 .PD 0
6142 .PP
6143 .TP
6144 .B h
6145 Remove a trailing file name component, leaving only the head.
6146 .TP
6147 .B t
6148 Remove all leading file name components, leaving the tail.
6149 .TP
6150 .B r
6151 Remove a trailing suffix of the form \fI.xxx\fP, leaving the
6152 basename.
6153 .TP
6154 .B e
6155 Remove all but the trailing suffix.
6156 .TP
6157 .B p
6158 Print the new command but do not execute it.
6159 .TP
6160 .B q
6161 Quote the substituted words, escaping further substitutions.
6162 .TP
6163 .B x
6164 Quote the substituted words as with
6165 .BR q ,
6166 but break into words at
6167 .B blanks
6168 and newlines.
6169 .TP
6170 .B s/\fIold\fP/\fInew\fP/
6171 Substitute
6172 .I new
6173 for the first occurrence of
6174 .I old
6175 in the event line.  Any delimiter can be used in place of /.  The
6176 final delimiter is optional if it is the last character of the
6177 event line.  The delimiter may be quoted in
6178 .I old
6179 and
6180 .I new
6181 with a single backslash.  If & appears in
6182 .IR new ,
6183 it is replaced by
6184 .IR old .
6185 A single backslash will quote the &.  If
6186 .I old
6187 is null, it is set to the last
6188 .I old
6189 substituted, or, if no previous history substitutions took place,
6190 the last
6191 .I string
6192 in a
6193 .B !?\fIstring\fR\fB[?]\fR
6194 search.
6195 .TP
6196 .B &
6197 Repeat the previous substitution.
6198 .TP
6199 .B g
6200 Cause changes to be applied over the entire event line.  This is
6201 used in conjunction with `\fB:s\fP' (e.g., `\fB:gs/\fIold\fP/\fInew\fP/\fR')
6202 or `\fB:&\fP'.  If used with
6203 `\fB:s\fP', any delimiter can be used
6204 in place of /, and the final delimiter is optional
6205 if it is the last character of the event line.
6206 An \fBa\fP may be used as a synonym for \fBg\fP.
6207 .TP
6208 .B G
6209 Apply the following `\fBs\fP' modifier once to each word in the event line.
6210 .PD
6211 .SH "SHELL BUILTIN COMMANDS"
6212 .\" start of bash_builtins
6213 .zZ
6214 .PP
6215 Unless otherwise noted, each builtin command documented in this
6216 section as accepting options preceded by
6217 .B \-
6218 accepts
6219 .B \-\-
6220 to signify the end of the options.
6221 For example, the \fB:\fP, \fBtrue\fP, \fBfalse\fP, and \fBtest\fP builtins
6222 do not accept options.
6223 .sp .5
6224 .PD 0
6225 .TP
6226 \fB:\fP [\fIarguments\fP]
6227 .PD
6228 No effect; the command does nothing beyond expanding
6229 .I arguments
6230 and performing any specified
6231 redirections.  A zero exit code is returned.
6232 .TP
6233 \fB .\| \fP \fIfilename\fP [\fIarguments\fP]
6234 .PD 0
6235 .TP
6236 \fBsource\fP \fIfilename\fP [\fIarguments\fP]
6237 .PD
6238 Read and execute commands from
6239 .I filename
6240 in the current
6241 shell environment and return the exit status of the last command
6242 executed from
6243 .IR filename .
6244 If
6245 .I filename
6246 does not contain a slash, file names in
6247 .SM
6248 .B PATH
6249 are used to find the directory containing
6250 .IR filename .
6251 The file searched for in
6252 .SM
6253 .B PATH
6254 need not be executable.
6255 When \fBbash\fP is not in \fIposix mode\fP, the current directory is
6256 searched if no file is found in
6257 .SM
6258 .BR PATH .
6259 If the
6260 .B sourcepath
6261 option to the
6262 .B shopt
6263 builtin command is turned off, the
6264 .SM
6265 .B PATH
6266 is not searched.
6267 If any \fIarguments\fP are supplied, they become the positional
6268 parameters when \fIfilename\fP is executed.  Otherwise the positional
6269 parameters are unchanged.
6270 The return status is the status of the last command exited within
6271 the script (0 if no commands are executed), and false if
6272 .I filename
6273 is not found or cannot be read.
6274 .TP
6275 \fBalias\fP [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
6276 \fBAlias\fP with no arguments or with the
6277 .B \-p
6278 option prints the list of aliases in the form
6279 \fBalias\fP \fIname\fP=\fIvalue\fP on standard output.
6280 When arguments are supplied, an alias is defined for
6281 each \fIname\fP whose \fIvalue\fP is given.
6282 A trailing space in  \fIvalue\fP causes the next word to be
6283 checked for alias substitution when the alias is expanded.
6284 For each \fIname\fP in the argument list for which no \fIvalue\fP
6285 is supplied, the name and value of the alias is printed.
6286 \fBAlias\fP returns true unless a \fIname\fP is given for which
6287 no alias has been defined.
6288 .TP
6289 \fBbg\fP [\fIjobspec\fP ...]
6290 Resume each suspended job \fIjobspec\fP in the background, as if it
6291 had been started with
6292 .BR & .
6293 If
6294 .I jobspec
6295 is not present, the shell's notion of the \fIcurrent job\fP is used.
6296 .B bg
6297 .I jobspec
6298 returns 0 unless run when job control is disabled or, when run with
6299 job control enabled, any specified \fIjobspec\fP was not found
6300 or was started without job control.
6301 .TP
6302 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-lpsvPSV\fP]
6303 .PD 0
6304 .TP
6305 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-q\fP \fIfunction\fP] [\fB\-u\fP \fIfunction\fP] [\fB\-r\fP \fIkeyseq\fP]
6306 .TP
6307 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-f\fP \fIfilename\fP
6308 .TP
6309 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-x\fP \fIkeyseq\fP:\fIshell\-command\fP
6310 .TP
6311 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fIkeyseq\fP:\fIfunction\-name\fP
6312 .TP
6313 \fBbind\fP \fIreadline\-command\fP
6314 .PD
6315 Display current
6316 .B readline
6317 key and function bindings, bind a key sequence to a
6318 .B readline
6319 function or macro, or set a
6320 .B readline
6321 variable.
6322 Each non-option argument is a command as it would appear in
6323 .IR .inputrc ,
6324 but each binding or command must be passed as a separate argument;
6325 e.g., '"\eC\-x\eC\-r": re\-read\-init\-file'.
6326 Options, if supplied, have the following meanings:
6327 .RS
6328 .PD 0
6329 .TP
6330 .B \-m \fIkeymap\fP
6331 Use
6332 .I keymap
6333 as the keymap to be affected by the subsequent bindings.
6334 Acceptable
6335 .I keymap
6336 names are
6337 \fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi,
6338 vi\-move, vi\-command\fP, and
6339 .IR vi\-insert .
6340 \fIvi\fP is equivalent to \fIvi\-command\fP; \fIemacs\fP is
6341 equivalent to \fIemacs\-standard\fP.
6342 .TP
6343 .B \-l
6344 List the names of all \fBreadline\fP functions.
6345 .TP
6346 .B \-p
6347 Display \fBreadline\fP function names and bindings in such a way
6348 that they can be re-read.
6349 .TP
6350 .B \-P
6351 List current \fBreadline\fP function names and bindings.
6352 .TP
6353 .B \-s
6354 Display \fBreadline\fP key sequences bound to macros and the strings
6355 they output in such a way that they can be re-read.
6356 .TP
6357 .B \-S
6358 Display \fBreadline\fP key sequences bound to macros and the strings
6359 they output.
6360 .TP
6361 .B \-v
6362 Display \fBreadline\fP variable names and values in such a way that they
6363 can be re-read.
6364 .TP
6365 .B \-V
6366 List current \fBreadline\fP variable names and values.
6367 .TP
6368 .B \-f \fIfilename\fP
6369 Read key bindings from \fIfilename\fP.
6370 .TP
6371 .B \-q \fIfunction\fP
6372 Query about which keys invoke the named \fIfunction\fP.
6373 .TP
6374 .B \-u \fIfunction\fP
6375 Unbind all keys bound to the named \fIfunction\fP.
6376 .TP
6377 .B \-r \fIkeyseq\fP
6378 Remove any current binding for \fIkeyseq\fP.
6379 .TP
6380 .B \-x \fIkeyseq\fP:\fIshell\-command\fP
6381 Cause \fIshell\-command\fP to be executed whenever \fIkeyseq\fP is
6382 entered.
6383 When \fIshell\-command\fP is executed, the shell sets the
6384 .B READLINE_LINE
6385 variable to the contents of the \fBreadline\fP line buffer and the
6386 .B READLINE_POINT
6387 variable to the current location of the insertion point.
6388 If the executed command changes the value of
6389 .B READLINE_LINE
6390 or
6391 .BR READLINE_POINT ,
6392 those new values will be reflected in the editing state.
6393 .PD
6394 .PP
6395 The return value is 0 unless an unrecognized option is given or an
6396 error occurred.
6397 .RE
6398 .TP
6399 \fBbreak\fP [\fIn\fP]
6400 Exit from within a
6401 .BR for ,
6402 .BR while ,
6403 .BR until ,
6404 or
6405 .B select
6406 loop.  If \fIn\fP is specified, break \fIn\fP levels.
6407 .I n
6408 must be \(>= 1.  If
6409 .I n
6410 is greater than the number of enclosing loops, all enclosing loops
6411 are exited.
6412 The return value is 0 unless \fIn\fP is not greater than or equal to 1.
6413 .TP
6414 \fBbuiltin\fP \fIshell\-builtin\fP [\fIarguments\fP]
6415 Execute the specified shell builtin, passing it
6416 .IR arguments ,
6417 and return its exit status.
6418 This is useful when defining a
6419 function whose name is the same as a shell builtin,
6420 retaining the functionality of the builtin within the function.
6421 The \fBcd\fP builtin is commonly redefined this way.
6422 The return status is false if
6423 .I shell\-builtin
6424 is not a shell builtin command.
6425 .TP
6426 \fBcaller\fP [\fIexpr\fP]
6427 Returns the context of any active subroutine call (a shell function or
6428 a script executed with the \fB.\fP or \fBsource\fP builtins.
6429 Without \fIexpr\fP, \fBcaller\fP displays the line number and source
6430 filename of the current subroutine call.
6431 If a non-negative integer is supplied as \fIexpr\fP, \fBcaller\fP 
6432 displays the line number, subroutine name, and source file corresponding
6433 to that position in the current execution call stack.  This extra
6434 information may be used, for example, to print a stack trace.  The
6435 current frame is frame 0.
6436 The return value is 0 unless the shell is not executing a subroutine
6437 call or \fIexpr\fP does not correspond to a valid position in the
6438 call stack.
6439 .TP
6440 \fBcd\fP [\fB\-L|-P\fP] [\fIdir\fP]
6441 Change the current directory to \fIdir\fP.  The variable
6442 .SM
6443 .B HOME
6444 is the
6445 default
6446 .IR dir .
6447 The variable
6448 .SM
6449 .B CDPATH
6450 defines the search path for the directory containing
6451 .IR dir .
6452 Alternative directory names in
6453 .SM
6454 .B CDPATH
6455 are separated by a colon (:).  A null directory name in
6456 .SM
6457 .B CDPATH
6458 is the same as the current directory, i.e., ``\fB.\fP''.  If
6459 .I dir
6460 begins with a slash (/),
6461 then
6462 .SM
6463 .B CDPATH
6464 is not used. The
6465 .B \-P
6466 option says to use the physical directory structure instead of
6467 following symbolic links (see also the
6468 .B \-P
6469 option to the
6470 .B set
6471 builtin command); the
6472 .B \-L
6473 option forces symbolic links to be followed.  An argument of
6474 .B \-
6475 is equivalent to
6476 .SM
6477 .BR $OLDPWD .
6478 If a non-empty directory name from \fBCDPATH\fP is used, or if
6479 \fB\-\fP is the first argument, and the directory change is
6480 successful, the absolute pathname of the new working directory is
6481 written to the standard output.
6482 The return value is true if the directory was successfully changed;
6483 false otherwise.
6484 .TP
6485 \fBcommand\fP [\fB\-pVv\fP] \fIcommand\fP [\fIarg\fP ...]
6486 Run
6487 .I command
6488 with
6489 .I args
6490 suppressing the normal shell function lookup. Only builtin
6491 commands or commands found in the
6492 .SM
6493 .B PATH
6494 are executed.  If the
6495 .B \-p
6496 option is given, the search for
6497 .I command
6498 is performed using a default value for
6499 .B PATH
6500 that is guaranteed to find all of the standard utilities.
6501 If either the
6502 .B \-V
6503 or
6504 .B \-v
6505 option is supplied, a description of
6506 .I command
6507 is printed.  The
6508 .B \-v
6509 option causes a single word indicating the command or file name
6510 used to invoke
6511 .I command
6512 to be displayed; the
6513 .B \-V
6514 option produces a more verbose description.
6515 If the
6516 .B \-V
6517 or
6518 .B \-v
6519 option is supplied, the exit status is 0 if
6520 .I command
6521 was found, and 1 if not.  If neither option is supplied and
6522 an error occurred or
6523 .I command
6524 cannot be found, the exit status is 127.  Otherwise, the exit status of the
6525 .B command
6526 builtin is the exit status of
6527 .IR command .
6528 .TP
6529 \fBcompgen\fP [\fIoption\fP] [\fIword\fP]
6530 Generate possible completion matches for \fIword\fP according to
6531 the \fIoption\fPs, which may be any option accepted by the
6532 .B complete
6533 builtin with the exception of \fB\-p\fP and \fB\-r\fP, and write
6534 the matches to the standard output.
6535 When using the \fB\-F\fP or \fB\-C\fP options, the various shell variables
6536 set by the programmable completion facilities, while available, will not
6537 have useful values.
6538 .sp 1
6539 The matches will be generated in the same way as if the programmable
6540 completion code had generated them directly from a completion specification
6541 with the same flags.
6542 If \fIword\fP is specified, only those completions matching \fIword\fP
6543 will be displayed.
6544 .sp 1
6545 The return value is true unless an invalid option is supplied, or no
6546 matches were generated.
6547 .TP
6548 \fBcomplete\fP [\fB\-abcdefgjksuv\fP] [\fB\-o\fP \fIcomp-option\fP] [\fB\-E\fP] [\fB\-A\fP \fIaction\fP] [\fB\-G\fP \fIglobpat\fP] [\fB\-W\fP \fIwordlist\fP] [\fB\-F\fP \fIfunction\fP] [\fB\-C\fP \fIcommand\fP]
6549 .br
6550 [\fB\-X\fP \fIfilterpat\fP] [\fB\-P\fP \fIprefix\fP] [\fB\-S\fP \fIsuffix\fP] \fIname\fP [\fIname ...\fP]
6551 .PD 0
6552 .TP
6553 \fBcomplete\fP \fB\-pr\fP [\fB\-E\fP] [\fIname\fP ...]
6554 .PD
6555 Specify how arguments to each \fIname\fP should be completed.
6556 If the \fB\-p\fP option is supplied, or if no options are supplied,
6557 existing completion specifications are printed in a way that allows
6558 them to be reused as input.
6559 The \fB\-r\fP option removes a completion specification for
6560 each \fIname\fP, or, if no \fIname\fPs are supplied, all
6561 completion specifications.
6562 The \fB\-E\fP option indicates that the remaining options and actions should
6563 apply to ``empty'' command completion; that is, completion attempted on a
6564 blank line.
6565 .sp 1
6566 The process of applying these completion specifications when word completion
6567 is attempted is described above under \fBProgrammable Completion\fP.
6568 .sp 1
6569 Other options, if specified, have the following meanings.
6570 The arguments to the \fB\-G\fP, \fB\-W\fP, and \fB\-X\fP options
6571 (and, if necessary, the \fB\-P\fP and \fB\-S\fP options)
6572 should be quoted to protect them from expansion before the
6573 .B complete
6574 builtin is invoked.
6575 .RS
6576 .PD 0
6577 .TP 8
6578 \fB\-o\fP \fIcomp-option\fP
6579 The \fIcomp-option\fP controls several aspects of the compspec's behavior
6580 beyond the simple generation of completions.
6581 \fIcomp-option\fP may be one of:
6582 .RS
6583 .TP 8
6584 .B bashdefault
6585 Perform the rest of the default \fBbash\fP completions if the compspec
6586 generates no matches.
6587 .TP 8
6588 .B default
6589 Use readline's default filename completion if the compspec generates
6590 no matches.
6591 .TP 8
6592 .B dirnames
6593 Perform directory name completion if the compspec generates no matches.
6594 .TP 8
6595 .B filenames
6596 Tell readline that the compspec generates filenames, so it can perform any
6597 filename\-specific processing (like adding a slash to directory names,
6598 quoting special characters, or suppressing trailing spaces).
6599 Intended to be used with shell functions.
6600 .TP 8
6601 .B nospace
6602 Tell readline not to append a space (the default) to words completed at
6603 the end of the line.
6604 .TP 8
6605 .B plusdirs
6606 After any matches defined by the compspec are generated, 
6607 directory name completion is attempted and any
6608 matches are added to the results of the other actions.
6609 .RE
6610 .TP 8
6611 \fB\-A\fP \fIaction\fP
6612 The \fIaction\fP may be one of the following to generate a list of possible
6613 completions:
6614 .RS
6615 .TP 8
6616 .B alias
6617 Alias names.  May also be specified as \fB\-a\fP.
6618 .TP 8
6619 .B arrayvar
6620 Array variable names.
6621 .TP 8
6622 .B binding
6623 \fBReadline\fP key binding names.
6624 .TP 8
6625 .B builtin
6626 Names of shell builtin commands.  May also be specified as \fB\-b\fP.
6627 .TP 8
6628 .B command
6629 Command names.  May also be specified as \fB\-c\fP.
6630 .TP 8
6631 .B directory
6632 Directory names.  May also be specified as \fB\-d\fP.
6633 .TP 8
6634 .B disabled
6635 Names of disabled shell builtins.
6636 .TP 8
6637 .B enabled
6638 Names of enabled shell builtins.
6639 .TP 8
6640 .B export
6641 Names of exported shell variables.  May also be specified as \fB\-e\fP.
6642 .TP 8
6643 .B file
6644 File names.  May also be specified as \fB\-f\fP.
6645 .TP 8
6646 .B function
6647 Names of shell functions.
6648 .TP 8
6649 .B group
6650 Group names.  May also be specified as \fB\-g\fP.
6651 .TP 8
6652 .B helptopic
6653 Help topics as accepted by the \fBhelp\fP builtin.
6654 .TP 8
6655 .B hostname
6656 Hostnames, as taken from the file specified by the
6657 .SM
6658 .B HOSTFILE
6659 shell variable.
6660 .TP 8
6661 .B job
6662 Job names, if job control is active.  May also be specified as \fB\-j\fP.
6663 .TP 8
6664 .B keyword
6665 Shell reserved words.  May also be specified as \fB\-k\fP.
6666 .TP 8
6667 .B running
6668 Names of running jobs, if job control is active.
6669 .TP 8
6670 .B service
6671 Service names.  May also be specified as \fB\-s\fP.
6672 .TP 8
6673 .B setopt
6674 Valid arguments for the \fB\-o\fP option to the \fBset\fP builtin.
6675 .TP 8
6676 .B shopt
6677 Shell option names as accepted by the \fBshopt\fP builtin.
6678 .TP 8
6679 .B signal
6680 Signal names.
6681 .TP 8
6682 .B stopped
6683 Names of stopped jobs, if job control is active.
6684 .TP 8
6685 .B user
6686 User names.  May also be specified as \fB\-u\fP.
6687 .TP 8
6688 .B variable
6689 Names of all shell variables.  May also be specified as \fB\-v\fP.
6690 .RE
6691 .TP 8
6692 \fB\-G\fP \fIglobpat\fP
6693 The filename expansion pattern \fIglobpat\fP is expanded to generate
6694 the possible completions.
6695 .TP 8
6696 \fB\-W\fP \fIwordlist\fP
6697 The \fIwordlist\fP is split using the characters in the
6698 .SM
6699 .B IFS
6700 special variable as delimiters, and each resultant word is expanded.
6701 The possible completions are the members of the resultant list which
6702 match the word being completed.
6703 .TP 8
6704 \fB\-C\fP \fIcommand\fP
6705 \fIcommand\fP is executed in a subshell environment, and its output is
6706 used as the possible completions.
6707 .TP 8
6708 \fB\-F\fP \fIfunction\fP
6709 The shell function \fIfunction\fP is executed in the current shell
6710 environment.
6711 When it finishes, the possible completions are retrieved from the value
6712 of the
6713 .SM
6714 .B COMPREPLY
6715 array variable.
6716 .TP 8
6717 \fB\-X\fP \fIfilterpat\fP
6718 \fIfilterpat\fP is a pattern as used for filename expansion.
6719 It is applied to the list of possible completions generated by the
6720 preceding options and arguments, and each completion matching
6721 \fIfilterpat\fP is removed from the list.
6722 A leading \fB!\fP in \fIfilterpat\fP negates the pattern; in this
6723 case, any completion not matching \fIfilterpat\fP is removed.
6724 .TP 8
6725 \fB\-P\fP \fIprefix\fP
6726 \fIprefix\fP is added at the beginning of each possible completion
6727 after all other options have been applied.
6728 .TP 8
6729 \fB\-S\fP \fIsuffix\fP
6730 \fIsuffix\fP is appended to each possible completion
6731 after all other options have been applied.
6732 .PD
6733 .PP
6734 The return value is true unless an invalid option is supplied, an option
6735 other than \fB\-p\fP or \fB\-r\fP is supplied without a \fIname\fP
6736 argument, an attempt is made to remove a completion specification for
6737 a \fIname\fP for which no specification exists, or
6738 an error occurs adding a completion specification.
6739 .RE
6740 .TP
6741 \fBcompopt\fP [\fB\-o\fP \fIoption\fP] [\fB+o\fP \fIoption\fP] [\fIname\fP]
6742 Modify completion options for each \fIname\fP according to the
6743 \fIoption\fPs, or for the
6744 currently-execution completion if no \fIname\fPs are supplied.
6745 If no \fIoption\fPs are given, display the completion options for each
6746 \fIname\fP or the current completion.
6747 The possible values of \fIoption\fP are those valid for the \fBcomplete\fP
6748 builtin described above.
6749 .PP
6750 The return value is true unless an invalid option is supplied, an attempt
6751 is made to modify the options for a \fIname\fP for which no completion
6752 specification exists, or an output error occurs.
6753 .TP
6754 \fBcontinue\fP [\fIn\fP]
6755 Resume the next iteration of the enclosing
6756 .BR for ,
6757 .BR while ,
6758 .BR until ,
6759 or
6760 .B select
6761 loop.
6762 If
6763 .I n
6764 is specified, resume at the \fIn\fPth enclosing loop.
6765 .I n
6766 must be \(>= 1.  If
6767 .I n
6768 is greater than the number of enclosing loops, the last enclosing loop
6769 (the ``top-level'' loop) is resumed.
6770 The return value is 0 unless \fIn\fP is not greater than or equal to 1.
6771 .TP
6772 \fBdeclare\fP [\fB\-aAfFilrtux\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
6773 .PD 0
6774 .TP
6775 \fBtypeset\fP [\fB\-aAfFilrtux\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
6776 .PD
6777 Declare variables and/or give them attributes.
6778 If no \fIname\fPs are given then display the values of variables.
6779 The
6780 .B \-p
6781 option will display the attributes and values of each
6782 .IR name .
6783 When
6784 .B \-p
6785 is used with \fIname\fP arguments, additional options are ignored.
6786 When
6787 .B \-p
6788 is supplied without \fIname\fP arguments, it will display the attributes
6789 and values of all variables having the attributes specified by the
6790 additional options.
6791 If no other options are supplied with \fB\-p\fP, \fBdeclare\fP will display
6792 the attributes and values of all shell variables.  The \fB\-f\fP option
6793 will restrict the display to shell functions.
6794 The
6795 .B \-F
6796 option inhibits the display of function definitions; only the
6797 function name and attributes are printed.
6798 If the \fBextdebug\fP shell option is enabled using \fBshopt\fP,
6799 the source file name and line number where the function is defined
6800 are displayed as well.  The
6801 .B \-F
6802 option implies
6803 .BR \-f .
6804 The following options can
6805 be used to restrict output to variables with the specified attribute or
6806 to give variables attributes:
6807 .RS
6808 .PD 0
6809 .TP
6810 .B \-a
6811 Each \fIname\fP is an indexed array variable (see
6812 .B Arrays
6813 above).
6814 .TP
6815 .B \-A
6816 Each \fIname\fP is an associative array variable (see
6817 .B Arrays
6818 above).
6819 .TP
6820 .B \-f
6821 Use function names only.
6822 .TP
6823 .B \-i
6824 The variable is treated as an integer; arithmetic evaluation (see
6825 .SM
6826 .B "ARITHMETIC EVALUATION" ") "
6827 is performed when the variable is assigned a value.
6828 .TP
6829 .B \-l
6830 When the variable is assigned a value, all upper-case characters are
6831 converted to lower-case.
6832 The upper-case attribute is disabled.
6833 .TP
6834 .B \-r
6835 Make \fIname\fPs readonly.  These names cannot then be assigned values
6836 by subsequent assignment statements or unset.
6837 .TP
6838 .B \-t
6839 Give each \fIname\fP the \fItrace\fP attribute.
6840 Traced functions inherit the \fBDEBUG\fP and \fBRETURN\fP traps from
6841 the calling shell.
6842 The trace attribute has no special meaning for variables.
6843 .TP
6844 .B \-u
6845 When the variable is assigned a value, all lower-case characters are
6846 converted to upper-case.
6847 The lower-case attribute is disabled.
6848 .TP
6849 .B \-x
6850 Mark \fIname\fPs for export to subsequent commands via the environment.
6851 .PD
6852 .PP
6853 Using `+' instead of `\-'
6854 turns off the attribute instead,
6855 with the exceptions that \fB+a\fP
6856 may not be used to destroy an array variable and \fB+r\fB will not
6857 remove the readonly attribute.
6858 When used in a function,
6859 makes each
6860 \fIname\fP local, as with the 
6861 .B local
6862 command.
6863 If a variable name is followed by =\fIvalue\fP, the value of
6864 the variable is set to \fIvalue\fP.
6865 The return value is 0 unless an invalid option is encountered,
6866 an attempt is made to define a function using
6867 .if n ``\-f foo=bar'',
6868 .if t \f(CW\-f foo=bar\fP,
6869 an attempt is made to assign a value to a readonly variable,
6870 an attempt is made to assign a value to an array variable without
6871 using the compound assignment syntax (see
6872 .B Arrays
6873 above), one of the \fInames\fP is not a valid shell variable name,
6874 an attempt is made to turn off readonly status for a readonly variable,
6875 an attempt is made to turn off array status for an array variable,
6876 or an attempt is made to display a non-existent function with \fB\-f\fP.
6877 .RE
6878 .TP
6879 .B dirs [+\fIn\fP] [\-\fIn\fP] [\fB\-cplv\fP]
6880 Without options, displays the list of currently remembered directories.
6881 The default display is on a single line with directory names separated
6882 by spaces.
6883 Directories are added to the list with the 
6884 .B pushd
6885 command; the
6886 .B popd
6887 command removes entries from the list.
6888 .RS
6889 .PD 0
6890 .TP
6891 \fB+\fP\fIn\fP
6892 Displays the \fIn\fPth entry counting from the left of the list
6893 shown by
6894 .B dirs
6895 when invoked without options, starting with zero.
6896 .TP
6897 \fB\-\fP\fIn\fP
6898 Displays the \fIn\fPth entry counting from the right of the list
6899 shown by
6900 .B dirs
6901 when invoked without options, starting with zero.
6902 .TP
6903 .B \-c
6904 Clears the directory stack by deleting all of the entries.
6905 .TP
6906 .B \-l
6907 Produces a longer listing; the default listing format uses a 
6908 tilde to denote the home directory.
6909 .TP
6910 .B \-p
6911 Print the directory stack with one entry per line.
6912 .TP
6913 .B \-v
6914 Print the directory stack with one entry per line,
6915 prefixing each entry with its index in the stack.
6916 .PD
6917 .PP
6918 The return value is 0 unless an
6919 invalid option is supplied or \fIn\fP indexes beyond the end
6920 of the directory stack.
6921 .RE
6922 .TP
6923 \fBdisown\fP [\fB\-ar\fP] [\fB\-h\fP] [\fIjobspec\fP ...]
6924 Without options, each
6925 .I jobspec
6926 is removed from the table of active jobs.
6927 If
6928 .I jobspec
6929 is not present, and neither \fB\-a\fB nor \fB\-r\fP is supplied,
6930 the shell's notion of the \fIcurrent job\fP is used.
6931 If the \fB\-h\fP option is given, each
6932 .I jobspec
6933 is not removed from the table, but is marked so that
6934 .SM
6935 .B SIGHUP
6936 is not sent to the job if the shell receives a
6937 .SM
6938 .BR SIGHUP .
6939 If no
6940 .I jobspec
6941 is present, and neither the
6942 .B \-a
6943 nor the
6944 .B \-r
6945 option is supplied, the \fIcurrent job\fP is used.
6946 If no
6947 .I jobspec
6948 is supplied, the
6949 .B \-a
6950 option means to remove or mark all jobs; the
6951 .B \-r
6952 option without a
6953 .I jobspec
6954 argument restricts operation to running jobs.
6955 The return value is 0 unless a
6956 .I jobspec
6957 does not specify a valid job.
6958 .TP
6959 \fBecho\fP [\fB\-neE\fP] [\fIarg\fP ...]
6960 Output the \fIarg\fPs, separated by spaces, followed by a newline.
6961 The return status is always 0.
6962 If \fB\-n\fP is specified, the trailing newline is
6963 suppressed.  If the \fB\-e\fP option is given, interpretation of
6964 the following backslash-escaped characters is enabled.  The
6965 .B \-E
6966 option disables the interpretation of these escape characters,
6967 even on systems where they are interpreted by default.
6968 The \fBxpg_echo\fP shell option may be used to
6969 dynamically determine whether or not \fBecho\fP expands these
6970 escape characters by default.
6971 .B echo
6972 does not interpret \fB\-\-\fP to mean the end of options.
6973 .B echo
6974 interprets the following escape sequences:
6975 .RS
6976 .PD 0
6977 .TP
6978 .B \ea
6979 alert (bell)
6980 .TP
6981 .B \eb
6982 backspace
6983 .TP
6984 .B \ec
6985 suppress further output
6986 .TP
6987 .B \ee
6988 an escape character
6989 .TP
6990 .B \ef
6991 form feed
6992 .TP
6993 .B \en
6994 new line
6995 .TP
6996 .B \er
6997 carriage return
6998 .TP
6999 .B \et
7000 horizontal tab
7001 .TP
7002 .B \ev
7003 vertical tab
7004 .TP
7005 .B \e\e
7006 backslash
7007 .TP
7008 .B \e0\fInnn\fP
7009 the eight-bit character whose value is the octal value \fInnn\fP
7010 (zero to three octal digits)
7011 .TP
7012 .B \ex\fIHH\fP
7013 the eight-bit character whose value is the hexadecimal value \fIHH\fP
7014 (one or two hex digits)
7015 .PD
7016 .RE
7017 .TP
7018 \fBenable\fP [\fB\-a\fP] [\fB\-dnps\fP] [\fB\-f\fP \fIfilename\fP] [\fIname\fP ...]
7019 Enable and disable builtin shell commands.
7020 Disabling a builtin allows a disk command which has the same name
7021 as a shell builtin to be executed without specifying a full pathname,
7022 even though the shell normally searches for builtins before disk commands.
7023 If \fB\-n\fP is used, each \fIname\fP
7024 is disabled; otherwise,
7025 \fInames\fP are enabled.  For example, to use the
7026 .B test
7027 binary found via the
7028 .SM
7029 .B PATH
7030 instead of the shell builtin version, run
7031 .if t \f(CWenable -n test\fP.
7032 .if n ``enable -n test''.
7033 The
7034 .B \-f
7035 option means to load the new builtin command
7036 .I name
7037 from shared object
7038 .IR filename ,
7039 on systems that support dynamic loading.  The
7040 .B \-d
7041 option will delete a builtin previously loaded with
7042 .BR \-f .
7043 If no \fIname\fP arguments are given, or if the
7044 .B \-p
7045 option is supplied, a list of shell builtins is printed.
7046 With no other option arguments, the list consists of all enabled
7047 shell builtins.
7048 If \fB\-n\fP is supplied, only disabled builtins are printed.
7049 If \fB\-a\fP is supplied, the list printed includes all builtins, with an
7050 indication of whether or not each is enabled.
7051 If \fB\-s\fP is supplied, the output is restricted to the POSIX
7052 \fIspecial\fP builtins.
7053 The return value is 0 unless a
7054 .I name
7055 is not a shell builtin or there is an error loading a new builtin
7056 from a shared object.
7057 .TP
7058 \fBeval\fP [\fIarg\fP ...]
7059 The \fIarg\fPs are read and concatenated together into a single
7060 command.  This command is then read and executed by the shell, and
7061 its exit status is returned as the value of
7062 .BR eval .
7063 If there are no
7064 .IR args ,
7065 or only null arguments,
7066 .B eval
7067 returns 0.
7068 .TP
7069 \fBexec\fP [\fB\-cl\fP] [\fB\-a\fP \fIname\fP] [\fIcommand\fP [\fIarguments\fP]]
7070 If
7071 .I command
7072 is specified, it replaces the shell.
7073 No new process is created.  The
7074 .I arguments
7075 become the arguments to \fIcommand\fP.
7076 If the
7077 .B \-l
7078 option is supplied,
7079 the shell places a dash at the beginning of the zeroth argument passed to 
7080 .IR command .
7081 This is what
7082 .IR login (1)
7083 does.  The
7084 .B \-c
7085 option causes
7086 .I command
7087 to be executed with an empty environment.  If
7088 .B \-a
7089 is supplied, the shell passes
7090 .I name
7091 as the zeroth argument to the executed command.  If
7092 .I command
7093 cannot be executed for some reason, a non-interactive shell exits,
7094 unless the shell option
7095 .B execfail
7096 is enabled, in which case it returns failure.
7097 An interactive shell returns failure if the file cannot be executed.
7098 If
7099 .I command
7100 is not specified, any redirections take effect in the current shell,
7101 and the return status is 0.  If there is a redirection error, the
7102 return status is 1.
7103 .TP
7104 \fBexit\fP [\fIn\fP]
7105 Cause the shell to exit
7106 with a status of \fIn\fP.  If
7107 .I n
7108 is omitted, the exit status
7109 is that of the last command executed.
7110 A trap on
7111 .SM
7112 .B EXIT
7113 is executed before the shell terminates.
7114 .TP
7115 \fBexport\fP [\fB\-fn\fP\^] [\fIname\fP[=\fIword\fP]] ...
7116 .PD 0
7117 .TP
7118 .B export \-p
7119 .PD
7120 The supplied
7121 .I names
7122 are marked for automatic export to the environment of
7123 subsequently executed commands.  If the 
7124 .B \-f
7125 option is given,
7126 the 
7127 .I names
7128 refer to functions.
7129 If no
7130 .I names
7131 are given, or if the
7132 .B \-p
7133 option is supplied, a list
7134 of all names that are exported in this shell is printed.
7135 The
7136 .B \-n
7137 option causes the export property to be removed from each
7138 \fIname\fP.
7139 If a variable name is followed by =\fIword\fP, the value of
7140 the variable is set to \fIword\fP.
7141 .B export
7142 returns an exit status of 0 unless an invalid option is
7143 encountered,
7144 one of the \fInames\fP is not a valid shell variable name, or
7145 .B \-f
7146 is supplied with a
7147 .I name
7148 that is not a function.
7149 .TP
7150 \fBfc\fP [\fB\-e\fP \fIename\fP] [\fB\-lnr\fP] [\fIfirst\fP] [\fIlast\fP]
7151 .PD 0
7152 .TP
7153 \fBfc\fP \fB\-s\fP [\fIpat\fP=\fIrep\fP] [\fIcmd\fP]
7154 .PD
7155 Fix Command.  In the first form, a range of commands from
7156 .I first
7157 to
7158 .I last
7159 is selected from the history list.
7160 .I First
7161 and
7162 .I last
7163 may be specified as a string (to locate the last command beginning
7164 with that string) or as a number (an index into the history list,
7165 where a negative number is used as an offset from the current
7166 command number).  If 
7167 .I last
7168 is not specified it is set to
7169 the current command for listing (so that
7170 .if n ``fc \-l \-10''
7171 .if t \f(CWfc \-l \-10\fP
7172 prints the last 10 commands) and to
7173 .I first
7174 otherwise.
7175 If
7176 .I first
7177 is not specified it is set to the previous
7178 command for editing and \-16 for listing.
7179 .sp 1
7180 The
7181 .B \-n
7182 option suppresses
7183 the command numbers when listing.  The
7184 .B \-r
7185 option reverses the order of
7186 the commands.  If the
7187 .B \-l
7188 option is given,
7189 the commands are listed on
7190 standard output.  Otherwise, the editor given by
7191 .I ename
7192 is invoked
7193 on a file containing those commands.  If
7194 .I ename
7195 is not given, the
7196 value of the
7197 .SM
7198 .B FCEDIT
7199 variable is used, and
7200 the value of
7201 .SM
7202 .B EDITOR
7203 if
7204 .SM
7205 .B FCEDIT
7206 is not set.  If neither variable is set,
7207 .FN vi
7208 is used.  When editing is complete, the edited commands are
7209 echoed and executed.
7210 .sp 1
7211 In the second form, \fIcommand\fP is re-executed after each instance
7212 of \fIpat\fP is replaced by \fIrep\fP.
7213 A useful alias to use with this is
7214 .if n ``r="fc -s"'',
7215 .if t \f(CWr='fc \-s'\fP,
7216 so that typing
7217 .if n ``r cc''
7218 .if t \f(CWr cc\fP
7219 runs the last command beginning with
7220 .if n ``cc''
7221 .if t \f(CWcc\fP
7222 and typing
7223 .if n ``r''
7224 .if t \f(CWr\fP
7225 re-executes the last command.
7226 .sp 1
7227 If the first form is used, the return value is 0 unless an invalid
7228 option is encountered or
7229 .I first
7230 or
7231 .I last
7232 specify history lines out of range.
7233 If the
7234 .B \-e
7235 option is supplied, the return value is the value of the last
7236 command executed or failure if an error occurs with the temporary
7237 file of commands.  If the second form is used, the return status
7238 is that of the command re-executed, unless
7239 .I cmd
7240 does not specify a valid history line, in which case
7241 .B fc
7242 returns failure.
7243 .TP
7244 \fBfg\fP [\fIjobspec\fP]
7245 Resume
7246 .I jobspec
7247 in the foreground, and make it the current job.
7248 If
7249 .I jobspec
7250 is not present, the shell's notion of the \fIcurrent job\fP is used.
7251 The return value is that of the command placed into the foreground,
7252 or failure if run when job control is disabled or, when run with
7253 job control enabled, if
7254 .I jobspec
7255 does not specify a valid job or
7256 .I jobspec
7257 specifies a job that was started without job control.
7258 .TP
7259 \fBgetopts\fP \fIoptstring\fP \fIname\fP [\fIargs\fP]
7260 .B getopts
7261 is used by shell procedures to parse positional parameters.
7262 .I optstring
7263 contains the option characters to be recognized; if a character
7264 is followed by a colon, the option is expected to have an
7265 argument, which should be separated from it by white space.
7266 The colon and question mark characters may not be used as
7267 option characters.
7268 Each time it is invoked,
7269 .B getopts
7270 places the next option in the shell variable
7271 .IR name ,
7272 initializing
7273 .I name
7274 if it does not exist,
7275 and the index of the next argument to be processed into the
7276 variable
7277 .SM
7278 .BR OPTIND .
7279 .SM
7280 .B OPTIND
7281 is initialized to 1 each time the shell or a shell script
7282 is invoked.  When an option requires an argument,
7283 .B getopts
7284 places that argument into the variable
7285 .SM
7286 .BR OPTARG .
7287 The shell does not reset
7288 .SM
7289 .B OPTIND
7290 automatically; it must be manually reset between multiple
7291 calls to
7292 .B getopts
7293 within the same shell invocation if a new set of parameters
7294 is to be used.
7295 .sp 1
7296 When the end of options is encountered, \fBgetopts\fP exits with a
7297 return value greater than zero.
7298 \fBOPTIND\fP is set to the index of the first non-option argument,
7299 and \fBname\fP is set to ?.
7300 .sp 1
7301 .B getopts
7302 normally parses the positional parameters, but if more arguments are
7303 given in
7304 .IR args ,
7305 .B getopts
7306 parses those instead.
7307 .sp 1
7308 .B getopts
7309 can report errors in two ways.  If the first character of
7310 .I optstring
7311 is a colon,
7312 .I silent
7313 error reporting is used.  In normal operation diagnostic messages
7314 are printed when invalid options or missing option arguments are
7315 encountered.
7316 If the variable
7317 .SM
7318 .B OPTERR
7319 is set to 0, no error messages will be displayed, even if the first
7320 character of 
7321 .I optstring
7322 is not a colon.
7323 .sp 1
7324 If an invalid option is seen,
7325 .B getopts
7326 places ? into
7327 .I name
7328 and, if not silent,
7329 prints an error message and unsets
7330 .SM
7331 .BR OPTARG .
7332 If
7333 .B getopts
7334 is silent,
7335 the option character found is placed in
7336 .SM
7337 .B OPTARG
7338 and no diagnostic message is printed.
7339 .sp 1
7340 If a required argument is not found, and
7341 .B getopts
7342 is not silent,
7343 a question mark (\^\fB?\fP\^) is placed in
7344 .IR name ,
7345 .SM
7346 .B OPTARG
7347 is unset, and a diagnostic message is printed.
7348 If
7349 .B getopts
7350 is silent, then a colon (\^\fB:\fP\^) is placed in
7351 .I name
7352 and
7353 .SM
7354 .B OPTARG
7355 is set to the option character found.
7356 .sp 1
7357 .B getopts
7358 returns true if an option, specified or unspecified, is found.
7359 It returns false if the end of options is encountered or an
7360 error occurs.
7361 .TP
7362 \fBhash\fP [\fB\-lr\fP] [\fB\-p\fP \fIfilename\fP] [\fB\-dt\fP] [\fIname\fP]
7363 For each
7364 .IR name ,
7365 the full file name of the command is determined by searching
7366 the directories in
7367 .B $PATH
7368 and remembered.
7369 If the
7370 .B \-p
7371 option is supplied, no path search is performed, and
7372 .I filename
7373 is used as the full file name of the command.
7374 The
7375 .B \-r
7376 option causes the shell to forget all
7377 remembered locations.
7378 The
7379 .B \-d
7380 option causes the shell to forget the remembered location of each \fIname\fP.
7381 If the
7382 .B \-t
7383 option is supplied, the full pathname to which each \fIname\fP corresponds
7384 is printed.  If multiple \fIname\fP arguments are supplied with \fB\-t\fP,
7385 the \fIname\fP is printed before the hashed full pathname.
7386 The
7387 .B \-l
7388 option causes output to be displayed in a format that may be reused as input.
7389 If no arguments are given, or if only \fB\-l\fP is supplied,
7390 information about remembered commands is printed.
7391 The return status is true unless a
7392 .I name
7393 is not found or an invalid option is supplied.
7394 .TP
7395 \fBhelp\fP [\fB\-dms\fP] [\fIpattern\fP]
7396 Display helpful information about builtin commands.  If
7397 .I pattern
7398 is specified,
7399 .B help
7400 gives detailed help on all commands matching
7401 .IR pattern ;
7402 otherwise help for all the builtins and shell control structures
7403 is printed.
7404 .RS
7405 .PD 0
7406 .TP
7407 .B \-d
7408 Display a short description of each \fIpattern\fP
7409 .TP
7410 .B \ -m
7411 Display the description of each \fIpattern\fP in a manpage-like format
7412 .TP
7413 .B \-s
7414 Display only a short usage synopsis for each \fIpattern\fP
7415 .PD
7416 .RE
7417 The return status is 0 unless no command matches
7418 .IR pattern .
7419 .TP
7420 \fBhistory [\fIn\fP]
7421 .PD 0
7422 .TP
7423 \fBhistory\fP \fB\-c\fP
7424 .TP
7425 \fBhistory \-d\fP \fIoffset\fP
7426 .TP
7427 \fBhistory\fP \fB\-anrw\fP [\fIfilename\fP]
7428 .TP
7429 \fBhistory\fP \fB\-p\fP \fIarg\fP [\fIarg ...\fP]
7430 .TP
7431 \fBhistory\fP \fB\-s\fP \fIarg\fP [\fIarg ...\fP]
7432 .PD
7433 With no options, display the command
7434 history list with line numbers.  Lines listed
7435 with a 
7436 .B *
7437 have been modified.  An argument of
7438 .I n
7439 lists only the last
7440 .I n
7441 lines.
7442 If the shell variable \fBHISTTIMEFORMAT\fP is set and not null,
7443 it is used as a format string for \fIstrftime\fP(3) to display
7444 the time stamp associated with each displayed history entry.
7445 No intervening blank is printed between the formatted time stamp
7446 and the history line.
7447 If \fIfilename\fP is supplied, it is used as the
7448 name of the history file; if not, the value of
7449 .SM
7450 .B HISTFILE
7451 is used.  Options, if supplied, have the following meanings:
7452 .RS
7453 .PD 0
7454 .TP
7455 .B \-c
7456 Clear the history list by deleting all the entries.
7457 .TP
7458 \fB\-d\fP \fIoffset\fP
7459 Delete the history entry at position \fIoffset\fP.
7460 .TP
7461 .B \-a
7462 Append the ``new'' history lines (history lines entered since the
7463 beginning of the current \fBbash\fP session) to the history file.
7464 .TP
7465 .B \-n
7466 Read the history lines not already read from the history
7467 file into the current history list.  These are lines
7468 appended to the history file since the beginning of the
7469 current \fBbash\fP session.
7470 .TP
7471 .B \-r
7472 Read the contents of the history file
7473 and use them as the current history.
7474 .TP
7475 .B \-w
7476 Write the current history to the history file, overwriting the
7477 history file's contents.
7478 .TP
7479 .B \-p
7480 Perform history substitution on the following \fIargs\fP and display
7481 the result on the standard output.
7482 Does not store the results in the history list.
7483 Each \fIarg\fP must be quoted to disable normal history expansion.
7484 .TP
7485 .B \-s
7486 Store the
7487 .I args
7488 in the history list as a single entry.  The last command in the
7489 history list is removed before the
7490 .I args
7491 are added.
7492 .PD
7493 .PP
7494 If the \fBHISTTIMEFORMAT\fP is set, the time stamp information
7495 associated with each history entry is written to the history file,
7496 marked with the history comment character.
7497 When the history file is read, lines beginning with the history
7498 comment character followed immediately by a digit are interpreted
7499 as timestamps for the previous history line.
7500 The return value is 0 unless an invalid option is encountered, an
7501 error occurs while reading or writing the history file, an invalid
7502 \fIoffset\fP is supplied as an argument to \fB\-d\fP, or the
7503 history expansion supplied as an argument to \fB\-p\fP fails.
7504 .RE
7505 .TP
7506 \fBjobs\fP [\fB\-lnprs\fP] [ \fIjobspec\fP ... ]
7507 .PD 0
7508 .TP
7509 \fBjobs\fP \fB\-x\fP \fIcommand\fP [ \fIargs\fP ... ]
7510 .PD
7511 The first form lists the active jobs.  The options have the following
7512 meanings:
7513 .RS
7514 .PD 0
7515 .TP
7516 .B \-l
7517 List process IDs
7518 in addition to the normal information.
7519 .TP
7520 .B \-p
7521 List only the process ID of the job's process group
7522 leader.
7523 .TP
7524 .B \-n
7525 Display information only about jobs that have changed status since
7526 the user was last notified of their status.
7527 .TP
7528 .B \-r
7529 Restrict output to running jobs.
7530 .TP
7531 .B \-s
7532 Restrict output to stopped jobs.
7533 .PD
7534 .PP
7535 If
7536 .I jobspec
7537 is given, output is restricted to information about that job.
7538 The return status is 0 unless an invalid option is encountered
7539 or an invalid
7540 .I jobspec
7541 is supplied.
7542 .PP
7543 If the
7544 .B \-x
7545 option is supplied,
7546 .B jobs
7547 replaces any
7548 .I jobspec
7549 found in
7550 .I command
7551 or
7552 .I args
7553 with the corresponding process group ID, and executes
7554 .I command
7555 passing it
7556 .IR args ,
7557 returning its exit status.
7558 .RE
7559 .TP
7560 \fBkill\fP [\fB\-s\fP \fIsigspec\fP | \fB\-n\fP \fIsignum\fP | \fB\-\fP\fIsigspec\fP] [\fIpid\fP | \fIjobspec\fP] ...
7561 .PD 0
7562 .TP
7563 \fBkill\fP \fB\-l\fP [\fIsigspec\fP | \fIexit_status\fP]
7564 .PD
7565 Send the signal named by
7566 .I sigspec
7567 or
7568 .I signum
7569 to the processes named by
7570 .I pid
7571 or
7572 .IR jobspec .
7573 .I sigspec
7574 is either a case-insensitive signal name such as
7575 .SM
7576 .B SIGKILL
7577 (with or without the
7578 .SM
7579 .B SIG
7580 prefix) or a signal number;
7581 .I signum
7582 is a signal number.
7583 If
7584 .I sigspec
7585 is not present, then
7586 .SM
7587 .B SIGTERM
7588 is assumed.
7589 An argument of
7590 .B \-l
7591 lists the signal names.
7592 If any arguments are supplied when
7593 .B \-l
7594 is given, the names of the signals corresponding to the arguments are
7595 listed, and the return status is 0.
7596 The \fIexit_status\fP argument to
7597 .B \-l
7598 is a number specifying either a signal number or the exit status of
7599 a process terminated by a signal.
7600 .B kill
7601 returns true if at least one signal was successfully sent, or false
7602 if an error occurs or an invalid option is encountered.
7603 .TP
7604 \fBlet\fP \fIarg\fP [\fIarg\fP ...]
7605 Each
7606 .I arg
7607 is an arithmetic expression to be evaluated (see
7608 .SM
7609 .BR "ARITHMETIC EVALUATION" ).
7610 If the last
7611 .I arg
7612 evaluates to 0,
7613 .B let
7614 returns 1; 0 is returned otherwise.
7615 .TP
7616 \fBlocal\fP [\fIoption\fP] [\fIname\fP[=\fIvalue\fP] ...]
7617 For each argument, a local variable named
7618 .I name 
7619 is created, and assigned
7620 .IR value .
7621 The \fIoption\fP can be any of the options accepted by \fBdeclare\fP.
7622 When
7623 .B local
7624 is used within a function, it causes the variable
7625 .I name
7626 to have a visible scope restricted to that function and its children.
7627 With no operands,
7628 .B local
7629 writes a list of local variables to the standard output.  It is
7630 an error to use
7631 .B local
7632 when not within a function.  The return status is 0 unless
7633 .B local
7634 is used outside a function, an invalid
7635 .I name
7636 is supplied, or
7637 \fIname\fP is a readonly variable.
7638 .TP
7639 .B logout
7640 Exit a login shell.
7641 .TP
7642 \fBmapfile\fP [\fB\-n\fP \fIcount\fP] [\fB\-O\fP \fIorigin\fP] [\fB\-s\fP \fIcount\fP] [\fB\-t\fP] [\fB\-u\fP \fIfd\fP] [\fB\-C\fP \fIcallback\fP] [\fB\-c\fP \fIquantum\fP] [\fIarray\fP]
7643 .PD 0
7644 .TP
7645 \fBreadarray\fP [\fB\-n\fP \fIcount\fP] [\fB\-O\fP \fIorigin\fP] [\fB\-s\fP \fIcount\fP] [\fB\-t\fP] [\fB\-u\fP \fIfd\fP] [\fB\-C\fP \fIcallback\fP] [\fB\-c\fP \fIquantum\fP] [\fIarray\fP]
7646 .PD
7647 Read lines from the standard input into array variable
7648 .IR array ,
7649 or from file descriptor 
7650 .IR fd
7651 if the 
7652 .B \-u
7653 option is supplied.
7654 The variable \fBMAPFILE\fP is the default \fIarray\fP.
7655 Options, if supplied, have the following meanings:
7656 .RS
7657 .PD 0
7658 .TP
7659 .B \-n
7660 Copy at most
7661 .I count
7662 lines.  If \fIcount\fP is 0, all lines are copied.
7663 .TP
7664 .B \-O
7665 Begin assigning to
7666 .I array
7667 at index
7668 .IR origin .
7669 The default index is 0.
7670 .TP
7671 .B \-s
7672 Discard the first \fIcount\fP lines read.
7673 .TP
7674 .B \-t
7675 Remove a trailing line from each line read.
7676 .TP
7677 .B \-u
7678 Read lines from file descriptor \fIfd\fP instead of the standard input.
7679 .TP
7680 .B \-C
7681 Evaluate
7682 .I callback
7683 each time \fIquantum\fP lines are read.  The \fB\-c\fP option specifies
7684 .IR quantum .
7685 .TP
7686 .B \-c
7687 Specify the number of lines read between each call to
7688 .IR callback .
7689 .PD
7690 .PP
7691 If
7692 .B \-C
7693 is specified without 
7694 .BR \-c ,
7695 the default quantum is 5000.
7696 When \fIcallback\fP is evaluated, it is supplied the index of the next
7697 array element to be assigned as an additional argument.
7698 \fIcallback\fP is evaluated after the line is read but before the 
7699 array element is assigned.
7700 .PP
7701 If not supplied with an explicit origin, \fBmapfile\fP will clear \fIarray\fP
7702 before assigning to it.
7703 .PP
7704 \fBmapfile\fP returns successfully unless an invalid option or option
7705 argument is supplied, or \fIarray\fP is invalid or unassignable.
7706 .RE
7707 .TP
7708 \fBpopd\fP [\-\fBn\fP] [+\fIn\fP] [\-\fIn\fP]
7709 Removes entries from the directory stack.  With no arguments,
7710 removes the top directory from the stack, and performs a
7711 .B cd
7712 to the new top directory.
7713 Arguments, if supplied, have the following meanings:
7714 .RS
7715 .PD 0
7716 .TP
7717 .B \-n
7718 Suppresses the normal change of directory when removing directories
7719 from the stack, so that only the stack is manipulated.
7720 .TP
7721 \fB+\fP\fIn\fP
7722 Removes the \fIn\fPth entry counting from the left of the list
7723 shown by
7724 .BR dirs ,
7725 starting with zero.  For example:
7726 .if n ``popd +0''
7727 .if t \f(CWpopd +0\fP
7728 removes the first directory,
7729 .if n ``popd +1''
7730 .if t \f(CWpopd +1\fP
7731 the second.
7732 .TP
7733 \fB\-\fP\fIn\fP
7734 Removes the \fIn\fPth entry counting from the right of the list
7735 shown by
7736 .BR dirs ,
7737 starting with zero.  For example:
7738 .if n ``popd -0''
7739 .if t \f(CWpopd -0\fP
7740 removes the last directory,
7741 .if n ``popd -1''
7742 .if t \f(CWpopd -1\fP
7743 the next to last.
7744 .PD
7745 .PP
7746 If the
7747 .B popd
7748 command is successful, a 
7749 .B dirs
7750 is performed as well, and the return status is 0.
7751 .B popd
7752 returns false if an invalid option is encountered, the directory stack
7753 is empty, a non-existent directory stack entry is specified, or the
7754 directory change fails.
7755 .RE
7756 .TP
7757 \fBprintf\fP [\fB\-v\fP \fIvar\fP] \fIformat\fP [\fIarguments\fP]
7758 Write the formatted \fIarguments\fP to the standard output under the
7759 control of the \fIformat\fP.
7760 The \fIformat\fP is a character string which contains three types of objects:
7761 plain characters, which are simply copied to standard output, character
7762 escape sequences, which are converted and copied to the standard output, and
7763 format specifications, each of which causes printing of the next successive
7764 \fIargument\fP.
7765 In addition to the standard \fIprintf\fP(1) formats, \fB%b\fP causes
7766 \fBprintf\fP to expand backslash escape sequences in the corresponding
7767 \fIargument\fP (except that \fB\ec\fP terminates output, backslashes in
7768 \fB\e\(aq\fP, \fB\e"\fP, and \fB\e?\fP are not removed, and octal escapes
7769 beginning with \fB\e0\fP may contain up to four digits),
7770 and \fB%q\fP causes \fBprintf\fP to output the corresponding
7771 \fIargument\fP in a format that can be reused as shell input.
7772 .sp 1
7773 The \fB\-v\fP option causes the output to be assigned to the variable
7774 \fIvar\fP rather than being printed to the standard output.
7775 .sp 1
7776 The \fIformat\fP is reused as necessary to consume all of the \fIarguments\fP.
7777 If the \fIformat\fP requires more \fIarguments\fP than are supplied, the
7778 extra format specifications behave as if a zero value or null string, as
7779 appropriate, had been supplied.  The return value is zero on success,
7780 non-zero on failure.
7781 .TP
7782 \fBpushd\fP [\fB\-n\fP] [+\fIn\fP] [\-\fIn\fP]
7783 .PD 0
7784 .TP
7785 \fBpushd\fP [\fB\-n\fP] [\fIdir\fP]
7786 .PD
7787 Adds a directory to the top of the directory stack, or rotates
7788 the stack, making the new top of the stack the current working
7789 directory.  With no arguments, exchanges the top two directories
7790 and returns 0, unless the directory stack is empty.
7791 Arguments, if supplied, have the following meanings:
7792 .RS
7793 .PD 0
7794 .TP
7795 .B \-n
7796 Suppresses the normal change of directory when adding directories
7797 to the stack, so that only the stack is manipulated.
7798 .TP
7799 \fB+\fP\fIn\fP
7800 Rotates the stack so that the \fIn\fPth directory
7801 (counting from the left of the list shown by
7802 .BR dirs ,
7803 starting with zero)
7804 is at the top.
7805 .TP
7806 \fB\-\fP\fIn\fP
7807 Rotates the stack so that the \fIn\fPth directory
7808 (counting from the right of the list shown by
7809 .BR dirs ,
7810 starting with zero) is at the top.
7811 .TP
7812 .I dir
7813 Adds
7814 .I dir
7815 to the directory stack at the top, making it the
7816 new current working directory.
7817 .PD
7818 .PP
7819 If the
7820 .B pushd
7821 command is successful, a 
7822 .B dirs
7823 is performed as well.
7824 If the first form is used,
7825 .B pushd
7826 returns 0 unless the cd to
7827 .I dir
7828 fails.  With the second form,
7829 .B pushd
7830 returns 0 unless the directory stack is empty,
7831 a non-existent directory stack element is specified,
7832 or the directory change to the specified new current directory
7833 fails.
7834 .RE
7835 .TP
7836 \fBpwd\fP [\fB\-LP\fP]
7837 Print the absolute pathname of the current working directory.
7838 The pathname printed contains no symbolic links if the
7839 .B \-P
7840 option is supplied or the 
7841 .B \-o physical
7842 option to the
7843 .B set
7844 builtin command is enabled.
7845 If the
7846 .B \-L
7847 option is used, the pathname printed may contain symbolic links.
7848 The return status is 0 unless an error occurs while
7849 reading the name of the current directory or an
7850 invalid option is supplied.
7851 .TP
7852 \fBread\fP [\fB\-ers\fP] [\fB\-a\fP \fIaname\fP] [\fB\-d\fP \fIdelim\fP] [\fB\-i\fP \fItext\fP] [\fB\-n\fP \fInchars\fP] [\fB\-p\fP \fIprompt\fP] [\fB\-t\fP \fItimeout\fP] [\fB\-u\fP \fIfd\fP] [\fIname\fP ...]
7853 One line is read from the standard input, or from the file descriptor
7854 \fIfd\fP supplied as an argument to the \fB\-u\fP option, and the first word
7855 is assigned to the first
7856 .IR name ,
7857 the second word to the second
7858 .IR name ,
7859 and so on, with leftover words and their intervening separators assigned
7860 to the last
7861 .IR name .
7862 If there are fewer words read from the input stream than names,
7863 the remaining names are assigned empty values.
7864 The characters in 
7865 .SM
7866 .B IFS
7867 are used to split the line into words.
7868 The backslash character (\fB\e\fP) may be used to remove any special
7869 meaning for the next character read and for line continuation.
7870 Options, if supplied, have the following meanings:
7871 .RS
7872 .PD 0
7873 .TP
7874 .B \-a \fIaname\fP
7875 The words are assigned to sequential indices
7876 of the array variable
7877 .IR aname ,
7878 starting at 0.
7879 .I aname
7880 is unset before any new values are assigned.
7881 Other \fIname\fP arguments are ignored.
7882 .TP
7883 .B \-d \fIdelim\fP
7884 The first character of \fIdelim\fP is used to terminate the input line,
7885 rather than newline.
7886 .TP
7887 .B \-e
7888 If the standard input
7889 is coming from a terminal,
7890 .B readline
7891 (see
7892 .SM
7893 .B READLINE
7894 above) is used to obtain the line.
7895 Readline uses the current (or default, if line editing was not previously
7896 active) editing settings.
7897 .TP
7898 .B \-i \fItext\fP
7899 If
7900 .B readline
7901 is being used to read the line, \fItext\fP is placed into the editing
7902 buffer before editing begins.
7903 .TP
7904 .B \-n \fInchars\fP
7905 \fBread\fP returns after reading \fInchars\fP characters rather than
7906 waiting for a complete line of input.
7907 .TP
7908 .B \-p \fIprompt\fP
7909 Display \fIprompt\fP on standard error, without a
7910 trailing newline, before attempting to read any input.  The prompt
7911 is displayed only if input is coming from a terminal.
7912 .TP
7913 .B \-r
7914 Backslash does not act as an escape character.
7915 The backslash is considered to be part of the line.
7916 In particular, a backslash-newline pair may not be used as a line
7917 continuation.
7918 .TP
7919 .B \-s
7920 Silent mode.  If input is coming from a terminal, characters are
7921 not echoed.
7922 .TP
7923 .B \-t \fItimeout\fP
7924 Cause \fBread\fP to time out and return failure if a complete line of
7925 input is not read within \fItimeout\fP seconds.
7926 \fItimeout\fP may be a decimal number with a fractional portion following
7927 the decimal point.
7928 This option is only effective if \fBread\fP is reading input from a
7929 terminal, pipe, or other special file; it has no effect when reading
7930 from regular files.
7931 If \fItimeout\fP is 0, \fBread\fP returns success if input is available on
7932 the specified file descriptor, failure otherwise.
7933 The exit status is greater than 128 if the timeout is exceeded.
7934 .TP
7935 .B \-u \fIfd\fP
7936 Read input from file descriptor \fIfd\fP.
7937 .PD
7938 .PP
7939 If no
7940 .I names
7941 are supplied, the line read is assigned to the variable
7942 .SM
7943 .BR REPLY .
7944 The return code is zero, unless end-of-file is encountered, \fBread\fP
7945 times out (in which case the return code is greater than 128), or an
7946 invalid file descriptor is supplied as the argument to \fB\-u\fP.
7947 .RE
7948 .TP
7949 \fBreadonly\fP [\fB\-aApf\fP] [\fIname\fP[=\fIword\fP] ...]
7950 .PD
7951 The given
7952 \fInames\fP are marked readonly; the values of these
7953 .I names
7954 may not be changed by subsequent assignment.
7955 If the
7956 .B \-f
7957 option is supplied, the functions corresponding to the
7958 \fInames\fP are so
7959 marked.
7960 The
7961 .B \-a
7962 option restricts the variables to indexed arrays; the
7963 .B \-A
7964 option restricts the variables to associative arrays.
7965 If no
7966 .I name
7967 arguments are given, or if the
7968 .B \-p
7969 option is supplied, a list of all readonly names is printed.
7970 The
7971 .B \-p
7972 option causes output to be displayed in a format that
7973 may be reused as input.
7974 If a variable name is followed by =\fIword\fP, the value of
7975 the variable is set to \fIword\fP.
7976 The return status is 0 unless an invalid option is encountered,
7977 one of the
7978 .I names
7979 is not a valid shell variable name, or
7980 .B \-f
7981 is supplied with a
7982 .I name
7983 that is not a function.
7984 .TP
7985 \fBreturn\fP [\fIn\fP]
7986 Causes a function to exit with the return value specified by
7987 .IR n .
7988 If 
7989 .I n
7990 is omitted, the return status is that of the last command
7991 executed in the function body.  If used outside a function,
7992 but during execution of a script by the 
7993 .B .
7994 (\fBsource\fP) command, it causes the shell to stop executing
7995 that script and return either
7996 .I n
7997 or the exit status of the last command executed within the
7998 script as the exit status of the script.  If used outside a
7999 function and not during execution of a script by \fB.\fP\^,
8000 the return status is false.
8001 Any command associated with the \fBRETURN\fP trap is executed
8002 before execution resumes after the function or script.
8003 .TP
8004 \fBset\fP [\fB\-\-abefhkmnptuvxBCEHPT\fP] [\fB\-o\fP \fIoption\fP] [\fIarg\fP ...]
8005 .PD 0
8006 .TP
8007 \fBset\fP [\fB+abefhkmnptuvxBCEHPT\fP] [\fB+o\fP \fIoption\fP] [\fIarg\fP ...]
8008 .PD
8009 Without options, the name and value of each shell variable are displayed
8010 in a format that can be reused as input
8011 for setting or resetting the currently-set variables.
8012 Read-only variables cannot be reset.
8013 In \fIposix mode\fP, only shell variables are listed.
8014 The output is sorted according to the current locale.
8015 When options are specified, they set or unset shell attributes.
8016 Any arguments remaining after option processing are treated
8017 as values for the positional parameters and are assigned, in order, to 
8018 .BR $1 ,
8019 .BR $2 ,
8020 .B ...
8021 .BR $\fIn\fP .
8022 Options, if specified, have the following meanings:
8023 .RS
8024 .PD 0
8025 .TP 8
8026 .B \-a
8027 Automatically mark variables and functions which are modified or
8028 created for export to the environment of subsequent commands.
8029 .TP 8
8030 .B \-b
8031 Report the status of terminated background jobs
8032 immediately, rather than before the next primary prompt.  This is
8033 effective only when job control is enabled.
8034 .TP 8
8035 .B \-e
8036 Exit immediately if a \fIpipeline\fP (which may consist of a single
8037 \fIsimple command\fP),  a \fIsubshell\fP command enclosed in parentheses,
8038 or one of the commands executed as part of a command list enclosed
8039 by braces (see
8040 .SM
8041 .B SHELL GRAMMAR
8042 above) exits with a non-zero status.
8043 The shell does not exit if the
8044 command that fails is part of the command list immediately following a
8045 .B while
8046 or
8047 .B until
8048 keyword, 
8049 part of the test following the
8050 .B if
8051 or
8052 .B elif
8053 reserved words, part of any command executed in a
8054 .B &&
8055 or
8056 .B \(bv\(bv
8057 list except the command following the final \fB&&\fP or \fB\(bv\(bv\fP,
8058 any command in a pipeline but the last,
8059 or if the command's return value is
8060 being inverted with
8061 .BR ! .
8062 A trap on \fBERR\fP, if set, is executed before the shell exits.
8063 This option applies to the shell environment and each subshell environment
8064 separately (see
8065 .B "COMMAND EXECUTION ENVIRONMENT"
8066 above), and may cause
8067 subshells to exit before executing all the commands in the subshell.
8068 .TP 8
8069 .B \-f
8070 Disable pathname expansion.
8071 .TP 8 
8072 .B \-h
8073 Remember the location of commands as they are looked up for execution.
8074 This is enabled by default.
8075 .TP 8
8076 .B \-k
8077 All arguments in the form of assignment statements
8078 are placed in the environment for a command, not just
8079 those that precede the command name.
8080 .TP 8
8081 .B \-m
8082 Monitor mode.  Job control is enabled.  This option is on
8083 by default for interactive shells on systems that support
8084 it (see
8085 .SM
8086 .B JOB CONTROL
8087 above).  Background processes run in a separate process
8088 group and a line containing their exit status is printed
8089 upon their completion.
8090 .TP 8
8091 .B \-n
8092 Read commands but do not execute them.  This may be used to 
8093 check a shell script for syntax errors.  This is ignored by
8094 interactive shells.
8095 .TP 8
8096 .B \-o \fIoption\-name\fP
8097 The \fIoption\-name\fP can be one of the following:
8098 .RS
8099 .TP 8
8100 .B allexport
8101 Same as
8102 .BR \-a .
8103 .TP 8
8104 .B braceexpand
8105 Same as
8106 .BR \-B .
8107 .TP 8
8108 .B emacs
8109 Use an emacs-style command line editing interface.  This is enabled
8110 by default when the shell is interactive, unless the shell is started
8111 with the
8112 .B \-\-noediting
8113 option.
8114 This also affects the editing interface used for \fBread \-e\fP.
8115 .TP 8
8116 .B errtrace
8117 Same as
8118 .BR \-E .
8119 .TP 8
8120 .B functrace
8121 Same as
8122 .BR \-T .
8123 .TP 8
8124 .B errexit
8125 Same as
8126 .BR \-e .
8127 .TP 8
8128 .B hashall
8129 Same as
8130 .BR \-h .
8131 .TP 8
8132 .B histexpand
8133 Same as
8134 .BR \-H .
8135 .TP 8
8136 .B history
8137 Enable command history, as described above under
8138 .SM
8139 .BR HISTORY .
8140 This option is on by default in interactive shells.
8141 .TP 8
8142 .B ignoreeof
8143 The effect is as if the shell command
8144 .if t \f(CWIGNOREEOF=10\fP
8145 .if n ``IGNOREEOF=10''
8146 had been executed
8147 (see
8148 .B Shell Variables
8149 above).
8150 .TP 8
8151 .B keyword
8152 Same as
8153 .BR \-k .
8154 .TP 8
8155 .B monitor
8156 Same as
8157 .BR \-m .
8158 .TP 8
8159 .B noclobber
8160 Same as
8161 .BR \-C .
8162 .TP 8
8163 .B noexec
8164 Same as
8165 .BR \-n .
8166 .TP 8
8167 .B noglob
8168 Same as
8169 .BR \-f .
8170 .TP 8
8171 .B nolog
8172 Currently ignored.
8173 .TP 8
8174 .B notify
8175 Same as
8176 .BR \-b .
8177 .TP 8
8178 .B nounset
8179 Same as
8180 .BR \-u .
8181 .TP 8
8182 .B onecmd
8183 Same as
8184 .BR \-t .
8185 .TP 8
8186 .B physical
8187 Same as
8188 .BR \-P .
8189 .TP 8
8190 .B pipefail
8191 If set, the return value of a pipeline is the value of the last
8192 (rightmost) command to exit with a non-zero status, or zero if all
8193 commands in the pipeline exit successfully.
8194 This option is disabled by default.
8195 .TP 8
8196 .B posix
8197 Change the behavior of
8198 .B bash
8199 where the default operation differs
8200 from the POSIX standard to match the standard (\fIposix mode\fP).
8201 .TP 8
8202 .B privileged
8203 Same as
8204 .BR \-p .
8205 .TP 8
8206 .B verbose
8207 Same as
8208 .BR \-v .
8209 .TP 8
8210 .B vi
8211 Use a vi-style command line editing interface.
8212 This also affects the editing interface used for \fBread \-e\fP.
8213 .TP 8
8214 .B xtrace
8215 Same as
8216 .BR \-x .
8217 .sp .5
8218 .PP
8219 If
8220 .B \-o
8221 is supplied with no \fIoption\-name\fP, the values of the current options are
8222 printed.
8223 If
8224 .B +o
8225 is supplied with no \fIoption\-name\fP, a series of
8226 .B set
8227 commands to recreate the current option settings is displayed on
8228 the standard output.
8229 .RE
8230 .TP 8
8231 .B \-p
8232 Turn on
8233 .I privileged
8234 mode.  In this mode, the
8235 .SM
8236 .B $ENV
8237 and
8238 .SM
8239 .B $BASH_ENV
8240 files are not processed, shell functions are not inherited from the
8241 environment, and the
8242 .SM
8243 .BR SHELLOPTS ,
8244 .BR CDPATH ,
8245 and
8246 .B GLOBIGNORE
8247 variables, if they appear in the environment, are ignored.
8248 If the shell is started with the effective user (group) id not equal to the
8249 real user (group) id, and the \fB\-p\fP option is not supplied, these actions
8250 are taken and the effective user id is set to the real user id.
8251 If the \fB\-p\fP option is supplied at startup, the effective user id is
8252 not reset.
8253 Turning this option off causes the effective user
8254 and group ids to be set to the real user and group ids.
8255 .TP 8
8256 .B \-t
8257 Exit after reading and executing one command.
8258 .TP 8
8259 .B \-u
8260 Treat unset variables and parameters other than the special
8261 parameters "@" and "*" as an error when performing
8262 parameter expansion.  If expansion is attempted on an
8263 unset variable or parameter, the shell prints an error message, and,
8264 if not interactive, exits with a non-zero status.
8265 .TP 8
8266 .B \-v
8267 Print shell input lines as they are read.
8268 .TP 8
8269 .B \-x
8270 After expanding each \fIsimple command\fP,
8271 \fBfor\fP command, \fBcase\fP command, \fBselect\fP command, or
8272 arithmetic \fBfor\fP command, display the expanded value of
8273 .SM
8274 .BR PS4 ,
8275 followed by the command and its expanded arguments
8276 or associated word list.
8277 .TP 8
8278 .B \-B
8279 The shell performs brace expansion (see
8280 .B Brace Expansion
8281 above).  This is on by default.
8282 .TP 8
8283 .B \-C
8284 If set,
8285 .B bash
8286 does not overwrite an existing file with the
8287 .BR > ,
8288 .BR >& ,
8289 and
8290 .B <>
8291 redirection operators.  This may be overridden when 
8292 creating output files by using the redirection operator
8293 .B >|
8294 instead of
8295 .BR > .
8296 .TP 8
8297 .B \-E
8298 If set, any trap on \fBERR\fP is inherited by shell functions, command
8299 substitutions, and commands executed in a subshell environment.
8300 The \fBERR\fP trap is normally not inherited in such cases.
8301 .TP 8
8302 .B \-H
8303 Enable
8304 .B !
8305 style history substitution.  This option is on by
8306 default when the shell is interactive.
8307 .TP 8
8308 .B \-P
8309 If set, the shell does not follow symbolic links when executing
8310 commands such as
8311 .B cd
8312 that change the current working directory.  It uses the
8313 physical directory structure instead.  By default,
8314 .B bash
8315 follows the logical chain of directories when performing commands
8316 which change the current directory.
8317 .TP 8
8318 .B \-T
8319 If set, any traps on \fBDEBUG\fP and \fBRETURN\fP are inherited by shell
8320 functions, command substitutions, and commands executed in a
8321 subshell environment.
8322 The \fBDEBUG\fP and \fBRETURN\fP traps are normally not inherited
8323 in such cases.
8324 .TP 8
8325 .B \-\-
8326 If no arguments follow this option, then the positional parameters are
8327 unset.  Otherwise, the positional parameters are set to the
8328 \fIarg\fPs, even if some of them begin with a
8329 .BR \- .
8330 .TP 8
8331 .B \-
8332 Signal the end of options, cause all remaining \fIarg\fPs to be
8333 assigned to the positional parameters.  The
8334 .B \-x
8335 and
8336 .B \-v
8337 options are turned off.
8338 If there are no \fIarg\fPs,
8339 the positional parameters remain unchanged.
8340 .PD
8341 .PP
8342 The options are off by default unless otherwise noted.
8343 Using + rather than \- causes these options to be turned off.
8344 The options can also be specified as arguments to an invocation of
8345 the shell.
8346 The current set of options may be found in
8347 .BR $\- .
8348 The return status is always true unless an invalid option is encountered.
8349 .RE
8350 .TP
8351 \fBshift\fP [\fIn\fP]
8352 The positional parameters from \fIn\fP+1 ... are renamed to
8353 .B $1
8354 .B ....
8355 Parameters represented by the numbers \fB$#\fP
8356 down to \fB$#\fP\-\fIn\fP+1 are unset.
8357 .I n
8358 must be a non-negative number less than or equal to \fB$#\fP.
8359 If
8360 .I n
8361 is 0, no parameters are changed.
8362 If
8363 .I n 
8364 is not given, it is assumed to be 1.
8365 If
8366 .I n
8367 is greater than \fB$#\fP, the positional parameters are not changed.
8368 The return status is greater than zero if
8369 .I n
8370 is greater than
8371 .B $#
8372 or less than zero; otherwise 0.
8373 .TP
8374 \fBshopt\fP [\fB\-pqsu\fP] [\fB\-o\fP] [\fIoptname\fP ...]
8375 Toggle the values of variables controlling optional shell behavior.
8376 With no options, or with the
8377 .B \-p
8378 option, a list of all settable options is displayed, with
8379 an indication of whether or not each is set.
8380 The \fB\-p\fP option causes output to be displayed in a form that
8381 may be reused as input.
8382 Other options have the following meanings:
8383 .RS
8384 .PD 0
8385 .TP
8386 .B \-s
8387 Enable (set) each \fIoptname\fP.
8388 .TP
8389 .B \-u
8390 Disable (unset) each \fIoptname\fP.
8391 .TP
8392 .B \-q
8393 Suppresses normal output (quiet mode); the return status indicates
8394 whether the \fIoptname\fP is set or unset.
8395 If multiple \fIoptname\fP arguments are given with
8396 .BR \-q ,
8397 the return status is zero if all \fIoptnames\fP are enabled; non-zero
8398 otherwise.
8399 .TP
8400 .B \-o
8401 Restricts the values of \fIoptname\fP to be those defined for the
8402 .B \-o
8403 option to the
8404 .B set
8405 builtin.
8406 .PD
8407 .PP
8408 If either
8409 .B \-s
8410 or
8411 .B \-u
8412 is used with no \fIoptname\fP arguments, the display is limited to
8413 those options which are set or unset, respectively.
8414 Unless otherwise noted, the \fBshopt\fP options are disabled (unset)
8415 by default.
8416 .PP
8417 The return status when listing options is zero if all \fIoptnames\fP
8418 are enabled, non-zero otherwise.  When setting or unsetting options,
8419 the return status is zero unless an \fIoptname\fP is not a valid shell
8420 option.
8421 .PP
8422 The list of \fBshopt\fP options is:
8423 .if t .sp .5v
8424 .if n .sp 1v
8425 .PD 0
8426 .TP 8
8427 .B autocd
8428 If set, a command name that is the name of a directory is executed as if
8429 it were the argument to the \fBcd\fP command.
8430 This option is only used by interactive shells.
8431 .TP 8
8432 .B cdable_vars
8433 If set, an argument to the
8434 .B cd
8435 builtin command that
8436 is not a directory is assumed to be the name of a variable whose
8437 value is the directory to change to.
8438 .TP 8
8439 .B cdspell
8440 If set, minor errors in the spelling of a directory component in a
8441 .B cd
8442 command will be corrected.
8443 The errors checked for are transposed characters,
8444 a missing character, and one character too many.
8445 If a correction is found, the corrected file name is printed,
8446 and the command proceeds.
8447 This option is only used by interactive shells.
8448 .TP 8
8449 .B checkhash
8450 If set, \fBbash\fP checks that a command found in the hash
8451 table exists before trying to execute it.  If a hashed command no
8452 longer exists, a normal path search is performed.
8453 .TP 8
8454 .B checkjobs
8455 If set, \fBbash\fP lists the status of any stopped and running jobs before
8456 exiting an interactive shell.  If any jobs are running, this causes
8457 the exit to be deferred until a second exit is attempted without an
8458 intervening command (see \fBJOB CONTROL\fP above).  The shell always
8459 postpones exiting if any jobs are stopped.
8460 .TP 8
8461 .B checkwinsize
8462 If set, \fBbash\fP checks the window size after each command
8463 and, if necessary, updates the values of
8464 .SM
8465 .B LINES
8466 and
8467 .SM
8468 .BR COLUMNS .
8469 .TP 8
8470 .B cmdhist
8471 If set,
8472 .B bash
8473 attempts to save all lines of a multiple-line
8474 command in the same history entry.  This allows
8475 easy re-editing of multi-line commands.
8476 .TP 8
8477 .B compat31
8478 If set,
8479 .B bash
8480 changes its behavior to that of version 3.1 with respect to quoted
8481 arguments to the conditional command's =~ operator.
8482 .TP 8
8483 .B dirspell
8484 If set,
8485 .B bash
8486 attempts spelling correction on directory names during word completion
8487 if the directory name initially supplied does not exist.
8488 .TP 8
8489 .B dotglob
8490 If set, 
8491 .B bash
8492 includes filenames beginning with a `.' in the results of pathname
8493 expansion.
8494 .TP 8
8495 .B execfail
8496 If set, a non-interactive shell will not exit if
8497 it cannot execute the file specified as an argument to the
8498 .B exec
8499 builtin command.  An interactive shell does not exit if
8500 .B exec
8501 fails.
8502 .TP 8
8503 .B expand_aliases
8504 If set, aliases are expanded as described above under
8505 .SM
8506 .BR ALIASES .
8507 This option is enabled by default for interactive shells.
8508 .TP 8
8509 .B extdebug
8510 If set, behavior intended for use by debuggers is enabled:
8511 .RS
8512 .TP
8513 .B 1.
8514 The \fB\-F\fP option to the \fBdeclare\fP builtin displays the source
8515 file name and line number corresponding to each function name supplied
8516 as an argument.
8517 .TP
8518 .B 2.
8519 If the command run by the \fBDEBUG\fP trap returns a non-zero value, the
8520 next command is skipped and not executed.
8521 .TP
8522 .B 3.
8523 If the command run by the \fBDEBUG\fP trap returns a value of 2, and the
8524 shell is executing in a subroutine (a shell function or a shell script
8525 executed by the \fB.\fP or \fBsource\fP builtins), a call to
8526 \fBreturn\fP is simulated.
8527 .TP
8528 .B 4.
8529 \fBBASH_ARGC\fP and \fBBASH_ARGV\fP are updated as described in their
8530 descriptions above.
8531 .TP
8532 .B 5.
8533 Function tracing is enabled:  command substitution, shell functions, and
8534 subshells invoked with \fB(\fP \fIcommand\fP \fB)\fP inherit the
8535 \fBDEBUG\fP and \fBRETURN\fP traps.
8536 .TP
8537 .B 6.
8538 Error tracing is enabled:  command substitution, shell functions, and
8539 subshells invoked with \fB(\fP \fIcommand\fP \fB)\fP inherit the
8540 \fBERROR\fP trap.
8541 .RE
8542 .TP 8
8543 .B extglob
8544 If set, the extended pattern matching features described above under
8545 \fBPathname Expansion\fP are enabled.
8546 .TP 8
8547 .B extquote
8548 If set, \fB$\fP\(aq\fIstring\fP\(aq and \fB$\fP"\fIstring\fP" quoting is
8549 performed within \fB${\fP\fIparameter\fP\fB}\fP expansions
8550 enclosed in double quotes.  This option is enabled by default.
8551 .TP 8
8552 .B failglob
8553 If set, patterns which fail to match filenames during pathname expansion
8554 result in an expansion error.
8555 .TP 8
8556 .B force_fignore
8557 If set, the suffixes specified by the \fBFIGNORE\fP shell variable
8558 cause words to be ignored when performing word completion even if
8559 the ignored words are the only possible completions.
8560 See
8561 .SM
8562 \fBSHELL VARIABLES\fP
8563 above for a description of \fBFIGNORE\fP.
8564 This option is enabled by default.
8565 .TP 8
8566 .B globstar
8567 If set, the pattern \fB**\fP used in a filename expansion context will
8568 match a files and zero or more directories and subdirectories.
8569 If the pattern is followed by a \fB/\fP, only directories and
8570 subdirectories match.
8571 .TP 8
8572 .B gnu_errfmt
8573 If set, shell error messages are written in the standard GNU error
8574 message format.
8575 .TP 8
8576 .B histappend
8577 If set, the history list is appended to the file named by the value
8578 of the
8579 .B HISTFILE
8580 variable when the shell exits, rather than overwriting the file.
8581 .TP 8
8582 .B histreedit
8583 If set, and
8584 .B readline
8585 is being used, a user is given the opportunity to re-edit a
8586 failed history substitution.
8587 .TP 8
8588 .B histverify
8589 If set, and 
8590 .B readline
8591 is being used, the results of history substitution are not immediately
8592 passed to the shell parser.  Instead, the resulting line is loaded into
8593 the \fBreadline\fP editing buffer, allowing further modification.
8594 .TP 8
8595 .B hostcomplete
8596 If set, and
8597 .B readline
8598 is being used, \fBbash\fP will attempt to perform hostname completion when a
8599 word containing a \fB@\fP is being completed (see
8600 .B Completing
8601 under
8602 .SM
8603 .B READLINE
8604 above).
8605 This is enabled by default.
8606 .TP 8
8607 .B huponexit
8608 If set, \fBbash\fP will send
8609 .SM
8610 .B SIGHUP
8611 to all jobs when an interactive login shell exits.
8612 .TP 8
8613 .B interactive_comments
8614 If set, allow a word beginning with
8615 .B #
8616 to cause that word and all remaining characters on that
8617 line to be ignored in an interactive shell (see
8618 .SM
8619 .B COMMENTS
8620 above).  This option is enabled by default.
8621 .TP 8
8622 .B lithist
8623 If set, and the
8624 .B cmdhist
8625 option is enabled, multi-line commands are saved to the history with
8626 embedded newlines rather than using semicolon separators where possible.
8627 .TP 8
8628 .B login_shell
8629 The shell sets this option if it is started as a login shell (see
8630 .SM
8631 .B "INVOCATION"
8632 above).
8633 The value may not be changed.
8634 .TP 8
8635 .B mailwarn
8636 If set, and a file that \fBbash\fP is checking for mail has been  
8637 accessed since the last time it was checked, the message ``The mail in
8638 \fImailfile\fP has been read'' is displayed.
8639 .TP 8
8640 .B no_empty_cmd_completion
8641 If set, and
8642 .B readline
8643 is being used,
8644 .B bash
8645 will not attempt to search the \fBPATH\fP for possible completions when
8646 completion is attempted on an empty line.
8647 .TP 8
8648 .B nocaseglob
8649 If set,
8650 .B bash
8651 matches filenames in a case\-insensitive fashion when performing pathname
8652 expansion (see
8653 .B Pathname Expansion
8654 above).
8655 .TP 8
8656 .B nocasematch
8657 If set,
8658 .B bash
8659 matches patterns in a case\-insensitive fashion when performing matching
8660 while executing \fBcase\fP or \fB[[\fP conditional commands.
8661 .TP 8
8662 .B nullglob
8663 If set,
8664 .B bash
8665 allows patterns which match no
8666 files (see
8667 .B Pathname Expansion
8668 above)
8669 to expand to a null string, rather than themselves.
8670 .TP 8
8671 .B progcomp
8672 If set, the programmable completion facilities (see
8673 \fBProgrammable Completion\fP above) are enabled.
8674 This option is enabled by default.
8675 .TP 8
8676 .B promptvars
8677 If set, prompt strings undergo
8678 parameter expansion, command substitution, arithmetic
8679 expansion, and quote removal after being expanded as described in
8680 .SM
8681 .B PROMPTING
8682 above.  This option is enabled by default.
8683 .TP 8
8684 .B restricted_shell
8685 The shell sets this option if it is started in restricted mode (see
8686 .SM
8687 .B "RESTRICTED SHELL"
8688 below).
8689 The value may not be changed.
8690 This is not reset when the startup files are executed, allowing
8691 the startup files to discover whether or not a shell is restricted.
8692 .TP 8
8693 .B shift_verbose
8694 If set, the
8695 .B shift
8696 builtin prints an error message when the shift count exceeds the
8697 number of positional parameters.
8698 .TP 8
8699 .B sourcepath
8700 If set, the
8701 \fBsource\fP (\fB.\fP) builtin uses the value of
8702 .SM
8703 .B PATH
8704 to find the directory containing the file supplied as an argument.
8705 This option is enabled by default.
8706 .TP 8
8707 .B xpg_echo
8708 If set, the \fBecho\fP builtin expands backslash-escape sequences
8709 by default.
8710 .RE
8711 .TP
8712 \fBsuspend\fP [\fB\-f\fP]
8713 Suspend the execution of this shell until it receives a
8714 .SM
8715 .B SIGCONT
8716 signal.  A login shell cannot be suspended; the
8717 .B \-f
8718 option can be used to override this and force the suspension.
8719 The return status is 0 unless the shell is a login shell and
8720 .B \-f
8721 is not supplied, or if job control is not enabled.
8722 .TP
8723 \fBtest\fP \fIexpr\fP
8724 .PD 0
8725 .TP
8726 \fB[\fP \fIexpr\fP \fB]\fP
8727 Return a status of 0 or 1 depending on
8728 the evaluation of the conditional expression
8729 .IR expr .
8730 Each operator and operand must be a separate argument.
8731 Expressions are composed of the primaries described above under
8732 .SM
8733 .BR "CONDITIONAL EXPRESSIONS" .
8734 \fBtest\fP does not accept any options, nor does it accept and ignore
8735 an argument of \fB\-\-\fP as signifying the end of options.
8736 .if t .sp 0.5
8737 .if n .sp 1
8738 Expressions may be combined using the following operators, listed
8739 in decreasing order of precedence.
8740 The evaluation depends on the number of arguments; see below.
8741 .RS
8742 .PD 0
8743 .TP
8744 .B ! \fIexpr\fP
8745 True if
8746 .I expr
8747 is false.
8748 .TP
8749 .B ( \fIexpr\fP )
8750 Returns the value of \fIexpr\fP.
8751 This may be used to override the normal precedence of operators.
8752 .TP
8753 \fIexpr1\fP \-\fBa\fP \fIexpr2\fP
8754 True if both
8755 .I expr1
8756 and
8757 .I expr2
8758 are true.
8759 .TP
8760 \fIexpr1\fP \-\fBo\fP \fIexpr2\fP
8761 True if either
8762 .I expr1
8763 or
8764 .I expr2
8765 is true.
8766 .PD
8767 .PP
8768 \fBtest\fP and \fB[\fP evaluate conditional
8769 expressions using a set of rules based on the number of arguments.
8770 .if t .sp 0.5
8771 .if n .sp 1
8772 .PD 0
8773 .TP
8774 0 arguments
8775 The expression is false.
8776 .TP
8777 1 argument
8778 The expression is true if and only if the argument is not null.
8779 .TP
8780 2 arguments
8781 If the first argument is \fB!\fP, the expression is true if and
8782 only if the second argument is null.
8783 If the first argument is one of the unary conditional operators listed above
8784 under
8785 .SM
8786 .BR "CONDITIONAL EXPRESSIONS" ,
8787 the expression is true if the unary test is true.
8788 If the first argument is not a valid unary conditional operator, the expression
8789 is false.
8790 .TP
8791 3 arguments
8792 If the second argument is one of the binary conditional operators listed above
8793 under
8794 .SM
8795 .BR "CONDITIONAL EXPRESSIONS" ,
8796 the result of the expression is the result of the binary test using
8797 the first and third arguments as operands.
8798 The \fB\-a\fP and \fB\-o\fP operators are considered binary operators
8799 when there are three arguments.  
8800 If the first argument is \fB!\fP, the value is the negation of
8801 the two-argument test using the second and third arguments.
8802 If the first argument is exactly \fB(\fP and the third argument is
8803 exactly \fB)\fP, the result is the one-argument test of the second
8804 argument.
8805 Otherwise, the expression is false.
8806 .TP
8807 4 arguments
8808 If the first argument is \fB!\fP, the result is the negation of
8809 the three-argument expression composed of the remaining arguments.
8810 Otherwise, the expression is parsed and evaluated according to 
8811 precedence using the rules listed above.
8812 .TP
8813 5 or more arguments
8814 The expression is parsed and evaluated according to precedence
8815 using the rules listed above.
8816 .RE
8817 .PD
8818 .TP
8819 .B times
8820 Print the accumulated user and system times for the shell and
8821 for processes run from the shell.  The return status is 0.
8822 .TP
8823 \fBtrap\fP [\fB\-lp\fP] [[\fIarg\fP] \fIsigspec\fP ...]
8824 The command
8825 .I arg
8826 is to be read and executed when the shell receives
8827 signal(s)
8828 .IR sigspec .
8829 If
8830 .I arg
8831 is absent (and there is a single \fIsigspec\fP) or
8832 .BR \- ,
8833 each specified signal is
8834 reset to its original disposition (the value it had
8835 upon entrance to the shell).
8836 If 
8837 .I arg
8838 is the null string the signal specified by each
8839 .I sigspec
8840 is ignored by the shell and by the commands it invokes.
8841 If
8842 .I arg
8843 is not present and
8844 .B \-p
8845 has been supplied, then the trap commands associated with each
8846 .I sigspec
8847 are displayed.
8848 If no arguments are supplied or if only
8849 .B \-p
8850 is given,
8851 .B trap
8852 prints the list of commands associated with each signal.
8853 The
8854 .B \-l
8855 option causes the shell to print a list of signal names and
8856 their corresponding numbers.
8857 Each
8858 .I sigspec
8859 is either
8860 a signal name defined in <\fIsignal.h\fP>, or a signal number.
8861 Signal names are case insensitive and the SIG prefix is optional.
8862 If a
8863 .I sigspec
8864 is
8865 .SM
8866 .B EXIT
8867 (0) the command
8868 .I arg
8869 is executed on exit from the shell.
8870 If a
8871 .I sigspec
8872 is
8873 .SM
8874 .BR DEBUG ,
8875 the command
8876 .I arg
8877 is executed before every \fIsimple command\fP, \fIfor\fP command,
8878 \fIcase\fP command, \fIselect\fP command, every arithmetic \fIfor\fP
8879 command, and before the first command executes in a shell function (see
8880 .SM
8881 .B SHELL GRAMMAR
8882 above).
8883 Refer to the description of the \fBextdebug\fP option to the
8884 \fBshopt\fP builtin for details of its effect on the \fBDEBUG\fP trap.
8885 If a
8886 .I sigspec
8887 is
8888 .SM
8889 .BR ERR ,
8890 the command
8891 .I arg
8892 is executed whenever a simple command has a non\-zero exit status,
8893 subject to the following conditions.
8894 The
8895 .SM
8896 .B ERR
8897 trap is not executed if the failed
8898 command is part of the command list immediately following a
8899 .B while
8900 or
8901 .B until
8902 keyword, 
8903 part of the test in an
8904 .I if
8905 statement, part of a command executed in a
8906 .B &&
8907 or
8908 .B \(bv\(bv
8909 list, or if the command's return value is
8910 being inverted via
8911 .BR ! .
8912 These are the same conditions obeyed by the \fBerrexit\fP option.
8913 If a
8914 .I sigspec
8915 is
8916 .SM
8917 .BR RETURN ,
8918 the command
8919 .I arg
8920 is executed each time a shell function or a script executed with the
8921 \fB.\fP or \fBsource\fP builtins finishes executing.
8922 Signals ignored upon entry to the shell cannot be trapped or reset.
8923 Trapped signals that are not being ignored are reset to their original
8924 values in a child process when it is created.
8925 The return status is false if any
8926 .I sigspec
8927 is invalid; otherwise
8928 .B trap
8929 returns true.
8930 .TP
8931 \fBtype\fP [\fB\-aftpP\fP] \fIname\fP [\fIname\fP ...]
8932 With no options, 
8933 indicate how each
8934 .I name
8935 would be interpreted if used as a command name.
8936 If the
8937 .B \-t
8938 option is used,
8939 .B type
8940 prints a string which is one of
8941 .IR alias ,
8942 .IR keyword ,
8943 .IR function ,
8944 .IR builtin ,
8945 or
8946 .I file 
8947 if
8948 .I name
8949 is an alias, shell reserved word, function, builtin, or disk file,
8950 respectively.
8951 If the
8952 .I name
8953 is not found, then nothing is printed, and an exit status of false
8954 is returned.
8955 If the
8956 .B \-p
8957 option is used,
8958 .B type
8959 either returns the name of the disk file
8960 that would be executed if
8961 .I name
8962 were specified as a command name,
8963 or nothing if
8964 .if t \f(CWtype -t name\fP
8965 .if n ``type -t name''
8966 would not return
8967 .IR file .
8968 The
8969 .B \-P
8970 option forces a
8971 .SM
8972 .B PATH
8973 search for each \fIname\fP, even if
8974 .if t \f(CWtype -t name\fP
8975 .if n ``type -t name''
8976 would not return
8977 .IR file .
8978 If a command is hashed,
8979 .B \-p
8980 and
8981 .B \-P
8982 print the hashed value, not necessarily the file that appears
8983 first in 
8984 .SM
8985 .BR PATH .
8986 If the
8987 .B \-a
8988 option is used, 
8989 .B type
8990 prints all of the places that contain
8991 an executable named 
8992 .IR name .
8993 This includes aliases and functions,
8994 if and only if the 
8995 .B \-p
8996 option is not also used.
8997 The table of hashed commands is not consulted
8998 when using
8999 .BR \-a .
9000 The
9001 .B \-f
9002 option suppresses shell function lookup, as with the \fBcommand\fP builtin.
9003 .B type
9004 returns true if all of the arguments are found, false if
9005 any are not found.
9006 .TP
9007 \fBulimit\fP [\fB\-HSTabcdefilmnpqrstuvx\fP [\fIlimit\fP]]
9008 Provides control over the resources available to the shell and to
9009 processes started by it, on systems that allow such control.
9010 The \fB\-H\fP and \fB\-S\fP options specify that the hard or soft limit is
9011 set for the given resource.
9012 A hard limit cannot be increased by a non-root user once it is set;
9013 a soft limit may be increased up to the value of the hard limit.
9014 If neither \fB\-H\fP nor \fB\-S\fP is specified, both the soft and hard
9015 limits are set.
9016 The value of
9017 .I limit
9018 can be a number in the unit specified for the resource
9019 or one of the special values
9020 .BR hard ,
9021 .BR soft ,
9022 or
9023 .BR unlimited ,
9024 which stand for the current hard limit, the current soft limit, and
9025 no limit, respectively.
9026 If
9027 .I limit
9028 is omitted, the current value of the soft limit of the resource is
9029 printed, unless the \fB\-H\fP option is given.  When more than one
9030 resource is specified, the limit name and unit are printed before the value.
9031 Other options are interpreted as follows:
9032 .RS
9033 .PD 0
9034 .TP
9035 .B \-a
9036 All current limits are reported
9037 .TP
9038 .B \-b
9039 The maximum socket buffer size
9040 .TP
9041 .B \-c
9042 The maximum size of core files created
9043 .TP
9044 .B \-d
9045 The maximum size of a process's data segment
9046 .TP
9047 .B \-e
9048 The maximum scheduling priority ("nice")
9049 .TP
9050 .B \-f
9051 The maximum size of files written by the shell and its children
9052 .TP
9053 .B \-i
9054 The maximum number of pending signals
9055 .TP
9056 .B \-l
9057 The maximum size that may be locked into memory
9058 .TP
9059 .B \-m
9060 The maximum resident set size (many systems do not honor this limit)
9061 .TP
9062 .B \-n
9063 The maximum number of open file descriptors (most systems do not
9064 allow this value to be set)
9065 .TP
9066 .B \-p
9067 The pipe size in 512-byte blocks (this may not be set)
9068 .TP
9069 .B \-q
9070 The maximum number of bytes in POSIX message queues
9071 .TP
9072 .B \-r
9073 The maximum real-time scheduling priority
9074 .TP
9075 .B \-s
9076 The maximum stack size
9077 .TP
9078 .B \-t
9079 The maximum amount of cpu time in seconds
9080 .TP
9081 .B \-u
9082 The maximum number of processes available to a single user
9083 .TP
9084 .B \-v
9085 The maximum amount of virtual memory available to the shell
9086 .TP
9087 .B \-x
9088 The maximum number of file locks
9089 .TP
9090 .B \-T
9091 The maximum number of threads
9092 .PD
9093 .PP
9094 If
9095 .I limit
9096 is given, it is the new value of the specified resource (the
9097 .B \-a
9098 option is display only).
9099 If no option is given, then
9100 .B \-f
9101 is assumed.  Values are in 1024-byte increments, except for
9102 .BR \-t ,
9103 which is in seconds,
9104 .BR \-p ,
9105 which is in units of 512-byte blocks,
9106 and
9107 .BR \-T ,
9108 .BR \-b ,
9109 .BR \-n ,
9110 and
9111 .BR \-u ,
9112 which are unscaled values.
9113 The return status is 0 unless an invalid option or argument is supplied,
9114 or an error occurs while setting a new limit.
9115 .RE
9116 .TP
9117 \fBumask\fP [\fB\-p\fP] [\fB\-S\fP] [\fImode\fP]
9118 The user file-creation mask is set to 
9119 .IR mode .
9120 If
9121 .I mode
9122 begins with a digit, it
9123 is interpreted as an octal number; otherwise
9124 it is interpreted as a symbolic mode mask similar
9125 to that accepted by
9126 .IR chmod (1).
9127 If
9128 .I mode
9129 is omitted, the current value of the mask is printed.
9130 The
9131 .B \-S
9132 option causes the mask to be printed in symbolic form; the
9133 default output is an octal number.
9134 If the
9135 .B \-p
9136 option is supplied, and
9137 .I mode
9138 is omitted, the output is in a form that may be reused as input.
9139 The return status is 0 if the mode was successfully changed or if
9140 no \fImode\fP argument was supplied, and false otherwise.
9141 .TP
9142 \fBunalias\fP [\-\fBa\fP] [\fIname\fP ...]
9143 Remove each \fIname\fP from the list of defined aliases.  If
9144 .B \-a
9145 is supplied, all alias definitions are removed.  The return
9146 value is true unless a supplied
9147 .I name
9148 is not a defined alias.
9149 .TP
9150 \fBunset\fP [\-\fBfv\fP] [\fIname\fP ...]
9151 For each
9152 .IR name ,
9153 remove the corresponding variable or function.
9154 If no options are supplied, or the
9155 .B \-v
9156 option is given, each
9157 .I name
9158 refers to a shell variable.
9159 Read-only variables may not be unset.
9160 If
9161 .B \-f
9162 is specified, each
9163 .I name
9164 refers to a shell function, and the function definition
9165 is removed.
9166 Each unset variable or function is removed from the environment
9167 passed to subsequent commands.
9168 If any of
9169 .SM
9170 .BR RANDOM ,
9171 .SM
9172 .BR SECONDS ,
9173 .SM
9174 .BR LINENO ,
9175 .SM
9176 .BR HISTCMD ,
9177 .SM
9178 .BR FUNCNAME ,
9179 .SM
9180 .BR GROUPS ,
9181 or
9182 .SM
9183 .B DIRSTACK
9184 are unset, they lose their special properties, even if they are
9185 subsequently reset.  The exit status is true unless a
9186 .I name
9187 is readonly.
9188 .TP
9189 \fBwait\fP [\fIn ...\fP]
9190 Wait for each specified process and return its termination status.
9191 Each
9192 .I n
9193 may be a process
9194 ID or a job specification; if a job spec is given, all processes
9195 in that job's pipeline are waited for.  If
9196 .I n
9197 is not given, all currently active child processes
9198 are waited for, and the return status is zero.  If
9199 .I n
9200 specifies a non-existent process or job, the return status is
9201 127.  Otherwise, the return status is the exit status of the last
9202 process or job waited for.
9203 .\" bash_builtins
9204 .if \n(zZ=1 .ig zZ
9205 .SH "RESTRICTED SHELL"
9206 .\" rbash.1
9207 .zY
9208 .PP
9209 If
9210 .B bash
9211 is started with the name
9212 .BR rbash ,
9213 or the
9214 .B \-r
9215 option is supplied at invocation,
9216 the shell becomes restricted.
9217 A restricted shell is used to
9218 set up an environment more controlled than the standard shell.
9219 It behaves identically to
9220 .B bash
9221 with the exception that the following are disallowed or not performed:
9222 .IP \(bu
9223 changing directories with \fBcd\fP
9224 .IP \(bu
9225 setting or unsetting the values of
9226 .BR SHELL ,
9227 .BR PATH ,
9228 .BR ENV ,
9229 or
9230 .B BASH_ENV
9231 .IP \(bu
9232 specifying command names containing
9233 .B /
9234 .IP \(bu
9235 specifying a file name containing a
9236 .B /
9237 as an argument to the
9238 .B .
9239 builtin command
9240 .IP \(bu
9241 Specifying a filename containing a slash as an argument to the
9242 .B \-p
9243 option to the
9244 .B hash
9245 builtin command
9246 .IP \(bu
9247 importing function definitions from the shell environment at startup
9248 .IP \(bu
9249 parsing the value of \fBSHELLOPTS\fP from the shell environment at startup
9250 .IP \(bu
9251 redirecting output using the >, >|, <>, >&, &>, and >> redirection operators
9252 .IP \(bu
9253 using the
9254 .B exec
9255 builtin command to replace the shell with another command
9256 .IP \(bu
9257 adding or deleting builtin commands with the
9258 .B \-f
9259 and
9260 .B \-d
9261 options to the
9262 .B enable
9263 builtin command
9264 .IP \(bu
9265 Using the \fBenable\fP builtin command to enable disabled shell builtins
9266 .IP \(bu
9267 specifying the
9268 .B \-p
9269 option to the
9270 .B command
9271 builtin command
9272 .IP \(bu
9273 turning off restricted mode with
9274 \fBset +r\fP or \fBset +o restricted\fP.
9275 .PP
9276 These restrictions are enforced after any startup files are read.
9277 .PP
9278 .ie \n(zY=1 When a command that is found to be a shell script is executed,
9279 .el \{ When a command that is found to be a shell script is executed
9280 (see
9281 .SM
9282 .B "COMMAND EXECUTION"
9283 above),
9284 \}
9285 .B rbash
9286 turns off any restrictions in the shell spawned to execute the
9287 script.
9288 .\" end of rbash.1
9289 .if \n(zY=1 .ig zY
9290 .SH "SEE ALSO"
9291 .PD 0
9292 .TP
9293 \fIBash Reference Manual\fP, Brian Fox and Chet Ramey
9294 .TP
9295 \fIThe Gnu Readline Library\fP, Brian Fox and Chet Ramey
9296 .TP
9297 \fIThe Gnu History Library\fP, Brian Fox and Chet Ramey
9298 .TP
9299 \fIPortable Operating System Interface (POSIX) Part 2: Shell and Utilities\fP, IEEE
9300 .TP
9301 \fIsh\fP(1), \fIksh\fP(1), \fIcsh\fP(1)
9302 .TP
9303 \fIemacs\fP(1), \fIvi\fP(1)
9304 .TP
9305 \fIreadline\fP(3)
9306 .PD
9307 .SH FILES
9308 .PD 0
9309 .TP
9310 .FN /bin/bash
9311 The \fBbash\fP executable
9312 .TP
9313 .FN /etc/profile
9314 The systemwide initialization file, executed for login shells
9315 .TP
9316 .FN ~/.bash_profile
9317 The personal initialization file, executed for login shells
9318 .TP
9319 .FN ~/.bashrc
9320 The individual per-interactive-shell startup file
9321 .TP
9322 .FN ~/.bash_logout
9323 The individual login shell cleanup file, executed when a login shell exits
9324 .TP
9325 .FN ~/.inputrc
9326 Individual \fIreadline\fP initialization file
9327 .PD
9328 .SH AUTHORS
9329 Brian Fox, Free Software Foundation
9330 .br
9331 bfox@gnu.org
9332 .PP
9333 Chet Ramey, Case Western Reserve University
9334 .br
9335 chet.ramey@case.edu
9336 .SH BUG REPORTS
9337 If you find a bug in
9338 .B bash,
9339 you should report it.  But first, you should
9340 make sure that it really is a bug, and that it appears in the latest
9341 version of
9342 .BR bash .
9343 The latest version is always available from
9344 \fIftp://ftp.gnu.org/pub/bash/\fP.
9345 .PP
9346 Once you have determined that a bug actually exists, use the
9347 .I bashbug
9348 command to submit a bug report.
9349 If you have a fix, you are encouraged to mail that as well!
9350 Suggestions and `philosophical' bug reports may be mailed
9351 to \fIbug-bash@gnu.org\fP or posted to the Usenet
9352 newsgroup
9353 .BR gnu.bash.bug .
9354 .PP
9355 ALL bug reports should include:
9356 .PP
9357 .PD 0
9358 .TP 20
9359 The version number of \fBbash\fR
9360 .TP
9361 The hardware and operating system
9362 .TP
9363 The compiler used to compile
9364 .TP
9365 A description of the bug behaviour
9366 .TP
9367 A short script or `recipe' which exercises the bug
9368 .PD
9369 .PP
9370 .I bashbug
9371 inserts the first three items automatically into the template
9372 it provides for filing a bug report.
9373 .PP
9374 Comments and bug reports concerning
9375 this manual page should be directed to
9376 .IR chet@po.cwru.edu .
9377 .SH BUGS
9378 .PP
9379 It's too big and too slow.
9380 .PP
9381 There are some subtle differences between 
9382 .B bash
9383 and traditional versions of
9384 .BR sh ,
9385 mostly because of the
9386 .SM
9387 .B POSIX
9388 specification.
9389 .PP
9390 Aliases are confusing in some uses.
9391 .PP
9392 Shell builtin commands and functions are not stoppable/restartable.
9393 .PP
9394 Compound commands and command sequences of the form `a ; b ; c'
9395 are not handled gracefully when process suspension is attempted.
9396 When a process is stopped, the shell immediately executes the next
9397 command in the sequence.
9398 It suffices to place the sequence of commands between
9399 parentheses to force it into a subshell, which may be stopped as
9400 a unit.
9401 .PP
9402 Array variables may not (yet) be exported.
9403 .PP
9404 There may be only one active coprocess at a time.
9405 .zZ
9406 .zY