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