2 .\" MAN PAGE COMMENTS to
5 .\" Case Western Reserve University
6 .\" chet.ramey@case.edu
8 .\" Last Change: Wed Sep 23 09:28:31 EDT 2020
10 .\" bush_builtins, strip all but Built-Ins section
13 .TH BUSH 1 "2020 October 29" "GNU Bush 5.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 bush \- GNU Bourne-Again SHell
51 [command_string | file]
53 .if n Bush is Copyright (C) 1989-2020 by the Free Software Foundation, Inc.
54 .if t Bush is Copyright \(co 1989-2020 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 All of the single-character shell options documented in the
71 description of the \fBset\fR builtin command, including \fB\-o\fP,
72 can be used as options when the shell is invoked.
73 In addition, \fBbush\fR
74 interprets the following options when it is invoked:
81 option is present, then commands are read from the first non-option argument
83 If there are arguments after the
85 the first argument is assigned to
87 and any remaining arguments are assigned to the positional parameters.
90 sets the name of the shell, which is used in warning and error messages.
95 option is present, the shell is
101 act as if it had been invoked as a login shell (see
109 option is present, the shell becomes
113 .B "RESTRICTED SHELL"
119 option is present, or if no arguments remain after option
120 processing, then commands are read from the standard input.
121 This option allows the positional parameters to be set
122 when invoking an interactive shell or when reading input
126 A list of all double-quoted strings preceded by \fB$\fP
127 is printed on the standard output.
128 These are the strings that
129 are subject to language translation when the current locale
130 is not \fBC\fP or \fBPOSIX\fP.
131 This implies the \fB\-n\fP option; no commands will be executed.
133 .B [\-+]O [\fIshopt_option\fP]
134 \fIshopt_option\fP is one of the shell options accepted by the
135 \fBshopt\fP builtin (see
137 .B SHELL BUILTIN COMMANDS
139 If \fIshopt_option\fP is present, \fB\-O\fP sets the value of that option;
141 If \fIshopt_option\fP is not supplied, the names and values of the shell
142 options accepted by \fBshopt\fP are printed on the standard output.
143 If the invocation option is \fB+O\fP, the output is displayed in a format
144 that may be reused as input.
149 signals the end of options and disables further option processing.
150 Any arguments after the
152 are treated as filenames and arguments. An argument of
154 is equivalent to \fB\-\-\fP.
158 also interprets a number of multi-character options.
159 These options must appear on the command line before the
160 single-character options to be recognized.
165 Arrange for the debugger profile to be executed before the shell
167 Turns on extended debugging mode (see the description of the
173 .B \-\-dump\-po\-strings
174 Equivalent to \fB\-D\fP, but the output is in the GNU \fIgettext\fP
175 \fBpo\fP (portable object) file format.
178 Equivalent to \fB\-D\fP.
181 Display a usage message on standard output and exit successfully.
183 \fB\-\-init\-file\fP \fIfile\fP
186 \fB\-\-rcfile\fP \fIfile\fP
188 Execute commands from
190 instead of the standard personal initialization file
192 if the shell is interactive (see
198 Equivalent to \fB\-l\fP.
203 library to read command lines when the shell is interactive.
206 Do not read either the system-wide startup file
208 or any of the personal initialization files
209 .IR ~/.bush_profile ,
215 reads these files when it is invoked as a login shell (see
221 Do not read and execute the personal initialization file
223 if the shell is interactive.
224 This option is on by default if the shell is invoked as
228 Change the behavior of \fBbush\fP where the default operation differs
229 from the POSIX standard to match the standard (\fIposix mode\fP).
233 below for a reference to a document that details how posix mode affects
237 The shell becomes restricted (see
239 .B "RESTRICTED SHELL"
243 Equivalent to \fB\-v\fP.
246 Show version information for this instance of
248 on the standard output and exit successfully.
251 If arguments remain after option processing, and neither the
255 option has been supplied, the first argument is assumed to
256 be the name of a file containing shell commands.
259 is invoked in this fashion,
261 is set to the name of the file, and the positional parameters
262 are set to the remaining arguments.
264 reads and executes commands from this file, then exits.
265 \fBBush\fP's exit status is the exit status of the last command
266 executed in the script.
267 If no commands are executed, the exit status is 0.
268 An attempt is first made to open the file in the current directory, and,
269 if no file is found, then the shell searches the directories in
274 A \fIlogin shell\fP is one whose first character of argument zero is a
276 or one started with the
280 An \fIinteractive\fP shell is one started without non-option arguments
281 (unless \fB\-s\fP is specified)
285 whose standard input and error are
286 both connected to terminals (as determined by
288 or one started with the
300 allowing a shell script or a startup file to test this state.
302 The following paragraphs describe how
304 executes its startup files.
305 If any of the files exist but cannot be read,
308 Tildes are expanded in filenames as described below under
317 is invoked as an interactive login shell, or as a non-interactive shell
318 with the \fB\-\-login\fP option, it first reads and
319 executes commands from the file \fI/etc/profile\fP, if that
321 After reading that file, it looks for \fI~/.bush_profile\fP,
322 \fI~/.bush_login\fP, and \fI~/.profile\fP, in that order, and reads
323 and executes commands from the first one that exists and is readable.
326 option may be used when the shell is started to inhibit this behavior.
328 When an interactive login shell exits,
329 or a non-interactive login shell executes the \fBexit\fP builtin command,
331 reads and executes commands from the file \fI~/.bush_logout\fP, if it
334 When an interactive shell that is not a login shell is started,
336 reads and executes commands from \fI~/.bushrc\fP, if that file exists.
337 This may be inhibited by using the
340 The \fB\-\-rcfile\fP \fIfile\fP option will force
342 to read and execute commands from \fIfile\fP instead of \fI~/.bushrc\fP.
346 is started non-interactively, to run a shell script, for example, it
347 looks for the variable
350 in the environment, expands its value if it appears there, and uses the
351 expanded value as the name of a file to read and execute.
353 behaves as if the following command were executed:
356 .if t \f(CWif [ \-n "$BUSH_ENV" ]; then . "$BUSH_ENV"; fi\fP
357 .if n if [ \-n "$BUSH_ENV" ]; then . "$BUSH_ENV"; fi
363 variable is not used to search for the filename.
367 is invoked with the name
369 it tries to mimic the startup behavior of historical versions of
371 as closely as possible,
372 while conforming to the POSIX standard as well.
373 When invoked as an interactive login shell, or a non-interactive
374 shell with the \fB\-\-login\fP option, it first attempts to
375 read and execute commands from
382 option may be used to inhibit this behavior.
383 When invoked as an interactive shell with the name
386 looks for the variable
389 expands its value if it is defined, and uses the
390 expanded value as the name of a file to read and execute.
391 Since a shell invoked as
393 does not attempt to read and execute commands from any other startup
396 option has no effect.
397 A non-interactive shell invoked with the name
399 does not attempt to read any other startup files.
405 mode after the startup files are read.
413 command line option, it follows the POSIX standard for startup files.
414 In this mode, interactive shells expand the
417 variable and commands are read and executed from the file
418 whose name is the expanded value.
419 No other startup files are read.
422 attempts to determine when it is being run with its standard input
423 connected to a network connection, as when executed by the remote shell
424 daemon, usually \fIrshd\fP, or the secure shell daemon \fIsshd\fP.
427 determines it is being run in this fashion, it reads and executes
428 commands from \fI~/.bushrc\fP, if that file exists and is readable.
429 It will not do this if invoked as \fBsh\fP.
432 option may be used to inhibit this behavior, and the
434 option may be used to force another file to be read, but neither
435 \fIrshd\fP nor \fIsshd\fP generally invoke the shell with those options
436 or allow them to be specified.
438 If the shell is started with the effective user (group) id not equal to the
439 real user (group) id, and the \fB\-p\fP option is not supplied, no startup
440 files are read, shell functions are not inherited from the environment, the
450 variables, if they appear in the environment, are ignored,
451 and the effective user id is set to the real user id.
452 If the \fB\-p\fP option is supplied at invocation, the startup behavior is
453 the same, but the effective user id is not reset.
455 The following definitions are used throughout the rest of this
463 A sequence of characters considered as a single unit by the shell.
470 consisting only of alphanumeric characters and underscores, and
471 beginning with an alphabetic character or an underscore. Also
476 A character that, when unquoted, separates words. One of the following:
480 .if t \fB| & ; ( ) < > space tab newline\fP
481 .if n \fB| & ; ( ) < > space tab newline\fP
485 A \fItoken\fP that performs a control function. It is one of the following
489 .if t \fB|| & && ; ;; ;& ;;& ( ) | |& <newline>\fP
490 .if n \fB|| & && ; ;; ;& ;;& ( ) | |& <newline>\fP
494 \fIReserved words\fP are words that have a special meaning to the shell.
495 The following words are recognized as reserved when unquoted and either
496 the first word of a command (see
499 below), the third word of a
504 (only \fBin\fP is valid), or the third word of a
506 command (only \fBin\fP and \fBdo\fP are valid):
510 .if n ! case coproc do done elif else esac fi for function if in select then until while { } time [[ ]]
511 .if t ! case coproc do done elif else esac fi for function if in select then until while { } time [[ ]]
515 A \fIsimple command\fP is a sequence of optional variable assignments
516 followed by \fBblank\fP-separated words and redirections, and
517 terminated by a \fIcontrol operator\fP. The first word
518 specifies the command to be executed, and is passed as argument zero.
519 The remaining words are passed as arguments to the invoked command.
521 The return value of a \fIsimple command\fP is its exit status, or
522 128+\fIn\^\fP if the command is terminated by signal
525 A \fIpipeline\fP is a sequence of one or more commands separated by
526 one of the control operators
529 The format for a pipeline is:
532 [\fBtime\fP [\fB\-p\fP]] [ ! ] \fIcommand\fP [ [\fB|\fP\(bv\fB|&\fP] \fIcommand2\fP ... ]
535 The standard output of
537 is connected via a pipe to the standard input of
539 This connection is performed before any redirections specified by the
544 If \fB|&\fP is used, \fIcommand\fP's standard error, in addition to its
545 standard output, is connected to
546 \fIcommand2\fP's standard input through the pipe;
547 it is shorthand for \fB2>&1 |\fP.
548 This implicit redirection of the standard error to the standard output is
549 performed after any redirections specified by the command.
551 The return status of a pipeline is the exit status of the last
552 command, unless the \fBpipefail\fP option is enabled.
553 If \fBpipefail\fP is enabled, the pipeline's return status is the
554 value of the last (rightmost) command to exit with a non-zero status,
555 or zero if all commands exit successfully.
558 precedes a pipeline, the exit status of that pipeline is the logical
559 negation of the exit status as described above.
560 The shell waits for all commands in the pipeline to
561 terminate before returning a value.
565 reserved word precedes a pipeline, the elapsed as well as user and
566 system time consumed by its execution are reported when the pipeline
568 The \fB\-p\fP option changes the output format to that specified by POSIX.
569 When the shell is in \fIposix mode\fP, it does not recognize
570 \fBtime\fP as a reserved word if the next token begins with a `-'.
574 variable may be set to a format string that specifies how the timing
575 information should be displayed; see the description of
582 When the shell is in \fIposix mode\fP, \fBtime\fP
583 may be followed by a newline. In this case, the shell displays the
584 total user and system time consumed by the shell and its children.
588 variable may be used to specify the format of
589 the time information.
591 Each command in a pipeline is executed as a separate process (i.e., in a
595 \fBCOMMAND EXECUTION ENVIRONMENT\fP
596 for a description of a subshell environment.
597 If the \fBlastpipe\fP option is enabled using the \fBshopt\fP builtin
598 (see the description of \fBshopt\fP below),
599 the last element of a pipeline may be run by the shell process.
601 A \fIlist\fP is a sequence of one or more pipelines separated by one
608 and optionally terminated by one of
614 Of these list operators,
618 have equal precedence, followed by
622 which have equal precedence.
624 A sequence of one or more newlines may appear in a \fIlist\fP instead
625 of a semicolon to delimit commands.
627 If a command is terminated by the control operator
629 the shell executes the command in the \fIbackground\fP
631 The shell does not wait for the command to
632 finish, and the return status is 0.
633 These are referred to as \fIasynchronous\fP commands.
634 Commands separated by a
636 are executed sequentially; the shell waits for each
637 command to terminate in turn. The return status is the
638 exit status of the last command executed.
640 AND and OR lists are sequences of one or more pipelines separated by the
641 \fB&&\fP and \fB||\fP control operators, respectively.
642 AND and OR lists are executed with left associativity.
643 An AND list has the form
646 \fIcommand1\fP \fB&&\fP \fIcommand2\fP
650 is executed if, and only if,
652 returns an exit status of zero (success).
654 An OR list has the form
657 \fIcommand1\fP \fB||\fP \fIcommand2\fP
661 is executed if, and only if,
663 returns a non-zero exit status.
665 AND and OR lists is the exit status of the last command
666 executed in the list.
667 .SS Compound Commands
668 A \fIcompound command\fP is one of the following.
669 In most cases a \fIlist\fP in a command's description may be separated from
670 the rest of the command by one or more newlines, and may be followed by a
671 newline in place of a semicolon.
674 \fIlist\fP is executed in a subshell environment (see
676 \fBCOMMAND EXECUTION ENVIRONMENT\fP
678 Variable assignments and builtin
679 commands that affect the shell's environment do not remain in effect
680 after the command completes. The return status is the exit status of
684 \fIlist\fP is simply executed in the current shell environment.
685 \fIlist\fP must be terminated with a newline or semicolon.
686 This is known as a \fIgroup command\fP.
687 The return status is the exit status of
689 Note that unlike the metacharacters \fB(\fP and \fB)\fP, \fB{\fP and
690 \fB}\fP are \fIreserved words\fP and must occur where a reserved
691 word is permitted to be recognized. Since they do not cause a word
692 break, they must be separated from \fIlist\fP by whitespace or another
696 The \fIexpression\fP is evaluated according to the rules described
699 .BR "ARITHMETIC EVALUATION" .
700 If the value of the expression is non-zero, the return status is 0;
701 otherwise the return status is 1. This is exactly equivalent to
702 \fBlet "\fIexpression\fP"\fR.
704 \fB[[\fP \fIexpression\fP \fB]]\fP
705 Return a status of 0 or 1 depending on the evaluation of
706 the conditional expression \fIexpression\fP.
707 Expressions are composed of the primaries described below under
709 .BR "CONDITIONAL EXPRESSIONS" .
710 Word splitting and pathname expansion are not performed on the words
711 between the \fB[[\fP and \fB]]\fP; tilde expansion,
712 parameter and variable expansion,
713 arithmetic expansion, command substitution, process
714 substitution, and quote removal are performed.
715 Conditional operators such as \fB\-f\fP must be unquoted to be recognized
719 When used with \fB[[\fP, the \fB<\fP and \fB>\fP operators sort
720 lexicographically using the current locale.
723 When the \fB==\fP and \fB!=\fP operators are used, the string to the
724 right of the operator is considered a pattern and matched according
725 to the rules described below under \fBPattern Matching\fP,
726 as if the \fBextglob\fP shell option were enabled.
727 The \fB=\fP operator is equivalent to \fB==\fP.
730 shell option is enabled, the match is performed without regard to the case
731 of alphabetic characters.
732 The return value is 0 if the string matches (\fB==\fP) or does not match
733 (\fB!=\fP) the pattern, and 1 otherwise.
734 Any part of the pattern may be quoted to force the quoted portion
735 to be matched as a string.
738 An additional binary operator, \fB=~\fP, is available, with the same
739 precedence as \fB==\fP and \fB!=\fP.
740 When it is used, the string to the right of the operator is considered
741 a POSIX extended regular expression and matched accordingly
742 (using the POSIX \fIregcomp\fP and \fIregexec\fP interfaces
743 usually described in \fIregex\fP(3)).
744 The return value is 0 if the string matches
745 the pattern, and 1 otherwise.
746 If the regular expression is syntactically incorrect, the conditional
747 expression's return value is 2.
750 shell option is enabled, the match is performed without regard to the case
751 of alphabetic characters.
752 Any part of the pattern may be quoted to force the quoted portion
753 to be matched as a string.
754 Bracket expressions in regular expressions must be treated carefully,
755 since normal quoting characters lose their meanings between brackets.
756 If the pattern is stored in a shell variable, quoting the variable
757 expansion forces the entire pattern to be matched as a string.
760 The pattern will match if it matches any part of the string.
761 Anchor the pattern using the \fB^\fP and \fB$\fP regular expression
762 operators to force it to match the entire string.
766 records which parts of the string matched the pattern.
770 with index 0 contains the portion of
771 the string matching the entire regular expression.
772 Substrings matched by parenthesized subexpressions within the regular
773 expression are saved in the remaining
776 indices. The element of
779 with index \fIn\fP is the portion of the
780 string matching the \fIn\fPth parenthesized subexpression.
783 Expressions may be combined using the following operators, listed
784 in decreasing order of precedence:
790 .B ( \fIexpression\fP )
791 Returns the value of \fIexpression\fP.
792 This may be used to override the normal precedence of operators.
794 .B ! \fIexpression\fP
799 \fIexpression1\fP \fB&&\fP \fIexpression2\fP
806 \fIexpression1\fP \fB||\fP \fIexpression2\fP
814 The \fB&&\fP and \fB||\fP
815 operators do not evaluate \fIexpression2\fP if the value of
816 \fIexpression1\fP is sufficient to determine the return value of
817 the entire conditional expression.
820 \fBfor\fP \fIname\fP [ [ \fBin\fP [ \fIword ...\fP ] ] ; ] \fBdo\fP \fIlist\fP ; \fBdone\fP
821 The list of words following \fBin\fP is expanded, generating a list
823 The variable \fIname\fP is set to each element of this list
824 in turn, and \fIlist\fP is executed each time.
825 If the \fBin\fP \fIword\fP is omitted, the \fBfor\fP command executes
826 \fIlist\fP once for each positional parameter that is set (see
830 The return status is the exit status of the last command that executes.
831 If the expansion of the items following \fBin\fP results in an empty
832 list, no commands are executed, and the return status is 0.
834 \fBfor\fP (( \fIexpr1\fP ; \fIexpr2\fP ; \fIexpr3\fP )) ; \fBdo\fP \fIlist\fP ; \fBdone\fP
835 First, the arithmetic expression \fIexpr1\fP is evaluated according
836 to the rules described below under
838 .BR "ARITHMETIC EVALUATION" .
839 The arithmetic expression \fIexpr2\fP is then evaluated repeatedly
840 until it evaluates to zero.
841 Each time \fIexpr2\fP evaluates to a non-zero value, \fIlist\fP is
842 executed and the arithmetic expression \fIexpr3\fP is evaluated.
843 If any expression is omitted, it behaves as if it evaluates to 1.
844 The return value is the exit status of the last command in \fIlist\fP
845 that is executed, or false if any of the expressions is invalid.
847 \fBselect\fP \fIname\fP [ \fBin\fP \fIword\fP ] ; \fBdo\fP \fIlist\fP ; \fBdone\fP
848 The list of words following \fBin\fP is expanded, generating a list
849 of items. The set of expanded words is printed on the standard
850 error, each preceded by a number. If the \fBin\fP
851 \fIword\fP is omitted, the positional parameters are printed (see
857 prompt is then displayed and a line read from the standard input.
858 If the line consists of a number corresponding to one of
859 the displayed words, then the value of
861 is set to that word. If the line is empty, the words and prompt
862 are displayed again. If EOF is read, the command completes. Any
863 other value read causes
865 to be set to null. The line read is saved in the variable
870 is executed after each selection until a
875 is the exit status of the last command executed in
877 or zero if no commands were executed.
879 \fBcase\fP \fIword\fP \fBin\fP [ [(] \fIpattern\fP [ \fB|\fP \fIpattern\fP ] \
880 ... ) \fIlist\fP ;; ] ... \fBesac\fP
881 A \fBcase\fP command first expands \fIword\fP, and tries to match
882 it against each \fIpattern\fP in turn, using the matching rules
886 The \fIword\fP is expanded using tilde
887 expansion, parameter and variable expansion, arithmetic expansion,
888 command substitution, process substitution and quote removal.
889 Each \fIpattern\fP examined is expanded using tilde
890 expansion, parameter and variable expansion, arithmetic expansion,
891 command substitution, and process substitution.
894 shell option is enabled, the match is performed without regard to the case
895 of alphabetic characters.
896 When a match is found, the corresponding \fIlist\fP is executed.
897 If the \fB;;\fP operator is used, no subsequent matches are attempted after
898 the first pattern match.
899 Using \fB;&\fP in place of \fB;;\fP causes execution to continue with
900 the \fIlist\fP associated with the next set of patterns.
901 Using \fB;;&\fP in place of \fB;;\fP causes the shell to test the next
902 pattern list in the statement, if any, and execute any associated \fIlist\fP
903 on a successful match,
904 continuing the case statement execution as if the pattern list had not matched.
905 The exit status is zero if no
906 pattern matches. Otherwise, it is the exit status of the
907 last command executed in \fIlist\fP.
909 \fBif\fP \fIlist\fP; \fBthen\fP \fIlist\fP; \
910 [ \fBelif\fP \fIlist\fP; \fBthen\fP \fIlist\fP; ] ... \
911 [ \fBelse\fP \fIlist\fP; ] \fBfi\fP
915 is executed. If its exit status is zero, the
916 \fBthen\fP \fIlist\fP is executed. Otherwise, each \fBelif\fP
917 \fIlist\fP is executed in turn, and if its exit status is zero,
918 the corresponding \fBthen\fP \fIlist\fP is executed and the
919 command completes. Otherwise, the \fBelse\fP \fIlist\fP is
920 executed, if present. The exit status is the exit status of the
921 last command executed, or zero if no condition tested true.
923 \fBwhile\fP \fIlist-1\fP; \fBdo\fP \fIlist-2\fP; \fBdone\fP
926 \fBuntil\fP \fIlist-1\fP; \fBdo\fP \fIlist-2\fP; \fBdone\fP
928 The \fBwhile\fP command continuously executes the list
929 \fIlist-2\fP as long as the last command in the list \fIlist-1\fP returns
930 an exit status of zero. The \fBuntil\fP command is identical
931 to the \fBwhile\fP command, except that the test is negated:
933 is executed as long as the last command in
935 returns a non-zero exit status.
936 The exit status of the \fBwhile\fP and \fBuntil\fP commands
938 of the last command executed in \fIlist-2\fP, or zero if
941 A \fIcoprocess\fP is a shell command preceded by the \fBcoproc\fP reserved
943 A coprocess is executed asynchronously in a subshell, as if the command
944 had been terminated with the \fB&\fP control operator, with a two-way pipe
945 established between the executing shell and the coprocess.
947 The format for a coprocess is:
950 \fBcoproc\fP [\fINAME\fP] \fIcommand\fP [\fIredirections\fP]
953 This creates a coprocess named \fINAME\fP.
954 If \fINAME\fP is not supplied, the default name is \fBCOPROC\fP.
955 \fINAME\fP must not be supplied if \fIcommand\fP is a \fIsimple
956 command\fP (see above); otherwise, it is interpreted as the first word
957 of the simple command.
958 When the coprocess is executed, the shell creates an array variable (see
960 below) named \fINAME\fP in the context of the executing shell.
961 The standard output of
963 is connected via a pipe to a file descriptor in the executing shell,
964 and that file descriptor is assigned to \fINAME\fP[0].
965 The standard input of
967 is connected via a pipe to a file descriptor in the executing shell,
968 and that file descriptor is assigned to \fINAME\fP[1].
969 This pipe is established before any redirections specified by the
974 The file descriptors can be utilized as arguments to shell commands
975 and redirections using standard word expansions.
976 Other than those created to execute command and process substitutions,
977 the file descriptors are not available in subshells.
978 The process ID of the shell spawned to execute the coprocess is
979 available as the value of the variable \fINAME\fP_PID.
981 builtin command may be used to wait for the coprocess to terminate.
983 Since the coprocess is created as an asynchronous command,
984 the \fBcoproc\fP command always returns success.
985 The return status of a coprocess is the exit status of \fIcommand\fP.
986 .SS Shell Function Definitions
987 A shell function is an object that is called like a simple command and
988 executes a compound command with a new set of positional parameters.
989 Shell functions are declared as follows:
991 \fIfname\fP () \fIcompound\-command\fP [\fIredirection\fP]
994 \fBfunction\fP \fIfname\fP [()] \fIcompound\-command\fP [\fIredirection\fP]
996 This defines a function named \fIfname\fP.
997 The reserved word \fBfunction\fP is optional.
998 If the \fBfunction\fP reserved word is supplied, the parentheses are optional.
999 The \fIbody\fP of the function is the compound command
1000 .I compound\-command
1001 (see \fBCompound Commands\fP above).
1002 That command is usually a \fIlist\fP of commands between { and }, but
1003 may be any command listed under \fBCompound Commands\fP above,
1004 with one exception: If the \fBfunction\fP reserved word is used, but the
1005 parentheses are not supplied, the braces are required.
1006 \fIcompound\-command\fP is executed whenever \fIfname\fP is specified as the
1007 name of a simple command.
1008 When in \fIposix mode\fP, \fIfname\fP must be a valid shell \fIname\fP
1009 and may not be the name of one of the
1010 POSIX \fIspecial builtins\fP.
1011 In default mode, a function name can be any unquoted shell word that does
1012 not contain \fB$\fP.
1013 Any redirections (see
1016 below) specified when a function is defined are performed
1017 when the function is executed.
1018 The exit status of a function definition is zero unless a syntax error
1019 occurs or a readonly function with the same name already exists.
1020 When executed, the exit status of a function is the exit status of the
1021 last command executed in the body. (See
1026 In a non-interactive shell, or an interactive shell in which the
1027 .B interactive_comments
1030 builtin is enabled (see
1032 .B "SHELL BUILTIN COMMANDS"
1033 below), a word beginning with
1035 causes that word and all remaining characters on that line to
1036 be ignored. An interactive shell without the
1037 .B interactive_comments
1038 option enabled does not allow comments. The
1039 .B interactive_comments
1040 option is on by default in interactive shells.
1042 \fIQuoting\fP is used to remove the special meaning of certain
1043 characters or words to the shell. Quoting can be used to
1044 disable special treatment for special characters, to prevent
1045 reserved words from being recognized as such, and to prevent
1046 parameter expansion.
1048 Each of the \fImetacharacters\fP listed above under
1051 has special meaning to the shell and must be quoted if it is to
1054 When the command history expansion facilities are being used
1057 .B HISTORY EXPANSION
1059 \fIhistory expansion\fP character, usually \fB!\fP, must be quoted
1060 to prevent history expansion.
1062 There are three quoting mechanisms: the
1063 .IR "escape character" ,
1064 single quotes, and double quotes.
1066 A non-quoted backslash (\fB\e\fP) is the
1067 .IR "escape character" .
1068 It preserves the literal value of the next character that follows,
1069 with the exception of <newline>. If a \fB\e\fP<newline> pair
1070 appears, and the backslash is not itself quoted, the \fB\e\fP<newline>
1071 is treated as a line continuation (that is, it is removed from the
1072 input stream and effectively ignored).
1074 Enclosing characters in single quotes preserves the literal value
1075 of each character within the quotes. A single quote may not occur
1076 between single quotes, even when preceded by a backslash.
1078 Enclosing characters in double quotes preserves the literal value
1079 of all characters within the quotes, with the exception of
1083 and, when history expansion is enabled,
1085 When the shell is in \fIposix mode\fP, the \fB!\fP has no special meaning
1086 within double quotes, even when history expansion is enabled.
1091 retain their special meaning within double quotes. The backslash
1092 retains its special meaning only when followed by one of the following
1100 A double quote may be quoted within double quotes by preceding it with
1102 If enabled, history expansion will be performed unless an
1104 appearing in double quotes is escaped using a backslash.
1105 The backslash preceding the
1109 The special parameters
1113 have special meaning when in double
1119 Words of the form \fB$\fP\(aq\fIstring\fP\(aq are treated specially. The
1120 word expands to \fIstring\fP, with backslash-escaped characters replaced
1121 as specified by the ANSI C standard. Backslash escape sequences, if
1122 present, are decoded as follows:
1165 the eight-bit character whose value is the octal value \fInnn\fP
1166 (one to three octal digits)
1169 the eight-bit character whose value is the hexadecimal value \fIHH\fP
1170 (one or two hex digits)
1173 the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value
1174 \fIHHHH\fP (one to four hex digits)
1176 .B \eU\fIHHHHHHHH\fP
1177 the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value
1178 \fIHHHHHHHH\fP (one to eight hex digits)
1181 a control-\fIx\fP character
1185 The expanded result is single-quoted, as if the dollar sign had
1188 A double-quoted string preceded by a dollar sign (\fB$\fP\(dq\fIstring\fP\(dq)
1189 will cause the string to be translated according to the current locale.
1190 The \fIgettext\fP infrastructure performs the message catalog lookup and
1191 translation, using the \fBLC_MESSAGES\fP and \fBTEXTDOMAIN\fP shell
1193 If the current locale is \fBC\fP or \fBPOSIX\fP,
1194 or if there are no translations available,
1195 the dollar sign is ignored.
1196 If the string is translated and replaced, the replacement is
1201 is an entity that stores values.
1204 a number, or one of the special characters listed below under
1205 .BR "Special Parameters" .
1208 is a parameter denoted by a
1210 A variable has a \fIvalue\fP and zero or more \fIattributes\fP.
1211 Attributes are assigned using the
1213 builtin command (see
1217 .BR "SHELL BUILTIN COMMANDS" ).
1219 A parameter is set if it has been assigned a value. The null string is
1220 a valid value. Once a variable is set, it may be unset only by using
1223 builtin command (see
1225 .B SHELL BUILTIN COMMANDS
1230 may be assigned to by a statement of the form
1233 \fIname\fP=[\fIvalue\fP]
1238 is not given, the variable is assigned the null string. All
1240 undergo tilde expansion, parameter and variable expansion,
1241 command substitution, arithmetic expansion, and quote
1245 below). If the variable has its
1249 is evaluated as an arithmetic expression even if the $((...)) expansion is
1251 .B "Arithmetic Expansion"
1253 Word splitting is not performed, with the exception
1254 of \fB"$@"\fP as explained below under
1255 .BR "Special Parameters" .
1256 Pathname expansion is not performed.
1257 Assignment statements may also appear as arguments to the
1265 builtin commands (\fIdeclaration\fP commands).
1266 When in \fIposix mode\fP, these builtins may appear in a command after
1267 one or more instances of the \fBcommand\fP builtin and retain these
1268 assignment statement properties.
1270 In the context where an assignment statement is assigning a value
1271 to a shell variable or array index, the += operator can be used to
1272 append to or add to the variable's previous value.
1273 This includes arguments to builtin commands such as \fBdeclare\fP that
1274 accept assignment statements (\fIdeclaration\fP commands).
1275 When += is applied to a variable for which the \fIinteger\fP attribute has been
1276 set, \fIvalue\fP is evaluated as an arithmetic expression and added to the
1277 variable's current value, which is also evaluated.
1278 When += is applied to an array variable using compound assignment (see
1281 variable's value is not unset (as it is when using =), and new values are
1282 appended to the array beginning at one greater than the array's maximum index
1283 (for indexed arrays) or added as additional key\-value pairs in an
1285 When applied to a string-valued variable, \fIvalue\fP is expanded and
1286 appended to the variable's value.
1288 A variable can be assigned the \fInameref\fP attribute using the
1289 \fB\-n\fP option to the \fBdeclare\fP or \fBlocal\fP builtin commands
1290 (see the descriptions of \fBdeclare\fP and \fBlocal\fP below)
1291 to create a \fInameref\fP, or a reference to another variable.
1292 This allows variables to be manipulated indirectly.
1293 Whenever the nameref variable is referenced, assigned to, unset, or has
1294 its attributes modified (other than using or changing the \fInameref\fP
1295 attribute itself), the
1296 operation is actually performed on the variable specified by the nameref
1298 A nameref is commonly used within shell functions to refer to a variable
1299 whose name is passed as an argument to the function.
1300 For instance, if a variable name is passed to a shell function as its first
1304 .if t \f(CWdeclare -n ref=$1\fP
1305 .if n declare -n ref=$1
1308 inside the function creates a nameref variable \fBref\fP whose value is
1309 the variable name passed as the first argument.
1310 References and assignments to \fBref\fP, and changes to its attributes,
1311 are treated as references, assignments, and attribute modifications
1312 to the variable whose name was passed as \fB$1\fP.
1313 If the control variable in a \fBfor\fP loop has the nameref attribute,
1314 the list of words can be a list of shell variables, and a name reference
1315 will be established for each word in the list, in turn, when the loop is
1317 Array variables cannot be given the \fBnameref\fP attribute.
1318 However, nameref variables can reference array variables and subscripted
1320 Namerefs can be unset using the \fB\-n\fP option to the \fBunset\fP builtin.
1321 Otherwise, if \fBunset\fP is executed with the name of a nameref variable
1322 as an argument, the variable referenced by the nameref variable will be unset.
1323 .SS Positional Parameters
1325 .I positional parameter
1326 is a parameter denoted by one or more
1327 digits, other than the single digit 0. Positional parameters are
1328 assigned from the shell's arguments when it is invoked,
1329 and may be reassigned using the
1331 builtin command. Positional parameters may not be assigned to
1332 with assignment statements. The positional parameters are
1333 temporarily replaced when a shell function is executed (see
1338 When a positional parameter consisting of more than a single
1339 digit is expanded, it must be enclosed in braces (see
1343 .SS Special Parameters
1344 The shell treats several parameters specially. These parameters may
1345 only be referenced; assignment to them is not allowed.
1349 Expands to the positional parameters, starting from one.
1350 When the expansion is not within double quotes, each positional parameter
1351 expands to a separate word.
1352 In contexts where it is performed, those words
1353 are subject to further word splitting and pathname expansion.
1354 When the expansion occurs within double quotes, it expands to a single word
1355 with the value of each parameter separated by the first character of the
1358 special variable. That is, "\fB$*\fP" is equivalent
1359 to "\fB$1\fP\fIc\fP\fB$2\fP\fIc\fP\fB...\fP", where
1361 is the first character of the value of the
1367 is unset, the parameters are separated by spaces.
1371 is null, the parameters are joined without intervening separators.
1374 Expands to the positional parameters, starting from one.
1375 In contexts where word splitting is performed, this expands each
1376 positional parameter to a separate word; if not within double
1377 quotes, these words are subject to word splitting.
1378 In contexts where word splitting is not performed,
1379 this expands to a single word
1380 with each positional parameter separated by a space.
1382 expansion occurs within double quotes, each parameter expands to a
1383 separate word. That is, "\fB$@\fP" is equivalent to
1384 "\fB$1\fP" "\fB$2\fP" ...
1385 If the double-quoted expansion occurs within a word, the expansion of
1386 the first parameter is joined with the beginning part of the original
1387 word, and the expansion of the last parameter is joined with the last
1388 part of the original word.
1389 When there are no positional parameters, "\fB$@\fP" and
1391 expand to nothing (i.e., they are removed).
1394 Expands to the number of positional parameters in decimal.
1397 Expands to the exit status of the most recently executed foreground
1401 Expands to the current option flags as specified upon invocation,
1404 builtin command, or those set by the shell itself
1410 Expands to the process ID of the shell. In a () subshell, it
1411 expands to the process ID of the current shell, not the
1415 Expands to the process ID of the job most recently placed into the
1416 background, whether executed as an asynchronous command or using
1417 the \fBbg\fP builtin (see
1423 Expands to the name of the shell or shell script. This is set at
1424 shell initialization. If
1426 is invoked with a file of commands,
1428 is set to the name of that file. If
1434 is set to the first argument after the string to be
1435 executed, if one is present. Otherwise, it is set
1436 to the filename used to invoke
1438 as given by argument zero.
1441 The following variables are set by the shell:
1446 At shell startup, set to the pathname used to invoke the
1447 shell or shell script being executed as passed in the environment
1449 Subsequently, expands to the last argument to the previous simple
1450 command executed in the foreground, after expansion.
1451 Also set to the full pathname used to invoke each command executed
1452 and placed in the environment exported to that command.
1453 When checking mail, this parameter holds the name of the mail file
1454 currently being checked.
1457 Expands to the full filename used to invoke this instance of
1461 A colon-separated list of enabled shell options. Each word in
1462 the list is a valid argument for the
1466 builtin command (see
1468 .B "SHELL BUILTIN COMMANDS"
1469 below). The options appearing in
1472 are those reported as
1475 If this variable is in the environment when
1477 starts up, each shell option in the list will be enabled before
1478 reading any startup files.
1479 This variable is read-only.
1482 Expands to the process ID of the current \fBbush\fP process.
1483 This differs from \fB$$\fP under certain circumstances, such as subshells
1484 that do not require \fBbush\fP to be re-initialized.
1491 is unset, it loses its special properties, even if it is
1495 An associative array variable whose members correspond to the internal
1496 list of aliases as maintained by the \fBalias\fP builtin.
1497 Elements added to this array appear in the alias list; however,
1498 unsetting array elements currently does not cause aliases to be removed
1499 from the alias list.
1502 is unset, it loses its special properties, even if it is
1506 An array variable whose values are the number of parameters in each
1507 frame of the current \fBbush\fP execution call stack.
1509 parameters to the current subroutine (shell function or script executed
1510 with \fB.\fP or \fBsource\fP) is at the top of the stack.
1511 When a subroutine is executed, the number of parameters passed is pushed onto
1517 only when in extended debugging mode (see the description of the
1522 Setting \fBextdebug\fP after the shell has started to execute a script,
1523 or referencing this variable when \fBextdebug\fP is not set,
1524 may result in inconsistent values.
1527 An array variable containing all of the parameters in the current \fBbush\fP
1528 execution call stack. The final parameter of the last subroutine call
1529 is at the top of the stack; the first parameter of the initial call is
1530 at the bottom. When a subroutine is executed, the parameters supplied
1537 only when in extended debugging mode
1538 (see the description of the
1543 Setting \fBextdebug\fP after the shell has started to execute a script,
1544 or referencing this variable when \fBextdebug\fP is not set,
1545 may result in inconsistent values.
1548 When referenced, this variable expands to the name of the shell or shell
1549 script (identical to
1551 see the description of special parameter 0 above).
1554 causes the value assigned to also be assigned to \fB$0\fP.
1557 is unset, it loses its special properties, even if it is
1561 An associative array variable whose members correspond to the internal
1562 hash table of commands as maintained by the \fBhash\fP builtin.
1563 Elements added to this array appear in the hash table; however,
1564 unsetting array elements currently does not cause command names to be removed
1565 from the hash table.
1568 is unset, it loses its special properties, even if it is
1572 The command currently being executed or about to be executed, unless the
1573 shell is executing a command as the result of a trap,
1574 in which case it is the command executing at the time of the trap.
1577 is unset, it loses its special properties, even if it is
1580 .B BUSH_EXECUTION_STRING
1581 The command argument to the \fB\-c\fP invocation option.
1584 An array variable whose members are the line numbers in source files
1585 where each corresponding member of
1589 \fB${BUSH_LINENO[\fP\fI$i\fP\fB]}\fP is the line number in the source
1590 file (\fB${BUSH_SOURCE[\fP\fI$i+1\fP\fB]}\fP) where
1591 \fB${FUNCNAME[\fP\fI$i\fP\fB]}\fP was called
1592 (or \fB${BUSH_LINENO[\fP\fI$i-1\fP\fB]}\fP if referenced within another
1597 to obtain the current line number.
1599 .B BUSH_LOADABLES_PATH
1600 A colon-separated list of directories in which the shell looks for
1601 dynamically loadable builtins specified by the
1606 An array variable whose members are assigned by the \fB=~\fP binary
1607 operator to the \fB[[\fP conditional command.
1608 The element with index 0 is the portion of the string
1609 matching the entire regular expression.
1610 The element with index \fIn\fP is the portion of the
1611 string matching the \fIn\fPth parenthesized subexpression.
1614 An array variable whose members are the source filenames
1615 where the corresponding shell function names in the
1618 array variable are defined.
1620 \fB${FUNCNAME[\fP\fI$i\fP\fB]}\fP is defined in the file
1621 \fB${BUSH_SOURCE[\fP\fI$i\fP\fB]}\fP and called from
1622 \fB${BUSH_SOURCE[\fP\fI$i+1\fP\fB]}\fP.
1625 Incremented by one within each subshell or subshell environment when
1626 the shell begins executing in that environment.
1627 The initial value is 0.
1630 is unset, it loses its special properties, even if it is
1634 A readonly array variable whose members hold version information for
1637 The values assigned to the array members are as follows:
1641 .B BUSH_VERSINFO[\fR0\fP]
1642 The major version number (the \fIrelease\fP).
1644 .B BUSH_VERSINFO[\fR1\fP]
1645 The minor version number (the \fIversion\fP).
1647 .B BUSH_VERSINFO[\fR2\fP]
1650 .B BUSH_VERSINFO[\fR3\fP]
1653 .B BUSH_VERSINFO[\fR4\fP]
1654 The release status (e.g., \fIbeta1\fP).
1656 .B BUSH_VERSINFO[\fR5\fP]
1663 Expands to a string describing the version of this instance of
1667 An index into \fB${COMP_WORDS}\fP of the word containing the current
1669 This variable is available only in shell functions invoked by the
1670 programmable completion facilities (see \fBProgrammable Completion\fP
1674 The key (or final key of a key sequence) used to invoke the current
1675 completion function.
1678 The current command line.
1679 This variable is available only in shell functions and external
1680 commands invoked by the
1681 programmable completion facilities (see \fBProgrammable Completion\fP
1685 The index of the current cursor position relative to the beginning of
1686 the current command.
1687 If the current cursor position is at the end of the current command,
1688 the value of this variable is equal to \fB${#COMP_LINE}\fP.
1689 This variable is available only in shell functions and external
1690 commands invoked by the
1691 programmable completion facilities (see \fBProgrammable Completion\fP
1695 Set to an integer value corresponding to the type of completion attempted
1696 that caused a completion function to be called:
1697 \fITAB\fP, for normal completion,
1698 \fI?\fP, for listing completions after successive tabs,
1699 \fI!\fP, for listing alternatives on partial word completion,
1700 \fI@\fP, to list completions if the word is not unmodified,
1702 \fI%\fP, for menu completion.
1703 This variable is available only in shell functions and external
1704 commands invoked by the
1705 programmable completion facilities (see \fBProgrammable Completion\fP
1709 The set of characters that the \fBreadline\fP library treats as word
1710 separators when performing word completion.
1714 is unset, it loses its special properties, even if it is
1718 An array variable (see \fBArrays\fP below) consisting of the individual
1719 words in the current command line.
1720 The line is split into words as \fBreadline\fP would split it, using
1724 This variable is available only in shell functions invoked by the
1725 programmable completion facilities (see \fBProgrammable Completion\fP
1729 An array variable (see \fBArrays\fP below) created to hold the file descriptors
1730 for output from and input to an unnamed coprocess (see \fBCoprocesses\fP
1734 An array variable (see
1736 below) containing the current contents of the directory stack.
1737 Directories appear in the stack in the order they are displayed by the
1740 Assigning to members of this array variable may be used to modify
1741 directories already in the stack, but the
1745 builtins must be used to add and remove directories.
1746 Assignment to this variable will not change the current directory.
1750 is unset, it loses its special properties, even if it is
1754 Each time this parameter is referenced, it expands to the number of seconds
1755 since the Unix Epoch (see \fItime\fP\fR(3)\fP) as a floating point value
1756 with micro-second granularity.
1764 is unset, it loses its special properties, even if it is
1768 Each time this parameter is referenced, it expands to the number of seconds
1769 since the Unix Epoch (see \fItime\fP\fR(3)\fP).
1777 is unset, it loses its special properties, even if it is
1781 Expands to the effective user ID of the current user, initialized at
1782 shell startup. This variable is readonly.
1785 An array variable containing the names of all shell functions
1786 currently in the execution call stack.
1787 The element with index 0 is the name of any currently-executing
1789 The bottom-most element (the one with the highest index) is
1790 .if t \f(CW"main"\fP.
1792 This variable exists only when a shell function is executing.
1800 is unset, it loses its special properties, even if it is
1804 This variable can be used with \fBBUSH_LINENO\fP and \fBBUSH_SOURCE\fP.
1805 Each element of \fBFUNCNAME\fP has corresponding elements in
1806 \fBBUSH_LINENO\fP and \fBBUSH_SOURCE\fP to describe the call stack.
1807 For instance, \fB${FUNCNAME[\fP\fI$i\fP\fB]}\fP was called from the file
1808 \fB${BUSH_SOURCE[\fP\fI$i+1\fP\fB]}\fP at line number
1809 \fB${BUSH_LINENO[\fP\fI$i\fP\fB]}\fP.
1810 The \fBcaller\fP builtin displays the current call stack using this
1814 An array variable containing the list of groups of which the current
1823 is unset, it loses its special properties, even if it is
1827 The history number, or index in the history list, of the current
1836 is unset, it loses its special properties, even if it is
1840 Automatically set to the name of the current host.
1843 Automatically set to a string that uniquely
1844 describes the type of machine on which
1847 The default is system-dependent.
1850 Each time this parameter is referenced, the shell substitutes
1851 a decimal number representing the current sequential line number
1852 (starting with 1) within a script or function. When not in a
1853 script or function, the value substituted is not guaranteed to
1858 is unset, it loses its special properties, even if it is
1862 Automatically set to a string that fully describes the system
1865 is executing, in the standard GNU \fIcpu-company-system\fP format.
1866 The default is system-dependent.
1869 An array variable (see \fBArrays\fP below) created to hold the text
1870 read by the \fBmapfile\fP builtin when no variable name is supplied.
1873 The previous working directory as set by the
1878 The value of the last option argument processed by the
1880 builtin command (see
1882 .B SHELL BUILTIN COMMANDS
1886 The index of the next argument to be processed by the
1888 builtin command (see
1890 .B SHELL BUILTIN COMMANDS
1894 Automatically set to a string that
1895 describes the operating system on which
1898 The default is system-dependent.
1901 An array variable (see
1903 below) containing a list of exit status values from the processes
1904 in the most-recently-executed foreground pipeline (which may
1905 contain only a single command).
1908 The process ID of the shell's parent. This variable is readonly.
1911 The current working directory as set by the
1916 Each time this parameter is referenced, it expands to a random integer
1917 between 0 and 32767.
1922 initializes (seeds) the sequence of random numbers.
1926 is unset, it loses its special properties, even if it is
1932 line buffer, for use with
1933 .if t \f(CWbind -x\fP
1937 .B "SHELL BUILTIN COMMANDS"
1941 The position of the mark (saved insertion point) in the
1943 line buffer, for use with
1944 .if t \f(CWbind -x\fP
1948 .B "SHELL BUILTIN COMMANDS"
1950 The characters between the insertion point and the mark are often
1951 called the \fIregion\fP.
1954 The position of the insertion point in the
1956 line buffer, for use with
1957 .if t \f(CWbind -x\fP
1961 .B "SHELL BUILTIN COMMANDS"
1965 Set to the line of input read by the
1967 builtin command when no arguments are supplied.
1970 Each time this parameter is
1971 referenced, the number of seconds since shell invocation is returned. If a
1972 value is assigned to
1975 the value returned upon subsequent
1977 the number of seconds since the assignment plus the value assigned.
1978 The number of seconds at shell invocation and the current time is always
1979 determined by querying the system clock.
1983 is unset, it loses its special properties, even if it is
1987 A colon-separated list of enabled shell options. Each word in
1988 the list is a valid argument for the
1992 builtin command (see
1994 .B "SHELL BUILTIN COMMANDS"
1995 below). The options appearing in
1998 are those reported as
2001 If this variable is in the environment when
2003 starts up, each shell option in the list will be enabled before
2004 reading any startup files.
2005 This variable is read-only.
2008 Incremented by one each time an instance of
2013 This variable expands to a 32-bit pseudo-random number each time it is
2014 referenced. The random number generator is not linear on systems that
2015 support \f(CW/dev/urandom\fP or \fIarc4random\fP, so each returned number
2016 has no relationship to the numbers preceding it.
2017 The random number generator cannot be seeded, so assignments to this
2018 variable have no effect.
2022 is unset, it loses its special properties,
2023 even if it is subsequently reset.
2026 Expands to the user ID of the current user, initialized at shell startup.
2027 This variable is readonly.
2030 The following variables are used by the shell. In some cases,
2032 assigns a default value to a variable; these cases are noted
2038 The value is used to set the shell's compatibility level.
2041 .B SHELL COMPATIBILITY MODE
2042 below for a description of the various compatibility
2043 levels and their effects.
2044 The value may be a decimal number (e.g., 4.2) or an integer (e.g., 42)
2045 corresponding to the desired compatibility level.
2046 If \fBBUSH_COMPAT\fP is unset or set to the empty string, the compatibility
2047 level is set to the default for the current version.
2048 If \fBBUSH_COMPAT\fP is set to a value that is not one of the valid
2049 compatibility levels, the shell prints an error message and sets the
2050 compatibility level to the default for the current version.
2051 The valid values correspond to the compatibility levels
2052 described below under
2054 .BR BSHELL COMPATIBILITY MODE .
2055 For example, 4.2 and 42 are valid values that correspond
2056 to the \fBcompat42\fP \fBshopt\fP option
2057 and set the compatibility level to 42.
2058 The current version is also a valid value.
2061 If this parameter is set when \fBbush\fP is executing a shell script,
2062 its value is interpreted as a filename containing commands to
2063 initialize the shell, as in
2068 is subjected to parameter expansion, command substitution, and arithmetic
2069 expansion before being interpreted as a filename.
2072 is not used to search for the resultant filename.
2075 If set to an integer corresponding to a valid file descriptor, \fBbush\fP
2076 will write the trace output generated when
2077 .if t \f(CWset -x\fP
2079 is enabled to that file descriptor.
2080 The file descriptor is closed when
2083 is unset or assigned a new value.
2087 or assigning it the empty string causes the
2088 trace output to be sent to the standard error.
2092 to 2 (the standard error file
2093 descriptor) and then unsetting it will result in the standard error
2097 The search path for the
2100 This is a colon-separated list of directories in which the shell looks
2101 for destination directories specified by the
2105 .if t \f(CW".:~:/usr"\fP.
2109 Set the number of exited child status values for the shell to remember.
2110 Bush will not allow this value to be decreased below a POSIX-mandated
2111 minimum, and there is a maximum value (currently 8192) that this may
2113 The minimum value is system-dependent.
2116 Used by the \fBselect\fP compound command to determine the terminal width
2117 when printing selection lists.
2118 Automatically set if the
2120 option is enabled or in an interactive shell upon receipt of a
2125 An array variable from which \fBbush\fP reads the possible completions
2126 generated by a shell function invoked by the programmable completion
2127 facility (see \fBProgrammable Completion\fP below).
2128 Each array element contains one possible completion.
2131 If \fBbush\fP finds this variable in the environment when the shell starts
2135 it assumes that the shell is running in an Emacs shell buffer and disables
2139 Expanded and executed similarly to
2142 (see \fBINVOCATION\fP above)
2143 when an interactive shell is invoked in \fIposix mode\fP.
2146 A colon-separated list of shell patterns (see \fBPattern Matching\fP)
2147 defining the list of filenames to be ignored by command search using
2149 Files whose full pathnames match one of these patterns are not considered
2150 executable files for the purposes of completion and command execution
2151 via \fBPATH\fP lookup.
2152 This does not affect the behavior of the \fB[\fP, \fBtest\fP, and \fB[[\fP
2154 Full pathnames in the command hash table are not subject to \fBEXECIGNORE\fP.
2155 Use this variable to ignore shared library files that have the executable
2156 bit set, but are not executable files.
2157 The pattern matching honors the setting of the \fBextglob\fP shell
2161 The default editor for the
2166 A colon-separated list of suffixes to ignore when performing
2167 filename completion (see
2171 A filename whose suffix matches one of the entries in
2174 is excluded from the list of matched filenames.
2176 .if t \f(CW".o:~"\fP.
2180 If set to a numeric value greater than 0, defines a maximum function
2181 nesting level. Function invocations that exceed this nesting level
2182 will cause the current command to abort.
2185 A colon-separated list of patterns defining the set of file names to
2186 be ignored by pathname expansion.
2187 If a file name matched by a pathname expansion pattern also matches one
2191 it is removed from the list of matches.
2194 A colon-separated list of values controlling how commands are saved on
2196 If the list of values includes
2198 lines which begin with a
2200 character are not saved in the history list.
2203 causes lines matching the previous history entry to not be saved.
2206 is shorthand for \fIignorespace\fP and \fIignoredups\fP.
2209 causes all previous lines matching the current line to be removed from
2210 the history list before that line is saved.
2211 Any value not in the above list is ignored.
2215 is unset, or does not include a valid value,
2216 all lines read by the shell parser are saved on the history list,
2217 subject to the value of
2220 The second and subsequent lines of a multi-line compound command are
2221 not tested, and are added to the history regardless of the value of
2226 The name of the file in which command history is saved (see
2229 below). The default value is \fI~/.bush_history\fP. If unset, the
2230 command history is not saved when a shell exits.
2233 The maximum number of lines contained in the history file. When this
2234 variable is assigned a value, the history file is truncated, if
2236 to contain no more than that number of lines by removing the oldest entries.
2237 The history file is also truncated to this size after
2238 writing it when a shell exits.
2239 If the value is 0, the history file is truncated to zero size.
2240 Non-numeric values and numeric values less than zero inhibit truncation.
2241 The shell sets the default value to the value of \fBHISTSIZE\fP
2242 after reading any startup files.
2245 A colon-separated list of patterns used to decide which command lines
2246 should be saved on the history list. Each pattern is anchored at the
2247 beginning of the line and must match the complete line (no implicit
2248 `\fB*\fP' is appended). Each pattern is tested against the line
2249 after the checks specified by
2253 In addition to the normal shell pattern matching characters, `\fB&\fP'
2254 matches the previous history line. `\fB&\fP' may be escaped using a
2255 backslash; the backslash is removed before attempting a match.
2256 The second and subsequent lines of a multi-line compound command are
2257 not tested, and are added to the history regardless of the value of
2260 The pattern matching honors the setting of the \fBextglob\fP shell
2264 The number of commands to remember in the command history (see
2268 If the value is 0, commands are not saved in the history list.
2269 Numeric values less than zero result in every command being saved
2270 on the history list (there is no limit).
2271 The shell sets the default value to 500 after reading any startup files.
2274 If this variable is set and not null, its value is used as a format string
2275 for \fIstrftime\fP(3) to print the time stamp associated with each history
2276 entry displayed by the \fBhistory\fP builtin.
2277 If this variable is set, time stamps are written to the history file so
2278 they may be preserved across shell sessions.
2279 This uses the history comment character to distinguish timestamps from
2280 other history lines.
2283 The home directory of the current user; the default argument for the
2284 \fBcd\fP builtin command.
2285 The value of this variable is also used when performing tilde expansion.
2288 Contains the name of a file in the same format as
2290 that should be read when the shell needs to complete a
2292 The list of possible hostname completions may be changed while the
2294 the next time hostname completion is attempted after the
2297 adds the contents of the new file to the existing list.
2301 is set, but has no value, or does not name a readable file,
2302 \fBbush\fP attempts to read
2304 to obtain the list of possible hostname completions.
2308 is unset, the hostname list is cleared.
2312 .I Internal Field Separator
2314 for word splitting after expansion and to
2315 split lines into words with the
2317 builtin command. The default value is
2318 ``<space><tab><newline>''.
2322 action of an interactive shell on receipt of an
2325 character as the sole input. If set, the value is the number of
2329 characters which must be
2330 typed as the first characters on an input line before
2332 exits. If the variable exists but does not have a numeric value, or
2333 has no value, the default value is 10. If it does not exist,
2336 signifies the end of input to the shell.
2339 The filename for the
2341 startup file, overriding the default of
2349 If this variable appears in the environment when the shell starts,
2350 \fBbush\fP assumes that it is running inside an Emacs shell buffer
2351 and may disable line editing, depending on the value of \fBTERM\fP.
2354 Used to determine the locale category for any category not specifically
2355 selected with a variable starting with \fBLC_\fP.
2358 This variable overrides the value of
2362 \fBLC_\fP variable specifying a locale category.
2365 This variable determines the collation order used when sorting the
2366 results of pathname expansion, and determines the behavior of range
2367 expressions, equivalence classes, and collating sequences within
2368 pathname expansion and pattern matching.
2371 This variable determines the interpretation of characters and the
2372 behavior of character classes within pathname expansion and pattern
2376 This variable determines the locale used to translate double-quoted
2377 strings preceded by a \fB$\fP.
2380 This variable determines the locale category used for number formatting.
2383 This variable determines the locale category used for data and time
2387 Used by the \fBselect\fP compound command to determine the column length
2388 for printing selection lists.
2389 Automatically set if the
2391 option is enabled or in an interactive shell upon receipt of a
2396 If this parameter is set to a file or directory name and the
2399 variable is not set,
2401 informs the user of the arrival of mail in the specified file or
2402 Maildir-format directory.
2408 checks for mail. The default is 60 seconds. When it is time to check
2409 for mail, the shell does so before displaying the primary prompt.
2410 If this variable is unset, or set to a value that is not a number
2411 greater than or equal to zero, the shell disables mail checking.
2414 A colon-separated list of filenames to be checked for mail.
2415 The message to be printed when mail arrives in a particular file
2416 may be specified by separating the filename from the message with a `?'.
2417 When used in the text of the message, \fB$_\fP expands to the name of
2418 the current mailfile.
2422 \fBMAILPATH\fP=\(aq/var/mail/bfox?"You have mail":~/shell\-mail?"$_ has mail!"\(aq
2425 can be configured to supply
2426 a default value for this variable (there is no value by default),
2427 but the location of the user
2428 mail files that it uses is system dependent (e.g., /var/mail/\fB$USER\fP).
2432 If set to the value 1,
2434 displays error messages generated by the
2436 builtin command (see
2438 .B SHELL BUILTIN COMMANDS
2442 is initialized to 1 each time the shell is invoked or a shell
2446 The search path for commands. It
2447 is a colon-separated list of directories in which
2448 the shell looks for commands (see
2450 .B COMMAND EXECUTION
2452 A zero-length (null) directory name in the value of
2455 indicates the current directory.
2456 A null directory name may appear as two adjacent colons, or as an initial
2458 The default path is system-dependent,
2459 and is set by the administrator who installs
2463 .if t \f(CW/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin\fP.
2464 .if n ``/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin''.
2468 If this variable is in the environment when \fBbush\fP starts, the shell
2469 enters \fIposix mode\fP before reading the startup files, as if the
2471 invocation option had been supplied. If it is set while the shell is
2472 running, \fBbush\fP enables \fIposix mode\fP, as if the command
2473 .if t \f(CWset -o posix\fP
2474 .if n \fIset -o posix\fP
2476 When the shell enters \fIposix mode\fP, it sets this variable if it was
2480 If this variable is set, and is an array,
2481 the value of each set element is executed as a command
2482 prior to issuing each primary prompt.
2483 If this is set but not an array variable,
2484 its value is used as a command to execute instead.
2487 If set to a number greater than zero, the value is used as the number of
2488 trailing directory components to retain when expanding the \fB\ew\fP and
2489 \fB\eW\fP prompt string escapes (see
2492 below). Characters removed are replaced with an ellipsis.
2495 The value of this parameter is expanded (see
2498 below) and displayed by interactive shells after reading a command
2499 and before the command is executed.
2502 The value of this parameter is expanded (see
2505 below) and used as the primary prompt string. The default value is
2506 ``\fB\es\-\ev\e$ \fP''.
2509 The value of this parameter is expanded as with
2512 and used as the secondary prompt string. The default is
2516 The value of this parameter is used as the prompt for the
2524 The value of this parameter is expanded as with
2527 and the value is printed before each command
2529 displays during an execution trace. The first character of
2530 the expanded value of
2533 is replicated multiple times, as necessary, to indicate multiple
2534 levels of indirection. The default is ``\fB+ \fP''.
2537 This variable expands to the full pathname to the shell.
2538 If it is not set when the shell starts,
2540 assigns to it the full pathname of the current user's login shell.
2543 The value of this parameter is used as a format string specifying
2544 how the timing information for pipelines prefixed with the
2546 reserved word should be displayed.
2547 The \fB%\fP character introduces an escape sequence that is
2548 expanded to a time value or other information.
2549 The escape sequences and their meanings are as follows; the
2550 braces denote optional portions.
2559 The elapsed time in seconds.
2562 The number of CPU seconds spent in user mode.
2565 The number of CPU seconds spent in system mode.
2568 The CPU percentage, computed as (%U + %S) / %R.
2572 The optional \fIp\fP is a digit specifying the \fIprecision\fP,
2573 the number of fractional digits after a decimal point.
2574 A value of 0 causes no decimal point or fraction to be output.
2575 At most three places after the decimal point may be specified;
2576 values of \fIp\fP greater than 3 are changed to 3.
2577 If \fIp\fP is not specified, the value 3 is used.
2579 The optional \fBl\fP specifies a longer format, including
2580 minutes, of the form \fIMM\fPm\fISS\fP.\fIFF\fPs.
2581 The value of \fIp\fP determines whether or not the fraction is
2584 If this variable is not set, \fBbush\fP acts as if it had the
2585 value \fB$\(aq\enreal\et%3lR\enuser\et%3lU\ensys\et%3lS\(aq\fP.
2586 If the value is null, no timing information is displayed.
2587 A trailing newline is added when the format string is displayed.
2591 If set to a value greater than zero,
2595 default timeout for the \fBread\fP builtin.
2596 The \fBselect\fP command terminates if input does not arrive
2600 seconds when input is coming from a terminal.
2601 In an interactive shell, the value is interpreted as the
2602 number of seconds to wait for a line of input after issuing the
2605 terminates after waiting for that number of seconds if a complete
2606 line of input does not arrive.
2609 If set, \fBbush\fP uses its value as the name of a directory in which
2610 \fBbush\fP creates temporary files for the shell's use.
2613 This variable controls how the shell interacts with the user and
2614 job control. If this variable is set, single word simple
2615 commands without redirections are treated as candidates for resumption
2616 of an existing stopped job. There is no ambiguity allowed; if there is
2617 more than one job beginning with the string typed, the job most recently
2618 accessed is selected. The
2620 of a stopped job, in this context, is the command line used to
2624 the string supplied must match the name of a stopped job exactly;
2627 the string supplied needs to match a substring of the name of a
2630 value provides functionality analogous to the
2635 below). If set to any other value, the supplied string must
2636 be a prefix of a stopped job's name; this provides functionality
2637 analogous to the \fB%\fP\fIstring\fP job identifier.
2640 The two or three characters which control history expansion
2641 and tokenization (see
2643 .B HISTORY EXPANSION
2644 below). The first character is the \fIhistory expansion\fP character,
2645 the character which signals the start of a history
2646 expansion, normally `\fB!\fP'.
2647 The second character is the \fIquick substitution\fP
2648 character, which is used as shorthand for re-running the previous
2649 command entered, substituting one string for another in the command.
2650 The default is `\fB^\fP'.
2651 The optional third character is the character
2652 which indicates that the remainder of the line is a comment when found
2653 as the first character of a word, normally `\fB#\fP'. The history
2654 comment character causes history substitution to be skipped for the
2655 remaining words on the line. It does not necessarily cause the shell
2656 parser to treat the rest of the line as a comment.
2660 provides one-dimensional indexed and associative array variables.
2661 Any variable may be used as an indexed array; the
2663 builtin will explicitly declare an array.
2665 limit on the size of an array, nor any requirement that members
2666 be indexed or assigned contiguously.
2667 Indexed arrays are referenced using integers (including arithmetic
2668 expressions) and are zero-based; associative arrays are referenced
2669 using arbitrary strings.
2670 Unless otherwise noted, indexed array indices must be non-negative integers.
2672 An indexed array is created automatically if any variable is assigned to
2673 using the syntax \fIname\fP[\fIsubscript\fP]=\fIvalue\fP. The
2675 is treated as an arithmetic expression that must evaluate to a number.
2676 To explicitly declare an indexed array, use
2677 .B declare \-a \fIname\fP
2680 .B SHELL BUILTIN COMMANDS
2682 .B declare \-a \fIname\fP[\fIsubscript\fP]
2683 is also accepted; the \fIsubscript\fP is ignored.
2685 Associative arrays are created using
2686 .BR "declare \-A \fIname\fP" .
2689 specified for an array variable using the
2693 builtins. Each attribute applies to all members of an array.
2695 Arrays are assigned to using compound assignments of the form
2696 \fIname\fP=\fB(\fPvalue\fI1\fP ... value\fIn\fP\fB)\fP, where each
2697 \fIvalue\fP may be of the form [\fIsubscript\fP]=\fIstring\fP.
2698 Indexed array assignments do not require anything but \fIstring\fP.
2699 Each \fIvalue\fP in the list is expanded using all the shell expansions
2700 described below under
2703 When assigning to indexed arrays, if the optional brackets and subscript
2704 are supplied, that index is assigned to;
2705 otherwise the index of the element assigned is the last index assigned
2706 to by the statement plus one. Indexing starts at zero.
2708 When assigning to an associative array, the words in a compound assignment
2709 may be either assignment statements, for which the subscript is required,
2710 or a list of words that is interpreted as a sequence of alternating keys
2712 \fIname\fP=\fB( \fP\fIkey1 value1 key2 value2\fP ...\fB)\fP.
2713 These are treated identically to
2714 \fIname\fP=\fB(\fP [\fIkey1\fP]=\fIvalue1\fP [\fIkey2\fP]=\fIvalue2\fP ...\fB)\fP.
2715 The first word in the list determines how the remaining words
2716 are interpreted; all assignments in a list must be of the same type.
2717 When using key/value pairs, the keys may not be missing or empty;
2718 a final missing value is treated like the empty string.
2720 This syntax is also accepted by the
2722 builtin. Individual array elements may be assigned to using the
2723 \fIname\fP[\fIsubscript\fP]=\fIvalue\fP syntax introduced above.
2724 When assigning to an indexed array, if
2726 is subscripted by a negative number, that number is
2727 interpreted as relative to one greater than the maximum index of
2728 \fIname\fP, so negative indices count back from the end of the
2729 array, and an index of \-1 references the last element.
2731 Any element of an array may be referenced using
2732 ${\fIname\fP[\fIsubscript\fP]}. The braces are required to avoid
2733 conflicts with pathname expansion. If
2734 \fIsubscript\fP is \fB@\fP or \fB*\fP, the word expands to
2735 all members of \fIname\fP. These subscripts differ only when the
2736 word appears within double quotes. If the word is double-quoted,
2737 ${\fIname\fP[*]} expands to a single
2738 word with the value of each array member separated by the first
2742 special variable, and ${\fIname\fP[@]} expands each element of
2743 \fIname\fP to a separate word. When there are no array members,
2744 ${\fIname\fP[@]} expands to nothing.
2745 If the double-quoted expansion occurs within a word, the expansion of
2746 the first parameter is joined with the beginning part of the original
2747 word, and the expansion of the last parameter is joined with the last
2748 part of the original word.
2749 This is analogous to the expansion
2750 of the special parameters \fB*\fP and \fB@\fP (see
2751 .B Special Parameters
2752 above). ${#\fIname\fP[\fIsubscript\fP]} expands to the length of
2753 ${\fIname\fP[\fIsubscript\fP]}. If \fIsubscript\fP is \fB*\fP or
2754 \fB@\fP, the expansion is the number of elements in the array.
2757 used to reference an element of an indexed array
2758 evaluates to a number less than zero, it is
2759 interpreted as relative to one greater than the maximum index of the array,
2760 so negative indices count back from the end of the
2761 array, and an index of \-1 references the last element.
2763 Referencing an array variable without a subscript is equivalent to
2764 referencing the array with a subscript of 0.
2765 Any reference to a variable using a valid subscript is legal, and
2767 will create an array if necessary.
2769 An array variable is considered set if a subscript has been assigned a
2770 value. The null string is a valid value.
2772 It is possible to obtain the keys (indices) of an array as well as the values.
2773 ${\fB!\fP\fIname\fP[\fI@\fP]} and ${\fB!\fP\fIname\fP[\fI*\fP]}
2774 expand to the indices assigned in array variable \fIname\fP.
2775 The treatment when in double quotes is similar to the expansion of the
2776 special parameters \fI@\fP and \fI*\fP within double quotes.
2780 builtin is used to destroy arrays. \fBunset\fP \fIname\fP[\fIsubscript\fP]
2781 destroys the array element at index \fIsubscript\fP,
2782 for both indexed and associative arrays.
2783 Negative subscripts to indexed arrays are interpreted as described above.
2784 Unsetting the last element of an array variable does not unset the variable.
2785 \fBunset\fP \fIname\fP, where \fIname\fP is an array, or
2786 \fBunset\fP \fIname\fP[\fIsubscript\fP], where
2787 \fIsubscript\fP is \fB*\fP or \fB@\fP, removes the entire array.
2789 When using a variable name with a subscript as an argument to a command,
2790 such as with \fBunset\fP, without using the word expansion syntax
2791 described above, the argument is subject to pathname expansion.
2792 If pathname expansion is not desired, the argument should be quoted.
2799 builtins each accept a
2801 option to specify an indexed array and a
2803 option to specify an associative array.
2804 If both options are supplied,
2811 option to assign a list of words read from the standard input
2816 builtins display array values in a way that allows them to be
2817 reused as assignments.
2819 Expansion is performed on the command line after it has been split into
2820 words. There are seven kinds of expansion performed:
2821 .IR "brace expansion" ,
2822 .IR "tilde expansion" ,
2823 .IR "parameter and variable expansion" ,
2824 .IR "command substitution" ,
2825 .IR "arithmetic expansion" ,
2826 .IR "word splitting" ,
2828 .IR "pathname expansion" .
2830 The order of expansions is:
2832 tilde expansion, parameter and variable expansion, arithmetic expansion,
2833 and command substitution (done in a left-to-right fashion);
2835 and pathname expansion.
2837 On systems that can support it, there is an additional expansion
2838 available: \fIprocess substitution\fP.
2839 This is performed at the
2840 same time as tilde, parameter, variable, and arithmetic expansion and
2841 command substitution.
2843 After these expansions are performed, quote characters present in the
2844 original word are removed unless they have been quoted themselves
2845 (\fIquote removal\fP).
2847 Only brace expansion, word splitting, and pathname expansion
2848 can increase the number of words of the expansion; other expansions
2849 expand a single word to a single word.
2850 The only exceptions to this are the expansions of
2851 "\fB$@\fP" and "\fB${\fP\fIname\fP\fB[@]}\fP",
2852 and, in most cases, \fB$*\fP and \fB${\fP\fIname\fP\fB[*]}\fP
2853 as explained above (see
2857 .I "Brace expansion"
2858 is a mechanism by which arbitrary strings
2859 may be generated. This mechanism is similar to
2860 \fIpathname expansion\fP, but the filenames generated
2861 need not exist. Patterns to be brace expanded take
2862 the form of an optional
2864 followed by either a series of comma-separated strings or
2865 a sequence expression between a pair of braces, followed by
2868 The preamble is prefixed to each string contained
2869 within the braces, and the postscript is then appended
2870 to each resulting string, expanding left to right.
2872 Brace expansions may be nested. The results of each expanded
2873 string are not sorted; left to right order is preserved.
2874 For example, a\fB{\fPd,c,b\fB}\fPe expands into `ade ace abe'.
2876 A sequence expression takes the form
2877 \fB{\fP\fIx\fP\fB..\fP\fIy\fP\fB[..\fP\fIincr\fP\fB]}\fP,
2878 where \fIx\fP and \fIy\fP are either integers or single characters,
2879 and \fIincr\fP, an optional increment, is an integer.
2880 When integers are supplied, the expression expands to each number between
2881 \fIx\fP and \fIy\fP, inclusive.
2882 Supplied integers may be prefixed with \fI0\fP to force each term to have the
2884 When either \fIx\fP or \fPy\fP begins with a zero, the shell
2885 attempts to force all generated terms to contain the same number of digits,
2886 zero-padding where necessary.
2887 When characters are supplied, the expression expands to each character
2888 lexicographically between \fIx\fP and \fIy\fP, inclusive,
2889 using the default C locale.
2890 Note that both \fIx\fP and \fIy\fP must be of the same type.
2891 When the increment is supplied, it is used as the difference between
2892 each term. The default increment is 1 or \-1 as appropriate.
2894 Brace expansion is performed before any other expansions,
2895 and any characters special to other expansions are preserved
2896 in the result. It is strictly textual.
2898 does not apply any syntactic interpretation to the context of the
2899 expansion or the text between the braces.
2901 A correctly-formed brace expansion must contain unquoted opening
2902 and closing braces, and at least one unquoted comma or a valid
2903 sequence expression.
2904 Any incorrectly formed brace expansion is left unchanged.
2905 A \fB{\fP or \fB,\fP may be quoted with a backslash to prevent its
2906 being considered part of a brace expression.
2907 To avoid conflicts with parameter expansion, the string \fB${\fP
2908 is not considered eligible for brace expansion, and inhibits brace
2909 expansion until the closing \fB}\fP.
2911 This construct is typically used as shorthand when the common
2912 prefix of the strings to be generated is longer than in the
2916 mkdir /usr/local/src/bush/{old,new,dist,bugs}
2920 chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}
2923 Brace expansion introduces a slight incompatibility with
2924 historical versions of
2927 does not treat opening or closing braces specially when they
2928 appear as part of a word, and preserves them in the output.
2930 removes braces from words as a consequence of brace
2931 expansion. For example, a word entered to
2934 appears identically in the output. The same word is
2939 If strict compatibility with
2945 option or disable brace expansion with the
2951 .B SHELL BUILTIN COMMANDS
2954 If a word begins with an unquoted tilde character (`\fB~\fP'), all of
2955 the characters preceding the first unquoted slash (or all characters,
2956 if there is no unquoted slash) are considered a \fItilde-prefix\fP.
2957 If none of the characters in the tilde-prefix are quoted, the
2958 characters in the tilde-prefix following the tilde are treated as a
2959 possible \fIlogin name\fP.
2960 If this login name is the null string, the tilde is replaced with the
2961 value of the shell parameter
2967 is unset, the home directory of the user executing the shell is
2968 substituted instead.
2969 Otherwise, the tilde-prefix is replaced with the home directory
2970 associated with the specified login name.
2972 If the tilde-prefix is a `~+', the value of the shell variable
2975 replaces the tilde-prefix.
2976 If the tilde-prefix is a `~\-', the value of the shell variable
2979 if it is set, is substituted.
2980 If the characters following the tilde in the tilde-prefix consist
2981 of a number \fIN\fP, optionally prefixed
2982 by a `+' or a `\-', the tilde-prefix is replaced with the corresponding
2983 element from the directory stack, as it would be displayed by the
2985 builtin invoked with the tilde-prefix as an argument.
2986 If the characters following the tilde in the tilde-prefix consist of a
2987 number without a leading `+' or `\-', `+' is assumed.
2989 If the login name is invalid, or the tilde expansion fails, the word
2992 Each variable assignment is checked for unquoted tilde-prefixes immediately
2997 In these cases, tilde expansion is also performed.
2998 Consequently, one may use filenames with tildes in assignments to
3006 and the shell assigns the expanded value.
3008 Bush also performs tilde expansion on words satisfying the conditions of
3009 variable assignments (as described above under
3012 when they appear as arguments to simple commands.
3013 Bush does not do this, except for the \fIdeclaration\fP commands listed
3014 above, when in \fIposix mode\fP.
3015 .SS Parameter Expansion
3016 The `\fB$\fP' character introduces parameter expansion,
3017 command substitution, or arithmetic expansion. The parameter name
3018 or symbol to be expanded may be enclosed in braces, which
3019 are optional but serve to protect the variable to be expanded from
3020 characters immediately following it which could be
3021 interpreted as part of the name.
3023 When braces are used, the matching ending brace is the first `\fB}\fP'
3024 not escaped by a backslash or within a quoted string, and not within an
3025 embedded arithmetic expansion, command substitution, or parameter
3031 The value of \fIparameter\fP is substituted. The braces are required
3034 is a positional parameter with more than one digit,
3037 is followed by a character which is not to be
3038 interpreted as part of its name.
3039 The \fIparameter\fP is a shell parameter as described above
3040 \fBPARAMETERS\fP) or an array reference (\fBArrays\fP).
3043 If the first character of \fIparameter\fP is an exclamation point (\fB!\fP),
3044 and \fIparameter\fP is not a \fInameref\fP,
3045 it introduces a level of indirection.
3046 \fBBush\fP uses the value formed by expanding the rest of
3047 \fIparameter\fP as the new \fIparameter\fP; this is then
3048 expanded and that value is used in the rest of the expansion, rather
3049 than the expansion of the original \fIparameter\fP.
3050 This is known as \fIindirect expansion\fP.
3051 The value is subject to tilde expansion,
3052 parameter expansion, command substitution, and arithmetic expansion.
3053 If \fIparameter\fP is a nameref, this expands to the name of the
3054 parameter referenced by \fIparameter\fP instead of performing the
3055 complete indirect expansion.
3056 The exceptions to this are the expansions of ${\fB!\fP\fIprefix\fP\fB*\fP} and
3057 ${\fB!\fP\fIname\fP[\fI@\fP]} described below.
3058 The exclamation point must immediately follow the left brace in order to
3059 introduce indirection.
3061 In each of the cases below, \fIword\fP is subject to tilde expansion,
3062 parameter expansion, command substitution, and arithmetic expansion.
3064 When not performing substring expansion, using the forms documented below
3066 \fBbush\fP tests for a parameter that is unset or null. Omitting the colon
3067 results in a test only for a parameter that is unset.
3071 ${\fIparameter\fP\fB:\-\fP\fIword\fP}
3072 \fBUse Default Values\fP. If
3074 is unset or null, the expansion of
3076 is substituted. Otherwise, the value of
3080 ${\fIparameter\fP\fB:=\fP\fIword\fP}
3081 \fBAssign Default Values\fP.
3084 is unset or null, the expansion of
3090 is then substituted. Positional parameters and special parameters may
3091 not be assigned to in this way.
3093 ${\fIparameter\fP\fB:?\fP\fIword\fP}
3094 \fBDisplay Error if Null or Unset\fP.
3097 is null or unset, the expansion of \fIword\fP (or a message to that effect
3100 is not present) is written to the standard error and the shell, if it
3101 is not interactive, exits. Otherwise, the value of \fIparameter\fP is
3104 ${\fIparameter\fP\fB:+\fP\fIword\fP}
3105 \fBUse Alternate Value\fP.
3108 is null or unset, nothing is substituted, otherwise the expansion of
3112 ${\fIparameter\fP\fB:\fP\fIoffset\fP}
3115 ${\fIparameter\fP\fB:\fP\fIoffset\fP\fB:\fP\fIlength\fP}
3117 \fBSubstring Expansion\fP.
3118 Expands to up to \fIlength\fP characters of the value of \fIparameter\fP
3119 starting at the character specified by \fIoffset\fP.
3120 If \fIparameter\fP is \fB@\fP, an indexed array subscripted by
3121 \fB@\fP or \fB*\fP, or an associative array name, the results differ as
3123 If \fIlength\fP is omitted, expands to the substring of the value of
3124 \fIparameter\fP starting at the character specified by \fIoffset\fP
3125 and extending to the end of the value.
3126 \fIlength\fP and \fIoffset\fP are arithmetic expressions (see
3129 ARITHMETIC EVALUATION
3132 If \fIoffset\fP evaluates to a number less than zero, the value
3133 is used as an offset in characters
3134 from the end of the value of \fIparameter\fP.
3135 If \fIlength\fP evaluates to a number less than zero,
3136 it is interpreted as an offset in characters
3137 from the end of the value of \fIparameter\fP rather than
3138 a number of characters, and the expansion is the characters between
3139 \fIoffset\fP and that result.
3140 Note that a negative offset must be separated from the colon by at least
3141 one space to avoid being confused with the \fB:-\fP expansion.
3143 If \fIparameter\fP is \fB@\fP, the result is \fIlength\fP positional
3144 parameters beginning at \fIoffset\fP.
3145 A negative \fIoffset\fP is taken relative to one greater than the greatest
3146 positional parameter, so an offset of \-1 evaluates to the last positional
3148 It is an expansion error if \fIlength\fP evaluates to a number less than
3151 If \fIparameter\fP is an indexed array name subscripted by @ or *,
3152 the result is the \fIlength\fP
3153 members of the array beginning with ${\fIparameter\fP[\fIoffset\fP]}.
3154 A negative \fIoffset\fP is taken relative to one greater than the maximum
3155 index of the specified array.
3156 It is an expansion error if \fIlength\fP evaluates to a number less than
3159 Substring expansion applied to an associative array produces undefined
3162 Substring indexing is zero-based unless the positional parameters
3163 are used, in which case the indexing starts at 1 by default.
3164 If \fIoffset\fP is 0, and the positional parameters are used, \fB$0\fP is
3165 prefixed to the list.
3167 ${\fB!\fP\fIprefix\fP\fB*\fP}
3170 ${\fB!\fP\fIprefix\fP\fB@\fP}
3172 \fBNames matching prefix\fP.
3173 Expands to the names of variables whose names begin with \fIprefix\fP,
3174 separated by the first character of the
3178 When \fI@\fP is used and the expansion appears within double quotes, each
3179 variable name expands to a separate word.
3181 ${\fB!\fP\fIname\fP[\fI@\fP]}
3184 ${\fB!\fP\fIname\fP[\fI*\fP]}
3186 \fBList of array keys\fP.
3187 If \fIname\fP is an array variable, expands to the list of array indices
3188 (keys) assigned in \fIname\fP.
3189 If \fIname\fP is not an array, expands to 0 if \fIname\fP is set and null
3191 When \fI@\fP is used and the expansion appears within double quotes, each
3192 key expands to a separate word.
3194 ${\fB#\fP\fIparameter\fP}
3195 \fBParameter length\fP.
3196 The length in characters of the value of \fIparameter\fP is substituted.
3203 the value substituted is the number of positional parameters.
3206 is an array name subscripted by
3210 the value substituted is the number of elements in the array.
3213 is an indexed array name subscripted by a negative number, that number is
3214 interpreted as relative to one greater than the maximum index of
3215 \fIparameter\fP, so negative indices count back from the end of the
3216 array, and an index of \-1 references the last element.
3218 ${\fIparameter\fP\fB#\fP\fIword\fP}
3221 ${\fIparameter\fP\fB##\fP\fIword\fP}
3223 \fBRemove matching prefix pattern\fP.
3226 is expanded to produce a pattern just as in pathname
3227 expansion, and matched against the expanded value of
3229 using the rules described under
3232 If the pattern matches the beginning of
3235 then the result of the expansion is the expanded value of
3237 with the shortest matching pattern (the ``\fB#\fP'' case) or the
3238 longest matching pattern (the ``\fB##\fP'' case) deleted.
3245 the pattern removal operation is applied to each positional
3246 parameter in turn, and the expansion is the resultant list.
3249 is an array variable subscripted with
3253 the pattern removal operation is applied to each member of the
3254 array in turn, and the expansion is the resultant list.
3256 ${\fIparameter\fP\fB%\fP\fIword\fP}
3259 ${\fIparameter\fP\fB%%\fP\fIword\fP}
3261 \fBRemove matching suffix pattern\fP.
3262 The \fIword\fP is expanded to produce a pattern just as in
3263 pathname expansion, and matched against the expanded value of
3265 using the rules described under
3268 If the pattern matches a trailing portion of the expanded value of
3270 then the result of the expansion is the expanded value of
3272 with the shortest matching pattern (the ``\fB%\fP'' case) or the
3273 longest matching pattern (the ``\fB%%\fP'' case) deleted.
3280 the pattern removal operation is applied to each positional
3281 parameter in turn, and the expansion is the resultant list.
3284 is an array variable subscripted with
3288 the pattern removal operation is applied to each member of the
3289 array in turn, and the expansion is the resultant list.
3291 ${\fIparameter\fP\fB/\fP\fIpattern\fP\fB/\fP\fIstring\fP}
3292 \fBPattern substitution\fP.
3293 The \fIpattern\fP is expanded to produce a pattern just as in
3295 \fIParameter\fP is expanded and the longest match of \fIpattern\fP
3296 against its value is replaced with \fIstring\fP.
3297 The match is performed using the rules described under
3300 If \fIpattern\fP begins with \fB/\fP, all matches of \fIpattern\fP are
3301 replaced with \fIstring\fP. Normally only the first match is replaced.
3302 If \fIpattern\fP begins with \fB#\fP, it must match at the beginning
3303 of the expanded value of \fIparameter\fP.
3304 If \fIpattern\fP begins with \fB%\fP, it must match at the end
3305 of the expanded value of \fIparameter\fP.
3306 If \fIstring\fP is null, matches of \fIpattern\fP are deleted
3307 and the \fB/\fP following \fIpattern\fP may be omitted.
3310 shell option is enabled, the match is performed without regard to the case
3311 of alphabetic characters.
3318 the substitution operation is applied to each positional
3319 parameter in turn, and the expansion is the resultant list.
3322 is an array variable subscripted with
3326 the substitution operation is applied to each member of the
3327 array in turn, and the expansion is the resultant list.
3329 ${\fIparameter\fP\fB^\fP\fIpattern\fP}
3332 ${\fIparameter\fP\fB^^\fP\fIpattern\fP}
3334 ${\fIparameter\fP\fB,\fP\fIpattern\fP}
3336 ${\fIparameter\fP\fB,,\fP\fIpattern\fP}
3338 \fBCase modification\fP.
3339 This expansion modifies the case of alphabetic characters in \fIparameter\fP.
3340 The \fIpattern\fP is expanded to produce a pattern just as in
3342 Each character in the expanded value of \fIparameter\fP is tested against
3343 \fIpattern\fP, and, if it matches the pattern, its case is converted.
3344 The pattern should not attempt to match more than one character.
3345 The \fB^\fP operator converts lowercase letters matching \fIpattern\fP
3346 to uppercase; the \fB,\fP operator converts matching uppercase letters
3348 The \fB^^\fP and \fB,,\fP expansions convert each matched character in the
3349 expanded value; the \fB^\fP and \fB,\fP expansions match and convert only
3350 the first character in the expanded value.
3351 If \fIpattern\fP is omitted, it is treated like a \fB?\fP, which matches
3359 the case modification operation is applied to each positional
3360 parameter in turn, and the expansion is the resultant list.
3363 is an array variable subscripted with
3367 the case modification operation is applied to each member of the
3368 array in turn, and the expansion is the resultant list.
3370 ${\fIparameter\fP\fB@\fP\fIoperator\fP}
3371 \fBParameter transformation\fP.
3372 The expansion is either a transformation of the value of \fIparameter\fP
3373 or information about \fIparameter\fP itself, depending on the value of
3374 \fIoperator\fP. Each \fIoperator\fP is a single letter:
3380 The expansion is a string that is the value of \fIparameter\fP with lowercase
3381 alphabetic characters converted to uppercase.
3384 The expansion is a string that is the value of \fIparameter\fP with the first
3385 character converted to uppercase, if it is alphabetic.
3388 The expansion is a string that is the value of \fIparameter\fP with uppercase
3389 alphabetic characters converted to lowercase.
3392 The expansion is a string that is the value of \fIparameter\fP quoted in a
3393 format that can be reused as input.
3396 The expansion is a string that is the value of \fIparameter\fP with backslash
3397 escape sequences expanded as with the \fB$'...'\fP quoting mechanism.
3400 The expansion is a string that is the result of expanding the value of
3401 \fIparameter\fP as if it were a prompt string (see \fBPROMPTING\fP below).
3404 The expansion is a string in the form of
3405 an assignment statement or \fBdeclare\fP command that, if
3406 evaluated, will recreate \fIparameter\fP with its attributes and value.
3409 Produces a possibly-quoted version of the value of \fIparameter\fP,
3410 except that it prints the values of
3411 indexed and associative arrays as a sequence of quoted key-value pairs
3412 (see \fBArrays\fP above).
3415 The expansion is a string consisting of flag values representing
3416 \fIparameter\fP's attributes.
3425 the operation is applied to each positional
3426 parameter in turn, and the expansion is the resultant list.
3429 is an array variable subscripted with
3433 the operation is applied to each member of the
3434 array in turn, and the expansion is the resultant list.
3436 The result of the expansion is subject to word splitting and pathname
3437 expansion as described below.
3439 .SS Command Substitution
3440 \fICommand substitution\fP allows the output of a command to replace
3441 the command name. There are two forms:
3444 \fB$(\fP\fIcommand\fP\|\fB)\fP
3448 \fB\`\fP\fIcommand\fP\fB\`\fP
3452 performs the expansion by executing \fIcommand\fP in a subshell environment
3453 and replacing the command substitution with the standard output of the
3454 command, with any trailing newlines deleted.
3455 Embedded newlines are not deleted, but they may be removed during
3457 The command substitution \fB$(cat \fIfile\fP)\fR can be replaced by
3458 the equivalent but faster \fB$(< \fIfile\fP)\fR.
3460 When the old-style backquote form of substitution is used,
3461 backslash retains its literal meaning except when followed by
3466 The first backquote not preceded by a backslash terminates the
3467 command substitution.
3468 When using the $(\^\fIcommand\fP\|) form, all characters between the
3469 parentheses make up the command; none are treated specially.
3471 Command substitutions may be nested. To nest when using the backquoted form,
3472 escape the inner backquotes with backslashes.
3474 If the substitution appears within double quotes, word splitting and
3475 pathname expansion are not performed on the results.
3476 .SS Arithmetic Expansion
3477 Arithmetic expansion allows the evaluation of an arithmetic expression
3478 and the substitution of the result. The format for arithmetic expansion is:
3481 \fB$((\fP\fIexpression\fP\fB))\fP
3486 is treated as if it were within double quotes, but a double quote
3487 inside the parentheses is not treated specially.
3488 All tokens in the expression undergo parameter and variable expansion,
3489 command substitution, and quote removal.
3490 The result is treated as the arithmetic expression to be evaluated.
3491 Arithmetic expansions may be nested.
3493 The evaluation is performed according to the rules listed below under
3495 .BR "ARITHMETIC EVALUATION" .
3500 prints a message indicating failure and no substitution occurs.
3501 .SS Process Substitution
3502 \fIProcess substitution\fP allows a process's input or output to be
3503 referred to using a filename.
3504 It takes the form of
3505 \fB<(\fP\fIlist\^\fP\fB)\fP
3507 \fB>(\fP\fIlist\^\fP\fB)\fP.
3508 The process \fIlist\fP is run asynchronously, and its input or output
3509 appears as a filename.
3511 passed as an argument to the current command as the result of the
3513 If the \fB>(\fP\fIlist\^\fP\fB)\fP form is used, writing to
3514 the file will provide input for \fIlist\fP. If the
3515 \fB<(\fP\fIlist\^\fP\fB)\fP form is used, the file passed as an
3516 argument should be read to obtain the output of \fIlist\fP.
3517 Process substitution is supported on systems that support named
3518 pipes (\fIFIFOs\fP) or the \fB/dev/fd\fP method of naming open files.
3520 When available, process substitution is performed
3521 simultaneously with parameter and variable expansion,
3522 command substitution,
3523 and arithmetic expansion.
3525 The shell scans the results of
3526 parameter expansion,
3527 command substitution,
3529 arithmetic expansion
3530 that did not occur within double quotes for
3531 .IR "word splitting" .
3533 The shell treats each character of
3536 as a delimiter, and splits the results of the other
3537 expansions into words using these characters as field terminators.
3543 .BR <space><tab><newline> ,
3550 at the beginning and end of the results of the previous
3551 expansions are ignored, and
3555 characters not at the beginning or end serves to delimit words.
3559 has a value other than the default, then sequences of
3560 the whitespace characters
3565 are ignored at the beginning and end of the
3566 word, as long as the whitespace character is in the
3573 whitespace character).
3580 whitespace, along with any adjacent
3583 whitespace characters, delimits a field.
3587 whitespace characters is also treated as a delimiter.
3591 is null, no word splitting occurs.
3593 Explicit null arguments (\^\f3"\^"\fP or \^\f3\(aq\^\(aq\fP\^) are retained
3594 and passed to commands as empty strings.
3595 Unquoted implicit null arguments, resulting from the expansion of
3596 parameters that have no values, are removed.
3597 If a parameter with no value is expanded within double quotes, a
3598 null argument results and is retained
3599 and passed to a command as an empty string.
3600 When a quoted null argument appears as part of a word whose expansion is
3601 non-null, the null argument is removed.
3603 \f(CW\-d\(aq\^\(aq\fP becomes \f(CW\-d\fP after word splitting and
3604 null argument removal.
3606 Note that if no expansion occurs, no splitting
3608 .SS Pathname Expansion
3609 After word splitting,
3612 option has been set,
3614 scans each word for the characters
3619 If one of these characters appears, and is not quoted, then the word is
3622 and replaced with an alphabetically sorted list of
3623 filenames matching the pattern
3626 .B "Pattern Matching"
3628 If no matching filenames are found,
3629 and the shell option
3631 is not enabled, the word is left unchanged.
3634 option is set, and no matches are found,
3635 the word is removed.
3638 shell option is set, and no matches are found, an error message
3639 is printed and the command is not executed.
3642 is enabled, the match is performed without regard to the case
3643 of alphabetic characters.
3644 When a pattern is used for pathname expansion,
3647 at the start of a name or immediately following a slash
3648 must be matched explicitly, unless the shell option
3655 must always be matched explicitly, even if
3660 character is not treated specially.
3661 When matching a pathname, the slash character must always be
3662 matched explicitly by a slash in the pattern, but in other matching
3663 contexts it can be matched by a special pattern character as described
3666 .BR "Pattern Matching" .
3667 See the description of
3671 .B SHELL BUILTIN COMMANDS
3672 for a description of the
3683 shell variable may be used to restrict the set of file names matching a
3688 is set, each matching file name that also matches one of the patterns in
3691 is removed from the list of matches.
3692 If the \fBnocaseglob\fP option is set, the matching against the patterns in
3695 is performed without regard to case.
3700 are always ignored when
3703 is set and not null. However, setting
3706 to a non-null value has the effect of enabling the
3708 shell option, so all other filenames beginning with a
3711 To get the old behavior of ignoring filenames beginning with a
3715 one of the patterns in
3720 option is disabled when
3724 The pattern matching honors the setting of the \fBextglob\fP shell
3727 \fBPattern Matching\fP
3729 Any character that appears in a pattern, other than the special pattern
3730 characters described below, matches itself. The NUL character may not
3731 occur in a pattern. A backslash escapes the following character; the
3732 escaping backslash is discarded when matching.
3733 The special pattern characters must be quoted if
3734 they are to be matched literally.
3736 The special pattern characters have the following meanings:
3742 Matches any string, including the null string.
3743 When the \fBglobstar\fP shell option is enabled, and \fB*\fP is used in
3744 a pathname expansion context, two adjacent \fB*\fPs used as a single
3745 pattern will match all files and zero or more directories and
3747 If followed by a \fB/\fP, two adjacent \fB*\fPs will match only directories
3751 Matches any single character.
3754 Matches any one of the enclosed characters. A pair of characters
3755 separated by a hyphen denotes a
3756 \fIrange expression\fP;
3757 any character that falls between those two characters, inclusive,
3758 using the current locale's collating sequence and character set,
3759 is matched. If the first character following the
3765 then any character not enclosed is matched.
3766 The sorting order of characters in range expressions is determined by
3767 the current locale and the values of the
3773 shell variables, if set.
3774 To obtain the traditional interpretation of range expressions, where
3787 may be matched by including it as the first or last character
3791 may be matched by including it as the first character
3800 \fIcharacter classes\fP can be specified using the syntax
3801 \fB[:\fP\fIclass\fP\fB:]\fP, where \fIclass\fP is one of the
3802 following classes defined in the POSIX standard:
3806 .if n alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit
3807 .if t alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit
3809 A character class matches any character belonging to that class.
3810 The \fBword\fP character class matches letters, digits, and the character _.
3818 an \fIequivalence class\fP can be specified using the syntax
3819 \fB[=\fP\fIc\fP\fB=]\fP, which matches all characters with the
3820 same collation weight (as defined by the current locale) as
3821 the character \fIc\fP.
3829 the syntax \fB[.\fP\fIsymbol\fP\fB.]\fP matches the collating symbol
3835 If the \fBextglob\fP shell option is enabled using the \fBshopt\fP
3836 builtin, several extended pattern matching operators are recognized.
3837 In the following description, a \fIpattern-list\fP is a list of one
3838 or more patterns separated by a \fB|\fP.
3839 Composite patterns may be formed using one or more of the following
3845 \fB?(\fP\^\fIpattern-list\^\fP\fB)\fP
3846 Matches zero or one occurrence of the given patterns
3848 \fB*(\fP\^\fIpattern-list\^\fP\fB)\fP
3849 Matches zero or more occurrences of the given patterns
3851 \fB+(\fP\^\fIpattern-list\^\fP\fB)\fP
3852 Matches one or more occurrences of the given patterns
3854 \fB@(\fP\^\fIpattern-list\^\fP\fB)\fP
3855 Matches one of the given patterns
3857 \fB!(\fP\^\fIpattern-list\^\fP\fB)\fP
3858 Matches anything except one of the given patterns
3862 Complicated extended pattern matching against long strings is slow,
3863 especially when the patterns contain alternations and the strings
3864 contain multiple matches.
3865 Using separate matches against shorter strings, or using arrays of
3866 strings instead of a single long string, may be faster.
3868 After the preceding expansions, all unquoted occurrences of the
3872 and \^\f3"\fP\^ that did not result from one of the above
3873 expansions are removed.
3875 Before a command is executed, its input and output
3878 using a special notation interpreted by the shell.
3879 Redirection allows commands' file handles to be
3880 duplicated, opened, closed,
3881 made to refer to different files,
3882 and can change the files the command reads from and writes to.
3883 Redirection may also be used to modify file handles in the
3884 current shell execution environment.
3885 The following redirection
3886 operators may precede or appear anywhere within a
3890 Redirections are processed in the order they appear, from
3893 Each redirection that may be preceded by a file descriptor number
3894 may instead be preceded by a word of the form {\fIvarname\fP}.
3895 In this case, for each redirection operator except
3896 >&- and <&-, the shell will allocate a file descriptor greater
3897 than or equal to 10 and assign it to \fIvarname\fP.
3898 If >&- or <&- is preceded
3899 by {\fIvarname\fP}, the value of \fIvarname\fP defines the file
3900 descriptor to close.
3901 If {\fIvarname\fP} is supplied, the redirection persists beyond
3902 the scope of the command, allowing the shell programmer to manage
3903 the file descriptor himself.
3905 In the following descriptions, if the file descriptor number is
3906 omitted, and the first character of the redirection operator is
3908 the redirection refers to the standard input (file descriptor
3909 0). If the first character of the redirection operator is
3911 the redirection refers to the standard output (file descriptor
3914 The word following the redirection operator in the following
3915 descriptions, unless otherwise noted, is subjected to
3916 brace expansion, tilde expansion, parameter and variable expansion,
3917 command substitution, arithmetic expansion, quote removal,
3918 pathname expansion, and word splitting.
3919 If it expands to more than one word,
3923 Note that the order of redirections is significant. For example,
3927 ls \fB>\fP dirlist 2\fB>&\fP1
3930 directs both standard output and standard error to the file
3935 ls 2\fB>&\fP1 \fB>\fP dirlist
3938 directs only the standard output to file
3940 because the standard error was duplicated from the standard output
3941 before the standard output was redirected to
3944 \fBBush\fP handles several filenames specially when they are used in
3945 redirections, as described in the following table.
3946 If the operating system on which \fBbush\fP is running provides these
3947 special files, bush will use them; otherwise it will emulate them
3948 internally with the behavior described below.
3954 If \fIfd\fP is a valid integer, file descriptor \fIfd\fP is duplicated.
3957 File descriptor 0 is duplicated.
3960 File descriptor 1 is duplicated.
3963 File descriptor 2 is duplicated.
3965 .B /dev/tcp/\fIhost\fP/\fIport\fP
3966 If \fIhost\fP is a valid hostname or Internet address, and \fIport\fP
3967 is an integer port number or service name, \fBbush\fP attempts to open
3968 the corresponding TCP socket.
3970 .B /dev/udp/\fIhost\fP/\fIport\fP
3971 If \fIhost\fP is a valid hostname or Internet address, and \fIport\fP
3972 is an integer port number or service name, \fBbush\fP attempts to open
3973 the corresponding UDP socket.
3977 A failure to open or create a file causes the redirection to fail.
3979 Redirections using file descriptors greater than 9 should be used with
3980 care, as they may conflict with file descriptors the shell uses
3982 .SS Redirecting Input
3983 Redirection of input causes the file whose name results from
3986 to be opened for reading on file descriptor
3988 or the standard input (file descriptor 0) if
3992 The general format for redirecting input is:
3995 [\fIn\fP]\fB<\fP\fIword\fP
3997 .SS Redirecting Output
3998 Redirection of output causes the file whose name results from
4001 to be opened for writing on file descriptor
4003 or the standard output (file descriptor 1) if
4005 is not specified. If the file does not exist it is created;
4006 if it does exist it is truncated to zero size.
4008 The general format for redirecting output is:
4011 [\fIn\fP]\fB>\fP\fIword\fP
4014 If the redirection operator is
4020 builtin has been enabled, the redirection will fail if the file
4021 whose name results from the expansion of \fIword\fP exists and is
4023 If the redirection operator is
4025 or the redirection operator is
4031 builtin command is not enabled, the redirection is attempted even
4032 if the file named by \fIword\fP exists.
4033 .SS Appending Redirected Output
4034 Redirection of output in this fashion
4035 causes the file whose name results from
4038 to be opened for appending on file descriptor
4040 or the standard output (file descriptor 1) if
4042 is not specified. If the file does not exist it is created.
4044 The general format for appending output is:
4047 [\fIn\fP]\fB>>\fP\fIword\fP
4049 .SS Redirecting Standard Output and Standard Error
4050 This construct allows both the
4051 standard output (file descriptor 1) and
4052 the standard error output (file descriptor 2)
4053 to be redirected to the file whose name is the
4057 There are two formats for redirecting standard output and
4068 Of the two forms, the first is preferred.
4069 This is semantically equivalent to
4072 \fB>\fP\fIword\fP 2\fB>&\fP1
4075 When using the second form, \fIword\fP may not expand to a number or
4076 \fB\-\fP. If it does, other redirection operators apply
4077 (see \fBDuplicating File Descriptors\fP below) for compatibility
4079 .SS Appending Standard Output and Standard Error
4080 This construct allows both the
4081 standard output (file descriptor 1) and
4082 the standard error output (file descriptor 2)
4083 to be appended to the file whose name is the
4087 The format for appending standard output and standard error is:
4093 This is semantically equivalent to
4096 \fB>>\fP\fIword\fP 2\fB>&\fP1
4099 (see \fBDuplicating File Descriptors\fP below).
4101 This type of redirection instructs the shell to read input from the
4102 current source until a line containing only
4104 (with no trailing blanks)
4106 the lines read up to that point are then used as the standard
4107 input (or file descriptor \fIn\fP if \fIn\fP is specified) for a command.
4109 The format of here-documents is:
4113 [\fIn\fP]\fB<<\fP[\fB\-\fP]\fIword\fP
4119 No parameter and variable expansion, command substitution,
4120 arithmetic expansion, or pathname expansion is performed on
4126 is the result of quote removal on
4128 and the lines in the here-document are not expanded.
4129 If \fIword\fP is unquoted,
4130 all lines of the here-document are subjected to
4131 parameter expansion, command substitution, and arithmetic expansion,
4132 the character sequence
4136 must be used to quote the characters
4142 If the redirection operator is
4144 then all leading tab characters are stripped from input lines and the
4148 here-documents within shell scripts to be indented in a
4151 A variant of here documents, the format is:
4155 [\fIn\fP]\fB<<<\fP\fIword\fP
4159 The \fIword\fP undergoes
4160 tilde expansion, parameter and variable expansion,
4161 command substitution, arithmetic expansion, and quote removal.
4162 Pathname expansion and word splitting are not performed.
4163 The result is supplied as a single string, with a newline appended,
4164 to the command on its
4165 standard input (or file descriptor \fIn\fP if \fIn\fP is specified).
4166 .SS "Duplicating File Descriptors"
4167 The redirection operator
4170 [\fIn\fP]\fB<&\fP\fIword\fP
4173 is used to duplicate input file descriptors.
4176 expands to one or more digits, the file descriptor denoted by
4178 is made to be a copy of that file descriptor.
4181 do not specify a file descriptor open for input, a redirection error occurs.
4190 is not specified, the standard input (file descriptor 0) is used.
4195 [\fIn\fP]\fB>&\fP\fIword\fP
4198 is used similarly to duplicate output file descriptors. If
4200 is not specified, the standard output (file descriptor 1) is used.
4203 do not specify a file descriptor open for output, a redirection error occurs.
4211 As a special case, if \fIn\fP is omitted, and \fIword\fP does not
4212 expand to one or more digits or \fB\-\fP, the standard output and standard
4213 error are redirected as described previously.
4214 .SS "Moving File Descriptors"
4215 The redirection operator
4218 [\fIn\fP]\fB<&\fP\fIdigit\fP\fB\-\fP
4221 moves the file descriptor \fIdigit\fP to file descriptor
4223 or the standard input (file descriptor 0) if \fIn\fP is not specified.
4224 \fIdigit\fP is closed after being duplicated to \fIn\fP.
4226 Similarly, the redirection operator
4229 [\fIn\fP]\fB>&\fP\fIdigit\fP\fB\-\fP
4232 moves the file descriptor \fIdigit\fP to file descriptor
4234 or the standard output (file descriptor 1) if \fIn\fP is not specified.
4235 .SS "Opening File Descriptors for Reading and Writing"
4236 The redirection operator
4239 [\fIn\fP]\fB<>\fP\fIword\fP
4242 causes the file whose name is the expansion of
4244 to be opened for both reading and writing on file descriptor
4246 or on file descriptor 0 if
4248 is not specified. If the file does not exist, it is created.
4250 \fIAliases\fP allow a string to be substituted for a word when it is used
4251 as the first word of a simple command.
4252 The shell maintains a list of aliases that may be set and unset with the
4256 builtin commands (see
4258 .B SHELL BUILTIN COMMANDS
4260 The first word of each simple command, if unquoted,
4261 is checked to see if it has an
4262 alias. If so, that word is replaced by the text of the alias.
4263 The characters \fB/\fP, \fB$\fP, \fB\`\fP, and \fB=\fP and
4264 any of the shell \fImetacharacters\fP or quoting characters
4265 listed above may not appear in an alias name.
4266 The replacement text may contain any valid shell input,
4267 including shell metacharacters.
4268 The first word of the replacement text is tested
4269 for aliases, but a word that is identical to an alias being expanded
4270 is not expanded a second time.
4271 This means that one may alias
4277 does not try to recursively expand the replacement text.
4278 If the last character of the alias value is a
4280 then the next command
4281 word following the alias is also checked for alias expansion.
4283 Aliases are created and listed with the
4285 command, and removed with the
4289 There is no mechanism for using arguments in the replacement text.
4290 If arguments are needed, a shell function should be used (see
4295 Aliases are not expanded when the shell is not interactive, unless
4298 shell option is set using
4300 (see the description of
4304 \fBSHELL BUILTIN COMMANDS\fP
4307 The rules concerning the definition and use of aliases are
4310 always reads at least one complete line of input,
4311 and all lines that make up a compound command,
4312 before executing any of the commands on that line or the compound command.
4313 Aliases are expanded when a
4314 command is read, not when it is executed. Therefore, an
4315 alias definition appearing on the same line as another
4316 command does not take effect until the next line of input is read.
4317 The commands following the alias definition
4318 on that line are not affected by the new alias.
4319 This behavior is also an issue when functions are executed.
4320 Aliases are expanded when a function definition is read,
4321 not when the function is executed, because a function definition
4322 is itself a command. As a consequence, aliases
4323 defined in a function are not available until after that
4324 function is executed. To be safe, always put
4325 alias definitions on a separate line, and do not use
4327 in compound commands.
4329 For almost every purpose, aliases are superseded by
4332 A shell function, defined as described above under
4334 .BR "SHELL GRAMMAR" ,
4335 stores a series of commands for later execution.
4336 When the name of a shell function is used as a simple command name,
4337 the list of commands associated with that function name is executed.
4338 Functions are executed in the context of the
4339 current shell; no new process is created to interpret
4340 them (contrast this with the execution of a shell script).
4341 When a function is executed, the arguments to the
4342 function become the positional parameters
4343 during its execution.
4344 The special parameter
4346 is updated to reflect the change. Special parameter \fB0\fP
4348 The first element of the
4351 variable is set to the name of the function while the function
4354 All other aspects of the shell execution
4355 environment are identical between a function and its caller
4356 with these exceptions: the
4361 traps (see the description of the
4365 .B SHELL BUILTIN COMMANDS
4366 below) are not inherited unless the function has been given the
4367 \fBtrace\fP attribute (see the description of the
4370 builtin below) or the
4371 \fB\-o functrace\fP shell option has been enabled with
4372 the \fBset\fP builtin
4373 (in which case all functions inherit the \fBDEBUG\fP and \fBRETURN\fP traps),
4377 trap is not inherited unless the \fB\-o errtrace\fP shell option has
4380 Variables local to the function may be declared with the
4382 builtin command. Ordinarily, variables and their values
4383 are shared between the function and its caller.
4384 If a variable is declared \fBlocal\fP, the variable's visible scope
4385 is restricted to that function and its children (including the functions
4387 Local variables "shadow" variables with the same name declared at
4389 For instance, a local variable declared in a function
4390 hides a global variable of the same name: references and assignments
4391 refer to the local variable, leaving the global variable unmodified.
4392 When the function returns, the global variable is once again visible.
4394 The shell uses \fIdynamic scoping\fP to control a variable's visibility
4396 With dynamic scoping, visible variables and their values
4397 are a result of the sequence of function calls that caused execution
4398 to reach the current function.
4399 The value of a variable that a function sees depends
4400 on its value within its caller, if any, whether that caller is
4401 the "global" scope or another shell function.
4402 This is also the value that a local variable
4403 declaration "shadows", and the value that is restored when the function
4406 For example, if a variable \fIvar\fP is declared as local in function
4407 \fIfunc1\fP, and \fIfunc1\fP calls another function \fIfunc2\fP,
4408 references to \fIvar\fP made from within \fIfunc2\fP will resolve to the
4409 local variable \fIvar\fP from \fIfunc1\fP, shadowing any global variable
4412 The \fBunset\fP builtin also acts using the same dynamic scope: if a
4413 variable is local to the current scope, \fBunset\fP will unset it;
4414 otherwise the unset will refer to the variable found in any calling scope
4416 If a variable at the current local scope is unset, it will remain so
4417 until it is reset in that scope or until the function returns.
4418 Once the function returns, any instance of the variable at a previous
4419 scope will become visible.
4420 If the unset acts on a variable at a previous scope, any instance of a
4421 variable with that name that had been shadowed will become visible.
4423 The \fBFUNCNEST\fP variable, if set to a numeric value greater
4424 than 0, defines a maximum function nesting level. Function
4425 invocations that exceed the limit cause the entire command to
4428 If the builtin command
4430 is executed in a function, the function completes and
4431 execution resumes with the next command after the function
4433 Any command associated with the \fBRETURN\fP trap is executed
4434 before execution resumes.
4435 When a function completes, the values of the
4436 positional parameters and the special parameter
4438 are restored to the values they had prior to the function's
4441 Function names and definitions may be listed with the
4447 builtin commands. The
4453 will list the function names only
4454 (and optionally the source file and line number, if the \fBextdebug\fP
4455 shell option is enabled).
4456 Functions may be exported so that subshells
4457 automatically have them defined with the
4462 A function definition may be deleted using the \fB\-f\fP option to
4467 Functions may be recursive.
4468 The \fBFUNCNEST\fP variable may be used to limit the depth of the
4469 function call stack and restrict the number of function invocations.
4470 By default, no limit is imposed on the number of recursive calls.
4471 .SH "ARITHMETIC EVALUATION"
4472 The shell allows arithmetic expressions to be evaluated, under
4473 certain circumstances (see the \fBlet\fP and \fBdeclare\fP builtin
4474 commands, the \fB((\fP compound command, and \fBArithmetic Expansion\fP).
4475 Evaluation is done in fixed-width integers with no check for overflow,
4476 though division by 0 is trapped and flagged as an error.
4477 The operators and their precedence, associativity, and values
4478 are the same as in the C language.
4479 The following list of operators is grouped into levels of
4480 equal-precedence operators.
4481 The levels are listed in order of decreasing precedence.
4485 .B \fIid\fP++ \fIid\fP\-\-
4486 variable post-increment and post-decrement
4489 unary minus and plus
4491 .B ++\fIid\fP \-\-\fIid\fP
4492 variable pre-increment and pre-decrement
4495 logical and bitwise negation
4501 multiplication, division, remainder
4504 addition, subtraction
4507 left and right bitwise shifts
4513 equality and inequality
4519 bitwise exclusive OR
4530 .B \fIexpr\fP?\fIexpr\fP:\fIexpr\fP
4531 conditional operator
4533 .B = *= /= %= += \-= <<= >>= &= ^= |=
4536 .B \fIexpr1\fP , \fIexpr2\fP
4540 Shell variables are allowed as operands; parameter expansion is
4541 performed before the expression is evaluated.
4542 Within an expression, shell variables may also be referenced by name
4543 without using the parameter expansion syntax.
4544 A shell variable that is null or unset evaluates to 0 when referenced
4545 by name without using the parameter expansion syntax.
4546 The value of a variable is evaluated as an arithmetic expression
4547 when it is referenced, or when a variable which has been given the
4548 \fIinteger\fP attribute using \fBdeclare \-i\fP is assigned a value.
4549 A null value evaluates to 0.
4550 A shell variable need not have its \fIinteger\fP attribute
4551 turned on to be used in an expression.
4553 Integer constants follow the C language definition, without suffixes or
4554 character constants.
4555 Constants with a leading 0 are interpreted as octal numbers.
4556 A leading 0x or 0X denotes hexadecimal.
4557 Otherwise, numbers take the form [\fIbase#\fP]n, where the optional \fIbase\fP
4558 is a decimal number between 2 and 64 representing the arithmetic
4559 base, and \fIn\fP is a number in that base.
4560 If \fIbase#\fP is omitted, then base 10 is used.
4561 When specifying \fIn\fP,
4562 if a non-digit is required,
4563 the digits greater than 9 are represented by the lowercase letters,
4564 the uppercase letters, @, and _, in that order.
4565 If \fIbase\fP is less than or equal to 36, lowercase and uppercase
4566 letters may be used interchangeably to represent numbers between 10
4569 Operators are evaluated in order of precedence. Sub-expressions in
4570 parentheses are evaluated first and may override the precedence
4572 .SH "CONDITIONAL EXPRESSIONS"
4573 Conditional expressions are used by the \fB[[\fP compound command and
4574 the \fBtest\fP and \fB[\fP builtin commands to test file attributes
4575 and perform string and arithmetic comparisons.
4576 The \fBtest\fP and \fB[\fP commands determine their behavior based on
4577 the number of arguments; see the descriptions of those commands for any
4578 other command-specific actions.
4580 Expressions are formed from the following unary or binary primaries.
4581 \fBBush\fP handles several filenames specially when they are used in
4583 If the operating system on which \fBbush\fP is running provides these
4584 special files, bush will use them; otherwise it will emulate them
4585 internally with this behavior:
4586 If any \fIfile\fP argument to one of the primaries is of the form
4587 \fI/dev/fd/n\fP, then file descriptor \fIn\fP is checked.
4588 If the \fIfile\fP argument to one of the primaries is one of
4589 \fI/dev/stdin\fP, \fI/dev/stdout\fP, or \fI/dev/stderr\fP, file
4590 descriptor 0, 1, or 2, respectively, is checked.
4592 Unless otherwise specified, primaries that operate on files follow symbolic
4593 links and operate on the target of the link, rather than the link itself.
4596 When used with \fB[[\fP, the \fB<\fP and \fB>\fP operators sort
4597 lexicographically using the current locale.
4598 The \fBtest\fP command sorts using ASCII ordering.
4603 True if \fIfile\fP exists.
4606 True if \fIfile\fP exists and is a block special file.
4609 True if \fIfile\fP exists and is a character special file.
4612 True if \fIfile\fP exists and is a directory.
4615 True if \fIfile\fP exists.
4618 True if \fIfile\fP exists and is a regular file.
4621 True if \fIfile\fP exists and is set-group-id.
4624 True if \fIfile\fP exists and is a symbolic link.
4627 True if \fIfile\fP exists and its ``sticky'' bit is set.
4630 True if \fIfile\fP exists and is a named pipe (FIFO).
4633 True if \fIfile\fP exists and is readable.
4636 True if \fIfile\fP exists and has a size greater than zero.
4639 True if file descriptor
4641 is open and refers to a terminal.
4644 True if \fIfile\fP exists and its set-user-id bit is set.
4647 True if \fIfile\fP exists and is writable.
4650 True if \fIfile\fP exists and is executable.
4653 True if \fIfile\fP exists and is owned by the effective group id.
4656 True if \fIfile\fP exists and is a symbolic link.
4659 True if \fIfile\fP exists and has been modified since it was last read.
4662 True if \fIfile\fP exists and is owned by the effective user id.
4665 True if \fIfile\fP exists and is a socket.
4667 \fIfile1\fP \fB\-ef\fP \fIfile2\fP
4668 True if \fIfile1\fP and \fIfile2\fP refer to the same device and
4671 \fIfile1\fP \-\fBnt\fP \fIfile2\fP
4672 True if \fIfile1\fP is newer (according to modification date) than \fIfile2\fP,
4673 or if \fIfile1\fP exists and \fPfile2\fP does not.
4675 \fIfile1\fP \-\fBot\fP \fIfile2\fP
4676 True if \fIfile1\fP is older than \fIfile2\fP, or if \fIfile2\fP exists
4677 and \fIfile1\fP does not.
4679 .B \-o \fIoptname\fP
4680 True if the shell option
4683 See the list of options under the description of the
4689 .B \-v \fIvarname\fP
4690 True if the shell variable
4692 is set (has been assigned a value).
4694 .B \-R \fIvarname\fP
4695 True if the shell variable
4697 is set and is a name reference.
4700 True if the length of \fIstring\fP is zero.
4707 True if the length of
4711 \fIstring1\fP \fB==\fP \fIstring2\fP
4714 \fIstring1\fP \fB=\fP \fIstring2\fP
4716 True if the strings are equal. \fB=\fP should be used
4717 with the \fBtest\fP command for POSIX conformance.
4718 When used with the \fB[[\fP command, this performs pattern matching as
4719 described above (\fBCompound Commands\fP).
4721 \fIstring1\fP \fB!=\fP \fIstring2\fP
4722 True if the strings are not equal.
4724 \fIstring1\fP \fB<\fP \fIstring2\fP
4725 True if \fIstring1\fP sorts before \fIstring2\fP lexicographically.
4727 \fIstring1\fP \fB>\fP \fIstring2\fP
4728 True if \fIstring1\fP sorts after \fIstring2\fP lexicographically.
4730 .I \fIarg1\fP \fBOP\fP \fIarg2\fP
4741 These arithmetic binary operators return true if \fIarg1\fP
4742 is equal to, not equal to, less than, less than or equal to,
4743 greater than, or greater than or equal to \fIarg2\fP, respectively.
4747 may be positive or negative integers.
4748 When used with the \fB[[\fP command,
4752 are evaluated as arithmetic expressions (see
4754 .B "ARITHMETIC EVALUATION"
4757 .SH "SIMPLE COMMAND EXPANSION"
4758 When a simple command is executed, the shell performs the following
4759 expansions, assignments, and redirections, from left to right, in
4760 the following order.
4762 The words that the parser has marked as variable assignments (those
4763 preceding the command name) and redirections are saved for later
4766 The words that are not variable assignments or redirections are
4767 expanded. If any words remain after expansion, the first word
4768 is taken to be the name of the command and the remaining words are
4771 Redirections are performed as described above under
4775 The text after the \fB=\fP in each variable assignment undergoes tilde
4776 expansion, parameter expansion, command substitution, arithmetic expansion,
4777 and quote removal before being assigned to the variable.
4779 If no command name results, the variable assignments affect the current
4780 shell environment. Otherwise, the variables are added to the environment
4781 of the executed command and do not affect the current shell environment.
4782 If any of the assignments attempts to assign a value to a readonly variable,
4783 an error occurs, and the command exits with a non-zero status.
4785 If no command name results, redirections are performed, but do not
4786 affect the current shell environment. A redirection error causes the
4787 command to exit with a non-zero status.
4789 If there is a command name left after expansion, execution proceeds as
4790 described below. Otherwise, the command exits. If one of the expansions
4791 contained a command substitution, the exit status of the command is
4792 the exit status of the last command substitution performed. If there
4793 were no command substitutions, the command exits with a status of zero.
4794 .SH "COMMAND EXECUTION"
4795 After a command has been split into words, if it results in a
4796 simple command and an optional list of arguments, the following
4799 If the command name contains no slashes, the shell attempts to
4800 locate it. If there exists a shell function by that name, that
4801 function is invoked as described above in
4804 If the name does not match a function, the shell searches for
4805 it in the list of shell builtins. If a match is found, that
4808 If the name is neither a shell function nor a builtin,
4809 and contains no slashes,
4811 searches each element of the
4814 for a directory containing an executable file by that name.
4816 uses a hash table to remember the full pathnames of executable
4821 .B "SHELL BUILTIN COMMANDS"
4823 A full search of the directories in
4826 is performed only if the command is not found in the hash table.
4827 If the search is unsuccessful, the shell searches for a defined shell
4828 function named \fBcommand_not_found_handle\fP.
4829 If that function exists, it is invoked in a separate execution environment
4830 with the original command and
4831 the original command's arguments as its arguments, and the function's
4832 exit status becomes the exit status of that subshell.
4833 If that function is not defined, the shell prints an error
4834 message and returns an exit status of 127.
4836 If the search is successful, or if the command name contains
4837 one or more slashes, the shell executes the named program in a
4838 separate execution environment.
4839 Argument 0 is set to the name given, and the remaining arguments
4840 to the command are set to the arguments given, if any.
4842 If this execution fails because the file is not in executable
4843 format, and the file is not a directory, it is assumed to be
4844 a \fIshell script\fP, a file
4845 containing shell commands. A subshell is spawned to execute
4846 it. This subshell reinitializes itself, so
4847 that the effect is as if a new shell had been invoked
4848 to handle the script, with the exception that the locations of
4849 commands remembered by the parent (see
4853 \fBSHELL BUILTIN COMMANDS\fP)
4854 are retained by the child.
4856 If the program is a file beginning with
4858 the remainder of the first line specifies an interpreter
4859 for the program. The shell executes the
4860 specified interpreter on operating systems that do not
4861 handle this executable format themselves. The arguments to the
4862 interpreter consist of a single optional argument following the
4863 interpreter name on the first line of the program, followed
4864 by the name of the program, followed by the command
4866 .SH COMMAND EXECUTION ENVIRONMENT
4867 The shell has an \fIexecution environment\fP, which consists of the
4870 open files inherited by the shell at invocation, as modified by
4871 redirections supplied to the \fBexec\fP builtin
4873 the current working directory as set by \fBcd\fP, \fBpushd\fP, or
4874 \fBpopd\fP, or inherited by the shell at invocation
4876 the file creation mode mask as set by \fBumask\fP or inherited from
4879 current traps set by \fBtrap\fP
4881 shell parameters that are set by variable assignment or with \fBset\fP
4882 or inherited from the shell's parent in the environment
4884 shell functions defined during execution or inherited from the shell's
4885 parent in the environment
4887 options enabled at invocation (either by default or with command-line
4888 arguments) or by \fBset\fP
4890 options enabled by \fBshopt\fP
4892 shell aliases defined with \fBalias\fP
4894 various process IDs, including those of background jobs, the value
4895 of \fB$$\fP, and the value of
4899 When a simple command other than a builtin or shell function
4900 is to be executed, it
4901 is invoked in a separate execution environment that consists of
4902 the following. Unless otherwise noted, the values are inherited
4906 the shell's open files, plus any modifications and additions specified
4907 by redirections to the command
4909 the current working directory
4911 the file creation mode mask
4913 shell variables and functions marked for export, along with variables
4914 exported for the command, passed in the environment
4916 traps caught by the shell are reset to the values inherited from the
4917 shell's parent, and traps ignored by the shell are ignored
4919 A command invoked in this separate environment cannot affect the
4920 shell's execution environment.
4922 Command substitution, commands grouped with parentheses,
4923 and asynchronous commands are invoked in a
4924 subshell environment that is a duplicate of the shell environment,
4925 except that traps caught by the shell are reset to the values
4926 that the shell inherited from its parent at invocation. Builtin
4927 commands that are invoked as part of a pipeline are also executed in a
4928 subshell environment. Changes made to the subshell environment
4929 cannot affect the shell's execution environment.
4931 Subshells spawned to execute command substitutions inherit the value of
4932 the \fB\-e\fP option from the parent shell. When not in \fIposix mode\fP,
4933 \fBbush\fP clears the \fB\-e\fP option in such subshells.
4935 If a command is followed by a \fB&\fP and job control is not active, the
4936 default standard input for the command is the empty file \fI/dev/null\fP.
4937 Otherwise, the invoked command inherits the file descriptors of the calling
4938 shell as modified by redirections.
4940 When a program is invoked it is given an array of strings
4944 \fIname\fP\-\fIvalue\fP pairs, of the form
4945 .IR "name\fR=\fPvalue" .
4947 The shell provides several ways to manipulate the environment.
4948 On invocation, the shell scans its own environment and
4949 creates a parameter for each name found, automatically marking
4952 to child processes. Executed commands inherit the environment.
4957 commands allow parameters and functions to be added to and
4958 deleted from the environment. If the value of a parameter
4959 in the environment is modified, the new value becomes part
4960 of the environment, replacing the old. The environment
4961 inherited by any executed command consists of the shell's
4962 initial environment, whose values may be modified in the shell,
4963 less any pairs removed by the
4965 command, plus any additions via the
4971 The environment for any
4973 or function may be augmented temporarily by prefixing it with
4974 parameter assignments, as described above in
4977 These assignment statements affect only the environment seen
4982 option is set (see the
4984 builtin command below), then
4986 parameter assignments are placed in the environment for a command,
4987 not just those that precede the command name.
4991 invokes an external command, the variable
4993 is set to the full filename of the command and passed to that
4994 command in its environment.
4996 The exit status of an executed command is the value returned by the
4997 \fIwaitpid\fP system call or equivalent function. Exit statuses
4998 fall between 0 and 255, though, as explained below, the shell may
4999 use values above 125 specially. Exit statuses from shell builtins and
5000 compound commands are also limited to this range. Under certain
5001 circumstances, the shell will use special values to indicate specific
5004 For the shell's purposes, a command which exits with a
5005 zero exit status has succeeded. An exit status of zero
5006 indicates success. A non-zero exit status indicates failure.
5007 When a command terminates on a fatal signal \fIN\fP, \fBbush\fP uses
5008 the value of 128+\fIN\fP as the exit status.
5010 If a command is not found, the child process created to
5011 execute it returns a status of 127. If a command is found
5012 but is not executable, the return status is 126.
5014 If a command fails because of an error during expansion or redirection,
5015 the exit status is greater than zero.
5017 Shell builtin commands return a status of 0 (\fItrue\fP) if
5018 successful, and non-zero (\fIfalse\fP) if an error occurs
5020 All builtins return an exit status of 2 to indicate incorrect usage,
5021 generally invalid options or missing arguments.
5023 \fBBush\fP itself returns the exit status of the last command
5024 executed, unless a syntax error occurs, in which case it exits
5025 with a non-zero value. See also the \fBexit\fP builtin
5028 When \fBbush\fP is interactive, in the absence of any traps, it ignores
5031 (so that \fBkill 0\fP does not kill an interactive shell),
5035 is caught and handled (so that the \fBwait\fP builtin is interruptible).
5036 In all cases, \fBbush\fP ignores
5039 If job control is in effect,
5050 Non-builtin commands run by \fBbush\fP have signal handlers
5051 set to the values inherited by the shell from its parent.
5052 When job control is not in effect, asynchronous commands
5059 in addition to these inherited handlers.
5060 Commands run as a result of command substitution ignore the
5061 keyboard-generated job control signals
5070 The shell exits by default upon receipt of a
5073 Before exiting, an interactive shell resends the
5076 to all jobs, running or stopped.
5077 Stopped jobs are sent
5080 to ensure that they receive the
5083 To prevent the shell from
5084 sending the signal to a particular job, it should be removed from the
5089 .B "SHELL BUILTIN COMMANDS"
5099 shell option has been set with
5105 to all jobs when an interactive login shell exits.
5107 If \fBbush\fP is waiting for a command to complete and receives a signal
5108 for which a trap has been set, the trap will not be executed until
5109 the command completes.
5110 When \fBbush\fP is waiting for an asynchronous command via the \fBwait\fP
5111 builtin, the reception of a signal for which a trap has been set will
5112 cause the \fBwait\fP builtin to return immediately with an exit status
5113 greater than 128, immediately after which the trap is executed.
5116 refers to the ability to selectively stop (\fIsuspend\fP)
5117 the execution of processes and continue (\fIresume\fP)
5118 their execution at a later point. A user typically employs
5119 this facility via an interactive interface supplied jointly
5120 by the operating system kernel's terminal driver and
5123 The shell associates a
5125 with each pipeline. It keeps a table of currently executing
5126 jobs, which may be listed with the
5130 starts a job asynchronously (in the
5132 it prints a line that looks like:
5138 indicating that this job is job number 1 and that the process ID
5139 of the last process in the pipeline associated with this job is 25647.
5140 All of the processes in a single pipeline are members of the same job.
5144 abstraction as the basis for job control.
5146 To facilitate the implementation of the user interface to job
5147 control, the operating system maintains the notion of a \fIcurrent terminal
5148 process group ID\fP. Members of this process group (processes whose
5149 process group ID is equal to the current terminal process group ID)
5150 receive keyboard-generated signals such as
5153 These processes are said to be in the
5156 processes are those whose process group ID differs from the terminal's;
5157 such processes are immune to keyboard-generated signals.
5158 Only foreground processes are allowed to read from or, if the
5159 user so specifies with \f(CWstty tostop\fP, write to the
5161 Background processes which attempt to read from (write to when
5162 \f(CWstty tostop\fP is in effect) the
5165 .B SIGTTIN (SIGTTOU)
5166 signal by the kernel's terminal driver,
5167 which, unless caught, suspends the process.
5169 If the operating system on which
5174 contains facilities to use it.
5177 character (typically
5179 Control-Z) while a process is running
5180 causes that process to be stopped and returns control to
5183 .I "delayed suspend"
5184 character (typically
5186 Control-Y) causes the process to be stopped when it
5187 attempts to read input from the terminal, and control to
5190 The user may then manipulate the state of this job, using the
5192 command to continue it in the background, the
5194 command to continue it in the foreground, or
5197 command to kill it. A \fB^Z\fP takes effect immediately,
5198 and has the additional side effect of causing pending output
5199 and typeahead to be discarded.
5201 There are a number of ways to refer to a job in the shell.
5204 introduces a job specification (\fIjobspec\fP). Job number
5206 may be referred to as
5208 A job may also be referred to using a prefix of the name used to
5209 start it, or using a substring that appears in its command line.
5213 job whose command name begins with
5215 If a prefix matches more than one job,
5217 reports an error. Using
5219 on the other hand, refers to any job containing the string
5221 in its command line. If the substring matches more than one job,
5223 reports an error. The symbols
5227 refer to the shell's notion of the
5229 which is the last job stopped while it was in
5230 the foreground or started in the background.
5233 may be referenced using
5235 If there is only a single job, \fB%+\fP and \fB%\-\fP can both be used
5236 to refer to that job.
5237 In output pertaining to jobs (e.g., the output of the
5239 command), the current job is always flagged with a
5241 and the previous job with a
5243 A single % (with no accompanying job specification) also refers to the
5246 Simply naming a job can be used to bring it into the
5251 bringing job 1 from the background into the foreground.
5254 resumes job 1 in the background, equivalent to
5257 The shell learns immediately whenever a job changes state.
5260 waits until it is about to print a prompt before reporting
5261 changes in a job's status so as to not interrupt
5262 any other output. If the
5269 reports such changes immediately.
5273 is executed for each child that exits.
5275 If an attempt to exit
5277 is made while jobs are stopped (or, if the \fBcheckjobs\fP shell option has
5278 been enabled using the \fBshopt\fP builtin, running), the shell prints a
5279 warning message, and, if the \fBcheckjobs\fP option is enabled, lists the
5280 jobs and their statuses.
5283 command may then be used to inspect their status.
5284 If a second attempt to exit is made without an intervening command,
5285 the shell does not print another warning, and any stopped
5286 jobs are terminated.
5288 When the shell is waiting for a job or process using the \fBwait\fP
5289 builtin, and job control is enabled, \fBwait\fP will return when the
5290 job changes state. The \fB\-f\fP option causes \fBwait\fP to wait
5291 until the job or process terminates before returning.
5293 When executing interactively,
5295 displays the primary prompt
5298 when it is ready to read a command, and the secondary prompt
5301 when it needs more input to complete a command.
5306 after it reads a command but before executing it.
5312 before tracing each command when the \fB\-x\fP option is enabled.
5314 allows these prompt strings to be customized by inserting a number of
5315 backslash-escaped special characters that are decoded as follows:
5320 an ASCII bell character (07)
5323 the date in "Weekday Month Date" format (e.g., "Tue May 26")
5325 .B \eD{\fIformat\fP}
5326 the \fIformat\fP is passed to \fIstrftime\fP(3) and the result is inserted
5327 into the prompt string; an empty \fIformat\fP results in a locale-specific
5328 time representation. The braces are required
5331 an ASCII escape character (033)
5334 the hostname up to the first `.'
5340 the number of jobs currently managed by the shell
5343 the basename of the shell's terminal device name
5352 the name of the shell, the basename of
5354 (the portion following the final slash)
5357 the current time in 24-hour HH:MM:SS format
5360 the current time in 12-hour HH:MM:SS format
5363 the current time in 12-hour am/pm format
5366 the current time in 24-hour HH:MM format
5369 the username of the current user
5372 the version of \fBbush\fP (e.g., 2.00)
5375 the release of \fBbush\fP, version + patch level (e.g., 2.00.0)
5378 the current working directory, with
5381 abbreviated with a tilde
5382 (uses the value of the
5388 the basename of the current working directory, with
5391 abbreviated with a tilde
5394 the history number of this command
5397 the command number of this command
5400 if the effective UID is 0, a
5406 the character corresponding to the octal number \fInnn\fP
5412 begin a sequence of non-printing characters, which could be used to
5413 embed a terminal control sequence into the prompt
5416 end a sequence of non-printing characters
5420 The command number and the history number are usually different:
5421 the history number of a command is its position in the history
5422 list, which may include commands restored from the history file
5426 below), while the command number is the position in the sequence
5427 of commands executed during the current shell session.
5428 After the string is decoded, it is expanded via
5429 parameter expansion, command substitution, arithmetic
5430 expansion, and quote removal, subject to the value of the
5432 shell option (see the description of the
5436 .B "SHELL BUILTIN COMMANDS"
5438 This can have unwanted side effects if escaped portions of the string
5439 appear within command substitution or contain characters special to
5442 This is the library that handles reading input when using an interactive
5445 option is given at shell invocation.
5446 Line editing is also used when using the \fB\-e\fP option to the
5448 By default, the line editing commands are similar to those of Emacs.
5449 A vi-style line editing interface is also available.
5450 Line editing can be enabled at any time using the
5458 .B SHELL BUILTIN COMMANDS
5460 To turn off line editing after the shell is running, use the
5467 .SS "Readline Notation"
5468 In this section, the Emacs-style notation is used to denote
5469 keystrokes. Control keys are denoted by C\-\fIkey\fR, e.g., C\-n
5470 means Control\-N. Similarly,
5472 keys are denoted by M\-\fIkey\fR, so M\-x means Meta\-X. (On keyboards
5475 key, M\-\fIx\fP means ESC \fIx\fP, i.e., press the Escape key
5478 key. This makes ESC the \fImeta prefix\fP.
5479 The combination M\-C\-\fIx\fP means ESC\-Control\-\fIx\fP,
5480 or press the Escape key
5481 then hold the Control key while pressing the
5485 Readline commands may be given numeric
5487 which normally act as a repeat count.
5488 Sometimes, however, it is the sign of the argument that is significant.
5489 Passing a negative argument to a command that acts in the forward
5490 direction (e.g., \fBkill\-line\fP) causes that command to act in a
5492 Commands whose behavior with arguments deviates from this are noted
5495 When a command is described as \fIkilling\fP text, the text
5496 deleted is saved for possible future retrieval
5497 (\fIyanking\fP). The killed text is saved in a
5498 \fIkill ring\fP. Consecutive kills cause the text to be
5499 accumulated into one unit, which can be yanked all at once.
5500 Commands which do not kill text separate the chunks of text
5502 .SS "Readline Initialization"
5503 Readline is customized by putting commands in an initialization
5504 file (the \fIinputrc\fP file).
5505 The name of this file is taken from the value of the
5508 variable. If that variable is unset, the default is
5510 If that file does not exist or cannot be read, the ultimate default is
5512 When a program which uses the readline library starts up, the
5513 initialization file is read, and the key bindings and variables
5515 There are only a few basic constructs allowed in the
5516 readline initialization file.
5517 Blank lines are ignored.
5518 Lines beginning with a \fB#\fP are comments.
5519 Lines beginning with a \fB$\fP indicate conditional constructs.
5520 Other lines denote key bindings and variable settings.
5522 The default key-bindings may be changed with an
5525 Other programs that use this library may add their own commands
5528 For example, placing
5531 M\-Control\-u: universal\-argument
5535 C\-Meta\-u: universal\-argument
5539 would make M\-C\-u execute the readline command
5540 .IR universal\-argument .
5542 The following symbolic character names are recognized:
5555 In addition to command names, readline allows keys to be bound
5556 to a string that is inserted when the key is pressed (a \fImacro\fP).
5557 .SS "Readline Key Bindings"
5558 The syntax for controlling key bindings in the
5560 file is simple. All that is required is the name of the
5561 command or the text of a macro and a key sequence to which
5562 it should be bound. The name may be specified in one of two ways:
5563 as a symbolic key name, possibly with \fIMeta\-\fP or \fIControl\-\fP
5564 prefixes, or as a key sequence.
5566 When using the form \fBkeyname\fP:\^\fIfunction\-name\fP or \fImacro\fP,
5568 is the name of a key spelled out in English. For example:
5571 Control-u: universal\-argument
5573 Meta-Rubout: backward-kill-word
5575 Control-o: "> output"
5578 In the above example,
5580 is bound to the function
5581 .BR universal\-argument ,
5583 is bound to the function
5584 .BR backward\-kill\-word ,
5587 is bound to run the macro
5588 expressed on the right hand side (that is, to insert the text
5589 .if t \f(CW> output\fP
5593 In the second form, \fB"keyseq"\fP:\^\fIfunction\-name\fP or \fImacro\fP,
5597 above in that strings denoting
5598 an entire key sequence may be specified by placing the sequence
5599 within double quotes. Some GNU Emacs style key escapes can be
5600 used, as in the following example, but the symbolic character names
5604 "\eC\-u": universal\-argument
5606 "\eC\-x\eC\-r": re\-read\-init\-file
5608 "\ee[11~": "Function Key 1"
5613 is again bound to the function
5614 .BR universal\-argument .
5616 is bound to the function
5617 .BR re\-read\-init\-file ,
5620 is bound to insert the text
5621 .if t \f(CWFunction Key 1\fP.
5622 .if n ``Function Key 1''.
5624 The full set of GNU Emacs style escape sequences is
5648 In addition to the GNU Emacs style escape sequences, a second
5649 set of backslash escapes is available:
5678 the eight-bit character whose value is the octal value \fInnn\fP
5679 (one to three digits)
5682 the eight-bit character whose value is the hexadecimal value \fIHH\fP
5683 (one or two hex digits)
5687 When entering the text of a macro, single or double quotes must
5688 be used to indicate a macro definition.
5689 Unquoted text is assumed to be a function name.
5690 In the macro body, the backslash escapes described above are expanded.
5691 Backslash will quote any other character in the macro text,
5692 including " and \(aq.
5695 allows the current readline key bindings to be displayed or modified
5698 builtin command. The editing mode may be switched during interactive
5703 builtin command (see
5705 .B SHELL BUILTIN COMMANDS
5707 .SS "Readline Variables"
5708 Readline has variables that can be used to further customize its
5709 behavior. A variable may be set in the
5711 file with a statement of the form
5714 \fBset\fP \fIvariable\-name\fP \fIvalue\fP
5716 or using the \fBbind\fP builtin command (see
5718 .B SHELL BUILTIN COMMANDS
5721 Except where noted, readline variables can take the values
5725 (without regard to case).
5726 Unrecognized variable names are ignored.
5727 When a variable value is read, empty or null values, "on" (case-insensitive),
5728 and "1" are equivalent to \fBOn\fP. All other values are equivalent to
5730 The variables and their default values are:
5734 .B bell\-style (audible)
5735 Controls what happens when readline wants to ring the terminal bell.
5736 If set to \fBnone\fP, readline never rings the bell. If set to
5737 \fBvisible\fP, readline uses a visible bell if one is available.
5738 If set to \fBaudible\fP, readline attempts to ring the terminal's bell.
5740 .B bind\-tty\-special\-chars (On)
5741 If set to \fBOn\fP, readline attempts to bind the control characters
5742 treated specially by the kernel's terminal driver to their readline
5745 .B blink\-matching\-paren (Off)
5746 If set to \fBOn\fP, readline attempts to briefly move the cursor to an
5747 opening parenthesis when a closing parenthesis is inserted.
5749 .B colored\-completion\-prefix (Off)
5750 If set to \fBOn\fP, when listing completions, readline displays the
5751 common prefix of the set of possible completions using a different color.
5752 The color definitions are taken from the value of the \fBLS_COLORS\fP
5753 environment variable.
5755 .B colored\-stats (Off)
5756 If set to \fBOn\fP, readline displays possible completions using different
5757 colors to indicate their file type.
5758 The color definitions are taken from the value of the \fBLS_COLORS\fP
5759 environment variable.
5761 .B comment\-begin (``#'')
5762 The string that is inserted when the readline
5764 command is executed.
5765 This command is bound to
5767 in emacs mode and to
5771 .B completion\-display\-width (\-1)
5772 The number of screen columns used to display possible matches
5773 when performing completion.
5774 The value is ignored if it is less than 0 or greater than the terminal
5776 A value of 0 will cause matches to be displayed one per line.
5777 The default value is \-1.
5779 .B completion\-ignore\-case (Off)
5780 If set to \fBOn\fP, readline performs filename matching and completion
5781 in a case\-insensitive fashion.
5783 .B completion\-map\-case (Off)
5784 If set to \fBOn\fP, and \fBcompletion\-ignore\-case\fP is enabled, readline
5785 treats hyphens (\fI\-\fP) and underscores (\fI_\fP) as equivalent when
5786 performing case\-insensitive filename matching and completion.
5788 .B completion\-prefix\-display\-length (0)
5789 The length in characters of the common prefix of a list of possible
5790 completions that is displayed without modification. When set to a
5791 value greater than zero, common prefixes longer than this value are
5792 replaced with an ellipsis when displaying possible completions.
5794 .B completion\-query\-items (100)
5795 This determines when the user is queried about viewing
5796 the number of possible completions
5797 generated by the \fBpossible\-completions\fP command.
5798 It may be set to any integer value greater than or equal to zero.
5799 If the number of possible completions is greater than
5800 or equal to the value of this variable,
5801 readline will ask whether or not the user wishes to view them;
5802 otherwise they are simply listed on the terminal.
5804 .B convert\-meta (On)
5805 If set to \fBOn\fP, readline will convert characters with the
5806 eighth bit set to an ASCII key sequence
5807 by stripping the eighth bit and prefixing an
5808 escape character (in effect, using escape as the \fImeta prefix\fP).
5809 The default is \fIOn\fP, but readline will set it to \fIOff\fP if the
5810 locale contains eight-bit characters.
5812 .B disable\-completion (Off)
5813 If set to \fBOn\fP, readline will inhibit word completion. Completion
5814 characters will be inserted into the line as if they had been
5815 mapped to \fBself-insert\fP.
5817 .B echo\-control\-characters (On)
5818 When set to \fBOn\fP, on operating systems that indicate they support it,
5819 readline echoes a character corresponding to a signal generated from the
5822 .B editing\-mode (emacs)
5823 Controls whether readline begins with a set of key bindings similar
5824 to \fIEmacs\fP or \fIvi\fP.
5826 can be set to either
5831 .B emacs\-mode\-string (@)
5832 If the \fIshow\-mode\-in\-prompt\fP variable is enabled,
5833 this string is displayed immediately before the last line of the primary
5834 prompt when emacs editing mode is active. The value is expanded like a
5835 key binding, so the standard set of meta- and control prefixes and
5836 backslash escape sequences is available.
5837 Use the \e1 and \e2 escapes to begin and end sequences of
5838 non-printing characters, which can be used to embed a terminal control
5839 sequence into the mode string.
5841 .B enable\-bracketed\-paste (On)
5842 When set to \fBOn\fP, readline will configure the terminal in a way
5843 that will enable it to insert each paste into the editing buffer as a
5844 single string of characters, instead of treating each character as if
5845 it had been read from the keyboard. This can prevent pasted characters
5846 from being interpreted as editing commands.
5848 .B enable\-keypad (Off)
5849 When set to \fBOn\fP, readline will try to enable the application
5850 keypad when it is called. Some systems need this to enable the
5853 .B enable\-meta\-key (On)
5854 When set to \fBOn\fP, readline will try to enable any meta modifier
5855 key the terminal claims to support when it is called. On many terminals,
5856 the meta key is used to send eight-bit characters.
5858 .B expand\-tilde (Off)
5859 If set to \fBOn\fP, tilde expansion is performed when readline
5860 attempts word completion.
5862 .B history\-preserve\-point (Off)
5863 If set to \fBOn\fP, the history code attempts to place point at the
5864 same location on each history line retrieved with \fBprevious-history\fP
5865 or \fBnext-history\fP.
5867 .B history\-size (unset)
5868 Set the maximum number of history entries saved in the history list.
5869 If set to zero, any existing history entries are deleted and no new entries
5871 If set to a value less than zero, the number of history entries is not
5873 By default, the number of history entries is set to the value of the
5874 \fBHISTSIZE\fP shell variable.
5875 If an attempt is made to set \fIhistory\-size\fP to a non-numeric value,
5876 the maximum number of history entries will be set to 500.
5878 .B horizontal\-scroll\-mode (Off)
5879 When set to \fBOn\fP, makes readline use a single line for display,
5880 scrolling the input horizontally on a single screen line when it
5881 becomes longer than the screen width rather than wrapping to a new line.
5882 This setting is automatically enabled for terminals of height 1.
5884 .B input\-meta (Off)
5885 If set to \fBOn\fP, readline will enable eight-bit input (that is,
5886 it will not strip the eighth bit from the characters it reads),
5887 regardless of what the terminal claims it can support. The name
5889 is a synonym for this variable.
5890 The default is \fIOff\fP, but readline will set it to \fIOn\fP if the
5891 locale contains eight-bit characters.
5893 .B isearch\-terminators (``C\-[C\-J'')
5894 The string of characters that should terminate an incremental
5895 search without subsequently executing the character as a command.
5896 If this variable has not been given a value, the characters
5897 \fIESC\fP and \fIC\-J\fP will terminate an incremental search.
5900 Set the current readline keymap. The set of valid keymap names is
5901 \fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi,
5904 \fIvi\fP is equivalent to \fIvi\-command\fP; \fIemacs\fP is
5905 equivalent to \fIemacs\-standard\fP. The default value is
5909 also affects the default keymap.
5911 .B keyseq\-timeout (500)
5912 Specifies the duration \fIreadline\fP will wait for a character when reading an
5913 ambiguous key sequence (one that can form a complete key sequence using
5914 the input read so far, or can take additional input to complete a longer
5916 If no input is received within the timeout, \fIreadline\fP will use the shorter
5917 but complete key sequence.
5918 The value is specified in milliseconds, so a value of 1000 means that
5919 \fIreadline\fP will wait one second for additional input.
5920 If this variable is set to a value less than or equal to zero, or to a
5921 non-numeric value, \fIreadline\fP will wait until another key is pressed to
5922 decide which key sequence to complete.
5924 .B mark\-directories (On)
5925 If set to \fBOn\fP, completed directory names have a slash
5928 .B mark\-modified\-lines (Off)
5929 If set to \fBOn\fP, history lines that have been modified are displayed
5930 with a preceding asterisk (\fB*\fP).
5932 .B mark\-symlinked\-directories (Off)
5933 If set to \fBOn\fP, completed names which are symbolic links to directories
5934 have a slash appended (subject to the value of
5935 \fBmark\-directories\fP).
5937 .B match\-hidden\-files (On)
5938 This variable, when set to \fBOn\fP, causes readline to match files whose
5939 names begin with a `.' (hidden files) when performing filename
5941 If set to \fBOff\fP, the leading `.' must be
5942 supplied by the user in the filename to be completed.
5944 .B menu\-complete\-display\-prefix (Off)
5945 If set to \fBOn\fP, menu completion displays the common prefix of the
5946 list of possible completions (which may be empty) before cycling through
5949 .B output\-meta (Off)
5950 If set to \fBOn\fP, readline will display characters with the
5951 eighth bit set directly rather than as a meta-prefixed escape
5953 The default is \fIOff\fP, but readline will set it to \fIOn\fP if the
5954 locale contains eight-bit characters.
5956 .B page\-completions (On)
5957 If set to \fBOn\fP, readline uses an internal \fImore\fP-like pager
5958 to display a screenful of possible completions at a time.
5960 .B print\-completions\-horizontally (Off)
5961 If set to \fBOn\fP, readline will display completions with matches
5962 sorted horizontally in alphabetical order, rather than down the screen.
5964 .B revert\-all\-at\-newline (Off)
5965 If set to \fBOn\fP, readline will undo all changes to history lines
5966 before returning when \fBaccept\-line\fP is executed. By default,
5967 history lines may be modified and retain individual undo lists across
5968 calls to \fBreadline\fP.
5970 .B show\-all\-if\-ambiguous (Off)
5971 This alters the default behavior of the completion functions. If
5974 words which have more than one possible completion cause the
5975 matches to be listed immediately instead of ringing the bell.
5977 .B show\-all\-if\-unmodified (Off)
5978 This alters the default behavior of the completion functions in
5979 a fashion similar to \fBshow\-all\-if\-ambiguous\fP.
5982 words which have more than one possible completion without any
5983 possible partial completion (the possible completions don't share
5984 a common prefix) cause the matches to be listed immediately instead
5985 of ringing the bell.
5987 .B show\-mode\-in\-prompt (Off)
5988 If set to \fBOn\fP, add a string to the beginning of the prompt
5989 indicating the editing mode: emacs, vi command, or vi insertion.
5990 The mode strings are user-settable (e.g., \fIemacs\-mode\-string\fP).
5992 .B skip\-completed\-text (Off)
5993 If set to \fBOn\fP, this alters the default completion behavior when
5994 inserting a single match into the line. It's only active when
5995 performing completion in the middle of a word. If enabled, readline
5996 does not insert characters from the completion that match characters
5997 after point in the word being completed, so portions of the word
5998 following the cursor are not duplicated.
6000 .B vi\-cmd\-mode\-string ((cmd))
6001 If the \fIshow\-mode\-in\-prompt\fP variable is enabled,
6002 this string is displayed immediately before the last line of the primary
6003 prompt when vi editing mode is active and in command mode.
6004 The value is expanded like a
6005 key binding, so the standard set of meta- and control prefixes and
6006 backslash escape sequences is available.
6007 Use the \e1 and \e2 escapes to begin and end sequences of
6008 non-printing characters, which can be used to embed a terminal control
6009 sequence into the mode string.
6011 .B vi\-ins\-mode\-string ((ins))
6012 If the \fIshow\-mode\-in\-prompt\fP variable is enabled,
6013 this string is displayed immediately before the last line of the primary
6014 prompt when vi editing mode is active and in insertion mode.
6015 The value is expanded like a
6016 key binding, so the standard set of meta- and control prefixes and
6017 backslash escape sequences is available.
6018 Use the \e1 and \e2 escapes to begin and end sequences of
6019 non-printing characters, which can be used to embed a terminal control
6020 sequence into the mode string.
6022 .B visible\-stats (Off)
6023 If set to \fBOn\fP, a character denoting a file's type as reported
6024 by \fIstat\fP(2) is appended to the filename when listing possible
6027 .SS "Readline Conditional Constructs"
6028 Readline implements a facility similar in spirit to the conditional
6029 compilation features of the C preprocessor which allows key
6030 bindings and variable settings to be performed as the result
6031 of tests. There are four parser directives used.
6035 construct allows bindings to be made based on the
6036 editing mode, the terminal being used, or the application using
6037 readline. The text of the test, after any comparison operator,
6038 extends to the end of the line;
6039 unless otherwise noted, no characters are required to isolate it.
6042 The \fBmode=\fP form of the \fB$if\fP directive is used to test
6043 whether readline is in emacs or vi mode.
6044 This may be used in conjunction
6045 with the \fBset keymap\fP command, for instance, to set bindings in
6046 the \fIemacs\-standard\fP and \fIemacs\-ctlx\fP keymaps only if
6047 readline is starting out in emacs mode.
6049 The \fBterm=\fP form may be used to include terminal-specific
6050 key bindings, perhaps to bind the key sequences output by the
6051 terminal's function keys. The word on the right side of the
6053 is tested against both the full name of the terminal and the portion
6054 of the terminal name before the first \fB\-\fP. This allows
6062 The \fBversion\fP test may be used to perform comparisons against
6063 specific readline versions.
6064 The \fBversion\fP expands to the current readline version.
6065 The set of comparison operators includes
6075 The version number supplied on the right side of the operator consists
6076 of a major version number, an optional decimal point, and an optional
6077 minor version (e.g., \fB7.1\fP). If the minor version is omitted, it
6078 is assumed to be \fB0\fP.
6079 The operator may be separated from the string \fBversion\fP
6080 and from the version number argument by whitespace.
6081 .IP \fBapplication\fP
6082 The \fBapplication\fP construct is used to include
6083 application-specific settings. Each program using the readline
6084 library sets the \fIapplication name\fP, and an initialization
6085 file can test for a particular value.
6086 This could be used to bind key sequences to functions useful for
6087 a specific program. For instance, the following command adds a
6088 key sequence that quotes the current or previous word in \fBbush\fP:
6093 # Quote the current or previous word
6094 "\eC\-xq": "\eeb\e"\eef\e""
6099 The \fIvariable\fP construct provides simple equality tests for readline
6100 variables and values.
6101 The permitted comparison operators are \fI=\fP, \fI==\fP, and \fI!=\fP.
6102 The variable name must be separated from the comparison operator by
6103 whitespace; the operator may be separated from the value on the right hand
6105 Both string and boolean variables may be tested. Boolean variables must be
6106 tested against the values \fIon\fP and \fIoff\fP.
6109 This command, as seen in the previous example, terminates an
6112 Commands in this branch of the \fB$if\fP directive are executed if
6115 This directive takes a single filename as an argument and reads commands
6116 and bindings from that file. For example, the following directive
6117 would read \fI/etc/inputrc\fP:
6121 \fB$include\fP \^ \fI/etc/inputrc\fP
6125 Readline provides commands for searching through the command history
6129 below) for lines containing a specified string.
6130 There are two search modes:
6133 .IR non-incremental .
6135 Incremental searches begin before the user has finished typing the
6137 As each character of the search string is typed, readline displays
6138 the next entry from the history matching the string typed so far.
6139 An incremental search requires only as many characters as needed to
6140 find the desired history entry.
6141 The characters present in the value of the \fBisearch-terminators\fP
6142 variable are used to terminate an incremental search.
6143 If that variable has not been assigned a value the Escape and
6144 Control-J characters will terminate an incremental search.
6145 Control-G will abort an incremental search and restore the original
6147 When the search is terminated, the history entry containing the
6148 search string becomes the current line.
6150 To find other matching entries in the history list, type Control-S or
6151 Control-R as appropriate.
6152 This will search backward or forward in the history for the next
6153 entry matching the search string typed so far.
6154 Any other key sequence bound to a readline command will terminate
6155 the search and execute that command.
6156 For instance, a \fInewline\fP will terminate the search and accept
6157 the line, thereby executing the command from the history list.
6159 Readline remembers the last incremental search string. If two
6160 Control-Rs are typed without any intervening characters defining a
6161 new search string, any remembered search string is used.
6163 Non-incremental searches read the entire search string before starting
6164 to search for matching history lines. The search string may be
6165 typed by the user or be part of the contents of the current line.
6166 .SS "Readline Command Names"
6167 The following is a list of the names of the commands and the default
6168 key sequences to which they are bound.
6169 Command names without an accompanying key sequence are unbound by default.
6170 In the following descriptions, \fIpoint\fP refers to the current cursor
6171 position, and \fImark\fP refers to a cursor position saved by the
6172 \fBset\-mark\fP command.
6173 The text between the point and mark is referred to as the \fIregion\fP.
6174 .SS Commands for Moving
6177 .B beginning\-of\-line (C\-a)
6178 Move to the start of the current line.
6180 .B end\-of\-line (C\-e)
6181 Move to the end of the line.
6183 .B forward\-char (C\-f)
6184 Move forward a character.
6186 .B backward\-char (C\-b)
6187 Move back a character.
6189 .B forward\-word (M\-f)
6190 Move forward to the end of the next word. Words are composed of
6191 alphanumeric characters (letters and digits).
6193 .B backward\-word (M\-b)
6194 Move back to the start of the current or previous word.
6195 Words are composed of alphanumeric characters (letters and digits).
6197 .B shell\-forward\-word
6198 Move forward to the end of the next word.
6199 Words are delimited by non-quoted shell metacharacters.
6201 .B shell\-backward\-word
6202 Move back to the start of the current or previous word.
6203 Words are delimited by non-quoted shell metacharacters.
6205 .B previous\-screen\-line
6206 Attempt to move point to the same physical screen column on the previous
6207 physical screen line. This will not have the desired effect if the current
6208 Readline line does not take up more than one physical line or if point is not
6209 greater than the length of the prompt plus the screen width.
6211 .B next\-screen\-line
6212 Attempt to move point to the same physical screen column on the next
6213 physical screen line. This will not have the desired effect if the current
6214 Readline line does not take up more than one physical line or if the length
6215 of the current Readline line is not greater than the length of the prompt
6216 plus the screen width.
6218 .B clear\-display (M\-C\-l)
6219 Clear the screen and, if possible, the terminal's scrollback buffer,
6220 then redraw the current line,
6221 leaving the current line at the top of the screen.
6223 .B clear\-screen (C\-l)
6225 then redraw the current line,
6226 leaving the current line at the top of the screen.
6227 With an argument, refresh the current line without clearing the
6230 .B redraw\-current\-line
6231 Refresh the current line.
6233 .SS Commands for Manipulating the History
6236 .B accept\-line (Newline, Return)
6237 Accept the line regardless of where the cursor is. If this line is
6238 non-empty, add it to the history list according to the state of the
6241 variable. If the line is a modified history
6242 line, then restore the history line to its original state.
6244 .B previous\-history (C\-p)
6245 Fetch the previous command from the history list, moving back in
6248 .B next\-history (C\-n)
6249 Fetch the next command from the history list, moving forward in the
6252 .B beginning\-of\-history (M\-<)
6253 Move to the first line in the history.
6255 .B end\-of\-history (M\->)
6256 Move to the end of the input history, i.e., the line currently being
6259 .B reverse\-search\-history (C\-r)
6260 Search backward starting at the current line and moving `up' through
6261 the history as necessary. This is an incremental search.
6263 .B forward\-search\-history (C\-s)
6264 Search forward starting at the current line and moving `down' through
6265 the history as necessary. This is an incremental search.
6267 .B non\-incremental\-reverse\-search\-history (M\-p)
6268 Search backward through the history starting at the current line
6269 using a non-incremental search for a string supplied by the user.
6271 .B non\-incremental\-forward\-search\-history (M\-n)
6272 Search forward through the history using a non-incremental search for
6273 a string supplied by the user.
6275 .B history\-search\-forward
6276 Search forward through the history for the string of characters
6277 between the start of the current line and the point.
6278 This is a non-incremental search.
6280 .B history\-search\-backward
6281 Search backward through the history for the string of characters
6282 between the start of the current line and the point.
6283 This is a non-incremental search.
6285 .B history\-substring\-search\-backward
6286 Search backward through the history for the string of characters
6287 between the start of the current line and the current cursor
6288 position (the \fIpoint\fP).
6289 The search string may match anywhere in a history line.
6290 This is a non-incremental search.
6292 .B history\-substring\-search\-forward
6293 Search forward through the history for the string of characters
6294 between the start of the current line and the point.
6295 The search string may match anywhere in a history line.
6296 This is a non-incremental search.
6298 .B yank\-nth\-arg (M\-C\-y)
6299 Insert the first argument to the previous command (usually
6300 the second word on the previous line) at point.
6303 insert the \fIn\fPth word from the previous command (the words
6304 in the previous command begin with word 0). A negative argument
6305 inserts the \fIn\fPth word from the end of the previous command.
6306 Once the argument \fIn\fP is computed, the argument is extracted
6307 as if the "!\fIn\fP" history expansion had been specified.
6310 yank\-last\-arg (M\-.\^, M\-_\^)
6311 Insert the last argument to the previous command (the last word of
6312 the previous history entry).
6313 With a numeric argument, behave exactly like \fByank\-nth\-arg\fP.
6314 Successive calls to \fByank\-last\-arg\fP move back through the history
6315 list, inserting the last word (or the word specified by the argument to
6316 the first call) of each line in turn.
6317 Any numeric argument supplied to these successive calls determines
6318 the direction to move through the history. A negative argument switches
6319 the direction through the history (back or forward).
6320 The history expansion facilities are used to extract the last word,
6321 as if the "!$" history expansion had been specified.
6323 .B shell\-expand\-line (M\-C\-e)
6324 Expand the line as the shell does. This
6325 performs alias and history expansion as well as all of the shell
6326 word expansions. See
6328 .B HISTORY EXPANSION
6329 below for a description of history expansion.
6331 .B history\-expand\-line (M\-^)
6332 Perform history expansion on the current line.
6335 .B HISTORY EXPANSION
6336 below for a description of history expansion.
6339 Perform history expansion on the current line and insert a space.
6342 .B HISTORY EXPANSION
6343 below for a description of history expansion.
6345 .B alias\-expand\-line
6346 Perform alias expansion on the current line.
6350 above for a description of alias expansion.
6352 .B history\-and\-alias\-expand\-line
6353 Perform history and alias expansion on the current line.
6355 .B insert\-last\-argument (M\-.\^, M\-_\^)
6356 A synonym for \fByank\-last\-arg\fP.
6358 .B operate\-and\-get\-next (C\-o)
6359 Accept the current line for execution and fetch the next line
6360 relative to the current line from the history for editing.
6361 A numeric argument, if supplied, specifies the history entry to use instead
6362 of the current line.
6364 .B edit\-and\-execute\-command (C\-x C\-e)
6365 Invoke an editor on the current command line, and execute the result as shell
6367 \fBBush\fP attempts to invoke
6372 and \fIemacs\fP as the editor, in that order.
6374 .SS Commands for Changing Text
6377 .B \fIend\-of\-file\fP (usually C\-d)
6378 The character indicating end-of-file as set, for example, by
6381 If this character is read when there are no characters
6382 on the line, and point is at the beginning of the line, Readline
6383 interprets it as the end of input and returns
6387 .B delete\-char (C\-d)
6388 Delete the character at point.
6389 If this function is bound to the
6390 same character as the tty \fBEOF\fP character, as \fBC\-d\fP
6391 commonly is, see above for the effects.
6393 .B backward\-delete\-char (Rubout)
6394 Delete the character behind the cursor. When given a numeric argument,
6395 save the deleted text on the kill ring.
6397 .B forward\-backward\-delete\-char
6398 Delete the character under the cursor, unless the cursor is at the
6399 end of the line, in which case the character behind the cursor is
6402 .B quoted\-insert (C\-q, C\-v)
6403 Add the next character typed to the line verbatim. This is
6404 how to insert characters like \fBC\-q\fP, for example.
6406 .B tab\-insert (C\-v TAB)
6407 Insert a tab character.
6409 .B self\-insert (a,\ b,\ A,\ 1,\ !,\ ...)
6410 Insert the character typed.
6412 .B transpose\-chars (C\-t)
6413 Drag the character before point forward over the character at point,
6414 moving point forward as well.
6415 If point is at the end of the line, then this transposes
6416 the two characters before point.
6417 Negative arguments have no effect.
6419 .B transpose\-words (M\-t)
6420 Drag the word before point past the word after point,
6421 moving point over that word as well.
6422 If point is at the end of the line, this transposes
6423 the last two words on the line.
6425 .B upcase\-word (M\-u)
6426 Uppercase the current (or following) word. With a negative argument,
6427 uppercase the previous word, but do not move point.
6429 .B downcase\-word (M\-l)
6430 Lowercase the current (or following) word. With a negative argument,
6431 lowercase the previous word, but do not move point.
6433 .B capitalize\-word (M\-c)
6434 Capitalize the current (or following) word. With a negative argument,
6435 capitalize the previous word, but do not move point.
6438 Toggle overwrite mode. With an explicit positive numeric argument,
6439 switches to overwrite mode. With an explicit non-positive numeric
6440 argument, switches to insert mode. This command affects only
6441 \fBemacs\fP mode; \fBvi\fP mode does overwrite differently.
6442 Each call to \fIreadline()\fP starts in insert mode.
6443 In overwrite mode, characters bound to \fBself\-insert\fP replace
6444 the text at point rather than pushing the text to the right.
6445 Characters bound to \fBbackward\-delete\-char\fP replace the character
6446 before point with a space. By default, this command is unbound.
6448 .SS Killing and Yanking
6451 .B kill\-line (C\-k)
6452 Kill the text from point to the end of the line.
6454 .B backward\-kill\-line (C\-x Rubout)
6455 Kill backward to the beginning of the line.
6457 .B unix\-line\-discard (C\-u)
6458 Kill backward from point to the beginning of the line.
6459 The killed text is saved on the kill-ring.
6460 .\" There is no real difference between this and backward-kill-line
6462 .B kill\-whole\-line
6463 Kill all characters on the current line, no matter where point is.
6465 .B kill\-word (M\-d)
6466 Kill from point to the end of the current word, or if between
6467 words, to the end of the next word.
6468 Word boundaries are the same as those used by \fBforward\-word\fP.
6470 .B backward\-kill\-word (M\-Rubout)
6471 Kill the word behind point.
6472 Word boundaries are the same as those used by \fBbackward\-word\fP.
6474 .B shell\-kill\-word
6475 Kill from point to the end of the current word, or if between
6476 words, to the end of the next word.
6477 Word boundaries are the same as those used by \fBshell\-forward\-word\fP.
6479 .B shell\-backward\-kill\-word
6480 Kill the word behind point.
6481 Word boundaries are the same as those used by \fBshell\-backward\-word\fP.
6483 .B unix\-word\-rubout (C\-w)
6484 Kill the word behind point, using white space as a word boundary.
6485 The killed text is saved on the kill-ring.
6487 .B unix\-filename\-rubout
6488 Kill the word behind point, using white space and the slash character
6489 as the word boundaries.
6490 The killed text is saved on the kill-ring.
6492 .B delete\-horizontal\-space (M\-\e)
6493 Delete all spaces and tabs around point.
6496 Kill the text in the current region.
6498 .B copy\-region\-as\-kill
6499 Copy the text in the region to the kill buffer.
6501 .B copy\-backward\-word
6502 Copy the word before point to the kill buffer.
6503 The word boundaries are the same as \fBbackward\-word\fP.
6505 .B copy\-forward\-word
6506 Copy the word following point to the kill buffer.
6507 The word boundaries are the same as \fBforward\-word\fP.
6510 Yank the top of the kill ring into the buffer at point.
6513 Rotate the kill ring, and yank the new top. Only works following
6518 .SS Numeric Arguments
6521 .B digit\-argument (M\-0, M\-1, ..., M\-\-)
6522 Add this digit to the argument already accumulating, or start a new
6523 argument. M\-\- starts a negative argument.
6525 .B universal\-argument
6526 This is another way to specify an argument.
6527 If this command is followed by one or more digits, optionally with a
6528 leading minus sign, those digits define the argument.
6529 If the command is followed by digits, executing
6530 .B universal\-argument
6531 again ends the numeric argument, but is otherwise ignored.
6532 As a special case, if this command is immediately followed by a
6533 character that is neither a digit nor minus sign, the argument count
6534 for the next command is multiplied by four.
6535 The argument count is initially one, so executing this function the
6536 first time makes the argument count four, a second time makes the
6537 argument count sixteen, and so on.
6543 Attempt to perform completion on the text before point.
6545 attempts completion treating the text as a variable (if the
6546 text begins with \fB$\fP), username (if the text begins with
6547 \fB~\fP), hostname (if the text begins with \fB@\fP), or
6548 command (including aliases and functions) in turn. If none
6549 of these produces a match, filename completion is attempted.
6551 .B possible\-completions (M\-?)
6552 List the possible completions of the text before point.
6554 .B insert\-completions (M\-*)
6555 Insert all completions of the text before point
6556 that would have been generated by
6557 \fBpossible\-completions\fP.
6560 Similar to \fBcomplete\fP, but replaces the word to be completed
6561 with a single match from the list of possible completions.
6562 Repeated execution of \fBmenu\-complete\fP steps through the list
6563 of possible completions, inserting each match in turn.
6564 At the end of the list of completions, the bell is rung
6565 (subject to the setting of \fBbell\-style\fP)
6566 and the original text is restored.
6567 An argument of \fIn\fP moves \fIn\fP positions forward in the list
6568 of matches; a negative argument may be used to move backward
6570 This command is intended to be bound to \fBTAB\fP, but is unbound
6573 .B menu\-complete\-backward
6574 Identical to \fBmenu\-complete\fP, but moves backward through the list
6575 of possible completions, as if \fBmenu\-complete\fP had been given a
6576 negative argument. This command is unbound by default.
6578 .B delete\-char\-or\-list
6579 Deletes the character under the cursor if not at the beginning or
6580 end of the line (like \fBdelete\-char\fP).
6581 If at the end of the line, behaves identically to
6582 \fBpossible\-completions\fP.
6583 This command is unbound by default.
6585 .B complete\-filename (M\-/)
6586 Attempt filename completion on the text before point.
6588 .B possible\-filename\-completions (C\-x /)
6589 List the possible completions of the text before point,
6590 treating it as a filename.
6592 .B complete\-username (M\-~)
6593 Attempt completion on the text before point, treating
6596 .B possible\-username\-completions (C\-x ~)
6597 List the possible completions of the text before point,
6598 treating it as a username.
6600 .B complete\-variable (M\-$)
6601 Attempt completion on the text before point, treating
6602 it as a shell variable.
6604 .B possible\-variable\-completions (C\-x $)
6605 List the possible completions of the text before point,
6606 treating it as a shell variable.
6608 .B complete\-hostname (M\-@)
6609 Attempt completion on the text before point, treating
6612 .B possible\-hostname\-completions (C\-x @)
6613 List the possible completions of the text before point,
6614 treating it as a hostname.
6616 .B complete\-command (M\-!)
6617 Attempt completion on the text before point, treating
6618 it as a command name. Command completion attempts to
6619 match the text against aliases, reserved words, shell
6620 functions, shell builtins, and finally executable filenames,
6623 .B possible\-command\-completions (C\-x !)
6624 List the possible completions of the text before point,
6625 treating it as a command name.
6627 .B dynamic\-complete\-history (M\-TAB)
6628 Attempt completion on the text before point, comparing
6629 the text against lines from the history list for possible
6633 Attempt menu completion on the text before point, comparing
6634 the text against lines from the history list for possible
6637 .B complete\-into\-braces (M\-{)
6638 Perform filename completion and insert the list of possible completions
6639 enclosed within braces so the list is available to the shell (see
6646 .B start\-kbd\-macro (C\-x (\^)
6647 Begin saving the characters typed into the current keyboard macro.
6649 .B end\-kbd\-macro (C\-x )\^)
6650 Stop saving the characters typed into the current keyboard macro
6651 and store the definition.
6653 .B call\-last\-kbd\-macro (C\-x e)
6654 Re-execute the last keyboard macro defined, by making the characters
6655 in the macro appear as if typed at the keyboard.
6657 .B print\-last\-kbd\-macro ()
6658 Print the last keyboard macro defined in a format suitable for the
6664 .B re\-read\-init\-file (C\-x C\-r)
6665 Read in the contents of the \fIinputrc\fP file, and incorporate
6666 any bindings or variable assignments found there.
6669 Abort the current editing command and
6670 ring the terminal's bell (subject to the setting of
6673 .B do\-lowercase\-version (M\-A, M\-B, M\-\fIx\fP, ...)
6674 If the metafied character \fIx\fP is uppercase, run the command
6675 that is bound to the corresponding metafied lowercase character.
6676 The behavior is undefined if \fIx\fP is already lowercase.
6678 .B prefix\-meta (ESC)
6679 Metafy the next character typed.
6686 .B undo (C\-_, C\-x C\-u)
6687 Incremental undo, separately remembered for each line.
6689 .B revert\-line (M\-r)
6690 Undo all changes made to this line. This is like executing the
6692 command enough times to return the line to its initial state.
6694 .B tilde\-expand (M\-&)
6695 Perform tilde expansion on the current word.
6697 .B set\-mark (C\-@, M\-<space>)
6698 Set the mark to the point. If a
6699 numeric argument is supplied, the mark is set to that position.
6701 .B exchange\-point\-and\-mark (C\-x C\-x)
6702 Swap the point with the mark. The current cursor position is set to
6703 the saved position, and the old cursor position is saved as the mark.
6705 .B character\-search (C\-])
6706 A character is read and point is moved to the next occurrence of that
6707 character. A negative count searches for previous occurrences.
6709 .B character\-search\-backward (M\-C\-])
6710 A character is read and point is moved to the previous occurrence of that
6711 character. A negative count searches for subsequent occurrences.
6713 .B skip\-csi\-sequence
6714 Read enough characters to consume a multi-key sequence such as those
6715 defined for keys like Home and End. Such sequences begin with a
6716 Control Sequence Indicator (CSI), usually ESC\-[. If this sequence is
6717 bound to "\e[", keys producing such sequences will have no effect
6718 unless explicitly bound to a readline command, instead of inserting
6719 stray characters into the editing buffer. This is unbound by default,
6720 but usually bound to ESC\-[.
6722 .B insert\-comment (M\-#)
6723 Without a numeric argument, the value of the readline
6725 variable is inserted at the beginning of the current line.
6726 If a numeric argument is supplied, this command acts as a toggle: if
6727 the characters at the beginning of the line do not match the value
6728 of \fBcomment\-begin\fP, the value is inserted, otherwise
6729 the characters in \fBcomment\-begin\fP are deleted from the beginning of
6731 In either case, the line is accepted as if a newline had been typed.
6732 The default value of
6733 \fBcomment\-begin\fP causes this command to make the current line
6735 If a numeric argument causes the comment character to be removed, the line
6736 will be executed by the shell.
6738 .B glob\-complete\-word (M\-g)
6739 The word before point is treated as a pattern for pathname expansion,
6740 with an asterisk implicitly appended. This pattern is used to
6741 generate a list of matching filenames for possible completions.
6743 .B glob\-expand\-word (C\-x *)
6744 The word before point is treated as a pattern for pathname expansion,
6745 and the list of matching filenames is inserted, replacing the word.
6746 If a numeric argument is supplied, an asterisk is appended before
6749 .B glob\-list\-expansions (C\-x g)
6750 The list of expansions that would have been generated by
6751 .B glob\-expand\-word
6752 is displayed, and the line is redrawn.
6753 If a numeric argument is supplied, an asterisk is appended before
6757 Print all of the functions and their key bindings to the
6758 readline output stream. If a numeric argument is supplied,
6759 the output is formatted in such a way that it can be made part
6760 of an \fIinputrc\fP file.
6763 Print all of the settable readline variables and their values to the
6764 readline output stream. If a numeric argument is supplied,
6765 the output is formatted in such a way that it can be made part
6766 of an \fIinputrc\fP file.
6769 Print all of the readline key sequences bound to macros and the
6770 strings they output. If a numeric argument is supplied,
6771 the output is formatted in such a way that it can be made part
6772 of an \fIinputrc\fP file.
6774 .B display\-shell\-version (C\-x C\-v)
6775 Display version information about the current instance of
6778 .SS Programmable Completion
6779 When word completion is attempted for an argument to a command for
6780 which a completion specification (a \fIcompspec\fP) has been defined
6781 using the \fBcomplete\fP builtin (see
6783 .B "SHELL BUILTIN COMMANDS"
6784 below), the programmable completion facilities are invoked.
6786 First, the command name is identified.
6787 If the command word is the empty string (completion attempted at the
6788 beginning of an empty line), any compspec defined with
6789 the \fB\-E\fP option to \fBcomplete\fP is used.
6790 If a compspec has been defined for that command, the
6791 compspec is used to generate the list of possible completions for the word.
6792 If the command word is a full pathname, a compspec for the full
6793 pathname is searched for first.
6794 If no compspec is found for the full pathname, an attempt is made to
6795 find a compspec for the portion following the final slash.
6796 If those searches do not result in a compspec, any compspec defined with
6797 the \fB\-D\fP option to \fBcomplete\fP is used as the default.
6798 If there is no default compspec, \fBbush\fP attempts alias expansion
6799 on the command word as a final resort, and attempts to find a compspec
6800 for the command word from any successful expansion.
6802 Once a compspec has been found, it is used to generate the list of
6804 If a compspec is not found, the default \fBbush\fP completion as
6805 described above under \fBCompleting\fP is performed.
6807 First, the actions specified by the compspec are used.
6808 Only matches which are prefixed by the word being completed are
6814 option is used for filename or directory name completion, the shell
6818 is used to filter the matches.
6820 Any completions specified by a pathname expansion pattern to the
6821 \fB\-G\fP option are generated next.
6822 The words generated by the pattern need not match the word
6827 shell variable is not used to filter the matches, but the
6832 Next, the string specified as the argument to the \fB\-W\fP option
6834 The string is first split using the characters in the
6837 special variable as delimiters.
6838 Shell quoting is honored.
6839 Each word is then expanded using
6840 brace expansion, tilde expansion, parameter and variable expansion,
6841 command substitution, and arithmetic expansion,
6842 as described above under
6845 The results are split using the rules described above under
6846 \fBWord Splitting\fP.
6847 The results of the expansion are prefix-matched against the word being
6848 completed, and the matching words become the possible completions.
6850 After these matches have been generated, any shell function or command
6851 specified with the \fB\-F\fP and \fB\-C\fP options is invoked.
6852 When the command or function is invoked, the
6862 variables are assigned values as described above under
6863 \fBShell Variables\fP.
6864 If a shell function is being invoked, the
6870 variables are also set.
6871 When the function or command is invoked,
6872 the first argument (\fB$1\fP) is the name of the command whose arguments are
6874 the second argument (\fB$2\fP) is the word being completed,
6875 and the third argument (\fB$3\fP) is the word preceding the word being
6876 completed on the current command line.
6877 No filtering of the generated completions against the word being completed
6878 is performed; the function or command has complete freedom in generating
6881 Any function specified with \fB\-F\fP is invoked first.
6882 The function may use any of the shell facilities, including the
6883 \fBcompgen\fP builtin described below, to generate the matches.
6884 It must put the possible completions in the
6887 array variable, one per array element.
6889 Next, any command specified with the \fB\-C\fP option is invoked
6890 in an environment equivalent to command substitution.
6891 It should print a list of completions, one per line, to the
6893 Backslash may be used to escape a newline, if necessary.
6895 After all of the possible completions are generated, any filter
6896 specified with the \fB\-X\fP option is applied to the list.
6897 The filter is a pattern as used for pathname expansion; a \fB&\fP
6898 in the pattern is replaced with the text of the word being completed.
6899 A literal \fB&\fP may be escaped with a backslash; the backslash
6900 is removed before attempting a match.
6901 Any completion that matches the pattern will be removed from the list.
6902 A leading \fB!\fP negates the pattern; in this case any completion
6903 not matching the pattern will be removed.
6906 shell option is enabled, the match is performed without regard to the case
6907 of alphabetic characters.
6909 Finally, any prefix and suffix specified with the \fB\-P\fP and \fB\-S\fP
6910 options are added to each member of the completion list, and the result is
6911 returned to the readline completion code as the list of possible
6914 If the previously-applied actions do not generate any matches, and the
6915 \fB\-o dirnames\fP option was supplied to \fBcomplete\fP when the
6916 compspec was defined, directory name completion is attempted.
6918 If the \fB\-o plusdirs\fP option was supplied to \fBcomplete\fP when the
6919 compspec was defined, directory name completion is attempted and any
6920 matches are added to the results of the other actions.
6922 By default, if a compspec is found, whatever it generates is returned
6923 to the completion code as the full set of possible completions.
6924 The default \fBbush\fP completions are not attempted, and the readline
6925 default of filename completion is disabled.
6926 If the \fB\-o bushdefault\fP option was supplied to \fBcomplete\fP when
6927 the compspec was defined, the \fBbush\fP default completions are attempted
6928 if the compspec generates no matches.
6929 If the \fB\-o default\fP option was supplied to \fBcomplete\fP when the
6930 compspec was defined, readline's default completion will be performed
6931 if the compspec (and, if attempted, the default \fBbush\fP completions)
6932 generate no matches.
6934 When a compspec indicates that directory name completion is desired,
6935 the programmable completion functions force readline to append a slash
6936 to completed names which are symbolic links to directories, subject to
6937 the value of the \fBmark\-directories\fP readline variable, regardless
6938 of the setting of the \fBmark-symlinked\-directories\fP readline variable.
6940 There is some support for dynamically modifying completions. This is
6941 most useful when used in combination with a default completion specified
6942 with \fBcomplete \-D\fP.
6943 It's possible for shell functions executed as completion
6944 handlers to indicate that completion should be retried by returning an
6945 exit status of 124. If a shell function returns 124, and changes
6946 the compspec associated with the command on which completion is being
6947 attempted (supplied as the first argument when the function is executed),
6948 programmable completion restarts from the beginning, with an
6949 attempt to find a new compspec for that command. This allows a set of
6950 completions to be built dynamically as completion is attempted, rather than
6951 being loaded all at once.
6953 For instance, assuming that there is a library of compspecs, each kept in a
6954 file corresponding to the name of the command, the following default
6955 completion function would load completions dynamically:
6957 \f(CW_completion_loader()
6961 . "/etc/bush_completion.d/$1.sh" >/dev/null 2>&1 && return 124
6965 complete -D -F _completion_loader -o bushdefault -o default
6973 builtin is enabled, the shell provides access to the
6974 \fIcommand history\fP,
6975 the list of commands previously typed.
6979 variable is used as the
6980 number of commands to save in a history list.
6981 The text of the last
6984 commands (default 500) is saved. The shell
6985 stores each command in the history list prior to parameter and
6986 variable expansion (see
6989 above) but after history expansion is performed, subject to the
6990 values of the shell variables
6997 On startup, the history is initialized from the file named by
7001 (default \fI~/.bush_history\fP).
7002 The file named by the value of
7005 is truncated, if necessary, to contain no more than
7006 the number of lines specified by the value of
7009 If \fBHISTFILESIZE\fP is unset, or set to null, a non-numeric value,
7010 or a numeric value less than zero, the history file is not truncated.
7011 When the history file is read,
7012 lines beginning with the history comment character followed immediately
7013 by a digit are interpreted as timestamps for the following history line.
7014 These timestamps are optionally displayed depending on the value of the
7018 When a shell with history enabled exits, the last
7021 lines are copied from the history list to
7026 shell option is enabled
7027 (see the description of
7031 .B "SHELL BUILTIN COMMANDS"
7032 below), the lines are appended to the history file,
7033 otherwise the history file is overwritten.
7037 is unset, or if the history file is unwritable, the history is
7042 variable is set, time stamps are written to the history file, marked
7043 with the history comment character, so
7044 they may be preserved across shell sessions.
7045 This uses the history comment character to distinguish timestamps from
7046 other history lines.
7047 After saving the history, the history file is truncated
7048 to contain no more than
7054 is unset, or set to null, a non-numeric value,
7055 or a numeric value less than zero, the history file is not truncated.
7061 .B SHELL BUILTIN COMMANDS
7062 below) may be used to list or edit and re-execute a portion of
7066 builtin may be used to display or modify the history list and
7067 manipulate the history file.
7068 When using command-line editing, search commands
7069 are available in each editing mode that provide access to the
7072 The shell allows control over which commands are saved on the history
7079 variables may be set to cause the shell to save only a subset of the
7083 shell option, if enabled, causes the shell to attempt to save each
7084 line of a multi-line command in the same history entry, adding
7085 semicolons where necessary to preserve syntactic correctness.
7088 shell option causes the shell to save the command with embedded newlines
7089 instead of semicolons. See the description of the
7093 .B "SHELL BUILTIN COMMANDS"
7094 for information on setting and unsetting shell options.
7095 .SH "HISTORY EXPANSION"
7096 The shell supports a history expansion feature that
7097 is similar to the history expansion in
7099 This section describes what syntax features are available. This
7100 feature is enabled by default for interactive shells, and can be
7105 builtin command (see
7107 .B SHELL BUILTIN COMMANDS
7108 below). Non-interactive shells do not perform history expansion
7111 History expansions introduce words from the history list into
7112 the input stream, making it easy to repeat commands, insert the
7113 arguments to a previous command into the current input line, or
7114 fix errors in previous commands quickly.
7116 History expansion is performed immediately after a complete line
7117 is read, before the shell breaks it into words, and is performed
7118 on each line individually without taking quoting on previous lines into
7120 It takes place in two parts.
7121 The first is to determine which line from the history list
7122 to use during substitution.
7123 The second is to select portions of that line for inclusion into
7125 The line selected from the history is the \fIevent\fP,
7126 and the portions of that line that are acted upon are \fIwords\fP.
7127 Various \fImodifiers\fP are available to manipulate the selected words.
7128 The line is broken into words in the same fashion as when reading input,
7129 so that several \fImetacharacter\fP-separated words surrounded by
7130 quotes are considered one word.
7131 History expansions are introduced by the appearance of the
7132 history expansion character, which is \^\fB!\fP\^ by default.
7133 Only backslash (\^\fB\e\fP\^) and single quotes can quote
7134 the history expansion character, but the history expansion character is
7135 also treated as quoted if it immediately precedes the closing double quote
7136 in a double-quoted string.
7138 Several characters inhibit history expansion if found immediately
7139 following the history expansion character, even if it is unquoted:
7140 space, tab, newline, carriage return, and \fB=\fP.
7141 If the \fBextglob\fP shell option is enabled, \fB(\fP will also
7144 Several shell options settable with the
7146 builtin may be used to tailor the behavior of history expansion.
7149 shell option is enabled (see the description of the
7153 is being used, history substitutions are not immediately passed to
7155 Instead, the expanded line is reloaded into the
7157 editing buffer for further modification.
7160 is being used, and the
7162 shell option is enabled, a failed history substitution will be reloaded
7165 editing buffer for correction.
7170 builtin command may be used to see what a history expansion will
7176 builtin may be used to add commands to the end of the history list
7177 without actually executing them, so that they are available for
7180 The shell allows control of the various characters used by the
7181 history expansion mechanism (see the description of
7184 .BR "Shell Variables" ).
7186 the history comment character to mark history timestamps when
7187 writing the history file.
7188 .SS Event Designators
7189 An event designator is a reference to a command line entry in the
7191 Unless the reference is absolute, events are relative to the current
7192 position in the history list.
7197 Start a history substitution, except when followed by a
7199 newline, carriage return, =
7200 or ( (when the \fBextglob\fP shell option is enabled using
7201 the \fBshopt\fP builtin).
7204 Refer to command line
7208 Refer to the current command minus
7212 Refer to the previous command. This is a synonym for `!\-1'.
7215 Refer to the most recent command preceding the current position in the
7216 history list starting with
7219 .B !?\fIstring\fR\fB[?]\fR
7220 Refer to the most recent command preceding the current position in the
7221 history list containing
7223 The trailing \fB?\fP may be omitted if
7225 is followed immediately by a newline.
7226 If \fIstring\fP is missing, the string from the most recent search is used;
7227 it is an error if there is no previous search string.
7229 .B \d\s+2^\s-2\u\fIstring1\fP\d\s+2^\s-2\u\fIstring2\fP\d\s+2^\s-2\u
7230 Quick substitution. Repeat the previous command, replacing
7235 ``!!:s\d\s+2^\s-2\u\fIstring1\fP\d\s+2^\s-2\u\fIstring2\fP\d\s+2^\s-2\u''
7236 (see \fBModifiers\fP below).
7239 The entire command line typed so far.
7241 .SS Word Designators
7242 Word designators are used to select desired words from the event.
7245 separates the event specification from the word designator.
7246 It may be omitted if the word designator begins with a
7253 Words are numbered from the beginning of the line,
7254 with the first word being denoted by 0 (zero).
7255 Words are inserted into the current line separated by single spaces.
7260 The zeroth word. For the shell, this is the command
7267 The first argument. That is, word 1.
7270 The last word. This is usually the last argument, but will expand to the
7271 zeroth word if there is only one word in the line.
7274 The first word matched by the most recent `?\fIstring\fR?' search,
7275 if the search string begins with a character that is part of a word.
7278 A range of words; `\-\fIy\fR' abbreviates `0\-\fIy\fR'.
7281 All of the words but the zeroth. This is a synonym
7282 for `\fI1\-$\fP'. It is not an error to use
7284 if there is just one
7285 word in the event; the empty string is returned in that case.
7288 Abbreviates \fIx\-$\fP.
7291 Abbreviates \fIx\-$\fP like \fBx*\fP, but omits the last word.
7292 If \fBx\fP is missing, it defaults to 0.
7295 If a word designator is supplied without an event specification, the
7296 previous command is used as the event.
7298 After the optional word designator, there may appear a sequence of
7299 one or more of the following modifiers, each preceded by a `:'.
7300 These modify, or edit, the word or words selected from the history event.
7305 Remove a trailing filename component, leaving only the head.
7308 Remove all leading filename components, leaving the tail.
7311 Remove a trailing suffix of the form \fI.xxx\fP, leaving the
7315 Remove all but the trailing suffix.
7318 Print the new command but do not execute it.
7321 Quote the substituted words, escaping further substitutions.
7324 Quote the substituted words as with
7326 but break into words at
7329 The \fBq\fP and \fBx\fP modifiers are mutually exclusive; the last one
7332 .B s/\fIold\fP/\fInew\fP/
7335 for the first occurrence of
7338 Any character may be used as the delimiter in place of /.
7339 The final delimiter is optional if it is the last character of the
7341 The delimiter may be quoted in
7345 with a single backslash. If & appears in
7349 A single backslash will quote the &.
7352 is null, it is set to the last
7354 substituted, or, if no previous history substitutions took place,
7358 .B !?\fIstring\fR\fB[?]\fR
7362 is null, each matching
7367 Repeat the previous substitution.
7370 Cause changes to be applied over the entire event line. This is
7371 used in conjunction with `\fB:s\fP' (e.g., `\fB:gs/\fIold\fP/\fInew\fP/\fR')
7372 or `\fB:&\fP'. If used with
7373 `\fB:s\fP', any delimiter can be used
7374 in place of /, and the final delimiter is optional
7375 if it is the last character of the event line.
7376 An \fBa\fP may be used as a synonym for \fBg\fP.
7379 Apply the following `\fBs\fP' or `\fB&\fP' modifier once to each word
7382 .SH "SHELL BUILTIN COMMANDS"
7383 .\" start of bush_builtins
7386 Unless otherwise noted, each builtin command documented in this
7387 section as accepting options preceded by
7391 to signify the end of the options.
7392 The \fB:\fP, \fBtrue\fP, \fBfalse\fP, and \fBtest\fP/\fB[\fP builtins
7393 do not accept options and do not treat \fB\-\-\fP specially.
7394 The \fBexit\fP, \fBlogout\fP, \fBreturn\fP,
7395 \fBbreak\fP, \fBcontinue\fP, \fBlet\fP,
7396 and \fBshift\fP builtins accept and process arguments beginning with
7397 \fB\-\fP without requiring \fB\-\-\fP.
7398 Other builtins that accept arguments but are not specified as accepting
7399 options interpret arguments beginning with \fB\-\fP as invalid options and
7400 require \fB\-\-\fP to prevent this interpretation.
7404 \fB:\fP [\fIarguments\fP]
7406 No effect; the command does nothing beyond expanding
7408 and performing any specified
7410 The return status is zero.
7412 \fB .\| \fP \fIfilename\fP [\fIarguments\fP]
7415 \fBsource\fP \fIfilename\fP [\fIarguments\fP]
7417 Read and execute commands from
7420 shell environment and return the exit status of the last command
7425 does not contain a slash, filenames in
7428 are used to find the directory containing
7430 The file searched for in
7433 need not be executable.
7434 When \fBbush\fP is not in \fIposix mode\fP, the current directory is
7435 searched if no file is found in
7442 builtin command is turned off, the
7446 If any \fIarguments\fP are supplied, they become the positional
7447 parameters when \fIfilename\fP is executed. Otherwise the positional
7448 parameters are unchanged.
7449 If the \fB\-T\fP option is enabled, \fBsource\fP inherits any trap on
7450 \fBDEBUG\fP; if it is not, any \fBDEBUG\fP trap string is saved and
7451 restored around the call to \fBsource\fP, and \fBsource\fP unsets the
7452 \fBDEBUG\fP trap while it executes.
7453 If \fB\-T\fP is not set, and the sourced file changes
7454 the \fBDEBUG\fP trap, the new value is retained when \fBsource\fP completes.
7455 The return status is the status of the last command exited within
7456 the script (0 if no commands are executed), and false if
7458 is not found or cannot be read.
7460 \fBalias\fP [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
7461 \fBAlias\fP with no arguments or with the
7463 option prints the list of aliases in the form
7464 \fBalias\fP \fIname\fP=\fIvalue\fP on standard output.
7465 When arguments are supplied, an alias is defined for
7466 each \fIname\fP whose \fIvalue\fP is given.
7467 A trailing space in \fIvalue\fP causes the next word to be
7468 checked for alias substitution when the alias is expanded.
7469 For each \fIname\fP in the argument list for which no \fIvalue\fP
7470 is supplied, the name and value of the alias is printed.
7471 \fBAlias\fP returns true unless a \fIname\fP is given for which
7472 no alias has been defined.
7474 \fBbg\fP [\fIjobspec\fP ...]
7475 Resume each suspended job \fIjobspec\fP in the background, as if it
7476 had been started with
7480 is not present, the shell's notion of the \fIcurrent job\fP is used.
7483 returns 0 unless run when job control is disabled or, when run with
7484 job control enabled, any specified \fIjobspec\fP was not found
7485 or was started without job control.
7487 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-lpsvPSVX\fP]
7490 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-q\fP \fIfunction\fP] [\fB\-u\fP \fIfunction\fP] [\fB\-r\fP \fIkeyseq\fP]
7492 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-f\fP \fIfilename\fP
7494 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-x\fP \fIkeyseq\fP:\fIshell\-command\fP
7496 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fIkeyseq\fP:\fIfunction\-name\fP
7498 \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fIkeyseq\fP:\fIreadline\-command\fP
7502 key and function bindings, bind a key sequence to a
7504 function or macro, or set a
7507 Each non-option argument is a command as it would appear in
7509 but each binding or command must be passed as a separate argument;
7510 e.g., '"\eC\-x\eC\-r": re\-read\-init\-file'.
7511 Options, if supplied, have the following meanings:
7518 as the keymap to be affected by the subsequent bindings.
7522 \fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi,
7523 vi\-move, vi\-command\fP, and
7525 \fIvi\fP is equivalent to \fIvi\-command\fP (\fIvi\-move\fP is also
7526 a synonym); \fIemacs\fP is
7527 equivalent to \fIemacs\-standard\fP.
7530 List the names of all \fBreadline\fP functions.
7533 Display \fBreadline\fP function names and bindings in such a way
7534 that they can be re-read.
7537 List current \fBreadline\fP function names and bindings.
7540 Display \fBreadline\fP key sequences bound to macros and the strings
7541 they output in such a way that they can be re-read.
7544 Display \fBreadline\fP key sequences bound to macros and the strings
7548 Display \fBreadline\fP variable names and values in such a way that they
7552 List current \fBreadline\fP variable names and values.
7554 .B \-f \fIfilename\fP
7555 Read key bindings from \fIfilename\fP.
7557 .B \-q \fIfunction\fP
7558 Query about which keys invoke the named \fIfunction\fP.
7560 .B \-u \fIfunction\fP
7561 Unbind all keys bound to the named \fIfunction\fP.
7564 Remove any current binding for \fIkeyseq\fP.
7566 .B \-x \fIkeyseq\fP:\fIshell\-command\fP
7567 Cause \fIshell\-command\fP to be executed whenever \fIkeyseq\fP is
7569 When \fIshell\-command\fP is executed, the shell sets the
7572 variable to the contents of the \fBreadline\fP line buffer and the
7578 variables to the current location of the insertion point and the saved
7579 insertion point (the mark), respectively.
7580 If the executed command changes the value of any of
7584 .BR READLINE_POINT ,
7588 those new values will be reflected in the editing state.
7591 List all key sequences bound to shell commands and the associated commands
7592 in a format that can be reused as input.
7595 The return value is 0 unless an unrecognized option is given or an
7599 \fBbreak\fP [\fIn\fP]
7606 loop. If \fIn\fP is specified, break \fIn\fP levels.
7610 is greater than the number of enclosing loops, all enclosing loops
7612 The return value is 0 unless \fIn\fP is not greater than or equal to 1.
7614 \fBbuiltin\fP \fIshell\-builtin\fP [\fIarguments\fP]
7615 Execute the specified shell builtin, passing it
7617 and return its exit status.
7618 This is useful when defining a
7619 function whose name is the same as a shell builtin,
7620 retaining the functionality of the builtin within the function.
7621 The \fBcd\fP builtin is commonly redefined this way.
7622 The return status is false if
7624 is not a shell builtin command.
7626 \fBcaller\fP [\fIexpr\fP]
7627 Returns the context of any active subroutine call (a shell function or
7628 a script executed with the \fB.\fP or \fBsource\fP builtins).
7629 Without \fIexpr\fP, \fBcaller\fP displays the line number and source
7630 filename of the current subroutine call.
7631 If a non-negative integer is supplied as \fIexpr\fP, \fBcaller\fP
7632 displays the line number, subroutine name, and source file corresponding
7633 to that position in the current execution call stack. This extra
7634 information may be used, for example, to print a stack trace. The
7635 current frame is frame 0.
7636 The return value is 0 unless the shell is not executing a subroutine
7637 call or \fIexpr\fP does not correspond to a valid position in the
7640 \fBcd\fP [\fB\-L\fP|[\fB\-P\fP [\fB\-e\fP]] [\-@]] [\fIdir\fP]
7641 Change the current directory to \fIdir\fP.
7642 if \fIdir\fP is not supplied, the value of the
7645 shell variable is the default.
7646 Any additional arguments following \fIdir\fP are ignored.
7650 defines the search path for the directory containing
7652 each directory name in
7655 is searched for \fIdir\fP.
7656 Alternative directory names in
7659 are separated by a colon (:). A null directory name in
7662 is the same as the current directory, i.e., ``\fB.\fP''. If
7664 begins with a slash (/),
7670 option causes \fBcd\fP to use the physical directory structure
7671 by resolving symbolic links while traversing \fIdir\fP and
7672 before processing instances of \fI..\fP in \fIdir\fP (see also the
7676 builtin command); the
7678 option forces symbolic links to be followed by resolving the link
7679 after processing instances of \fI..\fP in \fIdir\fP.
7680 If \fI..\fP appears in \fIdir\fP, it is processed by removing the
7681 immediately previous pathname component from \fIdir\fP, back to a slash
7682 or the beginning of \fIdir\fP.
7685 option is supplied with
7687 and the current working directory cannot be successfully determined
7688 after a successful directory change, \fBcd\fP will return an unsuccessful
7690 On systems that support it, the \fB\-@\fP option presents the extended
7691 attributes associated with a file as a directory.
7697 before the directory change is attempted.
7698 If a non-empty directory name from
7702 \fB\-\fP is the first argument, and the directory change is
7703 successful, the absolute pathname of the new working directory is
7704 written to the standard output.
7705 The return value is true if the directory was successfully changed;
7708 \fBcommand\fP [\fB\-pVv\fP] \fIcommand\fP [\fIarg\fP ...]
7713 suppressing the normal shell function lookup.
7714 Only builtin commands or commands found in the
7717 are executed. If the
7719 option is given, the search for
7721 is performed using a default value for
7724 that is guaranteed to find all of the standard utilities.
7729 option is supplied, a description of
7733 option causes a single word indicating the command or filename
7736 to be displayed; the
7738 option produces a more verbose description.
7743 option is supplied, the exit status is 0 if
7745 was found, and 1 if not. If neither option is supplied and
7746 an error occurred or
7748 cannot be found, the exit status is 127. Otherwise, the exit status of the
7750 builtin is the exit status of
7753 \fBcompgen\fP [\fIoption\fP] [\fIword\fP]
7754 Generate possible completion matches for \fIword\fP according to
7755 the \fIoption\fPs, which may be any option accepted by the
7757 builtin with the exception of \fB\-p\fP and \fB\-r\fP, and write
7758 the matches to the standard output.
7759 When using the \fB\-F\fP or \fB\-C\fP options, the various shell variables
7760 set by the programmable completion facilities, while available, will not
7763 The matches will be generated in the same way as if the programmable
7764 completion code had generated them directly from a completion specification
7765 with the same flags.
7766 If \fIword\fP is specified, only those completions matching \fIword\fP
7769 The return value is true unless an invalid option is supplied, or no
7770 matches were generated.
7772 \fBcomplete\fP [\fB\-abcdefgjksuv\fP] [\fB\-o\fP \fIcomp-option\fP] [\fB\-DEI\fP] [\fB\-A\fP \fIaction\fP] [\fB\-G\fP \fIglobpat\fP] [\fB\-W\fP \fIwordlist\fP]
7774 [\fB\-F\fP \fIfunction\fP] [\fB\-C\fP \fIcommand\fP] [\fB\-X\fP \fIfilterpat\fP] [\fB\-P\fP \fIprefix\fP] [\fB\-S\fP \fIsuffix\fP] \fIname\fP [\fIname ...\fP]
7777 \fBcomplete\fP \fB\-pr\fP [\fB\-DEI\fP] [\fIname\fP ...]
7779 Specify how arguments to each \fIname\fP should be completed.
7780 If the \fB\-p\fP option is supplied, or if no options are supplied,
7781 existing completion specifications are printed in a way that allows
7782 them to be reused as input.
7783 The \fB\-r\fP option removes a completion specification for
7784 each \fIname\fP, or, if no \fIname\fPs are supplied, all
7785 completion specifications.
7786 The \fB\-D\fP option indicates that other supplied options and actions should
7787 apply to the ``default'' command completion; that is, completion attempted
7788 on a command for which no completion has previously been defined.
7789 The \fB\-E\fP option indicates that other supplied options and actions should
7790 apply to ``empty'' command completion; that is, completion attempted on a
7792 The \fB\-I\fP option indicates that other supplied options and actions should
7793 apply to completion on the initial non-assignment word on the line, or after
7794 a command delimiter such as \fB;\fP or \fB|\fP, which is usually command
7796 If multiple options are supplied, the \fB\-D\fP option takes precedence
7797 over \fB\-E\fP, and both take precedence over \fB\-I\fP.
7798 If any of \fB\-D\fP, \fB\-E\fP, or \fB\-I\fP are supplied, any other
7799 \fIname\fP arguments are ignored; these completions only apply to the case
7800 specified by the option.
7802 The process of applying these completion specifications when word completion
7803 is attempted is described above under \fBProgrammable Completion\fP.
7805 Other options, if specified, have the following meanings.
7806 The arguments to the \fB\-G\fP, \fB\-W\fP, and \fB\-X\fP options
7807 (and, if necessary, the \fB\-P\fP and \fB\-S\fP options)
7808 should be quoted to protect them from expansion before the
7814 \fB\-o\fP \fIcomp-option\fP
7815 The \fIcomp-option\fP controls several aspects of the compspec's behavior
7816 beyond the simple generation of completions.
7817 \fIcomp-option\fP may be one of:
7821 Perform the rest of the default \fBbush\fP completions if the compspec
7822 generates no matches.
7825 Use readline's default filename completion if the compspec generates
7829 Perform directory name completion if the compspec generates no matches.
7832 Tell readline that the compspec generates filenames, so it can perform any
7833 filename\-specific processing (like adding a slash to directory names,
7834 quoting special characters, or suppressing trailing spaces).
7835 Intended to be used with shell functions.
7838 Tell readline not to quote the completed words if they are filenames
7839 (quoting filenames is the default).
7842 Tell readline not to sort the list of possible completions alphabetically.
7845 Tell readline not to append a space (the default) to words completed at
7846 the end of the line.
7849 After any matches defined by the compspec are generated,
7850 directory name completion is attempted and any
7851 matches are added to the results of the other actions.
7854 \fB\-A\fP \fIaction\fP
7855 The \fIaction\fP may be one of the following to generate a list of possible
7860 Alias names. May also be specified as \fB\-a\fP.
7863 Array variable names.
7866 \fBReadline\fP key binding names.
7869 Names of shell builtin commands. May also be specified as \fB\-b\fP.
7872 Command names. May also be specified as \fB\-c\fP.
7875 Directory names. May also be specified as \fB\-d\fP.
7878 Names of disabled shell builtins.
7881 Names of enabled shell builtins.
7884 Names of exported shell variables. May also be specified as \fB\-e\fP.
7887 File names. May also be specified as \fB\-f\fP.
7890 Names of shell functions.
7893 Group names. May also be specified as \fB\-g\fP.
7896 Help topics as accepted by the \fBhelp\fP builtin.
7899 Hostnames, as taken from the file specified by the
7905 Job names, if job control is active. May also be specified as \fB\-j\fP.
7908 Shell reserved words. May also be specified as \fB\-k\fP.
7911 Names of running jobs, if job control is active.
7914 Service names. May also be specified as \fB\-s\fP.
7917 Valid arguments for the \fB\-o\fP option to the \fBset\fP builtin.
7920 Shell option names as accepted by the \fBshopt\fP builtin.
7926 Names of stopped jobs, if job control is active.
7929 User names. May also be specified as \fB\-u\fP.
7932 Names of all shell variables. May also be specified as \fB\-v\fP.
7935 \fB\-C\fP \fIcommand\fP
7936 \fIcommand\fP is executed in a subshell environment, and its output is
7937 used as the possible completions.
7939 \fB\-F\fP \fIfunction\fP
7940 The shell function \fIfunction\fP is executed in the current shell
7942 When the function is executed,
7943 the first argument (\fB$1\fP) is the name of the command whose arguments are
7945 the second argument (\fB$2\fP) is the word being completed,
7946 and the third argument (\fB$3\fP) is the word preceding the word being
7947 completed on the current command line.
7948 When it finishes, the possible completions are retrieved from the value
7954 \fB\-G\fP \fIglobpat\fP
7955 The pathname expansion pattern \fIglobpat\fP is expanded to generate
7956 the possible completions.
7958 \fB\-P\fP \fIprefix\fP
7959 \fIprefix\fP is added at the beginning of each possible completion
7960 after all other options have been applied.
7962 \fB\-S\fP \fIsuffix\fP
7963 \fIsuffix\fP is appended to each possible completion
7964 after all other options have been applied.
7966 \fB\-W\fP \fIwordlist\fP
7967 The \fIwordlist\fP is split using the characters in the
7970 special variable as delimiters, and each resultant word is expanded.
7971 Shell quoting is honored within \fIwordlist\fP,
7972 in order to provide a
7973 mechanism for the words to contain shell metacharacters or characters
7977 The possible completions are the members of the resultant list which
7978 match the word being completed.
7980 \fB\-X\fP \fIfilterpat\fP
7981 \fIfilterpat\fP is a pattern as used for pathname expansion.
7982 It is applied to the list of possible completions generated by the
7983 preceding options and arguments, and each completion matching
7984 \fIfilterpat\fP is removed from the list.
7985 A leading \fB!\fP in \fIfilterpat\fP negates the pattern; in this
7986 case, any completion not matching \fIfilterpat\fP is removed.
7989 The return value is true unless an invalid option is supplied, an option
7990 other than \fB\-p\fP or \fB\-r\fP is supplied without a \fIname\fP
7991 argument, an attempt is made to remove a completion specification for
7992 a \fIname\fP for which no specification exists, or
7993 an error occurs adding a completion specification.
7996 \fBcompopt\fP [\fB\-o\fP \fIoption\fP] [\fB\-DEI\fP] [\fB+o\fP \fIoption\fP] [\fIname\fP]
7997 Modify completion options for each \fIname\fP according to the
7998 \fIoption\fPs, or for the
7999 currently-executing completion if no \fIname\fPs are supplied.
8000 If no \fIoption\fPs are given, display the completion options for each
8001 \fIname\fP or the current completion.
8002 The possible values of \fIoption\fP are those valid for the \fBcomplete\fP
8003 builtin described above.
8004 The \fB\-D\fP option indicates that other supplied options should
8005 apply to the ``default'' command completion; that is, completion attempted
8006 on a command for which no completion has previously been defined.
8007 The \fB\-E\fP option indicates that other supplied options should
8008 apply to ``empty'' command completion; that is, completion attempted on a
8010 The \fB\-I\fP option indicates that other supplied options should
8011 apply to completion on the initial non-assignment word on the line,
8012 or after a command delimiter such as \fB;\fP or \fB|\fP, which is usually
8013 command name completion.
8015 The return value is true unless an invalid option is supplied, an attempt
8016 is made to modify the options for a \fIname\fP for which no completion
8017 specification exists, or an output error occurs.
8019 \fBcontinue\fP [\fIn\fP]
8020 Resume the next iteration of the enclosing
8029 is specified, resume at the \fIn\fPth enclosing loop.
8033 is greater than the number of enclosing loops, the last enclosing loop
8034 (the ``top-level'' loop) is resumed.
8035 The return value is 0 unless \fIn\fP is not greater than or equal to 1.
8037 \fBdeclare\fP [\fB\-aAfFgiIlnrtux\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
8040 \fBtypeset\fP [\fB\-aAfFgiIlnrtux\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
8042 Declare variables and/or give them attributes.
8043 If no \fIname\fPs are given then display the values of variables.
8046 option will display the attributes and values of each
8050 is used with \fIname\fP arguments, additional options,
8051 other than \fB\-f\fP and \fB\-F\fP, are ignored.
8054 is supplied without \fIname\fP arguments, it will display the attributes
8055 and values of all variables having the attributes specified by the
8057 If no other options are supplied with \fB\-p\fP, \fBdeclare\fP will display
8058 the attributes and values of all shell variables. The \fB\-f\fP option
8059 will restrict the display to shell functions.
8062 option inhibits the display of function definitions; only the
8063 function name and attributes are printed.
8064 If the \fBextdebug\fP shell option is enabled using \fBshopt\fP,
8065 the source file name and line number where each \fIname\fP
8066 is defined are displayed as well. The
8072 option forces variables to be created or modified at the global scope,
8073 even when \fBdeclare\fP is executed in a shell function.
8074 It is ignored in all other cases.
8077 option causes local variables to inherit the attributes
8078 (except the \fInameref\fP attribute)
8079 and value of any existing variable with the same
8080 \fIname\fP at a surrounding scope.
8081 If there is no existing variable, the local variable is initially unset.
8082 The following options can
8083 be used to restrict output to variables with the specified attribute or
8084 to give variables attributes:
8089 Each \fIname\fP is an indexed array variable (see
8094 Each \fIname\fP is an associative array variable (see
8099 Use function names only.
8102 The variable is treated as an integer; arithmetic evaluation (see
8104 .B "ARITHMETIC EVALUATION"
8105 above) is performed when the variable is assigned a value.
8108 When the variable is assigned a value, all upper-case characters are
8109 converted to lower-case.
8110 The upper-case attribute is disabled.
8113 Give each \fIname\fP the \fInameref\fP attribute, making
8114 it a name reference to another variable.
8115 That other variable is defined by the value of \fIname\fP.
8116 All references, assignments, and attribute modifications
8117 to \fIname\fP, except those using or changing the
8118 \fB\-n\fP attribute itself, are performed on the variable referenced by
8120 The nameref attribute cannot be applied to array variables.
8123 Make \fIname\fPs readonly. These names cannot then be assigned values
8124 by subsequent assignment statements or unset.
8127 Give each \fIname\fP the \fItrace\fP attribute.
8128 Traced functions inherit the \fBDEBUG\fP and \fBRETURN\fP traps from
8130 The trace attribute has no special meaning for variables.
8133 When the variable is assigned a value, all lower-case characters are
8134 converted to upper-case.
8135 The lower-case attribute is disabled.
8138 Mark \fIname\fPs for export to subsequent commands via the environment.
8141 Using `+' instead of `\-'
8142 turns off the attribute instead,
8143 with the exceptions that \fB+a\fP and \fB+A\fP
8144 may not be used to destroy array variables and \fB+r\fP will not
8145 remove the readonly attribute.
8146 When used in a function,
8151 \fIname\fP local, as with the
8154 unless the \fB\-g\fP option is supplied.
8155 If a variable name is followed by =\fIvalue\fP, the value of
8156 the variable is set to \fIvalue\fP.
8157 When using \fB\-a\fP or \fB\-A\fP and the compound assignment syntax to
8158 create array variables, additional attributes do not take effect until
8159 subsequent assignments.
8160 The return value is 0 unless an invalid option is encountered,
8161 an attempt is made to define a function using
8162 .if n ``\-f foo=bar'',
8163 .if t \f(CW\-f foo=bar\fP,
8164 an attempt is made to assign a value to a readonly variable,
8165 an attempt is made to assign a value to an array variable without
8166 using the compound assignment syntax (see
8168 above), one of the \fInames\fP is not a valid shell variable name,
8169 an attempt is made to turn off readonly status for a readonly variable,
8170 an attempt is made to turn off array status for an array variable,
8171 or an attempt is made to display a non-existent function with \fB\-f\fP.
8174 .B dirs [\fB\-clpv\fP] [+\fIn\fP] [\-\fIn\fP]
8175 Without options, displays the list of currently remembered directories.
8176 The default display is on a single line with directory names separated
8178 Directories are added to the list with the
8182 command removes entries from the list.
8183 The current directory is always the first directory in the stack.
8188 Clears the directory stack by deleting all of the entries.
8191 Produces a listing using full pathnames;
8192 the default listing format uses a tilde to denote the home directory.
8195 Print the directory stack with one entry per line.
8198 Print the directory stack with one entry per line,
8199 prefixing each entry with its index in the stack.
8202 Displays the \fIn\fPth entry counting from the left of the list
8205 when invoked without options, starting with zero.
8208 Displays the \fIn\fPth entry counting from the right of the list
8211 when invoked without options, starting with zero.
8214 The return value is 0 unless an
8215 invalid option is supplied or \fIn\fP indexes beyond the end
8216 of the directory stack.
8219 \fBdisown\fP [\fB\-ar\fP] [\fB\-h\fP] [\fIjobspec\fP ... | \fIpid\fP ... ]
8220 Without options, remove each
8222 from the table of active jobs.
8225 is not present, and neither the \fB\-a\fP nor the \fB\-r\fP option
8226 is supplied, the \fIcurrent job\fP is used.
8227 If the \fB\-h\fP option is given, each
8229 is not removed from the table, but is marked so that
8232 is not sent to the job if the shell receives a
8239 option means to remove or mark all jobs; the
8243 argument restricts operation to running jobs.
8244 The return value is 0 unless a
8246 does not specify a valid job.
8248 \fBecho\fP [\fB\-neE\fP] [\fIarg\fP ...]
8249 Output the \fIarg\fPs, separated by spaces, followed by a newline.
8250 The return status is 0 unless a write error occurs.
8251 If \fB\-n\fP is specified, the trailing newline is
8252 suppressed. If the \fB\-e\fP option is given, interpretation of
8253 the following backslash-escaped characters is enabled. The
8255 option disables the interpretation of these escape characters,
8256 even on systems where they are interpreted by default.
8257 The \fBxpg_echo\fP shell option may be used to
8258 dynamically determine whether or not \fBecho\fP expands these
8259 escape characters by default.
8261 does not interpret \fB\-\-\fP to mean the end of options.
8263 interprets the following escape sequences:
8274 suppress further output
8300 the eight-bit character whose value is the octal value \fInnn\fP
8301 (zero to three octal digits)
8304 the eight-bit character whose value is the hexadecimal value \fIHH\fP
8305 (one or two hex digits)
8308 the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value
8309 \fIHHHH\fP (one to four hex digits)
8311 .B \eU\fIHHHHHHHH\fP
8312 the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value
8313 \fIHHHHHHHH\fP (one to eight hex digits)
8317 \fBenable\fP [\fB\-a\fP] [\fB\-dnps\fP] [\fB\-f\fP \fIfilename\fP] [\fIname\fP ...]
8318 Enable and disable builtin shell commands.
8319 Disabling a builtin allows a disk command which has the same name
8320 as a shell builtin to be executed without specifying a full pathname,
8321 even though the shell normally searches for builtins before disk commands.
8322 If \fB\-n\fP is used, each \fIname\fP
8323 is disabled; otherwise,
8324 \fInames\fP are enabled. For example, to use the
8326 binary found via the
8329 instead of the shell builtin version, run
8330 .if t \f(CWenable -n test\fP.
8331 .if n ``enable -n test''.
8334 option means to load the new builtin command
8338 on systems that support dynamic loading. The
8340 option will delete a builtin previously loaded with
8342 If no \fIname\fP arguments are given, or if the
8344 option is supplied, a list of shell builtins is printed.
8345 With no other option arguments, the list consists of all enabled
8347 If \fB\-n\fP is supplied, only disabled builtins are printed.
8348 If \fB\-a\fP is supplied, the list printed includes all builtins, with an
8349 indication of whether or not each is enabled.
8350 If \fB\-s\fP is supplied, the output is restricted to the POSIX
8351 \fIspecial\fP builtins.
8352 The return value is 0 unless a
8354 is not a shell builtin or there is an error loading a new builtin
8355 from a shared object.
8357 \fBeval\fP [\fIarg\fP ...]
8358 The \fIarg\fPs are read and concatenated together into a single
8359 command. This command is then read and executed by the shell, and
8360 its exit status is returned as the value of
8364 or only null arguments,
8368 \fBexec\fP [\fB\-cl\fP] [\fB\-a\fP \fIname\fP] [\fIcommand\fP [\fIarguments\fP]]
8371 is specified, it replaces the shell.
8372 No new process is created. The
8374 become the arguments to \fIcommand\fP.
8378 the shell places a dash at the beginning of the zeroth argument passed to
8386 to be executed with an empty environment. If
8388 is supplied, the shell passes
8390 as the zeroth argument to the executed command.
8393 cannot be executed for some reason, a non-interactive shell exits,
8397 is enabled. In that case, it returns failure.
8398 An interactive shell returns failure if the file cannot be executed.
8399 A subshell exits unconditionally if \fBexec\fP fails.
8402 is not specified, any redirections take effect in the current shell,
8403 and the return status is 0. If there is a redirection error, the
8406 \fBexit\fP [\fIn\fP]
8407 Cause the shell to exit
8408 with a status of \fIn\fP. If
8410 is omitted, the exit status
8411 is that of the last command executed.
8415 is executed before the shell terminates.
8417 \fBexport\fP [\fB\-fn\fP\^] [\fIname\fP[=\fIword\fP]] ...
8424 are marked for automatic export to the environment of
8425 subsequently executed commands. If the
8427 option is given, the
8432 are given, or if the
8434 option is supplied, a list
8435 of names of all exported variables is printed.
8438 option causes the export property to be removed from each
8440 If a variable name is followed by =\fIword\fP, the value of
8441 the variable is set to \fIword\fP.
8443 returns an exit status of 0 unless an invalid option is
8445 one of the \fInames\fP is not a valid shell variable name, or
8449 that is not a function.
8451 \fBfc\fP [\fB\-e\fP \fIename\fP] [\fB\-lnr\fP] [\fIfirst\fP] [\fIlast\fP]
8454 \fBfc\fP \fB\-s\fP [\fIpat\fP=\fIrep\fP] [\fIcmd\fP]
8456 The first form selects a range of commands from
8460 from the history list and displays or edits and re-executes them.
8464 may be specified as a string (to locate the last command beginning
8465 with that string) or as a number (an index into the history list,
8466 where a negative number is used as an offset from the current
8468 When listing, a \fIfirst\fP or \fIlast\fP of
8469 0 is equivalent to \-1 and \-0 is equivalent to the current
8470 command (usually the \fBfc\fP command); otherwise 0 is equivalent to \-1
8474 is not specified, it is set to
8475 the current command for listing (so that
8476 .if n ``fc \-l \-10''
8477 .if t \f(CWfc \-l \-10\fP
8478 prints the last 10 commands) and to
8483 is not specified, it is set to the previous
8484 command for editing and \-16 for listing.
8489 the command numbers when listing. The
8491 option reverses the order of
8492 the commands. If the
8495 the commands are listed on
8496 standard output. Otherwise, the editor given by
8499 on a file containing those commands. If
8505 variable is used, and
8512 is not set. If neither variable is set,
8514 is used. When editing is complete, the edited commands are
8515 echoed and executed.
8517 In the second form, \fIcommand\fP is re-executed after each instance
8518 of \fIpat\fP is replaced by \fIrep\fP.
8519 \fICommand\fP is interpreted the same as \fIfirst\fP above.
8520 A useful alias to use with this is
8521 .if n ``r="fc -s"'',
8522 .if t \f(CWr='fc \-s'\fP,
8526 runs the last command beginning with
8532 re-executes the last command.
8534 If the first form is used, the return value is 0 unless an invalid
8535 option is encountered or
8539 specify history lines out of range.
8542 option is supplied, the return value is the value of the last
8543 command executed or failure if an error occurs with the temporary
8544 file of commands. If the second form is used, the return status
8545 is that of the command re-executed, unless
8547 does not specify a valid history line, in which case
8551 \fBfg\fP [\fIjobspec\fP]
8554 in the foreground, and make it the current job.
8557 is not present, the shell's notion of the \fIcurrent job\fP is used.
8558 The return value is that of the command placed into the foreground,
8559 or failure if run when job control is disabled or, when run with
8560 job control enabled, if
8562 does not specify a valid job or
8564 specifies a job that was started without job control.
8566 \fBgetopts\fP \fIoptstring\fP \fIname\fP [\fIarg ...\fP]
8568 is used by shell procedures to parse positional parameters.
8570 contains the option characters to be recognized; if a character
8571 is followed by a colon, the option is expected to have an
8572 argument, which should be separated from it by white space.
8573 The colon and question mark characters may not be used as
8575 Each time it is invoked,
8577 places the next option in the shell variable
8581 if it does not exist,
8582 and the index of the next argument to be processed into the
8588 is initialized to 1 each time the shell or a shell script
8589 is invoked. When an option requires an argument,
8591 places that argument into the variable
8594 The shell does not reset
8597 automatically; it must be manually reset between multiple
8600 within the same shell invocation if a new set of parameters
8603 When the end of options is encountered, \fBgetopts\fP exits with a
8604 return value greater than zero.
8607 is set to the index of the first non-option argument,
8608 and \fIname\fP is set to ?.
8611 normally parses the positional parameters, but if more arguments are
8616 parses those instead.
8619 can report errors in two ways. If the first character of
8623 error reporting is used. In normal operation, diagnostic messages
8624 are printed when invalid options or missing option arguments are
8629 is set to 0, no error messages will be displayed, even if the first
8634 If an invalid option is seen,
8639 prints an error message and unsets
8645 the option character found is placed in
8648 and no diagnostic message is printed.
8650 If a required argument is not found, and
8653 a question mark (\^\fB?\fP\^) is placed in
8657 is unset, and a diagnostic message is printed.
8660 is silent, then a colon (\^\fB:\fP\^) is placed in
8665 is set to the option character found.
8668 returns true if an option, specified or unspecified, is found.
8669 It returns false if the end of options is encountered or an
8672 \fBhash\fP [\fB\-lr\fP] [\fB\-p\fP \fIfilename\fP] [\fB\-dt\fP] [\fIname\fP]
8673 Each time \fBhash\fP is invoked,
8674 the full pathname of the command
8676 is determined by searching
8679 and remembered. Any previously-remembered pathname is discarded.
8682 option is supplied, no path search is performed, and
8684 is used as the full filename of the command.
8687 option causes the shell to forget all
8688 remembered locations.
8691 option causes the shell to forget the remembered location of each \fIname\fP.
8694 option is supplied, the full pathname to which each \fIname\fP corresponds
8695 is printed. If multiple \fIname\fP arguments are supplied with \fB\-t\fP,
8696 the \fIname\fP is printed before the hashed full pathname.
8699 option causes output to be displayed in a format that may be reused as input.
8700 If no arguments are given, or if only \fB\-l\fP is supplied,
8701 information about remembered commands is printed.
8702 The return status is true unless a
8704 is not found or an invalid option is supplied.
8706 \fBhelp\fP [\fB\-dms\fP] [\fIpattern\fP]
8707 Display helpful information about builtin commands. If
8711 gives detailed help on all commands matching
8713 otherwise help for all the builtins and shell control structures
8719 Display a short description of each \fIpattern\fP
8722 Display the description of each \fIpattern\fP in a manpage-like format
8725 Display only a short usage synopsis for each \fIpattern\fP
8728 The return status is 0 unless no command matches
8732 \fBhistory [\fIn\fP]
8735 \fBhistory\fP \fB\-c\fP
8737 \fBhistory \-d\fP \fIoffset\fP
8739 \fBhistory \-d\fP \fIstart\fP\-\fIend\fP
8741 \fBhistory\fP \fB\-anrw\fP [\fIfilename\fP]
8743 \fBhistory\fP \fB\-p\fP \fIarg\fP [\fIarg ...\fP]
8745 \fBhistory\fP \fB\-s\fP \fIarg\fP [\fIarg ...\fP]
8747 With no options, display the command
8748 history list with line numbers. Lines listed
8751 have been modified. An argument of
8756 If the shell variable
8759 is set and not null,
8760 it is used as a format string for \fIstrftime\fP(3) to display
8761 the time stamp associated with each displayed history entry.
8762 No intervening blank is printed between the formatted time stamp
8763 and the history line.
8764 If \fIfilename\fP is supplied, it is used as the
8765 name of the history file; if not, the value of
8768 is used. Options, if supplied, have the following meanings:
8773 Clear the history list by deleting all the entries.
8775 \fB\-d\fP \fIoffset\fP
8776 Delete the history entry at position \fIoffset\fP.
8777 If \fIoffset\fP is negative, it is interpreted as relative to one greater
8778 than the last history position, so negative indices count back from the
8779 end of the history, and an index of \-1 refers to the current
8780 \fBhistory -d\fP command.
8782 \fB\-d\fP \fIstart\fP\-\fIend\fP
8783 Delete the history entries between positions \fIstart\fP and \fIend\fP,
8784 inclusive. Positive and negative values for \fIstart\fP and \fIend\fP
8785 are interpreted as described above.
8788 Append the ``new'' history lines to the history file.
8789 These are history lines entered since the beginning of the current
8790 \fBbush\fP session, but not already appended to the history file.
8793 Read the history lines not already read from the history
8794 file into the current history list. These are lines
8795 appended to the history file since the beginning of the
8796 current \fBbush\fP session.
8799 Read the contents of the history file
8800 and append them to the current history list.
8803 Write the current history list to the history file, overwriting the
8804 history file's contents.
8807 Perform history substitution on the following \fIargs\fP and display
8808 the result on the standard output.
8809 Does not store the results in the history list.
8810 Each \fIarg\fP must be quoted to disable normal history expansion.
8815 in the history list as a single entry. The last command in the
8816 history list is removed before the
8824 variable is set, the time stamp information
8825 associated with each history entry is written to the history file,
8826 marked with the history comment character.
8827 When the history file is read, lines beginning with the history
8828 comment character followed immediately by a digit are interpreted
8829 as timestamps for the following history entry.
8830 The return value is 0 unless an invalid option is encountered, an
8831 error occurs while reading or writing the history file, an invalid
8832 \fIoffset\fP is supplied as an argument to \fB\-d\fP, or the
8833 history expansion supplied as an argument to \fB\-p\fP fails.
8836 \fBjobs\fP [\fB\-lnprs\fP] [ \fIjobspec\fP ... ]
8839 \fBjobs\fP \fB\-x\fP \fIcommand\fP [ \fIargs\fP ... ]
8841 The first form lists the active jobs. The options have the following
8848 in addition to the normal information.
8851 Display information only about jobs that have changed status since
8852 the user was last notified of their status.
8855 List only the process ID of the job's process group
8859 Display only running jobs.
8862 Display only stopped jobs.
8867 is given, output is restricted to information about that job.
8868 The return status is 0 unless an invalid option is encountered
8883 with the corresponding process group ID, and executes
8887 returning its exit status.
8890 \fBkill\fP [\fB\-s\fP \fIsigspec\fP | \fB\-n\fP \fIsignum\fP | \fB\-\fP\fIsigspec\fP] [\fIpid\fP | \fIjobspec\fP] ...
8893 \fBkill\fP \fB\-l\fP|\fB\-L\fP [\fIsigspec\fP | \fIexit_status\fP]
8895 Send the signal named by
8899 to the processes named by
8904 is either a case-insensitive signal name such as
8907 (with or without the
8910 prefix) or a signal number;
8915 is not present, then
8921 lists the signal names.
8922 If any arguments are supplied when
8924 is given, the names of the signals corresponding to the arguments are
8925 listed, and the return status is 0.
8926 The \fIexit_status\fP argument to
8928 is a number specifying either a signal number or the exit status of
8929 a process terminated by a signal.
8932 option is equivalent to \fB\-l\fP.
8934 returns true if at least one signal was successfully sent, or false
8935 if an error occurs or an invalid option is encountered.
8937 \fBlet\fP \fIarg\fP [\fIarg\fP ...]
8940 is an arithmetic expression to be evaluated (see
8942 .B "ARITHMETIC EVALUATION"
8948 returns 1; 0 is returned otherwise.
8950 \fBlocal\fP [\fIoption\fP] [\fIname\fP[=\fIvalue\fP] ... | \- ]
8951 For each argument, a local variable named
8953 is created, and assigned
8955 The \fIoption\fP can be any of the options accepted by \fBdeclare\fP.
8958 is used within a function, it causes the variable
8960 to have a visible scope restricted to that function and its children.
8961 If \fIname\fP is \-, the set of shell options is made local to the function
8962 in which \fBlocal\fP is invoked: shell options changed using the
8963 \fBset\fP builtin inside the function are restored to their original values
8964 when the function returns.
8965 The restore is effected as if a series of \fBset\fP commands were executed
8966 to restore the values that were in place before the function.
8969 writes a list of local variables to the standard output. It is
8972 when not within a function. The return status is 0 unless
8974 is used outside a function, an invalid
8977 \fIname\fP is a readonly variable.
8982 \fBmapfile\fP [\fB\-d\fP \fIdelim\fP] [\fB\-n\fP \fIcount\fP] [\fB\-O\fP \fIorigin\fP] [\fB\-s\fP \fIcount\fP] [\fB\-t\fP] [\fB\-u\fP \fIfd\fP] [\fB\-C\fP \fIcallback\fP] [\fB\-c\fP \fIquantum\fP] [\fIarray\fP]
8985 \fBreadarray\fP [\fB\-d\fP \fIdelim\fP] [\fB\-n\fP \fIcount\fP] [\fB\-O\fP \fIorigin\fP] [\fB\-s\fP \fIcount\fP] [\fB\-t\fP] [\fB\-u\fP \fIfd\fP] [\fB\-C\fP \fIcallback\fP] [\fB\-c\fP \fIquantum\fP] [\fIarray\fP]
8987 Read lines from the standard input into the indexed array variable
8989 or from file descriptor
8997 is the default \fIarray\fP.
8998 Options, if supplied, have the following meanings:
9003 The first character of \fIdelim\fP is used to terminate each input line,
9004 rather than newline.
9005 If \fIdelim\fP is the empty string, \fBmapfile\fP will terminate a line
9006 when it reads a NUL character.
9011 lines. If \fIcount\fP is 0, all lines are copied.
9018 The default index is 0.
9021 Discard the first \fIcount\fP lines read.
9024 Remove a trailing \fIdelim\fP (default newline) from each line read.
9027 Read lines from file descriptor \fIfd\fP instead of the standard input.
9032 each time \fIquantum\fP lines are read. The \fB\-c\fP option specifies
9036 Specify the number of lines read between each call to
9042 is specified without
9044 the default quantum is 5000.
9045 When \fIcallback\fP is evaluated, it is supplied the index of the next
9046 array element to be assigned and the line to be assigned to that element
9047 as additional arguments.
9048 \fIcallback\fP is evaluated after the line is read but before the
9049 array element is assigned.
9051 If not supplied with an explicit origin, \fBmapfile\fP will clear \fIarray\fP
9052 before assigning to it.
9054 \fBmapfile\fP returns successfully unless an invalid option or option
9055 argument is supplied, \fIarray\fP is invalid or unassignable, or if
9056 \fIarray\fP is not an indexed array.
9059 \fBpopd\fP [\-\fBn\fP] [+\fIn\fP] [\-\fIn\fP]
9060 Removes entries from the directory stack. With no arguments,
9061 removes the top directory from the stack, and performs a
9063 to the new top directory.
9064 Arguments, if supplied, have the following meanings:
9069 Suppresses the normal change of directory when removing directories
9070 from the stack, so that only the stack is manipulated.
9073 Removes the \fIn\fPth entry counting from the left of the list
9076 starting with zero. For example:
9078 .if t \f(CWpopd +0\fP
9079 removes the first directory,
9081 .if t \f(CWpopd +1\fP
9085 Removes the \fIn\fPth entry counting from the right of the list
9088 starting with zero. For example:
9090 .if t \f(CWpopd -0\fP
9091 removes the last directory,
9093 .if t \f(CWpopd -1\fP
9099 command is successful, a
9101 is performed as well, and the return status is 0.
9103 returns false if an invalid option is encountered, the directory stack
9104 is empty, a non-existent directory stack entry is specified, or the
9105 directory change fails.
9108 \fBprintf\fP [\fB\-v\fP \fIvar\fP] \fIformat\fP [\fIarguments\fP]
9109 Write the formatted \fIarguments\fP to the standard output under the
9110 control of the \fIformat\fP.
9111 The \fB\-v\fP option causes the output to be assigned to the variable
9112 \fIvar\fP rather than being printed to the standard output.
9114 The \fIformat\fP is a character string which contains three types of objects:
9115 plain characters, which are simply copied to standard output, character
9116 escape sequences, which are converted and copied to the standard output, and
9117 format specifications, each of which causes printing of the next successive
9119 In addition to the standard \fIprintf\fP(1) format specifications,
9120 \fBprintf\fP interprets the following extensions:
9126 \fBprintf\fP to expand backslash escape sequences in the corresponding
9128 in the same way as \fBecho \-e\fP.
9131 causes \fBprintf\fP to output the corresponding
9132 \fIargument\fP in a format that can be reused as shell input.
9134 .B %(\fIdatefmt\fP)T
9135 causes \fBprintf\fP to output the date-time string resulting from using
9136 \fIdatefmt\fP as a format string for \fIstrftime\fP(3).
9137 The corresponding \fIargument\fP is an integer representing the number of
9138 seconds since the epoch.
9139 Two special argument values may be used: \-1 represents the current
9140 time, and \-2 represents the time the shell was invoked.
9141 If no argument is specified, conversion behaves as if \-1 had been given.
9142 This is an exception to the usual \fBprintf\fP behavior.
9145 The %b, %q, and %T directives all use the field width and precision
9146 arguments from the format specification and write that many bytes from
9147 (or use that wide a field for) the expanded argument, which usually
9148 contains more characters than the original.
9150 Arguments to non-string format specifiers are treated as C constants,
9151 except that a leading plus or minus sign is allowed, and if the leading
9152 character is a single or double quote, the value is the ASCII value of
9153 the following character.
9155 The \fIformat\fP is reused as necessary to consume all of the \fIarguments\fP.
9156 If the \fIformat\fP requires more \fIarguments\fP than are supplied, the
9157 extra format specifications behave as if a zero value or null string, as
9158 appropriate, had been supplied.
9159 The return value is zero on success, non-zero on failure.
9162 \fBpushd\fP [\fB\-n\fP] [+\fIn\fP] [\-\fIn\fP]
9165 \fBpushd\fP [\fB\-n\fP] [\fIdir\fP]
9167 Adds a directory to the top of the directory stack, or rotates
9168 the stack, making the new top of the stack the current working
9169 directory. With no arguments, \fBpushd\fP exchanges the top two directories
9170 and returns 0, unless the directory stack is empty.
9171 Arguments, if supplied, have the following meanings:
9176 Suppresses the normal change of directory when rotating or
9177 adding directories to the stack, so that only the stack is manipulated.
9180 Rotates the stack so that the \fIn\fPth directory
9181 (counting from the left of the list shown by
9187 Rotates the stack so that the \fIn\fPth directory
9188 (counting from the right of the list shown by
9190 starting with zero) is at the top.
9195 to the directory stack at the top, making it the
9196 new current working directory as if it had been supplied as the argument
9197 to the \fBcd\fP builtin.
9202 command is successful, a
9204 is performed as well.
9205 If the first form is used,
9207 returns 0 unless the cd to
9209 fails. With the second form,
9211 returns 0 unless the directory stack is empty,
9212 a non-existent directory stack element is specified,
9213 or the directory change to the specified new current directory
9217 \fBpwd\fP [\fB\-LP\fP]
9218 Print the absolute pathname of the current working directory.
9219 The pathname printed contains no symbolic links if the
9221 option is supplied or the
9225 builtin command is enabled.
9228 option is used, the pathname printed may contain symbolic links.
9229 The return status is 0 unless an error occurs while
9230 reading the name of the current directory or an
9231 invalid option is supplied.
9233 \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 ...]
9234 One line is read from the standard input, or from the file descriptor
9235 \fIfd\fP supplied as an argument to the \fB\-u\fP option,
9236 split into words as described above under \fBWord Splitting\fP,
9238 is assigned to the first
9240 the second word to the second
9243 If there are more words than names, the remaining words and their
9244 intervening delimiters are assigned to the last
9246 If there are fewer words read from the input stream than names,
9247 the remaining names are assigned empty values.
9251 are used to split the line into words using the same rules the shell
9252 uses for expansion (described above under \fBWord Splitting\fP).
9253 The backslash character (\fB\e\fP) may be used to remove any special
9254 meaning for the next character read and for line continuation.
9255 Options, if supplied, have the following meanings:
9260 The words are assigned to sequential indices
9261 of the array variable
9265 is unset before any new values are assigned.
9266 Other \fIname\fP arguments are ignored.
9269 The first character of \fIdelim\fP is used to terminate the input line,
9270 rather than newline.
9271 If \fIdelim\fP is the empty string, \fBread\fP will terminate a line
9272 when it reads a NUL character.
9275 If the standard input
9276 is coming from a terminal,
9281 above) is used to obtain the line.
9282 Readline uses the current (or default, if line editing was not previously
9283 active) editing settings, but uses Readline's default filename completion.
9288 is being used to read the line, \fItext\fP is placed into the editing
9289 buffer before editing begins.
9292 \fBread\fP returns after reading \fInchars\fP characters rather than
9293 waiting for a complete line of input, but honors a delimiter if fewer
9294 than \fInchars\fP characters are read before the delimiter.
9297 \fBread\fP returns after reading exactly \fInchars\fP characters rather
9298 than waiting for a complete line of input, unless EOF is encountered or
9299 \fBread\fP times out.
9300 Delimiter characters encountered in the input are
9301 not treated specially and do not cause \fBread\fP to return until
9302 \fInchars\fP characters are read.
9303 The result is not split on the characters in \fBIFS\fP; the intent is
9304 that the variable is assigned exactly the characters read
9305 (with the exception of backslash; see the \fB\-r\fP option below).
9308 Display \fIprompt\fP on standard error, without a
9309 trailing newline, before attempting to read any input. The prompt
9310 is displayed only if input is coming from a terminal.
9313 Backslash does not act as an escape character.
9314 The backslash is considered to be part of the line.
9315 In particular, a backslash-newline pair may not then be used as a line
9319 Silent mode. If input is coming from a terminal, characters are
9322 .B \-t \fItimeout\fP
9323 Cause \fBread\fP to time out and return failure if a complete line of
9324 input (or a specified number of characters)
9325 is not read within \fItimeout\fP seconds.
9326 \fItimeout\fP may be a decimal number with a fractional portion following
9328 This option is only effective if \fBread\fP is reading input from a
9329 terminal, pipe, or other special file; it has no effect when reading
9331 If \fBread\fP times out, \fBread\fP saves any partial input read into
9332 the specified variable \fIname\fP.
9333 If \fItimeout\fP is 0, \fBread\fP returns immediately, without trying to
9334 read any data. The exit status is 0 if input is available on
9335 the specified file descriptor, non-zero otherwise.
9336 The exit status is greater than 128 if the timeout is exceeded.
9339 Read input from file descriptor \fIfd\fP.
9344 are supplied, the line read,
9345 without the ending delimiter but otherwise unmodified,
9346 is assigned to the variable
9349 The exit status is zero, unless end-of-file is encountered, \fBread\fP
9350 times out (in which case the status is greater than 128),
9351 a variable assignment error (such as assigning to a readonly variable) occurs,
9352 or an invalid file descriptor is supplied as the argument to \fB\-u\fP.
9355 \fBreadonly\fP [\fB\-aAf\fP] [\fB\-p\fP] [\fIname\fP[=\fIword\fP] ...]
9358 \fInames\fP are marked readonly; the values of these
9360 may not be changed by subsequent assignment.
9363 option is supplied, the functions corresponding to the
9368 option restricts the variables to indexed arrays; the
9370 option restricts the variables to associative arrays.
9371 If both options are supplied,
9376 arguments are given, or if the
9378 option is supplied, a list of all readonly names is printed.
9379 The other options may be used to restrict the output to a subset of
9380 the set of readonly names.
9383 option causes output to be displayed in a format that
9384 may be reused as input.
9385 If a variable name is followed by =\fIword\fP, the value of
9386 the variable is set to \fIword\fP.
9387 The return status is 0 unless an invalid option is encountered,
9390 is not a valid shell variable name, or
9394 that is not a function.
9396 \fBreturn\fP [\fIn\fP]
9397 Causes a function to stop executing and return the value specified by
9402 is omitted, the return status is that of the last command
9403 executed in the function body.
9404 If \fBreturn\fP is executed by a trap handler, the last command used to
9405 determine the status is the last command executed before the trap handler.
9406 If \fBreturn\fP is executed during a \fBDEBUG\fP trap, the last command
9407 used to determine the status is the last command executed by the trap
9408 handler before \fBreturn\fP was invoked.
9411 is used outside a function,
9412 but during execution of a script by the
9414 (\fBsource\fP) command, it causes the shell to stop executing
9415 that script and return either
9417 or the exit status of the last command executed within the
9418 script as the exit status of the script.
9419 If \fIn\fP is supplied, the return value is its least significant
9421 The return status is non-zero if
9423 is supplied a non-numeric argument, or
9425 function and not during execution of a script by \fB.\fP\^ or \fBsource\fP.
9426 Any command associated with the \fBRETURN\fP trap is executed
9427 before execution resumes after the function or script.
9429 \fBset\fP [\fB\-\-abefhkmnptuvxBCEHPT\fP] [\fB\-o\fP \fIoption\-name\fP] [\fIarg\fP ...]
9432 \fBset\fP [\fB+abefhkmnptuvxBCEHPT\fP] [\fB+o\fP \fIoption\-name\fP] [\fIarg\fP ...]
9434 Without options, the name and value of each shell variable are displayed
9435 in a format that can be reused as input
9436 for setting or resetting the currently-set variables.
9437 Read-only variables cannot be reset.
9438 In \fIposix mode\fP, only shell variables are listed.
9439 The output is sorted according to the current locale.
9440 When options are specified, they set or unset shell attributes.
9441 Any arguments remaining after option processing are treated
9442 as values for the positional parameters and are assigned, in order, to
9447 Options, if specified, have the following meanings:
9452 Each variable or function that is created or modified is given the
9453 export attribute and marked for export to the environment of
9454 subsequent commands.
9457 Report the status of terminated background jobs
9458 immediately, rather than before the next primary prompt. This is
9459 effective only when job control is enabled.
9462 Exit immediately if a
9463 \fIpipeline\fP (which may consist of a single \fIsimple command\fP),
9465 or a \fIcompound command\fP
9469 above), exits with a non-zero status.
9470 The shell does not exit if the
9471 command that fails is part of the command list immediately following a
9476 part of the test following the
9480 reserved words, part of any command executed in a
9484 list except the command following the final \fB&&\fP or \fB||\fP,
9485 any command in a pipeline but the last,
9486 or if the command's return value is
9489 If a compound command other than a subshell
9490 returns a non-zero status because a command failed
9491 while \fB\-e\fP was being ignored, the shell does not exit.
9492 A trap on \fBERR\fP, if set, is executed before the shell exits.
9493 This option applies to the shell environment and each subshell environment
9496 .B "COMMAND EXECUTION ENVIRONMENT"
9497 above), and may cause
9498 subshells to exit before executing all the commands in the subshell.
9501 If a compound command or shell function executes in a context
9502 where \fB\-e\fP is being ignored,
9503 none of the commands executed within the compound command or function body
9504 will be affected by the \fB\-e\fP setting, even if \fB\-e\fP is set
9505 and a command returns a failure status.
9506 If a compound command or shell function sets \fB\-e\fP while executing in
9507 a context where \fB\-e\fP is ignored, that setting will not have any
9508 effect until the compound command or the command containing the function
9512 Disable pathname expansion.
9515 Remember the location of commands as they are looked up for execution.
9516 This is enabled by default.
9519 All arguments in the form of assignment statements
9520 are placed in the environment for a command, not just
9521 those that precede the command name.
9524 Monitor mode. Job control is enabled. This option is on
9525 by default for interactive shells on systems that support
9530 All processes run in a separate process group.
9531 When a background job completes, the shell prints a line
9532 containing its exit status.
9535 Read commands but do not execute them.
9536 This may be used to check a shell script for syntax errors.
9537 This is ignored by interactive shells.
9539 .B \-o \fIoption\-name\fP
9540 The \fIoption\-name\fP can be one of the following:
9552 Use an emacs-style command line editing interface. This is enabled
9553 by default when the shell is interactive, unless the shell is started
9557 This also affects the editing interface used for \fBread \-e\fP.
9580 Enable command history, as described above under
9583 This option is on by default in interactive shells.
9586 The effect is as if the shell command
9587 .if t \f(CWIGNOREEOF=10\fP
9588 .if n ``IGNOREEOF=10''
9634 If set, the return value of a pipeline is the value of the last
9635 (rightmost) command to exit with a non-zero status, or zero if all
9636 commands in the pipeline exit successfully.
9637 This option is disabled by default.
9640 Change the behavior of
9642 where the default operation differs
9643 from the POSIX standard to match the standard (\fIposix mode\fP).
9647 below for a reference to a document that details how posix mode affects
9659 Use a vi-style command line editing interface.
9660 This also affects the editing interface used for \fBread \-e\fP.
9669 is supplied with no \fIoption\-name\fP, the values of the current options are
9673 is supplied with no \fIoption\-name\fP, a series of
9675 commands to recreate the current option settings is displayed on
9676 the standard output.
9682 mode. In this mode, the
9688 files are not processed, shell functions are not inherited from the
9689 environment, and the
9699 variables, if they appear in the environment, are ignored.
9700 If the shell is started with the effective user (group) id not equal to the
9701 real user (group) id, and the \fB\-p\fP option is not supplied, these actions
9702 are taken and the effective user id is set to the real user id.
9703 If the \fB\-p\fP option is supplied at startup, the effective user id is
9705 Turning this option off causes the effective user
9706 and group ids to be set to the real user and group ids.
9709 Exit after reading and executing one command.
9712 Treat unset variables and parameters other than the special
9713 parameters "@" and "*" as an error when performing
9714 parameter expansion. If expansion is attempted on an
9715 unset variable or parameter, the shell prints an error message, and,
9716 if not interactive, exits with a non-zero status.
9719 Print shell input lines as they are read.
9722 After expanding each \fIsimple command\fP,
9723 \fBfor\fP command, \fBcase\fP command, \fBselect\fP command, or
9724 arithmetic \fBfor\fP command, display the expanded value of
9727 followed by the command and its expanded arguments
9728 or associated word list.
9731 The shell performs brace expansion (see
9733 above). This is on by default.
9738 does not overwrite an existing file with the
9743 redirection operators. This may be overridden when
9744 creating output files by using the redirection operator
9750 If set, any trap on \fBERR\fP is inherited by shell functions, command
9751 substitutions, and commands executed in a subshell environment.
9752 The \fBERR\fP trap is normally not inherited in such cases.
9757 style history substitution. This option is on by
9758 default when the shell is interactive.
9761 If set, the shell does not resolve symbolic links when executing
9764 that change the current working directory. It uses the
9765 physical directory structure instead. By default,
9767 follows the logical chain of directories when performing commands
9768 which change the current directory.
9771 If set, any traps on \fBDEBUG\fP and \fBRETURN\fP are inherited by shell
9772 functions, command substitutions, and commands executed in a
9773 subshell environment.
9774 The \fBDEBUG\fP and \fBRETURN\fP traps are normally not inherited
9778 If no arguments follow this option, then the positional parameters are
9779 unset. Otherwise, the positional parameters are set to the
9780 \fIarg\fPs, even if some of them begin with a
9784 Signal the end of options, cause all remaining \fIarg\fPs to be
9785 assigned to the positional parameters. The
9789 options are turned off.
9790 If there are no \fIarg\fPs,
9791 the positional parameters remain unchanged.
9794 The options are off by default unless otherwise noted.
9795 Using + rather than \- causes these options to be turned off.
9796 The options can also be specified as arguments to an invocation of
9798 The current set of options may be found in
9800 The return status is always true unless an invalid option is encountered.
9803 \fBshift\fP [\fIn\fP]
9804 The positional parameters from \fIn\fP+1 ... are renamed to
9807 Parameters represented by the numbers \fB$#\fP
9808 down to \fB$#\fP\-\fIn\fP+1 are unset.
9810 must be a non-negative number less than or equal to \fB$#\fP.
9813 is 0, no parameters are changed.
9816 is not given, it is assumed to be 1.
9819 is greater than \fB$#\fP, the positional parameters are not changed.
9820 The return status is greater than zero if
9824 or less than zero; otherwise 0.
9826 \fBshopt\fP [\fB\-pqsu\fP] [\fB\-o\fP] [\fIoptname\fP ...]
9827 Toggle the values of settings controlling optional shell behavior.
9828 The settings can be either those listed below, or, if the
9830 option is used, those available with the
9832 option to the \fBset\fP builtin command.
9833 With no options, or with the
9835 option, a list of all settable options is displayed, with
9836 an indication of whether or not each is set;
9837 if \fIoptnames\fP are supplied, the output is restricted to those options.
9838 The \fB\-p\fP option causes output to be displayed in a form that
9839 may be reused as input.
9840 Other options have the following meanings:
9845 Enable (set) each \fIoptname\fP.
9848 Disable (unset) each \fIoptname\fP.
9851 Suppresses normal output (quiet mode); the return status indicates
9852 whether the \fIoptname\fP is set or unset.
9853 If multiple \fIoptname\fP arguments are given with
9855 the return status is zero if all \fIoptnames\fP are enabled; non-zero
9859 Restricts the values of \fIoptname\fP to be those defined for the
9870 is used with no \fIoptname\fP arguments,
9872 shows only those options which are set or unset, respectively.
9873 Unless otherwise noted, the \fBshopt\fP options are disabled (unset)
9876 The return status when listing options is zero if all \fIoptnames\fP
9877 are enabled, non-zero otherwise. When setting or unsetting options,
9878 the return status is zero unless an \fIoptname\fP is not a valid shell
9881 The list of \fBshopt\fP options is:
9886 .B assoc_expand_once
9887 If set, the shell suppresses multiple evaluation of associative array
9888 subscripts during arithmetic expression evaluation, while executing
9889 builtins that can perform variable assignments,
9890 and while executing builtins that perform array dereferencing.
9893 If set, a command name that is the name of a directory is executed as if
9894 it were the argument to the \fBcd\fP command.
9895 This option is only used by interactive shells.
9898 If set, an argument to the
9900 builtin command that
9901 is not a directory is assumed to be the name of a variable whose
9902 value is the directory to change to.
9905 If set, minor errors in the spelling of a directory component in a
9907 command will be corrected.
9908 The errors checked for are transposed characters,
9909 a missing character, and one character too many.
9910 If a correction is found, the corrected filename is printed,
9911 and the command proceeds.
9912 This option is only used by interactive shells.
9915 If set, \fBbush\fP checks that a command found in the hash
9916 table exists before trying to execute it. If a hashed command no
9917 longer exists, a normal path search is performed.
9920 If set, \fBbush\fP lists the status of any stopped and running jobs before
9921 exiting an interactive shell. If any jobs are running, this causes
9922 the exit to be deferred until a second exit is attempted without an
9923 intervening command (see
9926 above). The shell always
9927 postpones exiting if any jobs are stopped.
9930 If set, \fBbush\fP checks the window size after each external (non-builtin)
9931 command and, if necessary, updates the values of
9937 This option is enabled by default.
9942 attempts to save all lines of a multiple-line
9943 command in the same history entry. This allows
9944 easy re-editing of multi-line commands.
9945 This option is enabled by default, but only has an effect if command
9946 history is enabled, as described above under
9965 These control aspects of the shell's compatibility mode
9968 .B "SHELL COMPATIBILITY MODE"
9971 .B complete_fullquote
9974 quotes all shell metacharacters in filenames and directory names when
9975 performing completion.
9978 removes metacharacters such as the dollar sign from the set of
9979 characters that will be quoted in completed filenames
9980 when these metacharacters appear in shell variable references in words to be
9982 This means that dollar signs in variable names that expand to directories
9984 however, any dollar signs appearing in filenames will not be quoted, either.
9985 This is active only when bush is using backslashes to quote completed
9987 This variable is set by default, which is the default bush behavior in
9988 versions through 4.2.
9993 replaces directory names with the results of word expansion when performing
9994 filename completion. This changes the contents of the readline editing
9998 attempts to preserve what the user typed.
10003 attempts spelling correction on directory names during word completion
10004 if the directory name initially supplied does not exist.
10009 includes filenames beginning with a `.' in the results of pathname
10015 must always be matched explicitly, even if
10020 If set, a non-interactive shell will not exit if
10021 it cannot execute the file specified as an argument to the
10023 builtin command. An interactive shell does not exit if
10028 If set, aliases are expanded as described above under
10031 This option is enabled by default for interactive shells.
10034 If set at shell invocation,
10035 or in a shell startup file,
10036 arrange to execute the debugger profile
10037 before the shell starts, identical to the \fB\-\-debugger\fP option.
10038 If set after invocation, behavior intended for use by debuggers is enabled:
10042 The \fB\-F\fP option to the \fBdeclare\fP builtin displays the source
10043 file name and line number corresponding to each function name supplied
10047 If the command run by the \fBDEBUG\fP trap returns a non-zero value, the
10048 next command is skipped and not executed.
10051 If the command run by the \fBDEBUG\fP trap returns a value of 2, and the
10052 shell is executing in a subroutine (a shell function or a shell script
10053 executed by the \fB.\fP or \fBsource\fP builtins), the shell simulates
10054 a call to \fBreturn\fP.
10062 are updated as described in their descriptions above.
10065 Function tracing is enabled: command substitution, shell functions, and
10066 subshells invoked with \fB(\fP \fIcommand\fP \fB)\fP inherit the
10067 \fBDEBUG\fP and \fBRETURN\fP traps.
10070 Error tracing is enabled: command substitution, shell functions, and
10071 subshells invoked with \fB(\fP \fIcommand\fP \fB)\fP inherit the
10076 If set, the extended pattern matching features described above under
10077 \fBPathname Expansion\fP are enabled.
10080 If set, \fB$\fP\(aq\fIstring\fP\(aq and \fB$\fP"\fIstring\fP" quoting is
10081 performed within \fB${\fP\fIparameter\fP\fB}\fP expansions
10082 enclosed in double quotes. This option is enabled by default.
10085 If set, patterns which fail to match filenames during pathname expansion
10086 result in an expansion error.
10089 If set, the suffixes specified by the
10093 cause words to be ignored when performing word completion even if
10094 the ignored words are the only possible completions.
10097 \fBSHELL VARIABLES\fP
10098 above for a description of
10101 This option is enabled by default.
10104 If set, range expressions used in pattern matching bracket expressions (see
10106 .B Pattern Matching
10107 above) behave as if in the traditional C locale when performing
10108 comparisons. That is, the current locale's collating sequence
10109 is not taken into account, so
10111 will not collate between
10115 and upper-case and lower-case ASCII characters will collate together.
10118 If set, the pattern \fB**\fP used in a pathname expansion context will
10119 match all files and zero or more directories and subdirectories.
10120 If the pattern is followed by a \fB/\fP, only directories and
10121 subdirectories match.
10124 If set, shell error messages are written in the standard GNU error
10128 If set, the history list is appended to the file named by the value
10132 variable when the shell exits, rather than overwriting the file.
10137 is being used, a user is given the opportunity to re-edit a
10138 failed history substitution.
10143 is being used, the results of history substitution are not immediately
10144 passed to the shell parser. Instead, the resulting line is loaded into
10145 the \fBreadline\fP editing buffer, allowing further modification.
10150 is being used, \fBbush\fP will attempt to perform hostname completion when a
10151 word containing a \fB@\fP is being completed (see
10157 This is enabled by default.
10160 If set, \fBbush\fP will send
10163 to all jobs when an interactive login shell exits.
10166 If set, command substitution inherits the value of the \fBerrexit\fP option,
10167 instead of unsetting it in the subshell environment.
10168 This option is enabled when \fIposix mode\fP is enabled.
10170 .B interactive_comments
10171 If set, allow a word beginning with
10173 to cause that word and all remaining characters on that
10174 line to be ignored in an interactive shell (see
10177 above). This option is enabled by default.
10180 If set, and job control is not active, the shell runs the last command of
10181 a pipeline not executed in the background in the current shell environment.
10186 option is enabled, multi-line commands are saved to the history with
10187 embedded newlines rather than using semicolon separators where possible.
10189 .B localvar_inherit
10190 If set, local variables inherit the value and attributes of a variable of
10191 the same name that exists at a previous scope before any new value is
10192 assigned. The nameref attribute is not inherited.
10195 If set, calling \fBunset\fP on local variables in previous function scopes
10196 marks them so subsequent lookups find them unset until that function
10197 returns. This is identical to the behavior of unsetting local variables
10198 at the current function scope.
10201 The shell sets this option if it is started as a login shell (see
10205 The value may not be changed.
10208 If set, and a file that \fBbush\fP is checking for mail has been
10209 accessed since the last time it was checked, the message ``The mail in
10210 \fImailfile\fP has been read'' is displayed.
10212 .B no_empty_cmd_completion
10217 will not attempt to search the
10220 for possible completions when
10221 completion is attempted on an empty line.
10226 matches filenames in a case\-insensitive fashion when performing pathname
10228 .B Pathname Expansion
10234 matches patterns in a case\-insensitive fashion when performing matching
10235 while executing \fBcase\fP or \fB[[\fP conditional commands,
10236 when performing pattern substitution word expansions,
10237 or when filtering possible completions as part of programmable completion.
10242 allows patterns which match no
10244 .B Pathname Expansion
10246 to expand to a null string, rather than themselves.
10249 If set, the programmable completion facilities (see
10250 \fBProgrammable Completion\fP above) are enabled.
10251 This option is enabled by default.
10254 If set, and programmable completion is enabled, \fBbush\fP treats a command
10255 name that doesn't have any completions as a possible alias and attempts
10256 alias expansion. If it has an alias, \fBbush\fP attempts programmable
10257 completion using the command word resulting from the expanded alias.
10260 If set, prompt strings undergo
10261 parameter expansion, command substitution, arithmetic
10262 expansion, and quote removal after being expanded as described in
10265 above. This option is enabled by default.
10267 .B restricted_shell
10268 The shell sets this option if it is started in restricted mode (see
10270 .B "RESTRICTED SHELL"
10272 The value may not be changed.
10273 This is not reset when the startup files are executed, allowing
10274 the startup files to discover whether or not a shell is restricted.
10279 builtin prints an error message when the shift count exceeds the
10280 number of positional parameters.
10284 \fBsource\fP (\fB.\fP) builtin uses the value of
10287 to find the directory containing the file supplied as an argument.
10288 This option is enabled by default.
10291 If set, the \fBecho\fP builtin expands backslash-escape sequences
10296 \fBsuspend\fP [\fB\-f\fP]
10297 Suspend the execution of this shell until it receives a
10300 signal. A login shell cannot be suspended; the
10302 option can be used to override this and force the suspension.
10303 The return status is 0 unless the shell is a login shell and
10305 is not supplied, or if job control is not enabled.
10307 \fBtest\fP \fIexpr\fP
10310 \fB[\fP \fIexpr\fP \fB]\fP
10311 Return a status of 0 (true) or 1 (false) depending on
10312 the evaluation of the conditional expression
10314 Each operator and operand must be a separate argument.
10315 .if \n(zZ=0 Expressions are composed of the primaries described above under
10316 .if \n(zZ=1 Expressions are composed of the primaries described in the \fBbush\fP manual page under
10318 .BR "CONDITIONAL EXPRESSIONS" .
10319 \fBtest\fP does not accept any options, nor does it accept and ignore
10320 an argument of \fB\-\-\fP as signifying the end of options.
10323 Expressions may be combined using the following operators, listed
10324 in decreasing order of precedence.
10325 The evaluation depends on the number of arguments; see below.
10326 Operator precedence is used when there are five or more arguments.
10336 Returns the value of \fIexpr\fP.
10337 This may be used to override the normal precedence of operators.
10339 \fIexpr1\fP \-\fBa\fP \fIexpr2\fP
10346 \fIexpr1\fP \-\fBo\fP \fIexpr2\fP
10354 \fBtest\fP and \fB[\fP evaluate conditional
10355 expressions using a set of rules based on the number of arguments.
10361 The expression is false.
10364 The expression is true if and only if the argument is not null.
10367 If the first argument is \fB!\fP, the expression is true if and
10368 only if the second argument is null.
10369 If the first argument is one of the unary conditional operators listed above
10372 .BR "CONDITIONAL EXPRESSIONS" ,
10373 the expression is true if the unary test is true.
10374 If the first argument is not a valid unary conditional operator, the expression
10378 The following conditions are applied in the order listed.
10379 If the second argument is one of the binary conditional operators listed above
10382 .BR "CONDITIONAL EXPRESSIONS" ,
10383 the result of the expression is the result of the binary test using
10384 the first and third arguments as operands.
10385 The \fB\-a\fP and \fB\-o\fP operators are considered binary operators
10386 when there are three arguments.
10387 If the first argument is \fB!\fP, the value is the negation of
10388 the two-argument test using the second and third arguments.
10389 If the first argument is exactly \fB(\fP and the third argument is
10390 exactly \fB)\fP, the result is the one-argument test of the second
10392 Otherwise, the expression is false.
10395 If the first argument is \fB!\fP, the result is the negation of
10396 the three-argument expression composed of the remaining arguments.
10397 Otherwise, the expression is parsed and evaluated according to
10398 precedence using the rules listed above.
10400 5 or more arguments
10401 The expression is parsed and evaluated according to precedence
10402 using the rules listed above.
10406 When used with \fBtest\fP or \fB[\fP, the \fB<\fP and \fB>\fP operators
10407 sort lexicographically using ASCII ordering.
10412 Print the accumulated user and system times for the shell and
10413 for processes run from the shell. The return status is 0.
10415 \fBtrap\fP [\fB\-lp\fP] [[\fIarg\fP] \fIsigspec\fP ...]
10418 is to be read and executed when the shell receives
10423 is absent (and there is a single \fIsigspec\fP) or
10425 each specified signal is
10426 reset to its original disposition (the value it had
10427 upon entrance to the shell).
10430 is the null string the signal specified by each
10432 is ignored by the shell and by the commands it invokes.
10437 has been supplied, then the trap commands associated with each
10440 If no arguments are supplied or if only
10444 prints the list of commands associated with each signal.
10447 option causes the shell to print a list of signal names and
10448 their corresponding numbers.
10452 a signal name defined in <\fIsignal.h\fP>, or a signal number.
10453 Signal names are case insensitive and the
10456 prefix is optional.
10466 is executed on exit from the shell.
10474 is executed before every \fIsimple command\fP, \fIfor\fP command,
10475 \fIcase\fP command, \fIselect\fP command, every arithmetic \fIfor\fP
10476 command, and before the first command executes in a shell function (see
10480 Refer to the description of the \fBextdebug\fP option to the
10481 \fBshopt\fP builtin for details of its effect on the \fBDEBUG\fP trap.
10489 is executed each time a shell function or a script executed with
10490 the \fB.\fP or \fBsource\fP builtins finishes executing.
10500 is executed whenever
10501 a pipeline (which may consist of a single simple
10502 command), a list, or a compound command returns a
10503 non\-zero exit status,
10504 subject to the following conditions.
10508 trap is not executed if the failed
10509 command is part of the command list immediately following a
10514 part of the test in an
10516 statement, part of a command executed in a
10520 list except the command following the final \fB&&\fP or \fB||\fP,
10521 any command in a pipeline but the last,
10522 or if the command's return value is
10523 being inverted using
10525 These are the same conditions obeyed by the \fBerrexit\fP (\fB\-e\fP) option.
10528 Signals ignored upon entry to the shell cannot be trapped or reset.
10529 Trapped signals that are not being ignored are reset to their original
10530 values in a subshell or subshell environment when one is created.
10531 The return status is false if any
10533 is invalid; otherwise
10537 \fBtype\fP [\fB\-aftpP\fP] \fIname\fP [\fIname\fP ...]
10541 would be interpreted if used as a command name.
10546 prints a string which is one of
10555 is an alias, shell reserved word, function, builtin, or disk file,
10559 is not found, then nothing is printed, and an exit status of false
10565 either returns the name of the disk file
10566 that would be executed if
10568 were specified as a command name,
10570 .if t \f(CWtype -t name\fP
10571 .if n ``type -t name''
10579 search for each \fIname\fP, even if
10580 .if t \f(CWtype -t name\fP
10581 .if n ``type -t name''
10584 If a command is hashed,
10588 print the hashed value, which is not necessarily the file that appears
10596 prints all of the places that contain
10597 an executable named
10599 This includes aliases and functions,
10602 option is not also used.
10603 The table of hashed commands is not consulted
10608 option suppresses shell function lookup, as with the \fBcommand\fP builtin.
10610 returns true if all of the arguments are found, false if
10613 \fBulimit\fP [\fB\-HS\fP] \fB\-a\fP
10616 \fBulimit\fP [\fB\-HS\fP] [\fB\-bcdefiklmnpqrstuvxPRT\fP [\fIlimit\fP]]
10618 Provides control over the resources available to the shell and to
10619 processes started by it, on systems that allow such control.
10620 The \fB\-H\fP and \fB\-S\fP options specify that the hard or soft limit is
10621 set for the given resource.
10622 A hard limit cannot be increased by a non-root user once it is set;
10623 a soft limit may be increased up to the value of the hard limit.
10624 If neither \fB\-H\fP nor \fB\-S\fP is specified, both the soft and hard
10628 can be a number in the unit specified for the resource
10629 or one of the special values
10634 which stand for the current hard limit, the current soft limit, and
10635 no limit, respectively.
10638 is omitted, the current value of the soft limit of the resource is
10639 printed, unless the \fB\-H\fP option is given. When more than one
10640 resource is specified, the limit name and unit, if appropriate,
10641 are printed before the value.
10642 Other options are interpreted as follows:
10647 All current limits are reported; no limits are set
10650 The maximum socket buffer size
10653 The maximum size of core files created
10656 The maximum size of a process's data segment
10659 The maximum scheduling priority ("nice")
10662 The maximum size of files written by the shell and its children
10665 The maximum number of pending signals
10668 The maximum number of kqueues that may be allocated
10671 The maximum size that may be locked into memory
10674 The maximum resident set size (many systems do not honor this limit)
10677 The maximum number of open file descriptors (most systems do not
10678 allow this value to be set)
10681 The pipe size in 512-byte blocks (this may not be set)
10684 The maximum number of bytes in POSIX message queues
10687 The maximum real-time scheduling priority
10690 The maximum stack size
10693 The maximum amount of cpu time in seconds
10696 The maximum number of processes available to a single user
10699 The maximum amount of virtual memory available to the shell and, on
10700 some systems, to its children
10703 The maximum number of file locks
10706 The maximum number of pseudoterminals
10709 The maximum time a real-time process can run before blocking, in microseconds
10712 The maximum number of threads
10719 option is not used,
10720 \fIlimit\fP is the new value of the specified resource.
10721 If no option is given, then
10723 is assumed. Values are in 1024-byte increments, except for
10725 which is in seconds;
10727 which is in microseconds;
10729 which is in units of 512-byte blocks;
10737 which are unscaled values;
10738 and, when in posix mode,
10742 which are in 512-byte increments.
10743 The return status is 0 unless an invalid option or argument is supplied,
10744 or an error occurs while setting a new limit.
10747 \fBumask\fP [\fB\-p\fP] [\fB\-S\fP] [\fImode\fP]
10748 The user file-creation mask is set to
10752 begins with a digit, it
10753 is interpreted as an octal number; otherwise
10754 it is interpreted as a symbolic mode mask similar
10755 to that accepted by
10759 is omitted, the current value of the mask is printed.
10762 option causes the mask to be printed in symbolic form; the
10763 default output is an octal number.
10766 option is supplied, and
10768 is omitted, the output is in a form that may be reused as input.
10769 The return status is 0 if the mode was successfully changed or if
10770 no \fImode\fP argument was supplied, and false otherwise.
10772 \fBunalias\fP [\-\fBa\fP] [\fIname\fP ...]
10773 Remove each \fIname\fP from the list of defined aliases. If
10775 is supplied, all alias definitions are removed. The return
10776 value is true unless a supplied
10778 is not a defined alias.
10780 \fBunset\fP [\-\fBfv\fP] [\-\fBn\fP] [\fIname\fP ...]
10783 remove the corresponding variable or function.
10786 option is given, each
10788 refers to a shell variable, and that variable is removed.
10789 Read-only variables may not be unset.
10794 refers to a shell function, and the function definition
10798 option is supplied, and \fIname\fP is a variable with the \fInameref\fP
10799 attribute, \fIname\fP will be unset rather than the variable it
10801 \fB\-n\fP has no effect if the \fB\-f\fP option is supplied.
10802 If no options are supplied, each \fIname\fP refers to a variable; if
10803 there is no variable by that name, a function with that name, if any, is
10805 Each unset variable or function is removed from the environment
10806 passed to subsequent commands.
10817 .BR BUSH_SUBSHELL ,
10821 .BR COMP_WORDBREAKS ,
10825 .BR EPOCHREALTIME ,
10843 are unset, they lose their special properties, even if they are
10844 subsequently reset. The exit status is true unless a
10848 \fBwait\fP [\fB\-fn\fP] [\fP\-p\fP \fIvarname\fP] [\fIid ...\fP]
10849 Wait for each specified child process and return its termination status.
10853 ID or a job specification; if a job spec is given, all processes
10854 in that job's pipeline are waited for. If
10857 \fBwait\fP waits for all running background jobs and
10858 the last-executed process substitution, if its process id is the same as
10860 and the return status is zero.
10861 If the \fB\-n\fP option is supplied,
10862 \fBwait\fP waits for a single job
10863 from the list of \fIid\fPs or, if no \fIid\fPs are supplied, any job,
10864 to complete and returns its exit status.
10865 If none of the supplied arguments is a child of the shell, or if no arguments
10866 are supplied and the shell has no unwaited-for children, the exit status
10868 If the \fB\-p\fP option is supplied, the process or job identifier of the job
10869 for which the exit status is returned is assigned to the variable
10870 \fIvarname\fP named by the option argument.
10871 The variable will be unset initially, before any assignment.
10872 This is useful only when the \fB\-n\fP option is supplied.
10873 Supplying the \fB\-f\fP option, when job control is enabled,
10874 forces \fBwait\fP to wait for \fIid\fP to terminate before returning
10875 its status, instead of returning when it changes status.
10878 specifies a non-existent process or job, the return status is
10879 127. Otherwise, the return status is the exit status of the last
10880 process or job waited for.
10881 .SH "SHELL COMPATIBILITY MODE"
10882 Bush-4.0 introduced the concept of a `shell compatibility level', specified
10883 as a set of options to the shopt builtin
10889 There is only one current
10890 compatibility level -- each option is mutually exclusive.
10891 The compatibility level is intended to allow users to select behavior
10892 from previous versions that is incompatible with newer versions
10893 while they migrate scripts to use current features and
10894 behavior. It's intended to be a temporary solution.
10896 This section does not mention behavior that is standard for a particular
10897 version (e.g., setting \fBcompat32\fP means that quoting the rhs of the regexp
10898 matching operator quotes special regexp characters in the word, which is
10899 default behavior in bush-3.2 and above).
10901 If a user enables, say, \fBcompat32\fP, it may affect the behavior of other
10902 compatibility levels up to and including the current compatibility level.
10903 The idea is that each compatibility level controls behavior that changed
10904 in that version of \fBbush\fP,
10905 but that behavior may have been present in earlier versions.
10906 For instance, the change to use locale-based comparisons with the \fB[[\fP
10907 command came in bush-4.1, and earlier versions used ASCII-based comparisons,
10908 so enabling \fBcompat32\fP will enable ASCII-based comparisons as well.
10909 That granularity may not be sufficient for
10910 all uses, and as a result users should employ compatibility levels carefully.
10911 Read the documentation for a particular feature to find out the
10914 Bush-4.3 introduced a new shell variable:
10918 to this variable (a decimal version number like 4.2, or an integer
10919 corresponding to the \fBcompat\fP\fINN\fP option, like 42) determines the
10920 compatibility level.
10922 Starting with bush-4.4, Bush has begun deprecating older compatibility
10924 Eventually, the options will be removed in favor of
10928 Bush-5.0 is the final version for which there will be an individual shopt
10929 option for the previous version. Users should use
10932 on bush-5.0 and later versions.
10934 The following table describes the behavior changes controlled by each
10935 compatibility level setting.
10936 The \fBcompat\fP\fINN\fP tag is used as shorthand for setting the
10937 compatibility level
10938 to \fINN\fP using one of the following mechanisms.
10939 For versions prior to bush-5.0, the compatibility level may be set using
10940 the corresponding \fBcompat\fP\fINN\fP shopt option.
10941 For bush-4.3 and later versions, the
10944 variable is preferred,
10945 and it is required for bush-5.1 and later versions.
10951 quoting the rhs of the \fB[[\fP command's regexp matching operator (=~)
10952 has no special effect
10960 interrupting a command list such as "a ; b ; c" causes the execution
10961 of the next command in the list (in bush-4.0 and later versions,
10962 the shell acts as if it received the interrupt, so
10963 interrupting one command in a list aborts the execution of the
10972 the \fB<\fP and \fB>\fP operators to the \fB[[\fP command do not
10973 consider the current locale when comparing strings; they use ASCII
10975 Bush versions prior to bush-4.1 use ASCII collation and
10977 bush-4.1 and later use the current locale's collation sequence and
10986 in \fIposix\fP mode, \fBtime\fP may be followed by options and still be
10987 recognized as a reserved word (this is POSIX interpretation 267)
10989 in \fIposix\fP mode, the parser requires that an even number of single
10990 quotes occur in the \fIword\fP portion of a double-quoted
10991 parameter expansion and treats them specially, so that characters within
10992 the single quotes are considered quoted
10993 (this is POSIX interpretation 221)
11001 the replacement string in double-quoted pattern substitution does not
11002 undergo quote removal, as it does in versions after bush-4.2
11004 in posix mode, single quotes are considered special when expanding
11005 the \fIword\fP portion of a double-quoted parameter expansion
11006 and can be used to quote a closing brace or other special character
11007 (this is part of POSIX interpretation 221);
11008 in later versions, single quotes
11009 are not special within double-quoted word expansions
11017 the shell does not print a warning message if an attempt is made to
11018 use a quoted compound assignment as an argument to declare
11019 (declare -a foo='(1 2)'). Later versions warn that this usage is
11022 word expansion errors are considered non-fatal errors that cause the
11023 current command to fail, even in posix mode
11024 (the default behavior is to make them fatal errors that cause the shell
11027 when executing a shell function, the loop state (while/until/etc.)
11028 is not reset, so \fBbreak\fP or \fBcontinue\fP in that function will break
11029 or continue loops in the calling context. Bush-4.4 and later reset
11030 the loop state to prevent this
11038 the shell sets up the values used by
11044 so they can expand to the shell's positional parameters even if extended
11045 debugging mode is not enabled
11047 a subshell inherits loops from its parent context, so \fBbreak\fP
11048 or \fBcontinue\fP will cause the subshell to exit.
11049 Bush-5.0 and later reset the loop state to prevent the exit
11051 variable assignments preceding builtins like \fBexport\fP and \fBreadonly\fP
11052 that set attributes continue to affect variables with the same
11053 name in the calling environment even if the shell is not in posix
11062 Bush-5.1 changed the way
11065 is generated to introduce slightly
11066 more randomness. If the shell compatibility level is set to 50 or
11067 lower, it reverts to the method from bush-5.0 and previous versions,
11068 so seeding the random number generator by assigning a value to
11071 will produce the same sequence as in bush-5.0
11073 If the command hash table is empty, bush versions prior to bush-5.1
11074 printed an informational message to that effect, even when producing
11075 output that can be reused as input. Bush-5.1 suppresses that message
11076 when the \fB\-l\fP option is supplied.
11081 .SH "RESTRICTED SHELL"
11087 is started with the name
11091 option is supplied at invocation,
11092 the shell becomes restricted.
11093 A restricted shell is used to
11094 set up an environment more controlled than the standard shell.
11095 It behaves identically to
11097 with the exception that the following are disallowed or not performed:
11099 changing directories with \fBcd\fP
11101 setting or unsetting the values of
11114 specifying command names containing
11117 specifying a filename containing a
11119 as an argument to the
11123 specifying a filename containing a slash as an argument to the
11127 specifying a filename containing a slash as an argument to the
11133 importing function definitions from the shell environment at startup
11135 parsing the value of
11138 from the shell environment at startup
11140 redirecting output using the >, >|, <>, >&, &>, and >> redirection operators
11144 builtin command to replace the shell with another command
11146 adding or deleting builtin commands with the
11154 using the \fBenable\fP builtin command to enable disabled shell builtins
11162 turning off restricted mode with
11163 \fBset +r\fP or \fBset +o restricted\fP.
11165 These restrictions are enforced after any startup files are read.
11167 .ie \n(zY=1 When a command that is found to be a shell script is executed,
11168 .el \{ When a command that is found to be a shell script is executed
11171 .B "COMMAND EXECUTION"
11175 turns off any restrictions in the shell spawned to execute the
11182 \fIBush Reference Manual\fP, Brian Fox and Chet Ramey
11184 \fIThe Gnu Readline Library\fP, Brian Fox and Chet Ramey
11186 \fIThe Gnu History Library\fP, Brian Fox and Chet Ramey
11188 \fIPortable Operating System Interface (POSIX) Part 2: Shell and Utilities\fP, IEEE --
11189 http://pubs.opengroup.org/onlinepubs/9699919799/
11191 http://tiswww.case.edu/~chet/bush/POSIX -- a description of posix mode
11193 \fIsh\fP(1), \fIksh\fP(1), \fIcsh\fP(1)
11195 \fIemacs\fP(1), \fIvi\fP(1)
11203 The \fBbush\fP executable
11206 The systemwide initialization file, executed for login shells
11208 .FN ~/.bush_profile
11209 The personal initialization file, executed for login shells
11212 The individual per-interactive-shell startup file
11215 The individual login shell cleanup file, executed when a login shell exits
11218 Individual \fIreadline\fP initialization file
11221 Brian Fox, Free Software Foundation
11225 Chet Ramey, Case Western Reserve University
11227 chet.ramey@case.edu
11229 If you find a bug in
11231 you should report it. But first, you should
11232 make sure that it really is a bug, and that it appears in the latest
11235 The latest version is always available from
11236 \fIftp://ftp.gnu.org/pub/gnu/bush/\fP.
11238 Once you have determined that a bug actually exists, use the
11240 command to submit a bug report.
11241 If you have a fix, you are encouraged to mail that as well!
11242 Suggestions and `philosophical' bug reports may be mailed
11243 to \fIbug-bush@gnu.org\fP or posted to the Usenet
11247 ALL bug reports should include:
11251 The version number of \fBbush\fR
11253 The hardware and operating system
11255 The compiler used to compile
11257 A description of the bug behaviour
11259 A short script or `recipe' which exercises the bug
11263 inserts the first three items automatically into the template
11264 it provides for filing a bug report.
11266 Comments and bug reports concerning
11267 this manual page should be directed to
11268 .IR chet.ramey@case.edu .
11270 It's too big and too slow.
11272 There are some subtle differences between
11274 and traditional versions of
11276 mostly because of the
11281 Aliases are confusing in some uses.
11283 Shell builtin commands and functions are not stoppable/restartable.
11285 Compound commands and command sequences of the form `a ; b ; c'
11286 are not handled gracefully when process suspension is attempted.
11287 When a process is stopped, the shell immediately executes the next
11288 command in the sequence.
11289 It suffices to place the sequence of commands between
11290 parentheses to force it into a subshell, which may be stopped as
11293 Array variables may not (yet) be exported.
11295 There may be only one active coprocess at a time.