Debian Codegraph @

upstream/opensuse-leap-16-1/man1/bash.1

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