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