Imported from ../bash-2.0.tar.gz.
[platform/upstream/bash.git] / doc / bash.1
1 .\"
2 .\" MAN PAGE COMMENTS to
3 .\"
4 .\"     Chet Ramey
5 .\"     Information Network Services
6 .\"     Case Western Reserve University
7 .\"     chet@ins.CWRU.Edu
8 .\"
9 .\"     Last Change: Mon Nov 25 15:36:20 EST 1996
10 .\"
11 .\" bash_builtins, strip all but Built-Ins section
12 .if \n(zZ=1 .ig zZ
13 .TH BASH 1 "1996 Nov 25" GNU
14 .\"
15 .\" There's some problem with having a `@'
16 .\" in a tagged paragraph with the BSD man macros.
17 .\" It has to do with `@' appearing in the }1 macro.
18 .\" This is a problem on 4.3 BSD and Ultrix, but Sun
19 .\" appears to have fixed it.
20 .\" If you're seeing the characters
21 .\" `@u-3p' appearing before the lines reading
22 .\" `possible-hostname-completions
23 .\" and `complete-hostname' down in READLINE,
24 .\" then uncomment this redefinition.
25 .\"
26 .de }1
27 .ds ]X \&\\*(]B\\
28 .nr )E 0
29 .if !"\\$1"" .nr )I \\$1n
30 .}f
31 .ll \\n(LLu
32 .in \\n()Ru+\\n(INu+\\n()Iu
33 .ti \\n(INu
34 .ie !\\n()Iu+\\n()Ru-\w\a\\*(]X\au-3p \{\\*(]X
35 .br\}
36 .el \\*(]X\h\a|\\n()Iu+\\n()Ru\a\c
37 .}f
38 ..
39 .\"
40 .\" File Name macro.  This used to be `.PN', for Path Name,
41 .\" but Sun doesn't seem to like that very much.
42 .\"
43 .de FN
44 \fI\|\\$1\|\fP
45 ..
46 .SH NAME
47 bash \- GNU Bourne-Again SHell
48 .SH SYNOPSIS
49 .B bash
50 [options]
51 [file]
52 .SH COPYRIGHT
53 .if n Bash is Copyright (C) 1989, 1991, 1993, 1995, 1996 by the Free Software Foundation, Inc.
54 .if t Bash is Copyright \(co 1989, 1991, 1993, 1995, 1996 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 ultimately intended to be a conformant implementation of the IEEE
65 POSIX Shell and Tools specification (IEEE Working Group 1003\.2).
66 .SH OPTIONS
67 In addition to the single-character shell options documented in the
68 description of the \fBset\fR builtin command, \fBbash\fR
69 interprets the following flags when it is invoked:
70 .PP
71 .PD 0
72 .TP 10
73 .BI \-c "\| string\^"
74 If the
75 .B \-c
76 flag is present, then commands are read from
77 .IR string .
78 If there are arguments after the
79 .IR string ,
80 they are assigned to the positional parameters, starting with
81 .BR $0 .
82 .TP
83 .B \-r
84 If the
85 .B \-r
86 flag is present, the shell becomes
87 .I restricted
88 (see
89 .SM
90 .B "RESTRICTED SHELL"
91 below).
92 .TP
93 .B \-i
94 If the
95 .B \-i
96 flag is present, the shell is
97 .IR interactive .
98 .TP
99 .B \-s
100 If the
101 .B \-s
102 flag is present, or if no arguments remain after option
103 processing, then commands are read from the standard input.
104 This option allows the positional parameters to be set
105 when invoking an interactive shell.
106 .TP
107 .B \-D
108 A list of all double-quoted strings preceded by \fB$\fP
109 is printed on the standard ouput.
110 These are the strings that
111 are subject to language translation when the current locale
112 is not C or POSIX.
113 This implies the \fB\-n\fP option; no commands will be executed.
114 .TP
115 .B \-\-
116 A
117 .B \-\-
118 signals the end of options and disables further option processing.
119 Any arguments after the
120 .B \-\-
121 are treated as filenames and arguments.  An argument of
122 .B \-
123 is equivalent to \fB\-\-\fP.
124 .PD
125 .PP
126 .B Bash
127 also interprets a number of multi-character options.
128 These options must appear on the command line before the
129 single-character options in order for them to be recognized.
130 .PP
131 .PD 0
132 .TP
133 .B \-\-dump\-strings
134 Equivalent to \fB\-D\fP.
135 .TP
136 .B \-\-help
137 Display a usage message on standard output and exit successfully.
138 .TP
139 .B \-\-login
140 Make
141 .B bash
142 act as if it had been invoked as a login shell (see
143 .SM
144 .B INVOCATION
145 below).
146 .TP
147 .B \-\-noediting
148 Do not use the GNU
149 .B readline
150 library to read command lines if interactive.
151 .TP
152 .B \-\-noprofile
153 Do not read either the system-wide startup file
154 .FN /etc/profile
155 or any of the personal initialization files
156 .IR ~/.bash_profile ,
157 .IR ~/.bash_login ,
158 or
159 .IR ~/.profile .
160 By default,
161 .B bash
162 reads these files when it is invoked as a login shell (see
163 .SM
164 .B INVOCATION
165 below).
166 .TP
167 .B \-\-norc
168 Do not read and execute the personal initialization file
169 .I ~/.bashrc
170 if the shell is interactive.
171 This option is on by default if the shell is invoked as
172 .BR sh .
173 .TP
174 .B \-\-posix
175 Change the behavior of \fBbash\fP where the default operation differs
176 from the POSIX 1003.2 standard to match the standard.
177 .TP
178 \fB\-\-rcfile\fP \fIfile\fP
179 Execute commands from
180 .I file
181 instead of the standard personal initialization file
182 .I ~/.bashrc
183 if the shell is interactive (see
184 .SM
185 .B INVOCATION
186 below).
187 .TP
188 .B \-\-restricted
189 The shell becomes restricted (see
190 .SM
191 .B "RESTRICTED SHELL"
192 below).
193 .TP
194 .B \-\-verbose
195 Equivalent to  \fB\-v\fP.
196 .TP
197 .B \-\-version
198 Show version information for this instance of
199 .B bash
200 on the standard output and exit successfully.
201 .PD
202 .SH ARGUMENTS
203 If arguments remain after option processing, and neither the
204 .B \-c
205 nor the
206 .B \-s
207 option has been supplied, the first argument is assumed to
208 be the name of a file containing shell commands.
209 If
210 .B bash
211 is invoked in this fashion, 
212 .B $0
213 is set to the name of the file, and the positional parameters
214 are set to the remaining arguments.
215 .B Bash
216 reads and executes commands from this file, then exits.
217 \fBBash\fP's exit status is the exit status of the last command
218 executed in the script.
219 If no commands are executed, the exit status is 0.
220 .SH INVOCATION
221 A \fIlogin shell\fP is one whose first character of argument zero is a
222 .BR \- ,
223 or one started with the 
224 .B \-\-login
225 option.
226 .PP
227 An \fIinteractive\fP shell is one whose standard input and output are
228 both connected to terminals (as determined by
229 .IR isatty (3)),
230 or one started with the
231 .B \-i
232 option.
233 .SM
234 .B PS1
235 is set and
236 .B $\-
237 includes
238 .B i
239 if
240 .B bash
241 is interactive,
242 allowing a shell script or a startup file to test this state.
243 .PP
244 The following paragraphs describe how
245 .B bash
246 executes its startup files.
247 If any of the files exist but cannot be read,
248 .B bash
249 reports an error.
250 Tildes are expanded in file names as described below under
251 .B "Tilde Expansion"
252 in the
253 .SM
254 .B EXPANSION
255 section.
256 .PP
257 When
258 .B bash
259 is invoked as a login shell, it first reads and executes commands
260 from the file \fI/etc/profile\fP, if that file exists.
261 After reading that file, it looks for \fI~/.bash_profile\fP,
262 \fI~/.bash_login\fP, and \fI~/.profile\fP, in that order, and reads
263 and executes commands from the first one that exists and is readable.
264 The
265 .B \-\-noprofile
266 option may be used when the shell is started to inhibit this behavior.
267 .PP
268 When a login shell exits,
269 .B bash
270 reads and executes commands from the file \fI~/.bash_logout\fP, if it
271 exists.
272 .PP
273 When an interactive shell that is not a login shell is started,
274 .B bash
275 reads and executes commands from \fI~/.bashrc\fP, if that file exists.
276 This may be inhibited by using the
277 .B \-\-norc
278 option.
279 The \fB\-\-rcfile\fP \fIfile\fP option will force
280 .B bash
281 to read and execute commands from \fIfile\fP instead of \fI~/.bashrc\fP.
282 .PP
283 When
284 .B bash
285 is started non-interactively, to run a shell script, for example, it
286 looks for the variable
287 .SM
288 .B BASH_ENV
289 in the environment, expands its value if it appears there, and uses the
290 expanded value as the name of a file to read and execute.
291 .B Bash
292 behaves as if the following command were executed:
293 .sp .5
294 .RS
295 \f(CWif [ \-n "$BASH_ENV" ]; then . "$BASH_ENV"; fi\fP
296 .RE
297 .sp .5
298 but the value of the
299 .SM
300 .B PATH
301 variable is not used to search for the file name.
302 .PP
303 If
304 .B bash
305 is invoked with the name
306 .BR sh ,
307 it tries to mimic the startup behavior of historical versions of
308 .B sh
309 as closely as possible,
310 while conforming to the POSIX standard as well.
311 When invoked as a login shell, it first attempts to read and execute
312 commands from
313 .I /etc/profile
314 and
315 .IR ~/.profile ,
316 in that order.
317 The
318 .B \-\-noprofile
319 option may be used to inhibit this behavior.
320 When invoked as an interactive shell with the name
321 .BR sh ,
322 .B bash
323 looks for the variable
324 .SM
325 .BR ENV ,
326 expands its value if it is defined, and uses the
327 expanded value as the name of a file to read and execute.
328 Since a shell invoked as
329 .B sh
330 does not attempt to read and execute commands from any other startup
331 files, the
332 .B \-\-rcfile
333 option has no effect.
334 A non-interactive shell invoked with the name
335 .B sh
336 does not attempt to read any startup files. 
337 When invoked as
338 .BR sh ,
339 .B bash
340 enters
341 .I posix
342 mode after the startup files are read.
343 .PP
344 When
345 .B bash
346 is started in
347 .I posix
348 mode, as with the
349 .B \-\-posix
350 command line option, it follows the POSIX standard for startup files.
351 In this mode, the
352 .SM
353 .B ENV
354 variable is expanded and commands are read and executed from the file
355 whose name is the expanded value.
356 No other startup files are read.
357 This is done by interactive shells only.
358 .PP
359 .B Bash
360 attempts to determine when it is being run by the remote shell
361 daemon, usually \fIrshd\fP.
362 If
363 .B bash
364 determines it is being run by \fIrshd\fP, it reads and executes
365 commands from \fI~/.bashrc\fP, if that file exists and is readable.
366 It will not do this if invoked as \fBsh\fP.
367 The
368 .B \-\-norc
369 option may be used to inhibit this behavior, and the
370 .B \-\-rcfile
371 option may be used to force another file to be read, but
372 \fIrshd\fP does not generally invoke the shell with those options
373 or allow them to be specified.
374 .SH DEFINITIONS
375 .PP
376 The following definitions are used throughout the rest of this
377 document.
378 .PD 0
379 .TP
380 .B blank 
381 A space or tab.
382 .TP
383 .B word
384 A sequence of characters considered as a single unit by the shell.
385 Also known as a
386 .BR token .
387 .TP
388 .B name
389
390 .I word
391 consisting only of alphanumeric characters and underscores, and
392 beginning with an alphabetic character or an underscore.  Also
393 referred to as an
394 .BR identifier .
395 .TP
396 .B metacharacter
397 A character that, when unquoted, separates words.  One of the following:
398 .br
399 .RS
400 .PP
401 .if t \fB|  &  ;  (  )  <  >  space  tab\fP
402 .if n \fB|  & ; ( ) < > space tab\fP
403 .RE
404 .PP
405 .TP
406 .B control operator
407 A \fItoken\fP that performs a control function.  It is one of the following
408 symbols:
409 .RS
410 .PP
411 .if t \fB\(bv\(bv  &  &&  ;  ;;  (  )  |  <newline>\fP
412 .if n \fB|| & && ; ;; ( ) | <newline>\fP
413 .RE
414 .PD
415 .SH "RESERVED WORDS"
416 \fIReserved words\fP are words that have a special meaning to the shell.
417 The following words are recognized as reserved when unquoted and either
418 the first word of a simple command (see
419 .SM
420 .B SHELL GRAMMAR
421 below) or the third word of a 
422 .B case 
423 or
424 .B for
425 command:
426 .if t .RS
427 .PP
428 .B
429 .if n ! case  do done elif else esac fi for function if in select then until while { } time
430 .if t !    case    do    done    elif    else    esac    fi    for    function    if    in    select    then    until    while    {    }    time
431 .if t .RE
432 .RE
433 .SH "SHELL GRAMMAR"
434 .SS Simple Commands
435 .PP
436 A \fIsimple command\fP is a sequence of optional variable assignments
437 followed by \fBblank\fP-separated words and redirections, and
438 terminated by a \fIcontrol operator\fP.  The first word
439 specifies the command to be executed.  The remaining words are
440 passed as arguments to the invoked command.
441 .PP
442 The return value of a \fIsimple command\fP is its exit status, or
443 128+\fIn\^\fP if the command is terminated by signal
444 .IR n .
445 .SS Pipelines
446 .PP
447 A \fIpipeline\fP is a sequence of one or more commands separated by
448 the character
449 .BR | .
450 The format for a pipeline is:
451 .RS
452 .PP
453 [\fBtime\fP [\fB\-p\fP]] [ ! ] \fIcommand\fP [ \fB|\fP \fIcommand2\fP ... ]
454 .RE
455 .PP
456 The standard output of
457 .I command
458 is connected to the standard input of
459 .IR command2 .
460 This connection is performed before any redirections specified by the
461 command (see
462 .SM
463 .B REDIRECTION
464 below).
465 .PP
466 If the reserved word
467 .B !
468 precedes a pipeline, the exit status of that
469 pipeline is the logical NOT of the exit status of the last command.
470 Otherwise, the status of the pipeline is the exit status of the last
471 command.
472 The shell waits for all commands in the pipeline to
473 terminate before returning a value.
474 .PP
475 If the
476 .B time
477 reserved word precedes a pipeline, the elapsed as well as user and
478 system time consumed by its execution are reported when the pipeline
479 terminates.
480 The \fB\-p\fP option changes the output format to that specified by POSIX.
481 The
482 .SM
483 .B TIMEFORMAT
484 variable may be set to a format string that specifies how the timing
485 information should be displayed; see the description of
486 .SM
487 .B TIMEFORMAT
488 under
489 .B "Shell Variables"
490 below.
491 .PP
492 Each command in a pipeline is executed as a separate process (i.e., in a
493 subshell).
494 .SS Lists
495 .PP
496 A \fIlist\fP is a sequence of one or more pipelines separated by one
497 of the operators
498 .BR ; ,
499 .BR & ,
500 .BR && ,
501 or
502 .BR \(bv\(bv ,
503 and optionally terminated by one of
504 .BR ; ,
505 .BR & ,
506 or
507 .BR <newline> .
508 .PP
509 Of these list operators,
510 .B &&
511 and
512 .B \(bv\(bv
513 have equal precedence, followed by
514 .B ;
515 and
516 .BR &,
517 which have equal precedence.
518 .PP
519 If a command is terminated by the control operator
520 .BR & ,
521 the shell executes the command in the \fIbackground\fP
522 in a subshell.  The shell does not wait for the command to
523 finish, and the return status is 0.  Commands separated by a
524 .B ;
525 are executed sequentially; the shell waits for each
526 command to terminate in turn.  The return status is the
527 exit status of the last command executed.
528 .PP
529 The control operators
530 .B &&
531 and
532 .B \(bv\(bv
533 denote AND lists and OR lists, respectively.
534 An AND list has the form
535 .RS
536 .PP
537 \fIcommand\fP \fB&&\fP \fIcommand2\fP
538 .RE
539 .PP
540 .I command2
541 is executed if, and only if,
542 .I command
543 returns an exit status of zero.
544 .PP
545 An OR list has the form
546 .RS
547 .PP
548 \fIcommand\fP \fB\(bv\(bv\fP \fIcommand2\fP
549 .PP
550 .RE
551 .PP
552 .I command2
553 is executed if and only if
554 .I command
555 returns a non-zero exit status.  The return status of
556 AND and OR lists is the exit status of the last command
557 executed in the list.
558 .SS Compound Commands
559 .PP
560 A \fIcompound command\fP is one of the following:
561 .TP
562 (\fIlist\fP)
563 \fIlist\fP is executed in a subshell.  Variable assignments and builtin
564 commands that affect the shell's environment do not remain in effect
565 after the command completes.  The return status is the exit status of
566 \fIlist\fP.
567 .TP
568 { \fIlist\fP; }
569 \fIlist\fP is simply executed in the current shell environment.
570 \fIlist\fP must be terminated with a newline or semicolon.
571 This is known as a \fIgroup command\fP.
572 The return status is the exit status of
573 \fIlist\fP.
574 .TP
575 ((\fIexpression\fP))
576 The \fIexpression\fP is evaluated according to the rules described
577 below under
578 .SM
579 .BR "ARITHMETIC EVALUATION" .
580 If the value of the expression is non-zero, the return status is 0;
581 otherwise the return status is 1.  This is exactly equivalent to
582 \fBlet "\fIexpression\fP"\fR.
583 .TP
584 \fBfor\fP \fIname\fP [ \fBin\fP \fIword\fP; ] \fBdo\fP \fIlist\fP ; \fBdone\fP
585 The list of words following \fBin\fP is expanded, generating a list
586 of items.  The variable \fIname\fP is set to each element of this list
587 in turn, and \fIlist\fP is executed each time.  If the \fBin\fP
588 \fIword\fP is omitted, the \fBfor\fP command executes \fIlist\fP 
589 once for each positional parameter that is set (see
590 .SM
591 .B PARAMETERS
592 below).
593 .TP
594 \fBselect\fP \fIname\fP [ \fBin\fP \fIword\fP; ] \fBdo\fP \fIlist\fP ; \fBdone\fP
595 The list of words following \fBin\fP is expanded, generating a list
596 of items.  The set of expanded words is printed on the standard
597 error, each preceded by a number.  If the \fBin\fP
598 \fIword\fP is omitted, the positional parameters are printed (see
599 .SM
600 .B PARAMETERS
601 below).  The
602 .B PS3
603 prompt is then displayed and a line read from the standard input.
604 If the line consists of a number corresponding to one of
605 the displayed words, then the value of
606 .I name
607 is set to that word.  If the line is empty, the words and prompt
608 are displayed again.  If EOF is read, the command completes.  Any
609 other value read causes
610 .I name
611 to be set to null.  The line read is saved in the variable
612 .BR REPLY .
613 The
614 .I list
615 is executed after each selection until a
616 .B break
617 or
618 .B return
619 command is executed.
620 The exit status of
621 .B select
622 is the exit status of the last command executed in
623 .IR list ,
624 or zero if no commands were executed.
625 .TP
626 \fBcase\fP \fIword\fP \fBin\fP [ \fIpattern\fP [ \fB|\fP \fIpattern\fP ] \
627 ... ) \fIlist\fP ;; ] ... \fBesac\fP
628 A \fBcase\fP command first expands \fIword\fP, and tries to match
629 it against each \fIpattern\fP in turn, using the same matching rules
630 as for pathname expansion (see
631 .B Pathname Expansion
632 below).  When a match is found, the
633 corresponding \fIlist\fP is executed.  After the first match, no
634 subsequent matches are attempted.  The exit status is zero if no
635 pattern matches.  Otherwise, it is the exit status of the
636 last command executed in \fIlist\fP.
637 .TP
638 \fBif\fP \fIlist\fP; \fBthen\fP \fIlist;\fP \
639 [ \fBelif\fP \fIlist\fP; \fBthen\fP \fIlist\fP; ] ... \
640 [ \fBelse\fP \fIlist\fP; ] \fBfi\fP
641 The
642 .B if 
643 .I list
644 is executed.  If its exit status is zero, the
645 \fBthen\fP \fIlist\fP is executed.  Otherwise, each \fBelif\fP
646 \fIlist\fP is executed in turn, and if its exit status is zero,
647 the corresponding \fBthen\fP \fIlist\fP is executed and the
648 command completes.  Otherwise, the \fBelse\fP \fIlist\fP is
649 executed, if present.  The exit status is the exit status of the
650 last command executed, or zero if no condition tested true.
651 .TP
652 .PD 0
653 \fBwhile\fP \fIlist\fP; \fBdo\fP \fIlist\fP; \fBdone\fP
654 .TP
655 \fBuntil\fP \fIlist\fP; \fBdo\fP \fIlist\fP; \fBdone\fP
656 .PD
657 The \fBwhile\fP command continuously executes the \fBdo\fP
658 \fIlist\fP as long as the last command in \fIlist\fP returns
659 an exit status of zero.  The \fBuntil\fP command is identical
660 to the \fBwhile\fP command, except that the test is negated;
661 the
662 .B do
663 .I list
664 is executed as long as the last command in
665 .I list
666 returns a non-zero exit status.
667 The exit status of the \fBwhile\fP and \fBuntil\fP commands
668 is the exit status
669 of the last \fBdo\fP \fIlist\fP command executed, or zero if
670 none was executed.
671 .TP
672 [ \fBfunction\fP ] \fIname\fP () { \fIlist\fP; }
673 This defines a function named \fIname\fP.  The \fIbody\fP of the
674 function is the
675 .I list
676 of commands between { and }.  This list
677 is executed whenever \fIname\fP is specified as the
678 name of a simple command.  The exit status of a function is
679 the exit status of the last command executed in the body.  (See
680 .SM
681 .B FUNCTIONS
682 below.)
683 .SH COMMENTS
684 In a non-interactive shell, or an interactive shell in which the
685 .B interactive_comments
686 option to the
687 .B shopt
688 builtin is enabled (see
689 .SM
690 .B "SHELL BUILTIN COMMANDS"
691 below), a word beginning with
692 .B #
693 causes that word and all remaining characters on that line to
694 be ignored.  An interactive shell without the
695 .B interactive_comments
696 .B shopt
697 option enabled does not allow comments.  The
698 .B interactive_comments
699 option is on by default in interactive shells.
700 .SH QUOTING
701 \fIQuoting\fP is used to remove the special meaning of certain
702 characters or words to the shell.  Quoting can be used to 
703 disable special treatment for special characters, to prevent
704 reserved words from being recognized as such, and to prevent
705 parameter expansion.
706 .PP
707 Each of the \fImetacharacters\fP listed above under
708 .SM
709 .B DEFINITIONS
710 has special meaning to the shell and must be quoted if they are to
711 represent themselves.  There are three quoting mechanisms: the
712 .IR "escape character" ,
713 single quotes, and double quotes.
714 .PP
715 A non-quoted backslash (\fB\e\fP) is the
716 .IR "escape character" .
717 It preserves the literal value of the next character that follows,
718 with the exception of <newline>.  If a \fB\e\fP<newline> pair
719 appears, and the backslash is not quoted, the \fB\e\fP<newline>
720 is treated as a line continuation (that is, it is effectively ignored).
721 .PP
722 Enclosing characters in single quotes preserves the literal value
723 of each character within the quotes.  A single quote may not occur
724 between single quotes, even when preceded by a backslash.
725 .PP
726 Enclosing characters in double quotes preserves the literal value
727 of all characters within the quotes, with the exception of
728 .BR $ ,
729 .BR ` ,
730 and
731 .BR \e .
732 The characters
733 .B $
734 and
735 .B `
736 retain their special meaning within double quotes.  The backslash
737 retains its special meaning only when followed by one of the following
738 characters:
739 .BR $ ,
740 .BR ` ,
741 \^\fB"\fP\^,
742 .BR \e ,
743 or
744 .BR <newline> .
745 A double quote may be quoted within double quotes by preceding it with
746 a backslash.
747 .PP
748 The special parameters
749 .B *
750 and
751 .B @
752 have special meaning when in double
753 quotes (see
754 .SM
755 .B PARAMETERS
756 below).
757 .PP
758 Words of the form \fB$\fP'\fIstring\fP' are treated specially.  The
759 word expands to \fIstring\fP, with backslash-escaped characters replaced
760 as specifed by the ANSI C standard.  Backslash escape sequences, if
761 present, are decoded as follows:
762 .RS
763 .PD 0
764 .TP
765 .B \ea
766 alert (bell)
767 .TP
768 .B \eb
769 backspace
770 .TP
771 .B \ee
772 an escape character
773 .TP   
774 .B \ef
775 form feed
776 .TP  
777 .B \en
778 new line
779 .TP     
780 .B \er
781 carriage return
782 .TP
783 .B \et
784 horizontal tab
785 .TP   
786 .B \ev
787 vertical tab
788 .TP
789 .B \e\e
790 backslash
791 .TP   
792 .B \e\fInnn\fP
793 the character whose ASCII code is \fInnn\fP (octal)
794 .PD
795 .RE
796 .LP
797 The translated result is single-quoted, as if the dollar sign had
798 not been present.
799 .PP
800 A double-quoted string preceded by a dollar sign (\fB$\fP) will cause
801 the string to be translated according to the current locale.
802 If the current locale is \fBC\fP or \fBPOSIX\fP, the dollar sign
803 is ignored.
804 If the string is translated and replaced, the replacement is
805 double-quoted.
806 .SH PARAMETERS
807 A
808 .I parameter
809 is an entity that stores values.
810 It can be a
811 .IR name ,
812 a number, or one of the special characters listed below under
813 .BR "Special Parameters" .
814 For the shell's purposes, a
815 .I variable
816 is a parameter denoted by a
817 .IR name .
818 .PP
819 A parameter is set if it has been assigned a value.  The null string is
820 a valid value.  Once a variable is set, it may be unset only by using
821 the
822 .B unset
823 builtin command (see
824 .SM
825 .B SHELL BUILTIN COMMANDS
826 below).
827 .PP
828 A
829 .I variable
830 may be assigned to by a statement of the form
831 .RS
832 .PP
833 \fIname\fP=[\fIvalue\fP]
834 .RE
835 .PP
836 If
837 .I value
838 is not given, the variable is assigned the null string.  All
839 .I values
840 undergo tilde expansion, parameter and variable expansion, string
841 expansion, command substitution, arithmetic expansion, and quote
842 removal (see
843 .SM
844 .B EXPANSION
845 below).  If the variable has its
846 .B \-i
847 attribute set (see
848 .B declare
849 below in
850 .SM
851 .BR "SHELL BUILTIN COMMANDS" )
852 then
853 .I value
854 is subject to arithmetic expansion even if the $((...)) syntax does
855 not appear (see
856 .B "Arithmetic Expansion"
857 below).
858 Word splitting is not performed, with the exception
859 of \fB"$@"\fP as explained below under
860 .BR "Special Parameters" .
861 Pathname expansion is not performed.
862 .SS Positional Parameters
863 .PP
864 A
865 .I positional parameter
866 is a parameter denoted by one or more
867 digits, other than the single digit 0.  Positional parameters are
868 assigned from the shell's arguments when it is invoked,
869 and may be reassigned using the
870 .B set
871 builtin command.  Positional parameters may not be assigned to
872 with assignment statements.  The positional parameters are
873 temporarily replaced when a shell function is executed (see
874 .SM
875 .B FUNCTIONS
876 below).
877 .PP
878 When a positional parameter consisting of more than a single
879 digit is expanded, it must be enclosed in braces (see
880 .SM
881 .B EXPANSION
882 below).
883 .SS Special Parameters
884 .PP
885 The shell treats several parameters specially.  These parameters may
886 only be referenced; assignment to them is not allowed.
887 .PD 0
888 .TP
889 .B *
890 Expands to the positional parameters, starting from one.  When the
891 expansion occurs within double quotes, it expands to a single word
892 with the value of each parameter separated by the first character
893 of the 
894 .SM
895 .B IFS
896 special variable.  That is, ``\fB$*\fP'' is equivalent
897 to ``\fB$1\fP\fIc\fP\fB$2\fP\fIc\fP\fB...\fP'', where
898 .I c
899 is the first character of the value of the
900 .SM
901 .B IFS
902 variable.  If
903 .SM
904 .B IFS
905 is null or unset, the parameters are separated by spaces.
906 .TP
907 .B @
908 Expands to the positional parameters, starting from one.  When the
909 expansion occurs within double quotes, each parameter expands as a
910 separate word.  That is, ``
911 .BR $@ ''
912 is equivalent to
913 ``\fB$1\fP'' ``\fB$2\fP'' ...
914 When there are no positional parameters, ``\fB$@\fP'' and 
915 .B $@
916 expand to nothing (i.e., they are removed).
917 .TP
918 .B #
919 Expands to the number of positional parameters in decimal.
920 .TP
921 .B ?
922 Expands to the status of the most recently executed foreground
923 pipeline.
924 .TP
925 .B \-
926 Expands to the current option flags as specified upon invocation, 
927 by the
928 .B set
929 builtin command, or those set by the shell itself
930 (such as the
931 .B \-i
932 flag).
933 .TP
934 .B $
935 Expands to the process ID of the shell.  In a () subshell, it
936 expands to the process ID of the current shell, not the
937 subshell.
938 .TP
939 .B !
940 Expands to the process ID of the most recently executed background
941 (asynchronous) command.
942 .TP
943 .B 0
944 Expands to the name of the shell or shell script.  This is set at
945 shell initialization.  If
946 .B bash
947 is invoked with a file of commands,
948 .B $0
949 is set to the name of that file.  If
950 .B bash
951 is started with the
952 .B \-c
953 option, then
954 .B $0
955 is set to the first argument after the string to be
956 executed, if one is present.  Otherwise, it is set
957 to the file name used to invoke
958 .BR bash ,
959 as given by argument zero.
960 .TP
961 .B _
962 At shell startup, set to the absolute file name of the shell or shell
963 script being executed as passed in the argument list.
964 Subsequently, expands to the last argument to the previous command,
965 after expansion.
966 Also set to the full file name of each command executed and placed in
967 the environment exported to that command.
968 When checking mail, this parameter holds the name of the mail file
969 currently being checked.
970 .PD
971 .SS Shell Variables
972 .PP
973 The following variables are set by the shell:
974 .PP
975 .PD 0
976 .TP
977 .B PPID
978 The process ID of the shell's parent.
979 .TP
980 .B PWD
981 The current working directory as set by the
982 .B cd
983 command.
984 .TP
985 .B OLDPWD
986 The previous working directory as set by the
987 .B cd
988 command.
989 .TP
990 .B REPLY
991 Set to the line of input read by the
992 .B read
993 builtin command when no arguments are supplied.
994 .TP
995 .B UID
996 Expands to the user ID of the current user, initialized at shell startup.
997 .TP
998 .B EUID
999 Expands to the effective user ID of the current user, initialized at
1000 shell startup.
1001 .TP
1002 .B BASH
1003 Expands to the full file name used to invoke this instance of
1004 .BR bash .
1005 .TP
1006 .B BASH_VERSION
1007 Expands to a string describing the version of this instance of
1008 .BR bash .
1009 .TP
1010 .B BASH_VERSINFO
1011 An array variable whose members hold version information for this
1012 instance of
1013 .BR bash .
1014 The values assigned to the array members are as follows:
1015 .sp .5
1016 .RS
1017 .PD 0
1018 .TP 24
1019 .B BASH_VERSINFO[\fR0\fP]
1020 The major version number (the \fIrelease\fP).
1021 .TP
1022 .B BASH_VERSINFO[\fR1\fP]
1023 The minor version number (the \fIversion\fP).
1024 .TP
1025 .B BASH_VERSINFO[\fR2\fP]
1026 The patch level.
1027 .TP
1028 .B BASH_VERSINFO[\fR3\fP]
1029 The build version.
1030 .TP
1031 .B BASH_VERSINFO[\fR4\fP]
1032 The release status (e.g., \fIbeta1\fP).
1033 .TP
1034 .B BASH_VERSINFO[\fR5\fP]
1035 The value of \fBMACHTYPE\fP.
1036 .PD
1037 .RE
1038 .TP
1039 .B SHLVL
1040 Incremented by one each time an instance of
1041 .B bash
1042 is started.
1043 .TP
1044 .B RANDOM
1045 Each time this parameter is referenced, a random integer between
1046 0 and 32767 is
1047 generated.  The sequence of random numbers may be initialized by assigning
1048 a value to
1049 .SM
1050 .BR RANDOM .
1051 If
1052 .SM
1053 .B RANDOM
1054 is unset, it loses its special properties, even if it is
1055 subsequently reset.
1056 .TP
1057 .B SECONDS
1058 Each time this parameter is
1059 referenced, the number of seconds since shell invocation is returned.  If a
1060 value is assigned to 
1061 .SM
1062 .BR SECONDS ,
1063 the value returned upon subsequent
1064 references is
1065 the number of seconds since the assignment plus the value assigned.
1066 If
1067 .SM
1068 .B SECONDS
1069 is unset, it loses its special properties, even if it is
1070 subsequently reset.
1071 .TP
1072 .B LINENO
1073 Each time this parameter is referenced, the shell substitutes
1074 a decimal number representing the current sequential line number
1075 (starting with 1) within a script or function.  When not in a
1076 script or function, the value substituted is not guaranteed to
1077 be meaningful.
1078 If
1079 .SM
1080 .B LINENO
1081 is unset, it loses its special properties, even if it is
1082 subsequently reset.
1083 .TP
1084 .B HISTCMD
1085 The history number, or index in the history list, of the current
1086 command.
1087 If
1088 .SM
1089 .B HISTCMD
1090 is unset, it loses its special properties, even if it is
1091 subsequently reset.
1092 .TP
1093 .B DIRSTACK
1094 An array variable (see
1095 .B Arrays
1096 below) containing the current contents of the directory stack.
1097 Directories appear in the stack in the order they are displayed by the
1098 .B dirs
1099 builtin.
1100 Assigning to members of this array variable may be used to modify
1101 directories already in the stack, but the
1102 .B pushd
1103 and
1104 .B popd
1105 builtins must be used to add and remove directories.
1106 Assignment to this variable will not change the current directory.
1107 If
1108 .SM
1109 .B DIRSTACK
1110 is unset, it loses its special properties, even if it is
1111 subsequently reset.
1112 .TP
1113 .B PIPESTATUS
1114 An array variable (see
1115 .B Arrays
1116 below) containing a list of exit status values from the processes
1117 in the most-recently-executed foreground pipeline (which may
1118 contain only a single command).
1119 .TP
1120 .B OPTARG
1121 The value of the last option argument processed by the
1122 .B getopts
1123 builtin command (see
1124 .SM
1125 .B SHELL BUILTIN COMMANDS
1126 below).
1127 .TP
1128 .B OPTIND
1129 The index of the next argument to be processed by the
1130 .B getopts
1131 builtin command (see
1132 .SM
1133 .B SHELL BUILTIN COMMANDS
1134 below).
1135 .TP
1136 .B HOSTNAME
1137 Automatically set to the name of the current host.
1138 .TP
1139 .B HOSTTYPE
1140 Automatically set to a string that uniquely
1141 describes the type of machine on which
1142 .B bash
1143 is executing.
1144 The default is system-dependent.
1145 .TP
1146 .B OSTYPE
1147 Automatically set to a string that
1148 describes the operating system on which
1149 .B bash
1150 is executing.
1151 The default is system-dependent.
1152 .TP
1153 .B MACHTYPE
1154 Automatically set to a string that fully describes the system
1155 type on which
1156 .B bash
1157 is executing, in the standard GNU \fIcpu-company-system\fP format.
1158 The default is system-dependent.
1159 .TP
1160 .B SHELLOPTS
1161 A colon-separated list of enabled shell options.  Each word in
1162 the list is a valid argument for the
1163 .B \-o
1164 option to the
1165 .B set
1166 builtin command (see
1167 .SM
1168 .B "SHELL BUILTIN COMMANDS"
1169 below).  The options appearing in
1170 .SM
1171 .B SHELLOPTS
1172 are those reported as
1173 .I on
1174 by \fBset \-o\fP.
1175 If this variable is in the environment when
1176 .B bash
1177 starts up, each shell option in the list will be enabled before
1178 reading any startup files.
1179 This variable is read-only.
1180 .PD
1181 .PP
1182 The following variables are used by the shell.  In some cases,
1183 .B bash
1184 assigns a default value to a variable; these cases are noted
1185 below.
1186 .PP
1187 .PD 0
1188 .TP
1189 .B IFS
1190 The
1191 .I Internal Field Separator
1192 that is used
1193 for word splitting after expansion and to
1194 split lines into words with the
1195 .B read
1196 builtin command.  The default value is
1197 ``<space><tab><newline>''.
1198 .TP
1199 .B PATH
1200 The search path for commands.  It
1201 is a colon-separated list of directories in which
1202 the shell looks for commands (see
1203 .SM
1204 .B COMMAND EXECUTION
1205 below).  The default path is system-dependent,
1206 and is set by the administrator who installs
1207 .BR bash .
1208 A common value is ``/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin:.''.
1209 .TP
1210 .B HOME
1211 The home directory of the current user; the default argument for the
1212 \fBcd\fP builtin command.
1213 .TP
1214 .B CDPATH
1215 The search path for the
1216 .B cd
1217 command.  This is a colon-separated
1218 list of directories in which the shell looks for destination directories
1219 specified by the
1220 .B cd
1221 command.  A sample value is
1222 ``.:~:/usr''.
1223 .TP
1224 .B ENV
1225 If this parameter is set when \fBbash\fP is executing a shell script,
1226 its value is interpreted as a filename containing commands to
1227 initialize the shell, as in
1228 .IR .bashrc .
1229 The value of
1230 .SM
1231 .B ENV
1232 is subjected to parameter expansion, command substitution, and arithmetic
1233 expansion before being interpreted as a file name.
1234 .SM
1235 .B PATH
1236 is not used to search for the resultant file name.
1237 .TP
1238 .B MAIL
1239 If this parameter is set to a file name and the
1240 .SM
1241 .B MAILPATH
1242 variable is not set,
1243 .B bash
1244 informs the user of the arrival of mail in the specified file.
1245 .TP
1246 .B MAILCHECK
1247 Specifies how
1248 often (in seconds)
1249 .B bash
1250 checks for mail.  The default is 60 seconds.  When it is time to check
1251 for mail, the shell does so before displaying the primary prompt.
1252 If this variable is unset, the shell disables mail checking.
1253 .TP
1254 .B MAILPATH
1255 A colon-separated list of file names to be checked for mail. 
1256 The message to be printed may be specified by separating the file name from
1257 the message with a `?'.  $_ stands for the name of the current mailfile. 
1258 Example:
1259 .RS
1260 .PP
1261 \fBMAILPATH\fP='/usr/spool/mail/bfox?"You have mail":~/shell\-mail?"$_ has mail!"'
1262 .PP
1263 .B Bash
1264 supplies a default value for this variable, but the location of the user
1265 mail files that it uses is system dependent (e.g., /usr/spool/mail/\fB$USER\fP).
1266 .RE
1267 .TP
1268 .B PS1
1269 The value of this parameter is expanded (see
1270 .SM
1271 .B PROMPTING
1272 below) and used as the primary prompt string.  The default value is
1273 ``\fB\es\-\ev\e$ \fP''.
1274 .TP
1275 .B PS2
1276 The value of this parameter is expanded as with
1277 .B PS1
1278 and used as the secondary prompt string.  The default is
1279 ``\fB> \fP''.
1280 .TP
1281 .B PS3
1282 The value of this parameter is used as the prompt for the
1283 .B select
1284 command (see
1285 .SM
1286 .B SHELL GRAMMAR
1287 above).
1288 .TP
1289 .B PS4
1290 The value of this parameter is expanded as with
1291 .B PS1
1292 and the value is printed before each command
1293 .B bash
1294 displays during an execution trace.  The first character of
1295 .SM
1296 .B PS4
1297 is replicated multiple times, as necessary, to indicate multiple
1298 levels of indirection.  The default is ``\fB+ \fP''.
1299 .TP
1300 .B TIMEFORMAT
1301 The value of this parameter is used as a format string specifying
1302 how the timing information for pipelines prefixed with the
1303 .B time
1304 reserved word should be displayed.
1305 The \fB%\fP character introduces an escape sequence that is
1306 expanded to a time value or other information.
1307 The escape sequences and their meanings are as follows; the
1308 braces denote optional portions.
1309 .sp .5
1310 .RS
1311 .PD 0
1312 .TP 10
1313 .B %%
1314 A literal \fB%\fP.
1315 .TP
1316 .B %[\fIp\fP][l]R
1317 The elapsed time in seconds.
1318 .TP
1319 .B %[\fIp\fP][l]U
1320 The number of CPU seconds spent in user mode.
1321 .TP
1322 .B %[\fIp\fP][l]S
1323 The number of CPU seconds spent in system mode.
1324 .TP
1325 .B %P
1326 The CPU percentage, computed as (%U + %S) / %R.
1327 .PD
1328 .RE
1329 .IP
1330 The optional \fIp\fP is a digit specifying the \fIprecision\fP,
1331 the number of fractional digits after a decimal point.
1332 A value of 0 causes no decimal point or fraction to be output.
1333 At most three places after the decimal point may be specified;
1334 values of \fIp\fP greater than 3 are changed to 3.
1335 If \fIp\fP is not specified, the value 3 is used.
1336 .IP
1337 The optional \fBl\fP specifies a longer format, including
1338 minutes, of the form \fIMM\fPm\fISS\fP.\fIFF\fPs.
1339 The value of \fIp\fP determines whether or not the fraction is
1340 included.
1341 .IP
1342 If this variable is not set, \fBbash\fP acts as if it had the
1343 value \fB$'\enreal\et%3lR\enuser\et%3lU\ensys\t%3lS'\fP.
1344 If the value is null, no timing information is displayed.
1345 A trailing newline is added when the format string is displayed.
1346 .TP
1347 .B HISTSIZE
1348 The number of commands to remember in the command history (see
1349 .SM
1350 .B HISTORY
1351 below).  The default value is 500.
1352 .TP
1353 .B HISTFILE
1354 The name of the file in which command history is saved (see
1355 .SM
1356 .B HISTORY
1357 below).  The default value is \fI~/.bash_history\fP.  If unset, the
1358 command history is not saved when an interactive shell exits.
1359 .TP
1360 .B HISTFILESIZE
1361 The maximum number of lines contained in the history file.  When this
1362 variable is assigned a value, the history file is truncated, if
1363 necessary, to contain no more than that number of lines.  The default
1364 value is 500.  The history file is also truncated to this size after
1365 writing it when an interactive shell exits.
1366 .TP
1367 .B OPTERR
1368 If set to the value 1,
1369 .B bash
1370 displays error messages generated by the
1371 .B getopts
1372 builtin command (see
1373 .SM
1374 .B SHELL BUILTIN COMMANDS
1375 below).
1376 .SM
1377 .B OPTERR
1378 is initialized to 1 each time the shell is invoked or a shell
1379 script is executed.
1380 .TP
1381 .B LANG
1382 Used to determine the locale category for any category not specifically
1383 selected with a variable starting with \fBLC_\fP.
1384 .TP
1385 .B LC_ALL
1386 This variable overrides the value of \fBLANG\fP and any other
1387 \fBLC_\fP variable specifying a locale category.
1388 .TP
1389 .B LC_COLLATE
1390 This variable determines the collation order used when sorting the
1391 results of pathname expansion.
1392 .TP
1393 .B LC_MESSAGES
1394 This variable determines the locale used to translate double-quoted
1395 strings preceded by a \fB$\fP.
1396 .TP
1397 .B PROMPT_COMMAND
1398 If set, the value is executed as a command prior to issuing each primary
1399 prompt.
1400 .TP
1401 .B IGNOREEOF
1402 Controls the
1403 action of an interactive shell on receipt of an
1404 .SM
1405 .B EOF
1406 character as the sole input.  If set, the value is the number of
1407 consecutive
1408 .SM
1409 .B EOF
1410 characters which must be
1411 typed as the first characters on an input line before
1412 .B bash
1413 exits.  If the variable exists but does not have a numeric value, or
1414 has no value, the default value is 10.  If it does not exist,
1415 .SM
1416 .B EOF
1417 signifies the end of input to the shell.
1418 .TP
1419 .B TMOUT
1420 If set to a value greater than zero, the value is interpreted as the
1421 number of seconds to wait for input after issuing the primary prompt.
1422 .B Bash
1423 terminates after waiting for that number of seconds if input does
1424 not arrive.
1425 .TP
1426 .B FCEDIT
1427 The default editor for the
1428 .B fc
1429 builtin command.
1430 .TP
1431 .B FIGNORE
1432 A colon-separated list of suffixes to ignore when performing
1433 filename completion (see
1434 .SM
1435 .B READLINE
1436 below).
1437 A filename whose suffix matches one of the entries in 
1438 .SM
1439 .B FIGNORE
1440 is excluded from the list of matched filenames.
1441 A sample value is ``.o:~''.
1442 .TP
1443 .B GLOBIGNORE
1444 A colon-separated list of patterns defining the set of filenames to
1445 be ignored by pathname expansion.
1446 If a filename matched by a pathname expansion pattern also matches one
1447 of the patterns in
1448 .SM
1449 .BR GLOBIGNORE ,
1450 it is removed from the list of matches.
1451 .TP
1452 .B INPUTRC
1453 The filename for the
1454 .B readline
1455 startup file, overriding the default of
1456 .FN ~/.inputrc
1457 (see
1458 .SM
1459 .B READLINE
1460 below).
1461 .TP
1462 .B HISTCONTROL
1463 If set to a value of
1464 .IR ignorespace ,
1465 lines which begin with a
1466 .B space
1467 character are not entered on the history list.  If set to
1468 a value of
1469 .IR ignoredups ,
1470 lines matching the last history line are not entered.
1471 A value of
1472 .I ignoreboth
1473 combines the two options.
1474 If unset, or if set to any other value than those above,
1475 all lines read
1476 by the parser are saved on the history list, subject to the value
1477 of
1478 .BR HISTIGNORE .
1479 This variable's function is superseded by
1480 .BR HISTIGNORE .
1481 .TP
1482 .B HISTIGNORE
1483 A colon-separated list of patterns used to decide which command lines
1484 should be saved on the history list.  Each pattern is anchored at the
1485 beginning of the line and must fully specify the line (no implicit
1486 `\fB*\fP' is appended).  Each pattern is tested against the line
1487 after the checks specified by
1488 .B HISTCONTROL
1489 are applied.
1490 In addition to the normal shell pattern matching characters, `\fB&\fP'
1491 matches the previous history line.  `\fB&\fP' may be escaped using a
1492 backslash.  The backslash is removed before attempting a match.
1493 .TP
1494 .B histchars
1495 The two or three characters which control history expansion
1496 and tokenization (see
1497 .SM
1498 .B HISTORY EXPANSION
1499 below).  The first character is the
1500 .IR "history expansion character" ,
1501 that is, the character which signals the start of a history
1502 expansion, normally `\fB!\fP'.
1503 The second character is the
1504 .IR "quick substitution"
1505 character, which is used as shorthand for re-running the previous
1506 command entered, substituting one string for another in the command.
1507 The default is `\fB^\fP'.
1508 The optional third character is the character
1509 which signifies that the remainder of the line is a comment when found
1510 as the first character of a word, normally `\fB#\fP'.  The history
1511 comment character causes history substitution to be skipped for the
1512 remaining words on the line.  It does not necessarily cause the shell
1513 parser to treat the rest of the line as a comment.
1514 .TP
1515 .B HOSTFILE
1516 Contains the name of a file in the same format as
1517 .FN /etc/hosts
1518 that should be read when the shell needs to complete a
1519 hostname.  The file may be changed interactively; the next
1520 time hostname completion is attempted
1521 .B bash
1522 adds the contents of the new file to the already existing database.
1523 .TP
1524 .B auto_resume
1525 This variable controls how the shell interacts with the user and
1526 job control.  If this variable is set, single word simple
1527 commands without redirections are treated as candidates for resumption
1528 of an existing stopped job.  There is no ambiguity allowed; if there is
1529 more than one job beginning with the string typed, the job most recently
1530 accessed is selected.  The
1531 .I name
1532 of a stopped job, in this context, is the command line used to
1533 start it.
1534 If set to the value
1535 .IR exact ,
1536 the string supplied must match the name of a stopped job exactly;
1537 if set to
1538 .IR substring ,
1539 the string supplied needs to match a substring of the name of a
1540 stopped job.  The
1541 .I substring
1542 value provides functionality analogous to the
1543 .B %?
1544 job identifier (see
1545 .SM
1546 .B JOB CONTROL
1547 below).  If set to any other value, the supplied string must
1548 be a prefix of a stopped job's name; this provides functionality
1549 analogous to the
1550 .B %
1551 job identifier.
1552 .PD
1553 .SS Arrays
1554 .B Bash
1555 provides one-dimensional array variables.  Any variable may be used as
1556 an array; the
1557 .B declare
1558 builtin will explicitly declare an array.  There is no maximum
1559 limit on the size of an array, nor any requirement that members
1560 be indexed or assigned contiguously.  Arrays are indexed using
1561 integers and are zero-based.
1562 .PP
1563 An array is created automatically if any variable is assigned to using
1564 the syntax \fIname\fP[\fIsubscript\fP]=\fIvalue\fP.  The
1565 .I subscript
1566 is treated as an arithmetic expression that must evaluate to a number
1567 greater than or equal to zero.  To explicitly declare an array, use
1568 .B declare \-a \fIname\fP
1569 (see
1570 .SM
1571 .B SHELL BUILTIN COMMANDS
1572 below).
1573 .B declare \-a \fIname\fP[\fIsubscript\fP]
1574 is also accepted; the \fIsubscript\fP is ignored.  Attributes may be
1575 specified for an array variable using the
1576 .B declare
1577 and
1578 .B readonly
1579 builtins.  Each attribute applies to all members of an array.
1580 .PP
1581 Arrays are assigned to using compound assignments of the form
1582 \fIname\fP=\fB(\fPvalue\fI1\fP ... value\fIn\fP\fB)\fP, where each
1583 \fIvalue\fP is of the form [\fIsubscript\fP]=\fIstring\fP.  Only
1584 \fIstring\fP is required.  If
1585 the optional brackets and subscript are supplied, that index is assigned to;
1586 otherwise the index of the element assigned is the last index assigned
1587 to by the statement plus one.  Indexing starts at zero.
1588 This syntax is also accepted by the
1589 .B declare
1590 builtin.  Individual array elements may be assigned to using the
1591 \fIname\fP[\fIsubscript\fP]=\fIvalue\fP syntax introduced above.
1592 .PP
1593 Any element of an array may be referenced using
1594 ${\fIname\fP[\fIsubscript\fP]}.  The braces are required to avoid
1595 conflicts with pathname expansion.  If
1596 \fIsubscript\fP is \fB@\fP or \fB*\fP, the word expands to
1597 all members of \fIname\fP.  These subscripts differ only when the
1598 word appears within double quotes.  If the word is double-quoted,
1599 ${\fIname\fP[*]} expands to a single
1600 word with the value of each array member separated by the first
1601 character of the
1602 .SM
1603 .B IFS
1604 special variable, and ${\fIname\fP[@]} expands each element of
1605 \fIname\fP to a separate word.  When there are no array members,
1606 ${\fIname\fP[@]} expands to nothing.  This is analogous to the expansion
1607 of the special parameters \fB*\fP and \fB@\fP (see
1608 .B Special Parameters
1609 above).  ${#\fIname\fP[\fIsubscript\fP]} expands to the length of
1610 ${\fIname\fP[\fIsubscript\fP]}.  If \fIsubscript\fP is \fB*\fP or
1611 \fB@\fP, the expansion is the number of elements in the array.
1612 Referencing an array variable without a subscript is equivalent to
1613 referencing element zero.
1614 .PP
1615 The
1616 .B unset
1617 builtin is used to destroy arrays.  \fBunset\fP \fIname\fP[\fIsubscript\fP]
1618 destroys the array element at index \fIsubscript\fP.
1619 \fBunset\fP \fIname\fP, where \fIname\fP is an array, or
1620 \fBunset\fP \fIname\fP[\fIsubscript\fP], where
1621 \fIsubscript\fP is \fB*\fP or \fB@\fP, removes the entire array.
1622 .PP
1623 The
1624 .BR declare ,
1625 .BR local ,
1626 and
1627 .B readonly
1628 builtins each accept a
1629 .B \-a
1630 option to specify an array.  The
1631 .B read
1632 builtin accepts a
1633 .B \-a
1634 option to assign a list of words read from the standard input
1635 to an array.  The
1636 .B set
1637 and
1638 .B declare
1639 builtins display array values in a way that allows them to be
1640 reused as assignments.
1641 .SH EXPANSION
1642 Expansion is performed on the command line after it has been split into
1643 words.  There are seven kinds of expansion performed:
1644 .IR "brace expansion" ,
1645 .IR "tilde expansion" ,
1646 .IR "parameter and variable expansion" ,
1647 .IR "command substitution" ,
1648 .IR "arithmetic expansion" ,
1649 .IR "word splitting" ,
1650 and
1651 .IR "pathname expansion" .
1652 .PP
1653 The order of expansions is: brace expansion, tilde expansion,
1654 parameter, variable and arithmetic expansion and
1655 command substitution
1656 (done in a left-to-right fashion), word splitting, and pathname
1657 expansion.
1658 .PP
1659 On systems that can support it, there is an additional expansion
1660 available: \fIprocess substitution\fP.
1661 .PP
1662 Only brace expansion, word splitting, and pathname expansion
1663 can change the number of words of the expansion; other expansions
1664 expand a single word to a single word.
1665 The only exceptions to this are the expansions of
1666 ``\fB$@\fP'' and ``\fB${\fP\fIname\fP\fB[@]}\fP''
1667 as explained above (see
1668 .SM
1669 .BR PARAMETERS ).
1670 .SS Brace Expansion
1671 .PP
1672 .I "Brace expansion"
1673 is a mechanism by which arbitrary strings
1674 may be generated.  This mechanism is similar to
1675 \fIpathname expansion\fP, but the filenames generated
1676 need not exist.  Patterns to be brace expanded take
1677 the form of an optional
1678 .IR preamble ,
1679 followed by a series of comma-separated strings
1680 between a pair of braces, followed by an optional
1681 .IR postamble .
1682 The preamble is prefixed to each string contained
1683 within the braces, and the postamble is then appended
1684 to each resulting string, expanding left to right.
1685 .PP
1686 Brace expansions may be nested.  The results of each expanded
1687 string are not sorted; left to right order is preserved.
1688 For example, a\fB{\fPd,c,b\fB}\fPe expands into `ade ace abe'.
1689 .PP
1690 Brace expansion is performed before any other expansions,
1691 and any characters special to other expansions are preserved
1692 in the result.  It is strictly textual.
1693 .B Bash
1694 does not apply any syntactic interpretation to the context of the
1695 expansion or the text between the braces.
1696 .PP
1697 A correctly-formed brace expansion must contain unquoted opening
1698 and closing braces, and at least one unquoted comma.
1699 Any incorrectly formed brace expansion is left unchanged.
1700 A \fB{\fP or \fB,\fP may be quoted with a backslash to prevent its
1701 being considered part of a brace expression.
1702 .PP
1703 This construct is typically used as shorthand when the common
1704 prefix of the strings to be generated is longer than in the
1705 above example:
1706 .RS
1707 .PP
1708 mkdir /usr/local/src/bash/{old,new,dist,bugs}
1709 .RE
1710 or
1711 .RS
1712 chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}
1713 .RE
1714 .PP
1715 Brace expansion introduces a slight incompatibility with
1716 historical versions of
1717 .BR sh .
1718 .B sh
1719 does not treat opening or closing braces specially when they
1720 appear as part of a word, and preserves them in the output.
1721 .B Bash
1722 removes braces from words as a consequence of brace
1723 expansion.  For example, a word entered to
1724 .B sh
1725 as \fIfile{1,2}\fP
1726 appears identically in the output.  The same word is
1727 output as
1728 .I file1 file2
1729 after expansion by
1730 .BR bash .
1731 If strict compatibility with
1732 .B sh
1733 is desired, start
1734 .B bash
1735 with the
1736 .B +B 
1737 option or disable brace expansion with the
1738 .B +B
1739 option to the
1740 .B set
1741 command (see
1742 .SM
1743 .B SHELL BUILTIN COMMANDS
1744 below).
1745 .SS Tilde Expansion
1746 .PP
1747 If a word begins with a tilde character (`\fB~\fP'), all of the characters
1748 preceding the first slash (or all characters, if there is no slash)
1749 are treated as a possible \fIlogin name\fP. If this \fIlogin name\fP
1750 is the null string, the tilde is replaced with the value of the
1751 parameter
1752 .SM
1753 .BR HOME .
1754 If
1755 .SM
1756 .B HOME
1757 is unset, the home directory of
1758 the user executing the shell is substituted instead.
1759 .PP
1760 If a `+' follows the tilde, the value of
1761 .SM
1762 .B PWD
1763 replaces the tilde and `+'.  If
1764 a `\-' follows, the value of
1765 .SM
1766 .B OLDPWD
1767 is substituted.
1768 If the value following the tilde is a valid \fIlogin name\fP,
1769 the tilde and \fIlogin name\fP are replaced with the home directory
1770 associated with that name.  If the name is invalid, or the tilde
1771 expansion fails, the word is unchanged.
1772 .PP
1773 Each variable assignment is checked for unquoted
1774 tildes immediately following a
1775 .B :
1776 or
1777 .BR = .
1778 In these cases, tilde substitution is also performed.  Consequently, one
1779 may use file names with tildes in assignments to
1780 .SM
1781 .BR PATH ,
1782 .SM
1783 .BR MAILPATH ,
1784 and
1785 .SM
1786 .BR CDPATH ,
1787 and the shell assigns the expanded value.
1788 .SS Parameter Expansion
1789 .PP
1790 The `\fB$\fP' character introduces parameter expansion,
1791 command substitution, or arithmetic expansion.  The parameter name
1792 or symbol to be expanded may be enclosed in braces, which
1793 are optional but serve to protect the variable to be expanded from
1794 characters immediately following it which could be
1795 interpreted as part of the name.
1796 .PP
1797 .PD 0
1798 .TP
1799 ${\fIparameter\fP}
1800 The value of \fIparameter\fP is substituted.  The braces are required
1801 when
1802 .I parameter
1803 is a positional parameter with more than one digit,
1804 or when
1805 .I parameter
1806 is followed by a character which is not to be
1807 interpreted as part of its name.
1808 .PD
1809 .PP
1810 If the first character of \fIparameter\fP is an exclamation point,
1811 a level of variable indirection is introduced.
1812 \fBBash\fP uses the value of the variable formed from the rest of
1813 \fIparameter\fP as the name of the variable; this variable is then
1814 expanded and that value used in the rest of the substitution, rather
1815 than the value of \fIparameter\fP itself.
1816 This is known as \fIindirect expansion\fP.
1817 .PP
1818 In each of the cases below, \fIword\fP is subject to tilde expansion,
1819 parameter expansion, command substitution, and arithmetic expansion.
1820 When not performing substring expansion, \fBbash\fP tests for a parameter
1821 that is unset or null; omitting the colon results in a test only for a
1822 parameter that is unset.
1823 .PP
1824 .PD 0
1825 .TP
1826 ${\fIparameter\fP\fB:\-\fP\fIword\fP}
1827 \fBUse Default Values\fP.  If
1828 .I parameter
1829 is unset or null, the expansion of
1830 .I word
1831 is substituted.  Otherwise, the value of
1832 .I parameter
1833 is substituted.
1834 .TP
1835 ${\fIparameter\fP\fB:=\fP\fIword\fP}
1836 \fBAssign Default Values\fP.
1837 If
1838 .I parameter
1839 is unset or null, the expansion of
1840 .I word
1841 is assigned to
1842 .IR parameter .
1843 The value of
1844 .I parameter
1845 is then substituted.  Positional parameters and special parameters may
1846 not be assigned to in this way.
1847 .TP
1848 ${\fIparameter\fP\fB:?\fP\fIword\fP}
1849 \fBDisplay Error if Null or Unset\fP.
1850 If
1851 .I parameter
1852 is null or unset, the expansion of \fIword\fP (or a message to that effect
1853 if
1854 .I word
1855 is not present) is written to the standard error and the shell, if it
1856 is not interactive, exits.  Otherwise, the value of \fIparameter\fP is
1857 substituted.
1858 .TP
1859 ${\fIparameter\fP\fB:+\fP\fIword\fP}
1860 \fBUse Alternate Value\fP.
1861 If
1862 .I parameter
1863 is null or unset, nothing is substituted, otherwise the expansion of
1864 .I word
1865 is substituted.
1866 .TP
1867 .PD 0
1868 ${\fIparameter\fP\fB:\fP\fIoffset\fP}
1869 .TP
1870 ${\fIparameter\fP\fB:\fP\fIoffset\fP\fB:\fP\fIlength\fP}
1871 .PD
1872 \fBSubstring Expansion.\fP
1873 Expands to up to \fIlength\fP characters of \fIparameter\fP,
1874 starting at \fIoffset\fP.
1875 If \fIlength\fP is omitted, expands to the substring of
1876 \fIparameter\fP, starting at the character specified by \fIoffset\fP.
1877 \fIlength\fP and \fIoffset\fP are arithmetic expressions (see
1878 .SM
1879 .B
1880 ARITHMETIC EVALUATION
1881 below).
1882 \fIlength\fP must evaluate to a number greater than or equal to zero.
1883 If \fIoffset\fP evaluates to a number less than zero, the value
1884 is used as an offset from the end of the value of \fIparameter\fP.
1885 If \fIparameter\fP is \fB@\fP, the result is \fIlength\fP positional
1886 parameters beginning at \fIoffset\fP.
1887 If \fIparameter\fP is an array name indexed by @ or *,
1888 the result is the \fIlength\fP
1889 members of the array beginning with ${\fIparameter\fP[\fIoffset\fP]}.
1890 Substring indexing is zero-based unless the positional parameters are
1891 used, in which case the indexing starts at 1.
1892 .TP
1893 ${\fB#\fP\fIparameter\fP}
1894 The length in characters of the value of \fIparameter\fP is substituted.
1895 If
1896 .I parameter
1897 is
1898 .B *
1899 or 
1900 .BR @ ,
1901 the length substituted is the number of positional parameters.
1902 If
1903 .I parameter
1904 is an array name subscripted by
1905 .B *
1906 or
1907 .BR @ ,
1908 the length substituted is the number of elements in the array.
1909 .TP
1910 .PD 0
1911 ${\fIparameter\fP\fB#\fP\fIword\fP}
1912 .TP
1913 ${\fIparameter\fP\fB##\fP\fIword\fP}
1914 .PD
1915 The 
1916 .I word
1917 is expanded to produce a pattern just as in pathname
1918 expansion.  If the pattern matches the beginning of
1919 the value of
1920 .IR parameter ,
1921 then the expansion is the value of
1922 .I parameter
1923 with the shortest matching pattern (the ``\fB#\fP'' case) or the
1924 longest matching pattern (the ``\fB##\fP'' case) deleted.
1925 If
1926 .I parameter
1927 is
1928 .B @
1929 or
1930 .BR * ,
1931 the pattern removal operation is applied to each positional
1932 parameter in turn, and the expansion is the resultant list.
1933 If
1934 .I parameter
1935 is an array variable subscripted with
1936 .B @
1937 or
1938 .BR * ,
1939 the pattern removal operation is applied to each member of the
1940 array in turn, and the expansion is the resultant list.
1941 .TP
1942 .PD 0
1943 ${\fIparameter\fP\fB%\fP\fIword\fP}
1944 .TP
1945 ${\fIparameter\fP\fB%%\fP\fIword\fP}
1946 .PD
1947 The \fIword\fP is expanded to produce a pattern just as in
1948 pathname expansion.
1949 If the pattern matches a trailing portion of the value of
1950 .IR parameter ,
1951 then the expansion is the value of
1952 .I parameter
1953 with the shortest matching pattern (the ``\fB%\fP'' case) or the
1954 longest matching pattern (the ``\fB%%\fP'' case) deleted.
1955 If
1956 .I parameter
1957 is
1958 .B @
1959 or
1960 .BR * ,
1961 the pattern removal operation is applied to each positional
1962 parameter in turn, and the expansion is the resultant list.
1963 If
1964 .I parameter
1965 is an array variable subscripted with
1966 .B @
1967 or
1968 .BR * ,
1969 the pattern removal operation is applied to each member of the
1970 array in turn, and the expansion is the resultant list.
1971 .TP
1972 .PD 0
1973 ${\fIparameter\fP\fB/\fP\fIpattern\fP\fB/\fP\fIstring\fP}
1974 .TP
1975 ${\fIparameter\fP\fB//\fP\fIpattern\fP\fB/\fP\fIstring\fP}
1976 .PD
1977 The \fIpattern\fP is expanded to produce a pattern just as in
1978 pathname expansion.
1979 \fIParameter\fP is expanded and the longest match of \fIpattern\fP
1980 against its value is replaced with \fIstring\fP.
1981 In the first form, only the first match is replaced.
1982 The second form causes all matches of \fIpattern\fP to be
1983 replaced with \fIstring\fP.
1984 If \fIpattern\fP begins with \fB#\fP, it must match at the beginning
1985 of \fIstring\fP.
1986 If \fIpattern\fP begins with \fB%\fP, it must match at the end
1987 of \fIstring\fP.
1988 If \fIstring\fP is null, matches of \fIpattern\fP are deleted
1989 and the \fB/\fP following \fIpattern\fP may be omitted.
1990 If
1991 .I parameter
1992 is
1993 .B @
1994 or
1995 .BR * ,
1996 the substitution operation is applied to each positional
1997 parameter in turn, and the expansion is the resultant list.
1998 If
1999 .I parameter
2000 is an array variable subscripted with
2001 .B @
2002 or
2003 .BR * ,
2004 the substitution operation is applied to each member of the
2005 array in turn, and the expansion is the resultant list.
2006 .SS Command Substitution
2007 .PP
2008 \fICommand substitution\fP allows the output of a command to replace 
2009 the command name.  There are two forms:
2010 .PP
2011 .RS
2012 .PP
2013 \fB$(\fP\fIcommand\fP\|\fB)\fP
2014 .RE
2015 or
2016 .RS
2017 \fB`\fP\fIcommand\fP\fB`\fP
2018 .RE
2019 .PP
2020 .B Bash
2021 performs the expansion by executing \fIcommand\fP and
2022 replacing the command substitution with the standard output of the
2023 command, with any trailing newlines deleted.
2024 .PP
2025 When the old-style backquote form of substitution is used,
2026 backslash retains its literal meaning except when followed by
2027 .BR $ ,
2028 .BR ` ,
2029 or
2030 .BR \e .
2031 When using the $(\^\fIcommand\fP\|) form, all characters between the
2032 parentheses make up the command; none are treated specially.
2033 .PP
2034 Command substitutions may be nested.  To nest when using the old form,
2035 escape the inner backquotes with backslashes.
2036 .PP
2037 If the substitution appears within double quotes, word splitting and
2038 pathname expansion are not performed on the results.
2039 .SS Arithmetic Expansion
2040 .PP
2041 Arithmetic expansion allows the evaluation of an arithmetic expression
2042 and the substitution of the result.  The format for arithmetic expansion is:
2043 .RS
2044 .PP
2045 \fB$((\fP\fIexpression\fP\fB))\fP
2046 .RE
2047 .PP
2048 The
2049 .I expression
2050 is treated as if it were within double quotes, but a double quote
2051 inside the parentheses is not treated specially.
2052 All tokens in the expression undergo parameter expansion, string
2053 expansion, command substitution, and quote removal.
2054 Arithmetic substitutions may be nested.
2055 .PP
2056 The evaluation is performed according to the rules listed below under
2057 .SM
2058 .BR "ARITHMETIC EVALUATION" .
2059 If
2060 .I expression
2061 is invalid,
2062 .B bash
2063 prints a message indicating failure and no substitution occurs.
2064 .SS Process Substitution
2065 .PP
2066 \fIProcess substitution\fP is supported on systems that support named
2067 pipes (\fIFIFOs\fP) or the \fB/dev/fd\fP method of naming open files.
2068 It takes the form of
2069 \fB<(\fP\fIlist\^\fP\fB)\fP
2070 or
2071 \fB>(\fP\fIlist\^\fP\fB)\fP.
2072 The process \fIlist\fP is run with its input or output connected to a
2073 \fIFIFO\fP or some file in \fB/dev/fd\fP.  The name of this file is
2074 passed as an argument to the current command as the result of the
2075 expansion.  If the \fB>(\fP\fIlist\^\fP\fB)\fP form is used, writing to
2076 the file will provide input for \fIlist\fP.  If the
2077 \fB<(\fP\fIlist\^\fP\fB)\fP form is used, the file passed as an
2078 argument should be read to obtain the output of \fIlist\fP.
2079 .PP
2080 On systems that support it, \fIprocess substitution\fP is performed
2081 simultaneously with parameter and variable expansion, 
2082 command substitution,
2083 and arithmetic expansion.
2084 .SS Word Splitting
2085 .PP
2086 The shell scans the results of
2087 parameter expansion,
2088 command substitution,
2089 and
2090 arithmetic expansion
2091 that did not occur within double quotes for
2092 .IR "word splitting" .
2093 .PP
2094 The shell treats each character of
2095 .SM
2096 .B IFS
2097 as a delimiter, and splits the results of the other
2098 expansions into words on these characters.  If
2099 .SM
2100 .B IFS
2101 is unset, or its
2102 value is exactly
2103 .BR <space><tab><newline> ,
2104 the default, then
2105 any sequence of
2106 .SM
2107 .B IFS
2108 characters serves to delimit words.  If
2109 .SM
2110 .B IFS
2111 has a value other than the default, then sequences of
2112 the whitespace characters
2113 .B space
2114 and
2115 .B tab
2116 are ignored at the beginning and end of the
2117 word, as long as the whitespace character is in the
2118 value of
2119 .SM
2120 .BR IFS
2121 (an
2122 .SM
2123 .B IFS
2124 whitespace character).
2125 Any character in
2126 .SM
2127 .B IFS
2128 that is not
2129 .SM
2130 .B IFS
2131 whitespace, along with any adjacent
2132 .SM
2133 .B IFS
2134 whitespace characters, delimits a field.
2135 A sequence of
2136 .SM
2137 .B IFS
2138 whitespace characters is also treated as a delimiter.
2139 If the value of
2140 .SM
2141 .B IFS
2142 is null, no word splitting occurs.
2143 .PP
2144 Explicit null arguments (\^\f3"\^"\fP or \^\f3'\^'\fP\^) are retained.
2145 Unquoted implicit null arguments, resulting from the expansion of
2146 .I parameters
2147 that have no values, are removed.
2148 If a parameter with no value is expanded within double quotes, a
2149 null argument results and is retained.
2150 .PP
2151 Note that if no expansion occurs, no splitting
2152 is performed.
2153 .SS Pathname Expansion
2154 .PP
2155 After word splitting,
2156 unless the
2157 .B \-f
2158 option has been set,
2159 .B bash
2160 scans each word for the characters
2161 .BR * ,
2162 .BR ? ,
2163 and
2164 .BR [ .
2165 If one of these characters appears, then the word is
2166 regarded as a
2167 .IR pattern ,
2168 and replaced with an alphabetically sorted list of
2169 file names matching the pattern.
2170 If no matching file names are found,
2171 and the shell option
2172 .B nullglob
2173 is disabled, the word is left unchanged.
2174 If the option is set, and no matches are found,
2175 the word is removed.
2176 When a pattern is used for pathname expansion,
2177 the character
2178 .B ``.''
2179 at the start of a name or immediately following a slash
2180 must be matched explicitly, unless the shell option
2181 .B dotglob
2182 is set.
2183 The slash character must always be matched explicitly.
2184 In other cases, the
2185 .B ``.''
2186 character is not treated specially.
2187 See the description of
2188 .B shopt
2189 below under
2190 .SM
2191 .B SHELL BUILTIN COMMANDS
2192 for a description of the
2193 .B nullglob
2194 and
2195 .B dotglob
2196 shell options.
2197 .PP
2198 The
2199 .SM
2200 .B GLOBIGNORE
2201 shell variable may be used to restrict the set of file names matching a
2202 .IR pattern .
2203 If
2204 .SM
2205 .B GLOBIGNORE
2206 is set, each matching file name that also matches one of the patterns in
2207 .SM
2208 .B GLOBIGNORE
2209 is removed from the list of matches.
2210 The file names
2211 .B ``.''
2212 and
2213 .B ``..''
2214 are always ignored, even when
2215 .SM
2216 .B GLOBIGNORE
2217 is set.  However, setting
2218 .SM
2219 .B GLOBIGNORE
2220 has the effect of enabling the
2221 .B dotglob
2222 shell option, so all other file names beginning with a
2223 .B ``.''
2224 will match.
2225 To get the old behavior of ignoring file names beginning with a
2226 .BR ``.'' ,
2227 make
2228 .B ``.*''
2229 one of the patterns in
2230 .SM
2231 .BR GLOBIGNORE .
2232 The
2233 .B dotglob
2234 option is disabled when
2235 .SM
2236 .B GLOBIGNORE
2237 is unset.
2238 .PP
2239 The special pattern characters have the following meanings:
2240 .PP
2241 .PD 0
2242 .TP
2243 .B *
2244 Matches any string, including the null string.
2245 .TP
2246 .B ?
2247 Matches any single character.
2248 .TP
2249 .B [...]
2250 Matches any one of the enclosed characters.  A pair of characters
2251 separated by a minus sign denotes a
2252 .IR range ;
2253 any character lexically between those two characters, inclusive,
2254 is matched.  If the first character following the
2255 .B [
2256 is a
2257 .B !
2258 or a
2259 .B ^
2260 then any character not enclosed is matched.
2261
2262 .B \-
2263 may be matched by including it as the first or last character
2264 in the set.
2265 A
2266 .B ]
2267 may be matched by including it as the first character
2268 in the set.
2269 .PD
2270 .SS Quote Removal
2271 .PP
2272 After the preceding expansions, all unquoted occurrences of the
2273 characters
2274 .BR \e ,
2275 .BR ` ,
2276 and \^\f3"\fP\^ that did not result from one of the above
2277 expansions are removed.
2278 .SH REDIRECTION
2279 Before a command is executed, its input and output
2280 may be
2281 .I redirected
2282 using a special notation interpreted by the shell.
2283 Redirection may also be used to open and close files for the
2284 current shell execution environment.  The following redirection
2285 operators may precede or appear anywhere within a
2286 .I simple command
2287 or may follow a
2288 .IR command .
2289 Redirections are processed in the order they appear, from
2290 left to right.
2291 .PP
2292 In the following descriptions, if the file descriptor number is
2293 omitted, and the first character of the redirection operator is
2294 .BR < ,
2295 the redirection refers to the standard input (file descriptor
2296 0).  If the first character of the redirection operator is
2297 .BR > ,
2298 the redirection refers to the standard output (file descriptor
2299 1).
2300 .PP
2301 The word that follows the redirection operator in the following
2302 descriptions is subjected to brace expansion, tilde expansion,
2303 parameter expansion, command substitution, arithmetic expansion,
2304 quote removal, and pathname expansion.  If it expands to more
2305 than one word,
2306 .B bash
2307 reports an error.
2308 .PP
2309 Note that the order of redirections is significant.  For example, 
2310 the command
2311 .RS
2312 .PP
2313 ls \fB>\fP dirlist 2\fB>&\fP1
2314 .RE
2315 .PP
2316 directs both standard output and standard error to the file 
2317 .IR dirlist ,
2318 while the command
2319 .RS
2320 .PP
2321 ls 2\fB>&\fP1 \fB>\fP dirlist
2322 .RE
2323 .PP
2324 directs only the standard output to file
2325 .IR dirlist ,
2326 because the standard error was duplicated as standard output
2327 before the standard output was redirected to
2328 .IR dirlist .
2329 .SS Redirecting Input
2330 .PP
2331 Redirection of input causes the file whose name results from
2332 the expansion of
2333 .I word
2334 to be opened for reading on file descriptor
2335 .IR n ,
2336 or the standard input (file descriptor 0) if
2337 .I n
2338 is not specified.
2339 .PP
2340 The general format for redirecting input is:
2341 .RS
2342 .PP
2343 [\fIn\fP]\fB<\fP\fIword\fP
2344 .RE
2345 .SS Redirecting Output
2346 .PP
2347 Redirection of output causes the file whose name results from
2348 the expansion of
2349 .I word
2350 to be opened for writing on file descriptor
2351 .IR n ,
2352 or the standard output (file descriptor 1) if
2353 .I n
2354 is not specified.  If the file does not exist it is created;
2355 if it does exist it is truncated to zero size.
2356 .PP
2357 The general format for redirecting output is:
2358 .RS
2359 .PP
2360 [\fIn\fP]\fB>\fP\fIword\fP
2361 .RE
2362 .PP
2363 If the redirection operator is
2364 .BR > ,
2365 and the
2366 .B \-C
2367 option to the
2368 .B set
2369 builtin has been enabled, the redirection will fail if the filename
2370 whose name results from the expansion of \fIword\fP exists.
2371 If the redirection operator is
2372 .BR >| ,
2373 then the value of the
2374 .B \-C
2375 option to the
2376 .B set
2377 builtin command is not tested, and the redirection is attempted even
2378 if the file named by \fIword\fP exists.
2379 .SS Appending Redirected Output
2380 .PP
2381 Redirection of output in this fashion
2382 causes the file whose name results from
2383 the expansion of
2384 .I word
2385 to be opened for appending on file descriptor
2386 .IR n ,
2387 or the standard output (file descriptor 1) if
2388 .I n
2389 is not specified.  If the file does not exist it is created.
2390 .PP
2391 The general format for appending output is:
2392 .RS
2393 .PP
2394 [\fIn\fP]\fB>>\fP\fIword\fP
2395 .RE
2396 .PP
2397 .SS Redirecting Standard Output and Standard Error
2398 .PP
2399 .B Bash
2400 allows both the
2401 standard output (file descriptor 1) and
2402 the standard error output (file descriptor 2)
2403 to be redirected to the file whose name is the
2404 expansion of
2405 .I word
2406 with this construct.
2407 .PP
2408 There are two formats for redirecting standard output and
2409 standard error:
2410 .RS
2411 .PP
2412 \fB&>\fP\fIword\fP
2413 .RE
2414 and
2415 .RS
2416 \fB>&\fP\fIword\fP
2417 .RE
2418 .PP
2419 Of the two forms, the first is preferred.
2420 This is semantically equivalent to
2421 .RS
2422 .PP
2423 \fB>\fP\fIword\fP 2\fB>&\fP1
2424 .RE
2425 .SS Here Documents
2426 .PP
2427 This type of redirection instructs the shell to read input from the
2428 current source until a line containing only
2429 .I word
2430 (with no trailing blanks)
2431 is seen.  All of
2432 the lines read up to that point are then used as the standard
2433 input for a command.
2434 .PP
2435 The format of here-documents is as follows:
2436 .RS
2437 .PP
2438 .nf
2439 \fB<<\fP[\fB\-\fP]\fIword\fP
2440         \fIhere\-document\fP
2441 \fIdelimiter\fP
2442 .fi
2443 .RE
2444 .PP
2445 No parameter expansion, command substitution, pathname
2446 expansion, or arithmetic expansion is performed on
2447 .IR word .
2448 If any characters in
2449 .I word
2450 are quoted, the
2451 .I delimiter
2452 is the result of quote removal on
2453 .IR word ,
2454 and the lines in the here-document are not expanded.  Otherwise,
2455 all lines of the here-document are subjected to parameter expansion,
2456 command substitution, and arithmetic expansion.  In the latter
2457 case, the pair
2458 .B \e<newline>
2459 is ignored, and
2460 .B \e
2461 must be used to quote the characters
2462 .BR \e ,
2463 .BR $ ,
2464 and
2465 .BR ` .
2466 .PP
2467 If the redirection operator is
2468 .BR <<\- ,
2469 then all leading tab characters are stripped from input lines and the
2470 line containing
2471 .IR delimiter .
2472 This allows
2473 here-documents within shell scripts to be indented in a
2474 natural fashion.
2475 .SS "Duplicating File Descriptors"
2476 .PP
2477 The redirection operator
2478 .RS
2479 .PP
2480 [\fIn\fP]\fB<&\fP\fIword\fP
2481 .RE
2482 .PP
2483 is used to duplicate input file descriptors.
2484 If
2485 .I word
2486 expands to one or more digits, the file descriptor denoted by
2487 .I n
2488 is made to be a copy of that file descriptor.  If
2489 .I word
2490 evaluates to
2491 .BR \- ,
2492 file descriptor
2493 .I n
2494 is closed.  If
2495 .I n
2496 is not specified, the standard input (file descriptor 0) is used.
2497 .PP
2498 The operator
2499 .RS
2500 .PP
2501 [\fIn\fP]\fB>&\fP\fIword\fP
2502 .RE
2503 .PP
2504 is used similarly to duplicate output file descriptors.  If
2505 .I n
2506 is not specified, the standard output (file descriptor 1) is used.
2507 As a special case, if \fIn\fP is omitted, and \fIword\fP does not
2508 expand to one or more digits, the standard output and standard
2509 error are redirected as described previously.
2510 .SS "Opening File Descriptors for Reading and Writing"
2511 .PP
2512 The redirection operator
2513 .RS
2514 .PP
2515 [\fIn\fP]\fB<>\fP\fIword\fP
2516 .RE
2517 .PP
2518 causes the file whose name is the expansion of
2519 .I word
2520 to be opened for both reading and writing on file descriptor
2521 .IR n ,
2522 or on file descriptor 0 if
2523 .I n
2524 is not specified.  If the file does not exist, it is created.
2525 .SH ALIASES
2526 The shell maintains a list of
2527 .I aliases
2528 that may be set and unset with the
2529 .B alias
2530 and
2531 .B unalias
2532 builtin commands (see
2533 .SM
2534 .B SHELL BUILTIN COMMANDS
2535 below).
2536 The first word of each command, if unquoted,
2537 is checked to see if it has an
2538 alias.  If so, that word is replaced by the text of the alias.
2539 The alias name and the replacement text may contain any valid
2540 shell input, including the
2541 .I metacharacters
2542 listed above, with the exception that the alias name may not
2543 contain \fI=\fP.  The first word of the replacement text is tested
2544 for aliases, but a word that is identical to an alias being expanded
2545 is not expanded a second time.  This means that one may alias
2546 .B ls
2547 to
2548 .BR "ls \-F" ,
2549 for instance, and
2550 .B bash
2551 does not try to recursively expand the replacement text.
2552 If the last character of the alias value is a
2553 .IR blank ,
2554 then the next command
2555 word following the alias is also checked for alias expansion.
2556 .PP
2557 Aliases are created and listed with the
2558 .B alias
2559 command, and removed with the
2560 .B unalias
2561 command.
2562 .PP
2563 There is no mechanism for using arguments in the replacement text.
2564 If arguments are needed, a shell function should be used.
2565 .PP
2566 Aliases are not expanded when the shell is not interactive, unless
2567 the
2568 .B expand_aliases
2569 shell option is set using
2570 .B shopt
2571 (see the description of
2572 .B shopt
2573 under
2574 .SM
2575 \fBSHELL BUILTIN COMMANDS\fP
2576 below).
2577 .PP
2578 The rules concerning the definition and use of aliases are
2579 somewhat confusing.
2580 .B Bash
2581 always reads at least one complete line
2582 of input before executing any
2583 of the commands on that line.  Aliases are expanded when a
2584 command is read, not when it is executed.  Therefore, an
2585 alias definition appearing on the same line as another
2586 command does not take effect until the next line of input is read.
2587 The commands following the alias definition
2588 on that line are not affected by the new alias.
2589 This behavior is also an issue when functions are executed.
2590 Aliases are expanded when the function definition is read,
2591 not when the function is executed, because a function definition
2592 is itself a compound command.  As a consequence, aliases
2593 defined in a function are not available until after that
2594 function is executed.  To be safe, always put
2595 alias definitions on a separate line, and do not use
2596 .B alias
2597 in compound commands.
2598 .PP
2599 Note that for almost every purpose, aliases are superseded by
2600 shell functions.
2601 .SH FUNCTIONS
2602 A shell function, defined as described above under
2603 .SM
2604 .BR "SHELL GRAMMAR" ,
2605 stores a series of commands for later execution.
2606 Functions are executed in the context of the
2607 current shell; no new process is created to interpret
2608 them (contrast this with the execution of a shell script).
2609 When a function is executed, the arguments to the
2610 function become the positional parameters
2611 during its execution.  The special parameter
2612 .B #
2613 is updated to reflect the change.  Positional parameter 0
2614 is unchanged.  All other aspects of the shell execution
2615 environment are identical between a function and its caller
2616 with the exception that the
2617 .SM
2618 .B DEBUG
2619 trap (see the description of the
2620 .B trap
2621 builtin under
2622 .SM
2623 .B SHELL BUILTIN COMMANDS
2624 below) is not inherited.
2625 .PP
2626 Variables local to the function may be declared with the
2627 .B local
2628 builtin command.  Ordinarily, variables and their values
2629 are shared between the function and its caller.
2630 .PP
2631 If the builtin command
2632 .B return
2633 is executed in a function, the function completes and
2634 execution resumes with the next command after the function
2635 call.  When a function completes, the values of the
2636 positional parameters and the special parameter
2637 .B #
2638 are restored to the values they had prior to function
2639 execution.
2640 .PP
2641 Function names and definitions may be listed with the
2642 .B \-f
2643 option to the
2644 .B declare
2645 or
2646 .B typeset
2647 builtin commands.  The
2648 .B \-F
2649 option to
2650 .B declare
2651 or
2652 .B typeset
2653 will list the function names only.
2654 Functions may be exported so that subshells
2655 automatically have them defined with the
2656 .B \-f
2657 option to the 
2658 .B export
2659 builtin.
2660 .PP
2661 Functions may be recursive.  No limit is imposed on the number
2662 of recursive calls.
2663 .SH "COMMAND EXECUTION"
2664 After a command has been split into words, if it results in a
2665 simple command and an optional list of arguments, the following
2666 actions are taken.
2667 .PP
2668 If the command name contains no slashes, the shell attempts to
2669 locate it.  If there exists a shell function by that name, that
2670 function is invoked as described above in
2671 .SM
2672 .BR FUNCTIONS .
2673 If the name does not match a function, the shell searches for
2674 it in the list of shell builtins.  If a match is found, that
2675 builtin is invoked.
2676 .PP
2677 If the name is neither a shell function nor a builtin,
2678 and contains no slashes,
2679 .B bash
2680 searches each element of the
2681 .SM
2682 .B PATH
2683 for a directory containing an executable file by that name.
2684 .B Bash
2685 uses a hash table to remember the full file names of executable
2686 files (see
2687 .B hash
2688 under
2689 .SM
2690 .B "SHELL BUILTIN COMMANDS"
2691 below).
2692 A full search of the directories in
2693 .SM
2694 .B PATH
2695 is performed only if the command is not found in the hash table.
2696 If the search is unsuccessful, the shell prints an error
2697 message and returns a non-zero exit status.
2698 .PP
2699 If the search is successful, or if the command name contains
2700 one or more slashes, the shell executes the named program.
2701 Argument 0 is set to the name given, and the remaining arguments
2702 to the command are set to the arguments given, if any.
2703 .PP
2704 If this execution fails because the file is not in executable
2705 format, and the file is not a directory, it is assumed to be
2706 a \fIshell script\fP, a file
2707 containing shell commands.  A subshell is spawned to execute
2708 it.  This subshell reinitializes itself, so
2709 that the effect is as if a new shell had been invoked
2710 to handle the script, with the exception that the locations of
2711 commands remembered by the parent (see
2712 .B hash
2713 below under
2714 .SM
2715 \fBSHELL BUILTIN COMMANDS\fP)
2716 are retained by the child.
2717 .PP
2718 If the program is a file beginning with
2719 .BR #! ,
2720 the remainder of the first line specifies an interpreter
2721 for the program.  The shell executes the
2722 specified interpreter on operating systems that do not
2723 handle this executable format themselves.  The arguments to the 
2724 interpreter consist of a single optional argument following the
2725 interpreter name on the first line of the program, followed
2726 by the name of the program, followed by the command
2727 arguments, if any.
2728 .SH ENVIRONMENT
2729 When a program is invoked it is given an array of strings
2730 called the
2731 .IR environment .
2732 This is a list of 
2733 \fIname\fP\-\fIvalue\fP pairs, of the form
2734 .IR "name\fR=\fPvalue" .
2735 .PP
2736 The shell allows you to manipulate the environment in several
2737 ways.  On invocation, the shell scans its own environment and
2738 creates a parameter for each name found, automatically marking
2739 it for
2740 .I export
2741 to child processes.  Executed commands inherit the environment.
2742 The
2743 .B export
2744 and
2745 .B declare \-x
2746 commands allow parameters and functions to be added to and
2747 deleted from the environment.  If the value of a parameter
2748 in the environment is modified, the new value becomes part
2749 of the environment, replacing the old.  The environment
2750 inherited by any executed command consists of the shell's
2751 initial environment, whose values may be modified in the shell,
2752 less any pairs removed by the
2753 .B unset
2754 command, plus any additions via the
2755 .B export
2756 and
2757 .B declare \-x
2758 commands.
2759 .PP
2760 The environment for any
2761 .I simple command
2762 or function may be augmented temporarily by prefixing it with
2763 parameter assignments, as described above in
2764 .SM
2765 .BR PARAMETERS .
2766 These assignment statements affect only the environment seen
2767 by that command.
2768 .PP
2769 If the 
2770 .B \-k
2771 flag is set (see the
2772 .B set
2773 builtin command below), then
2774 .I all
2775 parameter assignments are placed in the environment for a command,
2776 not just those that precede the command name.
2777 .PP
2778 When
2779 .B bash
2780 invokes an external command, the variable
2781 .B _
2782 is set to the full file name of the command and passed to that
2783 command in its environment.
2784 .SH "EXIT STATUS"
2785 For the purposes of the shell, a command which exits with a 
2786 zero exit status has succeeded.  An exit status of zero
2787 indicates success.  A non-zero exit status indicates failure.
2788 When a command terminates on a fatal signal, \fBbash\fP uses
2789 the value of 128+\fBsignal\fP as the exit status.
2790 .PP
2791 If a command is not found, the child process created to
2792 execute it returns a status of 127.  If a command is found
2793 but is not executable, the return status is 126.
2794 .PP
2795 Shell builtin commands return a status of 0 (\fItrue\fP) if
2796 successful, and non-zero (\fIfalse\fP) if an error occurs
2797 while they execute. 
2798 All builtins return an exit status of 2 to indicate incorrect usage.
2799 .PP
2800 \fBBash\fP itself returns the exit status of the last command
2801 executed, unless a syntax error occurs, in which case it exits
2802 with a non-zero value.  See also the \fBexit\fP builtin
2803 command below.
2804 .SH SIGNALS
2805 When \fBbash\fP is interactive, it ignores
2806 .SM
2807 .B SIGTERM
2808 (so that \fBkill 0\fP does not kill an interactive shell),
2809 and
2810 .SM
2811 .B SIGINT
2812 is caught and handled (so that the \fBwait\fP builtin is interruptible).
2813 In all cases, \fBbash\fP ignores
2814 .SM
2815 .BR SIGQUIT .
2816 If job control is in effect,
2817 .B bash
2818 ignores
2819 .SM
2820 .BR SIGTTIN ,
2821 .SM
2822 .BR SIGTTOU ,
2823 and
2824 .SM
2825 .BR SIGTSTP .
2826 .PP
2827 Synchronous jobs started by \fBbash\fP have signals set to the
2828 values inherited by the shell from its parent.  When job control
2829 is not in effect, background jobs (jobs started with
2830 .BR & )
2831 ignore
2832 .SM
2833 .B SIGINT
2834 and
2835 .SM
2836 .BR SIGQUIT .
2837 Commands run as a result of command substitution ignore the
2838 keyboard-generated job control signals
2839 .SM
2840 .BR SIGTTIN ,
2841 .SM
2842 .BR SIGTTOU ,
2843 and
2844 .SM
2845 .BR SIGTSTP .
2846 .PP
2847 The shell exits by default upon receipt of a
2848 .SM
2849 .BR SIGHUP .
2850 Before exiting, it resends the
2851 .SM
2852 .B SIGHUP
2853 to all jobs, running or stopped.  To prevent the shell from
2854 sending the signal to a particular job, remove it from the
2855 jobs table with the 
2856 .B disown
2857 builtin (see
2858 .SM
2859 .B "SHELL BUILTIN COMMANDS"
2860 below) or use
2861 .B "disown \-h"
2862 to mark it to not receive
2863 .SM
2864 .BR SIGHUP .
2865 .SH "JOB CONTROL"
2866 .I Job control
2867 refers to the ability to selectively stop (\fIsuspend\fP)
2868 the execution of processes and continue (\fIresume\fP)
2869 their execution at a later point.  A user typically employs
2870 this facility via an interactive interface supplied jointly
2871 by the system's terminal driver and
2872 .BR bash .
2873 .PP
2874 The shell associates a
2875 .I job
2876 with each pipeline.  It keeps a table of currently executing
2877 jobs, which may be listed with the
2878 .B jobs
2879 command.  When
2880 .B bash
2881 starts a job asynchronously (in the
2882 .IR background ),
2883 it prints a line that looks like:
2884 .RS
2885 .PP
2886 [1] 25647
2887 .RE
2888 .PP
2889 indicating that this job is job number 1 and that the process ID
2890 of the last process in the pipeline associated with this job is 25647.
2891 All of the processes in a single pipeline are members of the same job.
2892 .B Bash
2893 uses the
2894 .I job
2895 abstraction as the basis for job control.
2896 .PP
2897 To facilitate the implementation of the user interface to job
2898 control, the system maintains the notion of a \fIcurrent terminal
2899 process group ID\fP.  Members of this process group (processes whose
2900 process group ID is equal to the current terminal process group ID)
2901 receive keyboard-generated signals such as
2902 .SM
2903 .BR SIGINT .
2904 These processes are said to be in the
2905 .IR foreground .
2906 .I Background
2907 processes are those whose process group ID differs from the terminal's;
2908 such processes are immune to keyboard-generated signals.
2909 Only foreground processes are allowed to read from or write to the
2910 terminal.  Background processes which attempt to read from (write to) the
2911 terminal are sent a 
2912 .SM
2913 .B SIGTTIN (SIGTTOU)
2914 signal by the terminal driver, 
2915 which, unless caught, suspends the process.
2916 .PP
2917 If the operating system on which
2918 .B bash
2919 is running supports
2920 job control,
2921 .B bash
2922 allows you to use it.
2923 Typing the
2924 .I suspend
2925 character (typically
2926 .BR ^Z ,
2927 Control-Z) while a process is running
2928 causes that process to be stopped and returns you to 
2929 .BR bash .
2930 Typing the
2931 .I "delayed suspend"
2932 character (typically
2933 .BR ^Y ,
2934 Control-Y) causes the process to be stopped when it
2935 attempts to read input from the terminal, and control to
2936 be returned to
2937 .BR bash .
2938 You may then manipulate the state of this job, using the
2939 .B bg
2940 command to continue it in the background, the
2941 .B fg
2942 command to continue it in the foreground, or
2943 the
2944 .B kill
2945 command to kill it.  A \fB^Z\fP takes effect immediately,
2946 and has the additional side effect of causing pending output
2947 and typeahead to be discarded.
2948 .PP
2949 There are a number of ways to refer to a job in the shell.
2950 The character
2951 .B %
2952 introduces a job name.  Job number
2953 .I n
2954 may be referred to as
2955 .BR %n .
2956 A job may also be referred to using a prefix of the name used to
2957 start it, or using a substring that appears in its command line.
2958 For example,
2959 .B %ce
2960 refers to a stopped
2961 .B ce
2962 job.  If a prefix matches more than one job,
2963 .B bash
2964 reports an error.  Using
2965 .BR %?ce ,
2966 on the other hand, refers to any job containing the string
2967 .B ce
2968 in its command line.  If the substring matches more than one job,
2969 .B bash
2970 reports an error.  The symbols
2971 .B %%
2972 and
2973 .B %+
2974 refer to the shell's notion of the
2975 .IR "current job" ,
2976 which is the last job stopped while it was in
2977 the foreground.
2978 The 
2979 .I "previous job"
2980 may be referenced using
2981 .BR %\- .
2982 In output pertaining to jobs (e.g., the output of the
2983 .B jobs
2984 command), the current job is always flagged with a
2985 .BR + ,
2986 and the previous job with a
2987 .BR \- .
2988 .PP
2989 Simply naming a job can be used to bring it into the
2990 foreground:
2991 .B %1
2992 is a synonym for
2993 \fB``fg %1''\fP,
2994 bringing job 1 from the background into the foreground.
2995 Similarly,
2996 .B ``%1 &''
2997 resumes job 1 in the background, equivalent to
2998 \fB``bg %1''\fP.
2999 .PP
3000 The shell learns immediately whenever a job changes state.
3001 Normally,
3002 .B bash
3003 waits until it is about to print a prompt before reporting
3004 changes in a job's status so as to not interrupt
3005 any other output.  If the 
3006 .B \-b
3007 option to the
3008 .B set
3009 builtin command
3010 is set,
3011 .B bash
3012 reports such changes immediately.
3013 .PP
3014 If an attempt to exit
3015 .B bash
3016 is made while jobs are stopped, the shell prints a warning message.  The
3017 .B jobs
3018 command may then be used to inspect their status.
3019 If a second attempt to exit is made without an intervening command,
3020 the shell does not print another warning, and the stopped
3021 jobs are terminated.
3022 .SH PROMPTING
3023 When executing interactively, 
3024 .B bash
3025 displays the primary prompt
3026 .SM
3027 .B PS1
3028 when it is ready to read a command, and the secondary prompt
3029 .SM
3030 .B PS2
3031 when it needs more input to complete a command.
3032 .B Bash
3033 allows these prompt strings to be customized by inserting a number of
3034 backslash-escaped special characters that are decoded as follows:
3035 .RS
3036 .PD 0
3037 .TP
3038 .B \ea
3039 an ASCII bell character (07)
3040 .TP
3041 .B \ed
3042 the date in "Weekday Month Date" format (e.g., "Tue May 26")
3043 .TP
3044 .B \ee
3045 an ASCII escape character (033)
3046 .TP
3047 .B \eh
3048 the hostname up to the first `.'
3049 .TP
3050 .B \eH
3051 the hostname
3052 .TP
3053 .B \en
3054 newline
3055 .TP
3056 .B \es
3057 the name of the shell, the basename of
3058 .B $0
3059 (the portion following the final slash)
3060 .TP
3061 .B \et
3062 the current time in 24-hour HH:MM:SS format
3063 .TP
3064 .B \eT
3065 the current time in 12-hour HH:MM:SS format
3066 .TP
3067 .B \e@
3068 the current time in 12-hour am/pm format
3069 .TP
3070 .B \eu
3071 the username of the current user
3072 .TP
3073 .B \ev
3074 the version of \fBbash\fP (e.g., 2.00)
3075 .TP
3076 .B \eV
3077 the release of \fBbash\fP, version + patchlevel (e.g., 2.00.0)
3078 .TP
3079 .B \ew
3080 the current working directory
3081 .TP
3082 .B \eW
3083 the basename of the current working directory
3084 .TP
3085 .B \e!
3086 the history number of this command
3087 .TP
3088 .B \e#
3089 the command number of this command
3090 .TP
3091 .B \e$
3092 if the effective UID is 0, a
3093 .BR # ,
3094 otherwise a
3095 .B $
3096 .TP
3097 .B \e\fInnn\fP
3098 the character corresponding to the octal number \fInnn\fP
3099 .TP
3100 .B \e\e
3101 a backslash
3102 .TP
3103 .B \e[
3104 begin a sequence of non-printing characters, which could be used to
3105 embed a terminal control sequence into the prompt
3106 .TP
3107 .B \e]
3108 end a sequence of non-printing characters
3109 .PD
3110 .RE
3111 .PP
3112 The command number and the history number are usually different:
3113 the history number of a command is its position in the history
3114 list, which may include commands restored from the history file
3115 (see
3116 .SM
3117 .B HISTORY
3118 below), while the command number is the position in the sequence
3119 of commands executed during the current shell session.
3120 After the string is decoded, it is expanded via
3121 parameter expansion, command substitution, arithmetic expansion,
3122 string expansion, and quote removal, subject to the value of the
3123 .B promptvars
3124 shell option (see the description of the
3125 .B shopt
3126 command under
3127 .SM
3128 .B "SHELL BUILTIN COMMANDS"
3129 below).
3130 .SH READLINE
3131 This is the library that handles reading input when using an interactive
3132 shell, unless the
3133 .B \-noediting
3134 option is given at shell invocation.
3135 By default, the line editing commands are similar to those of emacs.
3136 A vi-style line editing interface is also available.
3137 To turn off line editing after the shell is running, use the
3138 .B +o emacs
3139 or
3140 .B +o vi
3141 options to the
3142 .B set
3143 builtin (see
3144 .SM
3145 .B SHELL BUILTIN COMMANDS
3146 below).
3147 .SS "Readline Notation"
3148 .PP
3149 In this section, the emacs-style notation is used to denote
3150 keystrokes.  Control keys are denoted by C\-\fIkey\fR, e.g., C\-n
3151 means Control\-N.  Similarly, 
3152 .I meta
3153 keys are denoted by M\-\fIkey\fR, so M\-x means Meta\-X.  (On keyboards
3154 without a 
3155 .I meta
3156 key, M\-\fIx\fP means ESC \fIx\fP, i.e., press the Escape key
3157 then the
3158 .I x
3159 key.  This makes ESC the \fImeta prefix\fP.
3160 The combination M\-C\-\fIx\fP means ESC\-Control\-\fIx\fP,
3161 or press the Escape key
3162 then hold the Control key while pressing the
3163 .I x
3164 key.)
3165 .PP
3166 Readline commands may be given numeric
3167 .IR arguments ,
3168 which normally act as a repeat count.
3169 Sometimes, however, it is the sign of the argument that is significant.
3170 Passing a negative argument to a command that acts in the forward
3171 direction (e.g., \fBkill\-line\fP) causes that command to act in a
3172 backward direction. 
3173 Commands whose behavior with arguments deviates from this are noted
3174 below.
3175 .PP
3176 When a command is described as \fIkilling\fP text, the text
3177 deleted is saved for possible future retrieval
3178 (\fIyanking\fP).  The killed text is saved in a
3179 \fIkill ring\fP.  Consecutive kills cause the text to be
3180 accumulated into one unit, which can be yanked all at once. 
3181 Commands which do not kill text separate the chunks of text
3182 on the kill ring.
3183 .SS "Readline Initialization"
3184 .PP
3185 Readline is customized by putting commands in an initialization
3186 file (the \fIinputrc\fP file).
3187 The name of this file is taken from the value of the
3188 .SM
3189 .B INPUTRC
3190 variable.  If that variable is unset, the default is
3191 .IR ~/.inputrc .
3192 When a program which uses the readline library starts up, the
3193 initialization file is read, and the key bindings and variables
3194 are set.
3195 There are only a few basic constructs allowed in the
3196 readline initialization file.
3197 Blank lines are ignored.
3198 Lines beginning with a \fB#\fP are comments.
3199 Lines beginning with a \fB$\fP indicate conditional constructs.
3200 Other lines denote key bindings and variable settings.
3201 .PP
3202 The default key-bindings may be changed with an
3203 .I inputrc 
3204 file.
3205 Other programs that use this library may add their own commands
3206 and bindings.
3207 .PP
3208 For example, placing
3209 .RS
3210 .PP
3211 M\-Control\-u: universal\-argument
3212 .RE
3213 or
3214 .RS
3215 C\-Meta\-u: universal\-argument
3216 .RE
3217 into the 
3218 .I inputrc
3219 would make M\-C\-u execute the readline command
3220 .IR universal\-argument .
3221 .PP
3222 The following symbolic character names are recognized:
3223 .IR RUBOUT ,
3224 .IR DEL ,
3225 .IR ESC ,
3226 .IR LFD ,
3227 .IR NEWLINE ,
3228 .IR RET ,
3229 .IR RETURN ,
3230 .IR SPC ,
3231 .IR SPACE ,
3232 and
3233 .IR TAB .
3234 In addition to command names, readline allows keys to be bound
3235 to a string that is inserted when the key is pressed (a \fImacro\fP).
3236 .SS "Readline Key Bindings"
3237 .PP
3238 The syntax for controlling key bindings in the
3239 .I ~/.inputrc
3240 file is simple.  All that is required is the name of the
3241 command or the text of a macro and a key sequence to which
3242 it should be bound. The name may be specified in one of two ways:
3243 as a symbolic key name, possibly with \fIMeta\-\fP or \fIControl\-\fP
3244 prefixes, or as a key sequence.
3245 When using the form \fBkeyname\fP:\fIfunction\-name\fP or \fImacro\fP,
3246 .I keyname
3247 is the name of a key spelled out in English.  For example:
3248 .sp
3249 .RS
3250 Control-u: universal\-argument
3251 .br
3252 Meta-Rubout: backward-kill-word
3253 .br
3254 Control-o: "> output"
3255 .RE
3256 .LP
3257 In the above example,
3258 .I C\-u
3259 is bound to the function
3260 .BR universal\-argument ,
3261 .I M\-DEL
3262 is bound to the function
3263 .BR backward\-kill\-word ,
3264 and
3265 .I C\-o
3266 is bound to run the macro
3267 expressed on the right hand side (that is, to insert the text
3268 .I "> output"
3269 into the line).
3270 .PP
3271 In the second form, \fB"keyseq"\fP:\fIfunction\-name\fP or \fImacro\fP,
3272 .B keyseq
3273 differs from
3274 .B keyname
3275 above in that strings denoting
3276 an entire key sequence may be specified by placing the sequence
3277 within double quotes.  Some GNU Emacs style key escapes can be
3278 used, as in the following example.
3279 .sp
3280 .RS
3281 "\eC\-u": universal\-argument
3282 .br
3283 "\eC\-x\eC\-r": re\-read\-init\-file
3284 .br
3285 "\ee[11~": "Function Key 1"
3286 .RE
3287 .PP
3288 In this example,
3289 .I C\-u
3290 is again bound to the function
3291 .BR universal\-argument .
3292 .I "C\-x C\-r"
3293 is bound to the function
3294 .BR re\-read\-init\-file ,
3295 and 
3296 .I "ESC [ 1 1 ~"
3297 is bound to insert the text
3298 .BR "Function Key 1" .
3299 The full set of escape sequences is
3300 .RS
3301 .TP
3302 .B \eC\-
3303 control prefix
3304 .TP
3305 .B \eM\-
3306 meta prefix
3307 .TP
3308 .B \ee
3309 an escape character
3310 .TP
3311 .B \e\e
3312 backslash
3313 .TP
3314 .B \e"
3315 literal "
3316 .TP
3317 .B \e'
3318 literal '
3319 .RE
3320 .PP
3321 When entering the text of a macro, single or double quotes should
3322 be used to indicate a macro definition.  Unquoted text
3323 is assumed to be a function name.  Backslash
3324 will quote any character in the macro text, including " and '.
3325 .PP
3326 .B Bash
3327 allows the current readline key bindings to be displayed or modified
3328 with the
3329 .B bind
3330 builtin command.  The editing mode may be switched during interactive
3331 use by using the
3332 .B \-o
3333 option to the
3334 .B set
3335 builtin command (see
3336 .SM
3337 .B SHELL BUILTIN COMMANDS
3338 below).
3339 .SS "Readline Variables"
3340 .PP
3341 Readline has variables that can be used to further customize its
3342 behavior.  A variable may be set in the
3343 .I inputrc
3344 file with a statement of the form
3345 .RS
3346 .PP
3347 \fBset\fP \fIvariable\-name\fP \fIvalue\fP
3348 .RE
3349 .PP
3350 Except where noted, readline variables can take the values
3351 .B On
3352 or
3353 .BR Off .
3354 The variables and their default values are:
3355 .PP
3356 .PD 0
3357 .TP
3358 .B bell\-style (audible)
3359 Controls what happens when readline wants to ring the terminal bell.
3360 If set to \fBnone\fP, readline never rings the bell.  If set to
3361 \fBvisible\fP, readline uses a visible bell if one is available.
3362 If set to \fBaudible\fP, readline attempts to ring the terminal's bell.
3363 .TP
3364 .B comment\-begin (``#'')
3365 The string that is inserted when the
3366 .B readline
3367 .B insert\-comment
3368 command is executed.
3369 This command is bound to
3370 .B M\-#
3371 in emacs mode and to
3372 .B #
3373 in vi command mode.
3374 .TP
3375 .B completion\-query\-items (100)
3376 This determines when the user is queried about viewing
3377 the number of possible completions
3378 generated by the \fBpossible\-completions\fP command.
3379 It may be set to any integer value greater than or equal to
3380 zero.  If the number of possible completions is greater than
3381 or equal to the value of this variable, the user is asked whether
3382 or not he wishes to view them; otherwise they are simply listed
3383 on the terminal.
3384 .TP
3385 .B convert\-meta (On)
3386 If set to \fBOn\fP, readline will convert characters with the
3387 eighth bit set to an ASCII key sequence
3388 by stripping the eighth bit and prepending an
3389 escape character (in effect, using escape as the \fImeta prefix\fP).
3390 .TP
3391 .B disable\-completion (Off)
3392 If set to \fBOn\fP, readline will inhibit word completion.  Completion
3393 characters will be inserted into the line as if they had been
3394 mapped to \fBself-insert\fP.
3395 .TP
3396 .B editing\-mode (emacs)
3397 Controls whether readline begins with a set of key bindings similar
3398 to \fIemacs\fP or \fIvi\fP.
3399 .B editing\-mode
3400 can be set to either
3401 .B emacs
3402 or
3403 .BR vi .
3404 .TP
3405 .B enable\-keypad (Off)
3406 When set to \fBOn\fP, readline will try to enable the application
3407 keypad when it is called.  Some systems need this to enable the
3408 arrow keys.
3409 .TP
3410 .B expand\-tilde (Off)
3411 If set to \fBon\fP, tilde expansion is performed when readline
3412 attempts word completion.
3413 .TP
3414 .B horizontal\-scroll\-mode (Off)
3415 When set to \fBOn\fP, makes readline use a single line for display,
3416 scrolling the input horizontally on a single screen line when it
3417 becomes longer than the screen width rather than wrapping to a new line.
3418 .TP
3419 .B input\-meta (Off)
3420 If set to \fBOn\fP, readline will enable eight-bit input (that is,
3421 it will not strip the high bit from the characters it reads),
3422 regardless of what the terminal claims it can support.  The name
3423 .B meta\-flag
3424 is a synonym for this variable.
3425 .TP
3426 .B keymap (emacs)
3427 Set the current readline keymap.  The set of legal keymap names is
3428 \fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi,
3429 vi\-command\fP, and
3430 .IR vi\-insert .
3431 \fIvi\fP is equivalent to \fIvi\-command\fP; \fIemacs\fP is
3432 equivalent to \fIemacs\-standard\fP.  The default value is
3433 .IR emacs ;
3434 the value of
3435 .B editing\-mode
3436 also affects the default keymap.
3437 .TP
3438 .B mark\-directories (On)
3439 If set to \fBOn\fP, completed directory names have a slash
3440 appended.
3441 .TP
3442 .B mark\-modified\-lines (Off)
3443 If set to \fBOn\fP, history lines that have been modified are displayed
3444 with a preceding asterisk (\fB*\fP).
3445 .TP
3446 .B output\-meta (Off)
3447 If set to \fBOn\fP, readline will display characters with the
3448 eighth bit set directly rather than as a meta-prefixed escape
3449 sequence.
3450 .TP
3451 .B show\-all\-if\-ambiguous (Off)
3452 This alters the default behavior of the completion functions.  If
3453 set to
3454 .BR on ,
3455 words which have more than one possible completion cause the
3456 matches to be listed immediately instead of ringing the bell.
3457 .TP
3458 .B visible\-stats (Off)
3459 If set to \fBOn\fP, a character denoting a file's type as reported
3460 by \fIstat\fP(2) is appended to the filename when listing possible
3461 completions.
3462 .PD
3463 .SS "Readline Conditional Constructs"
3464 .PP
3465 Readline implements a facility similar in spirit to the conditional
3466 compilation features of the C preprocessor which allows key
3467 bindings and variable settings to be performed as the result
3468 of tests.  There are three parser directives used.
3469 .IP \fB$if\fP
3470 The 
3471 .B $if
3472 construct allows bindings to be made based on the
3473 editing mode, the terminal being used, or the application using
3474 readline.  The text of the test extends to the end of the line;
3475 no characters are required to isolate it.
3476 .RS
3477 .IP \fBmode\fP
3478 The \fBmode=\fP form of the \fB$if\fP directive is used to test
3479 whether readline is in emacs or vi mode.
3480 This may be used in conjunction
3481 with the \fBset keymap\fP command, for instance, to set bindings in
3482 the \fIemacs\-standard\fP and \fIemacs\-ctlx\fP keymaps only if
3483 readline is starting out in emacs mode.
3484 .IP \fBterm\fP
3485 The \fBterm=\fP form may be used to include terminal-specific
3486 key bindings, perhaps to bind the key sequences output by the
3487 terminal's function keys.  The word on the right side of the
3488 .B =
3489 is tested against the full name of the terminal and the portion
3490 of the terminal name before the first \fB\-\fP.  This allows
3491 .I sun
3492 to match both
3493 .I sun
3494 and
3495 .IR sun\-cmd ,
3496 for instance.
3497 .IP \fBapplication\fP
3498 The \fBapplication\fP construct is used to include
3499 application-specific settings.  Each program using the readline
3500 library sets the \fIapplication name\fP, and an initialization
3501 file can test for a particular value.
3502 This could be used to bind key sequences to functions useful for
3503 a specific program.  For instance, the following command adds a
3504 key sequence that quotes the current or previous word in Bash:
3505 .RS
3506 .nf
3507 \fB$if\fP Bash
3508 # Quote the current or previous word
3509 "\eC\-xq": "\eeb\e"\eef\e""
3510 \fB$endif\fP
3511 .fi
3512 .RE
3513 .RE
3514 .IP \fB$endif\fP
3515 This command, as you saw in the previous example, terminates an
3516 \fB$if\fP command.
3517 .IP \fB$else\fP
3518 Commands in this branch of the \fB$if\fP directive are executed if
3519 the test fails.
3520 .SS Searching
3521 .PP
3522 Readline provides commands for searching through the command history
3523 (see
3524 .SM
3525 .B HISTORY
3526 below) for lines containing a specified string.
3527 There are two search modes:
3528 .I incremental
3529 and
3530 .IR non-incremental .
3531 .PP
3532 Incremental searches begin before the user has finished typing the
3533 search string.
3534 As each character of the search string is typed, readline displays
3535 the next entry from the history matching the string typed so far.
3536 An incremental search requires only as many characters as needed to
3537 find the desired history entry.
3538 The Escape character is used to terminate an incremental search.
3539 Control-J will also terminate the search.
3540 Control-G will abort an incremental search and restore the original
3541 line.
3542 When the search is terminated, the history entry containing the
3543 search string becomes the current line.
3544 To find other matching entries in the history list, type Control-S or
3545 Control-R as appropriate.
3546 This will search backward or forward in the history for the next
3547 entry matching the search string typed so far.
3548 Any other key sequence bound to a readline command will terminate
3549 the search and execute that command.
3550 For instance, a \fInewline\fP will terminate the search and accept
3551 the line, thereby executing the command from the history list.
3552 .PP
3553 Non-incremental searches read the entire search string before starting
3554 to search for matching history lines.  The search string may be
3555 typed by the user or part of the contents of the current line.
3556 .SS "Readline Command Names"
3557 .PP
3558 The following is a list of the names of the commands and the default
3559 key sequences to which they are bound.
3560 Command names without an accompanying key sequence are unbound by default.
3561 .SS Commands for Moving
3562 .PP
3563 .PD 0
3564 .TP
3565 .B beginning\-of\-line (C\-a)
3566 Move to the start of the current line.
3567 .TP
3568 .B end\-of\-line (C\-e)
3569 Move to the end of the line.
3570 .TP
3571 .B forward\-char (C\-f)
3572 Move forward a character.
3573 .TP
3574 .B backward\-char (C\-b)
3575 Move back a character.
3576 .TP
3577 .B forward\-word (M\-f)
3578 Move forward to the end of the next word.  Words are composed of
3579 alphanumeric characters (letters and digits).
3580 .TP
3581 .B backward\-word (M\-b)
3582 Move back to the start of this, or the previous, word.  Words are
3583 composed of alphanumeric characters (letters and digits).
3584 .TP
3585 .B clear\-screen (C\-l)
3586 Clear the screen leaving the current line at the top of the screen.
3587 With an argument, refresh the current line without clearing the
3588 screen.
3589 .TP
3590 .B redraw\-current\-line
3591 Refresh the current line.
3592 .PD
3593 .SS Commands for Manipulating the History
3594 .PP
3595 .PD 0
3596 .TP
3597 .B accept\-line (Newline, Return)
3598 Accept the line regardless of where the cursor is.  If this line is
3599 non-empty, add it to the history list according to the state of the
3600 .SM
3601 .B HISTCONTROL
3602 variable.  If the line is a modified history
3603 line, then restore the history line to its original state.
3604 .TP
3605 .B previous\-history (C\-p)
3606 Fetch the previous command from the history list, moving back in
3607 the list.
3608 .TP
3609 .B next\-history (C\-n)
3610 Fetch the next command from the history list, moving forward in the
3611 list.
3612 .TP
3613 .B beginning\-of\-history (M\-<)
3614 Move to the first line in the history.
3615 .TP
3616 .B end\-of\-history (M\->)
3617 Move to the end of the input history, i.e., the line currently being
3618 entered.
3619 .TP
3620 .B reverse\-search\-history (C\-r)
3621 Search backward starting at the current line and moving `up' through
3622 the history as necessary.  This is an incremental search.
3623 .TP
3624 .B forward\-search\-history (C\-s)
3625 Search forward starting at the current line and moving `down' through
3626 the history as necessary.  This is an incremental search.
3627 .TP
3628 .B non\-incremental\-reverse\-search\-history (M\-p)
3629 Search backward through the history starting at the current line
3630 using a non-incremental search for a string supplied by the user.
3631 .TP
3632 .B non\-incremental\-forward\-search\-history (M\-n)
3633 Search forward through the history using a non-incremental search for
3634 a string supplied by the user.
3635 .TP
3636 .B history\-search\-forward
3637 Search forward through the history for the string of characters
3638 between the start of the current line and the current cursor
3639 position (the \fIpoint\fP).
3640 This is a non-incremental search.
3641 .TP
3642 .B history\-search\-backward
3643 Search backward through the history for the string of characters
3644 between the start of the current line and the point.
3645 This is a non-incremental search.
3646 .TP
3647 .B yank\-nth\-arg (M\-C\-y)
3648 Insert the first argument to the previous command (usually
3649 the second word on the previous line) at point (the current
3650 cursor position).  With an argument
3651 .IR n ,
3652 insert the \fIn\fPth word from the previous command (the words
3653 in the previous command begin with word 0).  A negative argument
3654 inserts the \fIn\fPth word from the end of the previous command.
3655 .TP
3656 .B
3657 yank\-last\-arg (M\-.\^, M\-_\^)
3658 Insert the last argument to the previous command (the last word of
3659 the previous history entry).  With an argument,
3660 behave exactly like \fByank\-nth\-arg\fP.
3661 .TP
3662 .B shell\-expand\-line (M\-C\-e)
3663 Expand the line the way the shell does when it reads it.  This
3664 performs alias and history expansion as well as all of the shell
3665 word expansions.  See
3666 .SM
3667 .B HISTORY EXPANSION
3668 below for a description of history expansion.
3669 .TP
3670 .B history\-expand\-line (M\-^)
3671 Perform history expansion on the current line.  See
3672 .SM
3673 .B HISTORY EXPANSION
3674 below for a description of history expansion.
3675 .TP
3676 .B insert\-last\-argument (M\-.\^, M\-_\^)
3677 A synonym for \fByank\-last\-arg\fP.
3678 .TP
3679 .B operate\-and\-get\-next (C\-o)
3680 Accept the current line for execution and fetch the next line
3681 relative to the current line from the history for editing.  Any
3682 argument is ignored.
3683 .PD
3684 .SS Commands for Changing Text
3685 .PP
3686 .PD 0
3687 .TP
3688 .B delete\-char (C\-d)
3689 Delete the character under the cursor.  If point is at the
3690 beginning of the line, there are no characters in the line, and
3691 the last character typed was not
3692 .BR C\-d ,
3693 then return
3694 .SM
3695 .BR EOF .
3696 .TP
3697 .B backward\-delete\-char (Rubout)
3698 Delete the character behind the cursor.  When given a numeric argument,
3699 save the deleted text on the kill ring.
3700 .TP
3701 .B quoted\-insert (C\-q, C\-v)
3702 Add the next character that you type to the line verbatim.  This is
3703 how to insert characters like \fBC\-q\fP, for example.
3704 .TP
3705 .B tab\-insert (C\-v TAB)
3706 Insert a tab character.
3707 .TP
3708 .B self\-insert (a,\ b,\ A,\ 1,\ !,\ ...)
3709 Insert the character typed.
3710 .TP
3711 .B transpose\-chars (C\-t)
3712 Drag the character before point forward over the character at point.
3713 Point moves forward as well.  If point is at the end of the line, then
3714 transpose the two characters before point.  Negative arguments don't work.
3715 .TP
3716 .B transpose\-words (M\-t)
3717 Drag the word behind the cursor past the word in front of the cursor
3718 moving the cursor over that word as well.
3719 .TP
3720 .B upcase\-word (M\-u)
3721 Uppercase the current (or following) word.  With a negative argument,
3722 do the previous word, but do not move point.
3723 .TP
3724 .B downcase\-word (M\-l)
3725 Lowercase the current (or following) word.  With a negative argument,
3726 do the previous word, but do not move point.
3727 .TP
3728 .B capitalize\-word (M\-c)
3729 Capitalize the current (or following) word.  With a negative argument,
3730 do the previous word, but do not move point.
3731 .PD
3732 .SS Killing and Yanking
3733 .PP
3734 .PD 0
3735 .TP
3736 .B kill\-line (C\-k)
3737 Kill the text from the current cursor position to the end of the line.
3738 .TP
3739 .B backward\-kill\-line (C\-x Rubout)
3740 Kill backward to the beginning of the line.
3741 .TP
3742 .B unix\-line\-discard (C\-u)
3743 Kill backward from point to the beginning of the line.
3744 .\" There is no real difference between this and backward-kill-line
3745 .TP
3746 .B kill\-whole\-line
3747 Kill all characters on the current line, no matter where the
3748 cursor is.
3749 .TP
3750 .B kill\-word  (M\-d)
3751 Kill from the cursor to the end of the current word, or if between
3752 words, to the end of the next word.  Word boundaries are the same as
3753 those used by \fBforward\-word\fP.
3754 .TP
3755 .B backward\-kill\-word (M\-Rubout)
3756 Kill the word behind the cursor.  Word boundaries are the same as
3757 those used by \fBbackward\-word\fP.
3758 .TP
3759 .B unix\-word\-rubout (C\-w)
3760 Kill the word behind the cursor, using white space as a word boundary.
3761 The word boundaries are different from \fBbackward\-kill\-word\fP.
3762 .TP
3763 .B delete\-horizontal\-space (M\-\e)
3764 Delete all spaces and tabs around point.
3765 .TP
3766 .B kill\-region
3767 Kill the text between the point and \fImark\fP (saved cursor position).
3768 This text is referred to as the \fIregion\fP.
3769 .TP
3770 .B copy\-region\-as\-kill
3771 Copy the text in the region to the kill buffer.
3772 .TP
3773 .B copy\-backward\-word
3774 Copy the word before point to the kill buffer.
3775 .TP
3776 .B copy\-forward\-word
3777 Copy the word following point to the kill buffer.
3778 .TP
3779 .B yank (C\-y)
3780 Yank the top of the kill ring into the buffer at the cursor.
3781 .TP
3782 .B yank\-pop (M\-y)
3783 Rotate the kill ring, and yank the new top.  Only works following
3784 .B yank
3785 or
3786 .BR yank\-pop .
3787 .PD
3788 .SS Numeric Arguments
3789 .PP
3790 .PD 0
3791 .TP
3792 .B digit\-argument (M\-0, M\-1, ..., M\-\-)
3793 Add this digit to the argument already accumulating, or start a new
3794 argument.  M\-\- starts a negative argument.
3795 .TP
3796 .B universal\-argument
3797 Each time this is executed, the argument count is multiplied by four.
3798 The argument count is initially one, so executing this function the
3799 first time makes the argument count four.
3800 .PD
3801 .SS Completing
3802 .PP
3803 .PD 0
3804 .TP
3805 .B complete (TAB)
3806 Attempt to perform completion on the text before point.
3807 .B Bash
3808 attempts completion treating the text as a variable (if the
3809 text begins with \fB$\fP), username (if the text begins with
3810 \fB~\fP), hostname (if the text begins with \fB@\fP), or
3811 command (including aliases and functions) in turn.  If none
3812 of these produces a match, filename completion is attempted.
3813 .TP
3814 .B possible\-completions (M\-?)
3815 List the possible completions of the text before point.
3816 .TP
3817 .B insert\-completions (M\-*)
3818 Insert all completions of the text before point
3819 that would have been generated by
3820 \fBpossible\-completions\fP.
3821 .TP
3822 .B complete\-filename (M\-/)
3823 Attempt filename completion on the text before point.
3824 .TP
3825 .B possible\-filename\-completions (C\-x /)
3826 List the possible completions of the text before point,
3827 treating it as a filename.
3828 .TP
3829 .B complete\-username (M\-~)
3830 Attempt completion on the text before point, treating
3831 it as a username.
3832 .TP
3833 .B possible\-username\-completions (C\-x ~)
3834 List the possible completions of the text before point,
3835 treating it as a username.
3836 .TP
3837 .B complete\-variable (M\-$)
3838 Attempt completion on the text before point, treating
3839 it as a shell variable.
3840 .TP
3841 .B possible\-variable\-completions (C\-x $)
3842 List the possible completions of the text before point,
3843 treating it as a shell variable.
3844 .TP
3845 .B complete\-hostname (M\-@)
3846 Attempt completion on the text before point, treating
3847 it as a hostname.
3848 .TP
3849 .B possible\-hostname\-completions (C\-x @)
3850 List the possible completions of the text before point,
3851 treating it as a hostname.
3852 .TP
3853 .B complete\-command (M\-!)
3854 Attempt completion on the text before point, treating
3855 it as a command name.  Command completion attempts to
3856 match the text against aliases, reserved words, shell
3857 functions, builtins, and finally executable filenames,
3858 in that order.
3859 .TP
3860 .B possible\-command\-completions (C\-x !)
3861 List the possible completions of the text before point,
3862 treating it as a command name.
3863 .TP
3864 .B dynamic\-complete\-history (M\-TAB)
3865 Attempt completion on the text before point, comparing
3866 the text against lines from the history list for possible
3867 completion matches.
3868 .TP
3869 .B complete\-into\-braces (M\-{)
3870 Perform filename completion and return the list of possible completions
3871 enclosed within braces so the list is available to the shell (see
3872 .B Brace Expansion
3873 above).
3874 .PD
3875 .SS Keyboard Macros
3876 .PP
3877 .PD 0
3878 .TP
3879 .B start\-kbd\-macro (C\-x (\^)
3880 Begin saving the characters typed into the current keyboard macro.
3881 .TP
3882 .B end\-kbd\-macro (C\-x )\^)
3883 Stop saving the characters typed into the current keyboard macro
3884 and store the definition.
3885 .TP
3886 .B call\-last\-kbd\-macro (C\-x e)
3887 Re-execute the last keyboard macro defined, by making the characters
3888 in the macro appear as if typed at the keyboard.
3889 .PD
3890 .SS Miscellaneous
3891 .PP
3892 .PD 0
3893 .TP
3894 .B re\-read\-init\-file (C\-x C\-r)
3895 Read in the contents of the \fIinputrc\fP file, and incorporate
3896 any bindings or variable assignments found there.
3897 .TP
3898 .B abort (C\-g)
3899 Abort the current editing command and
3900 ring the terminal's bell (subject to the setting of
3901 .BR bell\-style ).
3902 .TP
3903 .B do\-uppercase\-version (M\-a, M\-b, M\-\fIx\fP, ...)
3904 If the metafied character \fIx\fP is lowercase, run the command
3905 that is bound to the corresponding uppercase character.
3906 .TP
3907 .B prefix\-meta (ESC)
3908 Metafy the next character typed.
3909 .SM
3910 .B ESC
3911 .B f
3912 is equivalent to
3913 .BR Meta\-f .
3914 .TP
3915 .B undo (C\-_, C\-x C\-u)
3916 Incremental undo, separately remembered for each line.
3917 .TP
3918 .B revert\-line (M\-r)
3919 Undo all changes made to this line.  This is like typing the
3920 .B undo
3921 command enough times to return the line to its initial state.
3922 .TP
3923 .B tilde\-expand (M\-~)
3924 Perform tilde expansion on the current word.
3925 .TP
3926 .B set\-mark (C\-@, M\-<space>)
3927 Set the mark to the current point.  If a
3928 numeric argument is supplied, the mark is set to that position.
3929 .TP
3930 .B exchange\-point\-and\-mark (C\-x C\-x)
3931 Swap the point with the mark.  The current cursor position is set to
3932 the saved position, and the old cursor position is saved as the mark.
3933 .TP
3934 .B character\-search (C\-])
3935 A character is read and point is moved to the next occurrence of that
3936 character.  A negative count searches for previous occurrences.
3937 .TP
3938 .B character\-search\-backward (M\-C\-])
3939 A character is read and point is moved to the previous occurrence of that
3940 character.  A negative count searches for subsequent occurrences.
3941 .TP
3942 .B insert\-comment (M\-#)
3943 The value of the
3944 .B readline
3945 .B comment\-begin
3946 variable is inserted at the beginning of the current line, and the line
3947 is accepted as if a newline had been typed.  This makes the current line
3948 a shell comment.
3949 .TP
3950 .B glob\-expand\-word (C\-x *)
3951 The word before point is treated as a pattern for pathname expansion,
3952 and the list of matching file names is inserted, replacing the word.
3953 .TP
3954 .B glob\-list\-expansions (C\-x g)
3955 The list of expansions that would have been generated by
3956 .B glob\-expand\-word
3957 is displayed, and the line is redrawn.
3958 .TP
3959 .B dump\-functions
3960 Print all of the functions and their key bindings to the
3961 readline output stream.  If a numeric argument is supplied,
3962 the output is formatted in such a way that it can be made part
3963 of an \fIinputrc\fP file.
3964 .TP
3965 .B dump\-variables
3966 Print all of the settable readline variables and their values to the
3967 readline output stream.  If a numeric argument is supplied,
3968 the output is formatted in such a way that it can be made part
3969 of an \fIinputrc\fP file.
3970 .TP
3971 .B dump\-macros
3972 Print all of the readline key sequences bound to macros and the
3973 strings they ouput.  If a numeric argument is supplied,
3974 the output is formatted in such a way that it can be made part
3975 of an \fIinputrc\fP file.
3976 .TP
3977 .B display\-shell\-version (C\-x C\-v)
3978 Display version information about the current instance of
3979 .BR bash .
3980 .PD
3981 .SH HISTORY
3982 When the
3983 .B -o history
3984 option to the
3985 .B set
3986 builtin is enabled, the shell provides access to the
3987 \fIcommand history\fP,
3988 the list of commands previously typed.  The text of the last
3989 .SM
3990 .B HISTSIZE
3991 commands (default 500) is saved in a history list.  The shell
3992 stores each command in the history list prior to parameter and
3993 variable expansion (see
3994 .SM
3995 .B EXPANSION
3996 above) but after history expansion is performed, subject to the
3997 values of the shell variables
3998 .SM
3999 .B HISTIGNORE
4000 and
4001 .SM
4002 .BR HISTCONTROL .
4003 On startup, the history is initialized from the file named by
4004 the variable
4005 .SM
4006 .B HISTFILE
4007 (default \fI~/.bash_history\fP).
4008 .SM
4009 .B HISTFILE
4010 is truncated, if necessary, to contain no more than
4011 .SM
4012 .B HISTFILESIZE
4013 lines.
4014 When an interactive shell exits, the last
4015 .SM
4016 .B HISTSIZE
4017 lines are copied from the history list to
4018 .SM
4019 .BR HISTFILE .
4020 If the
4021 .B histappend
4022 shell option is enabled
4023 (see the description of
4024 .B shopt
4025 under
4026 .SM
4027 .B "SHELL BUILTIN COMMANDS"
4028 below), the lines are appended to the history file,
4029 otherwise the history file is overwritten.
4030 If
4031 .SM
4032 .B HISTFILE
4033 is unset, or if the history file is unwritable, the history is
4034 not saved.  After saving the history, the history file is truncated
4035 to contain no more than
4036 .SM
4037 .B HISTFILESIZE
4038 lines.  If
4039 .SM
4040 .B HISTFILESIZE
4041 is not set, no truncation is performed.
4042 .PP
4043 The builtin command
4044 .B fc
4045 (see
4046 .SM
4047 .B SHELL BUILTIN COMMANDS
4048 below) may be used to list or edit and re-execute a portion of
4049 the history list.
4050 The
4051 .B history
4052 builtin can be used to display or modify the history list and
4053 manipulate the history file.
4054 When using the command-line editing, search commands
4055 are available in each editing mode that provide access to the
4056 history list.
4057 .PP
4058 The shell allows control over which commands are saved on the history
4059 list.  The
4060 .SM
4061 .B HISTCONTROL
4062 and
4063 .SM
4064 .B HISTIGNORE
4065 variables may be set to cause the shell to save only a subset of the
4066 commands entered.
4067 The
4068 .B cmdhist
4069 shell option, if enabled, causes the shell to attempt to save each
4070 line of a multi-line command in the same history entry, adding
4071 semicolons where necessary to preserve syntactic correctness.
4072 The
4073 .B lithist
4074 shell option causes the shell to save the command with embedded newlines
4075 instead of semicolons.  See the description of the
4076 .B shopt
4077 builtin below under
4078 .SM
4079 .B "SHELL BUILTIN COMMANDS"
4080 for information on setting and unsetting shell options.
4081 .SH "HISTORY EXPANSION"
4082 .PP
4083 The shell supports a history expansion feature that
4084 is similar to the history expansion in
4085 .BR csh.
4086 This section describes what syntax features are available.  This
4087 feature is enabled by default for interactive shells, and can be
4088 disabled using the
4089 .B \+H
4090 option to the
4091 .B set
4092 builtin command (see
4093 .SM
4094 .B SHELL BUILTIN COMMANDS
4095 below).  Non-interactive shells do not perform history expansion
4096 by default.
4097 .PP
4098 History expansions introduce words from the history list into
4099 the input stream, making it easy to repeat commands, insert the
4100 arguments to a previous command into the current input line, or
4101 fix errors in previous commands quickly.
4102 .PP
4103 History expansion is performed immediately after a complete line
4104 is read, before the shell breaks it into words.
4105 It takes place in two parts.
4106 The first is to determine which line from the previous history
4107 to use during substitution.
4108 The second is to select portions of that line for inclusion into
4109 the current one.
4110 The line selected from the previous history is the \fIevent\fP,
4111 and the portions of that line that are acted upon are \fIwords\fP.
4112 Various \fImodifiers\fP are available to manipulate the selected words.
4113 The line is broken into words in the same fashion as when reading input,
4114 so that several \fImetacharacter\fP-separated words surrounded by
4115 quotes are considered as one word.
4116 History expansions are introduced by the appearance of the
4117 history expansion character, which is \^\fB!\fP\^ by default.
4118 Only backslash (\^\fB\e\fP\^) and single quotes can quote
4119 the history expansion character.
4120 .PP
4121 Several shell options settable with the
4122 .B shopt
4123 builtin may be used to tailor the behavior of history expansion.
4124 If the
4125 .B histverify
4126 shell option is enabled (see the description of the
4127 .B shopt
4128 builtin), and
4129 .B readline
4130 is being used, history substitutions are not immediately passed to
4131 the shell parser.
4132 Instead, the expanded line is reloaded into the
4133 .B readline
4134 editing buffer for further modification.
4135 If
4136 .B readline
4137 is being used, and the
4138 .B histreedit
4139 shell option is enabled, a failed history substitution will be reloaded
4140 into the
4141 .B readline
4142 editing buffer for correction.
4143 The
4144 .B \-p
4145 option to the
4146 .B history
4147 builtin command may be used to see what a history expansion will
4148 do before using it.
4149 The
4150 .B \-s
4151 option to the
4152 .B history
4153 builtin may be used to add commands to the end of the history list
4154 without actually executing them, so that they are available for
4155 subsequent recall.
4156 .PP
4157 The shell allows control of the various characters used by the
4158 history expansion mechanism (see the description of
4159 .B histchars
4160 above under
4161 .BR "Shell Variables" ).
4162 .SS Event Designators
4163 .PP
4164 An event designator is a reference to a command line entry in the
4165 history list.
4166 .PP
4167 .PD 0
4168 .TP
4169 .B !
4170 Start a history substitution, except when followed by a
4171 .BR blank ,
4172 newline, = or (.
4173 .TP
4174 .B !\fIn\fR
4175 Refer to command line
4176 .IR n .
4177 .TP
4178 .B !\-\fIn\fR
4179 Refer to the current command line minus
4180 .IR n .
4181 .TP
4182 .B !!
4183 Refer to the previous command.  This is a synonym for `!\-1'.
4184 .TP
4185 .B !\fIstring\fR
4186 Refer to the most recent command starting with 
4187 .IR string .
4188 .TP
4189 .B !?\fIstring\fR\fB[?]\fR
4190 Refer to the most recent command containing
4191 .IR string .
4192 The trailing \fB?\fP may be omitted if
4193 .I string
4194 is followed immediately by a newline.
4195 .TP
4196 .B \d\s+2^\s-2\u\fIstring1\fP\d\s+2^\s-2\u\fIstring2\fP\d\s+2^\s-2\u
4197 Quick substitution.  Repeat the last command, replacing
4198 .I string1
4199 with
4200 .IR string2 .
4201 Equivalent to
4202 ``!!:s/\fIstring1\fP/\fIstring2\fP/''
4203 (see \fBModifiers\fP below).
4204 .TP
4205 .B !#
4206 The entire command line typed so far.
4207 .PD
4208 .SS Word Designators
4209 .PP
4210 Word designators are used to select desired words from the event.
4211
4212 .B :
4213 separates the event specification from the word designator.
4214 It can be omitted if the word designator begins with a
4215 .BR ^ ,
4216 .BR $ ,
4217 .BR * ,
4218 .BR \- ,
4219 or
4220 .BR % .
4221 Words are numbered from the beginning of the line,
4222 with the first word being denoted by 0 (zero).
4223 Words are inserted into the current line separated by single spaces.
4224 .PP
4225 .PD 0
4226 .TP
4227 .B 0 (zero)
4228 The zeroth word.  For the shell, this is the command
4229 word.
4230 .TP
4231 .I n
4232 The \fIn\fRth word.
4233 .TP
4234 .B ^
4235 The first argument.  That is, word 1.
4236 .TP
4237 .B $
4238 The last argument.
4239 .TP
4240 .B %
4241 The word matched by the most recent `?\fIstring\fR?' search.
4242 .TP
4243 .I x\fB\-\fPy
4244 A range of words; `\-\fIy\fR' abbreviates `0\-\fIy\fR'.
4245 .TP
4246 .B *
4247 All of the words but the zeroth.  This is a synonym
4248 for `\fI1\-$\fP'.  It is not an error to use
4249 .B *
4250 if there is just one
4251 word in the event; the empty string is returned in that case.
4252 .TP
4253 .B x*
4254 Abbreviates \fIx\-$\fP.
4255 .TP
4256 .B x\-
4257 Abbreviates \fIx\-$\fP like \fBx*\fP, but omits the last word.
4258 .PD
4259 .PP
4260 If a word designator is supplied without an event specification, the
4261 previous command is used as the event.
4262 .SS Modifiers
4263 .PP
4264 After the optional word designator, there may appear a sequence of
4265 one or more of the following modifiers, each preceded by a `:'.
4266 .PP
4267 .PD 0
4268 .PP
4269 .TP
4270 .B h
4271 Remove a trailing file name component, leaving only the head.
4272 .TP
4273 .B t
4274 Remove all leading file name components, leaving the tail.
4275 .TP
4276 .B r
4277 Remove a trailing suffix of the form \fI.xxx\fP, leaving the
4278 basename.
4279 .TP
4280 .B e
4281 Remove all but the trailing suffix.
4282 .TP
4283 .B p
4284 Print the new command but do not execute it.
4285 .TP
4286 .B q
4287 Quote the substituted words, escaping further substitutions.
4288 .TP
4289 .B x
4290 Quote the substituted words as with
4291 .BR q ,
4292 but break into words at
4293 .B blanks
4294 and newlines.
4295 .TP
4296 .B s/\fIold\fP/\fInew\fP/
4297 Substitute
4298 .I new
4299 for the first occurrence of
4300 .I old
4301 in the event line.  Any delimiter can be used in place of /.  The
4302 final delimiter is optional if it is the last character of the
4303 event line.  The delimiter may be quoted in
4304 .I old
4305 and
4306 .I new
4307 with a single backslash.  If & appears in
4308 .IR new ,
4309 it is replaced by
4310 .IR old .
4311 A single backslash will quote the &.  If
4312 .I old
4313 is null, it is set to the last
4314 .I old
4315 substituted, or, if no previous history substitutions took place,
4316 the last
4317 .I string
4318 in a
4319 .B !?\fIstring\fR\fB[?]\fR
4320 search.
4321 .TP
4322 .B &
4323 Repeat the previous substitution.
4324 .TP
4325 .B g
4326 Cause changes to be applied over the entire event line.  This is
4327 used in conjunction with `\fB:s\fP' (e.g., `\fB:gs/\fIold\fP/\fInew\fP/\fR')
4328 or `\fB:&\fP'.  If used with
4329 `\fB:s\fP', any delimiter can be used
4330 in place of /, and the final delimiter is optional
4331 if it is the last character of the event line.
4332 .PD
4333 .SH "ARITHMETIC EVALUATION"
4334 The shell allows arithmetic expressions to be evaluated, under
4335 certain circumstances (see the \fBlet\fP builtin command and
4336 \fBArithmetic Expansion\fP).
4337 Evaluation
4338 is done in long integers with no check for overflow, though division
4339 by 0 is trapped and flagged as an error.  The following list of
4340 operators is grouped into levels of equal-precedence operators.
4341 The levels are listed in order of decreasing precedence.
4342 .PP
4343 .PD 0
4344 .TP
4345 .B \- +
4346 unary minus and plus
4347 .TP
4348 .B ! ~
4349 logical and bitwise negation
4350 .TP
4351 .B * / %
4352 multiplication, division, remainder
4353 .TP
4354 .B + \-
4355 addition, subtraction
4356 .TP
4357 .B << >>
4358 left and right bitwise shifts
4359 .TP
4360 .B <= >= < >
4361 comparison
4362 .TP
4363 .B == !=
4364 equality and inequality
4365 .TP
4366 .B &
4367 bitwise AND
4368 .TP
4369 .B ^
4370 bitwise exclusive OR
4371 .TP
4372 .B |
4373 bitwise OR
4374 .TP
4375 .B &&
4376 logical AND
4377 .TP
4378 .B ||
4379 logical OR
4380 .TP
4381 .B \fIexpr\fP?\fIexpr\fP:\fIexpr\fP
4382 conditional evaluation
4383 .TP
4384 .B = *= /= %= += \-= <<= >>= &= ^= |=
4385 assignment
4386 .PD
4387 .PP
4388 Shell variables are allowed as operands; parameter expansion is
4389 performed before the expression is evaluated. 
4390 The value of a parameter is coerced to a long integer within
4391 an expression.  A shell variable need not have its integer attribute
4392 turned on to be used in an expression.
4393 .PP
4394 Constants with a leading 0 are interpreted as octal numbers.
4395 A leading 0x or 0X denotes hexadecimal.
4396 Otherwise, numbers take the form [\fIbase#\fP]n, where \fIbase\fP
4397 is a decimal number between 2 and 64 representing the arithmetic
4398 base, and \fIn\fP is a number in that base.
4399 If \fIbase\fP is omitted, then base 10 is used.
4400 The digits greater than 9 are represented by the lowercase letters,
4401 the uppercase letters, _, and @, in that order.
4402 If \fIbase\fP is less than or equal to 36, lowercase and uppercase
4403 letters may be used interchangably to represent numbers between 10
4404 and 35.
4405 .PP
4406 Operators are evaluated in order of precedence.  Sub-expressions in
4407 parentheses are evaluated first and may override the precedence
4408 rules above.
4409 .SH "SHELL BUILTIN COMMANDS"
4410 .\" start of bash_builtins
4411 .zZ
4412 .PP
4413 Unless otherwise noted, each builtin command documented in this
4414 section as accepting options preceded by
4415 .B \-
4416 accepts
4417 .B \-\-
4418 to signify the end of the options.
4419 .sp .5
4420 .PD 0
4421 .TP
4422 \fB:\fP [\fIarguments\fP]
4423 .PD
4424 No effect; the command does nothing beyond expanding
4425 .I arguments
4426 and performing any specified
4427 redirections.  A zero exit code is returned.
4428 .TP
4429 .PD 0
4430 \fB .\| \fP \fIfilename\fP [\fIarguments\fP]
4431 .TP
4432 \fBsource\fP \fIfilename\fP [\fIarguments\fP]
4433 .PD
4434 Read and execute commands from
4435 .I filename
4436 in the current
4437 shell environment and return the exit status of the last command
4438 executed from
4439 .IR filename .
4440 If
4441 .I filename
4442 does not contain a slash, file names in
4443 .SM
4444 .B PATH
4445 are used to find the directory containing
4446 .IR filename .
4447 The file searched for in
4448 .SM
4449 .B PATH
4450 need not be executable.  The current directory is
4451 searched if no file is found in
4452 .SM
4453 .BR PATH .
4454 If the
4455 .B sourcepath
4456 option to the
4457 .B shopt
4458 builtin command is turned off, the
4459 .SM
4460 .B PATH
4461 is not searched.
4462 If any \fIarguments\fP are supplied, they become the positional
4463 parameters when \fIfilename\fP is executed.  Otherwise the positional
4464 parameters are unchanged.
4465 The return status is the status of the last command exited within
4466 the script (0 if no commands are executed), and false if
4467 .I filename
4468 is not found.
4469 .TP
4470 \fBalias\fP [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
4471 \fBAlias\fP with no arguments or with the
4472 .B \-p
4473 option prints the list of aliases in the form
4474 \fBalias\fP \fIname\fP=\fIvalue\fP on standard output.
4475 When arguments are supplied, an alias is defined for
4476 each \fIname\fP whose \fIvalue\fP is given.
4477 A trailing space in  \fIvalue\fP causes the next word to be
4478 checked for alias substitution when the alias is expanded.
4479 For each \fIname\fP in the argument list for which no \fIvalue\fP
4480 is supplied, the name and value of the alias is printed.
4481 \fBAlias\fP returns true unless a \fIname\fP is given for which
4482 no alias has been defined.
4483 .TP
4484 \fBbg\fP [\fIjobspec\fP]
4485 Place \fIjobspec\fP in the background, as if it had been started with
4486 .BR & .
4487 If \fIjobspec\fP is not present, the shell's notion of the
4488 \fIcurrent job\fP is used.
4489 .B bg
4490 .I jobspec
4491 returns 0 unless run when job control is disabled or, when run with
4492 job control enabled, if \fIjobspec\fP was not found or started without
4493 job control.
4494 .TP
4495 .PD 0
4496 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-lpsvPSV\fP] [\fB\-q\fP \fIname\fP] [\fB\-r\fP \fIkeyseq\fP]
4497 .TP
4498 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-f\fP \fIfilename\fP
4499 .TP
4500 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fIkeyseq\fP:\fIfunction\-name\fP
4501 .PD
4502 Display current
4503 .B readline
4504 key and function bindings, or bind a key sequence to a
4505 .B readline
4506 function or macro.  The binding syntax accepted is identical to that of
4507 .IR .inputrc ,
4508 but each binding must be passed as a separate argument;
4509 e.g., '"\eC\-x\eC\-r": re\-read\-init\-file'.  Options, if supplied, have the
4510 following meanings:
4511 .RS
4512 .PD 0
4513 .TP
4514 .B \-m \fIkeymap\fP
4515 Use
4516 .I keymap
4517 as the keymap to be affected by the subsequent bindings.
4518 Acceptable
4519 .I keymap
4520 names are
4521 \fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi,
4522 vi\-command\fP, and
4523 .IR vi\-insert .
4524 \fIvi\fP is equivalent to \fIvi\-command\fP; \fIemacs\fP is
4525 equivalent to \fIemacs\-standard\fP.
4526 .TP
4527 .B \-l
4528 List the names of all \fBreadline\fP functions.
4529 .TP
4530 .B \-p
4531 Display \fBreadline\fP function names and bindings in such a way
4532 that they can be re-read.
4533 .TP
4534 .B \-P
4535 List current \fBreadline\fP function names and bindings.
4536 .TP
4537 .B \-v
4538 Display \fBreadline\fP variable names and values in such a way that they
4539 can be re-read.
4540 .TP
4541 .B \-V
4542 List current \fBreadline\fP variable names and values.
4543 .TP
4544 .B \-s
4545 Display \fBreadline\fP key sequences bound to macros and the strings
4546 they output in such a way that they can be re-read.
4547 .TP
4548 .B \-S
4549 Display \fBreadline\fP key sequences bound to macros and the strings
4550 they output.
4551 .TP
4552 .B \-f \fIfilename\fP
4553 Read key bindings from \fIfilename\fP.
4554 .TP
4555 .B \-q \fIfunction\fP
4556 Query about which keys invoke the named \fIfunction\fP.
4557 .TP
4558 .B \-r \fIkeyseq\fP
4559 Remove any current binding for \fIkeyseq\fP.
4560 .PD
4561 .PP
4562 The return value is 0 unless an unrecognized option is given or an
4563 error occurred.
4564 .RE
4565 .TP
4566 \fBbreak\fP [\fIn\fP]
4567 Exit from within a
4568 .BR for ,
4569 .BR while ,
4570 .BR until ,
4571 or
4572 .B select
4573 loop.  If \fIn\fP is specified, break \fIn\fP levels.
4574 .I n
4575 must be \(>= 1.  If
4576 .I n
4577 is greater than the number of enclosing loops, all enclosing loops
4578 are exited.  The return value is 0 unless the shell is not executing
4579 a loop when
4580 .B break
4581 is executed.
4582 .TP
4583 \fBbuiltin\fP \fIshell\-builtin\fP [\fIarguments\fP]
4584 Execute the specified shell builtin, passing it
4585 .IR arguments ,
4586 and return its exit status.
4587 This is useful when you wish to define a
4588 function whose name is the same as a shell builtin,
4589 but need the functionality of the
4590 builtin within the function itself.  The \fBcd\fP builtin is
4591 commonly redefined this way.  The return status is false if
4592 .I shell\-builtin
4593 is not a shell builtin command.
4594 .TP
4595 \fBcd\fP [\fB\-LP\fP] [\fIdir\fP]
4596 Change the current directory to \fIdir\fP.  The variable
4597 .SM
4598 .B HOME
4599 is the
4600 default
4601 .IR dir .
4602 The variable
4603 .SM
4604 .B CDPATH
4605 defines the search path for the directory containing
4606 .IR dir .
4607 Alternative directory names in
4608 .SM
4609 .B CDPATH
4610 are separated by a colon (:).  A null directory name in
4611 .SM
4612 .B CDPATH
4613 is the same as the current directory, i.e., ``\fB.\fP''.  If
4614 .I dir
4615 begins with a slash (/),
4616 then
4617 .SM
4618 .B CDPATH
4619 is not used. The
4620 .B \-P
4621 option says to use the physical directory structure instead of
4622 following symbolic links (see also the
4623 .B \-P
4624 option to the
4625 .B set
4626 builtin command); the
4627 .B \-L
4628 option forces symbolic links to be followed.  An argument of
4629 .B \-
4630 is equivalent to
4631 .SM
4632 .BR $OLDPWD .
4633 The return value is true if the directory was successfully changed;
4634 false otherwise.
4635 .TP
4636 \fBcommand\fP [\fB\-pVv\fP] \fIcommand\fP [\fIarg\fP ...]
4637 Run
4638 .I command
4639 with
4640 .I args
4641 suppressing the normal shell function lookup. Only builtin
4642 commands or commands found in the
4643 .SM
4644 .B PATH
4645 are executed.  If the
4646 .B \-p
4647 option is given, the search for
4648 .I command
4649 is performed using a default value for
4650 .B PATH
4651 that is guaranteed to find all of the standard utilities.
4652 If either the
4653 .B \-V
4654 or
4655 .B \-v
4656 option is supplied, a description of
4657 .I command
4658 is printed.  The
4659 .B \-v
4660 option causes a single word indicating the command or file name
4661 used to invoke
4662 .I command
4663 to be printed; the
4664 .B \-V
4665 option produces a more verbose description.
4666 If the
4667 .B \-V
4668 or
4669 .B \-v
4670 option is supplied, the exit status is 0 if
4671 .I command
4672 was found, and 1 if not.  If neither option is supplied and
4673 an error occurred or
4674 .I command
4675 cannot be found, the exit status is 127.  Otherwise, the exit status of the
4676 .B command
4677 builtin is the exit status of
4678 .IR command .
4679 .TP
4680 \fBcontinue\fP [\fIn\fP]
4681 Resume the next iteration of the enclosing
4682 .BR for ,
4683 .BR while ,
4684 .BR until ,
4685 or
4686 .B select
4687 loop.
4688 If
4689 .I n
4690 is specified, resume at the \fIn\fPth enclosing loop.
4691 .I n
4692 must be \(>= 1.  If
4693 .I n
4694 is greater than the number of enclosing loops, the last enclosing loop
4695 (the ``top-level'' loop) is resumed.  The return value is 0 unless the
4696 shell is not executing a loop when
4697 .B continue
4698 is executed.
4699 .TP
4700 .PD 0
4701 \fBdeclare\fP [\fB\-afFirx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP]]
4702 .TP
4703 \fBtypeset\fP [\fB\-afFirx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP]]
4704 .PD
4705 Declare variables and/or give them attributes.
4706 If no \fIname\fPs are given then display the values of variables.
4707 The
4708 .B \-p
4709 option will display the attributes and values of each
4710 .IR name .
4711 When
4712 .B \-p
4713 is used, additional options are ignored.
4714 The
4715 .B \-F
4716 option inhibits the display of function definitions; only the
4717 function name and attributes are printed.
4718 The
4719 .B \-F
4720 option implies
4721 .BR \-f .
4722 The following options can
4723 be used to restrict output to variables with the specified attribute or
4724 to give variables attributes:
4725 .RS
4726 .PD 0
4727 .TP
4728 .B \-a
4729 Each \fIname\fP is an array variable (see
4730 .B Arrays
4731 above).
4732 .TP
4733 .B \-f
4734 Use function names only.
4735 .TP
4736 .B \-i
4737 The variable is treated as an integer; arithmetic evaluation (see
4738 .SM
4739 .B "ARITHMETIC EVALUATION" ") "
4740 is performed when the variable is assigned a value.
4741 .TP
4742 .B \-r
4743 Make \fIname\fPs readonly.  These names cannot then be assigned values
4744 by subsequent assignment statements.
4745 .TP
4746 .B \-x
4747 Mark \fIname\fPs for export to subsequent commands via the environment.
4748 .PD
4749 .PP
4750 Using `+' instead of `\-'
4751 turns off the attribute instead, with the exception that \fB+a\fP
4752 may not be used to destroy an array variable.  When used in a function,
4753 makes each
4754 \fIname\fP local, as with the 
4755 .B local
4756 command.  The return value is 0 unless an illegal option is encountered,
4757 an attempt is made to define a function using "\-f foo=bar",
4758 an attempt is made to assign a value to a readonly variable,
4759 an attempt is made to assign a value to an array variable without
4760 using the compound assignment syntax (see
4761 .B Arrays
4762 above), one of the \fInames\fP is not a legal shell variable name,
4763 an attempt is made to turn off readonly status for a readonly variable,
4764 an attempt is made to turn off array status for an array variable,
4765 or an attempt is made to display a non-existent function with \-f.
4766 .RE
4767 .TP
4768 .B dirs [\fB\-clpv\fP] [+\fIn\fP] [\-\fIn\fP]
4769 Without options, displays the list of currently remembered directories.
4770 The default display is on a single line with directory names separated
4771 by spaces.
4772 Directories are added to the list with the 
4773 .B pushd
4774 command; the
4775 .B popd
4776 command removes entries from the list.
4777 .RS
4778 .PD 0
4779 .TP
4780 \fB+\fP\fIn\fP
4781 Displays the \fIn\fPth entry counting from the left of the list
4782 shown by
4783 .B dirs
4784 when invoked without options, starting with zero.
4785 .TP
4786 \fB\-\fP\fIn\fP
4787 Displays the \fIn\fPth entry counting from the right of the list
4788 shown by
4789 .B dirs
4790 when invoked without options, starting with zero.
4791 .TP
4792 .B \-c
4793 Clears the directory stack by deleting all of the entries.
4794 .TP
4795 .B \-l
4796 Produces a longer listing; the default listing format uses a 
4797 tilde to denote the home directory.
4798 .TP
4799 .B \-p
4800 Print the directory stack with one entry per line.
4801 .TP
4802 .B \-v
4803 Print the directory stack with one entry per line,
4804 prefixing each entry with its index in the stack.
4805 .PD
4806 .PP
4807 The return value is 0 unless an
4808 illegal option is supplied or \fIn\fP indexes beyond the end
4809 of the directory stack.
4810 .RE
4811 .TP
4812 \fBdisown\fP [\fB\-h\fP] [\fIjobspec\fP ...]
4813 Without options, each
4814 .I jobspec
4815 is removed from the table of active jobs.
4816 If the \fB\-h\fP option is given, the job is not removed from the table,
4817 but is marked so that
4818 .SM
4819 .B SIGHUP
4820 is not sent to the job if the shell receives a
4821 .SM
4822 .BR SIGHUP .
4823 If no
4824 .I jobspec
4825 is present, the \fIcurrent job\fP is used.  The return value is
4826 0 unless a
4827 .I jobspec
4828 does not specify a valid job.
4829 .TP
4830 \fBecho\fP [\fB\-neE\fP] [\fIarg\fP ...]
4831 Output the \fIarg\fPs, separated by spaces, followed by a newline.
4832 The return status is always 0.
4833 If \fB\-n\fP is specified, the trailing newline is
4834 suppressed.  If the \fB\-e\fP option is given, interpretation of
4835 the following backslash-escaped characters is enabled.  The
4836 .B \-E
4837 option disables the interpretation of these escape characters,
4838 even on systems where they are interpreted by default.
4839 .B echo
4840 does not interpret
4841 .B \-\-
4842 to mean the end of options.
4843 .B echo
4844 interprets the following escape sequences:
4845 .RS
4846 .PD 0
4847 .TP
4848 .B \ea
4849 alert (bell)
4850 .TP
4851 .B \eb
4852 backspace
4853 .TP
4854 .B \ec
4855 suppress trailing newline
4856 .TP
4857 .B \ee
4858 an escape character
4859 .TP
4860 .B \ef
4861 form feed
4862 .TP
4863 .B \en
4864 new line
4865 .TP
4866 .B \er
4867 carriage return
4868 .TP
4869 .B \et
4870 horizontal tab
4871 .TP
4872 .B \ev
4873 vertical tab
4874 .TP
4875 .B \e\e
4876 backslash
4877 .TP
4878 .B \ennn
4879 the character whose ASCII code is \fInnn\fP (octal)
4880 .PD
4881 .RE
4882 .TP
4883 \fBenable\fP [\fB\-adnps\fP] [\fB\-f\fP \fIfilename\fP] [\fIname\fP ...]
4884 Enable and disable builtin shell commands.  This allows
4885 the execution of a disk command which has the same name as a shell
4886 builtin without specifying a full file name.
4887 If \fB\-n\fP is used, each \fIname\fP
4888 is disabled; otherwise,
4889 \fInames\fP are enabled.  For example, to use the
4890 .B test
4891 binary found via the
4892 .SM
4893 .B PATH
4894 instead of the shell builtin version, run
4895 \f(CWenable -n test\fP.
4896 The
4897 .B \-f
4898 option means to load the new builtin command
4899 .I name
4900 from shared object
4901 .IR filename ,
4902 on systems that support dynamic loading.  The
4903 .B \-d
4904 option will delete a builtin previously loaded with
4905 .BR \-f .
4906 If no \fIname\fP arguments are given, or if the
4907 .B \-p
4908 option is supplied, a list of shell builtins is printed.
4909 With no other option arguments, the list consists of all enabled
4910 shell builtins.
4911 If \fB\-n\fP is supplied, only disabled builtins are printed.
4912 If \fB\-a\fP is supplied, the list printed includes all builtins, with an
4913 indication of whether or not each is enabled.
4914 If \fB\-s\fP is supplied, the output is restricted to the POSIX
4915 \fIspecial\fP builtins.
4916 The return value is 0 unless a
4917 .I name
4918 is not a shell builtin or there is a problem loading a new builtin
4919 from a shared object.
4920 .TP
4921 \fBeval\fP [\fIarg\fP ...]
4922 The \fIarg\fPs are read and concatenated together into a single
4923 command.  This command is then read and executed by the shell, and
4924 its exit status is returned as the value of
4925 .BR eval .
4926 If there are no
4927 .IR args ,
4928 or only null arguments,
4929 .B eval
4930 returns 0.
4931 .TP
4932 \fBexec\fP [\fB\-cl\fP] [\fB\-a\fP \fIname\fP] [\fIcommand\fP] [\fIarguments\fP]
4933 If
4934 .I command
4935 is specified, it replaces the shell.
4936 No new process is created.  The
4937 .I arguments
4938 become the arguments to \fIcommand\fP.
4939 If the
4940 .B \-l
4941 option is supplied,
4942 the shell places a dash in the zeroth arg passed to 
4943 .IR command .
4944 This is what
4945 .IR login (1)
4946 does.  The
4947 .B \-c
4948 option causes
4949 .I command
4950 to be executed with an empty environment.  If
4951 .B \-a
4952 is supplied, the shell passes
4953 .I name
4954 as the zeroth argument to the executed command.  If
4955 .I command
4956 cannot be executed for some reason, a non-interactive shell exits,
4957 unless the shell option
4958 .B execfail
4959 is enabled, in which case it returns failure.
4960 An interactive shell returns failure if the file cannot be executed.
4961 If
4962 .I command
4963 is not specified, any redirections take effect in the current shell,
4964 and the return status is 0.
4965 .TP
4966 \fBexit\fP [\fIn\fP]
4967 Cause the shell to exit
4968 with a status of \fIn\fP.  If
4969 .I n
4970 is omitted, the exit status
4971 is that of the last command executed.
4972 A trap on
4973 .SM
4974 .B EXIT
4975 is executed before the shell terminates.
4976 .TP
4977 .PD 0
4978 \fBexport\fP [\fB\-fn\fP\^] [\fIname\fP[=\fIword\fP]] ...
4979 .TP
4980 .B export \-p
4981 .PD
4982 The supplied
4983 .I names
4984 are marked for automatic export to the environment of
4985 subsequently executed commands.  If the 
4986 .B \-f
4987 option is given,
4988 the 
4989 .I names
4990 refer to functions.
4991 If no
4992 .I names
4993 are given, or if the
4994 .B \-p
4995 option is supplied, a list
4996 of all names that are exported in this shell is printed.
4997 The
4998 .B \-n
4999 option causes the export property to be removed from the
5000 named variables.
5001 .B export
5002 returns an exit status of 0 unless an illegal option is
5003 encountered,
5004 one of the \fInames\fP is not a legal shell variable name, or
5005 .B \-f
5006 is supplied with a
5007 .I name
5008 that is not a function.
5009 .TP
5010 .PD 0
5011 \fBfc\fP [\fB\-e\fP \fIename\fP] [\fB\-nlr\fP] [\fIfirst\fP] [\fIlast\fP]
5012 .TP
5013 \fBfc\fP \fB\-s\fP [\fIpat\fP=\fIrep\fP] [\fIcmd\fP]
5014 .PD
5015 Fix Command.  In the first form, a range of commands from
5016 .I first
5017 to
5018 .I last
5019 is selected from the history list.
5020 .I First
5021 and
5022 .I last
5023 may be specified as a string (to locate the last command beginning
5024 with that string) or as a number (an index into the history list,
5025 where a negative number is used as an offset from the current
5026 command number).  If 
5027 .I last
5028 is not specified it is set to
5029 the current command for listing (so that
5030 .B fc \-l \-10
5031 prints the last 10 commands) and to
5032 .I first
5033 otherwise.
5034 If
5035 .I first
5036 is not specified it is set to the previous
5037 command for editing and \-16 for listing.
5038 .sp 1
5039 The
5040 .B \-n
5041 flag suppresses
5042 the command numbers when listing.  The
5043 .B \-r
5044 flag reverses the order of
5045 the commands.  If the
5046 .B \-l
5047 flag is given,
5048 the commands are listed on
5049 standard output.  Otherwise, the editor given by
5050 .I ename
5051 is invoked
5052 on a file containing those commands.  If
5053 .I ename
5054 is not given, the
5055 value of the
5056 .SM
5057 .B FCEDIT
5058 variable is used, and
5059 the value of
5060 .SM
5061 .B EDITOR
5062 if
5063 .SM
5064 .B FCEDIT
5065 is not set.  If neither variable is set,
5066 .FN vi
5067 is used.  When editing is complete, the edited commands are
5068 echoed and executed.
5069 .sp 1
5070 In the second form, \fIcommand\fP is re-executed after each instance
5071 of \fIpat\fP is replaced by \fIrep\fP.
5072 A useful alias to use with this is
5073 .if n ``r=fc -s'',
5074 .if t \f(CWr='fc \-s'\fP,
5075 so that typing
5076 .if n ``r cc''
5077 .if t \f(CWr cc\fP
5078 runs the last command beginning with
5079 .if n ``cc''
5080 .if t \f(CWcc\fP
5081 and typing
5082 .if n ``r''
5083 .if t \f(CWr\fP
5084 re-executes the last command.
5085 .sp 1
5086 If the first form is used, the return value is 0 unless an illegal
5087 option is encountered or
5088 .I first
5089 or
5090 .I last
5091 specify history lines out of range.
5092 If the
5093 .B \-e
5094 option is supplied, the return value is the value of the last
5095 command executed or failure if an error occurs with the temporary
5096 file of commands.  If the second form is used, the return status
5097 is that of the command re-executed, unless
5098 .I cmd
5099 does not specify a valid history line, in which case
5100 .B fc
5101 returns failure.
5102 .TP
5103 \fBfg\fP [\fIjobspec\fP]
5104 Place
5105 .I jobspec
5106 in the foreground, and make it the current job.  If
5107 .I jobspec
5108 is not present, the shell's notion of the \fIcurrent job\fP is used.
5109 The return value is that of the command placed into the foreground,
5110 or failure if run when job control is disabled or, when run with
5111 job control enabled, if
5112 .I jobspec
5113 does not specify a valid job or
5114 .I jobspec
5115 specifies a job that was started without job control.
5116 .TP
5117 \fBgetopts\fP \fIoptstring\fP \fIname\fP [\fIargs\fP]
5118 .B getopts
5119 is used by shell procedures to parse positional parameters.
5120 .I optstring
5121 contains the option letters to be recognized; if a letter
5122 is followed by a colon, the option is expected to have an
5123 argument, which should be separated from it by white space.
5124 Each time it is invoked,
5125 .B getopts
5126 places the next option in the shell variable
5127 .IR name ,
5128 initializing
5129 .I name
5130 if it does not exist,
5131 and the index of the next argument to be processed into the
5132 variable
5133 .SM
5134 .BR OPTIND .
5135 .SM
5136 .B OPTIND
5137 is initialized to 1 each time the shell or a shell script
5138 is invoked.  When an option requires an argument,
5139 .B getopts
5140 places that argument into the variable
5141 .SM
5142 .BR OPTARG .
5143 The shell does not reset
5144 .SM
5145 .B OPTIND
5146 automatically; it must be manually reset between multiple
5147 calls to
5148 .B getopts
5149 within the same shell invocation if a new set of parameters
5150 is to be used.
5151 .sp 1
5152 .B getopts
5153 can report errors in two ways.  If the first character of
5154 .I optstring
5155 is a colon,
5156 .I silent
5157 error reporting is used.  In normal operation diagnostic messages
5158 are printed when illegal options or missing option arguments are
5159 encountered.
5160 If the variable
5161 .SM
5162 .B OPTERR
5163 is set to 0, no error message will be displayed, even if the first
5164 character of 
5165 .I optstring
5166 is not a colon.
5167 .sp 1
5168 If an illegal option is seen,
5169 .B getopts
5170 places ? into
5171 .I name
5172 and, if not silent,
5173 prints an error message and unsets
5174 .SM
5175 .BR OPTARG .
5176 If
5177 .B getopts
5178 is silent,
5179 the option character found is placed in
5180 .SM
5181 .B OPTARG
5182 and no diagnostic message is printed.
5183 .sp 1
5184 If a required argument is not found, and
5185 .B getopts
5186 is not silent,
5187 a question mark (\^\fB?\fP\^) is placed in
5188 .IR name ,
5189 .B OPTARG
5190 is unset, and a diagnostic message is printed.
5191 If
5192 .B getopts
5193 is silent, then a colon (\^\fB:\fP\^) is placed in
5194 .I name
5195 and
5196 .SM
5197 .B OPTARG
5198 is set to the option character found.
5199 .sp 1
5200 .B getopts
5201 normally parses the positional parameters, but if more arguments are
5202 given in
5203 .IR args ,
5204 .B getopts
5205 parses those instead.
5206 .B getopts
5207 returns true if an option, specified or unspecified, is found.
5208 It returns false if the end of options is encountered or an
5209 error occurs.
5210 .TP
5211 \fBhash\fP [\fB\-r\fP] [\fB\-p\fP \fIfilename\fP] [\fIname\fP]
5212 For each
5213 .IR name ,
5214 the full file name of the command is determined by searching
5215 the directories in
5216 .B $PATH
5217 and remembered.
5218 If the
5219 .B \-p
5220 option is supplied, no path search is performed, and
5221 .I filename
5222 is used as the full file name of the command.
5223 The
5224 .B \-r
5225 option causes the shell to forget all
5226 remembered locations.  If no arguments are given, information
5227 about remembered commands is printed.
5228 The return status is true unless a
5229 .I name
5230 is not found or an illegal option is supplied.
5231 .TP
5232 \fBhelp\fP [\fIpattern\fP]
5233 Display helpful information about builtin commands.  If
5234 .I pattern
5235 is specified,
5236 .B help
5237 gives detailed help on all commands matching
5238 .IR pattern ;
5239 otherwise help for all the builtins and shell control structures
5240 is printed.  The return status is 0 unless no command matches
5241 .IR pattern .
5242 .TP
5243 .PD 0
5244 \fBhistory\fP [\fB\-c\fP] [\fIn\fP]
5245 .TP
5246 \fBhistory\fP \fB\-anrw\fP [\fIfilename\fP]
5247 .TP
5248 \fBhistory\fP \fB\-p\fP \fIarg\fP [\fIarg ...\fP]
5249 .TP
5250 \fBhistory\fP \fB\-s\fP \fIarg\fP [\fIarg ...\fP]
5251 .PD
5252 With no options, display the command
5253 history list with line numbers.  Lines listed
5254 with a 
5255 .B *
5256 have been modified.  An argument of
5257 .I n
5258 lists only the last
5259 .I n
5260 lines.  If \fIfilename\fP is supplied, it is used as the
5261 name of the history file; if not, the value of
5262 .SM
5263 .B HISTFILE
5264 is used.  Options, if supplied, have the following meanings:
5265 .RS
5266 .PD 0
5267 .TP
5268 .B \-a
5269 Append the ``new'' history lines (history lines entered since the
5270 beginning of the current \fBbash\fP session) to the history file.
5271 .TP
5272 .B \-n
5273 Read the history lines not already read from the history
5274 file into the current history list.  These are lines
5275 appended to the history file since the beginning of the
5276 current \fBbash\fP session.
5277 .TP
5278 .B \-r
5279 Read the contents of the history file
5280 and use them as the current history.
5281 .TP
5282 .B \-w
5283 Write the current history to the history file, overwriting the
5284 history file's contents.
5285 .TP
5286 .B \-c
5287 Clear the history list by deleting all the entries.
5288 .TP
5289 .B \-p
5290 Perform history substitution on the following \fIargs\fP and display
5291 the result on the standard output.
5292 Does not store the results in the history list.
5293 Each \fIarg\fP must be quoted to disable normal history expansion.
5294 .TP
5295 .B \-s
5296 Store the
5297 .I args
5298 in the history list as a single entry.  The last command in the
5299 history list is removed before the
5300 .I args
5301 are added.
5302 .PD
5303 .PP
5304 The return value is 0 unless an illegal option is encountered or an
5305 error occurs while reading or writing the history file.
5306 .RE
5307 .TP
5308 .PD 0
5309 \fBjobs\fP [\fB\-lnprs\fP] [ \fIjobspec\fP ... ]
5310 .TP
5311 \fBjobs\fP \fB\-x\fP \fIcommand\fP [ \fIargs\fP ... ]
5312 .PD
5313 The first form lists the active jobs.  The options have the following
5314 meanings:
5315 .RS
5316 .PD 0
5317 .TP
5318 .B \-l
5319 List process IDs
5320 in addition to the normal information.
5321 .TP
5322 .B \-p
5323 List only the process ID of the job's process group
5324 leader.
5325 .TP
5326 .B \-n
5327 Display information only about jobs that have changed status since
5328 the user was last notified of their status.
5329 .TP
5330 .B \-r
5331 Restrict output to running jobs.
5332 .TP
5333 .B \-s
5334 Restrict output to stopped jobs.
5335 .PD
5336 .PP
5337 If
5338 .I jobspec
5339 is given, output is restricted to information about that job.
5340 The return status is 0 unless an illegal option is encountered
5341 or an illegal
5342 .I jobspec
5343 is supplied.
5344 .PP
5345 If the
5346 .B \-x
5347 option is supplied,
5348 .B jobs
5349 replaces any
5350 .I jobspec
5351 found in
5352 .I command
5353 or
5354 .I args
5355 with the corresponding process group ID, and executes
5356 .I command
5357 passing it
5358 .IR args ,
5359 returning its exit status.
5360 .RE
5361 .TP
5362 .PD 0
5363 \fBkill\fP [\fB\-s\fP \fIsigspec\fP | \fB\-n\fP \fIsignum\fP | \fB\-\fP\fIsigspec\fP] [\fIpid\fP | \fIjobspec\fP] ...
5364 .TP
5365 \fBkill\fP \fB\-l\fP [\fIsignum\fP | \fIsigspec\fP]
5366 .PD
5367 Send the signal named by
5368 .I sigspec
5369 or
5370 .I signum
5371 to the processes named by
5372 .I pid
5373 or
5374 .IR jobspec .
5375 .I sigspec
5376 is either a signal name such as
5377 .SM
5378 .B SIGKILL
5379 or a signal number;
5380 .I signum
5381 is a signal number.  If
5382 .I sigspec
5383 is a signal name, the name may be
5384 given with or without the
5385 .SM
5386 .B SIG
5387 prefix.
5388 If
5389 .I sigspec
5390 is not present, then
5391 .SM
5392 .B SIGTERM
5393 is assumed.  An argument of
5394 .B \-l
5395 lists the signal names.  If any arguments are supplied when
5396 .B \-l
5397 is given, the names of the specified signals are listed, and
5398 the return status is 0.  The arguments to
5399 .B \-l
5400 may be either signal names or signal numbers; if signal names
5401 are given, the corresponding signal number is displayed.
5402 .B kill
5403 returns true if at least one signal was successfully sent, or false
5404 if an error occurs or an illegal option is encountered.
5405 .TP
5406 \fBlet\fP \fIarg\fP [\fIarg\fP ...]
5407 Each
5408 .I arg
5409 is an arithmetic expression to be evaluated (see
5410 .SM
5411 .BR "ARITHMETIC EVALUATION" ).
5412 If the last
5413 .I arg
5414 evaluates to 0,
5415 .B let
5416 returns 1; 0 is returned otherwise.
5417 .TP
5418 \fBlocal\fP [\fIname\fP[=\fIvalue\fP] ...]
5419 For each argument, create a local variable named
5420 .IR name ,
5421 and assign it
5422 .IR value .
5423 When
5424 .B local
5425 is used within a function, it causes the variable
5426 .I name
5427 to have a visible scope restricted to that function and its children.
5428 With no operands,
5429 .B local
5430 writes a list of local variables to the standard output.  It is
5431 an error to use
5432 .B local
5433 when not within a function.  The return status is 0 unless
5434 .B local
5435 is used outside a function, or an illegal
5436 .I name
5437 is supplied.
5438 .TP
5439 .B logout
5440 Exit a login shell.
5441 .TP
5442 \fBpopd\fP [\-\fBn\fP] [+\fIn\fP] [\-\fIn\fP]
5443 Removes entries from the directory stack.  With no arguments,
5444 removes the top directory from the stack, and performs a
5445 .B cd
5446 to the new top directory.
5447 Arguments, if supplied, have the following meanings:
5448 .RS
5449 .PD 0
5450 .TP
5451 \fB+\fP\fIn\fP
5452 Removes the \fIn\fPth entry counting from the left of the list
5453 shown by
5454 .BR dirs ,
5455 starting with zero.  For example: ``popd +0''
5456 removes the first directory, ``popd +1'' the second.
5457 .TP
5458 \fB\-\fP\fIn\fP
5459 Removes the \fIn\fPth entry counting from the right of the list
5460 shown by
5461 .BR dirs ,
5462 starting with zero.  For example: ``popd -0''
5463 removes the last directory, ``popd -1'' the next to last.
5464 .TP
5465 .B \-n
5466 Suppresses the normal change of directory when removing directories
5467 from the stack, so that only the stack is manipulated.
5468 .PD
5469 .PP
5470 If the
5471 .B popd
5472 command is successful, a 
5473 .B dirs
5474 is performed as well, and the return status is 0.
5475 .B popd
5476 returns false if an illegal option is encountered, the directory stack
5477 is empty, a non-existent directory stack entry is specified, or the
5478 directory change fails.
5479 .RE
5480 .TP
5481 .PD 0
5482 \fBpushd\fP [\fB\-n\fP] [\fIdir\fP]
5483 .TP
5484 \fBpushd\fP [\fB\-n\fP] [+\fIn\fP] [\-\fIn\fP]
5485 .PD
5486 Adds a directory to the top of the directory stack, or rotates
5487 the stack, making the new top of the stack the current working
5488 directory.  With no arguments, exchanges the top two directories
5489 and returns 0, unless the directory stack is empty.
5490 Arguments, if supplied, have the following meanings:
5491 .RS
5492 .PD 0
5493 .TP
5494 \fB+\fP\fIn\fP
5495 Rotates the stack so that the \fIn\fPth directory
5496 (counting from the left of the list shown by
5497 .BR dirs )
5498 is at the top.
5499 .TP
5500 \fB\-\fP\fIn\fP
5501 Rotates the stack so that the \fIn\fPth directory
5502 (counting from the right) is at the top.
5503 .TP
5504 .B \-n
5505 Suppresses the normal change of directory when adding directories
5506 to the stack, so that only the stack is manipulated.
5507 .TP
5508 .B dir
5509 Adds
5510 .I dir
5511 to the directory stack at the top, making it the
5512 new current working directory.
5513 .PD
5514 .PP
5515 If the
5516 .B pushd
5517 command is successful, a 
5518 .B dirs
5519 is performed as well.
5520 If the first form is used,
5521 .B pushd
5522 returns 0 unless the cd to
5523 .I dir
5524 fails.  With the second form,
5525 .B pushd
5526 returns 0 unless the directory stack is empty,
5527 a non-existent directory stack element is specified,
5528 or the directory change to the specified new current directory
5529 fails.
5530 .RE
5531 .TP
5532 \fBpwd\fP [\fB\-LP\fP]
5533 Print the absolute file name of the current working directory.
5534 The file name printed contains no symbolic links if the
5535 .B \-P
5536 option is supplied or the 
5537 .B \-o physical
5538 option to the
5539 .B set
5540 builtin command is enabled.
5541 If the
5542 .B \-L
5543 option is used, symbolic links are followed.
5544 The return status is 0 unless an error occurs while
5545 reading the name of the current directory.
5546 .TP
5547 \fBread\fP [\fB\-er\fP] [\fB\-a\fP \fIaname\fP] [\fB\-p\fP \fIprompt\fP] [\fIname\fP ...]
5548 One line is read from the standard input, and the first word
5549 is assigned to the first
5550 .IR name ,
5551 the second word to the second
5552 .IR name ,
5553 and so on, with leftover words assigned to the last
5554 .IR name .
5555 Only the characters in 
5556 .SM
5557 .B IFS
5558 are recognized as word delimiters.  Options, if supplied, have the
5559 following meanings:
5560 .RS
5561 .PD 0
5562 .TP
5563 .B \-r
5564 A backslash-newline pair is not ignored, and
5565 the backslash is considered to be part of the line.
5566 .TP
5567 .B \-p
5568 Display \fIprompt\fP, without a
5569 trailing newline, before attempting to read any input.  The prompt
5570 is displayed only if input is coming from a terminal.
5571 .TP
5572 .B \-a
5573 The words are assigned to sequential indices
5574 of the array variable
5575 .IR aname ,
5576 starting at 0.
5577 .I aname
5578 is unset before any new values are assigned.
5579 .TP
5580 .B \-e
5581 If the standard input
5582 is coming from a terminal,
5583 .B readline
5584 (see
5585 .SM
5586 .B READLINE
5587 above) is used to obtain the line.
5588 .PD
5589 .PP
5590 If no
5591 .I names
5592 are supplied, the line read is assigned to the variable
5593 .SM
5594 .BR REPLY .
5595 The return code is zero, unless end-of-file is encountered.
5596 .RE
5597 .TP
5598 \fBreadonly\fP [\fB\-apf\fP] [\fIname\fP ...]
5599 .PD
5600 The given
5601 \fInames\fP are marked readonly; the values of these
5602 .I names
5603 may not be changed by subsequent assignment.
5604 If the
5605 .B \-f
5606 option is supplied, the functions corresponding to the
5607 \fInames\fP are so
5608 marked.
5609 The
5610 .B \-a
5611 option restricts the variables to arrays.
5612 If no
5613 .I name
5614 arguments are given, or if the
5615 .B \-p
5616 option is supplied, a list of all readonly names is printed.
5617 The return status is 0 unless an illegal option is encountered,
5618 one of the
5619 .I names
5620 is not a legal shell variable name, or
5621 .B \-f
5622 is supplied with a
5623 .I name
5624 that is not a function.
5625 .TP
5626 \fBreturn\fP [\fIn\fP]
5627 Causes a function to exit with the return value specified by
5628 .IR n .
5629 If 
5630 .I n
5631 is omitted, the return status is that of the last command
5632 executed in the function body.  If used outside a function,
5633 but during execution of a script by the 
5634 .B .
5635 (\fBsource\fP) command, it causes the shell to stop executing
5636 that script and return either
5637 .I n
5638 or the exit status of the last command executed within the
5639 script as the exit status of the script.  If used outside a
5640 function and not during execution of a script by \fB.\fP\^,
5641 the return status is false.
5642 .TP
5643 \fBset\fP [\fB\-\-abefhkmnptuvxBCHP\fP] [\fB\-o\fP \fIoption\fP] [\fIarg\fP ...]
5644 Without options, the name and value of each shell variable are displayed
5645 in a format that can be re-used as input.
5646 When options are specified, they set or unset shell attributes.
5647 Any arguments remaining after the options are processed are treated
5648 as values for the positional parameters and are assigned, in order, to 
5649 .BR $1 ,
5650 .BR $2 ,
5651 .B ...
5652 .BR $\fIn\fP .
5653 Options, if specified, have the following meanings:
5654 .RS
5655 .PD 0
5656 .TP 8
5657 .B \-a
5658 Automatically mark variables which are modified or created for export
5659 to the environment of subsequent commands.
5660 .TP 8
5661 .B \-b
5662 Report the status of terminated background jobs
5663 immediately, rather than before the next primary prompt.  This is
5664 effective only when job control is enabled.
5665 .TP 8
5666 .B \-e
5667 Exit immediately if a \fIsimple command\fP (see
5668 .SM
5669 .B SHELL GRAMMAR
5670 above) exits with a non-zero status.  The shell does not exit if the
5671 command that fails is part of an
5672 .I until
5673 or
5674 .I while
5675 loop,
5676 part of an
5677 .I if
5678 statement, part of a
5679 .B &&
5680 or
5681 .B \(bv\(bv
5682 list, or if the command's return value is
5683 being inverted via
5684 .BR ! .
5685 .TP 8
5686 .B \-f
5687 Disable pathname expansion.
5688 .TP 8 
5689 .B \-h
5690 Remember the location of commands as they are looked up for execution.
5691 This is on by default.
5692 .TP 8
5693 .B \-k
5694 All arguments in the form of assignment statements
5695 are placed in the environment for a command, not just
5696 those that precede the command name.
5697 .TP 8
5698 .B \-m
5699 Monitor mode.  Job control is enabled.  This flag is on
5700 by default for interactive shells on systems that support
5701 it (see
5702 .SM
5703 .B JOB CONTROL
5704 above).  Background processes run in a separate process
5705 group and a line containing their exit status is printed
5706 upon their completion.
5707 .TP 8
5708 .B \-n
5709 Read commands but do not execute them.  This may be used to 
5710 check a shell script for syntax errors.  This is ignored by
5711 interactive shells.
5712 .TP 8
5713 .B \-o \fIoption\-name\fP
5714 The \fIoption\-name\fP can be one of the following:
5715 .RS
5716 .TP 8
5717 .B allexport
5718 Same as
5719 .BR \-a .
5720 .TP 8
5721 .B braceexpand
5722 Same as
5723 .BR \-B .
5724 .TP 8
5725 .B emacs
5726 Use an emacs-style command line editing interface.  This is enabled
5727 by default when the shell is interactive, unless the shell is started
5728 with the
5729 .B \-\-noediting
5730 option.
5731 .TP 8
5732 .B errexit
5733 Same as
5734 .BR \-e .
5735 .TP 8
5736 .B hashall
5737 Same as
5738 .BR \-h .
5739 .TP 8
5740 .B histexpand
5741 Same as
5742 .BR \-H .
5743 .TP 8
5744 .B history
5745 Enable command history, as described above under
5746 .SM
5747 .BR HISTORY .
5748 This option is on by default in interactive shells.
5749 .TP 8
5750 .B ignoreeof
5751 The effect is as if the shell command \f(CWIGNOREEOF=10\fP had been executed
5752 (see
5753 .B Shell Variables
5754 above).
5755 .TP 8
5756 .B keyword
5757 Same as
5758 .BR \-k .
5759 .TP 8
5760 .B monitor
5761 Same as
5762 .BR \-m .
5763 .TP 8
5764 .B noclobber
5765 Same as
5766 .BR \-C .
5767 .TP 8
5768 .B noexec
5769 Same as
5770 .BR \-n .
5771 .TP 8
5772 .B noglob
5773 Same as
5774 .BR \-f .
5775 .TP 8
5776 .B notify
5777 Same as
5778 .BR \-b .
5779 .TP 8
5780 .B nounset
5781 Same as
5782 .BR \-u .
5783 .TP 8
5784 .B onecmd
5785 Same as
5786 .BR \-t .
5787 .TP 8
5788 .B physical
5789 Same as
5790 .BR \-P .
5791 .TP 8
5792 .B posix
5793 Change the behavior of
5794 .B bash
5795 where the default operation differs
5796 from the POSIX 1003.2 standard to match the standard.
5797 .TP 8
5798 .B privileged
5799 Same as
5800 .BR \-p .
5801 .TP 8
5802 .B verbose
5803 Same as
5804 .BR \-v .
5805 .TP 8
5806 .B vi
5807 Use a vi-style command line editing interface.
5808 .TP 8
5809 .B xtrace
5810 Same as
5811 .BR \-x .
5812 .sp .5
5813 .PP
5814 If
5815 .B \-o
5816 is supplied with no \fIoption\-name\fP, the values of the current options are
5817 printed.
5818 If
5819 .B +o
5820 is supplied with no \fIoption\-name\fP, a series of
5821 .B set
5822 commands to recreate the current option settings is displayed on
5823 the standard output.
5824 .RE
5825 .TP 8
5826 .B \-p
5827 Turn on
5828 .I privileged
5829 mode.  In this mode, the
5830 .B $ENV
5831 file is not processed, and shell functions
5832 are not inherited from the environment.  This is enabled automatically
5833 on startup if the effective user (group) id is not equal to the real
5834 user (group) id.  Turning this option off causes the effective user
5835 and group ids to be set to the real user and group ids.
5836 .TP 8
5837 .B \-t
5838 Exit after reading and executing one command.
5839 .TP 8
5840 .B \-u
5841 Treat unset variables as an error when performing
5842 parameter expansion.  If expansion is attempted on an
5843 unset variable, the shell prints an error message, and,
5844 if not interactive, exits with a non-zero status.
5845 .TP 8
5846 .B \-v
5847 Print shell input lines as they are read.
5848 .TP 8
5849 .B \-x
5850 After expanding each \fIsimple command\fP,
5851 display the expanded value of
5852 .SM
5853 .BR PS4 ,
5854 followed by the command and its expanded arguments.
5855 .TP 8
5856 .B \-B
5857 The shell performs brace expansion (see
5858 .B Brace Expansion
5859 above).  This is on by default.
5860 .TP 8
5861 .B \-C
5862 If set,
5863 .B bash
5864 does not overwrite an existing file with the
5865 .BR > ,
5866 .BR >& ,
5867 and
5868 .B <>
5869 redirection operators.  This may be overridden when 
5870 creating output files by using the redirection operator
5871 .B >|
5872 instead of
5873 .BR > .
5874 .TP 8
5875 .B \-H
5876 Enable
5877 .B !
5878 style history substitution.  This flag is on by
5879 default when the shell is interactive.
5880 .TP 8
5881 .B \-P
5882 If set, the shell does not follow symbolic links when executing
5883 commands such as
5884 .B cd
5885 that change the current working directory.  It uses the
5886 physical directory structure instead.  By default,
5887 .B bash
5888 follows the logical chain of directories when performing commands
5889 which change the current directory.
5890 .TP 8
5891 .B \-\-
5892 If no arguments follow this flag, then the positional parameters are
5893 unset.  Otherwise, the positional parameters are set to the
5894 \fIarg\fPs, even if some of them begin with a
5895 .BR \- .
5896 .TP 8
5897 .B \-
5898 Signal the end of options, cause all remaining \fIarg\fPs to be
5899 assigned to the positional parameters.  The
5900 .B \-x
5901 and
5902 .B \-v
5903 options are turned off.
5904 If there are no \fIarg\fPs,
5905 the positional parameters remain unchanged.
5906 .PD
5907 .PP
5908 The flags are off by default
5909 unless otherwise noted.
5910 Using + rather than \- causes these flags
5911 to be turned off.  The
5912 flags can also be specified as options to an
5913 invocation of the shell.  The current
5914 set of flags may be found in
5915 .BR $\- .
5916 The return status is always true
5917 unless an illegal option is encountered.
5918 .RE
5919 .TP
5920 \fBshift\fP [\fIn\fP]
5921 The positional parameters from \fIn\fP+1 ... are renamed to
5922 .B $1
5923 .B ....
5924 Parameters represented by the numbers \fB$#\fP
5925 down to \fB$#\fP\-\fIn\fP+1 are unset.
5926 .I n
5927 must be a non-negative number less than or equal to \fB$#\fP.
5928 If
5929 .I n
5930 is 0, no parameters are changed.
5931 If
5932 .I n 
5933 is not given, it is assumed to be 1.
5934 If
5935 .I n
5936 is greater than \fB$#\fP, the positional parameters are not changed.
5937 The return status is greater than zero if
5938 .I n
5939 is greater than
5940 .B $#
5941 or less than zero; otherwise 0.
5942 .TP
5943 \fBshopt\fP [\fB\-pqsu\fP] [\fB\-o\fP] [\fIoptname\fP ...]
5944 Toggle the values of variables controlling optional shell behavior.
5945 With no options, or with the
5946 .B \-p
5947 option, a list of all settable options is displayed, with
5948 an indication of whether or not each is set.  Other options have
5949 the following meanings:
5950 .RS
5951 .PD 0
5952 .TP
5953 .B \-s
5954 Enable (set) each \fIoptname\fP.
5955 .TP
5956 .B \-u
5957 Disable (unset) each \fIoptname\fP.
5958 .TP
5959 .B \-q
5960 Suppresses normal output (quiet mode); the return status indicates
5961 whether the \fIoptname\fP is set or unset.
5962 If multiple \fIoptname\fP arguments are given with
5963 .BR \-q ,
5964 the return status is zero if all \fIoptnames\fP are enabled; non-zero
5965 otherwise.
5966 .TP
5967 .B \-o
5968 Restricts the values of \fIoptname\fP to be those defined for the
5969 .B \-o
5970 option to the
5971 .B set
5972 builtin.
5973 .PD
5974 .PP
5975 If either
5976 .B \-s
5977 or
5978 .B \-u
5979 is used with no \fIoptname\fP arguments, the display is limited to
5980 those options which are set or unset, respectively.
5981 Unless otherwise noted, the \fBshopt\fP options are disabled (unset)
5982 by default.
5983 .PP
5984 The return status when listing options is zero if all \fIoptnames\fP
5985 are enabled, non-zero otherwise.  When setting or unsetting options,
5986 the return status is zero unless an \fIoptname\fP is not a legal shell
5987 option.
5988 .PP
5989 The list of \fBshopt\fP options is:
5990 .if t .sp .5v
5991 .if n .sp 1v
5992 .PD 0
5993 .TP 8
5994 .B cdable_vars
5995 If set, an argument to the
5996 .B cd
5997 builtin command that
5998 is not a directory is assumed to be the name of a variable whose
5999 value is the directory to change to.
6000 .TP 8
6001 .B cdspell
6002 If set, minor errors in the spelling of a directory component in a
6003 .B cd
6004 command will be corrected.
6005 The errors checked for are transposed characters,
6006 a missing character, and one character too many.
6007 If a correction is found, the corrected file name is printed,
6008 and the command proceeds.
6009 This option is enabled by default, but is only used by interactive shells.
6010 .TP 8
6011 .B checkhash
6012 If set, \fBbash\fP checks that a command found in the hash
6013 table exists before trying to execute it.  If a hashed command no
6014 longer exists, a normal path search is performed.
6015 .TP 8
6016 .B checkwinsize
6017 If set, \fBbash\fP checks the window size after each command
6018 and, if necessary, updates the values of
6019 .SM
6020 .B LINES
6021 and
6022 .SM
6023 .BR COLUMNS .
6024 .TP 8
6025 .B cmdhist
6026 If set,
6027 .B bash
6028 attempts to save all lines of a multiple-line
6029 command in the same history entry.  This allows
6030 easy re-editing of multi-line commands.
6031 .TP 8
6032 .B dotglob
6033 If set, 
6034 .B bash
6035 includes filenames beginning with a `.' in the results of pathname
6036 expansion.
6037 .TP 8
6038 .B execfail
6039 If set, a non-interactive shell will not exit if
6040 it cannot execute the file specified as an argument to the
6041 .B exec
6042 builtin command.  An interactive shell does not exit if
6043 .B exec
6044 fails.
6045 .TP 8
6046 .B expand_aliases
6047 If set, aliases are expanded as described above under
6048 .SM
6049 .BR ALIASES .
6050 This option is enabled by default for interactive shells.
6051 .TP 8
6052 .B histappend
6053 If set, the history list is appended to the file named by the value
6054 of the
6055 .B HISTFILE
6056 variable when the shell exits, rather than overwriting the file.
6057 .TP 8
6058 .B histreedit
6059 If set, and
6060 .B readline
6061 is being used, a user is given the opportunity to re-edit a
6062 failed history substitution.
6063 .TP 8
6064 .B histverify
6065 If set, and 
6066 .B readline
6067 is being used, the results of history substitution are not immediately
6068 passed to the shell parser.  Instead, the resulting line is loaded into
6069 the \fBreadline\fP editing buffer, allowing further modification.
6070 .TP 8
6071 .B hostcomplete
6072 If set, and
6073 .B readline
6074 is being used, bash will attempt to perform hostname completion when a
6075 word beginning with \fB@\fP is being completed (see
6076 .B Completing
6077 under
6078 .SM
6079 .B READLINE
6080 above).
6081 This is enabled by default.
6082 .TP 8
6083 .B interactive_comments
6084 If set, allow a word beginning with
6085 .B #
6086 to cause that word and all remaining characters on that
6087 line to be ignored in an interactive shell (see
6088 .SM
6089 .B COMMENTS
6090 above).  This option is enabled by default.
6091 .TP 8
6092 .B lithist
6093 If set, and the
6094 .B cmdhist
6095 option is enabled, multi-line commands are saved to the history with
6096 embedded newlines rather than using semicolon separators where possible.
6097 .TP 8
6098 .B mailwarn
6099 If set, and a file that \fBbash\fP is checking for mail has been  
6100 accessed since the last time it was checked, the message ``The mail in
6101 \fImailfile\fP has been read'' is displayed.
6102 .TP 8
6103 .B nullglob
6104 If set,
6105 .B bash
6106 allows patterns which match no
6107 files (see
6108 .B Pathname Expansion
6109 above)
6110 to expand to a null string, rather than themselves.
6111 .TP 8
6112 .B promptvars
6113 If set, prompt strings undergo variable and parameter expansion after
6114 being expanded as described in
6115 .SM
6116 .B PROMPTING
6117 above.  This option is enabled by default.
6118 .TP 8
6119 .B shift_verbose
6120 If set, the
6121 .B shift
6122 builtin prints an error message when the shift count exceeds the
6123 number of positional parameters.
6124 .TP 8
6125 .B sourcepath
6126 If set, the
6127 \fBsource\fP (\fB.\fP) builtin uses the value of
6128 .SM
6129 .B PATH
6130 to find the directory containing the file supplied as an argument.
6131 This is enabled by default.
6132 .RE
6133 .TP
6134 \fBsuspend\fP [\fB\-f\fP]
6135 Suspend the execution of this shell until it receives a
6136 .SM
6137 .B SIGCONT
6138 signal.  The
6139 .B \-f
6140 option says not to complain if this is 
6141 a login shell; just suspend anyway.  The return status is 0 unless
6142 the shell is a login shell and
6143 .B \-f
6144 is not supplied, or if job control is not enabled.
6145 .TP
6146 .PD 0
6147 \fBtest\fP \fIexpr\fP
6148 .TP
6149 \fB[\fP \fIexpr\fP \fB]\fP
6150 Return a status of 0 or 1 depending on
6151 the evaluation of the conditional expression
6152 .IR expr .
6153 Expressions may be unary or binary.  Unary
6154 expressions are often used to examine the status of a file.  There
6155 are string operators and numeric comparison operators as well.  Each
6156 operator and operand must be a separate argument.  If \fIfile\fP
6157 is of the form /dev/fd/\fIn\fP, then file descriptor \fIn\fP is
6158 checked.  Expressions are composed of the following primaries:
6159 .RS
6160 .PD 0
6161 .TP
6162 .B \-b \fIfile\fP
6163 True if \fIfile\fP exists and is a block special file.
6164 .TP
6165 .B \-c \fIfile\fP
6166 True if \fIfile\fP exists and is a character special file.
6167 .TP
6168 .B \-d \fIfile\fP
6169 True if \fIfile\fP exists and is a directory.
6170 .TP
6171 .B \-e \fIfile\fP
6172 True if \fIfile\fP exists.
6173 .TP
6174 .B \-f \fIfile\fP
6175 True if \fIfile\fP exists and is a regular file.
6176 .TP
6177 .B \-g \fIfile\fP
6178 True if \fIfile\fP exists and is set-group-id.
6179 .TP
6180 .B \-k \fIfile\fP
6181 True if \fIfile\fP has its ``sticky'' bit set.
6182 .TP
6183 .B \-L \fIfile\fP
6184 True if \fIfile\fP exists and is a symbolic link.
6185 .TP
6186 .B \-p \fIfile\fP
6187 True if \fIfile\fP exists and is a named pipe.
6188 .TP
6189 .B \-r \fIfile\fP
6190 True if \fIfile\fP exists and is readable.
6191 .TP
6192 .B \-s \fIfile\fP
6193 True if \fIfile\fP exists and has a size greater than zero.
6194 .TP
6195 .B \-S \fIfile\fP
6196 True if \fIfile\fP exists and is a socket.
6197 .TP
6198 .B \-t \fIfd\fP
6199 True if
6200 .I fd
6201 is opened on a terminal.
6202 .TP
6203 .B \-u \fIfile\fP
6204 True if \fIfile\fP exists and its set-user-id bit is set.
6205 .TP
6206 .B \-w \fIfile\fP
6207 True if \fIfile\fP exists and is writable.
6208 .TP
6209 .B \-x \fIfile\fP
6210 True if \fIfile\fP exists and is executable.
6211 .TP
6212 .B \-O \fIfile\fP
6213 True if \fIfile\fP exists and is owned by the effective user id.
6214 .TP
6215 .B \-G \fIfile\fP
6216 True if \fIfile\fP exists and is owned by the effective group id.
6217 .TP
6218 \fIfile1\fP \-\fBnt\fP \fIfile2\fP
6219 True if \fIfile1\fP is newer (according to
6220 modification date) than \fIfile2\fP.
6221 .TP
6222 \fIfile1\fP \-\fBot\fP \fIfile2\fP
6223 True if \fIfile1\fP is older than \fIfile2\fP.
6224 .TP
6225 \fIfile1\fP \fB\-ef\fP \fIfile2\fP
6226 True if \fIfile1\fP and \fIfile2\fP have the same device and
6227 inode numbers.
6228 .TP
6229 .B \-o \fIoptname\fP
6230 True if shell option
6231 .I optname
6232 is enabled.
6233 See the list of options under the description of the
6234 .B \-o
6235 option to the
6236 .B set
6237 builtin above.
6238 .TP
6239 .B \-z \fIstring\fP
6240 True if the length of \fIstring\fP is zero.
6241 .TP
6242 .B \-n \fIstring\fP
6243 .TP
6244 \fIstring\fP
6245 True if the length of
6246 .I string
6247 is non-zero.
6248 .TP
6249 \fIstring1\fP \fB=\fP \fIstring2\fP
6250 True if the strings are equal.  \fB==\fP may be used in place of
6251 \fB=\fP.
6252 .TP
6253 \fIstring1\fP \fB!=\fP \fIstring2\fP
6254 True if the strings are not equal.
6255 .TP
6256 \fIstring1\fP \fB<\fP \fIstring2\fP
6257 True if \fIstring1\fP sorts before \fIstring2\fP lexicographically.
6258 .TP
6259 \fIstring1\fP \fB>\fP \fIstring2\fP
6260 True if \fIstring1\fP sorts after \fIstring2\fP lexicographically.
6261 .TP
6262 .B ! \fIexpr\fP
6263 True if
6264 .I expr
6265 is false.
6266 .TP
6267 \fIexpr1\fP \-\fBa\fP \fIexpr2\fP
6268 True if both
6269 .I expr1
6270 AND
6271 .I expr2
6272 are true.
6273 .TP
6274 \fIexpr1\fP \-\fBo\fP \fIexpr2\fP
6275 True if either
6276 .I expr1
6277 OR
6278 .I expr2
6279 is true.
6280 .TP
6281 .I \fIarg1\fP \fBOP\fP \fIarg2\fP
6282 .SM
6283 .B OP
6284 is one of
6285 .BR \-eq ,
6286 .BR \-ne ,
6287 .BR \-lt ,
6288 .BR \-le ,
6289 .BR \-gt ,
6290 or
6291 .BR \-ge .
6292 These arithmetic binary operators return true if \fIarg1\fP
6293 is equal to, not equal to, less than, less than or equal to,
6294 greater than, or greater than or equal to \fIarg2\fP, respectively.
6295 .I Arg1
6296 and
6297 .I arg2
6298 may be positive or negative integers.
6299 .PD
6300 .RE
6301 .TP
6302 .B times
6303 Print the accumulated user and system times for the shell and
6304 for processes run from the shell.  The return status is 0.
6305 .TP
6306 \fBtrap\fP [\fB\-lp\fP] [\fIarg\fP] [\fIsigspec\fP]
6307 The command
6308 .I arg
6309 is to be read and executed when the shell receives
6310 signal(s)
6311 .IR sigspec .
6312 If
6313 .I arg
6314 is absent or
6315 .BR \- ,
6316 all specified signals are
6317 reset to their original values (the values they had
6318 upon entrance to the shell).  If 
6319 .I arg
6320 is the null string this
6321 signal is ignored by the shell and by the
6322 commands it invokes.
6323 If
6324 .I arg
6325 is
6326 .B \-p
6327 then the trap commands associated with
6328 each
6329 .I sigspec
6330 are displayed.  If no arguments are supplied or if
6331 only
6332 .B \-p
6333 is given,
6334 .B trap
6335 prints the list of commands associated with each signal number.
6336 .I sigspec
6337 is either
6338 a signal name defined in <\fIsignal.h\fP>, or a signal number.  If
6339 .I sigspec
6340 is
6341 .SM
6342 .B EXIT
6343 (0) the command
6344 .I arg
6345 is executed on exit from the shell.  If
6346 .I sigspec
6347 is
6348 .SM
6349 .BR DEBUG ,
6350 the command
6351 .I arg
6352 is executed after every \fIsimple command\fP (see
6353 .SM
6354 .B SHELL GRAMMAR
6355 above).
6356 The
6357 .B \-l
6358 option causes the shell to print a list of signal names and
6359 their corresponding numbers.
6360 Signals ignored upon entry to the shell cannot be trapped or reset.
6361 Trapped signals are reset to their original values in a child
6362 process when it is created.  The return status is false if any
6363 .I sigspec
6364 is invalid; otherwise
6365 .B trap
6366 returns true.
6367 .TP
6368 \fBtype\fP [\fB\-all\fP] [\fB\-type\fP | \fB\-path\fP] \fIname\fP [\fIname\fP ...]
6369 With no options, 
6370 indicate how each
6371 .I name
6372 would be interpreted if used as a command name.
6373 If the
6374 .B \-type
6375 flag is used,
6376 .B type
6377 prints a string which is one of
6378 .IR alias ,
6379 .IR keyword ,
6380 .IR function ,
6381 .IR builtin ,
6382 or
6383 .I file 
6384 if
6385 .I name
6386 is an alias, shell reserved word, function, builtin, or disk file,
6387 respectively.
6388 If the
6389 .I name
6390 is not found, then nothing is printed, and an exit status of false
6391 is returned.
6392 If the
6393 .B \-path
6394 flag is used,
6395 .B type
6396 either returns the name of the disk file
6397 that would be executed if
6398 .I name
6399 were specified as a command name,
6400 or nothing if
6401 .B \-type
6402 would not return
6403 .IR file .
6404 If a command is hashed,
6405 .B \-path
6406 prints the hashed value, not necessarily the file that appears
6407 first in 
6408 .SM
6409 .BR PATH .
6410 If the
6411 .B \-all
6412 flag is used, 
6413 .B type
6414 prints all of the places that contain
6415 an executable named 
6416 .IR name .
6417 This includes aliases and functions,
6418 if and only if the 
6419 .B \-path
6420 flag is not also used.
6421 The table of hashed commands is not consulted
6422 when using
6423 .BR \-all .
6424 .B type
6425 accepts
6426 .BR \-a ,
6427 .BR \-t ,
6428 and
6429 .B \-p
6430 in place of
6431 .BR \-all ,
6432 .BR \-type ,
6433 and
6434 .BR \-path ,
6435 respectively.
6436 .B type
6437 returns true if any of the arguments are found, false if
6438 none are found.
6439 .TP
6440 \fBulimit\fP [\fB\-SHacdflmnpstuv\fP [\fIlimit\fP]]
6441 Provides control over the resources available to the shell and to
6442 processes started by it, on systems that allow such control.  The
6443 value of
6444 .I limit
6445 can be a number in the unit specified for the resource, or the
6446 value
6447 .BR unlimited .
6448 The \fB\-H\fP and \fB\-S\fP options specify that the hard or soft limit is
6449 set for the given resource.  A hard limit cannot be increased once it
6450 is set; a soft limit may be increased up to the value of the hard limit.
6451 If neither \fB\-H\fP nor \fB\-S\fP is specified, both the soft and hard
6452 limits are set.
6453 If
6454 .I limit
6455 is omitted, the current value of the soft limit of the resource is
6456 printed, unless the \fB\-H\fP option is given.  When more than one
6457 resource is specified, the limit name and unit are printed before the value.
6458 Other options are interpreted as follows:
6459 .RS
6460 .PD 0
6461 .TP
6462 .B \-a
6463 All current limits are reported
6464 .TP
6465 .B \-c
6466 The maximum size of core files created
6467 .TP
6468 .B \-d
6469 The maximum size of a process's data segment
6470 .TP
6471 .B \-f
6472 The maximum size of files created by the shell
6473 .TP
6474 .B \-l
6475 The maximum size that may be locked into memory
6476 .TP
6477 .B \-m
6478 The maximum resident set size
6479 .TP
6480 .B \-n
6481 The maximum number of open file descriptors (most systems do not
6482 allow this value to be set)
6483 .TP
6484 .B \-p
6485 The pipe size in 512-byte blocks (this may not be set)
6486 .TP
6487 .B \-s
6488 The maximum stack size
6489 .TP
6490 .B \-t
6491 The maximum amount of cpu time in seconds
6492 .TP
6493 .B \-u
6494 The maximum number of processes available to a single user
6495 .TP
6496 .B \-v
6497 The maximum amount of virtual memory available to the shell
6498 .PD
6499 .PP
6500 If
6501 .I limit
6502 is given, it is the new value of the specified resource (the
6503 .B \-a
6504 option is display only).
6505 If no option is given, then
6506 .B \-f
6507 is assumed.  Values are in 1024-byte increments, except for
6508 .BR \-t ,
6509 which is in seconds,
6510 .BR \-p ,
6511 which is in units of 512-byte blocks,
6512 and
6513 .B \-n
6514 and
6515 .BR \-u ,
6516 which are unscaled values.  The return status is 0
6517 unless an illegal option is encountered, a non-numeric argument
6518 other than \fBunlimited\fP is supplied as \fIlimit\fP, or an
6519 error occurs while setting a new limit.
6520 .RE
6521 .TP
6522 \fBumask\fP [\fB\-S\fP] [\fImode\fP]
6523 The user file-creation mask is set to 
6524 .IR mode .
6525 If
6526 .I mode
6527 begins with a digit, it
6528 is interpreted as an octal number; otherwise
6529 it is interpreted as a symbolic mode mask similar
6530 to that accepted by
6531 .IR chmod (1).
6532 If
6533 .I mode
6534 is omitted, or if the 
6535 .B \-S
6536 option is supplied, the
6537 current value of the mask is printed.
6538 The
6539 .B \-S
6540 option causes the mask to be printed in symbolic form; the
6541 default output is an octal number.
6542 The return status is 0 if the mode was successfully changed or if
6543 no \fImode\fP argument was supplied, and false otherwise.
6544 .TP
6545 \fBunalias\fP [\-\fBa\fP] [\fIname\fP ...]
6546 Remove \fIname\fPs from the list of defined aliases.  If
6547 .B \-a
6548 is supplied, all alias definitions are removed.  The return
6549 value is true unless a supplied
6550 .I name
6551 is not a defined alias.
6552 .TP
6553 \fBunset\fP [\-\fBfv\fP] [\fIname\fP ...]
6554 For each
6555 .IR name ,
6556 remove the corresponding variable or function.
6557 If no options are supplied, or the
6558 .B \-v
6559 option is given, each
6560 .I name
6561 refers to a shell variable.
6562 Read-only variables may not be unset.
6563 If
6564 .B \-f
6565 is specifed, 
6566 each
6567 .I name
6568 refers to a shell function, and the function definition
6569 is removed.
6570 Each unset variable or function is removed from the environment
6571 passed to subsequent commands.
6572 If any of
6573 .SM
6574 .BR RANDOM ,
6575 .SM
6576 .BR SECONDS ,
6577 .SM
6578 .BR LINENO ,
6579 .SM
6580 .BR HISTCMD ,
6581 or
6582 .SM
6583 .B DIRSTACK
6584 are unset, they lose their special properties, even if they are
6585 subsequently reset.  The exit status is true unless a
6586 .I name
6587 does not exist or is readonly.
6588 .TP
6589 \fBwait\fP [\fIn\fP]
6590 Wait for the specified process and return its termination
6591 status.
6592 .I n
6593 may be a process
6594 ID or a job specification; if a job spec is given, all processes
6595 in that job's pipeline are waited for.  If
6596 .I n
6597 is not given, all currently active child processes
6598 are waited for, and the return status is zero.  If
6599 .I n
6600 specifies a non-existent process or job, the return status is
6601 127.  Otherwise, the return status is the exit status of the last
6602 process or job waited for.
6603 .\" bash_builtins
6604 .if \n(zZ=1 .ig zZ
6605 .SH "RESTRICTED SHELL"
6606 .PP
6607 If
6608 .B bash
6609 is started with the name
6610 .BR rbash ,
6611 or the
6612 .B \-r
6613 option is supplied at invocation,
6614 the shell becomes restricted.
6615 A restricted shell is used to
6616 set up an environment more controlled than the standard shell.
6617 It behaves identically to
6618 .B bash
6619 with the exception that the following are disallowed:
6620 .IP \(bu
6621 changing directories with \fBcd\fP
6622 .IP \(bu
6623 setting or unsetting the values of
6624 .B SHELL
6625 or
6626 .B PATH
6627 .IP \(bu
6628 specifying command names containing
6629 .B /
6630 .IP \(bu
6631 specifying a file name containing a
6632 .B /
6633 as an argument to the
6634 .B .
6635 builtin command
6636 .IP \(bu
6637 importing function definitions from the shell environment at startup
6638 .IP \(bu
6639 redirecting output using the >, >|, <>, >&, &>, and >> redirection operators
6640 .IP \(bu
6641 using the
6642 .B exec
6643 builtin command to replace the shell with another command
6644 .IP \(bu
6645 adding or deleting builtin commands with the
6646 .B \-f
6647 and
6648 .B \-d
6649 options to the
6650 .B enable
6651 builtin command
6652 .IP \(bu
6653 specifying the
6654 .B \-p
6655 option to the
6656 .B command
6657 builtin command
6658 .IP \(bu
6659 turning off restricted mode with
6660 .BR "set +r" .
6661 .PP
6662 These restrictions are enforced after any startup files are read.
6663 .PP
6664 When a command that is found to be a shell script is executed (see
6665 .SM
6666 .B "COMMAND EXECUTION"
6667 above),
6668 .B rbash
6669 turns off any restrictions in the shell spawned to execute the
6670 script.
6671 .SH "SEE ALSO"
6672 .PD 0
6673 .TP
6674 \fIBash Features\fP, Brian Fox and Chet Ramey
6675 .TP
6676 \fIThe Gnu Readline Library\fP, Brian Fox and Chet Ramey
6677 .TP
6678 \fIThe Gnu History Library\fP, Brian Fox and Chet Ramey
6679 .TP
6680 \fIPortable Operating System Interface (POSIX) Part 2: Shell and Utilities\fP, IEEE
6681 .TP
6682 \fIsh\fP(1), \fIksh\fP(1), \fIcsh\fP(1)
6683 .TP
6684 \fIemacs\fP(1), \fIvi\fP(1)
6685 .TP
6686 \fIreadline\fP(3)
6687 .PD
6688 .SH FILES
6689 .PD 0
6690 .TP
6691 .FN /bin/bash
6692 The \fBbash\fP executable
6693 .TP
6694 .FN /etc/profile
6695 The systemwide initialization file, executed for login shells
6696 .TP
6697 .FN ~/.bash_profile
6698 The personal initialization file, executed for login shells
6699 .TP
6700 .FN ~/.bashrc
6701 The individual per-interactive-shell startup file
6702 .TP
6703 .FN ~/.inputrc
6704 Individual \fIreadline\fP initialization file
6705 .PD
6706 .SH AUTHORS
6707 Brian Fox, Free Software Foundation
6708 .br
6709 bfox@gnu.ai.MIT.Edu
6710 .PP
6711 Chet Ramey, Case Western Reserve University
6712 .br
6713 chet@ins.CWRU.Edu
6714 .SH BUG REPORTS
6715 If you find a bug in
6716 .B bash,
6717 you should report it.  But first, you should
6718 make sure that it really is a bug, and that it appears in the latest
6719 version of
6720 .B bash
6721 that you have.
6722 .PP
6723 Once you have determined that a bug actually exists, use the
6724 .I bashbug
6725 command to submit a bug report.
6726 If you have a fix, you are welcome to mail that
6727 as well!
6728 Suggestions and `philosophical' bug reports may be mailed
6729 to \fPbug-bash\fP@\fIprep.ai.MIT.Edu\fP or posted to the Usenet
6730 newsgroup
6731 .BR gnu.bash.bug .
6732 .PP
6733 ALL bug reports should include:
6734 .PP
6735 .PD 0
6736 .TP 20
6737 The version number of \fBbash\fR
6738 .TP
6739 The hardware and operating system
6740 .TP
6741 The compiler used to compile
6742 .TP
6743 A description of the bug behaviour
6744 .TP
6745 A short script or `recipe' which exercises the bug
6746 .PD
6747 .PP
6748 .I bashbug
6749 inserts the first three items automatically into the template
6750 it provides for filing a bug report.
6751 .PP
6752 Comments and bug reports concerning
6753 this manual page should be directed to
6754 .IR chet@ins.CWRU.Edu .
6755 .SH BUGS
6756 .PP
6757 It's too big and too slow.
6758 .PP
6759 There are some subtle differences between 
6760 .B bash
6761 and traditional versions of
6762 .BR sh ,
6763 mostly because of the
6764 .SM
6765 .B POSIX
6766 specification.
6767 .PP
6768 Aliases are confusing in some uses.
6769 .PP
6770 Shell builtin commands and functions are not stoppable/restartable.
6771 .PP
6772 Compound commands and command sequences of the form `a ; b ; c'
6773 are not handled gracefully when process suspension is attempted.
6774 When a process is stopped, the shell immediately executes the next
6775 command in the sequence.
6776 It suffices to place the sequence of commands between
6777 parentheses to force it into a subshell, which may be stopped as
6778 a unit.
6779 .PP
6780 Commands inside of \fB$(\fP...\fB)\fP command substitution are not
6781 parsed until substitution is attempted.  This will delay error
6782 reporting until some time after the command is entered.
6783 .PP
6784 Array variables may not (yet) be exported.
6785 .zZ