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