2 .\" MAN PAGE COMMENTS to
5 .\" Case Western Reserve University
8 .\" Last Change: Tue Dec 29 15:36:16 EST 2009
10 .\" bash_builtins, strip all but Built-Ins section
13 .TH BASH 1 "2009 December 29" "GNU Bash-4.1"
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.
29 .if !"\\$1"" .nr )I \\$1n
32 .in \\n()Ru+\\n(INu+\\n()Iu
34 .ie !\\n()Iu+\\n()Ru-\w
\a\\*(]X
\au-3p \{\\*(]X
36 .el \\*(]X\h
\a|\\n()Iu+\\n()Ru
\a\c
40 .\" File Name macro. This used to be `.PN', for Path Name,
41 .\" but Sun doesn't seem to like that very much.
47 bash \- GNU Bourne-Again SHell
53 .if n Bash is Copyright (C) 1989-2009 by the Free Software Foundation, Inc.
54 .if t Bash is Copyright \(co 1989-2009 by the Free Software Foundation, Inc.
57 is an \fBsh\fR-compatible command language interpreter that
58 executes commands read from the standard input or from a file.
60 also incorporates useful features from the \fIKorn\fP and \fIC\fP
61 shells (\fBksh\fP and \fBcsh\fP).
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).
68 can be configured to be POSIX-conformant by default.
70 In addition to the single-character shell options documented in the
71 description of the \fBset\fR builtin command, \fBbash\fR
72 interprets the following options when it is invoked:
79 option is present, then commands are read from
81 If there are arguments after the
83 they are assigned to the positional parameters, starting with
89 option is present, the shell is
95 act as if it had been invoked as a login shell (see
103 option is present, the shell becomes
107 .B "RESTRICTED SHELL"
113 option is present, or if no arguments remain after option
114 processing, then commands are read from the standard input.
115 This option allows the positional parameters to be set
116 when invoking an interactive shell.
119 A list of all double-quoted strings preceded by \fB$\fP
120 is printed on the standard output.
121 These are the strings that
122 are subject to language translation when the current locale
123 is not \fBC\fP or \fBPOSIX\fP.
124 This implies the \fB\-n\fP option; no commands will be executed.
126 .B [\-+]O [\fIshopt_option\fP]
127 \fIshopt_option\fP is one of the shell options accepted by the
128 \fBshopt\fP builtin (see
130 .B SHELL BUILTIN COMMANDS
132 If \fIshopt_option\fP is present, \fB\-O\fP sets the value of that option;
134 If \fIshopt_option\fP is not supplied, the names and values of the shell
135 options accepted by \fBshopt\fP are printed on the standard output.
136 If the invocation option is \fB+O\fP, the output is displayed in a format
137 that may be reused as input.
142 signals the end of options and disables further option processing.
143 Any arguments after the
145 are treated as filenames and arguments. An argument of
147 is equivalent to \fB\-\-\fP.
151 also interprets a number of multi-character options.
152 These options must appear on the command line before the
153 single-character options to be recognized.
158 Arrange for the debugger profile to be executed before the shell
160 Turns on extended debugging mode (see the description of the
165 and shell function tracing (see the description of the
166 \fB\-o functrace\fP option to the
170 .B \-\-dump\-po\-strings
171 Equivalent to \fB\-D\fP, but the output is in the GNU \fIgettext\fP
172 \fBpo\fP (portable object) file format.
175 Equivalent to \fB\-D\fP.
178 Display a usage message on standard output and exit successfully.
180 \fB\-\-init\-file\fP \fIfile\fP
183 \fB\-\-rcfile\fP \fIfile\fP
185 Execute commands from
187 instead of the standard personal initialization file
189 if the shell is interactive (see
195 Equivalent to \fB\-l\fP.
200 library to read command lines when the shell is interactive.
203 Do not read either the system-wide startup file
205 or any of the personal initialization files
206 .IR ~/.bash_profile ,
212 reads these files when it is invoked as a login shell (see
218 Do not read and execute the personal initialization file
220 if the shell is interactive.
221 This option is on by default if the shell is invoked as
225 Change the behavior of \fBbash\fP where the default operation differs
226 from the POSIX standard to match the standard (\fIposix mode\fP).
229 The shell becomes restricted (see
231 .B "RESTRICTED SHELL"
235 Equivalent to \fB\-v\fP.
238 Show version information for this instance of
240 on the standard output and exit successfully.
243 If arguments remain after option processing, and neither the
247 option has been supplied, the first argument is assumed to
248 be the name of a file containing shell commands.
251 is invoked in this fashion,
253 is set to the name of the file, and the positional parameters
254 are set to the remaining arguments.
256 reads and executes commands from this file, then exits.
257 \fBBash\fP's exit status is the exit status of the last command
258 executed in the script.
259 If no commands are executed, the exit status is 0.
260 An attempt is first made to open the file in the current directory, and,
261 if no file is found, then the shell searches the directories in
266 A \fIlogin shell\fP is one whose first character of argument zero is a
268 or one started with the
272 An \fIinteractive\fP shell is one started without non-option arguments
276 whose standard input and error are
277 both connected to terminals (as determined by
279 or one started with the
291 allowing a shell script or a startup file to test this state.
293 The following paragraphs describe how
295 executes its startup files.
296 If any of the files exist but cannot be read,
299 Tildes are expanded in file names as described below under
308 is invoked as an interactive login shell, or as a non-interactive shell
309 with the \fB\-\-login\fP option, it first reads and
310 executes commands from the file \fI/etc/profile\fP, if that
312 After reading that file, it looks for \fI~/.bash_profile\fP,
313 \fI~/.bash_login\fP, and \fI~/.profile\fP, in that order, and reads
314 and executes commands from the first one that exists and is readable.
317 option may be used when the shell is started to inhibit this behavior.
319 When a login shell exits,
321 reads and executes commands from the file \fI~/.bash_logout\fP, if it
324 When an interactive shell that is not a login shell is started,
326 reads and executes commands from \fI~/.bashrc\fP, if that file exists.
327 This may be inhibited by using the
330 The \fB\-\-rcfile\fP \fIfile\fP option will force
332 to read and execute commands from \fIfile\fP instead of \fI~/.bashrc\fP.
336 is started non-interactively, to run a shell script, for example, it
337 looks for the variable
340 in the environment, expands its value if it appears there, and uses the
341 expanded value as the name of a file to read and execute.
343 behaves as if the following command were executed:
346 .if t \f(CWif [ \-n "$BASH_ENV" ]; then . "$BASH_ENV"; fi\fP
347 .if n if [ \-n "$BASH_ENV" ]; then . "$BASH_ENV"; fi
353 variable is not used to search for the file name.
357 is invoked with the name
359 it tries to mimic the startup behavior of historical versions of
361 as closely as possible,
362 while conforming to the POSIX standard as well.
363 When invoked as an interactive login shell, or a non-interactive
364 shell with the \fB\-\-login\fP option, it first attempts to
365 read and execute commands from
372 option may be used to inhibit this behavior.
373 When invoked as an interactive shell with the name
376 looks for the variable
379 expands its value if it is defined, and uses the
380 expanded value as the name of a file to read and execute.
381 Since a shell invoked as
383 does not attempt to read and execute commands from any other startup
386 option has no effect.
387 A non-interactive shell invoked with the name
389 does not attempt to read any other startup files.
395 mode after the startup files are read.
403 command line option, it follows the POSIX standard for startup files.
404 In this mode, interactive shells expand the
407 variable and commands are read and executed from the file
408 whose name is the expanded value.
409 No other startup files are read.
412 attempts to determine when it is being run with its standard input
413 connected to a a network connection, as if by the remote shell
414 daemon, usually \fIrshd\fP, or the secure shell daemon \fIsshd\fP.
417 determines it is being run in this fashion, it reads and executes
418 commands from \fI~/.bashrc\fP, if that file exists and is readable.
419 It will not do this if invoked as \fBsh\fP.
422 option may be used to inhibit this behavior, and the
424 option may be used to force another file to be read, but
425 \fIrshd\fP does not generally invoke the shell with those options
426 or allow them to be specified.
428 If the shell is started with the effective user (group) id not equal to the
429 real user (group) id, and the \fB\-p\fP option is not supplied, no startup
430 files are read, shell functions are not inherited from the environment, the
440 variables, if they appear in the environment, are ignored,
441 and the effective user id is set to the real user id.
442 If the \fB\-p\fP option is supplied at invocation, the startup behavior is
443 the same, but the effective user id is not reset.
446 The following definitions are used throughout the rest of this
454 A sequence of characters considered as a single unit by the shell.
461 consisting only of alphanumeric characters and underscores, and
462 beginning with an alphabetic character or an underscore. Also
467 A character that, when unquoted, separates words. One of the following:
471 .if t \fB| & ; ( ) < > space tab\fP
472 .if n \fB| & ; ( ) < > space tab\fP
477 A \fItoken\fP that performs a control function. It is one of the following
481 .if t \fB\(bv\(bv & && ; ;; ( ) | |& <newline>\fP
482 .if n \fB|| & && ; ;; ( ) | |& <newline>\fP
486 \fIReserved words\fP are words that have a special meaning to the shell.
487 The following words are recognized as reserved when unquoted and either
488 the first word of a simple command (see
491 below) or the third word of a
499 .if n ! case do done elif else esac fi for function if in select then until while { } time [[ ]]
500 .if t ! case do done elif else esac fi for function if in select then until while { } time [[ ]]
505 A \fIsimple command\fP is a sequence of optional variable assignments
506 followed by \fBblank\fP-separated words and redirections, and
507 terminated by a \fIcontrol operator\fP. The first word
508 specifies the command to be executed, and is passed as argument zero.
509 The remaining words are passed as arguments to the invoked command.
511 The return value of a \fIsimple command\fP is its exit status, or
512 128+\fIn\^\fP if the command is terminated by signal
516 A \fIpipeline\fP is a sequence of one or more commands separated by
517 one of the control operators
520 The format for a pipeline is:
523 [\fBtime\fP [\fB\-p\fP]] [ ! ] \fIcommand\fP [ [\fB|\fP\(bv\fB|&\fP] \fIcommand2\fP ... ]
526 The standard output of
528 is connected via a pipe to the standard input of
530 This connection is performed before any redirections specified by the
535 If \fB|&\fP is used, the standard error of \fIcommand\fP is connected to
536 \fIcommand2\fP's standard input through the pipe; it is shorthand for
538 This implicit redirection of the standard error is performed after any
539 redirections specified by the command.
541 The return status of a pipeline is the exit status of the last
542 command, unless the \fBpipefail\fP option is enabled.
543 If \fBpipefail\fP is enabled, the pipeline's return status is the
544 value of the last (rightmost) command to exit with a non-zero status,
545 or zero if all commands exit successfully.
548 precedes a pipeline, the exit status of that pipeline is the logical
549 negation of the exit status as described above.
550 The shell waits for all commands in the pipeline to
551 terminate before returning a value.
555 reserved word precedes a pipeline, the elapsed as well as user and
556 system time consumed by its execution are reported when the pipeline
558 The \fB\-p\fP option changes the output format to that specified by POSIX.
562 variable may be set to a format string that specifies how the timing
563 information should be displayed; see the description of
570 Each command in a pipeline is executed as a separate process (i.e., in a
574 A \fIlist\fP is a sequence of one or more pipelines separated by one
581 and optionally terminated by one of
587 Of these list operators,
591 have equal precedence, followed by
595 which have equal precedence.
597 A sequence of one or more newlines may appear in a \fIlist\fP instead
598 of a semicolon to delimit commands.
600 If a command is terminated by the control operator
602 the shell executes the command in the \fIbackground\fP
603 in a subshell. The shell does not wait for the command to
604 finish, and the return status is 0. Commands separated by a
606 are executed sequentially; the shell waits for each
607 command to terminate in turn. The return status is the
608 exit status of the last command executed.
610 AND and OR lists are sequences of one of more pipelines separated by the
611 \fB&&\fP and \fB\(bv\(bv\fP control operators, respectively.
612 AND and OR lists are executed with left associativity.
613 An AND list has the form
616 \fIcommand1\fP \fB&&\fP \fIcommand2\fP
620 is executed if, and only if,
622 returns an exit status of zero.
624 An OR list has the form
627 \fIcommand1\fP \fB\(bv\(bv\fP \fIcommand2\fP
632 is executed if and only if
634 returns a non-zero exit status.
636 AND and OR lists is the exit status of the last command
637 executed in the list.
638 .SS Compound Commands
640 A \fIcompound command\fP is one of the following:
643 \fIlist\fP is executed in a subshell environment (see
645 \fBCOMMAND EXECUTION ENVIRONMENT\fP
647 Variable assignments and builtin
648 commands that affect the shell's environment do not remain in effect
649 after the command completes. The return status is the exit status of
653 \fIlist\fP is simply executed in the current shell environment.
654 \fIlist\fP must be terminated with a newline or semicolon.
655 This is known as a \fIgroup command\fP.
656 The return status is the exit status of
658 Note that unlike the metacharacters \fB(\fP and \fB)\fP, \fB{\fP and
659 \fB}\fP are \fIreserved words\fP and must occur where a reserved
660 word is permitted to be recognized. Since they do not cause a word
661 break, they must be separated from \fIlist\fP by whitespace or another
665 The \fIexpression\fP is evaluated according to the rules described
668 .BR "ARITHMETIC EVALUATION" .
669 If the value of the expression is non-zero, the return status is 0;
670 otherwise the return status is 1. This is exactly equivalent to
671 \fBlet "\fIexpression\fP"\fR.
673 \fB[[\fP \fIexpression\fP \fB]]\fP
674 Return a status of 0 or 1 depending on the evaluation of
675 the conditional expression \fIexpression\fP.
676 Expressions are composed of the primaries described below under
678 .BR "CONDITIONAL EXPRESSIONS" .
679 Word splitting and pathname expansion are not performed on the words
680 between the \fB[[\fP and \fB]]\fP; tilde expansion, parameter and
681 variable expansion, arithmetic expansion, command substitution, process
682 substitution, and quote removal are performed.
683 Conditional operators such as \fB\-f\fP must be unquoted to be recognized
687 When used with \fB[[\fP, The \fB<\fP and \fB>\fP operators sort
688 lexicographically using the current locale.
691 When the \fB==\fP and \fB!=\fP operators are used, the string to the
692 right of the operator is considered a pattern and matched according
693 to the rules described below under \fBPattern Matching\fP.
696 is enabled, the match is performed without regard to the case
697 of alphabetic characters.
698 The return value is 0 if the string matches (\fB==\fP) or does not match
699 (\fB!=\fP) the pattern, and 1 otherwise.
700 Any part of the pattern may be quoted to force it to be matched as a
704 An additional binary operator, \fB=~\fP, is available, with the same
705 precedence as \fB==\fP and \fB!=\fP.
706 When it is used, the string to the right of the operator is considered
707 an extended regular expression and matched accordingly (as in \fIregex\fP(3)).
708 The return value is 0 if the string matches
709 the pattern, and 1 otherwise.
710 If the regular expression is syntactically incorrect, the conditional
711 expression's return value is 2.
714 is enabled, the match is performed without regard to the case
715 of alphabetic characters.
716 Any part of the pattern may be quoted to force it to be matched as a
718 Substrings matched by parenthesized subexpressions within the regular
719 expression are saved in the array variable
725 with index 0 is the portion of the string
726 matching the entire regular expression.
730 with index \fIn\fP is the portion of the
731 string matching the \fIn\fPth parenthesized subexpression.
734 Expressions may be combined using the following operators, listed
735 in decreasing order of precedence:
741 .B ( \fIexpression\fP )
742 Returns the value of \fIexpression\fP.
743 This may be used to override the normal precedence of operators.
745 .B ! \fIexpression\fP
750 \fIexpression1\fP \fB&&\fP \fIexpression2\fP
757 .if t \fIexpression1\fP \fB\(bv\(bv\fP \fIexpression2\fP
758 .if n \fIexpression1\fP \fB||\fP \fIexpression2\fP
769 operators do not evaluate \fIexpression2\fP if the value of
770 \fIexpression1\fP is sufficient to determine the return value of
771 the entire conditional expression.
774 \fBfor\fP \fIname\fP [ [ \fBin\fP [ \fIword ...\fP ] ] ; ] \fBdo\fP \fIlist\fP ; \fBdone\fP
775 The list of words following \fBin\fP is expanded, generating a list
777 The variable \fIname\fP is set to each element of this list
778 in turn, and \fIlist\fP is executed each time.
779 If the \fBin\fP \fIword\fP is omitted, the \fBfor\fP command executes
780 \fIlist\fP once for each positional parameter that is set (see
784 The return status is the exit status of the last command that executes.
785 If the expansion of the items following \fBin\fP results in an empty
786 list, no commands are executed, and the return status is 0.
788 \fBfor\fP (( \fIexpr1\fP ; \fIexpr2\fP ; \fIexpr3\fP )) ; \fBdo\fP \fIlist\fP ; \fBdone\fP
789 First, the arithmetic expression \fIexpr1\fP is evaluated according
790 to the rules described below under
792 .BR "ARITHMETIC EVALUATION" .
793 The arithmetic expression \fIexpr2\fP is then evaluated repeatedly
794 until it evaluates to zero.
795 Each time \fIexpr2\fP evaluates to a non-zero value, \fIlist\fP is
796 executed and the arithmetic expression \fIexpr3\fP is evaluated.
797 If any expression is omitted, it behaves as if it evaluates to 1.
798 The return value is the exit status of the last command in \fIlist\fP
799 that is executed, or false if any of the expressions is invalid.
801 \fBselect\fP \fIname\fP [ \fBin\fP \fIword\fP ] ; \fBdo\fP \fIlist\fP ; \fBdone\fP
802 The list of words following \fBin\fP is expanded, generating a list
803 of items. The set of expanded words is printed on the standard
804 error, each preceded by a number. If the \fBin\fP
805 \fIword\fP is omitted, the positional parameters are printed (see
811 prompt is then displayed and a line read from the standard input.
812 If the line consists of a number corresponding to one of
813 the displayed words, then the value of
815 is set to that word. If the line is empty, the words and prompt
816 are displayed again. If EOF is read, the command completes. Any
817 other value read causes
819 to be set to null. The line read is saved in the variable
824 is executed after each selection until a
829 is the exit status of the last command executed in
831 or zero if no commands were executed.
833 \fBcase\fP \fIword\fP \fBin\fP [ [(] \fIpattern\fP [ \fB|\fP \fIpattern\fP ] \
834 ... ) \fIlist\fP ;; ] ... \fBesac\fP
835 A \fBcase\fP command first expands \fIword\fP, and tries to match
836 it against each \fIpattern\fP in turn, using the same matching rules
837 as for pathname expansion (see
838 .B Pathname Expansion
840 The \fIword\fP is expanded using tilde
841 expansion, parameter and variable expansion, arithmetic substitution,
842 command substitution, process substitution and quote removal.
843 Each \fIpattern\fP examined is expanded using tilde
844 expansion, parameter and variable expansion, arithmetic substitution,
845 command substitution, and process substitution.
848 is enabled, the match is performed without regard to the case
849 of alphabetic characters.
850 When a match is found, the corresponding \fIlist\fP is executed.
851 If the \fB;;\fP operator is used, no subsequent matches are attempted after
852 the first pattern match.
853 Using \fB;&\fP in place of \fB;;\fP causes execution to continue with
854 the \fIlist\fP associated with the next set of patterns.
855 Using \fB;;&\fP in place of \fB;;\fP causes the shell to test the next
856 pattern list in the statement, if any, and execute any associated \fIlist\fP
857 on a successful match.
858 The exit status is zero if no
859 pattern matches. Otherwise, it is the exit status of the
860 last command executed in \fIlist\fP.
862 \fBif\fP \fIlist\fP; \fBthen\fP \fIlist;\fP \
863 [ \fBelif\fP \fIlist\fP; \fBthen\fP \fIlist\fP; ] ... \
864 [ \fBelse\fP \fIlist\fP; ] \fBfi\fP
868 is executed. If its exit status is zero, the
869 \fBthen\fP \fIlist\fP is executed. Otherwise, each \fBelif\fP
870 \fIlist\fP is executed in turn, and if its exit status is zero,
871 the corresponding \fBthen\fP \fIlist\fP is executed and the
872 command completes. Otherwise, the \fBelse\fP \fIlist\fP is
873 executed, if present. The exit status is the exit status of the
874 last command executed, or zero if no condition tested true.
876 \fBwhile\fP \fIlist\fP; \fBdo\fP \fIlist\fP; \fBdone\fP
879 \fBuntil\fP \fIlist\fP; \fBdo\fP \fIlist\fP; \fBdone\fP
881 The \fBwhile\fP command continuously executes the \fBdo\fP
882 \fIlist\fP as long as the last command in \fIlist\fP returns
883 an exit status of zero. The \fBuntil\fP command is identical
884 to the \fBwhile\fP command, except that the test is negated;
888 is executed as long as the last command in
890 returns a non-zero exit status.
891 The exit status of the \fBwhile\fP and \fBuntil\fP commands
893 of the last \fBdo\fP \fIlist\fP command executed, or zero if
897 A \fIcoprocess\fP is a shell command preceded by the \fBcoproc\fP reserved
899 A coprocess is executed asynchronously in a subshell, as if the command
900 had been terminated with the \fB&\fP control operator, with a two-way pipe
901 established between the executing shell and the coprocess.
903 The format for a coprocess is:
906 \fBcoproc\fP [\fINAME\fP] \fIcommand\fP [\fIredirections\fP]
909 This creates a coprocess named \fINAME\fP.
910 If \fINAME\fP is not supplied, the default name is \fICOPROC\fP.
911 \fINAME\fP must not be supplied if \fIcommand\fP is a \fIsimple
912 command\fP (see above); otherwise, it is interpreted as the first word
913 of the simple command.
914 When the coproc is executed, the shell creates an array variable (see
916 below) named \fINAME\fP in the context of the executing shell.
917 The standard output of
919 is connected via a pipe to a file descriptor in the executing shell,
920 and that file descriptor is assigned to \fINAME\fP[0].
921 The standard input of
923 is connected via a pipe to a file descriptor in the executing shell,
924 and that file descriptor is assigned to \fINAME\fP[1].
925 This pipe is established before any redirections specified by the
930 The file descriptors can be utilized as arguments to shell commands
931 and redirections using standard word expansions.
932 The process id of the shell spawned to execute the coprocess is
933 available as the value of the variable \fINAME\fP_PID.
935 builtin command may be used to wait for the coprocess to terminate.
937 The return status of a coprocess is the exit status of \fIcommand\fP.
938 .SS Shell Function Definitions
940 A shell function is an object that is called like a simple command and
941 executes a compound command with a new set of positional parameters.
942 Shell functions are declared as follows:
944 [ \fBfunction\fP ] \fIname\fP () \fIcompound\-command\fP [\fIredirection\fP]
945 This defines a function named \fIname\fP.
946 The reserved word \fBfunction\fP is optional.
947 If the \fBfunction\fP reserved word is supplied, the parentheses are optional.
948 The \fIbody\fP of the function is the compound command
950 (see \fBCompound Commands\fP above).
951 That command is usually a \fIlist\fP of commands between { and }, but
952 may be any command listed under \fBCompound Commands\fP above.
953 \fIcompound\-command\fP is executed whenever \fIname\fP is specified as the
954 name of a simple command.
955 Any redirections (see
958 below) specified when a function is defined are performed
959 when the function is executed.
960 The exit status of a function definition is zero unless a syntax error
961 occurs or a readonly function with the same name already exists.
962 When executed, the exit status of a function is the exit status of the
963 last command executed in the body. (See
968 In a non-interactive shell, or an interactive shell in which the
969 .B interactive_comments
972 builtin is enabled (see
974 .B "SHELL BUILTIN COMMANDS"
975 below), a word beginning with
977 causes that word and all remaining characters on that line to
978 be ignored. An interactive shell without the
979 .B interactive_comments
980 option enabled does not allow comments. The
981 .B interactive_comments
982 option is on by default in interactive shells.
984 \fIQuoting\fP is used to remove the special meaning of certain
985 characters or words to the shell. Quoting can be used to
986 disable special treatment for special characters, to prevent
987 reserved words from being recognized as such, and to prevent
990 Each of the \fImetacharacters\fP listed above under
993 has special meaning to the shell and must be quoted if it is to
996 When the command history expansion facilities are being used
1001 \fIhistory expansion\fP character, usually \fB!\fP, must be quoted
1002 to prevent history expansion.
1004 There are three quoting mechanisms: the
1005 .IR "escape character" ,
1006 single quotes, and double quotes.
1008 A non-quoted backslash (\fB\e\fP) is the
1009 .IR "escape character" .
1010 It preserves the literal value of the next character that follows,
1011 with the exception of <newline>. If a \fB\e\fP<newline> pair
1012 appears, and the backslash is not itself quoted, the \fB\e\fP<newline>
1013 is treated as a line continuation (that is, it is removed from the
1014 input stream and effectively ignored).
1016 Enclosing characters in single quotes preserves the literal value
1017 of each character within the quotes. A single quote may not occur
1018 between single quotes, even when preceded by a backslash.
1020 Enclosing characters in double quotes preserves the literal value
1021 of all characters within the quotes, with the exception of
1025 and, when history expansion is enabled,
1031 retain their special meaning within double quotes. The backslash
1032 retains its special meaning only when followed by one of the following
1040 A double quote may be quoted within double quotes by preceding it with
1042 If enabled, history expansion will be performed unless an
1044 appearing in double quotes is escaped using a backslash.
1045 The backslash preceding the
1049 The special parameters
1053 have special meaning when in double
1059 Words of the form \fB$\fP\(aq\fIstring\fP\(aq are treated specially. The
1060 word expands to \fIstring\fP, with backslash-escaped characters replaced
1061 as specified by the ANSI C standard. Backslash escape sequences, if
1062 present, are decoded as follows:
1102 the eight-bit character whose value is the octal value \fInnn\fP
1103 (one to three digits)
1106 the eight-bit character whose value is the hexadecimal value \fIHH\fP
1107 (one or two hex digits)
1110 a control-\fIx\fP character
1114 The expanded result is single-quoted, as if the dollar sign had
1117 A double-quoted string preceded by a dollar sign (\fB$\fP\(dq\fIstring\fP\(dq)
1118 will cause the string to be translated according to the current locale.
1119 If the current locale is \fBC\fP or \fBPOSIX\fP, the dollar sign
1121 If the string is translated and replaced, the replacement is
1126 is an entity that stores values.
1129 a number, or one of the special characters listed below under
1130 .BR "Special Parameters" .
1133 is a parameter denoted by a
1135 A variable has a \fIvalue\fP and zero or more \fIattributes\fP.
1136 Attributes are assigned using the
1138 builtin command (see
1142 .BR "SHELL BUILTIN COMMANDS" ).
1144 A parameter is set if it has been assigned a value. The null string is
1145 a valid value. Once a variable is set, it may be unset only by using
1148 builtin command (see
1150 .B SHELL BUILTIN COMMANDS
1155 may be assigned to by a statement of the form
1158 \fIname\fP=[\fIvalue\fP]
1163 is not given, the variable is assigned the null string. All
1165 undergo tilde expansion, parameter and variable expansion,
1166 command substitution, arithmetic expansion, and quote
1170 below). If the variable has its
1174 is evaluated as an arithmetic expression even if the $((...)) expansion is
1176 .B "Arithmetic Expansion"
1178 Word splitting is not performed, with the exception
1179 of \fB"$@"\fP as explained below under
1180 .BR "Special Parameters" .
1181 Pathname expansion is not performed.
1182 Assignment statements may also appear as arguments to the
1192 In the context where an assignment statement is assigning a value
1193 to a shell variable or array index, the += operator can be used to
1194 append to or add to the variable's previous value.
1195 When += is applied to a variable for which the integer attribute has been
1196 set, \fIvalue\fP is evaluated as an arithmetic expression and added to the
1197 variable's current value, which is also evaluated.
1198 When += is applied to an array variable using compound assignment (see
1201 variable's value is not unset (as it is when using =), and new values are
1202 appended to the array beginning at one greater than the array's maximum index
1203 (for indexed arrays) or added as additional key\-value pairs in an
1205 When applied to a string-valued variable, \fIvalue\fP is expanded and
1206 appended to the variable's value.
1207 .SS Positional Parameters
1210 .I positional parameter
1211 is a parameter denoted by one or more
1212 digits, other than the single digit 0. Positional parameters are
1213 assigned from the shell's arguments when it is invoked,
1214 and may be reassigned using the
1216 builtin command. Positional parameters may not be assigned to
1217 with assignment statements. The positional parameters are
1218 temporarily replaced when a shell function is executed (see
1223 When a positional parameter consisting of more than a single
1224 digit is expanded, it must be enclosed in braces (see
1228 .SS Special Parameters
1230 The shell treats several parameters specially. These parameters may
1231 only be referenced; assignment to them is not allowed.
1235 Expands to the positional parameters, starting from one. When the
1236 expansion occurs within double quotes, it expands to a single word
1237 with the value of each parameter separated by the first character
1241 special variable. That is, "\fB$*\fP" is equivalent
1242 to "\fB$1\fP\fIc\fP\fB$2\fP\fIc\fP\fB...\fP", where
1244 is the first character of the value of the
1250 is unset, the parameters are separated by spaces.
1254 is null, the parameters are joined without intervening separators.
1257 Expands to the positional parameters, starting from one. When the
1258 expansion occurs within double quotes, each parameter expands to a
1259 separate word. That is, "\fB$@\fP" is equivalent to
1260 "\fB$1\fP" "\fB$2\fP" ...
1261 If the double-quoted expansion occurs within a word, the expansion of
1262 the first parameter is joined with the beginning part of the original
1263 word, and the expansion of the last parameter is joined with the last
1264 part of the original word.
1265 When there are no positional parameters, "\fB$@\fP" and
1267 expand to nothing (i.e., they are removed).
1270 Expands to the number of positional parameters in decimal.
1273 Expands to the exit status of the most recently executed foreground
1277 Expands to the current option flags as specified upon invocation,
1280 builtin command, or those set by the shell itself
1286 Expands to the process ID of the shell. In a () subshell, it
1287 expands to the process ID of the current shell, not the
1291 Expands to the process ID of the most recently executed background
1292 (asynchronous) command.
1295 Expands to the name of the shell or shell script. This is set at
1296 shell initialization. If
1298 is invoked with a file of commands,
1300 is set to the name of that file. If
1306 is set to the first argument after the string to be
1307 executed, if one is present. Otherwise, it is set
1308 to the file name used to invoke
1310 as given by argument zero.
1313 At shell startup, set to the absolute pathname used to invoke the
1314 shell or shell script being executed as passed in the environment
1316 Subsequently, expands to the last argument to the previous command,
1318 Also set to the full pathname used to invoke each command executed
1319 and placed in the environment exported to that command.
1320 When checking mail, this parameter holds the name of the mail file
1321 currently being checked.
1325 The following variables are set by the shell:
1330 Expands to the full file name used to invoke this instance of
1334 A colon-separated list of enabled shell options. Each word in
1335 the list is a valid argument for the
1339 builtin command (see
1341 .B "SHELL BUILTIN COMMANDS"
1342 below). The options appearing in
1345 are those reported as
1348 If this variable is in the environment when
1350 starts up, each shell option in the list will be enabled before
1351 reading any startup files.
1352 This variable is read-only.
1355 Expands to the process id of the current \fBbash\fP process.
1356 This differs from \fB$$\fP under certain circumstances, such as subshells
1357 that do not require \fBbash\fP to be re-initialized.
1360 An associative array variable whose members correspond to the internal
1361 list of aliases as maintained by the \fBalias\fP builtin
1362 Elements added to this array appear in the alias list; unsetting array
1363 elements cause aliases to be removed from the alias list.
1366 An array variable whose values are the number of parameters in each
1367 frame of the current \fBbash\fP execution call stack.
1369 parameters to the current subroutine (shell function or script executed
1370 with \fB.\fP or \fBsource\fP) is at the top of the stack.
1371 When a subroutine is executed, the number of parameters passed is pushed onto
1377 only when in extended debugging mode (see the description of the
1384 An array variable containing all of the parameters in the current \fBbash\fP
1385 execution call stack. The final parameter of the last subroutine call
1386 is at the top of the stack; the first parameter of the initial call is
1387 at the bottom. When a subroutine is executed, the parameters supplied
1394 only when in extended debugging mode
1395 (see the description of the
1402 An associative array variable whose members correspond to the internal
1403 hash table of commands as maintained by the \fBhash\fP builtin.
1404 Elements added to this array appear in the hash table; unsetting array
1405 elements cause commands to be removed from the hash table.
1408 The command currently being executed or about to be executed, unless the
1409 shell is executing a command as the result of a trap,
1410 in which case it is the command executing at the time of the trap.
1412 .B BASH_EXECUTION_STRING
1413 The command argument to the \fB\-c\fP invocation option.
1416 An array variable whose members are the line numbers in source files
1417 corresponding to each member of
1420 \fB${BASH_LINENO[\fP\fI$i\fP\fB]}\fP is the line number in the source
1421 file where \fB${FUNCNAME[\fP\fI$i\fP\fB]}\fP was called
1422 (or \fB${BASH_LINENO[\fP\fI$i-1\fP\fB]}\fP if referenced within another
1424 The corresponding source file name is \fB${BASH_SOURCE[\fP\fI$i\fP\fB]}\fP.
1428 to obtain the current line number.
1431 An array variable whose members are assigned by the \fB=~\fP binary
1432 operator to the \fB[[\fP conditional command.
1433 The element with index 0 is the portion of the string
1434 matching the entire regular expression.
1435 The element with index \fIn\fP is the portion of the
1436 string matching the \fIn\fPth parenthesized subexpression.
1437 This variable is read-only.
1440 An array variable whose members are the source filenames corresponding
1441 to the elements in the
1447 Incremented by one each time a subshell or subshell environment is spawned.
1448 The initial value is 0.
1451 A readonly array variable whose members hold version information for
1454 The values assigned to the array members are as follows:
1459 .B BASH_VERSINFO[\fR0\fP]
1460 The major version number (the \fIrelease\fP).
1462 .B BASH_VERSINFO[\fR1\fP]
1463 The minor version number (the \fIversion\fP).
1465 .B BASH_VERSINFO[\fR2\fP]
1468 .B BASH_VERSINFO[\fR3\fP]
1471 .B BASH_VERSINFO[\fR4\fP]
1472 The release status (e.g., \fIbeta1\fP).
1474 .B BASH_VERSINFO[\fR5\fP]
1482 Expands to a string describing the version of this instance of
1486 An index into \fB${COMP_WORDS}\fP of the word containing the current
1488 This variable is available only in shell functions invoked by the
1489 programmable completion facilities (see \fBProgrammable Completion\fP
1493 The key (or final key of a key sequence) used to invoke the current
1494 completion function.
1497 The current command line.
1498 This variable is available only in shell functions and external
1499 commands invoked by the
1500 programmable completion facilities (see \fBProgrammable Completion\fP
1504 The index of the current cursor position relative to the beginning of
1505 the current command.
1506 If the current cursor position is at the end of the current command,
1507 the value of this variable is equal to \fB${#COMP_LINE}\fP.
1508 This variable is available only in shell functions and external
1509 commands invoked by the
1510 programmable completion facilities (see \fBProgrammable Completion\fP
1514 Set to an integer value corresponding to the type of completion attempted
1515 that caused a completion function to be called:
1516 \fITAB\fP, for normal completion,
1517 \fI?\fP, for listing completions after successive tabs,
1518 \fI!\fP, for listing alternatives on partial word completion,
1519 \fI@\fP, to list completions if the word is not unmodified,
1521 \fI%\fP, for menu completion.
1522 This variable is available only in shell functions and external
1523 commands invoked by the
1524 programmable completion facilities (see \fBProgrammable Completion\fP
1528 The set of characters that the \fBreadline\fP library treats as word
1529 separators when performing word completion.
1533 is unset, it loses its special properties, even if it is
1537 An array variable (see \fBArrays\fP below) consisting of the individual
1538 words in the current command line.
1539 The line is split into words as \fBreadline\fP would split it, using
1543 This variable is available only in shell functions invoked by the
1544 programmable completion facilities (see \fBProgrammable Completion\fP
1548 An array variable (see
1550 below) containing the current contents of the directory stack.
1551 Directories appear in the stack in the order they are displayed by the
1554 Assigning to members of this array variable may be used to modify
1555 directories already in the stack, but the
1559 builtins must be used to add and remove directories.
1560 Assignment to this variable will not change the current directory.
1564 is unset, it loses its special properties, even if it is
1568 Expands to the effective user ID of the current user, initialized at
1569 shell startup. This variable is readonly.
1572 An array variable containing the names of all shell functions
1573 currently in the execution call stack.
1574 The element with index 0 is the name of any currently-executing
1576 The bottom-most element is
1577 .if t \f(CW"main"\fP.
1579 This variable exists only when a shell function is executing.
1583 have no effect and return an error status.
1587 is unset, it loses its special properties, even if it is
1591 An array variable containing the list of groups of which the current
1596 have no effect and return an error status.
1600 is unset, it loses its special properties, even if it is
1604 The history number, or index in the history list, of the current
1609 is unset, it loses its special properties, even if it is
1613 Automatically set to the name of the current host.
1616 Automatically set to a string that uniquely
1617 describes the type of machine on which
1620 The default is system-dependent.
1623 Each time this parameter is referenced, the shell substitutes
1624 a decimal number representing the current sequential line number
1625 (starting with 1) within a script or function. When not in a
1626 script or function, the value substituted is not guaranteed to
1631 is unset, it loses its special properties, even if it is
1635 Automatically set to a string that fully describes the system
1638 is executing, in the standard GNU \fIcpu-company-system\fP format.
1639 The default is system-dependent.
1642 The previous working directory as set by the
1647 The value of the last option argument processed by the
1649 builtin command (see
1651 .B SHELL BUILTIN COMMANDS
1655 The index of the next argument to be processed by the
1657 builtin command (see
1659 .B SHELL BUILTIN COMMANDS
1663 Automatically set to a string that
1664 describes the operating system on which
1667 The default is system-dependent.
1670 An array variable (see
1672 below) containing a list of exit status values from the processes
1673 in the most-recently-executed foreground pipeline (which may
1674 contain only a single command).
1677 The process ID of the shell's parent. This variable is readonly.
1680 The current working directory as set by the
1685 Each time this parameter is referenced, a random integer between
1687 generated. The sequence of random numbers may be initialized by assigning
1694 is unset, it loses its special properties, even if it is
1698 Set to the line of input read by the
1700 builtin command when no arguments are supplied.
1703 Each time this parameter is
1704 referenced, the number of seconds since shell invocation is returned. If a
1705 value is assigned to
1708 the value returned upon subsequent
1710 the number of seconds since the assignment plus the value assigned.
1714 is unset, it loses its special properties, even if it is
1718 A colon-separated list of enabled shell options. Each word in
1719 the list is a valid argument for the
1723 builtin command (see
1725 .B "SHELL BUILTIN COMMANDS"
1726 below). The options appearing in
1729 are those reported as
1732 If this variable is in the environment when
1734 starts up, each shell option in the list will be enabled before
1735 reading any startup files.
1736 This variable is read-only.
1739 Incremented by one each time an instance of
1744 Expands to the user ID of the current user, initialized at shell startup.
1745 This variable is readonly.
1748 The following variables are used by the shell. In some cases,
1750 assigns a default value to a variable; these cases are noted
1756 If this parameter is set when \fBbash\fP is executing a shell script,
1757 its value is interpreted as a filename containing commands to
1758 initialize the shell, as in
1763 is subjected to parameter expansion, command substitution, and arithmetic
1764 expansion before being interpreted as a file name.
1767 is not used to search for the resultant file name.
1770 The search path for the
1773 This is a colon-separated list of directories in which the shell looks
1774 for destination directories specified by the
1778 .if t \f(CW".:~:/usr"\fP.
1782 If set to an integer corresponding to a valid file descriptor, \fBbash\fP
1783 will write the trace output generated when
1784 .if t \f(CWset -x\fP
1786 is enabled to that file descriptor.
1787 The file descriptor is closed when
1790 is unset or assigned a new value.
1794 or assigning it the empty string causes the
1795 trace output to be sent to the standard error.
1799 to 2 (the standard error file
1800 descriptor) and then unsetting it will result in the standard error
1804 Used by the \fBselect\fP builtin command to determine the terminal width
1805 when printing selection lists. Automatically set upon receipt of a SIGWINCH.
1808 An array variable from which \fBbash\fP reads the possible completions
1809 generated by a shell function invoked by the programmable completion
1810 facility (see \fBProgrammable Completion\fP below).
1813 If \fBbash\fP finds this variable in the environment when the shell starts
1817 it assumes that the shell is running in an emacs shell buffer and disables
1821 The default editor for the
1826 A colon-separated list of suffixes to ignore when performing
1827 filename completion (see
1831 A filename whose suffix matches one of the entries in
1834 is excluded from the list of matched filenames.
1836 .if t \f(CW".o:~"\fP.
1840 A colon-separated list of patterns defining the set of filenames to
1841 be ignored by pathname expansion.
1842 If a filename matched by a pathname expansion pattern also matches one
1846 it is removed from the list of matches.
1849 A colon-separated list of values controlling how commands are saved on
1851 If the list of values includes
1853 lines which begin with a
1855 character are not saved in the history list.
1858 causes lines matching the previous history entry to not be saved.
1861 is shorthand for \fIignorespace\fP and \fIignoredups\fP.
1864 causes all previous lines matching the current line to be removed from
1865 the history list before that line is saved.
1866 Any value not in the above list is ignored.
1870 is unset, or does not include a valid value,
1871 all lines read by the shell parser are saved on the history list,
1872 subject to the value of
1875 The second and subsequent lines of a multi-line compound command are
1876 not tested, and are added to the history regardless of the value of
1881 The name of the file in which command history is saved (see
1884 below). The default value is \fI~/.bash_history\fP. If unset, the
1885 command history is not saved when an interactive shell exits.
1888 The maximum number of lines contained in the history file. When this
1889 variable is assigned a value, the history file is truncated, if
1890 necessary, by removing the oldest entries,
1891 to contain no more than that number of lines. The default
1892 value is 500. The history file is also truncated to this size after
1893 writing it when an interactive shell exits.
1896 A colon-separated list of patterns used to decide which command lines
1897 should be saved on the history list. Each pattern is anchored at the
1898 beginning of the line and must match the complete line (no implicit
1899 `\fB*\fP' is appended). Each pattern is tested against the line
1900 after the checks specified by
1904 In addition to the normal shell pattern matching characters, `\fB&\fP'
1905 matches the previous history line. `\fB&\fP' may be escaped using a
1906 backslash; the backslash is removed before attempting a match.
1907 The second and subsequent lines of a multi-line compound command are
1908 not tested, and are added to the history regardless of the value of
1913 The number of commands to remember in the command history (see
1916 below). The default value is 500.
1919 If this variable is set and not null, its value is used as a format string
1920 for \fIstrftime\fP(3) to print the time stamp associated with each history
1921 entry displayed by the \fBhistory\fP builtin.
1922 If this variable is set, time stamps are written to the history file so
1923 they may be preserved across shell sessions.
1924 This uses the history comment character to distinguish timestamps from
1925 other history lines.
1928 The home directory of the current user; the default argument for the
1929 \fBcd\fP builtin command.
1930 The value of this variable is also used when performing tilde expansion.
1933 Contains the name of a file in the same format as
1935 that should be read when the shell needs to complete a
1937 The list of possible hostname completions may be changed while the
1939 the next time hostname completion is attempted after the
1942 adds the contents of the new file to the existing list.
1946 is set, but has no value, or does not name a readable file,
1947 \fBbash\fP attempts to read
1949 to obtain the list of possible hostname completions.
1953 is unset, the hostname list is cleared.
1957 .I Internal Field Separator
1959 for word splitting after expansion and to
1960 split lines into words with the
1962 builtin command. The default value is
1963 ``<space><tab><newline>''.
1967 action of an interactive shell on receipt of an
1970 character as the sole input. If set, the value is the number of
1974 characters which must be
1975 typed as the first characters on an input line before
1977 exits. If the variable exists but does not have a numeric value, or
1978 has no value, the default value is 10. If it does not exist,
1981 signifies the end of input to the shell.
1984 The filename for the
1986 startup file, overriding the default of
1994 Used to determine the locale category for any category not specifically
1995 selected with a variable starting with \fBLC_\fP.
1998 This variable overrides the value of
2002 \fBLC_\fP variable specifying a locale category.
2005 This variable determines the collation order used when sorting the
2006 results of pathname expansion, and determines the behavior of range
2007 expressions, equivalence classes, and collating sequences within
2008 pathname expansion and pattern matching.
2011 This variable determines the interpretation of characters and the
2012 behavior of character classes within pathname expansion and pattern
2016 This variable determines the locale used to translate double-quoted
2017 strings preceded by a \fB$\fP.
2020 This variable determines the locale category used for number formatting.
2023 Used by the \fBselect\fP builtin command to determine the column length
2024 for printing selection lists. Automatically set upon receipt of a
2029 If this parameter is set to a file name and the
2032 variable is not set,
2034 informs the user of the arrival of mail in the specified file.
2040 checks for mail. The default is 60 seconds. When it is time to check
2041 for mail, the shell does so before displaying the primary prompt.
2042 If this variable is unset, or set to a value that is not a number
2043 greater than or equal to zero, the shell disables mail checking.
2046 A colon-separated list of file names to be checked for mail.
2047 The message to be printed when mail arrives in a particular file
2048 may be specified by separating the file name from the message with a `?'.
2049 When used in the text of the message, \fB$_\fP expands to the name of
2050 the current mailfile.
2054 \fBMAILPATH\fP=\(aq/var/mail/bfox?"You have mail":~/shell\-mail?"$_ has mail!"\(aq
2057 supplies a default value for this variable, but the location of the user
2058 mail files that it uses is system dependent (e.g., /var/mail/\fB$USER\fP).
2062 If set to the value 1,
2064 displays error messages generated by the
2066 builtin command (see
2068 .B SHELL BUILTIN COMMANDS
2072 is initialized to 1 each time the shell is invoked or a shell
2076 The search path for commands. It
2077 is a colon-separated list of directories in which
2078 the shell looks for commands (see
2080 .B COMMAND EXECUTION
2082 A zero-length (null) directory name in the value of
2085 indicates the current directory.
2086 A null directory name may appear as two adjacent colons, or as an initial
2088 The default path is system-dependent,
2089 and is set by the administrator who installs
2092 .if t \f(CW/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin\fP.
2093 .if n ``/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin''.
2096 If this variable is in the environment when \fBbash\fP starts, the shell
2097 enters \fIposix mode\fP before reading the startup files, as if the
2099 invocation option had been supplied. If it is set while the shell is
2100 running, \fBbash\fP enables \fIposix mode\fP, as if the command
2101 .if t \f(CWset -o posix\fP
2102 .if n \fIset -o posix\fP
2106 If set, the value is executed as a command prior to issuing each primary
2110 If set to a number greater than zero, the value is used as the number of
2111 trailing directory components to retain when expanding the \fB\ew\fP and
2112 \fB\eW\fP prompt string escapes (see
2115 below). Characters removed are replaced with an ellipsis.
2118 The value of this parameter is expanded (see
2121 below) and used as the primary prompt string. The default value is
2122 ``\fB\es\-\ev\e$ \fP''.
2125 The value of this parameter is expanded as with
2128 and used as the secondary prompt string. The default is
2132 The value of this parameter is used as the prompt for the
2140 The value of this parameter is expanded as with
2143 and the value is printed before each command
2145 displays during an execution trace. The first character of
2148 is replicated multiple times, as necessary, to indicate multiple
2149 levels of indirection. The default is ``\fB+ \fP''.
2152 The full pathname to the shell is kept in this environment variable.
2153 If it is not set when the shell starts,
2155 assigns to it the full pathname of the current user's login shell.
2158 The value of this parameter is used as a format string specifying
2159 how the timing information for pipelines prefixed with the
2161 reserved word should be displayed.
2162 The \fB%\fP character introduces an escape sequence that is
2163 expanded to a time value or other information.
2164 The escape sequences and their meanings are as follows; the
2165 braces denote optional portions.
2174 The elapsed time in seconds.
2177 The number of CPU seconds spent in user mode.
2180 The number of CPU seconds spent in system mode.
2183 The CPU percentage, computed as (%U + %S) / %R.
2187 The optional \fIp\fP is a digit specifying the \fIprecision\fP,
2188 the number of fractional digits after a decimal point.
2189 A value of 0 causes no decimal point or fraction to be output.
2190 At most three places after the decimal point may be specified;
2191 values of \fIp\fP greater than 3 are changed to 3.
2192 If \fIp\fP is not specified, the value 3 is used.
2194 The optional \fBl\fP specifies a longer format, including
2195 minutes, of the form \fIMM\fPm\fISS\fP.\fIFF\fPs.
2196 The value of \fIp\fP determines whether or not the fraction is
2199 If this variable is not set, \fBbash\fP acts as if it had the
2200 value \fB$\(aq\enreal\et%3lR\enuser\et%3lU\ensys\t%3lS\(aq\fP.
2201 If the value is null, no timing information is displayed.
2202 A trailing newline is added when the format string is displayed.
2205 If set to a value greater than zero,
2209 default timeout for the \fBread\fP builtin.
2210 The \fBselect\fP command terminates if input does not arrive
2214 seconds when input is coming from a terminal.
2215 In an interactive shell, the value is interpreted as the
2216 number of seconds to wait for input after issuing the primary prompt.
2218 terminates after waiting for that number of seconds if input does
2222 If set, \fBBash\fP uses its value as the name of a directory in which
2223 \fBBash\fP creates temporary files for the shell's use.
2226 This variable controls how the shell interacts with the user and
2227 job control. If this variable is set, single word simple
2228 commands without redirections are treated as candidates for resumption
2229 of an existing stopped job. There is no ambiguity allowed; if there is
2230 more than one job beginning with the string typed, the job most recently
2231 accessed is selected. The
2233 of a stopped job, in this context, is the command line used to
2237 the string supplied must match the name of a stopped job exactly;
2240 the string supplied needs to match a substring of the name of a
2243 value provides functionality analogous to the
2248 below). If set to any other value, the supplied string must
2249 be a prefix of a stopped job's name; this provides functionality
2250 analogous to the \fB%\fP\fIstring\fP job identifier.
2253 The two or three characters which control history expansion
2254 and tokenization (see
2256 .B HISTORY EXPANSION
2257 below). The first character is the \fIhistory expansion\fP character,
2258 the character which signals the start of a history
2259 expansion, normally `\fB!\fP'.
2260 The second character is the \fIquick substitution\fP
2261 character, which is used as shorthand for re-running the previous
2262 command entered, substituting one string for another in the command.
2263 The default is `\fB^\fP'.
2264 The optional third character is the character
2265 which indicates that the remainder of the line is a comment when found
2266 as the first character of a word, normally `\fB#\fP'. The history
2267 comment character causes history substitution to be skipped for the
2268 remaining words on the line. It does not necessarily cause the shell
2269 parser to treat the rest of the line as a comment.
2273 provides one-dimensional indexed and associative array variables.
2274 Any variable may be used as an indexed array; the
2276 builtin will explicitly declare an array.
2278 limit on the size of an array, nor any requirement that members
2279 be indexed or assigned contiguously.
2280 Indexed arrays are referenced using integers (including arithmetic
2281 expressions) and are zero-based; associative arrays are referenced
2282 using arbitrary strings.
2284 An indexed array is created automatically if any variable is assigned to
2285 using the syntax \fIname\fP[\fIsubscript\fP]=\fIvalue\fP. The
2287 is treated as an arithmetic expression that must evaluate to a number
2288 greater than or equal to zero. To explicitly declare an indexed array,
2290 .B declare \-a \fIname\fP
2293 .B SHELL BUILTIN COMMANDS
2295 .B declare \-a \fIname\fP[\fIsubscript\fP]
2296 is also accepted; the \fIsubscript\fP is ignored.
2298 Associative arrays are created using
2299 .BR "declare \-A \fIname\fP" .
2302 specified for an array variable using the
2306 builtins. Each attribute applies to all members of an array.
2308 Arrays are assigned to using compound assignments of the form
2309 \fIname\fP=\fB(\fPvalue\fI1\fP ... value\fIn\fP\fB)\fP, where each
2310 \fIvalue\fP is of the form [\fIsubscript\fP]=\fIstring\fP.
2311 Indexed array assignments do not require the bracket and subscript.
2312 When assigning to indexed arrays, if the optional brackets and subscript
2313 are supplied, that index is assigned to;
2314 otherwise the index of the element assigned is the last index assigned
2315 to by the statement plus one. Indexing starts at zero.
2317 When assigning to an associative array, the subscript is required.
2319 This syntax is also accepted by the
2321 builtin. Individual array elements may be assigned to using the
2322 \fIname\fP[\fIsubscript\fP]=\fIvalue\fP syntax introduced above.
2324 Any element of an array may be referenced using
2325 ${\fIname\fP[\fIsubscript\fP]}. The braces are required to avoid
2326 conflicts with pathname expansion. If
2327 \fIsubscript\fP is \fB@\fP or \fB*\fP, the word expands to
2328 all members of \fIname\fP. These subscripts differ only when the
2329 word appears within double quotes. If the word is double-quoted,
2330 ${\fIname\fP[*]} expands to a single
2331 word with the value of each array member separated by the first
2335 special variable, and ${\fIname\fP[@]} expands each element of
2336 \fIname\fP to a separate word. When there are no array members,
2337 ${\fIname\fP[@]} expands to nothing.
2338 If the double-quoted expansion occurs within a word, the expansion of
2339 the first parameter is joined with the beginning part of the original
2340 word, and the expansion of the last parameter is joined with the last
2341 part of the original word.
2342 This is analogous to the expansion
2343 of the special parameters \fB*\fP and \fB@\fP (see
2344 .B Special Parameters
2345 above). ${#\fIname\fP[\fIsubscript\fP]} expands to the length of
2346 ${\fIname\fP[\fIsubscript\fP]}. If \fIsubscript\fP is \fB*\fP or
2347 \fB@\fP, the expansion is the number of elements in the array.
2348 Referencing an array variable without a subscript is equivalent to
2349 referencing the array with a subscript of 0.
2351 An array variable is considered set if a subscript has been assigned a
2352 value. The null string is a valid value.
2356 builtin is used to destroy arrays. \fBunset\fP \fIname\fP[\fIsubscript\fP]
2357 destroys the array element at index \fIsubscript\fP.
2358 Care must be taken to avoid unwanted side effects caused by pathname
2360 \fBunset\fP \fIname\fP, where \fIname\fP is an array, or
2361 \fBunset\fP \fIname\fP[\fIsubscript\fP], where
2362 \fIsubscript\fP is \fB*\fP or \fB@\fP, removes the entire array.
2369 builtins each accept a
2371 option to specify an indexed array and a
2373 option to specify an associative array.
2378 option to assign a list of words read from the standard input
2383 builtins display array values in a way that allows them to be
2384 reused as assignments.
2386 Expansion is performed on the command line after it has been split into
2387 words. There are seven kinds of expansion performed:
2388 .IR "brace expansion" ,
2389 .IR "tilde expansion" ,
2390 .IR "parameter and variable expansion" ,
2391 .IR "command substitution" ,
2392 .IR "arithmetic expansion" ,
2393 .IR "word splitting" ,
2395 .IR "pathname expansion" .
2397 The order of expansions is: brace expansion, tilde expansion,
2398 parameter, variable and arithmetic expansion and
2399 command substitution
2400 (done in a left-to-right fashion), word splitting, and pathname
2403 On systems that can support it, there is an additional expansion
2404 available: \fIprocess substitution\fP.
2406 Only brace expansion, word splitting, and pathname expansion
2407 can change the number of words of the expansion; other expansions
2408 expand a single word to a single word.
2409 The only exceptions to this are the expansions of
2410 "\fB$@\fP" and "\fB${\fP\fIname\fP\fB[@]}\fP"
2411 as explained above (see
2416 .I "Brace expansion"
2417 is a mechanism by which arbitrary strings
2418 may be generated. This mechanism is similar to
2419 \fIpathname expansion\fP, but the filenames generated
2420 need not exist. Patterns to be brace expanded take
2421 the form of an optional
2423 followed by either a series of comma-separated strings or
2424 a sequence expression between a pair of braces, followed by
2427 The preamble is prefixed to each string contained
2428 within the braces, and the postscript is then appended
2429 to each resulting string, expanding left to right.
2431 Brace expansions may be nested. The results of each expanded
2432 string are not sorted; left to right order is preserved.
2433 For example, a\fB{\fPd,c,b\fB}\fPe expands into `ade ace abe'.
2435 A sequence expression takes the form
2436 \fB{\fP\fIx\fP\fB..\fP\fIy\fP\fB[..\fP\fIincr\fP\fB]}\fP,
2437 where \fIx\fP and \fIy\fP are either integers or single characters,
2438 and \fIincr\fP, an optional increment, is an integer.
2439 When integers are supplied, the expression expands to each number between
2440 \fIx\fP and \fIy\fP, inclusive.
2441 Supplied integers may be prefixed with \fI0\fP to force each term to have the
2442 same width. When either \fIx\fP or \fPy\fP begins with a zero, the shell
2443 attempts to force all generated terms to contain the same number of digits,
2444 zero-padding where necessary.
2445 When characters are supplied, the expression expands to each character
2446 lexicographically between \fIx\fP and \fIy\fP, inclusive. Note that
2447 both \fIx\fP and \fIy\fP must be of the same type.
2448 When the increment is supplied, it is used as the difference between
2449 each term. The default increment is 1 or -1 as appropriate.
2451 Brace expansion is performed before any other expansions,
2452 and any characters special to other expansions are preserved
2453 in the result. It is strictly textual.
2455 does not apply any syntactic interpretation to the context of the
2456 expansion or the text between the braces.
2458 A correctly-formed brace expansion must contain unquoted opening
2459 and closing braces, and at least one unquoted comma or a valid
2460 sequence expression.
2461 Any incorrectly formed brace expansion is left unchanged.
2462 A \fB{\fP or \fB,\fP may be quoted with a backslash to prevent its
2463 being considered part of a brace expression.
2464 To avoid conflicts with parameter expansion, the string \fB${\fP
2465 is not considered eligible for brace expansion.
2467 This construct is typically used as shorthand when the common
2468 prefix of the strings to be generated is longer than in the
2472 mkdir /usr/local/src/bash/{old,new,dist,bugs}
2476 chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}
2479 Brace expansion introduces a slight incompatibility with
2480 historical versions of
2483 does not treat opening or closing braces specially when they
2484 appear as part of a word, and preserves them in the output.
2486 removes braces from words as a consequence of brace
2487 expansion. For example, a word entered to
2490 appears identically in the output. The same word is
2495 If strict compatibility with
2501 option or disable brace expansion with the
2507 .B SHELL BUILTIN COMMANDS
2511 If a word begins with an unquoted tilde character (`\fB~\fP'), all of
2512 the characters preceding the first unquoted slash (or all characters,
2513 if there is no unquoted slash) are considered a \fItilde-prefix\fP.
2514 If none of the characters in the tilde-prefix are quoted, the
2515 characters in the tilde-prefix following the tilde are treated as a
2516 possible \fIlogin name\fP.
2517 If this login name is the null string, the tilde is replaced with the
2518 value of the shell parameter
2524 is unset, the home directory of the user executing the shell is
2525 substituted instead.
2526 Otherwise, the tilde-prefix is replaced with the home directory
2527 associated with the specified login name.
2529 If the tilde-prefix is a `~+', the value of the shell variable
2532 replaces the tilde-prefix.
2533 If the tilde-prefix is a `~\-', the value of the shell variable
2536 if it is set, is substituted.
2537 If the characters following the tilde in the tilde-prefix consist
2538 of a number \fIN\fP, optionally prefixed
2539 by a `+' or a `\-', the tilde-prefix is replaced with the corresponding
2540 element from the directory stack, as it would be displayed by the
2542 builtin invoked with the tilde-prefix as an argument.
2543 If the characters following the tilde in the tilde-prefix consist of a
2544 number without a leading `+' or `\-', `+' is assumed.
2546 If the login name is invalid, or the tilde expansion fails, the word
2549 Each variable assignment is checked for unquoted tilde-prefixes immediately
2554 In these cases, tilde expansion is also performed.
2555 Consequently, one may use file names with tildes in assignments to
2563 and the shell assigns the expanded value.
2564 .SS Parameter Expansion
2566 The `\fB$\fP' character introduces parameter expansion,
2567 command substitution, or arithmetic expansion. The parameter name
2568 or symbol to be expanded may be enclosed in braces, which
2569 are optional but serve to protect the variable to be expanded from
2570 characters immediately following it which could be
2571 interpreted as part of the name.
2573 When braces are used, the matching ending brace is the first `\fB}\fP'
2574 not escaped by a backslash or within a quoted string, and not within an
2575 embedded arithmetic expansion, command substitution, or parameter
2581 The value of \fIparameter\fP is substituted. The braces are required
2584 is a positional parameter with more than one digit,
2587 is followed by a character which is not to be
2588 interpreted as part of its name.
2591 If the first character of \fIparameter\fP is an exclamation point (\fB!\fP),
2592 a level of variable indirection is introduced.
2593 \fBBash\fP uses the value of the variable formed from the rest of
2594 \fIparameter\fP as the name of the variable; this variable is then
2595 expanded and that value is used in the rest of the substitution, rather
2596 than the value of \fIparameter\fP itself.
2597 This is known as \fIindirect expansion\fP.
2598 The exceptions to this are the expansions of ${!\fIprefix\fP*} and
2599 ${\fB!\fP\fIname\fP[\fI@\fP]} described below.
2600 The exclamation point must immediately follow the left brace in order to
2601 introduce indirection.
2603 In each of the cases below, \fIword\fP is subject to tilde expansion,
2604 parameter expansion, command substitution, and arithmetic expansion.
2606 When not performing substring expansion, using the forms documented below,
2607 \fBbash\fP tests for a parameter that is unset or null. Omitting the colon
2608 results in a test only for a parameter that is unset.
2612 ${\fIparameter\fP\fB:\-\fP\fIword\fP}
2613 \fBUse Default Values\fP. If
2615 is unset or null, the expansion of
2617 is substituted. Otherwise, the value of
2621 ${\fIparameter\fP\fB:=\fP\fIword\fP}
2622 \fBAssign Default Values\fP.
2625 is unset or null, the expansion of
2631 is then substituted. Positional parameters and special parameters may
2632 not be assigned to in this way.
2634 ${\fIparameter\fP\fB:?\fP\fIword\fP}
2635 \fBDisplay Error if Null or Unset\fP.
2638 is null or unset, the expansion of \fIword\fP (or a message to that effect
2641 is not present) is written to the standard error and the shell, if it
2642 is not interactive, exits. Otherwise, the value of \fIparameter\fP is
2645 ${\fIparameter\fP\fB:+\fP\fIword\fP}
2646 \fBUse Alternate Value\fP.
2649 is null or unset, nothing is substituted, otherwise the expansion of
2653 ${\fIparameter\fP\fB:\fP\fIoffset\fP}
2656 ${\fIparameter\fP\fB:\fP\fIoffset\fP\fB:\fP\fIlength\fP}
2658 \fBSubstring Expansion.\fP
2659 Expands to up to \fIlength\fP characters of \fIparameter\fP
2660 starting at the character specified by \fIoffset\fP.
2661 If \fIlength\fP is omitted, expands to the substring of
2662 \fIparameter\fP starting at the character specified by \fIoffset\fP.
2663 \fIlength\fP and \fIoffset\fP are arithmetic expressions (see
2666 ARITHMETIC EVALUATION
2668 \fIlength\fP must evaluate to a number greater than or equal to zero.
2669 If \fIoffset\fP evaluates to a number less than zero, the value
2670 is used as an offset from the end of the value of \fIparameter\fP.
2671 If \fIparameter\fP is \fB@\fP, the result is \fIlength\fP positional
2672 parameters beginning at \fIoffset\fP.
2673 If \fIparameter\fP is an indexed array name subscripted by @ or *,
2674 the result is the \fIlength\fP
2675 members of the array beginning with ${\fIparameter\fP[\fIoffset\fP]}.
2676 A negative \fIoffset\fP is taken relative to one greater than the maximum
2677 index of the specified array.
2678 Substring expansion applied to an associative array produces undefined
2680 Note that a negative offset must be separated from the colon by at least
2681 one space to avoid being confused with the :- expansion.
2682 Substring indexing is zero-based unless the positional parameters
2683 are used, in which case the indexing starts at 1 by default.
2684 If \fIoffset\fP is 0, and the positional parameters are used, \fB$0\fP is
2685 prefixed to the list.
2687 ${\fB!\fP\fIprefix\fP\fB*\fP}
2690 ${\fB!\fP\fIprefix\fP\fB@\fP}
2692 \fBNames matching prefix.\fP
2693 Expands to the names of variables whose names begin with \fIprefix\fP,
2694 separated by the first character of the
2698 When \fI@\fP is used and the expansion appears within double quotes, each
2699 variable name expands to a separate word.
2701 ${\fB!\fP\fIname\fP[\fI@\fP]}
2704 ${\fB!\fP\fIname\fP[\fI*\fP]}
2706 \fBList of array keys.\fP
2707 If \fIname\fP is an array variable, expands to the list of array indices
2708 (keys) assigned in \fIname\fP.
2709 If \fIname\fP is not an array, expands to 0 if \fIname\fP is set and null
2711 When \fI@\fP is used and the expansion appears within double quotes, each
2712 key expands to a separate word.
2714 ${\fB#\fP\fIparameter\fP}
2715 \fBParameter length.\fP
2716 The length in characters of the value of \fIparameter\fP is substituted.
2723 the value substituted is the number of positional parameters.
2726 is an array name subscripted by
2730 the value substituted is the number of elements in the array.
2732 ${\fIparameter\fP\fB#\fP\fIword\fP}
2735 ${\fIparameter\fP\fB##\fP\fIword\fP}
2737 \fBRemove matching prefix pattern.\fP
2740 is expanded to produce a pattern just as in pathname
2741 expansion. If the pattern matches the beginning of
2744 then the result of the expansion is the expanded value of
2746 with the shortest matching pattern (the ``\fB#\fP'' case) or the
2747 longest matching pattern (the ``\fB##\fP'' case) deleted.
2754 the pattern removal operation is applied to each positional
2755 parameter in turn, and the expansion is the resultant list.
2758 is an array variable subscripted with
2762 the pattern removal operation is applied to each member of the
2763 array in turn, and the expansion is the resultant list.
2765 ${\fIparameter\fP\fB%\fP\fIword\fP}
2768 ${\fIparameter\fP\fB%%\fP\fIword\fP}
2770 \fBRemove matching suffix pattern.\fP
2771 The \fIword\fP is expanded to produce a pattern just as in
2773 If the pattern matches a trailing portion of the expanded value of
2775 then the result of the expansion is the expanded value of
2777 with the shortest matching pattern (the ``\fB%\fP'' case) or the
2778 longest matching pattern (the ``\fB%%\fP'' case) deleted.
2785 the pattern removal operation is applied to each positional
2786 parameter in turn, and the expansion is the resultant list.
2789 is an array variable subscripted with
2793 the pattern removal operation is applied to each member of the
2794 array in turn, and the expansion is the resultant list.
2796 ${\fIparameter\fP\fB/\fP\fIpattern\fP\fB/\fP\fIstring\fP}
2797 \fBPattern substitution.\fP
2798 The \fIpattern\fP is expanded to produce a pattern just as in
2800 \fIParameter\fP is expanded and the longest match of \fIpattern\fP
2801 against its value is replaced with \fIstring\fP.
2802 If \fIpattern\fP begins with \fB/\fP, all matches of \fIpattern\fP are
2803 replaced with \fIstring\fP. Normally only the first match is replaced.
2804 If \fIpattern\fP begins with \fB#\fP, it must match at the beginning
2805 of the expanded value of \fIparameter\fP.
2806 If \fIpattern\fP begins with \fB%\fP, it must match at the end
2807 of the expanded value of \fIparameter\fP.
2808 If \fIstring\fP is null, matches of \fIpattern\fP are deleted
2809 and the \fB/\fP following \fIpattern\fP may be omitted.
2816 the substitution operation is applied to each positional
2817 parameter in turn, and the expansion is the resultant list.
2820 is an array variable subscripted with
2824 the substitution operation is applied to each member of the
2825 array in turn, and the expansion is the resultant list.
2827 ${\fIparameter\fP\fB^\fP\fIpattern\fP}
2830 ${\fIparameter\fP\fB^^\fP\fIpattern\fP}
2832 ${\fIparameter\fP\fB,\fP\fIpattern\fP}
2834 ${\fIparameter\fP\fB,,\fP\fIpattern\fP}
2836 \fBCase modification.\fP
2837 This expansion modifies the case of alphabetic characters in \fIparameter\fP.
2838 The \fIpattern\fP is expanded to produce a pattern just as in
2840 The \fB^\fP operator converts lowercase letters matching \fIpattern\fP
2841 to uppercase; the \fB,\fP operator converts matching uppercase letters
2843 The \fB^^\fP and \fB,,\fP expansions convert each matched character in the
2844 expanded value; the \fB^\fP and \fB,\fP expansions match and convert only
2845 the first character in the expanded value..
2846 If \fIpattern\fP is omitted, it is treated like a \fB?\fP, which matches
2854 the case modification operation is applied to each positional
2855 parameter in turn, and the expansion is the resultant list.
2858 is an array variable subscripted with
2862 the case modification operation is applied to each member of the
2863 array in turn, and the expansion is the resultant list.
2864 .SS Command Substitution
2866 \fICommand substitution\fP allows the output of a command to replace
2867 the command name. There are two forms:
2871 \fB$(\fP\fIcommand\fP\|\fB)\fP
2875 \fB\`\fP\fIcommand\fP\fB\`\fP
2879 performs the expansion by executing \fIcommand\fP and
2880 replacing the command substitution with the standard output of the
2881 command, with any trailing newlines deleted.
2882 Embedded newlines are not deleted, but they may be removed during
2884 The command substitution \fB$(cat \fIfile\fP)\fR can be replaced by
2885 the equivalent but faster \fB$(< \fIfile\fP)\fR.
2887 When the old-style backquote form of substitution is used,
2888 backslash retains its literal meaning except when followed by
2893 The first backquote not preceded by a backslash terminates the
2894 command substitution.
2895 When using the $(\^\fIcommand\fP\|) form, all characters between the
2896 parentheses make up the command; none are treated specially.
2898 Command substitutions may be nested. To nest when using the backquoted form,
2899 escape the inner backquotes with backslashes.
2901 If the substitution appears within double quotes, word splitting and
2902 pathname expansion are not performed on the results.
2903 .SS Arithmetic Expansion
2905 Arithmetic expansion allows the evaluation of an arithmetic expression
2906 and the substitution of the result. The format for arithmetic expansion is:
2909 \fB$((\fP\fIexpression\fP\fB))\fP
2914 is treated as if it were within double quotes, but a double quote
2915 inside the parentheses is not treated specially.
2916 All tokens in the expression undergo parameter expansion, string
2917 expansion, command substitution, and quote removal.
2918 Arithmetic expansions may be nested.
2920 The evaluation is performed according to the rules listed below under
2922 .BR "ARITHMETIC EVALUATION" .
2927 prints a message indicating failure and no substitution occurs.
2928 .SS Process Substitution
2930 \fIProcess substitution\fP is supported on systems that support named
2931 pipes (\fIFIFOs\fP) or the \fB/dev/fd\fP method of naming open files.
2932 It takes the form of
2933 \fB<(\fP\fIlist\^\fP\fB)\fP
2935 \fB>(\fP\fIlist\^\fP\fB)\fP.
2936 The process \fIlist\fP is run with its input or output connected to a
2937 \fIFIFO\fP or some file in \fB/dev/fd\fP. The name of this file is
2938 passed as an argument to the current command as the result of the
2939 expansion. If the \fB>(\fP\fIlist\^\fP\fB)\fP form is used, writing to
2940 the file will provide input for \fIlist\fP. If the
2941 \fB<(\fP\fIlist\^\fP\fB)\fP form is used, the file passed as an
2942 argument should be read to obtain the output of \fIlist\fP.
2944 When available, process substitution is performed
2945 simultaneously with parameter and variable expansion,
2946 command substitution,
2947 and arithmetic expansion.
2950 The shell scans the results of
2951 parameter expansion,
2952 command substitution,
2954 arithmetic expansion
2955 that did not occur within double quotes for
2956 .IR "word splitting" .
2958 The shell treats each character of
2961 as a delimiter, and splits the results of the other
2962 expansions into words on these characters. If
2967 .BR <space><tab><newline> ,
2974 at the beginning and end of the results of the previous
2975 expansions are ignored, and
2979 characters not at the beginning or end serves to delimit words.
2983 has a value other than the default, then sequences of
2984 the whitespace characters
2988 are ignored at the beginning and end of the
2989 word, as long as the whitespace character is in the
2996 whitespace character).
3003 whitespace, along with any adjacent
3006 whitespace characters, delimits a field.
3010 whitespace characters is also treated as a delimiter.
3014 is null, no word splitting occurs.
3016 Explicit null arguments (\^\f3"\^"\fP or \^\f3\(aq\^\(aq\fP\^) are retained.
3017 Unquoted implicit null arguments, resulting from the expansion of
3018 parameters that have no values, are removed.
3019 If a parameter with no value is expanded within double quotes, a
3020 null argument results and is retained.
3022 Note that if no expansion occurs, no splitting
3024 .SS Pathname Expansion
3026 After word splitting,
3029 option has been set,
3031 scans each word for the characters
3036 If one of these characters appears, then the word is
3039 and replaced with an alphabetically sorted list of
3040 file names matching the pattern.
3041 If no matching file names are found,
3042 and the shell option
3044 is not enabled, the word is left unchanged.
3047 option is set, and no matches are found,
3048 the word is removed.
3051 shell option is set, and no matches are found, an error message
3052 is printed and the command is not executed.
3055 is enabled, the match is performed without regard to the case
3056 of alphabetic characters.
3057 When a pattern is used for pathname expansion,
3060 at the start of a name or immediately following a slash
3061 must be matched explicitly, unless the shell option
3064 When matching a pathname, the slash character must always be
3068 character is not treated specially.
3069 See the description of
3073 .B SHELL BUILTIN COMMANDS
3074 for a description of the
3085 shell variable may be used to restrict the set of file names matching a
3090 is set, each matching file name that also matches one of the patterns in
3093 is removed from the list of matches.
3098 are always ignored when
3101 is set and not null. However, setting
3104 to a non-null value has the effect of enabling the
3106 shell option, so all other file names beginning with a
3109 To get the old behavior of ignoring file names beginning with a
3113 one of the patterns in
3118 option is disabled when
3123 \fBPattern Matching\fP
3125 Any character that appears in a pattern, other than the special pattern
3126 characters described below, matches itself. The NUL character may not
3127 occur in a pattern. A backslash escapes the following character; the
3128 escaping backslash is discarded when matching.
3129 The special pattern characters must be quoted if
3130 they are to be matched literally.
3132 The special pattern characters have the following meanings:
3137 Matches any string, including the null string.
3138 When the \fBglobstar\fP shell option is enabled, and \fB*\fP is used in
3139 a pathname expansion context, two adjacent \fB*\fPs used as a single
3140 pattern will match all files and zero or more directories and
3142 If followed by a \fB/\fP, two adjacent \fB*\fPs will match only directories
3146 Matches any single character.
3149 Matches any one of the enclosed characters. A pair of characters
3150 separated by a hyphen denotes a
3151 \fIrange expression\fP;
3152 any character that sorts between those two characters, inclusive,
3153 using the current locale's collating sequence and character set,
3154 is matched. If the first character following the
3160 then any character not enclosed is matched.
3161 The sorting order of characters in range expressions is determined by
3162 the current locale and the value of the
3169 may be matched by including it as the first or last character
3173 may be matched by including it as the first character
3182 \fIcharacter classes\fP can be specified using the syntax
3183 \fB[:\fP\fIclass\fP\fB:]\fP, where \fIclass\fP is one of the
3184 following classes defined in the POSIX standard:
3188 .if n alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit
3189 .if t alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit
3191 A character class matches any character belonging to that class.
3192 The \fBword\fP character class matches letters, digits, and the character _.
3200 an \fIequivalence class\fP can be specified using the syntax
3201 \fB[=\fP\fIc\fP\fB=]\fP, which matches all characters with the
3202 same collation weight (as defined by the current locale) as
3203 the character \fIc\fP.
3211 the syntax \fB[.\fP\fIsymbol\fP\fB.]\fP matches the collating symbol
3216 If the \fBextglob\fP shell option is enabled using the \fBshopt\fP
3217 builtin, several extended pattern matching operators are recognized.
3218 In the following description, a \fIpattern-list\fP is a list of one
3219 or more patterns separated by a \fB|\fP.
3220 Composite patterns may be formed using one or more of the following
3226 \fB?(\fP\^\fIpattern-list\^\fP\fB)\fP
3227 Matches zero or one occurrence of the given patterns
3229 \fB*(\fP\^\fIpattern-list\^\fP\fB)\fP
3230 Matches zero or more occurrences of the given patterns
3232 \fB+(\fP\^\fIpattern-list\^\fP\fB)\fP
3233 Matches one or more occurrences of the given patterns
3235 \fB@(\fP\^\fIpattern-list\^\fP\fB)\fP
3236 Matches one of the given patterns
3238 \fB!(\fP\^\fIpattern-list\^\fP\fB)\fP
3239 Matches anything except one of the given patterns
3244 After the preceding expansions, all unquoted occurrences of the
3248 and \^\f3"\fP\^ that did not result from one of the above
3249 expansions are removed.
3251 Before a command is executed, its input and output
3254 using a special notation interpreted by the shell.
3255 Redirection may also be used to open and close files for the
3256 current shell execution environment. The following redirection
3257 operators may precede or appear anywhere within a
3261 Redirections are processed in the order they appear, from
3264 Each redirection that may be preceded by a file descriptor number
3265 may instead be preceded by a word of the form {\fIvarname\fP}.
3266 In this case, for each redirection operator except
3267 >&- and <&-, the shell will allocate a file descriptor greater
3268 than 10 and assign it to \fIvarname\fP. If >&- or <&- is preceded
3269 by {\fIvarname\fP}, the value of \fIvarname\fP defines the file
3270 descriptor to close.
3272 In the following descriptions, if the file descriptor number is
3273 omitted, and the first character of the redirection operator is
3275 the redirection refers to the standard input (file descriptor
3276 0). If the first character of the redirection operator is
3278 the redirection refers to the standard output (file descriptor
3281 The word following the redirection operator in the following
3282 descriptions, unless otherwise noted, is subjected to brace expansion,
3283 tilde expansion, parameter expansion, command substitution, arithmetic
3284 expansion, quote removal, pathname expansion, and word splitting.
3285 If it expands to more than one word,
3289 Note that the order of redirections is significant. For example,
3293 ls \fB>\fP dirlist 2\fB>&\fP1
3296 directs both standard output and standard error to the file
3301 ls 2\fB>&\fP1 \fB>\fP dirlist
3304 directs only the standard output to file
3306 because the standard error was duplicated from the standard output
3307 before the standard output was redirected to
3310 \fBBash\fP handles several filenames specially when they are used in
3311 redirections, as described in the following table:
3317 If \fIfd\fP is a valid integer, file descriptor \fIfd\fP is duplicated.
3320 File descriptor 0 is duplicated.
3323 File descriptor 1 is duplicated.
3326 File descriptor 2 is duplicated.
3328 .B /dev/tcp/\fIhost\fP/\fIport\fP
3329 If \fIhost\fP is a valid hostname or Internet address, and \fIport\fP
3330 is an integer port number or service name, \fBbash\fP attempts to open
3331 a TCP connection to the corresponding socket.
3333 .B /dev/udp/\fIhost\fP/\fIport\fP
3334 If \fIhost\fP is a valid hostname or Internet address, and \fIport\fP
3335 is an integer port number or service name, \fBbash\fP attempts to open
3336 a UDP connection to the corresponding socket.
3340 A failure to open or create a file causes the redirection to fail.
3342 Redirections using file descriptors greater than 9 should be used with
3343 care, as they may conflict with file descriptors the shell uses
3345 .SS Redirecting Input
3347 Redirection of input causes the file whose name results from
3350 to be opened for reading on file descriptor
3352 or the standard input (file descriptor 0) if
3356 The general format for redirecting input is:
3359 [\fIn\fP]\fB<\fP\fIword\fP
3361 .SS Redirecting Output
3363 Redirection of output causes the file whose name results from
3366 to be opened for writing on file descriptor
3368 or the standard output (file descriptor 1) if
3370 is not specified. If the file does not exist it is created;
3371 if it does exist it is truncated to zero size.
3373 The general format for redirecting output is:
3376 [\fIn\fP]\fB>\fP\fIword\fP
3379 If the redirection operator is
3385 builtin has been enabled, the redirection will fail if the file
3386 whose name results from the expansion of \fIword\fP exists and is
3388 If the redirection operator is
3390 or the redirection operator is
3396 builtin command is not enabled, the redirection is attempted even
3397 if the file named by \fIword\fP exists.
3398 .SS Appending Redirected Output
3400 Redirection of output in this fashion
3401 causes the file whose name results from
3404 to be opened for appending on file descriptor
3406 or the standard output (file descriptor 1) if
3408 is not specified. If the file does not exist it is created.
3410 The general format for appending output is:
3413 [\fIn\fP]\fB>>\fP\fIword\fP
3416 .SS Redirecting Standard Output and Standard Error
3418 This construct allows both the
3419 standard output (file descriptor 1) and
3420 the standard error output (file descriptor 2)
3421 to be redirected to the file whose name is the
3425 There are two formats for redirecting standard output and
3436 Of the two forms, the first is preferred.
3437 This is semantically equivalent to
3440 \fB>\fP\fIword\fP 2\fB>&\fP1
3443 .SS Appending Standard Output and Standard Error
3445 This construct allows both the
3446 standard output (file descriptor 1) and
3447 the standard error output (file descriptor 2)
3448 to be appended to the file whose name is the
3452 The format for appending standard output and standard error is:
3458 This is semantically equivalent to
3461 \fB>>\fP\fIword\fP 2\fB>&\fP1
3465 This type of redirection instructs the shell to read input from the
3466 current source until a line containing only
3468 (with no trailing blanks)
3470 the lines read up to that point are then used as the standard
3471 input for a command.
3473 The format of here-documents is:
3477 \fB<<\fP[\fB\-\fP]\fIword\fP
3483 No parameter expansion, command substitution, arithmetic expansion,
3484 or pathname expansion is performed on
3486 If any characters in
3490 is the result of quote removal on
3492 and the lines in the here-document are not expanded.
3493 If \fIword\fP is unquoted,
3494 all lines of the here-document are subjected to parameter expansion,
3495 command substitution, and arithmetic expansion. In the latter
3496 case, the character sequence
3500 must be used to quote the characters
3506 If the redirection operator is
3508 then all leading tab characters are stripped from input lines and the
3512 here-documents within shell scripts to be indented in a
3515 A variant of here documents, the format is:
3523 The \fIword\fP is expanded and supplied to the command on its standard
3525 .SS "Duplicating File Descriptors"
3527 The redirection operator
3530 [\fIn\fP]\fB<&\fP\fIword\fP
3533 is used to duplicate input file descriptors.
3536 expands to one or more digits, the file descriptor denoted by
3538 is made to be a copy of that file descriptor.
3541 do not specify a file descriptor open for input, a redirection error occurs.
3550 is not specified, the standard input (file descriptor 0) is used.
3555 [\fIn\fP]\fB>&\fP\fIword\fP
3558 is used similarly to duplicate output file descriptors. If
3560 is not specified, the standard output (file descriptor 1) is used.
3563 do not specify a file descriptor open for output, a redirection error occurs.
3564 As a special case, if \fIn\fP is omitted, and \fIword\fP does not
3565 expand to one or more digits, the standard output and standard
3566 error are redirected as described previously.
3567 .SS "Moving File Descriptors"
3569 The redirection operator
3572 [\fIn\fP]\fB<&\fP\fIdigit\fP\fB\-\fP
3575 moves the file descriptor \fIdigit\fP to file descriptor
3577 or the standard input (file descriptor 0) if \fIn\fP is not specified.
3578 \fIdigit\fP is closed after being duplicated to \fIn\fP.
3580 Similarly, the redirection operator
3583 [\fIn\fP]\fB>&\fP\fIdigit\fP\fB\-\fP
3586 moves the file descriptor \fIdigit\fP to file descriptor
3588 or the standard output (file descriptor 1) if \fIn\fP is not specified.
3589 .SS "Opening File Descriptors for Reading and Writing"
3591 The redirection operator
3594 [\fIn\fP]\fB<>\fP\fIword\fP
3597 causes the file whose name is the expansion of
3599 to be opened for both reading and writing on file descriptor
3601 or on file descriptor 0 if
3603 is not specified. If the file does not exist, it is created.
3605 \fIAliases\fP allow a string to be substituted for a word when it is used
3606 as the first word of a simple command.
3607 The shell maintains a list of aliases that may be set and unset with the
3611 builtin commands (see
3613 .B SHELL BUILTIN COMMANDS
3615 The first word of each simple command, if unquoted,
3616 is checked to see if it has an
3617 alias. If so, that word is replaced by the text of the alias.
3618 The characters \fB/\fP, \fB$\fP, \fB\`\fP, and \fB=\fP and
3619 any of the shell \fImetacharacters\fP or quoting characters
3620 listed above may not appear in an alias name.
3621 The replacement text may contain any valid shell input,
3622 including shell metacharacters.
3623 The first word of the replacement text is tested
3624 for aliases, but a word that is identical to an alias being expanded
3625 is not expanded a second time.
3626 This means that one may alias
3632 does not try to recursively expand the replacement text.
3633 If the last character of the alias value is a
3635 then the next command
3636 word following the alias is also checked for alias expansion.
3638 Aliases are created and listed with the
3640 command, and removed with the
3644 There is no mechanism for using arguments in the replacement text.
3645 If arguments are needed, a shell function should be used (see
3650 Aliases are not expanded when the shell is not interactive, unless
3653 shell option is set using
3655 (see the description of
3659 \fBSHELL BUILTIN COMMANDS\fP
3662 The rules concerning the definition and use of aliases are
3665 always reads at least one complete line
3666 of input before executing any
3667 of the commands on that line. Aliases are expanded when a
3668 command is read, not when it is executed. Therefore, an
3669 alias definition appearing on the same line as another
3670 command does not take effect until the next line of input is read.
3671 The commands following the alias definition
3672 on that line are not affected by the new alias.
3673 This behavior is also an issue when functions are executed.
3674 Aliases are expanded when a function definition is read,
3675 not when the function is executed, because a function definition
3676 is itself a compound command. As a consequence, aliases
3677 defined in a function are not available until after that
3678 function is executed. To be safe, always put
3679 alias definitions on a separate line, and do not use
3681 in compound commands.
3683 For almost every purpose, aliases are superseded by
3686 A shell function, defined as described above under
3688 .BR "SHELL GRAMMAR" ,
3689 stores a series of commands for later execution.
3690 When the name of a shell function is used as a simple command name,
3691 the list of commands associated with that function name is executed.
3692 Functions are executed in the context of the
3693 current shell; no new process is created to interpret
3694 them (contrast this with the execution of a shell script).
3695 When a function is executed, the arguments to the
3696 function become the positional parameters
3697 during its execution.
3698 The special parameter
3700 is updated to reflect the change. Special parameter 0
3702 The first element of the
3705 variable is set to the name of the function while the function
3708 All other aspects of the shell execution
3709 environment are identical between a function and its caller
3710 with these exceptions: the
3715 traps (see the description of the
3719 .B SHELL BUILTIN COMMANDS
3720 below) are not inherited unless the function has been given the
3721 \fBtrace\fP attribute (see the description of the
3724 builtin below) or the
3725 \fB\-o functrace\fP shell option has been enabled with
3726 the \fBset\fP builtin
3727 (in which case all functions inherit the \fBDEBUG\fP and \fBRETURN\fP traps),
3731 trap is not inherited unless the \fB\-o errtrace\fP shell option has
3734 Variables local to the function may be declared with the
3736 builtin command. Ordinarily, variables and their values
3737 are shared between the function and its caller.
3739 If the builtin command
3741 is executed in a function, the function completes and
3742 execution resumes with the next command after the function
3744 Any command associated with the \fBRETURN\fP trap is executed
3745 before execution resumes.
3746 When a function completes, the values of the
3747 positional parameters and the special parameter
3749 are restored to the values they had prior to the function's
3752 Function names and definitions may be listed with the
3758 builtin commands. The
3764 will list the function names only
3765 (and optionally the source file and line number, if the \fBextdebug\fP
3766 shell option is enabled).
3767 Functions may be exported so that subshells
3768 automatically have them defined with the
3773 A function definition may be deleted using the \fB\-f\fP option to
3777 Note that shell functions and variables with the same name may result
3778 in multiple identically-named entries in the environment passed to the
3780 Care should be taken in cases where this may cause a problem.
3782 Functions may be recursive. No limit is imposed on the number
3784 .SH "ARITHMETIC EVALUATION"
3785 The shell allows arithmetic expressions to be evaluated, under
3786 certain circumstances (see the \fBlet\fP and \fBdeclare\fP builtin
3787 commands and \fBArithmetic Expansion\fP).
3788 Evaluation is done in fixed-width integers with no check for overflow,
3789 though division by 0 is trapped and flagged as an error.
3790 The operators and their precedence, associativity, and values
3791 are the same as in the C language.
3792 The following list of operators is grouped into levels of
3793 equal-precedence operators.
3794 The levels are listed in order of decreasing precedence.
3798 .B \fIid\fP++ \fIid\fP\-\-
3799 variable post-increment and post-decrement
3801 .B ++\fIid\fP \-\-\fIid\fP
3802 variable pre-increment and pre-decrement
3805 unary minus and plus
3808 logical and bitwise negation
3814 multiplication, division, remainder
3817 addition, subtraction
3820 left and right bitwise shifts
3826 equality and inequality
3832 bitwise exclusive OR
3843 .B \fIexpr\fP?\fIexpr\fP:\fIexpr\fP
3844 conditional operator
3846 .B = *= /= %= += \-= <<= >>= &= ^= |=
3849 .B \fIexpr1\fP , \fIexpr2\fP
3853 Shell variables are allowed as operands; parameter expansion is
3854 performed before the expression is evaluated.
3855 Within an expression, shell variables may also be referenced by name
3856 without using the parameter expansion syntax.
3857 A shell variable that is null or unset evaluates to 0 when referenced
3858 by name without using the parameter expansion syntax.
3859 The value of a variable is evaluated as an arithmetic expression
3860 when it is referenced, or when a variable which has been given the
3861 \fIinteger\fP attribute using \fBdeclare -i\fP is assigned a value.
3862 A null value evaluates to 0.
3863 A shell variable need not have its integer attribute
3864 turned on to be used in an expression.
3866 Constants with a leading 0 are interpreted as octal numbers.
3867 A leading 0x or 0X denotes hexadecimal.
3868 Otherwise, numbers take the form [\fIbase#\fP]n, where \fIbase\fP
3869 is a decimal number between 2 and 64 representing the arithmetic
3870 base, and \fIn\fP is a number in that base.
3871 If \fIbase#\fP is omitted, then base 10 is used.
3872 The digits greater than 9 are represented by the lowercase letters,
3873 the uppercase letters, @, and _, in that order.
3874 If \fIbase\fP is less than or equal to 36, lowercase and uppercase
3875 letters may be used interchangeably to represent numbers between 10
3878 Operators are evaluated in order of precedence. Sub-expressions in
3879 parentheses are evaluated first and may override the precedence
3881 .SH "CONDITIONAL EXPRESSIONS"
3882 Conditional expressions are used by the \fB[[\fP compound command and
3883 the \fBtest\fP and \fB[\fP builtin commands to test file attributes
3884 and perform string and arithmetic comparisons.
3885 Expressions are formed from the following unary or binary primaries.
3886 If any \fIfile\fP argument to one of the primaries is of the form
3887 \fI/dev/fd/n\fP, then file descriptor \fIn\fP is checked.
3888 If the \fIfile\fP argument to one of the primaries is one of
3889 \fI/dev/stdin\fP, \fI/dev/stdout\fP, or \fI/dev/stderr\fP, file
3890 descriptor 0, 1, or 2, respectively, is checked.
3892 Unless otherwise specified, primaries that operate on files follow symbolic
3893 links and operate on the target of the link, rather than the link itself.
3896 When used with \fB[[\fP, The \fB<\fP and \fB>\fP operators sort
3897 lexicographically using the current locale.
3902 True if \fIfile\fP exists.
3905 True if \fIfile\fP exists and is a block special file.
3908 True if \fIfile\fP exists and is a character special file.
3911 True if \fIfile\fP exists and is a directory.
3914 True if \fIfile\fP exists.
3917 True if \fIfile\fP exists and is a regular file.
3920 True if \fIfile\fP exists and is set-group-id.
3923 True if \fIfile\fP exists and is a symbolic link.
3926 True if \fIfile\fP exists and its ``sticky'' bit is set.
3929 True if \fIfile\fP exists and is a named pipe (FIFO).
3932 True if \fIfile\fP exists and is readable.
3935 True if \fIfile\fP exists and has a size greater than zero.
3938 True if file descriptor
3940 is open and refers to a terminal.
3943 True if \fIfile\fP exists and its set-user-id bit is set.
3946 True if \fIfile\fP exists and is writable.
3949 True if \fIfile\fP exists and is executable.
3952 True if \fIfile\fP exists and is owned by the effective user id.
3955 True if \fIfile\fP exists and is owned by the effective group id.
3958 True if \fIfile\fP exists and is a symbolic link.
3961 True if \fIfile\fP exists and is a socket.
3964 True if \fIfile\fP exists and has been modified since it was last read.
3966 \fIfile1\fP \-\fBnt\fP \fIfile2\fP
3967 True if \fIfile1\fP is newer (according to modification date) than \fIfile2\fP,
3968 or if \fIfile1\fP exists and \fPfile2\fP does not.
3970 \fIfile1\fP \-\fBot\fP \fIfile2\fP
3971 True if \fIfile1\fP is older than \fIfile2\fP, or if \fIfile2\fP exists
3972 and \fIfile1\fP does not.
3974 \fIfile1\fP \fB\-ef\fP \fIfile2\fP
3975 True if \fIfile1\fP and \fIfile2\fP refer to the same device and
3978 .B \-o \fIoptname\fP
3979 True if shell option
3982 See the list of options under the description of the
3989 True if the length of \fIstring\fP is zero.
3996 True if the length of
4000 \fIstring1\fP \fB==\fP \fIstring2\fP
4003 \fIstring1\fP \fB=\fP \fIstring2\fP
4005 True if the strings are equal. \fB=\fP should be used
4006 with the \fBtest\fP command for POSIX conformance.
4008 \fIstring1\fP \fB!=\fP \fIstring2\fP
4009 True if the strings are not equal.
4011 \fIstring1\fP \fB<\fP \fIstring2\fP
4012 True if \fIstring1\fP sorts before \fIstring2\fP lexicographically.
4014 \fIstring1\fP \fB>\fP \fIstring2\fP
4015 True if \fIstring1\fP sorts after \fIstring2\fP lexicographically.
4017 .I \fIarg1\fP \fBOP\fP \fIarg2\fP
4028 These arithmetic binary operators return true if \fIarg1\fP
4029 is equal to, not equal to, less than, less than or equal to,
4030 greater than, or greater than or equal to \fIarg2\fP, respectively.
4034 may be positive or negative integers.
4036 .SH "SIMPLE COMMAND EXPANSION"
4037 When a simple command is executed, the shell performs the following
4038 expansions, assignments, and redirections, from left to right.
4040 The words that the parser has marked as variable assignments (those
4041 preceding the command name) and redirections are saved for later
4044 The words that are not variable assignments or redirections are
4045 expanded. If any words remain after expansion, the first word
4046 is taken to be the name of the command and the remaining words are
4049 Redirections are performed as described above under
4053 The text after the \fB=\fP in each variable assignment undergoes tilde
4054 expansion, parameter expansion, command substitution, arithmetic expansion,
4055 and quote removal before being assigned to the variable.
4057 If no command name results, the variable assignments affect the current
4058 shell environment. Otherwise, the variables are added to the environment
4059 of the executed command and do not affect the current shell environment.
4060 If any of the assignments attempts to assign a value to a readonly variable,
4061 an error occurs, and the command exits with a non-zero status.
4063 If no command name results, redirections are performed, but do not
4064 affect the current shell environment. A redirection error causes the
4065 command to exit with a non-zero status.
4067 If there is a command name left after expansion, execution proceeds as
4068 described below. Otherwise, the command exits. If one of the expansions
4069 contained a command substitution, the exit status of the command is
4070 the exit status of the last command substitution performed. If there
4071 were no command substitutions, the command exits with a status of zero.
4072 .SH "COMMAND EXECUTION"
4073 After a command has been split into words, if it results in a
4074 simple command and an optional list of arguments, the following
4077 If the command name contains no slashes, the shell attempts to
4078 locate it. If there exists a shell function by that name, that
4079 function is invoked as described above in
4082 If the name does not match a function, the shell searches for
4083 it in the list of shell builtins. If a match is found, that
4086 If the name is neither a shell function nor a builtin,
4087 and contains no slashes,
4089 searches each element of the
4092 for a directory containing an executable file by that name.
4094 uses a hash table to remember the full pathnames of executable
4099 .B "SHELL BUILTIN COMMANDS"
4101 A full search of the directories in
4104 is performed only if the command is not found in the hash table.
4105 If the search is unsuccessful, the shell searches for a defined shell
4106 function named \fBcommand_not_found_handle\fP.
4107 If that function exists, it is invoked with the original command and
4108 the original command's arguments as its arguments, and the function's
4109 exit status becomes the exit status of the shell.
4110 If that function is not defined, the shell prints an error
4111 message and returns an exit status of 127.
4113 If the search is successful, or if the command name contains
4114 one or more slashes, the shell executes the named program in a
4115 separate execution environment.
4116 Argument 0 is set to the name given, and the remaining arguments
4117 to the command are set to the arguments given, if any.
4119 If this execution fails because the file is not in executable
4120 format, and the file is not a directory, it is assumed to be
4121 a \fIshell script\fP, a file
4122 containing shell commands. A subshell is spawned to execute
4123 it. This subshell reinitializes itself, so
4124 that the effect is as if a new shell had been invoked
4125 to handle the script, with the exception that the locations of
4126 commands remembered by the parent (see
4130 \fBSHELL BUILTIN COMMANDS\fP)
4131 are retained by the child.
4133 If the program is a file beginning with
4135 the remainder of the first line specifies an interpreter
4136 for the program. The shell executes the
4137 specified interpreter on operating systems that do not
4138 handle this executable format themselves. The arguments to the
4139 interpreter consist of a single optional argument following the
4140 interpreter name on the first line of the program, followed
4141 by the name of the program, followed by the command
4143 .SH COMMAND EXECUTION ENVIRONMENT
4144 The shell has an \fIexecution environment\fP, which consists of the
4148 open files inherited by the shell at invocation, as modified by
4149 redirections supplied to the \fBexec\fP builtin
4151 the current working directory as set by \fBcd\fP, \fBpushd\fP, or
4152 \fBpopd\fP, or inherited by the shell at invocation
4154 the file creation mode mask as set by \fBumask\fP or inherited from
4157 current traps set by \fBtrap\fP
4159 shell parameters that are set by variable assignment or with \fBset\fP
4160 or inherited from the shell's parent in the environment
4162 shell functions defined during execution or inherited from the shell's
4163 parent in the environment
4165 options enabled at invocation (either by default or with command-line
4166 arguments) or by \fBset\fP
4168 options enabled by \fBshopt\fP
4170 shell aliases defined with \fBalias\fP
4172 various process IDs, including those of background jobs, the value
4173 of \fB$$\fP, and the value of
4177 When a simple command other than a builtin or shell function
4178 is to be executed, it
4179 is invoked in a separate execution environment that consists of
4180 the following. Unless otherwise noted, the values are inherited
4184 the shell's open files, plus any modifications and additions specified
4185 by redirections to the command
4187 the current working directory
4189 the file creation mode mask
4191 shell variables and functions marked for export, along with variables
4192 exported for the command, passed in the environment
4194 traps caught by the shell are reset to the values inherited from the
4195 shell's parent, and traps ignored by the shell are ignored
4197 A command invoked in this separate environment cannot affect the
4198 shell's execution environment.
4200 Command substitution, commands grouped with parentheses,
4201 and asynchronous commands are invoked in a
4202 subshell environment that is a duplicate of the shell environment,
4203 except that traps caught by the shell are reset to the values
4204 that the shell inherited from its parent at invocation. Builtin
4205 commands that are invoked as part of a pipeline are also executed in a
4206 subshell environment. Changes made to the subshell environment
4207 cannot affect the shell's execution environment.
4209 Subshells spawned to execute command substitutions inherit the value of
4210 the \fB\-e\fP option from the parent shell. When not in posix mode,
4211 Bash clears the \fB\-e\fP option in such subshells.
4213 If a command is followed by a \fB&\fP and job control is not active, the
4214 default standard input for the command is the empty file \fI/dev/null\fP.
4215 Otherwise, the invoked command inherits the file descriptors of the calling
4216 shell as modified by redirections.
4218 When a program is invoked it is given an array of strings
4222 \fIname\fP\-\fIvalue\fP pairs, of the form
4223 .IR "name\fR=\fPvalue" .
4225 The shell provides several ways to manipulate the environment.
4226 On invocation, the shell scans its own environment and
4227 creates a parameter for each name found, automatically marking
4230 to child processes. Executed commands inherit the environment.
4235 commands allow parameters and functions to be added to and
4236 deleted from the environment. If the value of a parameter
4237 in the environment is modified, the new value becomes part
4238 of the environment, replacing the old. The environment
4239 inherited by any executed command consists of the shell's
4240 initial environment, whose values may be modified in the shell,
4241 less any pairs removed by the
4243 command, plus any additions via the
4249 The environment for any
4251 or function may be augmented temporarily by prefixing it with
4252 parameter assignments, as described above in
4255 These assignment statements affect only the environment seen
4260 option is set (see the
4262 builtin command below), then
4264 parameter assignments are placed in the environment for a command,
4265 not just those that precede the command name.
4269 invokes an external command, the variable
4271 is set to the full file name of the command and passed to that
4272 command in its environment.
4275 The exit status of an executed command is the value returned by the
4276 \fIwaitpid\fP system call or equivalent function. Exit statuses
4277 fall between 0 and 255, though, as explained below, the shell may
4278 use values above 125 specially. Exit statuses from shell builtins and
4279 compound commands are also limited to this range. Under certain
4280 circumstances, the shell will use special values to indicate specific
4283 For the shell's purposes, a command which exits with a
4284 zero exit status has succeeded. An exit status of zero
4285 indicates success. A non-zero exit status indicates failure.
4286 When a command terminates on a fatal signal \fIN\fP, \fBbash\fP uses
4287 the value of 128+\fIN\fP as the exit status.
4289 If a command is not found, the child process created to
4290 execute it returns a status of 127. If a command is found
4291 but is not executable, the return status is 126.
4293 If a command fails because of an error during expansion or redirection,
4294 the exit status is greater than zero.
4296 Shell builtin commands return a status of 0 (\fItrue\fP) if
4297 successful, and non-zero (\fIfalse\fP) if an error occurs
4299 All builtins return an exit status of 2 to indicate incorrect usage.
4301 \fBBash\fP itself returns the exit status of the last command
4302 executed, unless a syntax error occurs, in which case it exits
4303 with a non-zero value. See also the \fBexit\fP builtin
4306 When \fBbash\fP is interactive, in the absence of any traps, it ignores
4309 (so that \fBkill 0\fP does not kill an interactive shell),
4313 is caught and handled (so that the \fBwait\fP builtin is interruptible).
4314 In all cases, \fBbash\fP ignores
4317 If job control is in effect,
4328 Non-builtin commands run by \fBbash\fP have signal handlers
4329 set to the values inherited by the shell from its parent.
4330 When job control is not in effect, asynchronous commands
4337 in addition to these inherited handlers.
4338 Commands run as a result of command substitution ignore the
4339 keyboard-generated job control signals
4348 The shell exits by default upon receipt of a
4351 Before exiting, an interactive shell resends the
4354 to all jobs, running or stopped.
4355 Stopped jobs are sent
4358 to ensure that they receive the
4361 To prevent the shell from
4362 sending the signal to a particular job, it should be removed from the
4367 .B "SHELL BUILTIN COMMANDS"
4377 shell option has been set with
4383 to all jobs when an interactive login shell exits.
4385 If \fBbash\fP is waiting for a command to complete and receives a signal
4386 for which a trap has been set, the trap will not be executed until
4387 the command completes.
4388 When \fBbash\fP is waiting for an asynchronous command via the \fBwait\fP
4389 builtin, the reception of a signal for which a trap has been set will
4390 cause the \fBwait\fP builtin to return immediately with an exit status
4391 greater than 128, immediately after which the trap is executed.
4394 refers to the ability to selectively stop (\fIsuspend\fP)
4395 the execution of processes and continue (\fIresume\fP)
4396 their execution at a later point. A user typically employs
4397 this facility via an interactive interface supplied jointly
4398 by the operating system kernel's terminal driver and
4401 The shell associates a
4403 with each pipeline. It keeps a table of currently executing
4404 jobs, which may be listed with the
4408 starts a job asynchronously (in the
4410 it prints a line that looks like:
4416 indicating that this job is job number 1 and that the process ID
4417 of the last process in the pipeline associated with this job is 25647.
4418 All of the processes in a single pipeline are members of the same job.
4422 abstraction as the basis for job control.
4424 To facilitate the implementation of the user interface to job
4425 control, the operating system maintains the notion of a \fIcurrent terminal
4426 process group ID\fP. Members of this process group (processes whose
4427 process group ID is equal to the current terminal process group ID)
4428 receive keyboard-generated signals such as
4431 These processes are said to be in the
4434 processes are those whose process group ID differs from the terminal's;
4435 such processes are immune to keyboard-generated signals.
4436 Only foreground processes are allowed to read from or, if the
4437 user so specifies with \f(CWstty tostop\fP, write to the
4439 Background processes which attempt to read from (write to when
4440 \f(CWstty tostop\fP is in effect) the
4443 .B SIGTTIN (SIGTTOU)
4444 signal by the kernel's terminal driver,
4445 which, unless caught, suspends the process.
4447 If the operating system on which
4452 contains facilities to use it.
4455 character (typically
4457 Control-Z) while a process is running
4458 causes that process to be stopped and returns control to
4461 .I "delayed suspend"
4462 character (typically
4464 Control-Y) causes the process to be stopped when it
4465 attempts to read input from the terminal, and control to
4468 The user may then manipulate the state of this job, using the
4470 command to continue it in the background, the
4472 command to continue it in the foreground, or
4475 command to kill it. A \fB^Z\fP takes effect immediately,
4476 and has the additional side effect of causing pending output
4477 and typeahead to be discarded.
4479 There are a number of ways to refer to a job in the shell.
4482 introduces a job specification (\fIjobspec\fP). Job number
4484 may be referred to as
4486 A job may also be referred to using a prefix of the name used to
4487 start it, or using a substring that appears in its command line.
4492 job. If a prefix matches more than one job,
4494 reports an error. Using
4496 on the other hand, refers to any job containing the string
4498 in its command line. If the substring matches more than one job,
4500 reports an error. The symbols
4504 refer to the shell's notion of the
4506 which is the last job stopped while it was in
4507 the foreground or started in the background.
4510 may be referenced using
4512 If there is only a single job, \fB%+\fP and \fB%\-\fP can both be used
4513 to refer to that job.
4514 In output pertaining to jobs (e.g., the output of the
4516 command), the current job is always flagged with a
4518 and the previous job with a
4520 A single % (with no accompanying job specification) also refers to the
4523 Simply naming a job can be used to bring it into the
4528 bringing job 1 from the background into the foreground.
4531 resumes job 1 in the background, equivalent to
4534 The shell learns immediately whenever a job changes state.
4537 waits until it is about to print a prompt before reporting
4538 changes in a job's status so as to not interrupt
4539 any other output. If the
4546 reports such changes immediately.
4550 is executed for each child that exits.
4552 If an attempt to exit
4554 is made while jobs are stopped (or, if the \fBcheckjobs\fP shell option has
4555 been enabled using the \fBshopt\fP builtin, running), the shell prints a
4556 warning message, and, if the \fBcheckjobs\fP option is enabled, lists the
4557 jobs and their statuses.
4560 command may then be used to inspect their status.
4561 If a second attempt to exit is made without an intervening command,
4562 the shell does not print another warning, and any stopped
4563 jobs are terminated.
4565 When executing interactively,
4567 displays the primary prompt
4570 when it is ready to read a command, and the secondary prompt
4573 when it needs more input to complete a command.
4575 allows these prompt strings to be customized by inserting a number of
4576 backslash-escaped special characters that are decoded as follows:
4581 an ASCII bell character (07)
4584 the date in "Weekday Month Date" format (e.g., "Tue May 26")
4586 .B \eD{\fIformat\fP}
4587 the \fIformat\fP is passed to \fIstrftime\fP(3) and the result is inserted
4588 into the prompt string; an empty \fIformat\fP results in a locale-specific
4589 time representation. The braces are required
4592 an ASCII escape character (033)
4595 the hostname up to the first `.'
4601 the number of jobs currently managed by the shell
4604 the basename of the shell's terminal device name
4613 the name of the shell, the basename of
4615 (the portion following the final slash)
4618 the current time in 24-hour HH:MM:SS format
4621 the current time in 12-hour HH:MM:SS format
4624 the current time in 12-hour am/pm format
4627 the current time in 24-hour HH:MM format
4630 the username of the current user
4633 the version of \fBbash\fP (e.g., 2.00)
4636 the release of \fBbash\fP, version + patch level (e.g., 2.00.0)
4639 the current working directory, with
4642 abbreviated with a tilde
4643 (uses the value of the
4649 the basename of the current working directory, with
4652 abbreviated with a tilde
4655 the history number of this command
4658 the command number of this command
4661 if the effective UID is 0, a
4667 the character corresponding to the octal number \fInnn\fP
4673 begin a sequence of non-printing characters, which could be used to
4674 embed a terminal control sequence into the prompt
4677 end a sequence of non-printing characters
4681 The command number and the history number are usually different:
4682 the history number of a command is its position in the history
4683 list, which may include commands restored from the history file
4687 below), while the command number is the position in the sequence
4688 of commands executed during the current shell session.
4689 After the string is decoded, it is expanded via
4690 parameter expansion, command substitution, arithmetic
4691 expansion, and quote removal, subject to the value of the
4693 shell option (see the description of the
4697 .B "SHELL BUILTIN COMMANDS"
4700 This is the library that handles reading input when using an interactive
4703 option is given at shell invocation.
4704 Line editing is also used when using the \fB\-e\fP option to the
4706 By default, the line editing commands are similar to those of emacs.
4707 A vi-style line editing interface is also available.
4708 Line editing can be enabled at any time using the
4716 .B SHELL BUILTIN COMMANDS
4718 To turn off line editing after the shell is running, use the
4725 .SS "Readline Notation"
4727 In this section, the emacs-style notation is used to denote
4728 keystrokes. Control keys are denoted by C\-\fIkey\fR, e.g., C\-n
4729 means Control\-N. Similarly,
4731 keys are denoted by M\-\fIkey\fR, so M\-x means Meta\-X. (On keyboards
4734 key, M\-\fIx\fP means ESC \fIx\fP, i.e., press the Escape key
4737 key. This makes ESC the \fImeta prefix\fP.
4738 The combination M\-C\-\fIx\fP means ESC\-Control\-\fIx\fP,
4739 or press the Escape key
4740 then hold the Control key while pressing the
4744 Readline commands may be given numeric
4746 which normally act as a repeat count.
4747 Sometimes, however, it is the sign of the argument that is significant.
4748 Passing a negative argument to a command that acts in the forward
4749 direction (e.g., \fBkill\-line\fP) causes that command to act in a
4751 Commands whose behavior with arguments deviates from this are noted
4754 When a command is described as \fIkilling\fP text, the text
4755 deleted is saved for possible future retrieval
4756 (\fIyanking\fP). The killed text is saved in a
4757 \fIkill ring\fP. Consecutive kills cause the text to be
4758 accumulated into one unit, which can be yanked all at once.
4759 Commands which do not kill text separate the chunks of text
4761 .SS "Readline Initialization"
4763 Readline is customized by putting commands in an initialization
4764 file (the \fIinputrc\fP file).
4765 The name of this file is taken from the value of the
4768 variable. If that variable is unset, the default is
4770 When a program which uses the readline library starts up, the
4771 initialization file is read, and the key bindings and variables
4773 There are only a few basic constructs allowed in the
4774 readline initialization file.
4775 Blank lines are ignored.
4776 Lines beginning with a \fB#\fP are comments.
4777 Lines beginning with a \fB$\fP indicate conditional constructs.
4778 Other lines denote key bindings and variable settings.
4780 The default key-bindings may be changed with an
4783 Other programs that use this library may add their own commands
4786 For example, placing
4789 M\-Control\-u: universal\-argument
4793 C\-Meta\-u: universal\-argument
4797 would make M\-C\-u execute the readline command
4798 .IR universal\-argument .
4800 The following symbolic character names are recognized:
4813 In addition to command names, readline allows keys to be bound
4814 to a string that is inserted when the key is pressed (a \fImacro\fP).
4815 .SS "Readline Key Bindings"
4817 The syntax for controlling key bindings in the
4819 file is simple. All that is required is the name of the
4820 command or the text of a macro and a key sequence to which
4821 it should be bound. The name may be specified in one of two ways:
4822 as a symbolic key name, possibly with \fIMeta\-\fP or \fIControl\-\fP
4823 prefixes, or as a key sequence.
4825 When using the form \fBkeyname\fP:\^\fIfunction\-name\fP or \fImacro\fP,
4827 is the name of a key spelled out in English. For example:
4830 Control-u: universal\-argument
4832 Meta-Rubout: backward-kill-word
4834 Control-o: "> output"
4837 In the above example,
4839 is bound to the function
4840 .BR universal\-argument ,
4842 is bound to the function
4843 .BR backward\-kill\-word ,
4846 is bound to run the macro
4847 expressed on the right hand side (that is, to insert the text
4848 .if t \f(CW> output\fP
4852 In the second form, \fB"keyseq"\fP:\^\fIfunction\-name\fP or \fImacro\fP,
4856 above in that strings denoting
4857 an entire key sequence may be specified by placing the sequence
4858 within double quotes. Some GNU Emacs style key escapes can be
4859 used, as in the following example, but the symbolic character names
4863 "\eC\-u": universal\-argument
4865 "\eC\-x\eC\-r": re\-read\-init\-file
4867 "\ee[11~": "Function Key 1"
4872 is again bound to the function
4873 .BR universal\-argument .
4875 is bound to the function
4876 .BR re\-read\-init\-file ,
4879 is bound to insert the text
4880 .if t \f(CWFunction Key 1\fP.
4881 .if n ``Function Key 1''.
4883 The full set of GNU Emacs style escape sequences is
4907 In addition to the GNU Emacs style escape sequences, a second
4908 set of backslash escapes is available:
4937 the eight-bit character whose value is the octal value \fInnn\fP
4938 (one to three digits)
4941 the eight-bit character whose value is the hexadecimal value \fIHH\fP
4942 (one or two hex digits)
4946 When entering the text of a macro, single or double quotes must
4947 be used to indicate a macro definition.
4948 Unquoted text is assumed to be a function name.
4949 In the macro body, the backslash escapes described above are expanded.
4950 Backslash will quote any other character in the macro text,
4951 including " and \(aq.
4954 allows the current readline key bindings to be displayed or modified
4957 builtin command. The editing mode may be switched during interactive
4962 builtin command (see
4964 .B SHELL BUILTIN COMMANDS
4966 .SS "Readline Variables"
4968 Readline has variables that can be used to further customize its
4969 behavior. A variable may be set in the
4971 file with a statement of the form
4974 \fBset\fP \fIvariable\-name\fP \fIvalue\fP
4977 Except where noted, readline variables can take the values
4981 (without regard to case).
4982 Unrecognized variable names are ignored.
4983 When a variable value is read, empty or null values, "on" (case-insensitive),
4984 and "1" are equivalent to \fBOn\fP. All other values are equivalent to
4986 The variables and their default values are:
4990 .B bell\-style (audible)
4991 Controls what happens when readline wants to ring the terminal bell.
4992 If set to \fBnone\fP, readline never rings the bell. If set to
4993 \fBvisible\fP, readline uses a visible bell if one is available.
4994 If set to \fBaudible\fP, readline attempts to ring the terminal's bell.
4996 .B bind\-tty\-special\-chars (On)
4997 If set to \fBOn\fP, readline attempts to bind the control characters
4998 treated specially by the kernel's terminal driver to their readline
5001 .B comment\-begin (``#'')
5002 The string that is inserted when the readline
5004 command is executed.
5005 This command is bound to
5007 in emacs mode and to
5011 .B completion\-ignore\-case (Off)
5012 If set to \fBOn\fP, readline performs filename matching and completion
5013 in a case\-insensitive fashion.
5015 .B completion\-prefix\-display\-length (0)
5016 The length in characters of the common prefix of a list of possible
5017 completions that is displayed without modification. When set to a
5018 value greater than zero, common prefixes longer than this value are
5019 replaced with an ellipsis when displaying possible completions.
5021 .B completion\-query\-items (100)
5022 This determines when the user is queried about viewing
5023 the number of possible completions
5024 generated by the \fBpossible\-completions\fP command.
5025 It may be set to any integer value greater than or equal to
5026 zero. If the number of possible completions is greater than
5027 or equal to the value of this variable, the user is asked whether
5028 or not he wishes to view them; otherwise they are simply listed
5031 .B convert\-meta (On)
5032 If set to \fBOn\fP, readline will convert characters with the
5033 eighth bit set to an ASCII key sequence
5034 by stripping the eighth bit and prefixing an
5035 escape character (in effect, using escape as the \fImeta prefix\fP).
5037 .B disable\-completion (Off)
5038 If set to \fBOn\fP, readline will inhibit word completion. Completion
5039 characters will be inserted into the line as if they had been
5040 mapped to \fBself-insert\fP.
5042 .B editing\-mode (emacs)
5043 Controls whether readline begins with a set of key bindings similar
5044 to \fIemacs\fP or \fIvi\fP.
5046 can be set to either
5051 .B echo\-control\-characters (On)
5052 When set to \fBOn\fP, on operating systems that indicate they support it,
5053 readline echoes a character corresponding to a signal generated from the
5056 .B enable\-keypad (Off)
5057 When set to \fBOn\fP, readline will try to enable the application
5058 keypad when it is called. Some systems need this to enable the
5061 .B enable\-meta\-key (On)
5062 When set to \fBOn\fP, readline will try to enable any meta modifier
5063 key the terminal claims to support when it is called. On many terminals,
5064 the meta key is used to send eight-bit characters.
5066 .B expand\-tilde (Off)
5067 If set to \fBon\fP, tilde expansion is performed when readline
5068 attempts word completion.
5070 .B history\-preserve\-point (Off)
5071 If set to \fBon\fP, the history code attempts to place point at the
5072 same location on each history line retrieved with \fBprevious-history\fP
5073 or \fBnext-history\fP.
5075 .B history\-size (0)
5076 Set the maximum number of history entries saved in the history list. If
5077 set to zero, the number of entries in the history list is not limited.
5079 .B horizontal\-scroll\-mode (Off)
5080 When set to \fBOn\fP, makes readline use a single line for display,
5081 scrolling the input horizontally on a single screen line when it
5082 becomes longer than the screen width rather than wrapping to a new line.
5084 .B input\-meta (Off)
5085 If set to \fBOn\fP, readline will enable eight-bit input (that is,
5086 it will not strip the high bit from the characters it reads),
5087 regardless of what the terminal claims it can support. The name
5089 is a synonym for this variable.
5091 .B isearch\-terminators (``C\-[C\-J'')
5092 The string of characters that should terminate an incremental
5093 search without subsequently executing the character as a command.
5094 If this variable has not been given a value, the characters
5095 \fIESC\fP and \fIC\-J\fP will terminate an incremental search.
5098 Set the current readline keymap. The set of valid keymap names is
5099 \fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi,
5102 \fIvi\fP is equivalent to \fIvi\-command\fP; \fIemacs\fP is
5103 equivalent to \fIemacs\-standard\fP. The default value is
5107 also affects the default keymap.
5109 .B mark\-directories (On)
5110 If set to \fBOn\fP, completed directory names have a slash
5113 .B mark\-modified\-lines (Off)
5114 If set to \fBOn\fP, history lines that have been modified are displayed
5115 with a preceding asterisk (\fB*\fP).
5117 .B mark\-symlinked\-directories (Off)
5118 If set to \fBOn\fP, completed names which are symbolic links to directories
5119 have a slash appended (subject to the value of
5120 \fBmark\-directories\fP).
5122 .B match\-hidden\-files (On)
5123 This variable, when set to \fBOn\fP, causes readline to match files whose
5124 names begin with a `.' (hidden files) when performing filename
5125 completion, unless the leading `.' is
5126 supplied by the user in the filename to be completed.
5128 .B output\-meta (Off)
5129 If set to \fBOn\fP, readline will display characters with the
5130 eighth bit set directly rather than as a meta-prefixed escape
5133 .B page\-completions (On)
5134 If set to \fBOn\fP, readline uses an internal \fImore\fP-like pager
5135 to display a screenful of possible completions at a time.
5137 .B print\-completions\-horizontally (Off)
5138 If set to \fBOn\fP, readline will display completions with matches
5139 sorted horizontally in alphabetical order, rather than down the screen.
5141 .B revert\-all\-at\-newline (Off)
5142 If set to \fBon\fP, readline will undo all changes to history lines
5143 before returning when \fBaccept\-line\fP is executed. By default,
5144 history lines may be modified and retain individual undo lists across
5145 calls to \fBreadline\fP.
5147 .B show\-all\-if\-ambiguous (Off)
5148 This alters the default behavior of the completion functions. If
5151 words which have more than one possible completion cause the
5152 matches to be listed immediately instead of ringing the bell.
5154 .B show\-all\-if\-unmodified (Off)
5155 This alters the default behavior of the completion functions in
5156 a fashion similar to \fBshow\-all\-if\-ambiguous\fP.
5159 words which have more than one possible completion without any
5160 possible partial completion (the possible completions don't share
5161 a common prefix) cause the matches to be listed immediately instead
5162 of ringing the bell.
5164 .B skip\-completed\-text (Off)
5165 If set to \fBOn\fP, this alters the default completion behavior when
5166 inserting a single match into the line. It's only active when
5167 performing completion in the middle of a word. If enabled, readline
5168 does not insert characters from the completion that match characters
5169 after point in the word being completed, so portions of the word
5170 following the cursor are not duplicated.
5172 .B visible\-stats (Off)
5173 If set to \fBOn\fP, a character denoting a file's type as reported
5174 by \fIstat\fP(2) is appended to the filename when listing possible
5177 .SS "Readline Conditional Constructs"
5179 Readline implements a facility similar in spirit to the conditional
5180 compilation features of the C preprocessor which allows key
5181 bindings and variable settings to be performed as the result
5182 of tests. There are four parser directives used.
5186 construct allows bindings to be made based on the
5187 editing mode, the terminal being used, or the application using
5188 readline. The text of the test extends to the end of the line;
5189 no characters are required to isolate it.
5192 The \fBmode=\fP form of the \fB$if\fP directive is used to test
5193 whether readline is in emacs or vi mode.
5194 This may be used in conjunction
5195 with the \fBset keymap\fP command, for instance, to set bindings in
5196 the \fIemacs\-standard\fP and \fIemacs\-ctlx\fP keymaps only if
5197 readline is starting out in emacs mode.
5199 The \fBterm=\fP form may be used to include terminal-specific
5200 key bindings, perhaps to bind the key sequences output by the
5201 terminal's function keys. The word on the right side of the
5203 is tested against the both full name of the terminal and the portion
5204 of the terminal name before the first \fB\-\fP. This allows
5211 .IP \fBapplication\fP
5212 The \fBapplication\fP construct is used to include
5213 application-specific settings. Each program using the readline
5214 library sets the \fIapplication name\fP, and an initialization
5215 file can test for a particular value.
5216 This could be used to bind key sequences to functions useful for
5217 a specific program. For instance, the following command adds a
5218 key sequence that quotes the current or previous word in Bash:
5223 # Quote the current or previous word
5224 "\eC\-xq": "\eeb\e"\eef\e""
5230 This command, as seen in the previous example, terminates an
5233 Commands in this branch of the \fB$if\fP directive are executed if
5236 This directive takes a single filename as an argument and reads commands
5237 and bindings from that file. For example, the following directive
5238 would read \fI/etc/inputrc\fP:
5242 \fB$include\fP \^ \fI/etc/inputrc\fP
5247 Readline provides commands for searching through the command history
5251 below) for lines containing a specified string.
5252 There are two search modes:
5255 .IR non-incremental .
5257 Incremental searches begin before the user has finished typing the
5259 As each character of the search string is typed, readline displays
5260 the next entry from the history matching the string typed so far.
5261 An incremental search requires only as many characters as needed to
5262 find the desired history entry.
5263 The characters present in the value of the \fBisearch-terminators\fP
5264 variable are used to terminate an incremental search.
5265 If that variable has not been assigned a value the Escape and
5266 Control-J characters will terminate an incremental search.
5267 Control-G will abort an incremental search and restore the original
5269 When the search is terminated, the history entry containing the
5270 search string becomes the current line.
5272 To find other matching entries in the history list, type Control-S or
5273 Control-R as appropriate.
5274 This will search backward or forward in the history for the next
5275 entry matching the search string typed so far.
5276 Any other key sequence bound to a readline command will terminate
5277 the search and execute that command.
5278 For instance, a \fInewline\fP will terminate the search and accept
5279 the line, thereby executing the command from the history list.
5281 Readline remembers the last incremental search string. If two
5282 Control-Rs are typed without any intervening characters defining a
5283 new search string, any remembered search string is used.
5285 Non-incremental searches read the entire search string before starting
5286 to search for matching history lines. The search string may be
5287 typed by the user or be part of the contents of the current line.
5288 .SS "Readline Command Names"
5290 The following is a list of the names of the commands and the default
5291 key sequences to which they are bound.
5292 Command names without an accompanying key sequence are unbound by default.
5293 In the following descriptions, \fIpoint\fP refers to the current cursor
5294 position, and \fImark\fP refers to a cursor position saved by the
5295 \fBset\-mark\fP command.
5296 The text between the point and mark is referred to as the \fIregion\fP.
5297 .SS Commands for Moving
5301 .B beginning\-of\-line (C\-a)
5302 Move to the start of the current line.
5304 .B end\-of\-line (C\-e)
5305 Move to the end of the line.
5307 .B forward\-char (C\-f)
5308 Move forward a character.
5310 .B backward\-char (C\-b)
5311 Move back a character.
5313 .B forward\-word (M\-f)
5314 Move forward to the end of the next word. Words are composed of
5315 alphanumeric characters (letters and digits).
5317 .B backward\-word (M\-b)
5318 Move back to the start of the current or previous word.
5319 Words are composed of alphanumeric characters (letters and digits).
5321 .B shell\-forward\-word
5322 Move forward to the end of the next word.
5323 Words are delimited by non-quoted shell metacharacters.
5325 .B shell\-backward\-word
5326 Move back to the start of the current or previous word.
5327 Words are delimited by non-quoted shell metacharacters.
5329 .B clear\-screen (C\-l)
5330 Clear the screen leaving the current line at the top of the screen.
5331 With an argument, refresh the current line without clearing the
5334 .B redraw\-current\-line
5335 Refresh the current line.
5337 .SS Commands for Manipulating the History
5341 .B accept\-line (Newline, Return)
5342 Accept the line regardless of where the cursor is. If this line is
5343 non-empty, add it to the history list according to the state of the
5346 variable. If the line is a modified history
5347 line, then restore the history line to its original state.
5349 .B previous\-history (C\-p)
5350 Fetch the previous command from the history list, moving back in
5353 .B next\-history (C\-n)
5354 Fetch the next command from the history list, moving forward in the
5357 .B beginning\-of\-history (M\-<)
5358 Move to the first line in the history.
5360 .B end\-of\-history (M\->)
5361 Move to the end of the input history, i.e., the line currently being
5364 .B reverse\-search\-history (C\-r)
5365 Search backward starting at the current line and moving `up' through
5366 the history as necessary. This is an incremental search.
5368 .B forward\-search\-history (C\-s)
5369 Search forward starting at the current line and moving `down' through
5370 the history as necessary. This is an incremental search.
5372 .B non\-incremental\-reverse\-search\-history (M\-p)
5373 Search backward through the history starting at the current line
5374 using a non-incremental search for a string supplied by the user.
5376 .B non\-incremental\-forward\-search\-history (M\-n)
5377 Search forward through the history using a non-incremental search for
5378 a string supplied by the user.
5380 .B history\-search\-forward
5381 Search forward through the history for the string of characters
5382 between the start of the current line and the point.
5383 This is a non-incremental search.
5385 .B history\-search\-backward
5386 Search backward through the history for the string of characters
5387 between the start of the current line and the point.
5388 This is a non-incremental search.
5390 .B yank\-nth\-arg (M\-C\-y)
5391 Insert the first argument to the previous command (usually
5392 the second word on the previous line) at point.
5395 insert the \fIn\fPth word from the previous command (the words
5396 in the previous command begin with word 0). A negative argument
5397 inserts the \fIn\fPth word from the end of the previous command.
5398 Once the argument \fIn\fP is computed, the argument is extracted
5399 as if the "!\fIn\fP" history expansion had been specified.
5402 yank\-last\-arg (M\-.\^, M\-_\^)
5403 Insert the last argument to the previous command (the last word of
5404 the previous history entry). With an argument,
5405 behave exactly like \fByank\-nth\-arg\fP.
5406 Successive calls to \fByank\-last\-arg\fP move back through the history
5407 list, inserting the last argument of each line in turn.
5408 The history expansion facilities are used to extract the last argument,
5409 as if the "!$" history expansion had been specified.
5411 .B shell\-expand\-line (M\-C\-e)
5412 Expand the line as the shell does. This
5413 performs alias and history expansion as well as all of the shell
5414 word expansions. See
5416 .B HISTORY EXPANSION
5417 below for a description of history expansion.
5419 .B history\-expand\-line (M\-^)
5420 Perform history expansion on the current line.
5423 .B HISTORY EXPANSION
5424 below for a description of history expansion.
5427 Perform history expansion on the current line and insert a space.
5430 .B HISTORY EXPANSION
5431 below for a description of history expansion.
5433 .B alias\-expand\-line
5434 Perform alias expansion on the current line.
5438 above for a description of alias expansion.
5440 .B history\-and\-alias\-expand\-line
5441 Perform history and alias expansion on the current line.
5443 .B insert\-last\-argument (M\-.\^, M\-_\^)
5444 A synonym for \fByank\-last\-arg\fP.
5446 .B operate\-and\-get\-next (C\-o)
5447 Accept the current line for execution and fetch the next line
5448 relative to the current line from the history for editing. Any
5449 argument is ignored.
5451 .B edit\-and\-execute\-command (C\-xC\-e)
5452 Invoke an editor on the current command line, and execute the result as shell
5454 \fBBash\fP attempts to invoke
5459 and \fIemacs\fP as the editor, in that order.
5461 .SS Commands for Changing Text
5465 .B delete\-char (C\-d)
5466 Delete the character at point. If point is at the
5467 beginning of the line, there are no characters in the line, and
5468 the last character typed was not bound to \fBdelete\-char\fP,
5473 .B backward\-delete\-char (Rubout)
5474 Delete the character behind the cursor. When given a numeric argument,
5475 save the deleted text on the kill ring.
5477 .B forward\-backward\-delete\-char
5478 Delete the character under the cursor, unless the cursor is at the
5479 end of the line, in which case the character behind the cursor is
5482 .B quoted\-insert (C\-q, C\-v)
5483 Add the next character typed to the line verbatim. This is
5484 how to insert characters like \fBC\-q\fP, for example.
5486 .B tab\-insert (C\-v TAB)
5487 Insert a tab character.
5489 .B self\-insert (a,\ b,\ A,\ 1,\ !,\ ...)
5490 Insert the character typed.
5492 .B transpose\-chars (C\-t)
5493 Drag the character before point forward over the character at point,
5494 moving point forward as well.
5495 If point is at the end of the line, then this transposes
5496 the two characters before point.
5497 Negative arguments have no effect.
5499 .B transpose\-words (M\-t)
5500 Drag the word before point past the word after point,
5501 moving point over that word as well.
5502 If point is at the end of the line, this transposes
5503 the last two words on the line.
5505 .B upcase\-word (M\-u)
5506 Uppercase the current (or following) word. With a negative argument,
5507 uppercase the previous word, but do not move point.
5509 .B downcase\-word (M\-l)
5510 Lowercase the current (or following) word. With a negative argument,
5511 lowercase the previous word, but do not move point.
5513 .B capitalize\-word (M\-c)
5514 Capitalize the current (or following) word. With a negative argument,
5515 capitalize the previous word, but do not move point.
5518 Toggle overwrite mode. With an explicit positive numeric argument,
5519 switches to overwrite mode. With an explicit non-positive numeric
5520 argument, switches to insert mode. This command affects only
5521 \fBemacs\fP mode; \fBvi\fP mode does overwrite differently.
5522 Each call to \fIreadline()\fP starts in insert mode.
5523 In overwrite mode, characters bound to \fBself\-insert\fP replace
5524 the text at point rather than pushing the text to the right.
5525 Characters bound to \fBbackward\-delete\-char\fP replace the character
5526 before point with a space. By default, this command is unbound.
5528 .SS Killing and Yanking
5532 .B kill\-line (C\-k)
5533 Kill the text from point to the end of the line.
5535 .B backward\-kill\-line (C\-x Rubout)
5536 Kill backward to the beginning of the line.
5538 .B unix\-line\-discard (C\-u)
5539 Kill backward from point to the beginning of the line.
5540 The killed text is saved on the kill-ring.
5541 .\" There is no real difference between this and backward-kill-line
5543 .B kill\-whole\-line
5544 Kill all characters on the current line, no matter where point is.
5546 .B kill\-word (M\-d)
5547 Kill from point to the end of the current word, or if between
5548 words, to the end of the next word.
5549 Word boundaries are the same as those used by \fBforward\-word\fP.
5551 .B backward\-kill\-word (M\-Rubout)
5552 Kill the word behind point.
5553 Word boundaries are the same as those used by \fBbackward\-word\fP.
5555 .B shell\-kill\-word (M\-d)
5556 Kill from point to the end of the current word, or if between
5557 words, to the end of the next word.
5558 Word boundaries are the same as those used by \fBshell\-forward\-word\fP.
5560 .B shell\-backward\-kill\-word (M\-Rubout)
5561 Kill the word behind point.
5562 Word boundaries are the same as those used by \fBshell\-backward\-word\fP.
5564 .B unix\-word\-rubout (C\-w)
5565 Kill the word behind point, using white space as a word boundary.
5566 The killed text is saved on the kill-ring.
5568 .B unix\-filename\-rubout
5569 Kill the word behind point, using white space and the slash character
5570 as the word boundaries.
5571 The killed text is saved on the kill-ring.
5573 .B delete\-horizontal\-space (M\-\e)
5574 Delete all spaces and tabs around point.
5577 Kill the text in the current region.
5579 .B copy\-region\-as\-kill
5580 Copy the text in the region to the kill buffer.
5582 .B copy\-backward\-word
5583 Copy the word before point to the kill buffer.
5584 The word boundaries are the same as \fBbackward\-word\fP.
5586 .B copy\-forward\-word
5587 Copy the word following point to the kill buffer.
5588 The word boundaries are the same as \fBforward\-word\fP.
5591 Yank the top of the kill ring into the buffer at point.
5594 Rotate the kill ring, and yank the new top. Only works following
5599 .SS Numeric Arguments
5603 .B digit\-argument (M\-0, M\-1, ..., M\-\-)
5604 Add this digit to the argument already accumulating, or start a new
5605 argument. M\-\- starts a negative argument.
5607 .B universal\-argument
5608 This is another way to specify an argument.
5609 If this command is followed by one or more digits, optionally with a
5610 leading minus sign, those digits define the argument.
5611 If the command is followed by digits, executing
5612 .B universal\-argument
5613 again ends the numeric argument, but is otherwise ignored.
5614 As a special case, if this command is immediately followed by a
5615 character that is neither a digit or minus sign, the argument count
5616 for the next command is multiplied by four.
5617 The argument count is initially one, so executing this function the
5618 first time makes the argument count four, a second time makes the
5619 argument count sixteen, and so on.
5626 Attempt to perform completion on the text before point.
5628 attempts completion treating the text as a variable (if the
5629 text begins with \fB$\fP), username (if the text begins with
5630 \fB~\fP), hostname (if the text begins with \fB@\fP), or
5631 command (including aliases and functions) in turn. If none
5632 of these produces a match, filename completion is attempted.
5634 .B possible\-completions (M\-?)
5635 List the possible completions of the text before point.
5637 .B insert\-completions (M\-*)
5638 Insert all completions of the text before point
5639 that would have been generated by
5640 \fBpossible\-completions\fP.
5643 Similar to \fBcomplete\fP, but replaces the word to be completed
5644 with a single match from the list of possible completions.
5645 Repeated execution of \fBmenu\-complete\fP steps through the list
5646 of possible completions, inserting each match in turn.
5647 At the end of the list of completions, the bell is rung
5648 (subject to the setting of \fBbell\-style\fP)
5649 and the original text is restored.
5650 An argument of \fIn\fP moves \fIn\fP positions forward in the list
5651 of matches; a negative argument may be used to move backward
5653 This command is intended to be bound to \fBTAB\fP, but is unbound
5656 .B menu\-complete-\backward
5657 Identical to \fBmenu\-complete\fP, but moves backward through the list
5658 of possible completions, as if \fBmenu\-complete\fP had been given a
5659 negative argument. This command is unbound by default.
5661 .B delete\-char\-or\-list
5662 Deletes the character under the cursor if not at the beginning or
5663 end of the line (like \fBdelete\-char\fP).
5664 If at the end of the line, behaves identically to
5665 \fBpossible\-completions\fP.
5666 This command is unbound by default.
5668 .B complete\-filename (M\-/)
5669 Attempt filename completion on the text before point.
5671 .B possible\-filename\-completions (C\-x /)
5672 List the possible completions of the text before point,
5673 treating it as a filename.
5675 .B complete\-username (M\-~)
5676 Attempt completion on the text before point, treating
5679 .B possible\-username\-completions (C\-x ~)
5680 List the possible completions of the text before point,
5681 treating it as a username.
5683 .B complete\-variable (M\-$)
5684 Attempt completion on the text before point, treating
5685 it as a shell variable.
5687 .B possible\-variable\-completions (C\-x $)
5688 List the possible completions of the text before point,
5689 treating it as a shell variable.
5691 .B complete\-hostname (M\-@)
5692 Attempt completion on the text before point, treating
5695 .B possible\-hostname\-completions (C\-x @)
5696 List the possible completions of the text before point,
5697 treating it as a hostname.
5699 .B complete\-command (M\-!)
5700 Attempt completion on the text before point, treating
5701 it as a command name. Command completion attempts to
5702 match the text against aliases, reserved words, shell
5703 functions, shell builtins, and finally executable filenames,
5706 .B possible\-command\-completions (C\-x !)
5707 List the possible completions of the text before point,
5708 treating it as a command name.
5710 .B dynamic\-complete\-history (M\-TAB)
5711 Attempt completion on the text before point, comparing
5712 the text against lines from the history list for possible
5716 Attempt menu completion on the text before point, comparing
5717 the text against lines from the history list for possible
5720 .B complete\-into\-braces (M\-{)
5721 Perform filename completion and insert the list of possible completions
5722 enclosed within braces so the list is available to the shell (see
5730 .B start\-kbd\-macro (C\-x (\^)
5731 Begin saving the characters typed into the current keyboard macro.
5733 .B end\-kbd\-macro (C\-x )\^)
5734 Stop saving the characters typed into the current keyboard macro
5735 and store the definition.
5737 .B call\-last\-kbd\-macro (C\-x e)
5738 Re-execute the last keyboard macro defined, by making the characters
5739 in the macro appear as if typed at the keyboard.
5745 .B re\-read\-init\-file (C\-x C\-r)
5746 Read in the contents of the \fIinputrc\fP file, and incorporate
5747 any bindings or variable assignments found there.
5750 Abort the current editing command and
5751 ring the terminal's bell (subject to the setting of
5754 .B do\-uppercase\-version (M\-a, M\-b, M\-\fIx\fP, ...)
5755 If the metafied character \fIx\fP is lowercase, run the command
5756 that is bound to the corresponding uppercase character.
5758 .B prefix\-meta (ESC)
5759 Metafy the next character typed.
5766 .B undo (C\-_, C\-x C\-u)
5767 Incremental undo, separately remembered for each line.
5769 .B revert\-line (M\-r)
5770 Undo all changes made to this line. This is like executing the
5772 command enough times to return the line to its initial state.
5774 .B tilde\-expand (M\-&)
5775 Perform tilde expansion on the current word.
5777 .B set\-mark (C\-@, M\-<space>)
5778 Set the mark to the point. If a
5779 numeric argument is supplied, the mark is set to that position.
5781 .B exchange\-point\-and\-mark (C\-x C\-x)
5782 Swap the point with the mark. The current cursor position is set to
5783 the saved position, and the old cursor position is saved as the mark.
5785 .B character\-search (C\-])
5786 A character is read and point is moved to the next occurrence of that
5787 character. A negative count searches for previous occurrences.
5789 .B character\-search\-backward (M\-C\-])
5790 A character is read and point is moved to the previous occurrence of that
5791 character. A negative count searches for subsequent occurrences.
5793 .B skip\-csi\-sequence ()
5794 Read enough characters to consume a multi-key sequence such as those
5795 defined for keys like Home and End. Such sequences begin with a
5796 Control Sequence Indicator (CSI), usually ESC\-[. If this sequence is
5797 bound to "\e[", keys producing such sequences will have no effect
5798 unless explicitly bound to a readline command, instead of inserting
5799 stray characters into the editing buffer. This is unbound by default,
5800 but usually bound to ESC\-[.
5802 .B insert\-comment (M\-#)
5803 Without a numeric argument, the value of the readline
5805 variable is inserted at the beginning of the current line.
5806 If a numeric argument is supplied, this command acts as a toggle: if
5807 the characters at the beginning of the line do not match the value
5808 of \fBcomment\-begin\fP, the value is inserted, otherwise
5809 the characters in \fBcomment\-begin\fP are deleted from the beginning of
5811 In either case, the line is accepted as if a newline had been typed.
5812 The default value of
5813 \fBcomment\-begin\fP causes this command to make the current line
5815 If a numeric argument causes the comment character to be removed, the line
5816 will be executed by the shell.
5818 .B glob\-complete\-word (M\-g)
5819 The word before point is treated as a pattern for pathname expansion,
5820 with an asterisk implicitly appended. This pattern is used to
5821 generate a list of matching file names for possible completions.
5823 .B glob\-expand\-word (C\-x *)
5824 The word before point is treated as a pattern for pathname expansion,
5825 and the list of matching file names is inserted, replacing the word.
5826 If a numeric argument is supplied, an asterisk is appended before
5829 .B glob\-list\-expansions (C\-x g)
5830 The list of expansions that would have been generated by
5831 .B glob\-expand\-word
5832 is displayed, and the line is redrawn.
5833 If a numeric argument is supplied, an asterisk is appended before
5837 Print all of the functions and their key bindings to the
5838 readline output stream. If a numeric argument is supplied,
5839 the output is formatted in such a way that it can be made part
5840 of an \fIinputrc\fP file.
5843 Print all of the settable readline variables and their values to the
5844 readline output stream. If a numeric argument is supplied,
5845 the output is formatted in such a way that it can be made part
5846 of an \fIinputrc\fP file.
5849 Print all of the readline key sequences bound to macros and the
5850 strings they output. If a numeric argument is supplied,
5851 the output is formatted in such a way that it can be made part
5852 of an \fIinputrc\fP file.
5854 .B display\-shell\-version (C\-x C\-v)
5855 Display version information about the current instance of
5858 .SS Programmable Completion
5860 When word completion is attempted for an argument to a command for
5861 which a completion specification (a \fIcompspec\fP) has been defined
5862 using the \fBcomplete\fP builtin (see
5864 .B "SHELL BUILTIN COMMANDS"
5865 below), the programmable completion facilities are invoked.
5867 First, the command name is identified.
5868 If the command word is the empty string (completion attempted at the
5869 beginning of an empty line), any compspec defined with
5870 the \fB\-E\fP option to \fBcomplete\fP is used.
5871 If a compspec has been defined for that command, the
5872 compspec is used to generate the list of possible completions for the word.
5873 If the command word is a full pathname, a compspec for the full
5874 pathname is searched for first.
5875 If no compspec is found for the full pathname, an attempt is made to
5876 find a compspec for the portion following the final slash.
5877 If those searches to not result in a compspec, any compspec defined with
5878 the \fB\-D\fP option to \fBcomplete\fP is used as the default.
5880 Once a compspec has been found, it is used to generate the list of
5882 If a compspec is not found, the default \fBbash\fP completion as
5883 described above under \fBCompleting\fP is performed.
5885 First, the actions specified by the compspec are used.
5886 Only matches which are prefixed by the word being completed are
5892 option is used for filename or directory name completion, the shell
5896 is used to filter the matches.
5898 Any completions specified by a pathname expansion pattern to the
5899 \fB\-G\fP option are generated next.
5900 The words generated by the pattern need not match the word
5905 shell variable is not used to filter the matches, but the
5910 Next, the string specified as the argument to the \fB\-W\fP option
5912 The string is first split using the characters in the
5915 special variable as delimiters.
5916 Shell quoting is honored.
5917 Each word is then expanded using
5918 brace expansion, tilde expansion, parameter and variable expansion,
5919 command substitution, and arithmetic expansion,
5920 as described above under
5923 The results are split using the rules described above under
5924 \fBWord Splitting\fP.
5925 The results of the expansion are prefix-matched against the word being
5926 completed, and the matching words become the possible completions.
5928 After these matches have been generated, any shell function or command
5929 specified with the \fB\-F\fP and \fB\-C\fP options is invoked.
5930 When the command or function is invoked, the
5940 variables are assigned values as described above under
5941 \fBShell Variables\fP.
5942 If a shell function is being invoked, the
5948 variables are also set.
5949 When the function or command is invoked, the first argument is the
5950 name of the command whose arguments are being completed, the
5951 second argument is the word being completed, and the third argument
5952 is the word preceding the word being completed on the current command line.
5953 No filtering of the generated completions against the word being completed
5954 is performed; the function or command has complete freedom in generating
5957 Any function specified with \fB\-F\fP is invoked first.
5958 The function may use any of the shell facilities, including the
5959 \fBcompgen\fP builtin described below, to generate the matches.
5960 It must put the possible completions in the
5965 Next, any command specified with the \fB\-C\fP option is invoked
5966 in an environment equivalent to command substitution.
5967 It should print a list of completions, one per line, to the
5969 Backslash may be used to escape a newline, if necessary.
5971 After all of the possible completions are generated, any filter
5972 specified with the \fB\-X\fP option is applied to the list.
5973 The filter is a pattern as used for pathname expansion; a \fB&\fP
5974 in the pattern is replaced with the text of the word being completed.
5975 A literal \fB&\fP may be escaped with a backslash; the backslash
5976 is removed before attempting a match.
5977 Any completion that matches the pattern will be removed from the list.
5978 A leading \fB!\fP negates the pattern; in this case any completion
5979 not matching the pattern will be removed.
5981 Finally, any prefix and suffix specified with the \fB\-P\fP and \fB\-S\fP
5982 options are added to each member of the completion list, and the result is
5983 returned to the readline completion code as the list of possible
5986 If the previously-applied actions do not generate any matches, and the
5987 \fB\-o dirnames\fP option was supplied to \fBcomplete\fP when the
5988 compspec was defined, directory name completion is attempted.
5990 If the \fB\-o plusdirs\fP option was supplied to \fBcomplete\fP when the
5991 compspec was defined, directory name completion is attempted and any
5992 matches are added to the results of the other actions.
5994 By default, if a compspec is found, whatever it generates is returned
5995 to the completion code as the full set of possible completions.
5996 The default \fBbash\fP completions are not attempted, and the readline
5997 default of filename completion is disabled.
5998 If the \fB\-o bashdefault\fP option was supplied to \fBcomplete\fP when
5999 the compspec was defined, the \fBbash\fP default completions are attempted
6000 if the compspec generates no matches.
6001 If the \fB\-o default\fP option was supplied to \fBcomplete\fP when the
6002 compspec was defined, readline's default completion will be performed
6003 if the compspec (and, if attempted, the default \fBbash\fP completions)
6004 generate no matches.
6006 When a compspec indicates that directory name completion is desired,
6007 the programmable completion functions force readline to append a slash
6008 to completed names which are symbolic links to directories, subject to
6009 the value of the \fBmark\-directories\fP readline variable, regardless
6010 of the setting of the \fBmark-symlinked\-directories\fP readline variable.
6012 There is some support for dynamically modifying completions. This is
6013 most useful when used in combination with a default completion specified
6014 with \fBcomplete -D\fP.
6015 It's possible for shell functions executed as completion
6016 handlers to indicate that completion should be retried by returning an
6017 exit status of 124. If a shell function returns 124, and changes
6018 the compspec associated with the command on which completion is being
6019 attempted (supplied as the first argument when the function is executed),
6020 programmable completion restarts from the beginning, with an
6021 attempt to find a compspec for that command. This allows a set of
6022 completions to be built dynamically as completion is attempted, rather than
6023 being loaded all at once.
6025 For instance, assuming that there is a library of compspecs, each kept in a
6026 file corresponding to the name of the command, the following default
6027 completion function would load completions dynamically:
6029 \f(CW_completion_loader()
6033 . "/etc/bash_completion.d/$1.sh" >/dev/null 2>&1 && return 124
6037 complete -D -F _completion_loader
6045 builtin is enabled, the shell provides access to the
6046 \fIcommand history\fP,
6047 the list of commands previously typed.
6051 variable is used as the
6052 number of commands to save in a history list.
6053 The text of the last
6056 commands (default 500) is saved. The shell
6057 stores each command in the history list prior to parameter and
6058 variable expansion (see
6061 above) but after history expansion is performed, subject to the
6062 values of the shell variables
6069 On startup, the history is initialized from the file named by
6073 (default \fI~/.bash_history\fP).
6074 The file named by the value of
6077 is truncated, if necessary, to contain no more than
6078 the number of lines specified by the value of
6081 When the history file is read,
6082 lines beginning with the history comment character followed immediately
6083 by a digit are interpreted as timestamps for the preceding history line.
6084 These timestamps are optionally displayed depending on the value of the
6088 When an interactive shell exits, the last
6091 lines are copied from the history list to
6096 shell option is enabled
6097 (see the description of
6101 .B "SHELL BUILTIN COMMANDS"
6102 below), the lines are appended to the history file,
6103 otherwise the history file is overwritten.
6107 is unset, or if the history file is unwritable, the history is
6112 variable is set, time stamps are written to the history file, marked
6113 with the history comment character, so
6114 they may be preserved across shell sessions.
6115 This uses the history comment character to distinguish timestamps from
6116 other history lines.
6117 After saving the history, the history file is truncated
6118 to contain no more than
6124 is not set, no truncation is performed.
6130 .B SHELL BUILTIN COMMANDS
6131 below) may be used to list or edit and re-execute a portion of
6135 builtin may be used to display or modify the history list and
6136 manipulate the history file.
6137 When using command-line editing, search commands
6138 are available in each editing mode that provide access to the
6141 The shell allows control over which commands are saved on the history
6148 variables may be set to cause the shell to save only a subset of the
6152 shell option, if enabled, causes the shell to attempt to save each
6153 line of a multi-line command in the same history entry, adding
6154 semicolons where necessary to preserve syntactic correctness.
6157 shell option causes the shell to save the command with embedded newlines
6158 instead of semicolons. See the description of the
6162 .B "SHELL BUILTIN COMMANDS"
6163 for information on setting and unsetting shell options.
6164 .SH "HISTORY EXPANSION"
6166 The shell supports a history expansion feature that
6167 is similar to the history expansion in
6169 This section describes what syntax features are available. This
6170 feature is enabled by default for interactive shells, and can be
6175 builtin command (see
6177 .B SHELL BUILTIN COMMANDS
6178 below). Non-interactive shells do not perform history expansion
6181 History expansions introduce words from the history list into
6182 the input stream, making it easy to repeat commands, insert the
6183 arguments to a previous command into the current input line, or
6184 fix errors in previous commands quickly.
6186 History expansion is performed immediately after a complete line
6187 is read, before the shell breaks it into words.
6188 It takes place in two parts.
6189 The first is to determine which line from the history list
6190 to use during substitution.
6191 The second is to select portions of that line for inclusion into
6193 The line selected from the history is the \fIevent\fP,
6194 and the portions of that line that are acted upon are \fIwords\fP.
6195 Various \fImodifiers\fP are available to manipulate the selected words.
6196 The line is broken into words in the same fashion as when reading input,
6197 so that several \fImetacharacter\fP-separated words surrounded by
6198 quotes are considered one word.
6199 History expansions are introduced by the appearance of the
6200 history expansion character, which is \^\fB!\fP\^ by default.
6201 Only backslash (\^\fB\e\fP\^) and single quotes can quote
6202 the history expansion character.
6204 Several characters inhibit history expansion if found immediately
6205 following the history expansion character, even if it is unquoted:
6206 space, tab, newline, carriage return, and \fB=\fP.
6207 If the \fBextglob\fP shell option is enabled, \fB(\fP will also
6210 Several shell options settable with the
6212 builtin may be used to tailor the behavior of history expansion.
6215 shell option is enabled (see the description of the
6219 is being used, history substitutions are not immediately passed to
6221 Instead, the expanded line is reloaded into the
6223 editing buffer for further modification.
6226 is being used, and the
6228 shell option is enabled, a failed history substitution will be reloaded
6231 editing buffer for correction.
6236 builtin command may be used to see what a history expansion will
6242 builtin may be used to add commands to the end of the history list
6243 without actually executing them, so that they are available for
6246 The shell allows control of the various characters used by the
6247 history expansion mechanism (see the description of
6250 .BR "Shell Variables" ).
6252 the history comment character to mark history timestamps when
6253 writing the history file.
6254 .SS Event Designators
6256 An event designator is a reference to a command line entry in the
6262 Start a history substitution, except when followed by a
6264 newline, carriage return, =
6265 or ( (when the \fBextglob\fP shell option is enabled using
6266 the \fBshopt\fP builtin).
6269 Refer to command line
6273 Refer to the current command line minus
6277 Refer to the previous command. This is a synonym for `!\-1'.
6280 Refer to the most recent command starting with
6283 .B !?\fIstring\fR\fB[?]\fR
6284 Refer to the most recent command containing
6286 The trailing \fB?\fP may be omitted if
6288 is followed immediately by a newline.
6290 .B \d\s+2^\s-2\u\fIstring1\fP\d\s+2^\s-2\u\fIstring2\fP\d\s+2^\s-2\u
6291 Quick substitution. Repeat the last command, replacing
6296 ``!!:s/\fIstring1\fP/\fIstring2\fP/''
6297 (see \fBModifiers\fP below).
6300 The entire command line typed so far.
6302 .SS Word Designators
6304 Word designators are used to select desired words from the event.
6307 separates the event specification from the word designator.
6308 It may be omitted if the word designator begins with a
6315 Words are numbered from the beginning of the line,
6316 with the first word being denoted by 0 (zero).
6317 Words are inserted into the current line separated by single spaces.
6322 The zeroth word. For the shell, this is the command
6329 The first argument. That is, word 1.
6335 The word matched by the most recent `?\fIstring\fR?' search.
6338 A range of words; `\-\fIy\fR' abbreviates `0\-\fIy\fR'.
6341 All of the words but the zeroth. This is a synonym
6342 for `\fI1\-$\fP'. It is not an error to use
6344 if there is just one
6345 word in the event; the empty string is returned in that case.
6348 Abbreviates \fIx\-$\fP.
6351 Abbreviates \fIx\-$\fP like \fBx*\fP, but omits the last word.
6354 If a word designator is supplied without an event specification, the
6355 previous command is used as the event.
6358 After the optional word designator, there may appear a sequence of
6359 one or more of the following modifiers, each preceded by a `:'.
6365 Remove a trailing file name component, leaving only the head.
6368 Remove all leading file name components, leaving the tail.
6371 Remove a trailing suffix of the form \fI.xxx\fP, leaving the
6375 Remove all but the trailing suffix.
6378 Print the new command but do not execute it.
6381 Quote the substituted words, escaping further substitutions.
6384 Quote the substituted words as with
6386 but break into words at
6390 .B s/\fIold\fP/\fInew\fP/
6393 for the first occurrence of
6395 in the event line. Any delimiter can be used in place of /. The
6396 final delimiter is optional if it is the last character of the
6397 event line. The delimiter may be quoted in
6401 with a single backslash. If & appears in
6405 A single backslash will quote the &. If
6407 is null, it is set to the last
6409 substituted, or, if no previous history substitutions took place,
6413 .B !?\fIstring\fR\fB[?]\fR
6417 Repeat the previous substitution.
6420 Cause changes to be applied over the entire event line. This is
6421 used in conjunction with `\fB:s\fP' (e.g., `\fB:gs/\fIold\fP/\fInew\fP/\fR')
6422 or `\fB:&\fP'. If used with
6423 `\fB:s\fP', any delimiter can be used
6424 in place of /, and the final delimiter is optional
6425 if it is the last character of the event line.
6426 An \fBa\fP may be used as a synonym for \fBg\fP.
6429 Apply the following `\fBs\fP' modifier once to each word in the event line.
6431 .SH "SHELL BUILTIN COMMANDS"
6432 .\" start of bash_builtins
6435 Unless otherwise noted, each builtin command documented in this
6436 section as accepting options preceded by
6440 to signify the end of the options.
6441 The \fB:\fP, \fBtrue\fP, \fBfalse\fP, and \fBtest\fP builtins
6442 do not accept options and do not treat \fB\-\-\fP specially.
6443 The \fBexit\fP, \fBlogout\fP, \fBbreak\fP, \fBcontinue\fP, \fBlet\fP,
6444 and \fBshift\fP builtins accept and process arguments beginning with
6445 \fB\-\fP without requiring \fB\-\-\fP.
6446 Other builtins that accept arguments but are not specified as accepting
6447 options interpret arguments beginning with \fB\-\fP as invalid options and
6448 require \fB\-\-\fP to prevent this interpretation.
6452 \fB:\fP [\fIarguments\fP]
6454 No effect; the command does nothing beyond expanding
6456 and performing any specified
6457 redirections. A zero exit code is returned.
6459 \fB .\| \fP \fIfilename\fP [\fIarguments\fP]
6462 \fBsource\fP \fIfilename\fP [\fIarguments\fP]
6464 Read and execute commands from
6467 shell environment and return the exit status of the last command
6472 does not contain a slash, file names in
6475 are used to find the directory containing
6477 The file searched for in
6480 need not be executable.
6481 When \fBbash\fP is not in \fIposix mode\fP, the current directory is
6482 searched if no file is found in
6489 builtin command is turned off, the
6493 If any \fIarguments\fP are supplied, they become the positional
6494 parameters when \fIfilename\fP is executed. Otherwise the positional
6495 parameters are unchanged.
6496 The return status is the status of the last command exited within
6497 the script (0 if no commands are executed), and false if
6499 is not found or cannot be read.
6501 \fBalias\fP [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
6502 \fBAlias\fP with no arguments or with the
6504 option prints the list of aliases in the form
6505 \fBalias\fP \fIname\fP=\fIvalue\fP on standard output.
6506 When arguments are supplied, an alias is defined for
6507 each \fIname\fP whose \fIvalue\fP is given.
6508 A trailing space in \fIvalue\fP causes the next word to be
6509 checked for alias substitution when the alias is expanded.
6510 For each \fIname\fP in the argument list for which no \fIvalue\fP
6511 is supplied, the name and value of the alias is printed.
6512 \fBAlias\fP returns true unless a \fIname\fP is given for which
6513 no alias has been defined.
6515 \fBbg\fP [\fIjobspec\fP ...]
6516 Resume each suspended job \fIjobspec\fP in the background, as if it
6517 had been started with
6521 is not present, the shell's notion of the \fIcurrent job\fP is used.
6524 returns 0 unless run when job control is disabled or, when run with
6525 job control enabled, any specified \fIjobspec\fP was not found
6526 or was started without job control.
6528 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-lpsvPSV\fP]
6531 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-q\fP \fIfunction\fP] [\fB\-u\fP \fIfunction\fP] [\fB\-r\fP \fIkeyseq\fP]
6533 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-f\fP \fIfilename\fP
6535 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-x\fP \fIkeyseq\fP:\fIshell\-command\fP
6537 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fIkeyseq\fP:\fIfunction\-name\fP
6539 \fBbind\fP \fIreadline\-command\fP
6543 key and function bindings, bind a key sequence to a
6545 function or macro, or set a
6548 Each non-option argument is a command as it would appear in
6550 but each binding or command must be passed as a separate argument;
6551 e.g., '"\eC\-x\eC\-r": re\-read\-init\-file'.
6552 Options, if supplied, have the following meanings:
6559 as the keymap to be affected by the subsequent bindings.
6563 \fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi,
6564 vi\-move, vi\-command\fP, and
6566 \fIvi\fP is equivalent to \fIvi\-command\fP; \fIemacs\fP is
6567 equivalent to \fIemacs\-standard\fP.
6570 List the names of all \fBreadline\fP functions.
6573 Display \fBreadline\fP function names and bindings in such a way
6574 that they can be re-read.
6577 List current \fBreadline\fP function names and bindings.
6580 Display \fBreadline\fP key sequences bound to macros and the strings
6581 they output in such a way that they can be re-read.
6584 Display \fBreadline\fP key sequences bound to macros and the strings
6588 Display \fBreadline\fP variable names and values in such a way that they
6592 List current \fBreadline\fP variable names and values.
6594 .B \-f \fIfilename\fP
6595 Read key bindings from \fIfilename\fP.
6597 .B \-q \fIfunction\fP
6598 Query about which keys invoke the named \fIfunction\fP.
6600 .B \-u \fIfunction\fP
6601 Unbind all keys bound to the named \fIfunction\fP.
6604 Remove any current binding for \fIkeyseq\fP.
6606 .B \-x \fIkeyseq\fP:\fIshell\-command\fP
6607 Cause \fIshell\-command\fP to be executed whenever \fIkeyseq\fP is
6609 When \fIshell\-command\fP is executed, the shell sets the
6612 variable to the contents of the \fBreadline\fP line buffer and the
6615 variable to the current location of the insertion point.
6616 If the executed command changes the value of
6621 .BR READLINE_POINT ,
6622 those new values will be reflected in the editing state.
6625 The return value is 0 unless an unrecognized option is given or an
6629 \fBbreak\fP [\fIn\fP]
6636 loop. If \fIn\fP is specified, break \fIn\fP levels.
6640 is greater than the number of enclosing loops, all enclosing loops
6642 The return value is 0 unless \fIn\fP is not greater than or equal to 1.
6644 \fBbuiltin\fP \fIshell\-builtin\fP [\fIarguments\fP]
6645 Execute the specified shell builtin, passing it
6647 and return its exit status.
6648 This is useful when defining a
6649 function whose name is the same as a shell builtin,
6650 retaining the functionality of the builtin within the function.
6651 The \fBcd\fP builtin is commonly redefined this way.
6652 The return status is false if
6654 is not a shell builtin command.
6656 \fBcaller\fP [\fIexpr\fP]
6657 Returns the context of any active subroutine call (a shell function or
6658 a script executed with the \fB.\fP or \fBsource\fP builtins.
6659 Without \fIexpr\fP, \fBcaller\fP displays the line number and source
6660 filename of the current subroutine call.
6661 If a non-negative integer is supplied as \fIexpr\fP, \fBcaller\fP
6662 displays the line number, subroutine name, and source file corresponding
6663 to that position in the current execution call stack. This extra
6664 information may be used, for example, to print a stack trace. The
6665 current frame is frame 0.
6666 The return value is 0 unless the shell is not executing a subroutine
6667 call or \fIexpr\fP does not correspond to a valid position in the
6670 \fBcd\fP [\fB\-L|-P\fP] [\fIdir\fP]
6671 Change the current directory to \fIdir\fP. The variable
6680 defines the search path for the directory containing
6682 Alternative directory names in
6685 are separated by a colon (:). A null directory name in
6688 is the same as the current directory, i.e., ``\fB.\fP''. If
6690 begins with a slash (/),
6696 option says to use the physical directory structure instead of
6697 following symbolic links (see also the
6701 builtin command); the
6703 option forces symbolic links to be followed. An argument of
6708 If a non-empty directory name from
6712 \fB\-\fP is the first argument, and the directory change is
6713 successful, the absolute pathname of the new working directory is
6714 written to the standard output.
6715 The return value is true if the directory was successfully changed;
6718 \fBcommand\fP [\fB\-pVv\fP] \fIcommand\fP [\fIarg\fP ...]
6723 suppressing the normal shell function lookup. Only builtin
6724 commands or commands found in the
6727 are executed. If the
6729 option is given, the search for
6731 is performed using a default value for
6734 that is guaranteed to find all of the standard utilities.
6739 option is supplied, a description of
6743 option causes a single word indicating the command or file name
6746 to be displayed; the
6748 option produces a more verbose description.
6753 option is supplied, the exit status is 0 if
6755 was found, and 1 if not. If neither option is supplied and
6756 an error occurred or
6758 cannot be found, the exit status is 127. Otherwise, the exit status of the
6760 builtin is the exit status of
6763 \fBcompgen\fP [\fIoption\fP] [\fIword\fP]
6764 Generate possible completion matches for \fIword\fP according to
6765 the \fIoption\fPs, which may be any option accepted by the
6767 builtin with the exception of \fB\-p\fP and \fB\-r\fP, and write
6768 the matches to the standard output.
6769 When using the \fB\-F\fP or \fB\-C\fP options, the various shell variables
6770 set by the programmable completion facilities, while available, will not
6773 The matches will be generated in the same way as if the programmable
6774 completion code had generated them directly from a completion specification
6775 with the same flags.
6776 If \fIword\fP is specified, only those completions matching \fIword\fP
6779 The return value is true unless an invalid option is supplied, or no
6780 matches were generated.
6782 \fBcomplete\fP [\fB\-abcdefgjksuv\fP] [\fB\-o\fP \fIcomp-option\fP] [\fB\-DE\fP] [\fB\-A\fP \fIaction\fP] [\fB\-G\fP \fIglobpat\fP] [\fB\-W\fP \fIwordlist\fP] [\fB\-F\fP \fIfunction\fP] [\fB\-C\fP \fIcommand\fP]
6784 [\fB\-X\fP \fIfilterpat\fP] [\fB\-P\fP \fIprefix\fP] [\fB\-S\fP \fIsuffix\fP] \fIname\fP [\fIname ...\fP]
6787 \fBcomplete\fP \fB\-pr\fP [\fB\-DE\fP] [\fIname\fP ...]
6789 Specify how arguments to each \fIname\fP should be completed.
6790 If the \fB\-p\fP option is supplied, or if no options are supplied,
6791 existing completion specifications are printed in a way that allows
6792 them to be reused as input.
6793 The \fB\-r\fP option removes a completion specification for
6794 each \fIname\fP, or, if no \fIname\fPs are supplied, all
6795 completion specifications.
6796 The \fB\-D\fP option indicates that the remaining options and actions should
6797 apply to the ``default'' command completion; that is, completion attempted
6798 on a command for which no completion has previously been defined.
6799 The \fB\-E\fP option indicates that the remaining options and actions should
6800 apply to ``empty'' command completion; that is, completion attempted on a
6803 The process of applying these completion specifications when word completion
6804 is attempted is described above under \fBProgrammable Completion\fP.
6806 Other options, if specified, have the following meanings.
6807 The arguments to the \fB\-G\fP, \fB\-W\fP, and \fB\-X\fP options
6808 (and, if necessary, the \fB\-P\fP and \fB\-S\fP options)
6809 should be quoted to protect them from expansion before the
6815 \fB\-o\fP \fIcomp-option\fP
6816 The \fIcomp-option\fP controls several aspects of the compspec's behavior
6817 beyond the simple generation of completions.
6818 \fIcomp-option\fP may be one of:
6822 Perform the rest of the default \fBbash\fP completions if the compspec
6823 generates no matches.
6826 Use readline's default filename completion if the compspec generates
6830 Perform directory name completion if the compspec generates no matches.
6833 Tell readline that the compspec generates filenames, so it can perform any
6834 filename\-specific processing (like adding a slash to directory names,
6835 quoting special characters, or suppressing trailing spaces).
6836 Intended to be used with shell functions.
6839 Tell readline not to append a space (the default) to words completed at
6840 the end of the line.
6843 After any matches defined by the compspec are generated,
6844 directory name completion is attempted and any
6845 matches are added to the results of the other actions.
6848 \fB\-A\fP \fIaction\fP
6849 The \fIaction\fP may be one of the following to generate a list of possible
6854 Alias names. May also be specified as \fB\-a\fP.
6857 Array variable names.
6860 \fBReadline\fP key binding names.
6863 Names of shell builtin commands. May also be specified as \fB\-b\fP.
6866 Command names. May also be specified as \fB\-c\fP.
6869 Directory names. May also be specified as \fB\-d\fP.
6872 Names of disabled shell builtins.
6875 Names of enabled shell builtins.
6878 Names of exported shell variables. May also be specified as \fB\-e\fP.
6881 File names. May also be specified as \fB\-f\fP.
6884 Names of shell functions.
6887 Group names. May also be specified as \fB\-g\fP.
6890 Help topics as accepted by the \fBhelp\fP builtin.
6893 Hostnames, as taken from the file specified by the
6899 Job names, if job control is active. May also be specified as \fB\-j\fP.
6902 Shell reserved words. May also be specified as \fB\-k\fP.
6905 Names of running jobs, if job control is active.
6908 Service names. May also be specified as \fB\-s\fP.
6911 Valid arguments for the \fB\-o\fP option to the \fBset\fP builtin.
6914 Shell option names as accepted by the \fBshopt\fP builtin.
6920 Names of stopped jobs, if job control is active.
6923 User names. May also be specified as \fB\-u\fP.
6926 Names of all shell variables. May also be specified as \fB\-v\fP.
6929 \fB\-G\fP \fIglobpat\fP
6930 The pathname expansion pattern \fIglobpat\fP is expanded to generate
6931 the possible completions.
6933 \fB\-W\fP \fIwordlist\fP
6934 The \fIwordlist\fP is split using the characters in the
6937 special variable as delimiters, and each resultant word is expanded.
6938 The possible completions are the members of the resultant list which
6939 match the word being completed.
6941 \fB\-C\fP \fIcommand\fP
6942 \fIcommand\fP is executed in a subshell environment, and its output is
6943 used as the possible completions.
6945 \fB\-F\fP \fIfunction\fP
6946 The shell function \fIfunction\fP is executed in the current shell
6948 When it finishes, the possible completions are retrieved from the value
6954 \fB\-X\fP \fIfilterpat\fP
6955 \fIfilterpat\fP is a pattern as used for pathname expansion.
6956 It is applied to the list of possible completions generated by the
6957 preceding options and arguments, and each completion matching
6958 \fIfilterpat\fP is removed from the list.
6959 A leading \fB!\fP in \fIfilterpat\fP negates the pattern; in this
6960 case, any completion not matching \fIfilterpat\fP is removed.
6962 \fB\-P\fP \fIprefix\fP
6963 \fIprefix\fP is added at the beginning of each possible completion
6964 after all other options have been applied.
6966 \fB\-S\fP \fIsuffix\fP
6967 \fIsuffix\fP is appended to each possible completion
6968 after all other options have been applied.
6971 The return value is true unless an invalid option is supplied, an option
6972 other than \fB\-p\fP or \fB\-r\fP is supplied without a \fIname\fP
6973 argument, an attempt is made to remove a completion specification for
6974 a \fIname\fP for which no specification exists, or
6975 an error occurs adding a completion specification.
6978 \fBcompopt\fP [\fB\-o\fP \fIoption\fP] [\fB\-DE\fP] [\fB+o\fP \fIoption\fP] [\fIname\fP]
6979 Modify completion options for each \fIname\fP according to the
6980 \fIoption\fPs, or for the
6981 currently-execution completion if no \fIname\fPs are supplied.
6982 If no \fIoption\fPs are given, display the completion options for each
6983 \fIname\fP or the current completion.
6984 The possible values of \fIoption\fP are those valid for the \fBcomplete\fP
6985 builtin described above.
6986 The \fB\-D\fP option indicates that the remaining options should
6987 apply to the ``default'' command completion; that is, completion attempted
6988 on a command for which no completion has previously been defined.
6989 The \fB\-E\fP option indicates that the remaining options should
6990 apply to ``empty'' command completion; that is, completion attempted on a
6993 The return value is true unless an invalid option is supplied, an attempt
6994 is made to modify the options for a \fIname\fP for which no completion
6995 specification exists, or an output error occurs.
6997 \fBcontinue\fP [\fIn\fP]
6998 Resume the next iteration of the enclosing
7007 is specified, resume at the \fIn\fPth enclosing loop.
7011 is greater than the number of enclosing loops, the last enclosing loop
7012 (the ``top-level'' loop) is resumed.
7013 The return value is 0 unless \fIn\fP is not greater than or equal to 1.
7015 \fBdeclare\fP [\fB\-aAfFilrtux\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
7018 \fBtypeset\fP [\fB\-aAfFilrtux\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
7020 Declare variables and/or give them attributes.
7021 If no \fIname\fPs are given then display the values of variables.
7024 option will display the attributes and values of each
7028 is used with \fIname\fP arguments, additional options are ignored.
7031 is supplied without \fIname\fP arguments, it will display the attributes
7032 and values of all variables having the attributes specified by the
7034 If no other options are supplied with \fB\-p\fP, \fBdeclare\fP will display
7035 the attributes and values of all shell variables. The \fB\-f\fP option
7036 will restrict the display to shell functions.
7039 option inhibits the display of function definitions; only the
7040 function name and attributes are printed.
7041 If the \fBextdebug\fP shell option is enabled using \fBshopt\fP,
7042 the source file name and line number where the function is defined
7043 are displayed as well. The
7047 The following options can
7048 be used to restrict output to variables with the specified attribute or
7049 to give variables attributes:
7054 Each \fIname\fP is an indexed array variable (see
7059 Each \fIname\fP is an associative array variable (see
7064 Use function names only.
7067 The variable is treated as an integer; arithmetic evaluation (see
7069 .B "ARITHMETIC EVALUATION"
7070 above) is performed when the variable is assigned a value.
7073 When the variable is assigned a value, all upper-case characters are
7074 converted to lower-case.
7075 The upper-case attribute is disabled.
7078 Make \fIname\fPs readonly. These names cannot then be assigned values
7079 by subsequent assignment statements or unset.
7082 Give each \fIname\fP the \fItrace\fP attribute.
7083 Traced functions inherit the \fBDEBUG\fP and \fBRETURN\fP traps from
7085 The trace attribute has no special meaning for variables.
7088 When the variable is assigned a value, all lower-case characters are
7089 converted to upper-case.
7090 The lower-case attribute is disabled.
7093 Mark \fIname\fPs for export to subsequent commands via the environment.
7096 Using `+' instead of `\-'
7097 turns off the attribute instead,
7098 with the exceptions that \fB+a\fP
7099 may not be used to destroy an array variable and \fB+r\fP will not
7100 remove the readonly attribute.
7101 When used in a function,
7103 \fIname\fP local, as with the
7106 If a variable name is followed by =\fIvalue\fP, the value of
7107 the variable is set to \fIvalue\fP.
7108 The return value is 0 unless an invalid option is encountered,
7109 an attempt is made to define a function using
7110 .if n ``\-f foo=bar'',
7111 .if t \f(CW\-f foo=bar\fP,
7112 an attempt is made to assign a value to a readonly variable,
7113 an attempt is made to assign a value to an array variable without
7114 using the compound assignment syntax (see
7116 above), one of the \fInames\fP is not a valid shell variable name,
7117 an attempt is made to turn off readonly status for a readonly variable,
7118 an attempt is made to turn off array status for an array variable,
7119 or an attempt is made to display a non-existent function with \fB\-f\fP.
7122 .B dirs [+\fIn\fP] [\-\fIn\fP] [\fB\-cplv\fP]
7123 Without options, displays the list of currently remembered directories.
7124 The default display is on a single line with directory names separated
7126 Directories are added to the list with the
7130 command removes entries from the list.
7135 Displays the \fIn\fPth entry counting from the left of the list
7138 when invoked without options, starting with zero.
7141 Displays the \fIn\fPth entry counting from the right of the list
7144 when invoked without options, starting with zero.
7147 Clears the directory stack by deleting all of the entries.
7150 Produces a longer listing; the default listing format uses a
7151 tilde to denote the home directory.
7154 Print the directory stack with one entry per line.
7157 Print the directory stack with one entry per line,
7158 prefixing each entry with its index in the stack.
7161 The return value is 0 unless an
7162 invalid option is supplied or \fIn\fP indexes beyond the end
7163 of the directory stack.
7166 \fBdisown\fP [\fB\-ar\fP] [\fB\-h\fP] [\fIjobspec\fP ...]
7167 Without options, each
7169 is removed from the table of active jobs.
7172 is not present, and neither \fB\-a\fP nor \fB\-r\fP is supplied,
7173 the shell's notion of the \fIcurrent job\fP is used.
7174 If the \fB\-h\fP option is given, each
7176 is not removed from the table, but is marked so that
7179 is not sent to the job if the shell receives a
7184 is present, and neither the
7188 option is supplied, the \fIcurrent job\fP is used.
7193 option means to remove or mark all jobs; the
7197 argument restricts operation to running jobs.
7198 The return value is 0 unless a
7200 does not specify a valid job.
7202 \fBecho\fP [\fB\-neE\fP] [\fIarg\fP ...]
7203 Output the \fIarg\fPs, separated by spaces, followed by a newline.
7204 The return status is always 0.
7205 If \fB\-n\fP is specified, the trailing newline is
7206 suppressed. If the \fB\-e\fP option is given, interpretation of
7207 the following backslash-escaped characters is enabled. The
7209 option disables the interpretation of these escape characters,
7210 even on systems where they are interpreted by default.
7211 The \fBxpg_echo\fP shell option may be used to
7212 dynamically determine whether or not \fBecho\fP expands these
7213 escape characters by default.
7215 does not interpret \fB\-\-\fP to mean the end of options.
7217 interprets the following escape sequences:
7228 suppress further output
7252 the eight-bit character whose value is the octal value \fInnn\fP
7253 (zero to three octal digits)
7256 the eight-bit character whose value is the hexadecimal value \fIHH\fP
7257 (one or two hex digits)
7261 \fBenable\fP [\fB\-a\fP] [\fB\-dnps\fP] [\fB\-f\fP \fIfilename\fP] [\fIname\fP ...]
7262 Enable and disable builtin shell commands.
7263 Disabling a builtin allows a disk command which has the same name
7264 as a shell builtin to be executed without specifying a full pathname,
7265 even though the shell normally searches for builtins before disk commands.
7266 If \fB\-n\fP is used, each \fIname\fP
7267 is disabled; otherwise,
7268 \fInames\fP are enabled. For example, to use the
7270 binary found via the
7273 instead of the shell builtin version, run
7274 .if t \f(CWenable -n test\fP.
7275 .if n ``enable -n test''.
7278 option means to load the new builtin command
7282 on systems that support dynamic loading. The
7284 option will delete a builtin previously loaded with
7286 If no \fIname\fP arguments are given, or if the
7288 option is supplied, a list of shell builtins is printed.
7289 With no other option arguments, the list consists of all enabled
7291 If \fB\-n\fP is supplied, only disabled builtins are printed.
7292 If \fB\-a\fP is supplied, the list printed includes all builtins, with an
7293 indication of whether or not each is enabled.
7294 If \fB\-s\fP is supplied, the output is restricted to the POSIX
7295 \fIspecial\fP builtins.
7296 The return value is 0 unless a
7298 is not a shell builtin or there is an error loading a new builtin
7299 from a shared object.
7301 \fBeval\fP [\fIarg\fP ...]
7302 The \fIarg\fPs are read and concatenated together into a single
7303 command. This command is then read and executed by the shell, and
7304 its exit status is returned as the value of
7308 or only null arguments,
7312 \fBexec\fP [\fB\-cl\fP] [\fB\-a\fP \fIname\fP] [\fIcommand\fP [\fIarguments\fP]]
7315 is specified, it replaces the shell.
7316 No new process is created. The
7318 become the arguments to \fIcommand\fP.
7322 the shell places a dash at the beginning of the zeroth argument passed to
7330 to be executed with an empty environment. If
7332 is supplied, the shell passes
7334 as the zeroth argument to the executed command. If
7336 cannot be executed for some reason, a non-interactive shell exits,
7337 unless the shell option
7339 is enabled, in which case it returns failure.
7340 An interactive shell returns failure if the file cannot be executed.
7343 is not specified, any redirections take effect in the current shell,
7344 and the return status is 0. If there is a redirection error, the
7347 \fBexit\fP [\fIn\fP]
7348 Cause the shell to exit
7349 with a status of \fIn\fP. If
7351 is omitted, the exit status
7352 is that of the last command executed.
7356 is executed before the shell terminates.
7358 \fBexport\fP [\fB\-fn\fP\^] [\fIname\fP[=\fIword\fP]] ...
7365 are marked for automatic export to the environment of
7366 subsequently executed commands. If the
7374 are given, or if the
7376 option is supplied, a list
7377 of all names that are exported in this shell is printed.
7380 option causes the export property to be removed from each
7382 If a variable name is followed by =\fIword\fP, the value of
7383 the variable is set to \fIword\fP.
7385 returns an exit status of 0 unless an invalid option is
7387 one of the \fInames\fP is not a valid shell variable name, or
7391 that is not a function.
7393 \fBfc\fP [\fB\-e\fP \fIename\fP] [\fB\-lnr\fP] [\fIfirst\fP] [\fIlast\fP]
7396 \fBfc\fP \fB\-s\fP [\fIpat\fP=\fIrep\fP] [\fIcmd\fP]
7398 Fix Command. In the first form, a range of commands from
7402 is selected from the history list.
7406 may be specified as a string (to locate the last command beginning
7407 with that string) or as a number (an index into the history list,
7408 where a negative number is used as an offset from the current
7411 is not specified it is set to
7412 the current command for listing (so that
7413 .if n ``fc \-l \-10''
7414 .if t \f(CWfc \-l \-10\fP
7415 prints the last 10 commands) and to
7420 is not specified it is set to the previous
7421 command for editing and \-16 for listing.
7426 the command numbers when listing. The
7428 option reverses the order of
7429 the commands. If the
7432 the commands are listed on
7433 standard output. Otherwise, the editor given by
7436 on a file containing those commands. If
7442 variable is used, and
7449 is not set. If neither variable is set,
7451 is used. When editing is complete, the edited commands are
7452 echoed and executed.
7454 In the second form, \fIcommand\fP is re-executed after each instance
7455 of \fIpat\fP is replaced by \fIrep\fP.
7456 A useful alias to use with this is
7457 .if n ``r="fc -s"'',
7458 .if t \f(CWr='fc \-s'\fP,
7462 runs the last command beginning with
7468 re-executes the last command.
7470 If the first form is used, the return value is 0 unless an invalid
7471 option is encountered or
7475 specify history lines out of range.
7478 option is supplied, the return value is the value of the last
7479 command executed or failure if an error occurs with the temporary
7480 file of commands. If the second form is used, the return status
7481 is that of the command re-executed, unless
7483 does not specify a valid history line, in which case
7487 \fBfg\fP [\fIjobspec\fP]
7490 in the foreground, and make it the current job.
7493 is not present, the shell's notion of the \fIcurrent job\fP is used.
7494 The return value is that of the command placed into the foreground,
7495 or failure if run when job control is disabled or, when run with
7496 job control enabled, if
7498 does not specify a valid job or
7500 specifies a job that was started without job control.
7502 \fBgetopts\fP \fIoptstring\fP \fIname\fP [\fIargs\fP]
7504 is used by shell procedures to parse positional parameters.
7506 contains the option characters to be recognized; if a character
7507 is followed by a colon, the option is expected to have an
7508 argument, which should be separated from it by white space.
7509 The colon and question mark characters may not be used as
7511 Each time it is invoked,
7513 places the next option in the shell variable
7517 if it does not exist,
7518 and the index of the next argument to be processed into the
7524 is initialized to 1 each time the shell or a shell script
7525 is invoked. When an option requires an argument,
7527 places that argument into the variable
7530 The shell does not reset
7533 automatically; it must be manually reset between multiple
7536 within the same shell invocation if a new set of parameters
7539 When the end of options is encountered, \fBgetopts\fP exits with a
7540 return value greater than zero.
7543 is set to the index of the first non-option argument,
7544 and \fBname\fP is set to ?.
7547 normally parses the positional parameters, but if more arguments are
7551 parses those instead.
7554 can report errors in two ways. If the first character of
7558 error reporting is used. In normal operation diagnostic messages
7559 are printed when invalid options or missing option arguments are
7564 is set to 0, no error messages will be displayed, even if the first
7569 If an invalid option is seen,
7574 prints an error message and unsets
7580 the option character found is placed in
7583 and no diagnostic message is printed.
7585 If a required argument is not found, and
7588 a question mark (\^\fB?\fP\^) is placed in
7592 is unset, and a diagnostic message is printed.
7595 is silent, then a colon (\^\fB:\fP\^) is placed in
7600 is set to the option character found.
7603 returns true if an option, specified or unspecified, is found.
7604 It returns false if the end of options is encountered or an
7607 \fBhash\fP [\fB\-lr\fP] [\fB\-p\fP \fIfilename\fP] [\fB\-dt\fP] [\fIname\fP]
7610 the full file name of the command is determined by searching
7616 option is supplied, no path search is performed, and
7618 is used as the full file name of the command.
7621 option causes the shell to forget all
7622 remembered locations.
7625 option causes the shell to forget the remembered location of each \fIname\fP.
7628 option is supplied, the full pathname to which each \fIname\fP corresponds
7629 is printed. If multiple \fIname\fP arguments are supplied with \fB\-t\fP,
7630 the \fIname\fP is printed before the hashed full pathname.
7633 option causes output to be displayed in a format that may be reused as input.
7634 If no arguments are given, or if only \fB\-l\fP is supplied,
7635 information about remembered commands is printed.
7636 The return status is true unless a
7638 is not found or an invalid option is supplied.
7640 \fBhelp\fP [\fB\-dms\fP] [\fIpattern\fP]
7641 Display helpful information about builtin commands. If
7645 gives detailed help on all commands matching
7647 otherwise help for all the builtins and shell control structures
7653 Display a short description of each \fIpattern\fP
7656 Display the description of each \fIpattern\fP in a manpage-like format
7659 Display only a short usage synopsis for each \fIpattern\fP
7662 The return status is 0 unless no command matches
7665 \fBhistory [\fIn\fP]
7668 \fBhistory\fP \fB\-c\fP
7670 \fBhistory \-d\fP \fIoffset\fP
7672 \fBhistory\fP \fB\-anrw\fP [\fIfilename\fP]
7674 \fBhistory\fP \fB\-p\fP \fIarg\fP [\fIarg ...\fP]
7676 \fBhistory\fP \fB\-s\fP \fIarg\fP [\fIarg ...\fP]
7678 With no options, display the command
7679 history list with line numbers. Lines listed
7682 have been modified. An argument of
7687 If the shell variable
7690 is set and not null,
7691 it is used as a format string for \fIstrftime\fP(3) to display
7692 the time stamp associated with each displayed history entry.
7693 No intervening blank is printed between the formatted time stamp
7694 and the history line.
7695 If \fIfilename\fP is supplied, it is used as the
7696 name of the history file; if not, the value of
7699 is used. Options, if supplied, have the following meanings:
7704 Clear the history list by deleting all the entries.
7706 \fB\-d\fP \fIoffset\fP
7707 Delete the history entry at position \fIoffset\fP.
7710 Append the ``new'' history lines (history lines entered since the
7711 beginning of the current \fBbash\fP session) to the history file.
7714 Read the history lines not already read from the history
7715 file into the current history list. These are lines
7716 appended to the history file since the beginning of the
7717 current \fBbash\fP session.
7720 Read the contents of the history file
7721 and use them as the current history.
7724 Write the current history to the history file, overwriting the
7725 history file's contents.
7728 Perform history substitution on the following \fIargs\fP and display
7729 the result on the standard output.
7730 Does not store the results in the history list.
7731 Each \fIarg\fP must be quoted to disable normal history expansion.
7736 in the history list as a single entry. The last command in the
7737 history list is removed before the
7745 variable is set, the time stamp information
7746 associated with each history entry is written to the history file,
7747 marked with the history comment character.
7748 When the history file is read, lines beginning with the history
7749 comment character followed immediately by a digit are interpreted
7750 as timestamps for the previous history line.
7751 The return value is 0 unless an invalid option is encountered, an
7752 error occurs while reading or writing the history file, an invalid
7753 \fIoffset\fP is supplied as an argument to \fB\-d\fP, or the
7754 history expansion supplied as an argument to \fB\-p\fP fails.
7757 \fBjobs\fP [\fB\-lnprs\fP] [ \fIjobspec\fP ... ]
7760 \fBjobs\fP \fB\-x\fP \fIcommand\fP [ \fIargs\fP ... ]
7762 The first form lists the active jobs. The options have the following
7769 in addition to the normal information.
7772 List only the process ID of the job's process group
7776 Display information only about jobs that have changed status since
7777 the user was last notified of their status.
7780 Restrict output to running jobs.
7783 Restrict output to stopped jobs.
7788 is given, output is restricted to information about that job.
7789 The return status is 0 unless an invalid option is encountered
7804 with the corresponding process group ID, and executes
7808 returning its exit status.
7811 \fBkill\fP [\fB\-s\fP \fIsigspec\fP | \fB\-n\fP \fIsignum\fP | \fB\-\fP\fIsigspec\fP] [\fIpid\fP | \fIjobspec\fP] ...
7814 \fBkill\fP \fB\-l\fP [\fIsigspec\fP | \fIexit_status\fP]
7816 Send the signal named by
7820 to the processes named by
7825 is either a case-insensitive signal name such as
7828 (with or without the
7831 prefix) or a signal number;
7836 is not present, then
7842 lists the signal names.
7843 If any arguments are supplied when
7845 is given, the names of the signals corresponding to the arguments are
7846 listed, and the return status is 0.
7847 The \fIexit_status\fP argument to
7849 is a number specifying either a signal number or the exit status of
7850 a process terminated by a signal.
7852 returns true if at least one signal was successfully sent, or false
7853 if an error occurs or an invalid option is encountered.
7855 \fBlet\fP \fIarg\fP [\fIarg\fP ...]
7858 is an arithmetic expression to be evaluated (see
7860 .B "ARITHMETIC EVALUATION"
7866 returns 1; 0 is returned otherwise.
7868 \fBlocal\fP [\fIoption\fP] [\fIname\fP[=\fIvalue\fP] ...]
7869 For each argument, a local variable named
7871 is created, and assigned
7873 The \fIoption\fP can be any of the options accepted by \fBdeclare\fP.
7876 is used within a function, it causes the variable
7878 to have a visible scope restricted to that function and its children.
7881 writes a list of local variables to the standard output. It is
7884 when not within a function. The return status is 0 unless
7886 is used outside a function, an invalid
7889 \fIname\fP is a readonly variable.
7894 \fBmapfile\fP [\fB\-n\fP \fIcount\fP] [\fB\-O\fP \fIorigin\fP] [\fB\-s\fP \fIcount\fP] [\fB\-t\fP] [\fB\-u\fP \fIfd\fP] [\fB\-C\fP \fIcallback\fP] [\fB\-c\fP \fIquantum\fP] [\fIarray\fP]
7897 \fBreadarray\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]
7899 Read lines from the standard input into the indexed array variable
7901 or from file descriptor
7909 is the default \fIarray\fP.
7910 Options, if supplied, have the following meanings:
7917 lines. If \fIcount\fP is 0, all lines are copied.
7924 The default index is 0.
7927 Discard the first \fIcount\fP lines read.
7930 Remove a trailing newline from each line read.
7933 Read lines from file descriptor \fIfd\fP instead of the standard input.
7938 each time \fIquantum\fP lines are read. The \fB\-c\fP option specifies
7942 Specify the number of lines read between each call to
7948 is specified without
7950 the default quantum is 5000.
7951 When \fIcallback\fP is evaluated, it is supplied the index of the next
7952 array element to be assigned as an additional argument.
7953 \fIcallback\fP is evaluated after the line is read but before the
7954 array element is assigned.
7956 If not supplied with an explicit origin, \fBmapfile\fP will clear \fIarray\fP
7957 before assigning to it.
7959 \fBmapfile\fP returns successfully unless an invalid option or option
7960 argument is supplied, \fIarray\fP is invalid or unassignable, or if
7961 \fIarray\fP is not an indexed array.
7964 \fBpopd\fP [\-\fBn\fP] [+\fIn\fP] [\-\fIn\fP]
7965 Removes entries from the directory stack. With no arguments,
7966 removes the top directory from the stack, and performs a
7968 to the new top directory.
7969 Arguments, if supplied, have the following meanings:
7974 Suppresses the normal change of directory when removing directories
7975 from the stack, so that only the stack is manipulated.
7978 Removes the \fIn\fPth entry counting from the left of the list
7981 starting with zero. For example:
7983 .if t \f(CWpopd +0\fP
7984 removes the first directory,
7986 .if t \f(CWpopd +1\fP
7990 Removes the \fIn\fPth entry counting from the right of the list
7993 starting with zero. For example:
7995 .if t \f(CWpopd -0\fP
7996 removes the last directory,
7998 .if t \f(CWpopd -1\fP
8004 command is successful, a
8006 is performed as well, and the return status is 0.
8008 returns false if an invalid option is encountered, the directory stack
8009 is empty, a non-existent directory stack entry is specified, or the
8010 directory change fails.
8013 \fBprintf\fP [\fB\-v\fP \fIvar\fP] \fIformat\fP [\fIarguments\fP]
8014 Write the formatted \fIarguments\fP to the standard output under the
8015 control of the \fIformat\fP.
8016 The \fIformat\fP is a character string which contains three types of objects:
8017 plain characters, which are simply copied to standard output, character
8018 escape sequences, which are converted and copied to the standard output, and
8019 format specifications, each of which causes printing of the next successive
8021 In addition to the standard \fIprintf\fP(1) formats, \fB%b\fP causes
8022 \fBprintf\fP to expand backslash escape sequences in the corresponding
8023 \fIargument\fP (except that \fB\ec\fP terminates output, backslashes in
8024 \fB\e\(aq\fP, \fB\e"\fP, and \fB\e?\fP are not removed, and octal escapes
8025 beginning with \fB\e0\fP may contain up to four digits),
8026 and \fB%q\fP causes \fBprintf\fP to output the corresponding
8027 \fIargument\fP in a format that can be reused as shell input.
8029 The \fB\-v\fP option causes the output to be assigned to the variable
8030 \fIvar\fP rather than being printed to the standard output.
8032 The \fIformat\fP is reused as necessary to consume all of the \fIarguments\fP.
8033 If the \fIformat\fP requires more \fIarguments\fP than are supplied, the
8034 extra format specifications behave as if a zero value or null string, as
8035 appropriate, had been supplied. The return value is zero on success,
8036 non-zero on failure.
8038 \fBpushd\fP [\fB\-n\fP] [+\fIn\fP] [\-\fIn\fP]
8041 \fBpushd\fP [\fB\-n\fP] [\fIdir\fP]
8043 Adds a directory to the top of the directory stack, or rotates
8044 the stack, making the new top of the stack the current working
8045 directory. With no arguments, exchanges the top two directories
8046 and returns 0, unless the directory stack is empty.
8047 Arguments, if supplied, have the following meanings:
8052 Suppresses the normal change of directory when adding directories
8053 to the stack, so that only the stack is manipulated.
8056 Rotates the stack so that the \fIn\fPth directory
8057 (counting from the left of the list shown by
8063 Rotates the stack so that the \fIn\fPth directory
8064 (counting from the right of the list shown by
8066 starting with zero) is at the top.
8071 to the directory stack at the top, making it the
8072 new current working directory.
8077 command is successful, a
8079 is performed as well.
8080 If the first form is used,
8082 returns 0 unless the cd to
8084 fails. With the second form,
8086 returns 0 unless the directory stack is empty,
8087 a non-existent directory stack element is specified,
8088 or the directory change to the specified new current directory
8092 \fBpwd\fP [\fB\-LP\fP]
8093 Print the absolute pathname of the current working directory.
8094 The pathname printed contains no symbolic links if the
8096 option is supplied or the
8100 builtin command is enabled.
8103 option is used, the pathname printed may contain symbolic links.
8104 The return status is 0 unless an error occurs while
8105 reading the name of the current directory or an
8106 invalid option is supplied.
8108 \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 ...]
8109 One line is read from the standard input, or from the file descriptor
8110 \fIfd\fP supplied as an argument to the \fB\-u\fP option, and the first word
8111 is assigned to the first
8113 the second word to the second
8115 and so on, with leftover words and their intervening separators assigned
8118 If there are fewer words read from the input stream than names,
8119 the remaining names are assigned empty values.
8123 are used to split the line into words.
8124 The backslash character (\fB\e\fP) may be used to remove any special
8125 meaning for the next character read and for line continuation.
8126 Options, if supplied, have the following meanings:
8131 The words are assigned to sequential indices
8132 of the array variable
8136 is unset before any new values are assigned.
8137 Other \fIname\fP arguments are ignored.
8140 The first character of \fIdelim\fP is used to terminate the input line,
8141 rather than newline.
8144 If the standard input
8145 is coming from a terminal,
8150 above) is used to obtain the line.
8151 Readline uses the current (or default, if line editing was not previously
8152 active) editing settings.
8157 is being used to read the line, \fItext\fP is placed into the editing
8158 buffer before editing begins.
8161 \fBread\fP returns after reading \fInchars\fP characters rather than
8162 waiting for a complete line of input, but honor a delimiter if fewer
8163 than \fInchars\fP characters are read before the delimiter.
8166 \fBread\fP returns after reading exactly \fInchars\fP characters rather
8167 than waiting for a complete line of input, unless EOF is encountered or
8168 \fBread\fP times out.
8169 Delimiter characters encountered in the input are
8170 not treated specially and do not cause \fBread\fP to return until
8171 \fInchars\fP characters are read.
8174 Display \fIprompt\fP on standard error, without a
8175 trailing newline, before attempting to read any input. The prompt
8176 is displayed only if input is coming from a terminal.
8179 Backslash does not act as an escape character.
8180 The backslash is considered to be part of the line.
8181 In particular, a backslash-newline pair may not be used as a line
8185 Silent mode. If input is coming from a terminal, characters are
8188 .B \-t \fItimeout\fP
8189 Cause \fBread\fP to time out and return failure if a complete line of
8190 input is not read within \fItimeout\fP seconds.
8191 \fItimeout\fP may be a decimal number with a fractional portion following
8193 This option is only effective if \fBread\fP is reading input from a
8194 terminal, pipe, or other special file; it has no effect when reading
8196 If \fItimeout\fP is 0, \fBread\fP returns success if input is available on
8197 the specified file descriptor, failure otherwise.
8198 The exit status is greater than 128 if the timeout is exceeded.
8201 Read input from file descriptor \fIfd\fP.
8206 are supplied, the line read is assigned to the variable
8209 The return code is zero, unless end-of-file is encountered, \fBread\fP
8210 times out (in which case the return code is greater than 128), or an
8211 invalid file descriptor is supplied as the argument to \fB\-u\fP.
8214 \fBreadonly\fP [\fB\-aApf\fP] [\fIname\fP[=\fIword\fP] ...]
8217 \fInames\fP are marked readonly; the values of these
8219 may not be changed by subsequent assignment.
8222 option is supplied, the functions corresponding to the
8227 option restricts the variables to indexed arrays; the
8229 option restricts the variables to associative arrays.
8232 arguments are given, or if the
8234 option is supplied, a list of all readonly names is printed.
8237 option causes output to be displayed in a format that
8238 may be reused as input.
8239 If a variable name is followed by =\fIword\fP, the value of
8240 the variable is set to \fIword\fP.
8241 The return status is 0 unless an invalid option is encountered,
8244 is not a valid shell variable name, or
8248 that is not a function.
8250 \fBreturn\fP [\fIn\fP]
8251 Causes a function to exit with the return value specified by
8255 is omitted, the return status is that of the last command
8256 executed in the function body. If used outside a function,
8257 but during execution of a script by the
8259 (\fBsource\fP) command, it causes the shell to stop executing
8260 that script and return either
8262 or the exit status of the last command executed within the
8263 script as the exit status of the script. If used outside a
8264 function and not during execution of a script by \fB.\fP\^,
8265 the return status is false.
8266 Any command associated with the \fBRETURN\fP trap is executed
8267 before execution resumes after the function or script.
8269 \fBset\fP [\fB\-\-abefhkmnptuvxBCEHPT\fP] [\fB\-o\fP \fIoption\fP] [\fIarg\fP ...]
8272 \fBset\fP [\fB+abefhkmnptuvxBCEHPT\fP] [\fB+o\fP \fIoption\fP] [\fIarg\fP ...]
8274 Without options, the name and value of each shell variable are displayed
8275 in a format that can be reused as input
8276 for setting or resetting the currently-set variables.
8277 Read-only variables cannot be reset.
8278 In \fIposix mode\fP, only shell variables are listed.
8279 The output is sorted according to the current locale.
8280 When options are specified, they set or unset shell attributes.
8281 Any arguments remaining after option processing are treated
8282 as values for the positional parameters and are assigned, in order, to
8287 Options, if specified, have the following meanings:
8292 Automatically mark variables and functions which are modified or
8293 created for export to the environment of subsequent commands.
8296 Report the status of terminated background jobs
8297 immediately, rather than before the next primary prompt. This is
8298 effective only when job control is enabled.
8301 Exit immediately if a \fIpipeline\fP (which may consist of a single
8302 \fIsimple command\fP), a \fIsubshell\fP command enclosed in parentheses,
8303 or one of the commands executed as part of a command list enclosed
8307 above) exits with a non-zero status.
8308 The shell does not exit if the
8309 command that fails is part of the command list immediately following a
8314 part of the test following the
8318 reserved words, part of any command executed in a
8322 list except the command following the final \fB&&\fP or \fB\(bv\(bv\fP,
8323 any command in a pipeline but the last,
8324 or if the command's return value is
8327 A trap on \fBERR\fP, if set, is executed before the shell exits.
8328 This option applies to the shell environment and each subshell environment
8331 .B "COMMAND EXECUTION ENVIRONMENT"
8332 above), and may cause
8333 subshells to exit before executing all the commands in the subshell.
8336 Disable pathname expansion.
8339 Remember the location of commands as they are looked up for execution.
8340 This is enabled by default.
8343 All arguments in the form of assignment statements
8344 are placed in the environment for a command, not just
8345 those that precede the command name.
8348 Monitor mode. Job control is enabled. This option is on
8349 by default for interactive shells on systems that support
8353 above). Background processes run in a separate process
8354 group and a line containing their exit status is printed
8355 upon their completion.
8358 Read commands but do not execute them. This may be used to
8359 check a shell script for syntax errors. This is ignored by
8362 .B \-o \fIoption\-name\fP
8363 The \fIoption\-name\fP can be one of the following:
8375 Use an emacs-style command line editing interface. This is enabled
8376 by default when the shell is interactive, unless the shell is started
8380 This also affects the editing interface used for \fBread \-e\fP.
8403 Enable command history, as described above under
8406 This option is on by default in interactive shells.
8409 The effect is as if the shell command
8410 .if t \f(CWIGNOREEOF=10\fP
8411 .if n ``IGNOREEOF=10''
8457 If set, the return value of a pipeline is the value of the last
8458 (rightmost) command to exit with a non-zero status, or zero if all
8459 commands in the pipeline exit successfully.
8460 This option is disabled by default.
8463 Change the behavior of
8465 where the default operation differs
8466 from the POSIX standard to match the standard (\fIposix mode\fP).
8477 Use a vi-style command line editing interface.
8478 This also affects the editing interface used for \fBread \-e\fP.
8487 is supplied with no \fIoption\-name\fP, the values of the current options are
8491 is supplied with no \fIoption\-name\fP, a series of
8493 commands to recreate the current option settings is displayed on
8494 the standard output.
8500 mode. In this mode, the
8506 files are not processed, shell functions are not inherited from the
8507 environment, and the
8517 variables, if they appear in the environment, are ignored.
8518 If the shell is started with the effective user (group) id not equal to the
8519 real user (group) id, and the \fB\-p\fP option is not supplied, these actions
8520 are taken and the effective user id is set to the real user id.
8521 If the \fB\-p\fP option is supplied at startup, the effective user id is
8523 Turning this option off causes the effective user
8524 and group ids to be set to the real user and group ids.
8527 Exit after reading and executing one command.
8530 Treat unset variables and parameters other than the special
8531 parameters "@" and "*" as an error when performing
8532 parameter expansion. If expansion is attempted on an
8533 unset variable or parameter, the shell prints an error message, and,
8534 if not interactive, exits with a non-zero status.
8537 Print shell input lines as they are read.
8540 After expanding each \fIsimple command\fP,
8541 \fBfor\fP command, \fBcase\fP command, \fBselect\fP command, or
8542 arithmetic \fBfor\fP command, display the expanded value of
8545 followed by the command and its expanded arguments
8546 or associated word list.
8549 The shell performs brace expansion (see
8551 above). This is on by default.
8556 does not overwrite an existing file with the
8561 redirection operators. This may be overridden when
8562 creating output files by using the redirection operator
8568 If set, any trap on \fBERR\fP is inherited by shell functions, command
8569 substitutions, and commands executed in a subshell environment.
8570 The \fBERR\fP trap is normally not inherited in such cases.
8575 style history substitution. This option is on by
8576 default when the shell is interactive.
8579 If set, the shell does not follow symbolic links when executing
8582 that change the current working directory. It uses the
8583 physical directory structure instead. By default,
8585 follows the logical chain of directories when performing commands
8586 which change the current directory.
8589 If set, any traps on \fBDEBUG\fP and \fBRETURN\fP are inherited by shell
8590 functions, command substitutions, and commands executed in a
8591 subshell environment.
8592 The \fBDEBUG\fP and \fBRETURN\fP traps are normally not inherited
8596 If no arguments follow this option, then the positional parameters are
8597 unset. Otherwise, the positional parameters are set to the
8598 \fIarg\fPs, even if some of them begin with a
8602 Signal the end of options, cause all remaining \fIarg\fPs to be
8603 assigned to the positional parameters. The
8607 options are turned off.
8608 If there are no \fIarg\fPs,
8609 the positional parameters remain unchanged.
8612 The options are off by default unless otherwise noted.
8613 Using + rather than \- causes these options to be turned off.
8614 The options can also be specified as arguments to an invocation of
8616 The current set of options may be found in
8618 The return status is always true unless an invalid option is encountered.
8621 \fBshift\fP [\fIn\fP]
8622 The positional parameters from \fIn\fP+1 ... are renamed to
8625 Parameters represented by the numbers \fB$#\fP
8626 down to \fB$#\fP\-\fIn\fP+1 are unset.
8628 must be a non-negative number less than or equal to \fB$#\fP.
8631 is 0, no parameters are changed.
8634 is not given, it is assumed to be 1.
8637 is greater than \fB$#\fP, the positional parameters are not changed.
8638 The return status is greater than zero if
8642 or less than zero; otherwise 0.
8644 \fBshopt\fP [\fB\-pqsu\fP] [\fB\-o\fP] [\fIoptname\fP ...]
8645 Toggle the values of variables controlling optional shell behavior.
8646 With no options, or with the
8648 option, a list of all settable options is displayed, with
8649 an indication of whether or not each is set.
8650 The \fB\-p\fP option causes output to be displayed in a form that
8651 may be reused as input.
8652 Other options have the following meanings:
8657 Enable (set) each \fIoptname\fP.
8660 Disable (unset) each \fIoptname\fP.
8663 Suppresses normal output (quiet mode); the return status indicates
8664 whether the \fIoptname\fP is set or unset.
8665 If multiple \fIoptname\fP arguments are given with
8667 the return status is zero if all \fIoptnames\fP are enabled; non-zero
8671 Restricts the values of \fIoptname\fP to be those defined for the
8682 is used with no \fIoptname\fP arguments, the display is limited to
8683 those options which are set or unset, respectively.
8684 Unless otherwise noted, the \fBshopt\fP options are disabled (unset)
8687 The return status when listing options is zero if all \fIoptnames\fP
8688 are enabled, non-zero otherwise. When setting or unsetting options,
8689 the return status is zero unless an \fIoptname\fP is not a valid shell
8692 The list of \fBshopt\fP options is:
8698 If set, a command name that is the name of a directory is executed as if
8699 it were the argument to the \fBcd\fP command.
8700 This option is only used by interactive shells.
8703 If set, an argument to the
8705 builtin command that
8706 is not a directory is assumed to be the name of a variable whose
8707 value is the directory to change to.
8710 If set, minor errors in the spelling of a directory component in a
8712 command will be corrected.
8713 The errors checked for are transposed characters,
8714 a missing character, and one character too many.
8715 If a correction is found, the corrected file name is printed,
8716 and the command proceeds.
8717 This option is only used by interactive shells.
8720 If set, \fBbash\fP checks that a command found in the hash
8721 table exists before trying to execute it. If a hashed command no
8722 longer exists, a normal path search is performed.
8725 If set, \fBbash\fP lists the status of any stopped and running jobs before
8726 exiting an interactive shell. If any jobs are running, this causes
8727 the exit to be deferred until a second exit is attempted without an
8728 intervening command (see
8731 above). The shell always
8732 postpones exiting if any jobs are stopped.
8735 If set, \fBbash\fP checks the window size after each command
8736 and, if necessary, updates the values of
8746 attempts to save all lines of a multiple-line
8747 command in the same history entry. This allows
8748 easy re-editing of multi-line commands.
8753 changes its behavior to that of version 3.1 with respect to quoted
8754 arguments to the conditional command's =~ operator.
8759 changes its behavior to that of version 3.2 with respect to locale-specific
8760 string comparison when using the conditional command's < and > operators.
8765 changes its behavior to that of version 4.0 with respect to locale-specific
8766 string comparison when using the conditional command's < and > operators
8767 and the effect of interrupting a command list.
8772 attempts spelling correction on directory names during word completion
8773 if the directory name initially supplied does not exist.
8778 includes filenames beginning with a `.' in the results of pathname
8782 If set, a non-interactive shell will not exit if
8783 it cannot execute the file specified as an argument to the
8785 builtin command. An interactive shell does not exit if
8790 If set, aliases are expanded as described above under
8793 This option is enabled by default for interactive shells.
8796 If set, behavior intended for use by debuggers is enabled:
8800 The \fB\-F\fP option to the \fBdeclare\fP builtin displays the source
8801 file name and line number corresponding to each function name supplied
8805 If the command run by the \fBDEBUG\fP trap returns a non-zero value, the
8806 next command is skipped and not executed.
8809 If the command run by the \fBDEBUG\fP trap returns a value of 2, and the
8810 shell is executing in a subroutine (a shell function or a shell script
8811 executed by the \fB.\fP or \fBsource\fP builtins), a call to
8812 \fBreturn\fP is simulated.
8820 are updated as described in their descriptions above.
8823 Function tracing is enabled: command substitution, shell functions, and
8824 subshells invoked with \fB(\fP \fIcommand\fP \fB)\fP inherit the
8825 \fBDEBUG\fP and \fBRETURN\fP traps.
8828 Error tracing is enabled: command substitution, shell functions, and
8829 subshells invoked with \fB(\fP \fIcommand\fP \fB)\fP inherit the
8834 If set, the extended pattern matching features described above under
8835 \fBPathname Expansion\fP are enabled.
8838 If set, \fB$\fP\(aq\fIstring\fP\(aq and \fB$\fP"\fIstring\fP" quoting is
8839 performed within \fB${\fP\fIparameter\fP\fB}\fP expansions
8840 enclosed in double quotes. This option is enabled by default.
8843 If set, patterns which fail to match filenames during pathname expansion
8844 result in an expansion error.
8847 If set, the suffixes specified by the
8851 cause words to be ignored when performing word completion even if
8852 the ignored words are the only possible completions.
8855 \fBSHELL VARIABLES\fP
8856 above for a description of
8859 This option is enabled by default.
8862 If set, the pattern \fB**\fP used in a pathname expansion context will
8863 match a files and zero or more directories and subdirectories.
8864 If the pattern is followed by a \fB/\fP, only directories and
8865 subdirectories match.
8868 If set, shell error messages are written in the standard GNU error
8872 If set, the history list is appended to the file named by the value
8876 variable when the shell exits, rather than overwriting the file.
8881 is being used, a user is given the opportunity to re-edit a
8882 failed history substitution.
8887 is being used, the results of history substitution are not immediately
8888 passed to the shell parser. Instead, the resulting line is loaded into
8889 the \fBreadline\fP editing buffer, allowing further modification.
8894 is being used, \fBbash\fP will attempt to perform hostname completion when a
8895 word containing a \fB@\fP is being completed (see
8901 This is enabled by default.
8904 If set, \fBbash\fP will send
8907 to all jobs when an interactive login shell exits.
8909 .B interactive_comments
8910 If set, allow a word beginning with
8912 to cause that word and all remaining characters on that
8913 line to be ignored in an interactive shell (see
8916 above). This option is enabled by default.
8921 option is enabled, multi-line commands are saved to the history with
8922 embedded newlines rather than using semicolon separators where possible.
8925 The shell sets this option if it is started as a login shell (see
8929 The value may not be changed.
8932 If set, and a file that \fBbash\fP is checking for mail has been
8933 accessed since the last time it was checked, the message ``The mail in
8934 \fImailfile\fP has been read'' is displayed.
8936 .B no_empty_cmd_completion
8941 will not attempt to search the
8944 for possible completions when
8945 completion is attempted on an empty line.
8950 matches filenames in a case\-insensitive fashion when performing pathname
8952 .B Pathname Expansion
8958 matches patterns in a case\-insensitive fashion when performing matching
8959 while executing \fBcase\fP or \fB[[\fP conditional commands.
8964 allows patterns which match no
8966 .B Pathname Expansion
8968 to expand to a null string, rather than themselves.
8971 If set, the programmable completion facilities (see
8972 \fBProgrammable Completion\fP above) are enabled.
8973 This option is enabled by default.
8976 If set, prompt strings undergo
8977 parameter expansion, command substitution, arithmetic
8978 expansion, and quote removal after being expanded as described in
8981 above. This option is enabled by default.
8984 The shell sets this option if it is started in restricted mode (see
8986 .B "RESTRICTED SHELL"
8988 The value may not be changed.
8989 This is not reset when the startup files are executed, allowing
8990 the startup files to discover whether or not a shell is restricted.
8995 builtin prints an error message when the shift count exceeds the
8996 number of positional parameters.
9000 \fBsource\fP (\fB.\fP) builtin uses the value of
9003 to find the directory containing the file supplied as an argument.
9004 This option is enabled by default.
9007 If set, the \fBecho\fP builtin expands backslash-escape sequences
9011 \fBsuspend\fP [\fB\-f\fP]
9012 Suspend the execution of this shell until it receives a
9015 signal. A login shell cannot be suspended; the
9017 option can be used to override this and force the suspension.
9018 The return status is 0 unless the shell is a login shell and
9020 is not supplied, or if job control is not enabled.
9022 \fBtest\fP \fIexpr\fP
9025 \fB[\fP \fIexpr\fP \fB]\fP
9026 Return a status of 0 or 1 depending on
9027 the evaluation of the conditional expression
9029 Each operator and operand must be a separate argument.
9030 Expressions are composed of the primaries described above under
9032 .BR "CONDITIONAL EXPRESSIONS" .
9033 \fBtest\fP does not accept any options, nor does it accept and ignore
9034 an argument of \fB\-\-\fP as signifying the end of options.
9037 Expressions may be combined using the following operators, listed
9038 in decreasing order of precedence.
9039 The evaluation depends on the number of arguments; see below.
9049 Returns the value of \fIexpr\fP.
9050 This may be used to override the normal precedence of operators.
9052 \fIexpr1\fP \-\fBa\fP \fIexpr2\fP
9059 \fIexpr1\fP \-\fBo\fP \fIexpr2\fP
9067 \fBtest\fP and \fB[\fP evaluate conditional
9068 expressions using a set of rules based on the number of arguments.
9074 The expression is false.
9077 The expression is true if and only if the argument is not null.
9080 If the first argument is \fB!\fP, the expression is true if and
9081 only if the second argument is null.
9082 If the first argument is one of the unary conditional operators listed above
9085 .BR "CONDITIONAL EXPRESSIONS" ,
9086 the expression is true if the unary test is true.
9087 If the first argument is not a valid unary conditional operator, the expression
9091 If the second argument is one of the binary conditional operators listed above
9094 .BR "CONDITIONAL EXPRESSIONS" ,
9095 the result of the expression is the result of the binary test using
9096 the first and third arguments as operands.
9097 The \fB\-a\fP and \fB\-o\fP operators are considered binary operators
9098 when there are three arguments.
9099 If the first argument is \fB!\fP, the value is the negation of
9100 the two-argument test using the second and third arguments.
9101 If the first argument is exactly \fB(\fP and the third argument is
9102 exactly \fB)\fP, the result is the one-argument test of the second
9104 Otherwise, the expression is false.
9107 If the first argument is \fB!\fP, the result is the negation of
9108 the three-argument expression composed of the remaining arguments.
9109 Otherwise, the expression is parsed and evaluated according to
9110 precedence using the rules listed above.
9113 The expression is parsed and evaluated according to precedence
9114 using the rules listed above.
9119 Print the accumulated user and system times for the shell and
9120 for processes run from the shell. The return status is 0.
9122 \fBtrap\fP [\fB\-lp\fP] [[\fIarg\fP] \fIsigspec\fP ...]
9125 is to be read and executed when the shell receives
9130 is absent (and there is a single \fIsigspec\fP) or
9132 each specified signal is
9133 reset to its original disposition (the value it had
9134 upon entrance to the shell).
9137 is the null string the signal specified by each
9139 is ignored by the shell and by the commands it invokes.
9144 has been supplied, then the trap commands associated with each
9147 If no arguments are supplied or if only
9151 prints the list of commands associated with each signal.
9154 option causes the shell to print a list of signal names and
9155 their corresponding numbers.
9159 a signal name defined in <\fIsignal.h\fP>, or a signal number.
9160 Signal names are case insensitive and the SIG prefix is optional.
9170 is executed on exit from the shell.
9178 is executed before every \fIsimple command\fP, \fIfor\fP command,
9179 \fIcase\fP command, \fIselect\fP command, every arithmetic \fIfor\fP
9180 command, and before the first command executes in a shell function (see
9184 Refer to the description of the \fBextdebug\fP option to the
9185 \fBshopt\fP builtin for details of its effect on the \fBDEBUG\fP trap.
9193 is executed each time a shell function or a script executed with the
9194 \fB.\fP or \fBsource\fP builtins finishes executing.
9204 is executed whenever a simple command has a non\-zero exit status,
9205 subject to the following conditions.
9209 trap is not executed if the failed
9210 command is part of the command list immediately following a
9215 part of the test in an
9217 statement, part of a command executed in a
9221 list, or if the command's return value is
9224 These are the same conditions obeyed by the \fBerrexit\fP option.
9227 Signals ignored upon entry to the shell cannot be trapped or reset.
9228 Trapped signals that are not being ignored are reset to their original
9229 values in a subshell or subshell environment when one is created.
9230 The return status is false if any
9232 is invalid; otherwise
9236 \fBtype\fP [\fB\-aftpP\fP] \fIname\fP [\fIname\fP ...]
9240 would be interpreted if used as a command name.
9245 prints a string which is one of
9254 is an alias, shell reserved word, function, builtin, or disk file,
9258 is not found, then nothing is printed, and an exit status of false
9264 either returns the name of the disk file
9265 that would be executed if
9267 were specified as a command name,
9269 .if t \f(CWtype -t name\fP
9270 .if n ``type -t name''
9278 search for each \fIname\fP, even if
9279 .if t \f(CWtype -t name\fP
9280 .if n ``type -t name''
9283 If a command is hashed,
9287 print the hashed value, not necessarily the file that appears
9295 prints all of the places that contain
9298 This includes aliases and functions,
9301 option is not also used.
9302 The table of hashed commands is not consulted
9307 option suppresses shell function lookup, as with the \fBcommand\fP builtin.
9309 returns true if all of the arguments are found, false if
9312 \fBulimit\fP [\fB\-HSTabcdefilmnpqrstuvx\fP [\fIlimit\fP]]
9313 Provides control over the resources available to the shell and to
9314 processes started by it, on systems that allow such control.
9315 The \fB\-H\fP and \fB\-S\fP options specify that the hard or soft limit is
9316 set for the given resource.
9317 A hard limit cannot be increased by a non-root user once it is set;
9318 a soft limit may be increased up to the value of the hard limit.
9319 If neither \fB\-H\fP nor \fB\-S\fP is specified, both the soft and hard
9323 can be a number in the unit specified for the resource
9324 or one of the special values
9329 which stand for the current hard limit, the current soft limit, and
9330 no limit, respectively.
9333 is omitted, the current value of the soft limit of the resource is
9334 printed, unless the \fB\-H\fP option is given. When more than one
9335 resource is specified, the limit name and unit are printed before the value.
9336 Other options are interpreted as follows:
9341 All current limits are reported
9344 The maximum socket buffer size
9347 The maximum size of core files created
9350 The maximum size of a process's data segment
9353 The maximum scheduling priority ("nice")
9356 The maximum size of files written by the shell and its children
9359 The maximum number of pending signals
9362 The maximum size that may be locked into memory
9365 The maximum resident set size (many systems do not honor this limit)
9368 The maximum number of open file descriptors (most systems do not
9369 allow this value to be set)
9372 The pipe size in 512-byte blocks (this may not be set)
9375 The maximum number of bytes in POSIX message queues
9378 The maximum real-time scheduling priority
9381 The maximum stack size
9384 The maximum amount of cpu time in seconds
9387 The maximum number of processes available to a single user
9390 The maximum amount of virtual memory available to the shell
9393 The maximum number of file locks
9396 The maximum number of threads
9401 is given, it is the new value of the specified resource (the
9403 option is display only).
9404 If no option is given, then
9406 is assumed. Values are in 1024-byte increments, except for
9408 which is in seconds,
9410 which is in units of 512-byte blocks,
9417 which are unscaled values.
9418 The return status is 0 unless an invalid option or argument is supplied,
9419 or an error occurs while setting a new limit.
9422 \fBumask\fP [\fB\-p\fP] [\fB\-S\fP] [\fImode\fP]
9423 The user file-creation mask is set to
9427 begins with a digit, it
9428 is interpreted as an octal number; otherwise
9429 it is interpreted as a symbolic mode mask similar
9434 is omitted, the current value of the mask is printed.
9437 option causes the mask to be printed in symbolic form; the
9438 default output is an octal number.
9441 option is supplied, and
9443 is omitted, the output is in a form that may be reused as input.
9444 The return status is 0 if the mode was successfully changed or if
9445 no \fImode\fP argument was supplied, and false otherwise.
9447 \fBunalias\fP [\-\fBa\fP] [\fIname\fP ...]
9448 Remove each \fIname\fP from the list of defined aliases. If
9450 is supplied, all alias definitions are removed. The return
9451 value is true unless a supplied
9453 is not a defined alias.
9455 \fBunset\fP [\-\fBfv\fP] [\fIname\fP ...]
9458 remove the corresponding variable or function.
9459 If no options are supplied, or the
9461 option is given, each
9463 refers to a shell variable.
9464 Read-only variables may not be unset.
9469 refers to a shell function, and the function definition
9471 Each unset variable or function is removed from the environment
9472 passed to subsequent commands.
9475 .BR COMP_WORDBREAKS ,
9491 are unset, they lose their special properties, even if they are
9492 subsequently reset. The exit status is true unless a
9496 \fBwait\fP [\fIn ...\fP]
9497 Wait for each specified process and return its termination status.
9501 ID or a job specification; if a job spec is given, all processes
9502 in that job's pipeline are waited for. If
9504 is not given, all currently active child processes
9505 are waited for, and the return status is zero. If
9507 specifies a non-existent process or job, the return status is
9508 127. Otherwise, the return status is the exit status of the last
9509 process or job waited for.
9512 .SH "RESTRICTED SHELL"
9518 is started with the name
9522 option is supplied at invocation,
9523 the shell becomes restricted.
9524 A restricted shell is used to
9525 set up an environment more controlled than the standard shell.
9526 It behaves identically to
9528 with the exception that the following are disallowed or not performed:
9530 changing directories with \fBcd\fP
9532 setting or unsetting the values of
9543 specifying command names containing
9546 specifying a file name containing a
9548 as an argument to the
9552 Specifying a filename containing a slash as an argument to the
9558 importing function definitions from the shell environment at startup
9560 parsing the value of
9563 from the shell environment at startup
9565 redirecting output using the >, >|, <>, >&, &>, and >> redirection operators
9569 builtin command to replace the shell with another command
9571 adding or deleting builtin commands with the
9579 Using the \fBenable\fP builtin command to enable disabled shell builtins
9587 turning off restricted mode with
9588 \fBset +r\fP or \fBset +o restricted\fP.
9590 These restrictions are enforced after any startup files are read.
9592 .ie \n(zY=1 When a command that is found to be a shell script is executed,
9593 .el \{ When a command that is found to be a shell script is executed
9596 .B "COMMAND EXECUTION"
9600 turns off any restrictions in the shell spawned to execute the
9607 \fIBash Reference Manual\fP, Brian Fox and Chet Ramey
9609 \fIThe Gnu Readline Library\fP, Brian Fox and Chet Ramey
9611 \fIThe Gnu History Library\fP, Brian Fox and Chet Ramey
9613 \fIPortable Operating System Interface (POSIX) Part 2: Shell and Utilities\fP, IEEE
9615 \fIsh\fP(1), \fIksh\fP(1), \fIcsh\fP(1)
9617 \fIemacs\fP(1), \fIvi\fP(1)
9625 The \fBbash\fP executable
9628 The systemwide initialization file, executed for login shells
9631 The personal initialization file, executed for login shells
9634 The individual per-interactive-shell startup file
9637 The individual login shell cleanup file, executed when a login shell exits
9640 Individual \fIreadline\fP initialization file
9643 Brian Fox, Free Software Foundation
9647 Chet Ramey, Case Western Reserve University
9651 If you find a bug in
9653 you should report it. But first, you should
9654 make sure that it really is a bug, and that it appears in the latest
9657 The latest version is always available from
9658 \fIftp://ftp.gnu.org/pub/bash/\fP.
9660 Once you have determined that a bug actually exists, use the
9662 command to submit a bug report.
9663 If you have a fix, you are encouraged to mail that as well!
9664 Suggestions and `philosophical' bug reports may be mailed
9665 to \fIbug-bash@gnu.org\fP or posted to the Usenet
9669 ALL bug reports should include:
9673 The version number of \fBbash\fR
9675 The hardware and operating system
9677 The compiler used to compile
9679 A description of the bug behaviour
9681 A short script or `recipe' which exercises the bug
9685 inserts the first three items automatically into the template
9686 it provides for filing a bug report.
9688 Comments and bug reports concerning
9689 this manual page should be directed to
9690 .IR chet@po.cwru.edu .
9693 It's too big and too slow.
9695 There are some subtle differences between
9697 and traditional versions of
9699 mostly because of the
9704 Aliases are confusing in some uses.
9706 Shell builtin commands and functions are not stoppable/restartable.
9708 Compound commands and command sequences of the form `a ; b ; c'
9709 are not handled gracefully when process suspension is attempted.
9710 When a process is stopped, the shell immediately executes the next
9711 command in the sequence.
9712 It suffices to place the sequence of commands between
9713 parentheses to force it into a subshell, which may be stopped as
9716 Array variables may not (yet) be exported.
9718 There may be only one active coprocess at a time.