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