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