diff options
author | Jari Aalto <jari.aalto@cante.net> | 2000-03-17 21:46:59 +0000 |
---|---|---|
committer | Jari Aalto <jari.aalto@cante.net> | 2009-09-12 16:46:53 +0000 |
commit | bb70624e964126b7ac4ff085ba163a9c35ffa18f (patch) | |
tree | ba2dd4add13ada94b1899c6d4aca80195b80b74b /doc/bash.1 | |
parent | b72432fdcc59300c6fe7c9d6c8a31ad3447933f5 (diff) | |
download | android_external_bash-bb70624e964126b7ac4ff085ba163a9c35ffa18f.tar.gz android_external_bash-bb70624e964126b7ac4ff085ba163a9c35ffa18f.tar.bz2 android_external_bash-bb70624e964126b7ac4ff085ba163a9c35ffa18f.zip |
Imported from ../bash-2.04.tar.gz.
Diffstat (limited to 'doc/bash.1')
-rw-r--r-- | doc/bash.1 | 890 |
1 files changed, 728 insertions, 162 deletions
@@ -6,11 +6,12 @@ .\" Case Western Reserve University .\" chet@ins.CWRU.Edu .\" -.\" Last Change: Wed Jan 20 16:47:14 EST 1999 +.\" Last Change: Tue Mar 14 11:36:43 EST 2000 .\" .\" bash_builtins, strip all but Built-Ins section .if \n(zZ=1 .ig zZ -.TH BASH 1 "1999 Jan 20" GNU +.if \n(zY=1 .ig zY +.TH BASH 1 "2000 Mar 14" "GNU Bash-2.04" .\" .\" There's some problem with having a `@' .\" in a tagged paragraph with the BSD man macros. @@ -151,7 +152,7 @@ below). .B \-\-noediting Do not use the GNU .B readline -library to read command lines if interactive. +library to read command lines when the shell is interactive. .TP .B \-\-noprofile Do not read either the system-wide startup file @@ -228,7 +229,11 @@ or one started with the .B \-\-login option. .PP -An \fIinteractive\fP shell is one whose standard input and output are +An \fIinteractive\fP shell is one started without non-option arguments +and without the +.B \-c +option +whose standard input and output are both connected to terminals (as determined by .IR isatty (3)), or one started with the @@ -548,24 +553,24 @@ denote AND lists and OR lists, respectively. An AND list has the form .RS .PP -\fIcommand\fP \fB&&\fP \fIcommand2\fP +\fIcommand1\fP \fB&&\fP \fIcommand2\fP .RE .PP .I command2 is executed if, and only if, -.I command +.I command1 returns an exit status of zero. .PP An OR list has the form .RS .PP -\fIcommand\fP \fB\(bv\(bv\fP \fIcommand2\fP +\fIcommand1\fP \fB\(bv\(bv\fP \fIcommand2\fP .PP .RE .PP .I command2 is executed if and only if -.I command +.I command1 returns a non-zero exit status. The return status of AND and OR lists is the exit status of the last command executed in the list. @@ -658,10 +663,11 @@ the entire conditional expression. .TP \fBfor\fP \fIname\fP [ \fBin\fP \fIword\fP ] ; \fBdo\fP \fIlist\fP ; \fBdone\fP The list of words following \fBin\fP is expanded, generating a list -of items. The variable \fIname\fP is set to each element of this list -in turn, and \fIlist\fP is executed each time. If the \fBin\fP -\fIword\fP is omitted, the \fBfor\fP command executes \fIlist\fP -once for each positional parameter that is set (see +of items. +The variable \fIname\fP is set to each element of this list +in turn, and \fIlist\fP is executed each time. +If the \fBin\fP \fIword\fP is omitted, the \fBfor\fP command executes +\fIlist\fP once for each positional parameter that is set (see .SM .B PARAMETERS below). @@ -669,6 +675,19 @@ The return status is the exit status of the last command that executes. If the expansion of the items following \fBin\fP results in an empty list, no commands are executed, and the return status is 0. .TP +\fBfor\fP (( \fIexpr1\fP ; \fIexpr2\fP ; \fIexpr3\fP )) ; \fBdo\fP \fIlist\fP ; \fBdone\fP +First, the arithmetic expression \fIexpr1\fP is evaluated according +to the rules described below under +.SM +.BR "ARITHMETIC EVALUATION" . +The arithmetic expression \fIexpr2\fP is then evaluated repeatedly +until it evaluates to zero. +Each time \fIexpr2\fP evaluates to a non-zero value, \fIlist\fP is +executed and the arithmetic expression \fIexpr3\fP is evaluated. +If any expression is omitted, it behaves as if it evaluates to 1. +The return value is the exit status of the last command in \fIlist\fP +that is executed, or false if any of the expressions is invalid. +.TP \fBselect\fP \fIname\fP [ \fBin\fP \fIword\fP ] ; \fBdo\fP \fIlist\fP ; \fBdone\fP The list of words following \fBin\fP is expanded, generating a list of items. The set of expanded words is printed on the standard @@ -701,7 +720,7 @@ is the exit status of the last command executed in .IR list , or zero if no commands were executed. .TP -\fBcase\fP \fIword\fP \fBin\fP [ ( \fIpattern\fP [ \fB|\fP \fIpattern\fP ] \ +\fBcase\fP \fIword\fP \fBin\fP [ [(] \fIpattern\fP [ \fB|\fP \fIpattern\fP ] \ ... ) \fIlist\fP ;; ] ... \fBesac\fP A \fBcase\fP command first expands \fIword\fP, and tries to match it against each \fIpattern\fP in turn, using the same matching rules @@ -784,8 +803,14 @@ parameter expansion. Each of the \fImetacharacters\fP listed above under .SM .B DEFINITIONS -has special meaning to the shell and must be quoted if they are to -represent themselves. There are three quoting mechanisms: the +has special meaning to the shell and must be quoted if it is to +represent itself. +.PP +When the command history expansion facilities are being used, the +\fIhistory expansion\fP character, usually \fB!\fP, must be quoted +to prevent history expansion. +.PP +There are three quoting mechanisms: the .IR "escape character" , single quotes, and double quotes. .PP @@ -866,6 +891,9 @@ vertical tab .TP .B \e\e backslash +.TP +.B \e' +single quote .TP .B \e\fInnn\fP the character whose ASCII code is the octal value \fInnn\fP @@ -877,7 +905,7 @@ the character whose ASCII code is the hexadecimal value \fInnn\fP .PD .RE .LP -The translated result is single-quoted, as if the dollar sign had +The expanded result is single-quoted, as if the dollar sign had not been present. .PP A double-quoted string preceded by a dollar sign (\fB$\fP) will cause @@ -920,8 +948,8 @@ If .I value is not given, the variable is assigned the null string. All .I values -undergo tilde expansion, parameter and variable expansion, string -expansion, command substitution, arithmetic expansion, and quote +undergo tilde expansion, parameter and variable expansion, +command substitution, arithmetic expansion, and quote removal (see .SM .B EXPANSION @@ -1087,7 +1115,16 @@ shell startup. This variable is readonly. .TP .B GROUPS An array variable containing the list of groups of which the current -user is a member. This variable is readonly. +user is a member. +Assignments to +.SM +.B GROUPS +have no effect and are silently discarded. +If +.SM +.B GROUPS +is unset, it loses its special properties, even if it is +subsequently reset. .TP .B BASH Expands to the full file name used to invoke this instance of @@ -1180,6 +1217,19 @@ If is unset, it loses its special properties, even if it is subsequently reset. .TP +.B FUNCNAME +The name of any currently-executing shell function. +This variable exists only when a shell function is executing. +Assignments to +.SM +.B FUNCNAME +have no effect and are silently discarded. +If +.SM +.B FUNCNAME +is unset, it loses its special properties, even if it is +subsequently reset. +.TP .B DIRSTACK An array variable (see .B Arrays @@ -1267,6 +1317,37 @@ If this variable is in the environment when starts up, each shell option in the list will be enabled before reading any startup files. This variable is read-only. +.TP +.B COMP_WORDS +An array variable (see \fBArrays\fP below) consisting of the individual +words in the current command line. +This variable is available only in shell functions invoked by the +programmable completion facilities (see \fBProgrammable Completion\fP +below). +.TP +.B COMP_CWORD +An index into \fB${COMP_WORDS}\fP of the word containing the current +cursor position. +This variable is available only in shell functions invoked by the +programmable completion facilities (see \fBProgrammable Completion\fP +below). +.TP +.B COMP_LINE +The current command line. +This variable is available only in shell functions and external +commands invoked by the +programmable completion facilities (see \fBProgrammable Completion\fP +below). +.TP +.B COMP_POINT +The index of the current cursor position relative to the beginning of +the current command. +If the current cursor position is at the end of the current command, +the value of this variable is equal to \fB${#COMP_LINE}\fP. +This variable is available only in shell functions and external +commands invoked by the +programmable completion facilities (see \fBProgrammable Completion\fP +below). .PD .PP The following variables are used by the shell. In some cases, @@ -1351,11 +1432,11 @@ the current mailfile. Example: .RS .PP -\fBMAILPATH\fP='/usr/spool/mail/bfox?"You have mail":~/shell\-mail?"$_ has mail!"' +\fBMAILPATH\fP='/var/mail/bfox?"You have mail":~/shell\-mail?"$_ has mail!"' .PP .B Bash supplies a default value for this variable, but the location of the user -mail files that it uses is system dependent (e.g., /usr/spool/mail/\fB$USER\fP). +mail files that it uses is system dependent (e.g., /var/mail/\fB$USER\fP). .RE .TP .B PS1 @@ -1494,6 +1575,9 @@ matching. This variable determines the locale used to translate double-quoted strings preceded by a \fB$\fP. .TP +.B LC_NUMERIC +This variable determines the locale category used for number formatting. +.TP .B PROMPT_COMMAND If set, the value is executed as a command prior to issuing each primary prompt. @@ -1564,8 +1648,8 @@ If set to a value of .IR ignorespace , lines which begin with a .B space -character are not entered on the history list. If set to -a value of +character are not entered on the history list. +If set to a value of .IR ignoredups , lines matching the last history line are not entered. A value of @@ -1585,14 +1669,14 @@ not tested, and are added to the history regardless of the value of .B HISTIGNORE A colon-separated list of patterns used to decide which command lines should be saved on the history list. Each pattern is anchored at the -beginning of the line and must fully specify the line (no implicit +beginning of the line and must match the complete line (no implicit `\fB*\fP' is appended). Each pattern is tested against the line after the checks specified by .B HISTCONTROL are applied. In addition to the normal shell pattern matching characters, `\fB&\fP' matches the previous history line. `\fB&\fP' may be escaped using a -backslash. The backslash is removed before attempting a match. +backslash; the backslash is removed before attempting a match. The second and subsequent lines of a multi-line compound command are not tested, and are added to the history regardless of the value of .BR HISTIGNORE . @@ -1602,12 +1686,10 @@ The two or three characters which control history expansion and tokenization (see .SM .B HISTORY EXPANSION -below). The first character is the -.IR "history expansion character" , +below). The first character is the \fIhistory expansion\fP character, the character which signals the start of a history expansion, normally `\fB!\fP'. -The second character is the -.IR "quick substitution" +The second character is the \fIquick substitution\fP character, which is used as shorthand for re-running the previous command entered, substituting one string for another in the command. The default is `\fB^\fP'. @@ -1622,10 +1704,23 @@ parser to treat the rest of the line as a comment. Contains the name of a file in the same format as .FN /etc/hosts that should be read when the shell needs to complete a -hostname. The file may be changed interactively; the next -time hostname completion is attempted +hostname. +The list of possible hostname completions may be changed while the +shell is running; +the next time hostname completion is attempted after the +value is changed, .B bash -adds the contents of the new file to the already existing database. +adds the contents of the new file to the existing list. +If +.SM +.B HOSTFILE +is set, but has no value, \fBbash\fP attempts to read +.FN /etc/hosts +to obtain the list of possible hostname completions. +When +.SM +.B HOSTFILE +is unset, the hostname list is cleared. .TP .B auto_resume This variable controls how the shell interacts with the user and @@ -1655,6 +1750,11 @@ be a prefix of a stopped job's name; this provides functionality analogous to the .B % job identifier. +.TP +.B COMPREPLY +An array variable from which \fBbash\fP reads the possible completions +generated by a shell function invoked by the programmable completion +facility (see \fBProgrammable Completion\fP below). .PD .SS Arrays .B Bash @@ -1720,7 +1820,7 @@ referencing element zero. .PP The .B unset -builtin is used to destroy arrays. \fBunset\fP \fBname\fP[\fIsubscript\fP] +builtin is used to destroy arrays. \fBunset\fP \fIname\fP[\fIsubscript\fP] destroys the array element at index \fIsubscript\fP. \fBunset\fP \fIname\fP, where \fIname\fP is an array, or \fBunset\fP \fIname\fP[\fIsubscript\fP], where @@ -1805,6 +1905,8 @@ and closing braces, and at least one unquoted comma. Any incorrectly formed brace expansion is left unchanged. A \fB{\fP or \fB,\fP may be quoted with a backslash to prevent its being considered part of a brace expression. +To avoid conflicts with parameter expansion, the string \fB${\fP +is not considered eligible for brace expansion. .PP This construct is typically used as shorthand when the common prefix of the strings to be generated is longer than in the @@ -1934,9 +2036,11 @@ If the first character of \fIparameter\fP is an exclamation point, a level of variable indirection is introduced. \fBBash\fP uses the value of the variable formed from the rest of \fIparameter\fP as the name of the variable; this variable is then -expanded and that value used in the rest of the substitution, rather +expanded and that value is used in the rest of the substitution, rather than the value of \fIparameter\fP itself. This is known as \fIindirect expansion\fP. +The exception to this is the expansion of ${!\fIprefix\fP*} +described below. .PP In each of the cases below, \fIword\fP is subject to tilde expansion, parameter expansion, command substitution, and arithmetic expansion. @@ -1993,10 +2097,10 @@ ${\fIparameter\fP\fB:\fP\fIoffset\fP} ${\fIparameter\fP\fB:\fP\fIoffset\fP\fB:\fP\fIlength\fP} .PD \fBSubstring Expansion.\fP -Expands to up to \fIlength\fP characters of \fIparameter\fP, -starting at the characters specified by \fIoffset\fP. +Expands to up to \fIlength\fP characters of \fIparameter\fP +starting at the character specified by \fIoffset\fP. If \fIlength\fP is omitted, expands to the substring of -\fIparameter\fP, starting at the character specified by \fIoffset\fP. +\fIparameter\fP starting at the character specified by \fIoffset\fP. \fIlength\fP and \fIoffset\fP are arithmetic expressions (see .SM .B @@ -2013,6 +2117,13 @@ members of the array beginning with ${\fIparameter\fP[\fIoffset\fP]}. Substring indexing is zero-based unless the positional parameters are used, in which case the indexing starts at 1. .TP +${\fB!\fP\fIprefix\fP\fB*\fP} +Expands to the names of variables whose names begin with \fIprefix\fP, +separated by the first character of the +.SM +.B IFS +special variable. +.TP ${\fB#\fP\fIparameter\fP} The length in characters of the value of \fIparameter\fP is substituted. If @@ -2206,7 +2317,7 @@ the file will provide input for \fIlist\fP. If the \fB<(\fP\fIlist\^\fP\fB)\fP form is used, the file passed as an argument should be read to obtain the output of \fIlist\fP. .PP -When available, \fIprocess substitution\fP is performed +When available, process substitution is performed simultaneously with parameter and variable expansion, command substitution, and arithmetic expansion. @@ -2272,8 +2383,7 @@ is null, no word splitting occurs. .PP Explicit null arguments (\^\f3"\^"\fP or \^\f3'\^'\fP\^) are retained. Unquoted implicit null arguments, resulting from the expansion of -.I parameters -that have no values, are removed. +parameters that have no values, are removed. If a parameter with no value is expanded within double quotes, a null argument results and is retained. .PP @@ -2289,7 +2399,6 @@ option has been set, scans each word for the characters .BR * , .BR ? , -.BR ( , and .BR [ . If one of these characters appears, then the word is @@ -2453,7 +2562,7 @@ the syntax \fB[.\fP\fIsymbol\fP\fB.]\fP matches the collating symbol .PP If the \fBextglob\fP shell option is enabled using the \fBshopt\fP builtin, several extended pattern matching operators are recognized. -In the following description, a \fIpattern\-list\fP is a list of one +In the following description, a \fIpattern-list\fP is a list of one or more patterns separated by a \fB|\fP. Composite patterns may be formed using one or more of the following sub-patterns: @@ -2511,7 +2620,7 @@ the redirection refers to the standard output (file descriptor The word following the redirection operator in the following descriptions, unless otherwise noted, is subjected to brace expansion, tilde expansion, parameter expansion, command substitution, arithmetic -expansion, quote removal, and pathname expansion. +expansion, quote removal, pathname expansion, and word splitting. If it expands to more than one word, .B bash reports an error. @@ -2537,6 +2646,36 @@ because the standard error was duplicated as standard output before the standard output was redirected to .IR dirlist . .PP +\fBBash\fP handles several filenames specially when they are used in +redirections, as described in the following table: +.RS +.PP +.PD 0 +.TP +.B /dev/fd/\fIfd\fP +If \fIfd\fP is a valid integer, file descriptor \fIfd\fP is duplicated. +.TP +.B /dev/stdin +File descriptor 0 is duplicated. +.TP +.B /dev/stdout +File descriptor 1 is duplicated. +.TP +.B /dev/stderr +File descriptor 2 is duplicated. +.TP +.B /dev/tcp/\fIhost\fP/\fIport\fP +If \fIhost\fP is a valid hostname or Internet address, and \fIport\fP +is an integer port number, \fBbash\fP attempts to open a TCP connection +to the corresponding socket. +.TP +.B /dev/udp/\fIhost\fP/\fIport\fP +If \fIhost\fP is a valid hostname or Internet address, and \fIport\fP +is an integer port number, \fBbash\fP attempts to open a UDP connection +to the corresponding socket. +.PD +.RE +.PP A failure to open or create a file causes the redirection to fail. .SS Redirecting Input .PP @@ -2578,7 +2717,7 @@ and the .B noclobber option to the .B set -builtin has been enabled, the redirection will fail if the filename +builtin has been enabled, the redirection will fail if the file whose name results from the expansion of \fIword\fP exists and is a regular file. If the redirection operator is @@ -2657,8 +2796,8 @@ The format of here-documents is as follows: .fi .RE .PP -No parameter expansion, command substitution, pathname -expansion, or arithmetic expansion is performed on +No parameter expansion, command substitution, arithmetic expansion, +or pathname expansion is performed on .IR word . If any characters in .I word @@ -2670,7 +2809,7 @@ and the lines in the here-document are not expanded. If \fIword\fP is unquoted, all lines of the here-document are subjected to parameter expansion, command substitution, and arithmetic expansion. In the latter -case, the pair +case, the character sequence .B \e<newline> is ignored, and .B \e @@ -2746,11 +2885,9 @@ or on file descriptor 0 if .I n is not specified. If the file does not exist, it is created. .SH ALIASES -Aliases allow a string to be substituted for a word when it is used +\fIAliases\fP allow a string to be substituted for a word when it is used as the first word of a simple command. -The shell maintains a list of -.I aliases -that may be set and unset with the +The shell maintains a list of aliases that may be set and unset with the .B alias and .B unalias @@ -2786,7 +2923,10 @@ command, and removed with the command. .PP There is no mechanism for using arguments in the replacement text. -If arguments are needed, a shell function should be used. +If arguments are needed, a shell function should be used (see +.SM +.B FUNCTIONS +below). .PP Aliases are not expanded when the shell is not interactive, unless the @@ -2828,15 +2968,24 @@ A shell function, defined as described above under .SM .BR "SHELL GRAMMAR" , stores a series of commands for later execution. +When the name of a shell function is used as a simple command name, +the list of commands associated with that function name is executed. Functions are executed in the context of the current shell; no new process is created to interpret them (contrast this with the execution of a shell script). When a function is executed, the arguments to the function become the positional parameters -during its execution. The special parameter +during its execution. +The special parameter .B # is updated to reflect the change. Positional parameter 0 -is unchanged. All other aspects of the shell execution +is unchanged. +The +.SM +.B FUNCNAME +variable is set to the name of the function while the function +is executing. +All other aspects of the shell execution environment are identical between a function and its caller with the exception that the .SM @@ -2891,12 +3040,20 @@ certain circumstances (see the \fBlet\fP builtin command and \fBArithmetic Expansion\fP). Evaluation is done in long integers with no check for overflow, though division by 0 is trapped and flagged as an error. +The operators and their precedence and associativity are the same +as in the C language. The following list of operators is grouped into levels of equal-precedence operators. The levels are listed in order of decreasing precedence. .PP .PD 0 .TP +.B \fIid\fP++ \fIid\fP\-\- +variable post-increment and post-decrement +.TP +.B ++\fIid\fP \-\-\fIid\fP +variable pre-increment and pre-decrement +.TP .B \- + unary minus and plus .TP @@ -2941,12 +3098,18 @@ conditional evaluation .TP .B = *= /= %= += \-= <<= >>= &= ^= |= assignment +.TP +.B \fIexpr1\fP , \fIexpr2\fP +comma .PD .PP Shell variables are allowed as operands; parameter expansion is -performed before the expression is evaluated. -The value of a parameter is coerced to a long integer within -an expression. A shell variable need not have its integer attribute +performed before the expression is evaluated. +Within an expression, shell variables may also be referenced by name +without using the parameter expansion syntax. +The value of a variable is evaluated as an arithmetic expression +when it is referenced. +A shell variable need not have its integer attribute turned on to be used in an expression. .PP Constants with a leading 0 are interpreted as octal numbers. @@ -2954,7 +3117,7 @@ A leading 0x or 0X denotes hexadecimal. Otherwise, numbers take the form [\fIbase#\fP]n, where \fIbase\fP is a decimal number between 2 and 64 representing the arithmetic base, and \fIn\fP is a number in that base. -If \fIbase\fP is omitted, then base 10 is used. +If \fIbase#\fP is omitted, then base 10 is used. The digits greater than 9 are represented by the lowercase letters, the uppercase letters, _, and @, in that order. If \fIbase\fP is less than or equal to 36, lowercase and uppercase @@ -2970,7 +3133,10 @@ the \fBtest\fP and \fB[\fP builtin commands to test file attributes and perform string and arithmetic comparisons. Expressions are formed from the following unary or binary primaries. If any \fIfile\fP argument to one of the primaries is of the form -/dev/fd/\fIn\fP, then file descriptor \fIn\fP is checked. +\fI/dev/fd/n\fP, then file descriptor \fIn\fP is checked. +If the \fIfile\fP argument to one of the primaries is one of +\fI/dev/stdin\fP, \fI/dev/stdout\fP, or \fI/dev/stderr\fP, file +descriptor 0, 1, or 2, respectively, is checked. .sp 1 .PD 0 .TP @@ -3162,7 +3328,7 @@ searches each element of the .B PATH for a directory containing an executable file by that name. .B Bash -uses a hash table to remember the full file names of executable +uses a hash table to remember the full pathnames of executable files (see .B hash under @@ -3276,8 +3442,8 @@ This is a list of \fIname\fP\-\fIvalue\fP pairs, of the form .IR "name\fR=\fPvalue" . .PP -The shell allows you to manipulate the environment in several -ways. On invocation, the shell scans its own environment and +The shell provides several ways to manipulate the environment. +On invocation, the shell scans its own environment and creates a parameter for each name found, automatically marking it for .I export @@ -3328,8 +3494,8 @@ command in its environment. For the shell's purposes, a command which exits with a zero exit status has succeeded. An exit status of zero indicates success. A non-zero exit status indicates failure. -When a command terminates on a fatal signal, \fBbash\fP uses -the value of 128+\fBsignal\fP as the exit status. +When a command terminates on a fatal signal \fIN\fP, \fBbash\fP uses +the value of 128+\fIN\fP as the exit status. .PP If a command is not found, the child process created to execute it returns a status of 127. If a command is found @@ -3467,7 +3633,7 @@ uses the abstraction as the basis for job control. .PP To facilitate the implementation of the user interface to job -control, the system maintains the notion of a \fIcurrent terminal +control, the operating system maintains the notion of a \fIcurrent terminal process group ID\fP. Members of this process group (processes whose process group ID is equal to the current terminal process group ID) receive keyboard-generated signals such as @@ -3491,13 +3657,13 @@ If the operating system on which is running supports job control, .B bash -allows you to use it. +contains facilities to use it. Typing the .I suspend character (typically .BR ^Z , Control-Z) while a process is running -causes that process to be stopped and returns you to +causes that process to be stopped and returns control to .BR bash . Typing the .I "delayed suspend" @@ -3622,6 +3788,12 @@ the hostname up to the first `.' .B \eH the hostname .TP +.B \ej +the number of jobs currently managed by the shell +.TP +.B \el +the basename of the shell's terminal device name +.TP .B \en newline .TP @@ -3693,8 +3865,8 @@ list, which may include commands restored from the history file below), while the command number is the position in the sequence of commands executed during the current shell session. After the string is decoded, it is expanded via -parameter expansion, command substitution, arithmetic expansion, -string expansion, and quote removal, subject to the value of the +parameter expansion, command substitution, arithmetic +expansion, and quote removal, subject to the value of the .B promptvars shell option (see the description of the .B shopt @@ -3806,6 +3978,7 @@ The following symbolic character names are recognized: .IR SPACE , and .IR TAB . +.PP In addition to command names, readline allows keys to be bound to a string that is inserted when the key is pressed (a \fImacro\fP). .SS "Readline Key Bindings" @@ -3980,8 +4153,7 @@ If set to \fBnone\fP, readline never rings the bell. If set to If set to \fBaudible\fP, readline attempts to ring the terminal's bell. .TP .B comment\-begin (``#'') -The string that is inserted when the -.B readline +The string that is inserted when the readline .B insert\-comment command is executed. This command is bound to @@ -4007,7 +4179,7 @@ on the terminal. .B convert\-meta (On) If set to \fBOn\fP, readline will convert characters with the eighth bit set to an ASCII key sequence -by stripping the eighth bit and prepending an +by stripping the eighth bit and prefixing an escape character (in effect, using escape as the \fImeta prefix\fP). .TP .B disable\-completion (Off) @@ -4178,7 +4350,7 @@ As each character of the search string is typed, readline displays the next entry from the history matching the string typed so far. An incremental search requires only as many characters as needed to find the desired history entry. -The characters present in the value of the \fIisearch-terminators\fP +The characters present in the value of the \fBisearch-terminators\fP variable are used to terminate an incremental search. If that variable has not been assigned a value the Escape and Control-J characters will terminate an incremental search. @@ -4186,6 +4358,7 @@ Control-G will abort an incremental search and restore the original line. When the search is terminated, the history entry containing the search string becomes the current line. +.PP To find other matching entries in the history list, type Control-S or Control-R as appropriate. This will search backward or forward in the history for the next @@ -4203,6 +4376,10 @@ typed by the user or be part of the contents of the current line. The following is a list of the names of the commands and the default key sequences to which they are bound. Command names without an accompanying key sequence are unbound by default. +In the following descriptions, \fIpoint\fP refers to the current cursor +position, and \fImark\fP refers to a cursor position saved by the +\fBset\-mark\fP command. +The text between the point and mark is referred to as the \fIregion\fP. .SS Commands for Moving .PP .PD 0 @@ -4224,7 +4401,7 @@ Move forward to the end of the next word. Words are composed of alphanumeric characters (letters and digits). .TP .B backward\-word (M\-b) -Move back to the start of this, or the previous, word. Words are +Move back to the start of the current or previous word. Words are composed of alphanumeric characters (letters and digits). .TP .B clear\-screen (C\-l) @@ -4280,8 +4457,7 @@ a string supplied by the user. .TP .B history\-search\-forward Search forward through the history for the string of characters -between the start of the current line and the current cursor -position (the \fIpoint\fP). +between the start of the current line and the point. This is a non-incremental search. .TP .B history\-search\-backward @@ -4379,12 +4555,14 @@ Insert the character typed. .TP .B transpose\-chars (C\-t) Drag the character before point forward over the character at point. -Point moves forward as well. If point is at the end of the line, then -transpose the two characters before point. Negative arguments don't work. +Point moves forward as well. +If point is at the end of the line, then transpose the two characters +before point. +Negative arguments have no effect. .TP .B transpose\-words (M\-t) -Drag the word behind the cursor past the word in front of the cursor -moving the cursor over that word as well. +Drag the word before point past the word after point, +moving the point over that word as well. .TP .B upcase\-word (M\-u) Uppercase the current (or following) word. With a negative argument, @@ -4403,7 +4581,7 @@ capitalize the previous word, but do not move point. .PD 0 .TP .B kill\-line (C\-k) -Kill the text from the current cursor position to the end of the line. +Kill the text from point to the end of the line. .TP .B backward\-kill\-line (C\-x Rubout) Kill backward to the beginning of the line. @@ -4411,31 +4589,30 @@ Kill backward to the beginning of the line. .B unix\-line\-discard (C\-u) Kill backward from point to the beginning of the line. The killed text is saved on the kill-ring. -\" There is no real difference between this and backward-kill-line +.\" There is no real difference between this and backward-kill-line .TP .B kill\-whole\-line -Kill all characters on the current line, no matter where the -cursor is. +Kill all characters on the current line, no matter where point is. .TP .B kill\-word (M\-d) -Kill from the cursor to the end of the current word, or if between -words, to the end of the next word. Word boundaries are the same as -those used by \fBforward\-word\fP. +Kill from point to the end of the current word, or if between +words, to the end of the next word. +Word boundaries are the same as those used by \fBforward\-word\fP. .TP .B backward\-kill\-word (M\-Rubout) -Kill the word behind the cursor. Word boundaries are the same as -those used by \fBbackward\-word\fP. +Kill the word behind point. +Word boundaries are the same as those used by \fBbackward\-word\fP. .TP .B unix\-word\-rubout (C\-w) -Kill the word behind the cursor, using white space as a word boundary. +Kill the word behind point, using white space as a word boundary. The word boundaries are different from \fBbackward\-kill\-word\fP. +The killed text is saved on the kill-ring. .TP .B delete\-horizontal\-space (M\-\e) Delete all spaces and tabs around point. .TP .B kill\-region -Kill the text between the point and \fImark\fP (saved cursor position). -This text is referred to as the \fIregion\fP. +Kill the text in the current region. .TP .B copy\-region\-as\-kill Copy the text in the region to the kill buffer. @@ -4515,9 +4692,9 @@ by default. .TP .B delete\-char\-or\-list Deletes the character under the cursor if not at the beginning or -end of the line (like \fBdelete-char\fP). +end of the line (like \fBdelete\-char\fP). If at the end of the line, behaves identically to -\fBpossible-completions\fP. +\fBpossible\-completions\fP. This command is unbound by default. .TP .B complete\-filename (M\-/) @@ -4568,7 +4745,7 @@ the text against lines from the history list for possible completion matches. .TP .B complete\-into\-braces (M\-{) -Perform filename completion and return the list of possible completions +Perform filename completion and insert the list of possible completions enclosed within braces so the list is available to the shell (see .B Brace Expansion above). @@ -4641,11 +4818,11 @@ A character is read and point is moved to the previous occurrence of that character. A negative count searches for subsequent occurrences. .TP .B insert\-comment (M\-#) -The value of the -.B readline +The value of the readline .B comment\-begin variable is inserted at the beginning of the current line, and the line -is accepted as if a newline had been typed. This makes the current line +is accepted as if a newline had been typed. The default value of +\fBcomment\-begin\fP causes this command to make the current line a shell comment. .TP .B glob\-expand\-word (C\-x *) @@ -4679,6 +4856,129 @@ of an \fIinputrc\fP file. Display version information about the current instance of .BR bash . .PD +.SS Programmable Completion +.PP +When word completion is attempted for an argument to a command for +which a completion specification (a \fIcompspec\fP) has been defined +using the \fBcomplete\fP builtin (see +.SM +.B "SHELL BUILTIN COMMANDS" +below), the programmable completion facilities are invoked. +.PP +First, the command name is identified. +If a compspec has been defined for that command, the +compspec is used to generate the list of possible completions for the word. +If the command word is a full pathname, a compspec for the full +pathname is searched for first. +If no compspec is found for the full pathname, an attempt is made to +find a compspec for the portion following the final slash. +.PP +Once a compspec has been found, it is used to generate the list of +matching words. +If a compspec is not found, the default \fBbash\fP completion as +described above under \fBCompleting\fP is performed. +.PP +First, the actions specified by the compspec are used. +Only matches which are prefixed by the word being completed are +returned. +When the +.B \-f +or +.B \-d +option is used for filename or directory name completion, the shell +variable +.SM +.B FIGNORE +is used to filter the matches. +.PP +Any completions specified by a filename expansion pattern to the +\fB\-G\fP option are generated next. +The words generated by the pattern need not match the word +being completed. +The +.SM +.B GLOBIGNORE +shell variable is not used to filter the matches, but the +.SM +.B FIGNORE +variable is used. +.PP +Next, the string specified as the argument to the \fB\-W\fP option +is considered. +The string is first split using the characters in the +.SM +.B IFS +special variable as delimiters. +Shell quoting is honored. +Each word is then expanded using +brace expansion, tilde expansion, parameter and variable expansion, +command substitution, arithmetic expansion, and pathname expansion, +as described above under +.SM +.BR EXPANSION . +The results are split using the rules described above under +\fBWord Splitting\fP. +The results of the expansion are prefix-matched against the word being +completed, and the matching words become the possible completions. +.PP +After these matches have been generated, any shell function or command +specified with the \fB\-F\fP and \fB\-C\fP options is invoked. +When the command or function is invoked, the +.SM +.B COMP_LINE +and +.SM +.B COMP_POINT +variables are assigned values as described above under +\fBShell Variables\fP. +If a shell function is being invoked, the +.SM +.B COMP_WORDS +and +.SM +.B COMP_CWORD +variables are also set. +When the function or command is invoked, the first argument is the +name of the command whose arguments are being completed, the +second argument is the word being completed, and the third argument +is the word preceding the word being completed on the current command line. +No filtering of the generated completions against the word being completed +is performed; the function or command has complete freedom in generating +the matches. +.PP +Any function specified with \fB\-F\fP is invoked first. +The function may use any of the shell facilities, including the +\fBcompgen\fP builtin described below, to generate the matches. +It must put the possible completions in the +.SM +.B COMPREPLY +array variable. +.PP +Next, any command specified with the \fB\-C\fP option is invoked +in an environment equivalent to command substitution. +It should print a list of completions, one per line, to the +standard output. +Backslash may be used to escape a newline, if necessary. +.PP +After all of the possible completions are generated, any filter +specified with the \fB\-X\fP option is applied to the list. +The filter is a pattern as used for pathname expansion; a \fB&\fP +in the pattern is replaced with the text of the word being completed. +A literal \fB&\fP may be escaped with a backslash; the backslash +is removed before attempting a match. +Any completion that matches the pattern will be removed from the list. +A leading \fB!\fP negates the pattern; in this case any completion +not matching the pattern will be removed. +.PP +Finally, any prefix and suffix specified with the \fB\-P\fP and \fB\-S\fP +options are added to each member of the completion list, and the result is +returned to the readline completion code as the list of possible +completions. +.PP +If a compspec is found, whatever it generates is returned to the completion +code as the full set of possible completions. +The default \fBbash\fP completions are not attempted, and the readline +default of filename completion is disabled. .SH HISTORY When the .B \-o history @@ -4686,10 +4986,13 @@ option to the .B set builtin is enabled, the shell provides access to the \fIcommand history\fP, -the list of commands previously typed. The text of the last +the list of commands previously typed. +The value of the \fBHISTSIZE\fP variable is used as the +number of commands to save in a history list. +The text of the last .SM .B HISTSIZE -commands (default 500) is saved in a history list. The shell +commands (default 500) is saved. The shell stores each command in the history list prior to parameter and variable expansion (see .SM @@ -4701,23 +5004,25 @@ values of the shell variables and .SM .BR HISTCONTROL . +.PP On startup, the history is initialized from the file named by the variable .SM .B HISTFILE (default \fI~/.bash_history\fP). +The file named by the value of .SM .B HISTFILE is truncated, if necessary, to contain no more than +the number of lines specified by the value of .SM -.B HISTFILESIZE -lines. +.BR HISTFILESIZE . When an interactive shell exits, the last .SM -.B HISTSIZE +.B $HISTSIZE lines are copied from the history list to .SM -.BR HISTFILE . +.BR $HISTFILE . If the .B histappend shell option is enabled @@ -4750,9 +5055,9 @@ below) may be used to list or edit and re-execute a portion of the history list. The .B history -builtin can be used to display or modify the history list and +builtin may be used to display or modify the history list and manipulate the history file. -When using the command-line editing, search commands +When using command-line editing, search commands are available in each editing mode that provide access to the history list. .PP @@ -5125,6 +5430,8 @@ job control. .TP \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-f\fP \fIfilename\fP .TP +\fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-x\fP \fIkeyseq\fP:\fIshell\-command\fP +.TP \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fIkeyseq\fP:\fIfunction\-name\fP .PD Display current @@ -5188,6 +5495,10 @@ Unbind all keys bound to the named \fIfunction\fP. .TP .B \-r \fIkeyseq\fP Remove any current binding for \fIkeyseq\fP. +.TP +.B \-x \fIkeyseq\fP:\fIshell\-command\fP +Cause \fIshell\-command\fP to be executed whenever \fIkeyseq\fP is +entered. .PD .PP The return value is 0 unless an unrecognized option is given or an @@ -5308,6 +5619,176 @@ cannot be found, the exit status is 127. Otherwise, the exit status of the builtin is the exit status of .IR command . .TP +\fBcompgen\fP [\fIoption\fP] [\fIword\fP] +Generate possible completion matches for \fIword\fP according to +the \fIoption\fPs, which may be any option accepted by the +.B complete +builtin with the exception of \fB\-p\fP and \fB\-r\fP, and write +the matches to the standard output. +When using the \fB\-F\fP or \fB\-C\fP options, the various shell variables +set by the programmable completion facilities, while available, will not +have useful values. +.sp 1 +The matches will be generated in the same way as if the programmable +completion code had generated them directly from a completion specification +with the same flags. +If \fIword\fP is specified, only those completions matching \fIword\fP +will be displayed. +.sp 1 +The return value is true unless an invalid option is supplied, or no +matches were generated. +.TP +.PD 0 +\fBcomplete\fP [\fB\-abcdefjkvu\fP] [\fB\-A\fP \fIaction\fP] [\fB\-G\fP \fIglobpat\fP] [\fB\-W\fP \fIwordlist\fP] [\fB\-P\fP \fIprefix\fP] [\fB\-S\fP \fIsuffix\fP] +.br +[\fB\-X\fP \fIfilterpat\fP] [\fB\-F\fP \fIfunction\fP] [\fB\-C\fP \fIcommand\fP] \fIname\fP [\fIname ...\fP] +.TP +\fBcomplete\fP \fB\-pr\fP [\fIname\fP ...] +.PD +Specify how arguments to each \fIname\fP should be completed. +If the \fB\-p\fP option is supplied, or if no options are supplied, +existing completion specifications are printed in a way that allows +them to be reused as input. +The \fB\-r\fP option removes a completion specification for +each \fIname\fP, or, if no \fIname\fPs are supplied, all +completion specifications. +.sp 1 +The process of applying these completion specifications when word completion +is attempted is described above under \fBProgrammable Completion\fP. +.sp 1 +Other options, if specified, have the following meanings. +The arguments to the \fB\-G\fP, \fB\-W\fP, and \fB\-X\fP options +(and, if necessary, the \fB\-P\fP and \fB\-S\fP options) +should be quoted to protect them from expansion before the +.B complete +builtin is invoked. +.RS +.PD 0 +.TP 8 +\fB\-A\fP \fIaction\fP +The \fIaction\fP may be one of the following to generate a list of possible +completions: +.RS +.TP 8 +.B alias +Alias names. May also be specified as \fB\-a\fP. +.TP 8 +.B arrayvar +Array variable names. +.TP 8 +.B binding +\fBReadline\fP key binding names. +.TP 8 +.B builtin +Names of shell builtin commands. May also be specified as \fB\-b\fP. +.TP 8 +.B command +Command names. May also be specified as \fB\-c\fP. +.TP 8 +.B directory +Directory names. May also be specified as \fB\-d\fP. +.TP 8 +.B disabled +Names of disabled shell builtins. +.TP 8 +.B enabled +Names of enabled shell builtins. +.TP 8 +.B export +Names of exported shell variables. May also be specified as \fB\-e\fP. +.TP 8 +.B file +File names. May also be specified as \fB\-f\fP. +.TP 8 +.B function +Names of shell functions. +.TP 8 +.B helptopic +Help topics as accepted by the \fBhelp\fP builtin. +.TP 8 +.B hostname +Hostnames, as taken from the file specified by the +.SM +.B HOSTFILE +shell variable. +.TP 8 +.B job +Job names, if job control is active. May also be specified as \fB\-j\fP. +.TP 8 +.B keyword +Shell reserved words. May also be specified as \fB\-k\fP. +.TP 8 +.B running +Names of running jobs, if job control is active. +.TP 8 +.B setopt +Valid arguments for the \fB\-o\fP option to the \fBset\fP builtin. +.TP 8 +.B shopt +Shell option names as accepted by the \fBshopt\fP builtin. +.TP 8 +.B signal +Signal names. +.TP 8 +.B stopped +Names of stopped jobs, if job control is active. +.TP 8 +.B user +User names. May also be specified as \fB\-u\fP. +.TP 8 +.B variable +Names of all shell variables. May also be specified as \fB\-v\fP. +.RE +.TP 8 +\fB\-G\fP \fIglobpat\fP +The filename expansion pattern \fIglobpat\fP is expanded to generate +the possible completions. +.TP 8 +\fB\-W\fP \fIwordlist\fP +The \fIwordlist\fP is split using the characters in the +.SM +.B IFS +special variable as delimiters, and each resultant word is expanded. +The possible completions are the members of the resultant list which +match the word being completed. +.TP 8 +\fB\-C\fP \fIcommand\fP +\fIcommand\fP is executed in a subshell environment, and its output is +used as the possible completions. +.TP 8 +\fB\-F\fP \fIfunction\fP +The shell function \fIfunction\fP is executed in the current shell +environment. +When it finishes, the possible completions are retrieved from the value +of the +.SM +.B COMPREPLY +array variable. +.TP 8 +\fB\-X\fP \fIfilterpat\fP +\fIfilterpat\fP is a pattern as used for filename expansion. +It is applied to the list of possible completions generated by the +preceding options and arguments, and each completion matching +\fIfilterpat\fP is removed from the list. +A leading \fB!\fP in \fIfilterpat\fP negates the pattern; in this +case, any completion not matching \fIfilterpat\fP is removed. +.TP 8 +\fB\-P\fP \fIprefix\fP +\fIprefix\fP is added at the beginning of each possible completion +after all other options have been applied. +.TP 8 +\fB\-S\fP \fIsuffix\fP +\fIsuffix\fP is appended to each possible completion +after all other options have been applied. +.PD +.PP +The return value is true unless an invalid option is supplied, an option +other than \fB\-p\fP or \fB\-r\fP is supplied without a \fIname\fP +argument, an attempt is made to remove a completion specification for +a \fIname\fP for which no specification exists, or +an error occurs adding a completion specification. +.RE +.TP \fBcontinue\fP [\fIn\fP] Resume the next iteration of the enclosing .BR for , @@ -5385,7 +5866,9 @@ makes each \fIname\fP local, as with the .B local command. The return value is 0 unless an invalid option is encountered, -an attempt is made to define a function using "\-f foo=bar", +an attempt is made to define a function using +.if n ``\-f foo=bar'', +.if t \f(CW\-f foo=bar\fP, an attempt is made to assign a value to a readonly variable, an attempt is made to assign a value to an array variable without using the compound assignment syntax (see @@ -5393,7 +5876,7 @@ using the compound assignment syntax (see above), one of the \fInames\fP is not a valid shell variable name, an attempt is made to turn off readonly status for a readonly variable, an attempt is made to turn off array status for an array variable, -or an attempt is made to display a non-existent function with \-f. +or an attempt is made to display a non-existent function with \fB\-f\fP. .RE .TP .B dirs [\fB\-clpv\fP] [+\fIn\fP] [\-\fIn\fP] @@ -5481,6 +5964,9 @@ the following backslash-escaped characters is enabled. The .B \-E option disables the interpretation of these escape characters, even on systems where they are interpreted by default. +The \fBxpg_echo\fP shell option to the may be used to +dynamically determine whether or not \fBecho\fP expands these +escape characters by default. .B echo does not interpret .B \-\- @@ -5533,7 +6019,7 @@ the character whose ASCII code is the hexadecimal value \fInnn\fP \fBenable\fP [\fB\-adnps\fP] [\fB\-f\fP \fIfilename\fP] [\fIname\fP ...] Enable and disable builtin shell commands. Disabling a builtin allows a disk command which has the same name -as a shell builtin to be executed with specifying a full pathname, +as a shell builtin to be executed without specifying a full pathname, even though the shell normally searches for builtins before disk commands. If \fB\-n\fP is used, each \fIname\fP is disabled; otherwise, @@ -5566,7 +6052,7 @@ If \fB\-s\fP is supplied, the output is restricted to the POSIX \fIspecial\fP builtins. The return value is 0 unless a .I name -is not a shell builtin or there is a problem loading a new builtin +is not a shell builtin or there is an error loading a new builtin from a shared object. .TP \fBeval\fP [\fIarg\fP ...] @@ -5590,7 +6076,7 @@ become the arguments to \fIcommand\fP. If the .B \-l option is supplied, -the shell places a dash in the zeroth arg passed to +the shell places a dash at the beginning of the zeroth arg passed to .IR command . This is what .IR login (1) @@ -5679,7 +6165,8 @@ command number). If .I last is not specified it is set to the current command for listing (so that -.B fc \-l \-10 +.if n ``fc \-l \-10'' +.if t \f(CWfc \-l \-10\fP prints the last 10 commands) and to .I first otherwise. @@ -5771,9 +6258,11 @@ specifies a job that was started without job control. .B getopts is used by shell procedures to parse positional parameters. .I optstring -contains the option letters to be recognized; if a letter +contains the option characters to be recognized; if a character is followed by a colon, the option is expected to have an argument, which should be separated from it by white space. +The colon and question mark characters may not be used as +option characters. Each time it is invoked, .B getopts places the next option in the shell variable @@ -5888,7 +6377,7 @@ The return status is true unless a .I name is not found or an invalid option is supplied. .TP -\fBhelp\fP [\fIpattern\fP] +\fBhelp\fP [\fB\-s\fP] [\fIpattern\fP] Display helpful information about builtin commands. If .I pattern is specified, @@ -5896,11 +6385,18 @@ is specified, gives detailed help on all commands matching .IR pattern ; otherwise help for all the builtins and shell control structures -is printed. The return status is 0 unless no command matches +is printed. +The \fB\-s\fP option restricts the information displayed to a short +usage synopsis. +The return status is 0 unless no command matches .IR pattern . .TP .PD 0 -\fBhistory\fP [\fB\-c\fP] [\fIn\fP] +\fBhistory [\fIn\fP] +.TP +\fBhistory\fP \fB\-c\fP +.TP +\fBhistory \-d\fP \fIoffset\fP .TP \fBhistory\fP \fB\-anrw\fP [\fIfilename\fP] .TP @@ -5924,6 +6420,12 @@ is used. Options, if supplied, have the following meanings: .RS .PD 0 .TP +.B \-c +Clear the history list by deleting all the entries. +.TP +\fB\-d\fP \fIoffset\fP +Delete the history entry at position \fIoffset\fP. +.TP .B \-a Append the ``new'' history lines (history lines entered since the beginning of the current \fBbash\fP session) to the history file. @@ -5942,9 +6444,6 @@ and use them as the current history. Write the current history to the history file, overwriting the history file's contents. .TP -.B \-c -Clear the history list by deleting all the entries. -.TP .B \-p Perform history substitution on the following \fIargs\fP and display the result on the standard output. @@ -5960,8 +6459,10 @@ history list is removed before the are added. .PD .PP -The return value is 0 unless an invalid option is encountered or an -error occurs while reading or writing the history file. +The return value is 0 unless an invalid option is encountered, an +error occurs while reading or writing the history file, an invalid +\fIoffset\fP is supplied as an argument to \fB\-d\fP, or the +history expansion supplied as an argument to \fB\-p\fP fails. .RE .TP .PD 0 @@ -6077,11 +6578,12 @@ evaluates to 0, .B let returns 1; 0 is returned otherwise. .TP -\fBlocal\fP [\fIname\fP[=\fIvalue\fP] ...] +\fBlocal\fP [\fIoption\fP] [\fIname\fP[=\fIvalue\fP] ...] For each argument, a local variable named .I name is created, and assigned .IR value . +The \fIoption\fP can be any of the options accepted by \fBdeclare\fP. When .B local is used within a function, it causes the variable @@ -6094,9 +6596,10 @@ an error to use .B local when not within a function. The return status is 0 unless .B local -is used outside a function, or an invalid +is used outside a function, an invalid .I name -is supplied. +is supplied, or +\fIname\fP is a readonly variable. .TP .B logout Exit a login shell. @@ -6114,15 +6617,25 @@ Arguments, if supplied, have the following meanings: Removes the \fIn\fPth entry counting from the left of the list shown by .BR dirs , -starting with zero. For example: ``popd +0'' -removes the first directory, ``popd +1'' the second. +starting with zero. For example: +.if n ``popd +0'' +.if t \f(CWpopd +0\fP +removes the first directory, +.if n ``popd +1'' +.if t \f(CWpopd +1\fP +the second. .TP \fB\-\fP\fIn\fP Removes the \fIn\fPth entry counting from the right of the list shown by .BR dirs , -starting with zero. For example: ``popd -0'' -removes the last directory, ``popd -1'' the next to last. +starting with zero. For example: +.if n ``popd -0'' +.if t \f(CWpopd -0\fP +removes the last directory, +.if n ``popd -1'' +.if t \f(CWpopd -1\fP +the next to last. .TP .B \-n Suppresses the normal change of directory when removing directories @@ -6156,7 +6669,8 @@ In addition to the standard \fIprintf\fP(1) formats, %b causes The \fIformat\fP is reused as necessary to consume all of the \fIarguments\fP. If the \fIformat\fP requires more \fIarguments\fP than are supplied, the extra format specifications behave as if a zero value or null string, as -appropriate, had been supplied. +appropriate, had been supplied. The return value is zero on success, +non-zero on failure. .TP .PD 0 \fBpushd\fP [\fB\-n\fP] [\fIdir\fP] @@ -6188,7 +6702,7 @@ starting with zero) is at the top. Suppresses the normal change of directory when adding directories to the stack, so that only the stack is manipulated. .TP -.B dir +.I dir Adds .I dir to the directory stack at the top, making it the @@ -6213,8 +6727,8 @@ fails. .RE .TP \fBpwd\fP [\fB\-LP\fP] -Print the absolute file name of the current working directory. -The file name printed contains no symbolic links if the +Print the absolute pathname of the current working directory. +The pathname printed contains no symbolic links if the .B \-P option is supplied or the .B \-o physical @@ -6223,12 +6737,12 @@ option to the builtin command is enabled. If the .B \-L -option is used, symbolic links are followed. +option is used, the pathname printed may contain symbolic links. The return status is 0 unless an error occurs while reading the name of the current directory or an invalid option is supplied. .TP -\fBread\fP [\fB\-er\fP] [\fB\-a\fP \fIaname\fP] [\fB\-p\fP \fIprompt\fP] [\fIname\fP ...] +\fBread\fP [\fB\-ers\fP] [\fB\-t\fP \fItimeout\fP] [\fB\-a\fP \fIaname\fP] [\fB\-p\fP \fIprompt\fP] [\fB\-n\fP \fInchars\fP] [\fB\-d\fP \fIdelim\fP] [\fIname\fP ...] One line is read from the standard input, and the first word is assigned to the first .IR name , @@ -6249,18 +6763,7 @@ Options, if supplied, have the following meanings: .RS .PD 0 .TP -.B \-r -Backslash does not act as an escape character. -The backslash is considered to be part of the line. -In particular, a backslash-newline pair may not be used as a line -continuation. -.TP -.B \-p -Display \fIprompt\fP, without a -trailing newline, before attempting to read any input. The prompt -is displayed only if input is coming from a terminal. -.TP -.B \-a +.B \-a \fIaname\fP The words are assigned to sequential indices of the array variable .IR aname , @@ -6269,6 +6772,10 @@ starting at 0. is unset before any new values are assigned. Other \fIname\fP arguments are ignored. .TP +.B \-d \fIdelim\fP +The first character of \fIdelim\fP is used to terminate the input line, +rather than newline. +.TP .B \-e If the standard input is coming from a terminal, @@ -6277,6 +6784,31 @@ is coming from a terminal, .SM .B READLINE above) is used to obtain the line. +.TP +.B \-n \fInchars\fP +\fBread\fP returns after reading \fInchars\fP characters rather than +waiting for a complete line of input. +.TP +.B \-p \fIprompt\fP +Display \fIprompt\fP, without a +trailing newline, before attempting to read any input. The prompt +is displayed only if input is coming from a terminal. +.TP +.B \-r +Backslash does not act as an escape character. +The backslash is considered to be part of the line. +In particular, a backslash-newline pair may not be used as a line +continuation. +.TP +.B \-s +Silent mode. If input is coming from a terminal, characters are +not echoed. +.TP +.B \-t \fItimeout\fP +Cause \fBread\fP to time out and return failure if a complete line of +input is not read within \fItimeout\fP seconds. +This option has no effect if \fBread\fP is not reading input from the +terminal or a pipe. .PD .PP If no @@ -6284,7 +6816,8 @@ If no are supplied, the line read is assigned to the variable .SM .BR REPLY . -The return code is zero, unless end-of-file is encountered. +The return code is zero, unless end-of-file is encountered or \fBread\fP +times out. .RE .TP \fBreadonly\fP [\fB\-apf\fP] [\fIname\fP ...] @@ -6308,7 +6841,8 @@ arguments are given, or if the option is supplied, a list of all readonly names is printed. The .B \-p -option causes output to be displayed in a format thatmay be reused as input. +option causes output to be displayed in a format that +may be reused as input. The return status is 0 unless an invalid option is encountered, one of the .I names @@ -6523,12 +7057,16 @@ the standard output. Turn on .I privileged mode. In this mode, the +.SM .B $ENV and +.SM .B $BASH_ENV files are not processed, shell functions are not inherited from the -environment, and the \fBSHELLOPTS\fP variable, if it appears in the -environment, is ignored. +environment, and the +.SM +.B SHELLOPTS +variable, if it appears in the environment, is ignored. If the shell is started with the effective user (group) id not equal to the real user (group) id, and the \fB\-p\fP option is not supplied, these actions are taken and the effective user id is set to the real user id. @@ -6812,6 +7350,14 @@ If set, and a file that \fBbash\fP is checking for mail has been accessed since the last time it was checked, the message ``The mail in \fImailfile\fP has been read'' is displayed. .TP 8 +.B no_empty_cmd_completion +If set, and +.B readline +is being used, +.B bash +will not attempt to search the \fBPATH\fP for possible completions when +completion is attempted on an empty line. +.TP 8 .B nocaseglob If set, .B bash @@ -6829,6 +7375,11 @@ files (see above) to expand to a null string, rather than themselves. .TP 8 +.B progcomp +If set, the programmable completion facilities (see +\fBProgrammable Completion\fP above) are enabled. +This option is enabled by default. +.TP 8 .B promptvars If set, prompt strings undergo variable and parameter expansion after being expanded as described in @@ -6858,6 +7409,10 @@ If set, the .B PATH to find the directory containing the file supplied as an argument. This option is enabled by default. +.TP 8 +.B xpg_echo +If set, the \fBecho\fP builtin expands backslash-escape sequences +by default. .RE .TP \fBsuspend\fP [\fB\-f\fP] @@ -6989,13 +7544,12 @@ is the null string the signal specified by each is ignored by the shell and by the commands it invokes. If .I arg -is +is not present and .B \-p -then the trap commands associated with -each +has been supplied, then the trap commands associated with each .I sigspec -are displayed. If no arguments are supplied or if -only +are displayed. +If no arguments are supplied or if only .B \-p is given, .B trap @@ -7188,10 +7742,7 @@ to that accepted by .IR chmod (1). If .I mode -is omitted, or if the -.B \-S -option is supplied, the -current value of the mask is printed. +is omitted, the current value of the mask is printed. The .B \-S option causes the mask to be printed in symbolic form; the @@ -7205,7 +7756,7 @@ The return status is 0 if the mode was successfully changed or if no \fImode\fP argument was supplied, and false otherwise. .TP \fBunalias\fP [\-\fBa\fP] [\fIname\fP ...] -Remove \fIname\fPs from the list of defined aliases. If +Remove each \fIname\fP from the list of defined aliases. If .B \-a is supplied, all alias definitions are removed. The return value is true unless a supplied @@ -7240,6 +7791,10 @@ If any of .BR LINENO , .SM .BR HISTCMD , +.SM +.BR FUNCNAME , +.SM +.BR GROUPS , or .SM .B DIRSTACK @@ -7265,6 +7820,8 @@ process or job waited for. .\" bash_builtins .if \n(zZ=1 .ig zZ .SH "RESTRICTED SHELL" +.\" rbash.1 +.zY .PP If .B bash @@ -7298,6 +7855,12 @@ as an argument to the .B . builtin command .IP \(bu +Specifying a filename containing a slash as an argument to the +.B \-p +option to the +.B hash +builtin command +.IP \(bu importing function definitions from the shell environment at startup .IP \(bu parsing the value of \fBSHELLOPTS\fP from the shell environment at startup @@ -7334,10 +7897,12 @@ above), .B rbash turns off any restrictions in the shell spawned to execute the script. +.\" end of rbash.1 +.if \n(zY=1 .ig zY .SH "SEE ALSO" .PD 0 .TP -\fIBash Features\fP, Brian Fox and Chet Ramey +\fIBash Reference Manual\fP, Brian Fox and Chet Ramey .TP \fIThe Gnu Readline Library\fP, Brian Fox and Chet Ramey .TP @@ -7375,7 +7940,7 @@ Individual \fIreadline\fP initialization file .SH AUTHORS Brian Fox, Free Software Foundation .br -bfox@gnu.ai.MIT.Edu +bfox@gnu.org .PP Chet Ramey, Case Western Reserve University .br @@ -7451,3 +8016,4 @@ reporting until some time after the command is entered. .PP Array variables may not (yet) be exported. .zZ +.zY |