.\" Case Western Reserve University
.\" chet@ins.CWRU.Edu
.\"
-.\" Last Change: Fri May 5 10:44:39 EDT 1995
+.\" Last Change: Mon Nov 25 15:36:20 EST 1996
.\"
.\" bash_builtins, strip all but Built-Ins section
.if \n(zZ=1 .ig zZ
-.TH BASH 1 "1995 May 5" GNU
+.TH BASH 1 "1996 Nov 25" GNU
.\"
.\" There's some problem with having a `@'
.\" in a tagged paragraph with the BSD man macros.
\fI\|\\$1\|\fP
..
.SH NAME
-bash \- GNU Bourne\-Again SHell
+bash \- GNU Bourne-Again SHell
.SH SYNOPSIS
.B bash
[options]
[file]
.SH COPYRIGHT
-.if n Bash is Copyright (C) 1989, 1991 by the Free Software Foundation, Inc.
-.if t Bash is Copyright \(co 1989, 1991 by the Free Software Foundation, Inc.
+.if n Bash is Copyright (C) 1989, 1991, 1993, 1995, 1996 by the Free Software Foundation, Inc.
+.if t Bash is Copyright \(co 1989, 1991, 1993, 1995, 1996 by the Free Software Foundation, Inc.
.SH DESCRIPTION
.B Bash
-is an \fBsh\fR\-compatible command language interpreter that
+is an \fBsh\fR-compatible command language interpreter that
executes commands read from the standard input or from a file.
.B Bash
also incorporates useful features from the \fIKorn\fP and \fIC\fP
.PP
.B Bash
is ultimately intended to be a conformant implementation of the IEEE
-Posix Shell and Tools specification (IEEE Working Group 1003\.2).
+POSIX Shell and Tools specification (IEEE Working Group 1003\.2).
.SH OPTIONS
-In addition to the single\-character shell options documented in the
+In addition to the single-character shell options documented in the
description of the \fBset\fR builtin command, \fBbash\fR
interprets the following flags when it is invoked:
.PP
.PD 0
.TP 10
.BI \-c "\| string\^"
-If the
+If the
.B \-c
flag is present, then commands are read from
.IR string .
they are assigned to the positional parameters, starting with
.BR $0 .
.TP
+.B \-r
+If the
+.B \-r
+flag is present, the shell becomes
+.I restricted
+(see
+.SM
+.B "RESTRICTED SHELL"
+below).
+.TP
.B \-i
If the
.B \-i
This option allows the positional parameters to be set
when invoking an interactive shell.
.TP
-.B \-
-A single
-.B \-
+.B \-D
+A list of all double-quoted strings preceded by \fB$\fP
+is printed on the standard ouput.
+These are the strings that
+are subject to language translation when the current locale
+is not C or POSIX.
+This implies the \fB\-n\fP option; no commands will be executed.
+.TP
+.B \-\-
+A
+.B \-\-
signals the end of options and disables further option processing.
Any arguments after the
-.B \-
-are treated as filenames and arguments. An argument of
.B \-\-
-is equivalent to an argument of \fB\-\fP.
+are treated as filenames and arguments. An argument of
+.B \-
+is equivalent to \fB\-\-\fP.
.PD
.PP
.B Bash
-also interprets a number of multi\-character options. These options must
-appear on the command line before the single\-character options to be
-recognized.
+also interprets a number of multi-character options.
+These options must appear on the command line before the
+single-character options in order for them to be recognized.
.PP
.PD 0
-.TP 10
-.B \-norc
-Do not read and execute the personal initialization file
-.I ~/.bashrc
-if the shell is interactive.
-This option is on by default if the shell is invoked as
-.BR sh .
.TP
-.B \-noprofile
-Do not read either the system\-wide startup file
+.B \-\-dump\-strings
+Equivalent to \fB\-D\fP.
+.TP
+.B \-\-help
+Display a usage message on standard output and exit successfully.
+.TP
+.B \-\-login
+Make
+.B bash
+act as if it had been invoked as a login shell (see
+.SM
+.B INVOCATION
+below).
+.TP
+.B \-\-noediting
+Do not use the GNU
+.B readline
+library to read command lines if interactive.
+.TP
+.B \-\-noprofile
+Do not read either the system-wide startup file
.FN /etc/profile
or any of the personal initialization files
.IR ~/.bash_profile ,
.IR ~/.profile .
By default,
.B bash
-normally reads these files when it is invoked as a login shell (see
+reads these files when it is invoked as a login shell (see
.SM
.B INVOCATION
below).
.TP
-\fB\-rcfile\fP \fIfile\fP
+.B \-\-norc
+Do not read and execute the personal initialization file
+.I ~/.bashrc
+if the shell is interactive.
+This option is on by default if the shell is invoked as
+.BR sh .
+.TP
+.B \-\-posix
+Change the behavior of \fBbash\fP where the default operation differs
+from the POSIX 1003.2 standard to match the standard.
+.TP
+\fB\-\-rcfile\fP \fIfile\fP
Execute commands from
.I file
instead of the standard personal initialization file
-.IR ~/.bashrc ,
+.I ~/.bashrc
if the shell is interactive (see
.SM
.B INVOCATION
below).
.TP
-.B \-version
-Show the version number of this instance of
-.B bash
-when starting.
-.TP
-.B \-quiet
-Do not be verbose when starting up (do not show the shell version or any
-other information). This is the default.
-.TP
-.B \-login
-Make
-.B bash
-act as if it had been invoked as a login shell.
-.TP
-.B \-nobraceexpansion
-Do not perform curly brace expansion (see
-.B Brace Expansion
+.B \-\-restricted
+The shell becomes restricted (see
+.SM
+.B "RESTRICTED SHELL"
below).
.TP
-.B \-nolineediting
-Do not use the GNU
-.I readline
-library to read command lines if interactive.
+.B \-\-verbose
+Equivalent to \fB\-v\fP.
.TP
-.B \-posix
-Change the behavior of bash where the default operation differs
-from the Posix 1003.2 standard to match the standard
+.B \-\-version
+Show version information for this instance of
+.B bash
+on the standard output and exit successfully.
.PD
.SH ARGUMENTS
If arguments remain after option processing, and neither the
nor the
.B \-s
option has been supplied, the first argument is assumed to
-be the name of a file containing shell commands. If
+be the name of a file containing shell commands.
+If
.B bash
is invoked in this fashion,
.B $0
are set to the remaining arguments.
.B Bash
reads and executes commands from this file, then exits.
-.B Bash's
-exit status is the exit status of the last command executed
-in the script.
+\fBBash\fP's exit status is the exit status of the last command
+executed in the script.
+If no commands are executed, the exit status is 0.
+.SH INVOCATION
+A \fIlogin shell\fP is one whose first character of argument zero is a
+.BR \- ,
+or one started with the
+.B \-\-login
+option.
+.PP
+An \fIinteractive\fP shell is one whose standard input and output are
+both connected to terminals (as determined by
+.IR isatty (3)),
+or one started with the
+.B \-i
+option.
+.SM
+.B PS1
+is set and
+.B $\-
+includes
+.B i
+if
+.B bash
+is interactive,
+allowing a shell script or a startup file to test this state.
+.PP
+The following paragraphs describe how
+.B bash
+executes its startup files.
+If any of the files exist but cannot be read,
+.B bash
+reports an error.
+Tildes are expanded in file names as described below under
+.B "Tilde Expansion"
+in the
+.SM
+.B EXPANSION
+section.
+.PP
+When
+.B bash
+is invoked as a login shell, it first reads and executes commands
+from the file \fI/etc/profile\fP, if that file exists.
+After reading that file, it looks for \fI~/.bash_profile\fP,
+\fI~/.bash_login\fP, and \fI~/.profile\fP, in that order, and reads
+and executes commands from the first one that exists and is readable.
+The
+.B \-\-noprofile
+option may be used when the shell is started to inhibit this behavior.
+.PP
+When a login shell exits,
+.B bash
+reads and executes commands from the file \fI~/.bash_logout\fP, if it
+exists.
+.PP
+When an interactive shell that is not a login shell is started,
+.B bash
+reads and executes commands from \fI~/.bashrc\fP, if that file exists.
+This may be inhibited by using the
+.B \-\-norc
+option.
+The \fB\-\-rcfile\fP \fIfile\fP option will force
+.B bash
+to read and execute commands from \fIfile\fP instead of \fI~/.bashrc\fP.
+.PP
+When
+.B bash
+is started non-interactively, to run a shell script, for example, it
+looks for the variable
+.SM
+.B BASH_ENV
+in the environment, expands its value if it appears there, and uses the
+expanded value as the name of a file to read and execute.
+.B Bash
+behaves as if the following command were executed:
+.sp .5
+.RS
+\f(CWif [ \-n "$BASH_ENV" ]; then . "$BASH_ENV"; fi\fP
+.RE
+.sp .5
+but the value of the
+.SM
+.B PATH
+variable is not used to search for the file name.
+.PP
+If
+.B bash
+is invoked with the name
+.BR sh ,
+it tries to mimic the startup behavior of historical versions of
+.B sh
+as closely as possible,
+while conforming to the POSIX standard as well.
+When invoked as a login shell, it first attempts to read and execute
+commands from
+.I /etc/profile
+and
+.IR ~/.profile ,
+in that order.
+The
+.B \-\-noprofile
+option may be used to inhibit this behavior.
+When invoked as an interactive shell with the name
+.BR sh ,
+.B bash
+looks for the variable
+.SM
+.BR ENV ,
+expands its value if it is defined, and uses the
+expanded value as the name of a file to read and execute.
+Since a shell invoked as
+.B sh
+does not attempt to read and execute commands from any other startup
+files, the
+.B \-\-rcfile
+option has no effect.
+A non-interactive shell invoked with the name
+.B sh
+does not attempt to read any startup files.
+When invoked as
+.BR sh ,
+.B bash
+enters
+.I posix
+mode after the startup files are read.
+.PP
+When
+.B bash
+is started in
+.I posix
+mode, as with the
+.B \-\-posix
+command line option, it follows the POSIX standard for startup files.
+In this mode, the
+.SM
+.B ENV
+variable is expanded and commands are read and executed from the file
+whose name is the expanded value.
+No other startup files are read.
+This is done by interactive shells only.
+.PP
+.B Bash
+attempts to determine when it is being run by the remote shell
+daemon, usually \fIrshd\fP.
+If
+.B bash
+determines it is being run by \fIrshd\fP, it reads and executes
+commands from \fI~/.bashrc\fP, if that file exists and is readable.
+It will not do this if invoked as \fBsh\fP.
+The
+.B \-\-norc
+option may be used to inhibit this behavior, and the
+.B \-\-rcfile
+option may be used to force another file to be read, but
+\fIrshd\fP does not generally invoke the shell with those options
+or allow them to be specified.
.SH DEFINITIONS
+.PP
+The following definitions are used throughout the rest of this
+document.
.PD 0
.TP
.B blank
symbols:
.RS
.PP
-.if t \fB\(bv\|\(bv & && ; ;; ( ) | <newline>\fP
+.if t \fB\(bv\(bv & && ; ;; ( ) | <newline>\fP
.if n \fB|| & && ; ;; ( ) | <newline>\fP
.RE
.PD
.if t .RS
.PP
.B
-.if n ! case do done elif else esac fi for function if in select then until while { }
-.if t ! case do done elif else esac fi for function if in select then until while { }
+.if n ! case do done elif else esac fi for function if in select then until while { } time
+.if t ! case do done elif else esac fi for function if in select then until while { } time
.if t .RE
.RE
.SH "SHELL GRAMMAR"
.SS Simple Commands
.PP
A \fIsimple command\fP is a sequence of optional variable assignments
-followed by \fIblank\fP\-separated words and redirections, and
+followed by \fBblank\fP-separated words and redirections, and
terminated by a \fIcontrol operator\fP. The first word
specifies the command to be executed. The remaining words are
passed as arguments to the invoked command.
The format for a pipeline is:
.RS
.PP
-[ ! ] \fIcommand\fP [ \fB|\fP \fIcommand2\fP ... ]
+[\fBtime\fP [\fB\-p\fP]] [ ! ] \fIcommand\fP [ \fB|\fP \fIcommand2\fP ... ]
.RE
.PP
The standard output of
precedes a pipeline, the exit status of that
pipeline is the logical NOT of the exit status of the last command.
Otherwise, the status of the pipeline is the exit status of the last
-command. The shell waits for all commands in the pipeline to
+command.
+The shell waits for all commands in the pipeline to
terminate before returning a value.
.PP
+If the
+.B time
+reserved word precedes a pipeline, the elapsed as well as user and
+system time consumed by its execution are reported when the pipeline
+terminates.
+The \fB\-p\fP option changes the output format to that specified by POSIX.
+The
+.SM
+.B TIMEFORMAT
+variable may be set to a format string that specifies how the timing
+information should be displayed; see the description of
+.SM
+.B TIMEFORMAT
+under
+.B "Shell Variables"
+below.
+.PP
Each command in a pipeline is executed as a separate process (i.e., in a
subshell).
.SS Lists
.BR & ,
.BR && ,
or
-.BR \(bv\|\(bv ,
-and terminated by one of
+.BR \(bv\(bv ,
+and optionally terminated by one of
.BR ; ,
.BR & ,
or
Of these list operators,
.B &&
and
-.B \(bv\|\(bv
+.B \(bv\(bv
have equal precedence, followed by
.B ;
and
The control operators
.B &&
and
-.B \(bv\|\(bv
+.B \(bv\(bv
denote AND lists and OR lists, respectively.
An AND list has the form
.RS
An OR list has the form
.RS
.PP
-\fIcommand\fP \fB\(bv\|\(bv\fP \fIcommand2\fP
+\fIcommand\fP \fB\(bv\(bv\fP \fIcommand2\fP
.PP
.RE
.PP
.I command2
is executed if and only if
.I command
-returns a non\-zero exit status. The return status of
+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.
.SS Compound Commands
\fIlist\fP.
.TP
{ \fIlist\fP; }
-\fIlist\fP is simply executed in the current shell environment. This is
-known as a \fIgroup command\fP. The return status is the exit status of
+\fIlist\fP is simply executed in the current shell environment.
+\fIlist\fP must be terminated with a newline or semicolon.
+This is known as a \fIgroup command\fP.
+The return status is the exit status of
\fIlist\fP.
.TP
+((\fIexpression\fP))
+The \fIexpression\fP is evaluated according to the rules described
+below under
+.SM
+.BR "ARITHMETIC EVALUATION" .
+If the value of the expression is non-zero, the return status is 0;
+otherwise the return status is 1. This is exactly equivalent to
+\fBlet "\fIexpression\fP"\fR.
+.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
below). The
.B PS3
prompt is then displayed and a line read from the standard input.
-If the line consists of the number corresponding to one of
+If the line consists of a number corresponding to one of
the displayed words, then the value of
.I name
is set to that word. If the line is empty, the words and prompt
below). When a match is found, the
corresponding \fIlist\fP is executed. After the first match, no
subsequent matches are attempted. The exit status is zero if no
-patterns are matches. Otherwise, it is the exit status of the
+pattern matches. Otherwise, it is the exit status of the
last command executed in \fIlist\fP.
.TP
-\fBif\fP \fIlist\fP \fBthen\fP \fIlist\fP \
-[ \fBelif\fP \fIlist\fP \fBthen\fP \fIlist\fP ] ... \
-[ \fBelse\fP \fIlist\fP ] \fBfi\fP
+\fBif\fP \fIlist\fP; \fBthen\fP \fIlist;\fP \
+[ \fBelif\fP \fIlist\fP; \fBthen\fP \fIlist\fP; ] ... \
+[ \fBelse\fP \fIlist\fP; ] \fBfi\fP
The
.B if
.I list
last command executed, or zero if no condition tested true.
.TP
.PD 0
-\fBwhile\fP \fIlist\fP \fBdo\fP \fIlist\fP \fBdone\fP
+\fBwhile\fP \fIlist\fP; \fBdo\fP \fIlist\fP; \fBdone\fP
.TP
-\fBuntil\fP \fIlist\fP \fBdo\fP \fIlist\fP \fBdone\fP
+\fBuntil\fP \fIlist\fP; \fBdo\fP \fIlist\fP; \fBdone\fP
.PD
The \fBwhile\fP command continuously executes the \fBdo\fP
\fIlist\fP as long as the last command in \fIlist\fP returns
.I list
is executed as long as the last command in
.I list
-returns a non\-zero exit status.
+returns a non-zero exit status.
The exit status of the \fBwhile\fP and \fBuntil\fP commands
is the exit status
of the last \fBdo\fP \fIlist\fP command executed, or zero if
.B FUNCTIONS
below.)
.SH COMMENTS
-In a non\-interactive shell, or an interactive shell in which the
-.B -o interactive\-comments
-option to the \fBset\fP builtin is enabled, a word beginning with
+In a non-interactive shell, or an interactive shell in which the
+.B interactive_comments
+option to the
+.B shopt
+builtin is enabled (see
+.SM
+.B "SHELL BUILTIN COMMANDS"
+below), a word beginning with
.B #
causes that word and all remaining characters on that line to
be ignored. An interactive shell without the
-.B -o interactive\-comments
-option enabled does not allow comments.
+.B interactive_comments
+.B shopt
+option enabled does not allow comments. The
+.B interactive_comments
+option is on by default in interactive shells.
.SH QUOTING
\fIQuoting\fP is used to remove the special meaning of certain
characters or words to the shell. Quoting can be used to
.SM
.B PARAMETERS
below).
+.PP
+Words of the form \fB$\fP'\fIstring\fP' are treated specially. The
+word expands to \fIstring\fP, with backslash-escaped characters replaced
+as specifed by the ANSI C standard. Backslash escape sequences, if
+present, are decoded as follows:
+.RS
+.PD 0
+.TP
+.B \ea
+alert (bell)
+.TP
+.B \eb
+backspace
+.TP
+.B \ee
+an escape character
+.TP
+.B \ef
+form feed
+.TP
+.B \en
+new line
+.TP
+.B \er
+carriage return
+.TP
+.B \et
+horizontal tab
+.TP
+.B \ev
+vertical tab
+.TP
+.B \e\e
+backslash
+.TP
+.B \e\fInnn\fP
+the character whose ASCII code is \fInnn\fP (octal)
+.PD
+.RE
+.LP
+The translated 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
+the string to be translated according to the current locale.
+If the current locale is \fBC\fP or \fBPOSIX\fP, the dollar sign
+is ignored.
+If the string is translated and replaced, the replacement is
+double-quoted.
.SH PARAMETERS
A
.I parameter
-is an entity that stores values, somewhat like a
-variable in a conventional programming language. It can be a
+is an entity that stores values.
+It can be a
.IR name ,
a number, or one of the special characters listed below under
.BR "Special Parameters" .
.I value
is not given, the variable is assigned the null string. All
.I values
-undergo tilde expansion, parameter and variable expansion, command
-substitution, arithmetic expansion, and quote removal. If
-the variable has its
+undergo tilde expansion, parameter and variable expansion, string
+expansion, command substitution, arithmetic expansion, and quote
+removal (see
+.SM
+.B EXPANSION
+below). If the variable has its
.B \-i
attribute set (see
.B declare
.BR "SHELL BUILTIN COMMANDS" )
then
.I value
-is subject to arithmetic expansion even if the $[...] syntax does
-not appear. Word splitting is not performed, with the exception
+is subject to arithmetic expansion even if the $((...)) syntax does
+not appear (see
+.B "Arithmetic Expansion"
+below).
+Word splitting is not performed, with the exception
of \fB"$@"\fP as explained below under
.BR "Special Parameters" .
Pathname expansion is not performed.
.B $0
is set to the first argument after the string to be
executed, if one is present. Otherwise, it is set
-to the pathname used to invoke
+to the file name used to invoke
.BR bash ,
as given by argument zero.
.TP
.B _
-Expands to the last argument to the previous command, after expansion.
-Also set to the full pathname of each command executed and placed in
+At shell startup, set to the absolute file name of the shell or shell
+script being executed as passed in the argument list.
+Subsequently, expands to the last argument to the previous command,
+after expansion.
+Also set to the full file name of each command executed and placed in
the environment exported to that command.
+When checking mail, this parameter holds the name of the mail file
+currently being checked.
.PD
.SS Shell Variables
.PP
shell startup.
.TP
.B BASH
-Expands to the full pathname used to invoke this instance of
+Expands to the full file name used to invoke this instance of
.BR bash .
.TP
.B BASH_VERSION
-Expands to the version number of this instance of
+Expands to a string describing the version of this instance of
.BR bash .
.TP
+.B BASH_VERSINFO
+An array variable whose members hold version information for this
+instance of
+.BR bash .
+The values assigned to the array members are as follows:
+.sp .5
+.RS
+.PD 0
+.TP 24
+.B BASH_VERSINFO[\fR0\fP]
+The major version number (the \fIrelease\fP).
+.TP
+.B BASH_VERSINFO[\fR1\fP]
+The minor version number (the \fIversion\fP).
+.TP
+.B BASH_VERSINFO[\fR2\fP]
+The patch level.
+.TP
+.B BASH_VERSINFO[\fR3\fP]
+The build version.
+.TP
+.B BASH_VERSINFO[\fR4\fP]
+The release status (e.g., \fIbeta1\fP).
+.TP
+.B BASH_VERSINFO[\fR5\fP]
+The value of \fBMACHTYPE\fP.
+.PD
+.RE
+.TP
.B SHLVL
Incremented by one each time an instance of
.B bash
is started.
.TP
.B RANDOM
-Each time this parameter is referenced, a random integer is
+Each time this parameter is referenced, a random integer between
+0 and 32767 is
generated. The sequence of random numbers may be initialized by assigning
a value to
.SM
a decimal number representing the current sequential line number
(starting with 1) within a script or function. When not in a
script or function, the value substituted is not guaranteed to
-be meaningful. When in a function, the value is not
-the number of the source line that the command appears
-on (that information has been lost by the time the function is
-executed), but is an approximation of the number of
-.I simple commands
-executed in the current function.
+be meaningful.
If
.SM
.B LINENO
.TP
.B HISTCMD
The history number, or index in the history list, of the current
-command. If
+command.
+If
.SM
.B HISTCMD
is unset, it loses its special properties, even if it is
subsequently reset.
.TP
+.B DIRSTACK
+An array variable (see
+.B Arrays
+below) containing the current contents of the directory stack.
+Directories appear in the stack in the order they are displayed by the
+.B dirs
+builtin.
+Assigning to members of this array variable may be used to modify
+directories already in the stack, but the
+.B pushd
+and
+.B popd
+builtins must be used to add and remove directories.
+Assignment to this variable will not change the current directory.
+If
+.SM
+.B DIRSTACK
+is unset, it loses its special properties, even if it is
+subsequently reset.
+.TP
+.B PIPESTATUS
+An array variable (see
+.B Arrays
+below) containing a list of exit status values from the processes
+in the most-recently-executed foreground pipeline (which may
+contain only a single command).
+.TP
.B OPTARG
The value of the last option argument processed by the
.B getopts
.B SHELL BUILTIN COMMANDS
below).
.TP
+.B HOSTNAME
+Automatically set to the name of the current host.
+.TP
.B HOSTTYPE
Automatically set to a string that uniquely
describes the type of machine on which
.B bash
-is executing. The default is system-dependent.
+is executing.
+The default is system-dependent.
.TP
.B OSTYPE
Automatically set to a string that
describes the operating system on which
.B bash
-is executing. The default is system-dependent.
+is executing.
+The default is system-dependent.
+.TP
+.B MACHTYPE
+Automatically set to a string that fully describes the system
+type on which
+.B bash
+is executing, in the standard GNU \fIcpu-company-system\fP format.
+The default is system-dependent.
+.TP
+.B SHELLOPTS
+A colon-separated list of enabled shell options. Each word in
+the list is a valid argument for the
+.B \-o
+option to the
+.B set
+builtin command (see
+.SM
+.B "SHELL BUILTIN COMMANDS"
+below). The options appearing in
+.SM
+.B SHELLOPTS
+are those reported as
+.I on
+by \fBset \-o\fP.
+If this variable is in the environment when
+.B bash
+starts up, each shell option in the list will be enabled before
+reading any startup files.
+This variable is read-only.
.PD
.PP
The following variables are used by the shell. In some cases,
the shell looks for commands (see
.SM
.B COMMAND EXECUTION
-below). The default path is system\-dependent,
+below). The default path is system-dependent,
and is set by the administrator who installs
.BR bash .
A common value is ``/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin:.''.
.SM
.B ENV
is subjected to parameter expansion, command substitution, and arithmetic
-expansion before being interpreted as a pathname.
+expansion before being interpreted as a file name.
.SM
.B PATH
-is not used to search for the resultant pathname.
+is not used to search for the resultant file name.
.TP
.B MAIL
-If this parameter is set to a filename and the
+If this parameter is set to a file name and the
.SM
.B MAILPATH
variable is not set,
often (in seconds)
.B bash
checks for mail. The default is 60 seconds. When it is time to check
-for mail, the shell does so before prompting.
+for mail, the shell does so before displaying the primary prompt.
If this variable is unset, the shell disables mail checking.
.TP
.B MAILPATH
-A colon-separated list of pathnames to be checked for mail.
-The message to be printed may be specified by separating the pathname from
+A colon-separated list of file names to be checked for mail.
+The message to be printed may be specified by separating the file name from
the message with a `?'. $_ stands for the name of the current mailfile.
Example:
.RS
.PP
-\fBMAILPATH\fP='/usr/spool/mail/bfox?"You have mail":~/shell-mail?"$_ has mail!"'
+\fBMAILPATH\fP='/usr/spool/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).
.RE
.TP
-.B MAIL_WARNING
-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 printed.
-.TP
.B PS1
The value of this parameter is expanded (see
.SM
.B PROMPTING
below) and used as the primary prompt string. The default value is
-``\fBbash\e$ \fP''.
+``\fB\es\-\ev\e$ \fP''.
.TP
.B PS2
-The value of this parameter is expanded
+The value of this parameter is expanded as with
+.B PS1
and used as the secondary prompt string. The default is
``\fB> \fP''.
.TP
.B PS3
The value of this parameter is used as the prompt for the
-.I select
+.B select
command (see
.SM
.B SHELL GRAMMAR
above).
.TP
.B PS4
-The value of this parameter is expanded
+The value of this parameter is expanded as with
+.B PS1
and the value is printed before each command
.B bash
displays during an execution trace. The first character of
is replicated multiple times, as necessary, to indicate multiple
levels of indirection. The default is ``\fB+ \fP''.
.TP
+.B TIMEFORMAT
+The value of this parameter is used as a format string specifying
+how the timing information for pipelines prefixed with the
+.B time
+reserved word should be displayed.
+The \fB%\fP character introduces an escape sequence that is
+expanded to a time value or other information.
+The escape sequences and their meanings are as follows; the
+braces denote optional portions.
+.sp .5
+.RS
+.PD 0
+.TP 10
+.B %%
+A literal \fB%\fP.
+.TP
+.B %[\fIp\fP][l]R
+The elapsed time in seconds.
+.TP
+.B %[\fIp\fP][l]U
+The number of CPU seconds spent in user mode.
+.TP
+.B %[\fIp\fP][l]S
+The number of CPU seconds spent in system mode.
+.TP
+.B %P
+The CPU percentage, computed as (%U + %S) / %R.
+.PD
+.RE
+.IP
+The optional \fIp\fP is a digit specifying the \fIprecision\fP,
+the number of fractional digits after a decimal point.
+A value of 0 causes no decimal point or fraction to be output.
+At most three places after the decimal point may be specified;
+values of \fIp\fP greater than 3 are changed to 3.
+If \fIp\fP is not specified, the value 3 is used.
+.IP
+The optional \fBl\fP specifies a longer format, including
+minutes, of the form \fIMM\fPm\fISS\fP.\fIFF\fPs.
+The value of \fIp\fP determines whether or not the fraction is
+included.
+.IP
+If this variable is not set, \fBbash\fP acts as if it had the
+value \fB$'\enreal\et%3lR\enuser\et%3lU\ensys\t%3lS'\fP.
+If the value is null, no timing information is displayed.
+A trailing newline is added when the format string is displayed.
+.TP
.B HISTSIZE
The number of commands to remember in the command history (see
.SM
below). The default value is 500.
.TP
.B HISTFILE
-The name of the file in which command history is saved. (See
+The name of the file in which command history is saved (see
.SM
.B HISTORY
-below.) The default value is \fI~/.bash_history\fP. If unset, the
+below). The default value is \fI~/.bash_history\fP. If unset, the
command history is not saved when an interactive shell exits.
.TP
.B HISTFILESIZE
The maximum number of lines contained in the history file. When this
variable is assigned a value, the history file is truncated, if
necessary, to contain no more than that number of lines. The default
-value is 500.
+value is 500. The history file is also truncated to this size after
+writing it when an interactive shell exits.
.TP
.B OPTERR
If set to the value 1,
is initialized to 1 each time the shell is invoked or a shell
script is executed.
.TP
+.B LANG
+Used to determine the locale category for any category not specifically
+selected with a variable starting with \fBLC_\fP.
+.TP
+.B LC_ALL
+This variable overrides the value of \fBLANG\fP and any other
+\fBLC_\fP variable specifying a locale category.
+.TP
+.B LC_COLLATE
+This variable determines the collation order used when sorting the
+results of pathname expansion.
+.TP
+.B LC_MESSAGES
+This variable determines the locale used to translate double-quoted
+strings preceded by a \fB$\fP.
+.TP
.B PROMPT_COMMAND
If set, the value is executed as a command prior to issuing each primary
prompt.
.TP
.B IGNOREEOF
Controls the
-action of the shell on receipt of an
+action of an interactive shell on receipt of an
.SM
.B EOF
character as the sole input. If set, the value is the number of
consecutive
.SM
.B EOF
-characters typed as the first characters on an input line before
+characters which must be
+typed as the first characters on an input line before
.B bash
exits. If the variable exists but does not have a numeric value, or
has no value, the default value is 10. If it does not exist,
.SM
.B EOF
-signifies the end of input to the shell. This is only in effect for
-interactive shells.
+signifies the end of input to the shell.
.TP
.B TMOUT
If set to a value greater than zero, the value is interpreted as the
filename completion (see
.SM
.B READLINE
-below). A filename whose suffix matches one of the entries in
+below).
+A filename whose suffix matches one of the entries in
.SM
.B FIGNORE
-is excluded from the list of matched filenames. A sample
-value is ``.o:~''.
+is excluded from the list of matched filenames.
+A sample value is ``.o:~''.
+.TP
+.B GLOBIGNORE
+A colon-separated list of patterns defining the set of filenames to
+be ignored by pathname expansion.
+If a filename matched by a pathname expansion pattern also matches one
+of the patterns in
+.SM
+.BR GLOBIGNORE ,
+it is removed from the list of matches.
.TP
.B INPUTRC
-The filename for the readline startup file, overriding the default
-of
+The filename for the
+.B readline
+startup file, overriding the default of
.FN ~/.inputrc
(see
.SM
.B READLINE
below).
.TP
-.B notify
-If set,
-.B bash
-reports terminated background jobs immediately, rather than waiting
-until before printing the next primary prompt (see also the
-.B \-b
-option to the
-.B set
-builtin command).
-.PD 0
-.TP
-.B history_control
-.TP
.B HISTCONTROL
-.PD
If set to a value of
.IR ignorespace ,
lines which begin with a
combines the two options.
If unset, or if set to any other value than those above,
all lines read
-by the parser are saved on the history list.
-.TP
-.B command_oriented_history
-If set,
-.B bash
-attempts to save all lines of a multiple\-line
-command in the same history entry. This allows
-easy re\-editing of multi\-line commands.
-.TP
-.B glob_dot_filenames
-If set,
-.B bash
-includes filenames beginning with a `.' in the results of pathname
-expansion.
-.TP
-.B allow_null_glob_expansion
-If set,
-.B bash
-allows pathname patterns which match no
-files (see
-.B Pathname Expansion
-below)
-to expand to a null string, rather than themselves.
+by the parser are saved on the history list, subject to the value
+of
+.BR HISTIGNORE .
+This variable's function is superseded by
+.BR HISTIGNORE .
+.TP
+.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
+`\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.
.TP
.B histchars
The two or three characters which control history expansion
command entered, substituting one string for another in the command.
The default is `\fB^\fP'.
The optional third character is the character
-which signifies that the remainder of the line is a comment, when found
+which signifies that the remainder of the line is a comment when found
as the first character of a word, normally `\fB#\fP'. The history
comment character causes history substitution to be skipped for the
remaining words on the line. It does not necessarily cause the shell
parser to treat the rest of the line as a comment.
.TP
-.B nolinks
-If set, the shell does not follow symbolic links when executing
-commands that change the current working directory. It uses the
-physical directory structure instead. By default,
-.B bash
-follows the logical chain of directories when performing commands
-which change the current directory, such as
-.BR cd .
-See also the description of the \fB\-P\fP option to the \fBset\fP
-builtin (
-.SM
-.B SHELL BUILTIN COMMANDS
-below).
-.PD 0
-.TP
-.B hostname_completion_file
-.TP
.B HOSTFILE
-.PD
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
.B bash
adds the contents of the new file to the already existing database.
.TP
-.B noclobber
-If set,
-.B bash
-does not overwrite an existing file with the
-.BR > ,
-.BR >& ,
-and
-.B <>
-redirection operators. This variable may be overridden when
-creating output files by using the redirection operator
-.B >|
-instead of
-.B >
-(see also the \fB\-C\fP option to the
-.B set
-builtin command).
-.TP
.B auto_resume
This variable controls how the shell interacts with the user and
job control. If this variable is set, single word simple
.I substring
value provides functionality analogous to the
.B %?
-job id (see
+job identifier (see
.SM
.B JOB CONTROL
below). If set to any other value, the supplied string must
be a prefix of a stopped job's name; this provides functionality
analogous to the
.B %
-job id.
-.TP
-.B no_exit_on_failed_exec
-If this variable exists, a non-interactive shell will not exit if
-it cannot execute the file specified in the
-.B exec
-builtin command. An interactive shell does not exit if
-.B exec
-fails.
-.TP
-.B cdable_vars
-If this is set, an argument to the
-.B cd
-builtin command that
-is not a directory is assumed to be the name of a variable whose
-value is the directory to change to.
+job identifier.
.PD
+.SS Arrays
+.B Bash
+provides one-dimensional array variables. Any variable may be used as
+an array; the
+.B declare
+builtin will explicitly declare an array. There is no maximum
+limit on the size of an array, nor any requirement that members
+be indexed or assigned contiguously. Arrays are indexed using
+integers and are zero-based.
+.PP
+An array is created automatically if any variable is assigned to using
+the syntax \fIname\fP[\fIsubscript\fP]=\fIvalue\fP. The
+.I subscript
+is treated as an arithmetic expression that must evaluate to a number
+greater than or equal to zero. To explicitly declare an array, use
+.B declare \-a \fIname\fP
+(see
+.SM
+.B SHELL BUILTIN COMMANDS
+below).
+.B declare \-a \fIname\fP[\fIsubscript\fP]
+is also accepted; the \fIsubscript\fP is ignored. Attributes may be
+specified for an array variable using the
+.B declare
+and
+.B readonly
+builtins. Each attribute applies to all members of an array.
+.PP
+Arrays are assigned to using compound assignments of the form
+\fIname\fP=\fB(\fPvalue\fI1\fP ... value\fIn\fP\fB)\fP, where each
+\fIvalue\fP is of the form [\fIsubscript\fP]=\fIstring\fP. Only
+\fIstring\fP is required. If
+the optional brackets and subscript are supplied, that index is assigned to;
+otherwise the index of the element assigned is the last index assigned
+to by the statement plus one. Indexing starts at zero.
+This syntax is also accepted by the
+.B declare
+builtin. Individual array elements may be assigned to using the
+\fIname\fP[\fIsubscript\fP]=\fIvalue\fP syntax introduced above.
+.PP
+Any element of an array may be referenced using
+${\fIname\fP[\fIsubscript\fP]}. The braces are required to avoid
+conflicts with pathname expansion. If
+\fIsubscript\fP is \fB@\fP or \fB*\fP, the word expands to
+all members of \fIname\fP. These subscripts differ only when the
+word appears within double quotes. If the word is double-quoted,
+${\fIname\fP[*]} expands to a single
+word with the value of each array member separated by the first
+character of the
+.SM
+.B IFS
+special variable, and ${\fIname\fP[@]} expands each element of
+\fIname\fP to a separate word. When there are no array members,
+${\fIname\fP[@]} expands to nothing. This is analogous to the expansion
+of the special parameters \fB*\fP and \fB@\fP (see
+.B Special Parameters
+above). ${#\fIname\fP[\fIsubscript\fP]} expands to the length of
+${\fIname\fP[\fIsubscript\fP]}. If \fIsubscript\fP is \fB*\fP or
+\fB@\fP, the expansion is the number of elements in the array.
+Referencing an array variable without a subscript is equivalent to
+referencing element zero.
+.PP
+The
+.B unset
+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
+\fIsubscript\fP is \fB*\fP or \fB@\fP, removes the entire array.
+.PP
+The
+.BR declare ,
+.BR local ,
+and
+.B readonly
+builtins each accept a
+.B \-a
+option to specify an array. The
+.B read
+builtin accepts a
+.B \-a
+option to assign a list of words read from the standard input
+to an array. The
+.B set
+and
+.B declare
+builtins display array values in a way that allows them to be
+reused as assignments.
.SH EXPANSION
Expansion is performed on the command line after it has been split into
words. There are seven kinds of expansion performed:
.IR "pathname expansion" .
.PP
The order of expansions is: brace expansion, tilde expansion,
-parameter, variable, command, and arithmetic substitution (done
-in a left\-to\-right fashion), word splitting, and pathname
+parameter, variable and arithmetic expansion and
+command substitution
+(done in a left-to-right fashion), word splitting, and pathname
expansion.
.PP
On systems that can support it, there is an additional expansion
Only brace expansion, word splitting, and pathname expansion
can change the number of words of the expansion; other expansions
expand a single word to a single word.
-The single exception to this is the expansion of
-``\fB$@\fP'' as explained above (see
+The only exceptions to this are the expansions of
+``\fB$@\fP'' and ``\fB${\fP\fIname\fP\fB[@]}\fP''
+as explained above (see
.SM
.BR PARAMETERS ).
.SS Brace Expansion
followed by a series of comma-separated strings
between a pair of braces, followed by an optional
.IR postamble .
-The preamble is prepended to each string contained
+The preamble is prefixed to each string contained
within the braces, and the postamble is then appended
to each resulting string, expanding left to right.
.PP
A correctly-formed brace expansion must contain unquoted opening
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.
.PP
This construct is typically used as shorthand when the common
prefix of the strings to be generated is longer than in the
.RE
.PP
Brace expansion introduces a slight incompatibility with
-traditional versions of
-.BR sh ,
-the Bourne shell.
+historical versions of
+.BR sh .
.B sh
does not treat opening or closing braces specially when they
appear as part of a word, and preserves them in the output.
is desired, start
.B bash
with the
-.B \-nobraceexpansion
-flag (see
-.SM
-.B OPTIONS
-above)
-or disable brace expansion with the
-.B +o braceexpand
+.B +B
+option or disable brace expansion with the
+.B +B
option to the
.B set
command (see
expansion fails, the word is unchanged.
.PP
Each variable assignment is checked for unquoted
-instances of tildes following a
+tildes immediately following a
.B :
or
.BR = .
In these cases, tilde substitution is also performed. Consequently, one
-may use pathnames with tildes in assignments to
+may use file names with tildes in assignments to
.SM
.BR PATH ,
.SM
interpreted as part of its name.
.PD
.PP
+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
+than the value of \fIparameter\fP itself.
+This is known as \fIindirect expansion\fP.
+.PP
In each of the cases below, \fIword\fP is subject to tilde expansion,
parameter expansion, command substitution, and arithmetic expansion.
-\fBBash\fP tests for a parameter that is unset or null; omitting the
-colon results in a test only for a parameter that is unset.
+When not performing substring expansion, \fBbash\fP tests for a parameter
+that is unset or null; omitting the colon results in a test only for a
+parameter that is unset.
.PP
.PD 0
.TP
.I word
is substituted.
.TP
+.PD 0
+${\fIparameter\fP\fB:\fP\fIoffset\fP}
+.TP
+${\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 \fIoffset\fP.
+If \fIlength\fP is omitted, expands to the substring of
+\fIparameter\fP, starting at the character specified by \fIoffset\fP.
+\fIlength\fP and \fIoffset\fP are arithmetic expressions (see
+.SM
+.B
+ARITHMETIC EVALUATION
+below).
+\fIlength\fP must evaluate to a number greater than or equal to zero.
+If \fIoffset\fP evaluates to a number less than zero, the value
+is used as an offset from the end of the value of \fIparameter\fP.
+If \fIparameter\fP is \fB@\fP, the result is \fIlength\fP positional
+parameters beginning at \fIoffset\fP.
+If \fIparameter\fP is an array name indexed by @ or *,
+the result is the \fIlength\fP
+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\fIparameter\fP}
The length in characters of the value of \fIparameter\fP is substituted.
-If \fIparameter\fP is
+If
+.I parameter
+is
.B *
or
.BR @ ,
-the length substituted is the length of
+the length substituted is the number of positional parameters.
+If
+.I parameter
+is an array name subscripted by
.B *
-expanded within double quotes.
+or
+.BR @ ,
+the length substituted is the number of elements in the array.
.TP
.PD 0
${\fIparameter\fP\fB#\fP\fIword\fP}
.IR parameter ,
then the expansion is the value of
.I parameter
-with the shortest matching pattern deleted (the ``\fB#\fP''
-case) or the longest
-matching pattern deleted (the ``\fB##\fP'' case).
+with the shortest matching pattern (the ``\fB#\fP'' case) or the
+longest matching pattern (the ``\fB##\fP'' case) deleted.
+If
+.I parameter
+is
+.B @
+or
+.BR * ,
+the pattern removal operation is applied to each positional
+parameter in turn, and the expansion is the resultant list.
+If
+.I parameter
+is an array variable subscripted with
+.B @
+or
+.BR * ,
+the pattern removal operation is applied to each member of the
+array in turn, and the expansion is the resultant list.
.TP
.PD 0
${\fIparameter\fP\fB%\fP\fIword\fP}
${\fIparameter\fP\fB%%\fP\fIword\fP}
.PD
The \fIword\fP is expanded to produce a pattern just as in
-pathname expansion. If the pattern matches a
-trailing portion of the value of
+pathname expansion.
+If the pattern matches a trailing portion of the value of
.IR parameter ,
then the expansion is the value of
.I parameter
-with the shortest matching pattern deleted
-(the ``\fB%\fP'' case) or the longest
-matching pattern deleted (the ``\fB%%\fP'' case).
+with the shortest matching pattern (the ``\fB%\fP'' case) or the
+longest matching pattern (the ``\fB%%\fP'' case) deleted.
+If
+.I parameter
+is
+.B @
+or
+.BR * ,
+the pattern removal operation is applied to each positional
+parameter in turn, and the expansion is the resultant list.
+If
+.I parameter
+is an array variable subscripted with
+.B @
+or
+.BR * ,
+the pattern removal operation is applied to each member of the
+array in turn, and the expansion is the resultant list.
+.TP
+.PD 0
+${\fIparameter\fP\fB/\fP\fIpattern\fP\fB/\fP\fIstring\fP}
+.TP
+${\fIparameter\fP\fB//\fP\fIpattern\fP\fB/\fP\fIstring\fP}
+.PD
+The \fIpattern\fP is expanded to produce a pattern just as in
+pathname expansion.
+\fIParameter\fP is expanded and the longest match of \fIpattern\fP
+against its value is replaced with \fIstring\fP.
+In the first form, only the first match is replaced.
+The second form causes all matches of \fIpattern\fP to be
+replaced with \fIstring\fP.
+If \fIpattern\fP begins with \fB#\fP, it must match at the beginning
+of \fIstring\fP.
+If \fIpattern\fP begins with \fB%\fP, it must match at the end
+of \fIstring\fP.
+If \fIstring\fP is null, matches of \fIpattern\fP are deleted
+and the \fB/\fP following \fIpattern\fP may be omitted.
+If
+.I parameter
+is
+.B @
+or
+.BR * ,
+the substitution operation is applied to each positional
+parameter in turn, and the expansion is the resultant list.
+If
+.I parameter
+is an array variable subscripted with
+.B @
+or
+.BR * ,
+the substitution operation is applied to each member of the
+array in turn, and the expansion is the resultant list.
.SS Command Substitution
.PP
\fICommand substitution\fP allows the output of a command to replace
\fB`\fP\fIcommand\fP\fB`\fP
.RE
.PP
-. B Bash
+.B Bash
performs the expansion by executing \fIcommand\fP and
replacing the command substitution with the standard output of the
command, with any trailing newlines deleted.
.PP
-When the old\-style backquote form of substitution is used,
+When the old-style backquote form of substitution is used,
backslash retains its literal meaning except when followed by
.BR $ ,
.BR ` ,
.SS Arithmetic Expansion
.PP
Arithmetic expansion allows the evaluation of an arithmetic expression
-and the substitution of the result. There are two formats for
-arithmetic expansion:
+and the substitution of the result. The format for arithmetic expansion is:
.RS
.PP
-\fB$[\fP\fIexpression\fP\fB]\fP
-.PP
\fB$((\fP\fIexpression\fP\fB))\fP
.RE
.PP
The
.I expression
is treated as if it were within double quotes, but a double quote
-inside the braces or parentheses
-is not treated specially. All tokens in the
-expression undergo parameter expansion, command substitution,
-and quote removal. Arithmetic substitutions may be nested.
+inside the parentheses is not treated specially.
+All tokens in the expression undergo parameter expansion, string
+expansion, command substitution, and quote removal.
+Arithmetic substitutions may be nested.
.PP
The evaluation is performed according to the rules listed below under
.SM
argument should be read to obtain the output of \fIlist\fP.
.PP
On systems that support it, \fIprocess substitution\fP is performed
-simultaneously with
-.IR "parameter and variable expansion" ,
-.IR "command substitution" ,
-and
-.IR "arithmetic expansion" .
+simultaneously with parameter and variable expansion,
+command substitution,
+and arithmetic expansion.
.SS Word Splitting
.PP
The shell scans the results of
.SM
.B IFS
as a delimiter, and splits the results of the other
-expansions into words on these characters. If the
-value of
+expansions into words on these characters. If
.SM
.B IFS
-is exactly
+is unset, or its
+value is exactly
.BR <space><tab><newline> ,
the default, then
any sequence of
.SM
.B IFS
is null, no word splitting occurs.
-.SM
-.B IFS
-cannot be unset.
.PP
-Explicit null arguments (\^\f3"\^"\fP or \^\f3'\^'\fP\^)
-are retained. Implicit null arguments, resulting from the expansion
-of
+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.
+If a parameter with no value is expanded within double quotes, a
+null argument results and is retained.
.PP
Note that if no expansion occurs, no splitting
is performed.
.B \-f
option has been set,
.B bash
-scans each
-.I word
-for the characters
+scans each word for the characters
.BR * ,
.BR ? ,
and
regarded as a
.IR pattern ,
and replaced with an alphabetically sorted list of
-pathnames matching the pattern.
-If no matching pathnames are found,
-and the shell variable
-.B allow_null_glob_expansion
-is unset, the word is left unchanged.
-If the variable is set, and no matches are found,
+file names matching the pattern.
+If no matching file names are found,
+and the shell option
+.B nullglob
+is disabled, the word is left unchanged.
+If the option is set, and no matches are found,
the word is removed.
-When a pattern is used for pathname generation,
+When a pattern is used for pathname expansion,
the character
.B ``.''
at the start of a name or immediately following a slash
-must be matched explicitly, unless the shell variable
-.B glob_dot_filenames
-is set. The slash character must always be matched
-explicitly. In other cases, the
+must be matched explicitly, unless the shell option
+.B dotglob
+is set.
+The slash character must always be matched explicitly.
+In other cases, the
.B ``.''
character is not treated specially.
+See the description of
+.B shopt
+below under
+.SM
+.B SHELL BUILTIN COMMANDS
+for a description of the
+.B nullglob
+and
+.B dotglob
+shell options.
+.PP
+The
+.SM
+.B GLOBIGNORE
+shell variable may be used to restrict the set of file names matching a
+.IR pattern .
+If
+.SM
+.B GLOBIGNORE
+is set, each matching file name that also matches one of the patterns in
+.SM
+.B GLOBIGNORE
+is removed from the list of matches.
+The file names
+.B ``.''
+and
+.B ``..''
+are always ignored, even when
+.SM
+.B GLOBIGNORE
+is set. However, setting
+.SM
+.B GLOBIGNORE
+has the effect of enabling the
+.B dotglob
+shell option, so all other file names beginning with a
+.B ``.''
+will match.
+To get the old behavior of ignoring file names beginning with a
+.BR ``.'' ,
+make
+.B ``.*''
+one of the patterns in
+.SM
+.BR GLOBIGNORE .
+The
+.B dotglob
+option is disabled when
+.SM
+.B GLOBIGNORE
+is unset.
.PP
The special pattern characters have the following meanings:
.PP
.B !
or a
.B ^
-then any character not enclosed is matched. A
+then any character not enclosed is matched.
+A
.B \-
-or
-.B ]
may be matched by including it as the first or last character
in the set.
+A
+.B ]
+may be matched by including it as the first character
+in the set.
.PD
.SS Quote Removal
.PP
characters
.BR \e ,
.BR ` ,
-and \^\f3"\fP\^ are removed.
+and \^\f3"\fP\^ that did not result from one of the above
+expansions are removed.
.SH REDIRECTION
Before a command is executed, its input and output
may be
.RE
.PP
If the redirection operator is
+.BR > ,
+and the
+.B \-C
+option to the
+.B set
+builtin has been enabled, the redirection will fail if the filename
+whose name results from the expansion of \fIword\fP exists.
+If the redirection operator is
.BR >| ,
then the value of the
-.B -C
+.B \-C
option to the
.B set
-builtin command is not tested, and file creation is attempted.
-(See also the description of
-.B noclobber
-under
-.B "Shell Variables"
-above.)
+builtin command is not tested, and the redirection is attempted even
+if the file named by \fIword\fP exists.
.SS Appending Redirected Output
.PP
Redirection of output in this fashion
.PP
.nf
\fB<<\fP[\fB\-\fP]\fIword\fP
- \fIhere-document\fP
+ \fIhere\-document\fP
\fIdelimiter\fP
.fi
.RE
.I word
to be opened for both reading and writing on file descriptor
.IR n ,
-or as the standard input and standard output if
+or on file descriptor 0 if
.I n
is not specified. If the file does not exist, it is created.
-.SH FUNCTIONS
-A shell function, defined as described above under
-.SM
-.BR "SHELL GRAMMAR" ,
-stores a series of commands for later execution.
-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
-.B #
-is updated to reflect the change. Positional parameter 0
-is unchanged.
-.PP
-Variables local to the function may be declared with the
-.B local
-builtin command. Ordinarily, variables and their values
-are shared between the function and its caller.
-.PP
-If the builtin command
-.B return
-is executed in a function, the function completes and
-execution resumes with the next command after the function
-call. When a function completes, the values of the
-positional parameters and the special parameter
-.B #
-are restored to the values they had prior to function
-execution.
-.PP
-Function names and definitions may be listed with the
-.B \-f
-option to the
-.B declare
-or
-.B typeset
-builtin commands. Functions may be exported so that subshells
-automatically have them defined with the
-.B \-f
-option to the
-.B export
-builtin.
-.PP
-Functions may be recursive. No limit is imposed on the number
-of recursive calls.
.SH ALIASES
The shell maintains a list of
.I aliases
.B unalias
command.
.PP
-There is no mechanism for using arguments in the replacement text,
-as in
-.BR csh .
+There is no mechanism for using arguments in the replacement text.
If arguments are needed, a shell function should be used.
.PP
-Aliases are not expanded when the shell is not interactive.
+Aliases are not expanded when the shell is not interactive, unless
+the
+.B expand_aliases
+shell option is set using
+.B shopt
+(see the description of
+.B shopt
+under
+.SM
+\fBSHELL BUILTIN COMMANDS\fP
+below).
.PP
The rules concerning the definition and use of aliases are
somewhat confusing.
command is read, not when it is executed. Therefore, an
alias definition appearing on the same line as another
command does not take effect until the next line of input is read.
-This means that the commands following the alias definition
+The commands following the alias definition
on that line are not affected by the new alias.
This behavior is also an issue when functions are executed.
Aliases are expanded when the function definition is read,
.PP
Note that for almost every purpose, aliases are superseded by
shell functions.
-.SH "JOB CONTROL"
-.I Job control
-refers to the ability to selectively stop (\fIsuspend\fP)
-the execution of processes and continue (\fIresume\fP)
-their execution at a later point. A user typically employs
-this facility via an interactive interface supplied jointly
-by the system's terminal driver and
-.BR bash .
+.SH FUNCTIONS
+A shell function, defined as described above under
+.SM
+.BR "SHELL GRAMMAR" ,
+stores a series of commands for later execution.
+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
+.B #
+is updated to reflect the change. Positional parameter 0
+is unchanged. All other aspects of the shell execution
+environment are identical between a function and its caller
+with the exception that the
+.SM
+.B DEBUG
+trap (see the description of the
+.B trap
+builtin under
+.SM
+.B SHELL BUILTIN COMMANDS
+below) is not inherited.
.PP
-The shell associates a
-.I job
-with each pipeline. It keeps a table of currently executing
-jobs, which may be listed with the
-.B jobs
-command. When
-.B bash
-starts a job asynchronously (in the
-.IR background ),
-it prints a line that looks like:
-.RS
-.PP
-[1] 25647
-.RE
-.PP
-indicating that this job is job number 1 and that the process ID
-of the last process in the pipeline associated with this job is 25647.
-All of the processes in a single pipeline are members of the same job.
-.B Bash
-uses the
-.I job
-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
-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
-.SM
-.BR SIGINT .
-These processes are said to be in the
-.IR foreground .
-.I Background
-processes are those whose process group ID differs from the terminal's;
-such processes are immune to keyboard-generated signals.
-Only foreground processes are allowed to read from or write to the
-terminal. Background processes which attempt to read from (write to) the
-terminal are sent a
-.SM
-.B SIGTTIN (SIGTTOU)
-signal by the terminal driver,
-which, unless caught, suspends the process.
-.PP
-If the operating system on which
-.B bash
-is running supports
-job control,
-.B bash
-allows you 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
-.BR bash .
-Typing the
-.I "delayed suspend"
-character (typically
-.BR ^Y ,
-Control-Y) causes the process to be stopped when it
-attempts to read input from the terminal, and control to
-be returned to
-.BR bash .
-You may then manipulate the state of this job, using the
-.B bg
-command to continue it in the background, the
-.B fg
-command to continue it in the foreground, or
-the
-.B kill
-command to kill it. A \fB^Z\fP takes effect immediately,
-and has the additional side effect of causing pending output
-and typeahead to be discarded.
-.PP
-There are a number of ways to refer to a job in the shell.
-The character
-.B %
-introduces a job name. Job number
-.I n
-may be referred to as
-.BR %n .
-A job may also be referred to using a prefix of the name used to
-start it, or using a substring that appears in its command line.
-For example,
-.B %ce
-refers to a stopped
-.B ce
-job. If a prefix matches more than one job,
-.B bash
-reports an error. Using
-.BR %?ce ,
-on the other hand, refers to any job containing the string
-.B ce
-in its command line. If the substring matches more than one job,
-.B bash
-reports an error. The symbols
-.B %%
-and
-.B %+
-refer to the shell's notion of the
-.IR "current job" ,
-which is the last job stopped while it was in
-the foreground.
-The
-.I "previous job"
-may be referenced using
-.BR %\- .
-In output pertaining to jobs (e.g., the output of the
-.B jobs
-command), the current job is always flagged with a
-.BR + ,
-and the previous job with a
-.BR \- .
+Variables local to the function may be declared with the
+.B local
+builtin command. Ordinarily, variables and their values
+are shared between the function and its caller.
.PP
-Simply naming a job can be used to bring it into the
-foreground:
-.B %1
-is a synonym for
-\fB``fg %1''\fP,
-bringing job 1 from the background into the foreground.
-Similarly,
-.B ``%1 &''
-resumes job 1 in the background, equivalent to
-\fB``bg %1''\fP.
+If the builtin command
+.B return
+is executed in a function, the function completes and
+execution resumes with the next command after the function
+call. When a function completes, the values of the
+positional parameters and the special parameter
+.B #
+are restored to the values they had prior to function
+execution.
.PP
-The shell learns immediately whenever a job changes state.
-Normally,
-.B bash
-waits until it is about to print a prompt before reporting
-changes in a job's status so as to not interrupt
-any other output. If the
-.B -b
+Function names and definitions may be listed with the
+.B \-f
option to the
-.B set
-builtin command
-is set,
-.B bash
-reports such changes immediately. (See also the description of
-.B notify
-variable under
-.B "Shell Variables"
-above.)
-.PP
-If you attempt to exit
-.B bash
-while jobs are stopped, the shell prints a message warning you. You
-may then use the
-.B jobs
-command to inspect their status. If you do this, or try to exit
-again immediately, you are not warned again, and the stopped
-jobs are terminated.
-.SH SIGNALS
-When \fBbash\fP is interactive, it ignores
-.SM
-.B SIGTERM
-(so that \fBkill 0\fP does not kill an interactive shell),
-and
-.SM
-.B SIGINT
-is caught and handled (so that the \fBwait\fP builtin is interruptible).
-In all cases, \fBbash\fP ignores
-.SM
-.BR SIGQUIT .
-If job control is in effect,
-.B bash
-ignores
-.SM
-.BR SIGTTIN ,
-.SM
-.BR SIGTTOU ,
-and
-.SM
-.BR SIGTSTP .
+.B declare
+or
+.B typeset
+builtin commands. The
+.B \-F
+option to
+.B declare
+or
+.B typeset
+will list the function names only.
+Functions may be exported so that subshells
+automatically have them defined with the
+.B \-f
+option to the
+.B export
+builtin.
.PP
-Synchronous jobs started by \fBbash\fP have signals set to the
-values inherited by the shell from its parent. When job control
-is not in effect, background jobs (jobs started with
-.BR & )
-ignore
-.SM
-.B SIGINT
-and
-.SM
-.BR SIGQUIT .
-Commands run as a result of command substitution ignore the
-keyboard-generated job control signals
-.SM
-.BR SIGTTIN ,
-.SM
-.BR SIGTTOU ,
-and
-.SM
-.BR SIGTSTP .
+Functions may be recursive. No limit is imposed on the number
+of recursive calls.
.SH "COMMAND EXECUTION"
After a command has been split into words, if it results in a
simple command and an optional list of arguments, the following
.SM
.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
+files (see
+.B hash
+under
+.SM
+.B "SHELL BUILTIN COMMANDS"
+below).
+A full search of the directories in
+.SM
+.B PATH
+is performed only if the command is not found in the hash table.
If the search is unsuccessful, the shell prints an error
-message and returns a nonzero exit status.
+message and returns a non-zero exit status.
.PP
If the search is successful, or if the command name contains
one or more slashes, the shell executes the named program.
command, plus any additions via the
.B export
and
-.B declare \-x
-commands.
+.B declare \-x
+commands.
+.PP
+The environment for any
+.I simple command
+or function may be augmented temporarily by prefixing it with
+parameter assignments, as described above in
+.SM
+.BR PARAMETERS .
+These assignment statements affect only the environment seen
+by that command.
+.PP
+If the
+.B \-k
+flag is set (see the
+.B set
+builtin command below), then
+.I all
+parameter assignments are placed in the environment for a command,
+not just those that precede the command name.
+.PP
+When
+.B bash
+invokes an external command, the variable
+.B _
+is set to the full file name of the command and passed to that
+command in its environment.
+.SH "EXIT STATUS"
+For the purposes of the shell, 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.
+.PP
+If a command is not found, the child process created to
+execute it returns a status of 127. If a command is found
+but is not executable, the return status is 126.
+.PP
+Shell builtin commands return a status of 0 (\fItrue\fP) if
+successful, and non-zero (\fIfalse\fP) if an error occurs
+while they execute.
+All builtins return an exit status of 2 to indicate incorrect usage.
+.PP
+\fBBash\fP itself returns the exit status of the last command
+executed, unless a syntax error occurs, in which case it exits
+with a non-zero value. See also the \fBexit\fP builtin
+command below.
+.SH SIGNALS
+When \fBbash\fP is interactive, it ignores
+.SM
+.B SIGTERM
+(so that \fBkill 0\fP does not kill an interactive shell),
+and
+.SM
+.B SIGINT
+is caught and handled (so that the \fBwait\fP builtin is interruptible).
+In all cases, \fBbash\fP ignores
+.SM
+.BR SIGQUIT .
+If job control is in effect,
+.B bash
+ignores
+.SM
+.BR SIGTTIN ,
+.SM
+.BR SIGTTOU ,
+and
+.SM
+.BR SIGTSTP .
+.PP
+Synchronous jobs started by \fBbash\fP have signals set to the
+values inherited by the shell from its parent. When job control
+is not in effect, background jobs (jobs started with
+.BR & )
+ignore
+.SM
+.B SIGINT
+and
+.SM
+.BR SIGQUIT .
+Commands run as a result of command substitution ignore the
+keyboard-generated job control signals
+.SM
+.BR SIGTTIN ,
+.SM
+.BR SIGTTOU ,
+and
+.SM
+.BR SIGTSTP .
+.PP
+The shell exits by default upon receipt of a
+.SM
+.BR SIGHUP .
+Before exiting, it resends the
+.SM
+.B SIGHUP
+to all jobs, running or stopped. To prevent the shell from
+sending the signal to a particular job, remove it from the
+jobs table with the
+.B disown
+builtin (see
+.SM
+.B "SHELL BUILTIN COMMANDS"
+below) or use
+.B "disown \-h"
+to mark it to not receive
+.SM
+.BR SIGHUP .
+.SH "JOB CONTROL"
+.I Job control
+refers to the ability to selectively stop (\fIsuspend\fP)
+the execution of processes and continue (\fIresume\fP)
+their execution at a later point. A user typically employs
+this facility via an interactive interface supplied jointly
+by the system's terminal driver and
+.BR bash .
+.PP
+The shell associates a
+.I job
+with each pipeline. It keeps a table of currently executing
+jobs, which may be listed with the
+.B jobs
+command. When
+.B bash
+starts a job asynchronously (in the
+.IR background ),
+it prints a line that looks like:
+.RS
+.PP
+[1] 25647
+.RE
+.PP
+indicating that this job is job number 1 and that the process ID
+of the last process in the pipeline associated with this job is 25647.
+All of the processes in a single pipeline are members of the same job.
+.B Bash
+uses the
+.I job
+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
+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
+.SM
+.BR SIGINT .
+These processes are said to be in the
+.IR foreground .
+.I Background
+processes are those whose process group ID differs from the terminal's;
+such processes are immune to keyboard-generated signals.
+Only foreground processes are allowed to read from or write to the
+terminal. Background processes which attempt to read from (write to) the
+terminal are sent a
+.SM
+.B SIGTTIN (SIGTTOU)
+signal by the terminal driver,
+which, unless caught, suspends the process.
+.PP
+If the operating system on which
+.B bash
+is running supports
+job control,
+.B bash
+allows you 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
+.BR bash .
+Typing the
+.I "delayed suspend"
+character (typically
+.BR ^Y ,
+Control-Y) causes the process to be stopped when it
+attempts to read input from the terminal, and control to
+be returned to
+.BR bash .
+You may then manipulate the state of this job, using the
+.B bg
+command to continue it in the background, the
+.B fg
+command to continue it in the foreground, or
+the
+.B kill
+command to kill it. A \fB^Z\fP takes effect immediately,
+and has the additional side effect of causing pending output
+and typeahead to be discarded.
+.PP
+There are a number of ways to refer to a job in the shell.
+The character
+.B %
+introduces a job name. Job number
+.I n
+may be referred to as
+.BR %n .
+A job may also be referred to using a prefix of the name used to
+start it, or using a substring that appears in its command line.
+For example,
+.B %ce
+refers to a stopped
+.B ce
+job. If a prefix matches more than one job,
+.B bash
+reports an error. Using
+.BR %?ce ,
+on the other hand, refers to any job containing the string
+.B ce
+in its command line. If the substring matches more than one job,
+.B bash
+reports an error. The symbols
+.B %%
+and
+.B %+
+refer to the shell's notion of the
+.IR "current job" ,
+which is the last job stopped while it was in
+the foreground.
+The
+.I "previous job"
+may be referenced using
+.BR %\- .
+In output pertaining to jobs (e.g., the output of the
+.B jobs
+command), the current job is always flagged with a
+.BR + ,
+and the previous job with a
+.BR \- .
.PP
-The environment for any
-.I simple command
-or function may be augmented temporarily by prefixing it with
-parameter assignments, as described above in
-.SM
-.BR PARAMETERS .
-These assignment statements affect only the environment seen
-by that command.
+Simply naming a job can be used to bring it into the
+foreground:
+.B %1
+is a synonym for
+\fB``fg %1''\fP,
+bringing job 1 from the background into the foreground.
+Similarly,
+.B ``%1 &''
+resumes job 1 in the background, equivalent to
+\fB``bg %1''\fP.
.PP
-If the
-.B \-k
-flag is set (see the
+The shell learns immediately whenever a job changes state.
+Normally,
+.B bash
+waits until it is about to print a prompt before reporting
+changes in a job's status so as to not interrupt
+any other output. If the
+.B \-b
+option to the
.B set
-builtin command below), then
-.I all
-parameter assignments are placed in the environment for a command,
-not just those that precede the command name.
-.PP
-When
+builtin command
+is set,
.B bash
-invokes an external command, the variable
-.B _
-is set to the full path name of the command and passed to that
-command in its environment.
-.SH "EXIT STATUS"
-For the purposes of the shell, 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.
-.PP
-If a command is not found, the child process created to
-execute it returns a status of 127. If a command is found
-but is not executable, the return status is 126.
+reports such changes immediately.
.PP
-\fBBash\fP itself returns the exit status of the last command
-executed, unless a syntax error occurs, in which case it exits
-with a non\-zero value. See also the \fBexit\fP builtin
-command below.
+If an attempt to exit
+.B bash
+is made while jobs are stopped, the shell prints a warning message. The
+.B jobs
+command may then be used to inspect their status.
+If a second attempt to exit is made without an intervening command,
+the shell does not print another warning, and the stopped
+jobs are terminated.
.SH PROMPTING
When executing interactively,
.B bash
.RS
.PD 0
.TP
-.B \et
-the current time in HH:MM:SS format
+.B \ea
+an ASCII bell character (07)
.TP
.B \ed
the date in "Weekday Month Date" format (e.g., "Tue May 26")
.TP
+.B \ee
+an ASCII escape character (033)
+.TP
+.B \eh
+the hostname up to the first `.'
+.TP
+.B \eH
+the hostname
+.TP
.B \en
newline
.TP
.B $0
(the portion following the final slash)
.TP
-.B \ew
-the current working directory
+.B \et
+the current time in 24-hour HH:MM:SS format
.TP
-.B \eW
-the basename of the current working directory
+.B \eT
+the current time in 12-hour HH:MM:SS format
+.TP
+.B \e@
+the current time in 12-hour am/pm format
.TP
.B \eu
the username of the current user
.TP
-.B \eh
-the hostname
+.B \ev
+the version of \fBbash\fP (e.g., 2.00)
.TP
-.B \e#
-the command number of this command
+.B \eV
+the release of \fBbash\fP, version + patchlevel (e.g., 2.00.0)
+.TP
+.B \ew
+the current working directory
+.TP
+.B \eW
+the basename of the current working directory
.TP
.B \e!
the history number of this command
.TP
+.B \e#
+the command number of this command
+.TP
.B \e$
if the effective UID is 0, a
.BR # ,
otherwise a
.B $
.TP
-.B \ennn
-the character corresponding to the octal number \fBnnn\fP
+.B \e\fInnn\fP
+the character corresponding to the octal number \fInnn\fP
.TP
.B \e\e
a backslash
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, and word splitting.
+parameter expansion, command substitution, arithmetic expansion,
+string expansion, and quote removal, subject to the value of the
+.B promptvars
+shell option (see the description of the
+.B shopt
+command under
+.SM
+.B "SHELL BUILTIN COMMANDS"
+below).
.SH READLINE
This is the library that handles reading input when using an interactive
shell, unless the
-.B \-nolineediting
-option is given. By default, the line editing commands
-are similar to those of emacs.
+.B \-noediting
+option is given at shell invocation.
+By default, the line editing commands are similar to those of emacs.
A vi-style line editing interface is also available.
+To turn off line editing after the shell is running, use the
+.B +o emacs
+or
+.B +o vi
+options to the
+.B set
+builtin (see
+.SM
+.B SHELL BUILTIN COMMANDS
+below).
+.SS "Readline Notation"
.PP
In this section, the emacs-style notation is used to denote
keystrokes. Control keys are denoted by C\-\fIkey\fR, e.g., C\-n
.I x
key.)
.PP
-The default key-bindings may be changed with an
-.FN ~/.inputrc
-file. The value of the shell variable
+Readline commands may be given numeric
+.IR arguments ,
+which normally act as a repeat count.
+Sometimes, however, it is the sign of the argument that is significant.
+Passing a negative argument to a command that acts in the forward
+direction (e.g., \fBkill\-line\fP) causes that command to act in a
+backward direction.
+Commands whose behavior with arguments deviates from this are noted
+below.
+.PP
+When a command is described as \fIkilling\fP text, the text
+deleted is saved for possible future retrieval
+(\fIyanking\fP). The killed text is saved in a
+\fIkill ring\fP. Consecutive kills cause the text to be
+accumulated into one unit, which can be yanked all at once.
+Commands which do not kill text separate the chunks of text
+on the kill ring.
+.SS "Readline Initialization"
+.PP
+Readline is customized by putting commands in an initialization
+file (the \fIinputrc\fP file).
+The name of this file is taken from the value of the
.SM
-.BR INPUTRC ,
-if set, is used instead of
+.B INPUTRC
+variable. If that variable is unset, the default is
.IR ~/.inputrc .
+When a program which uses the readline library starts up, the
+initialization file is read, and the key bindings and variables
+are set.
+There are only a few basic constructs allowed in the
+readline initialization file.
+Blank lines are ignored.
+Lines beginning with a \fB#\fP are comments.
+Lines beginning with a \fB$\fP indicate conditional constructs.
+Other lines denote key bindings and variable settings.
+.PP
+The default key-bindings may be changed with an
+.I inputrc
+file.
Other programs that use this library may add their own commands
and bindings.
.PP
C\-Meta\-u: universal\-argument
.RE
into the
-.FN ~/.inputrc
+.I inputrc
would make M\-C\-u execute the readline command
.IR universal\-argument .
.PP
.IR TAB .
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).
-.PP
-Readline is customized by putting commands in an initialization
-file. The name of this file is taken from the value of the
-.SM
-.B INPUTRC
-variable. If that variable is unset, the default is
-.IR ~/.inputrc .
-When a program which uses the readline library starts up, the
-init file is read, and the key bindings and variables are set.
-There are only a few basic constructs allowed in the
-readline init file. Blank lines are ignored.
-Lines beginning with a \fB#\fP are comments.
-Lines beginning with a \fB$\fP indicate conditional
-constructs. Other lines
-denote key bindings and variable settings.
+.SS "Readline Key Bindings"
.PP
The syntax for controlling key bindings in the
.I ~/.inputrc
file is simple. All that is required is the name of the
command or the text of a macro and a key sequence to which
it should be bound. The name may be specified in one of two ways:
-as a symbolic key name, possibly with \fIMeta-\fP or \fIControl-\fP
+as a symbolic key name, possibly with \fIMeta\-\fP or \fIControl\-\fP
prefixes, or as a key sequence.
-When using the form \fBkeyname\fP:\fIfunction-name\fP or \fImacro\fP,
+When using the form \fBkeyname\fP:\fIfunction\-name\fP or \fImacro\fP,
.I keyname
is the name of a key spelled out in English. For example:
.sp
.br
Meta-Rubout: backward-kill-word
.br
-Control-o: ">&output"
+Control-o: "> output"
.RE
.LP
In the above example,
-.I C-u
+.I C\-u
is bound to the function
.BR universal\-argument ,
-.I M-DEL
+.I M\-DEL
is bound to the function
.BR backward\-kill\-word ,
and
-.I C-o
+.I C\-o
is bound to run the macro
expressed on the right hand side (that is, to insert the text
-.I >&output
+.I "> output"
into the line).
.PP
-In the second form, \fB"keyseq"\fP:\fIfunction-name\fP or \fImacro\fP,
+In the second form, \fB"keyseq"\fP:\fIfunction\-name\fP or \fImacro\fP,
.B keyseq
differs from
.B keyname
used, as in the following example.
.sp
.RS
-"\eC-u": universal\-argument
+"\eC\-u": universal\-argument
.br
-"\eC-x\eC-r": re\-read\-init\-file
+"\eC\-x\eC\-r": re\-read\-init\-file
.br
"\ee[11~": "Function Key 1"
.RE
.PP
In this example,
-.I C-u
+.I C\-u
is again bound to the function
.BR universal\-argument .
-.I "C-x C-r"
+.I "C\-x C\-r"
is bound to the function
.BR re\-read\-init\-file ,
and
.B \eC\-
control prefix
.TP
-.B \eM-
+.B \eM\-
meta prefix
.TP
.B \ee
.SM
.B SHELL BUILTIN COMMANDS
below).
+.SS "Readline Variables"
.PP
Readline has variables that can be used to further customize its
behavior. A variable may be set in the
.PP
.PD 0
.TP
-.B horizontal\-scroll\-mode (Off)
-When set to \fBOn\fP, makes readline use a single line for display,
-scrolling the input horizontally on a single screen line when it
-becomes longer than the screen width rather than wrapping to a new line.
-.TP
-.B editing\-mode (emacs)
-Controls whether readline begins with a set of key bindings similar
-to \fIemacs\fP or \fIvi\fP.
-.B editing\-mode
-can be set to either
-.B emacs
-or
-.BR vi .
-.TP
-.B mark\-modified\-lines (Off)
-If set to \fBOn\fP, history lines that have been modified are displayed
-with a preceding asterisk (\fB*\fP).
-.TP
.B bell\-style (audible)
Controls what happens when readline wants to ring the terminal bell.
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 in \fBvi\fP mode when the
-.B vi\-comment
+The string that is inserted when the
+.B readline
+.B insert\-comment
command is executed.
-.TP
-.B meta\-flag (Off)
-If set to \fBOn\fP, readline will enable eight-bit input (that is,
-it will not strip the high bit from the characters it reads),
-regardless of what the terminal claims it can support.
-.TP
-.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
-escape character (in effect, using escape as the \fImeta prefix\fP).
-.TP
-.B output\-meta (Off)
-If set to \fBOn\fP, readline will display characters with the
-eighth bit set directly rather than as a meta-prefixed escape
-sequence.
+This command is bound to
+.B M\-#
+in emacs mode and to
+.B #
+in vi command mode.
.TP
.B completion\-query\-items (100)
This determines when the user is queried about viewing
or not he wishes to view them; otherwise they are simply listed
on the terminal.
.TP
+.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
+escape character (in effect, using escape as the \fImeta prefix\fP).
+.TP
+.B disable\-completion (Off)
+If set to \fBOn\fP, readline will inhibit word completion. Completion
+characters will be inserted into the line as if they had been
+mapped to \fBself-insert\fP.
+.TP
+.B editing\-mode (emacs)
+Controls whether readline begins with a set of key bindings similar
+to \fIemacs\fP or \fIvi\fP.
+.B editing\-mode
+can be set to either
+.B emacs
+or
+.BR vi .
+.TP
+.B enable\-keypad (Off)
+When set to \fBOn\fP, readline will try to enable the application
+keypad when it is called. Some systems need this to enable the
+arrow keys.
+.TP
+.B expand\-tilde (Off)
+If set to \fBon\fP, tilde expansion is performed when readline
+attempts word completion.
+.TP
+.B horizontal\-scroll\-mode (Off)
+When set to \fBOn\fP, makes readline use a single line for display,
+scrolling the input horizontally on a single screen line when it
+becomes longer than the screen width rather than wrapping to a new line.
+.TP
+.B input\-meta (Off)
+If set to \fBOn\fP, readline will enable eight-bit input (that is,
+it will not strip the high bit from the characters it reads),
+regardless of what the terminal claims it can support. The name
+.B meta\-flag
+is a synonym for this variable.
+.TP
.B keymap (emacs)
Set the current readline keymap. The set of legal keymap names is
-\fIemacs, emacs-standard, emacs-meta, emacs-ctlx, vi, vi-move,
-vi-command\fP, and
-.IR vi-insert .
-\fIvi\fP is equivalent to \fIvi-command\fP; \fIemacs\fP is
-equivalent to \fIemacs-standard\fP. The default value is
+\fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi,
+vi\-command\fP, and
+.IR vi\-insert .
+\fIvi\fP is equivalent to \fIvi\-command\fP; \fIemacs\fP is
+equivalent to \fIemacs\-standard\fP. The default value is
.IR emacs ;
the value of
.B editing\-mode
also affects the default keymap.
.TP
+.B mark\-directories (On)
+If set to \fBOn\fP, completed directory names have a slash
+appended.
+.TP
+.B mark\-modified\-lines (Off)
+If set to \fBOn\fP, history lines that have been modified are displayed
+with a preceding asterisk (\fB*\fP).
+.TP
+.B output\-meta (Off)
+If set to \fBOn\fP, readline will display characters with the
+eighth bit set directly rather than as a meta-prefixed escape
+sequence.
+.TP
.B show\-all\-if\-ambiguous (Off)
This alters the default behavior of the completion functions. If
set to
words which have more than one possible completion cause the
matches to be listed immediately instead of ringing the bell.
.TP
-.B expand\-tilde (Off)
-If set to \fBon\fP, tilde expansion is performed when readline
-attempts word completion.
+.B visible\-stats (Off)
+If set to \fBOn\fP, a character denoting a file's type as reported
+by \fIstat\fP(2) is appended to the filename when listing possible
+completions.
.PD
+.SS "Readline Conditional Constructs"
.PP
Readline implements a facility similar in spirit to the conditional
compilation features of the C preprocessor which allows key
whether readline is in emacs or vi mode.
This may be used in conjunction
with the \fBset keymap\fP command, for instance, to set bindings in
-the \fIemacs-standard\fP and \fIemacs-ctlx\fP keymaps only if
+the \fIemacs\-standard\fP and \fIemacs\-ctlx\fP keymaps only if
readline is starting out in emacs mode.
.IP \fBterm\fP
The \fBterm=\fP form may be used to include terminal-specific
for instance.
.IP \fBapplication\fP
The \fBapplication\fP construct is used to include
-application\-specific settings. Each program using the readline
+application-specific settings. Each program using the readline
library sets the \fIapplication name\fP, and an initialization
file can test for a particular value.
This could be used to bind key sequences to functions useful for
.nf
\fB$if\fP Bash
# Quote the current or previous word
-"\eC-xq": "\eeb\e"\eef\e""
+"\eC\-xq": "\eeb\e"\eef\e""
\fB$endif\fP
.fi
.RE
.IP \fB$else\fP
Commands in this branch of the \fB$if\fP directive are executed if
the test fails.
+.SS Searching
.PP
-Readline commands may be given numeric
-.IR arguments ,
-which normally act as a repeat count. Sometimes, however, it is the
-sign of the argument that is significant. Passing a negative argument
-to a command that acts in the forward direction (e.g., \fBkill\-line\fP)
-causes that command to act in a backward direction. Commands whose
-behavior with arguments deviates from this are noted.
-.PP
-When a command is described as \fIkilling\fP text, the text
-deleted is saved for possible future retrieval
-(\fIyanking\fP). The killed text is saved in a
-\fIkill\-ring\fP. Consecutive kills cause the text to be
-accumulated into one unit, which can be yanked all at once.
-Commands which do not kill text separate the chunks of text
-on the kill\-ring.
+Readline provides commands for searching through the command history
+(see
+.SM
+.B HISTORY
+below) for lines containing a specified string.
+There are two search modes:
+.I incremental
+and
+.IR non-incremental .
+.PP
+Incremental searches begin before the user has finished typing the
+search string.
+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 Escape character is used to terminate an incremental search.
+Control-J will also terminate the search.
+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.
+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
+entry matching the search string typed so far.
+Any other key sequence bound to a readline command will terminate
+the search and execute that command.
+For instance, a \fInewline\fP will terminate the search and accept
+the line, thereby executing the command from the history list.
+.PP
+Non-incremental searches read the entire search string before starting
+to search for matching history lines. The search string may be
+typed by the user or part of the contents of the current line.
+.SS "Readline Command Names"
.PP
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.
.SS Commands for Moving
.PP
.PD 0
screen.
.TP
.B redraw\-current\-line
-Refresh the current line. By default, this is unbound.
+Refresh the current line.
.PD
.SS Commands for Manipulating the History
.PP
.TP
.B accept\-line (Newline, Return)
Accept the line regardless of where the cursor is. If this line is
-non\-empty, add it to the history list according to the state of the
+non-empty, add it to the history list according to the state of the
.SM
.B HISTCONTROL
variable. If the line is a modified history
.TP
.B non\-incremental\-reverse\-search\-history (M\-p)
Search backward through the history starting at the current line
-using a non\-incremental search for a string supplied by the user.
+using a non-incremental search for a string supplied by the user.
.TP
.B non\-incremental\-forward\-search\-history (M\-n)
-Search forward through the history using a non\-incremental search for
+Search forward through the history using a non-incremental search for
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 point. This
-is a non-incremental search. By default, this command is unbound.
+between the start of the current line and the current cursor
+position (the \fIpoint\fP).
+This is a non-incremental search.
.TP
.B history\-search\-backward
Search backward through the history for the string of characters
-between the start of the current line and the current point. This
-is a non-incremental search. By default, this command is unbound.
+between the start of the current line and the point.
+This is a non-incremental search.
.TP
.B yank\-nth\-arg (M\-C\-y)
Insert the first argument to the previous command (usually
.TP
.B
yank\-last\-arg (M\-.\^, M\-_\^)
-Insert the last argument to the previous command (the last word on
-the previous line). With an argument,
-behave exactly like \fByank-nth-arg\fP.
+Insert the last argument to the previous command (the last word of
+the previous history entry). With an argument,
+behave exactly like \fByank\-nth\-arg\fP.
.TP
.B shell\-expand\-line (M\-C\-e)
Expand the line the way the shell does when it reads it. This
.B insert\-last\-argument (M\-.\^, M\-_\^)
A synonym for \fByank\-last\-arg\fP.
.TP
-.B operate-and-get-next (C\-o)
+.B operate\-and\-get\-next (C\-o)
Accept the current line for execution and fetch the next line
relative to the current line from the history for editing. Any
argument is ignored.
.TP
.B backward\-delete\-char (Rubout)
Delete the character behind the cursor. When given a numeric argument,
-save the deleted text on the kill\-ring.
+save the deleted text on the kill ring.
.TP
.B quoted\-insert (C\-q, C\-v)
Add the next character that you type to the line verbatim. This is
how to insert characters like \fBC\-q\fP, for example.
.TP
-.B tab\-insert (C-v TAB)
+.B tab\-insert (C\-v TAB)
Insert a tab character.
.TP
.B self\-insert (a,\ b,\ A,\ 1,\ !,\ ...)
.B kill\-line (C\-k)
Kill the text from the current cursor position to the end of the line.
.TP
-.B backward\-kill\-line (C\-x C\-Rubout)
+.B backward\-kill\-line (C\-x Rubout)
Kill backward to the beginning of the line.
.TP
.B unix\-line\-discard (C\-u)
.TP
.B kill\-whole\-line
Kill all characters on the current line, no matter where the
-cursor is. By default, this is unbound.
+cursor is.
.TP
.B kill\-word (M\-d)
Kill from the cursor to the end of the current word, or if between
.TP
.B unix\-word\-rubout (C\-w)
Kill the word behind the cursor, using white space as a word boundary.
-The word boundaries are different from backward\-kill\-word.
+The word boundaries are different from \fBbackward\-kill\-word\fP.
+.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.
+.TP
+.B copy\-region\-as\-kill
+Copy the text in the region to the kill buffer.
.TP
-.B delete\-horizontal\-space
-Delete all spaces and tabs around point. By default, this is unbound.
+.B copy\-backward\-word
+Copy the word before point to the kill buffer.
+.TP
+.B copy\-forward\-word
+Copy the word following point to the kill buffer.
.TP
.B yank (C\-y)
Yank the top of the kill ring into the buffer at the cursor.
.TP
.B yank\-pop (M\-y)
-Rotate the kill\-ring, and yank the new top. Only works following
+Rotate the kill ring, and yank the new top. Only works following
.B yank
or
.BR yank\-pop .
.B universal\-argument
Each time this is executed, the argument count is multiplied by four.
The argument count is initially one, so executing this function the
-first time makes the argument count four. By default, this is not
-bound to a key.
+first time makes the argument count four.
.PD
.SS Completing
.PP
command (including aliases and functions) in turn. If none
of these produces a match, filename completion is attempted.
.TP
-.B possible\-completions (M-?)
+.B possible\-completions (M\-?)
List the possible completions of the text before point.
.TP
-.B insert\-completions
+.B insert\-completions (M\-*)
Insert all completions of the text before point
that would have been generated by
-\fBpossible\-completions\fP. By default, this
-is not bound to a key.
+\fBpossible\-completions\fP.
.TP
.B complete\-filename (M\-/)
Attempt filename completion on the text before point.
List the possible completions of the text before point,
treating it as a command name.
.TP
-.B dynamic\-complete\-history (M-TAB)
+.B dynamic\-complete\-history (M\-TAB)
Attempt completion on the text before point, comparing
the text against lines from the history list for possible
completion matches.
.PP
.PD 0
.TP
-.B start\-kbd\-macro (C-x (\^)
+.B start\-kbd\-macro (C\-x (\^)
Begin saving the characters typed into the current keyboard macro.
.TP
-.B end\-kbd\-macro (C-x )\^)
+.B end\-kbd\-macro (C\-x )\^)
Stop saving the characters typed into the current keyboard macro
-and save the definition.
+and store the definition.
.TP
-.B call\-last\-kbd\-macro (C-x e)
+.B call\-last\-kbd\-macro (C\-x e)
Re-execute the last keyboard macro defined, by making the characters
in the macro appear as if typed at the keyboard.
.PD
.PD 0
.TP
.B re\-read\-init\-file (C\-x C\-r)
-Read in the contents of your init file, and incorporate
+Read in the contents of the \fIinputrc\fP file, and incorporate
any bindings or variable assignments found there.
.TP
.B abort (C\-g)
ring the terminal's bell (subject to the setting of
.BR bell\-style ).
.TP
-.B do\-uppercase\-version (M\-a, M\-b, ...)
-Run the command that is bound to the corresponding uppercase
-character.
+.B do\-uppercase\-version (M\-a, M\-b, M\-\fIx\fP, ...)
+If the metafied character \fIx\fP is lowercase, run the command
+that is bound to the corresponding uppercase character.
.TP
.B prefix\-meta (ESC)
Metafy the next character typed.
.B tilde\-expand (M\-~)
Perform tilde expansion on the current word.
.TP
+.B set\-mark (C\-@, M\-<space>)
+Set the mark to the current point. If a
+numeric argument is supplied, the mark is set to that position.
+.TP
+.B exchange\-point\-and\-mark (C\-x C\-x)
+Swap the point with the mark. The current cursor position is set to
+the saved position, and the old cursor position is saved as the mark.
+.TP
+.B character\-search (C\-])
+A character is read and point is moved to the next occurrence of that
+character. A negative count searches for previous occurrences.
+.TP
+.B character\-search\-backward (M\-C\-])
+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
+.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
+a shell comment.
+.TP
+.B glob\-expand\-word (C\-x *)
+The word before point is treated as a pattern for pathname expansion,
+and the list of matching file names is inserted, replacing the word.
+.TP
+.B glob\-list\-expansions (C\-x g)
+The list of expansions that would have been generated by
+.B glob\-expand\-word
+is displayed, and the line is redrawn.
+.TP
.B dump\-functions
Print all of the functions and their key bindings to the
readline output stream. If a numeric argument is supplied,
the output is formatted in such a way that it can be made part
of an \fIinputrc\fP file.
.TP
+.B dump\-variables
+Print all of the settable readline variables and their values to the
+readline output stream. If a numeric argument is supplied,
+the output is formatted in such a way that it can be made part
+of an \fIinputrc\fP file.
+.TP
+.B dump\-macros
+Print all of the readline key sequences bound to macros and the
+strings they ouput. If a numeric argument is supplied,
+the output is formatted in such a way that it can be made part
+of an \fIinputrc\fP file.
+.TP
.B display\-shell\-version (C\-x C\-v)
Display version information about the current instance of
.BR bash .
.PD
.SH HISTORY
-When interactive, the shell provides access to the \fIcommand history\fP,
+When the
+.B -o history
+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
.SM
.B HISTSIZE
.B EXPANSION
above) but after history expansion is performed, subject to the
values of the shell variables
-.B command_oriented_history
+.SM
+.B HISTIGNORE
and
.SM
.BR HISTCONTROL .
.SM
.B HISTFILESIZE
lines.
+When an interactive shell exits, the last
+.SM
+.B HISTSIZE
+lines are copied from the history list to
+.SM
+.BR HISTFILE .
+If the
+.B histappend
+shell option is enabled
+(see the description of
+.B shopt
+under
+.SM
+.B "SHELL BUILTIN COMMANDS"
+below), the lines are appended to the history file,
+otherwise the history file is overwritten.
+If
+.SM
+.B HISTFILE
+is unset, or if the history file is unwritable, the history is
+not saved. After saving the history, the history file is truncated
+to contain no more than
+.SM
+.B HISTFILESIZE
+lines. If
+.SM
+.B HISTFILESIZE
+is not set, no truncation is performed.
+.PP
The builtin command
.B fc
(see
the history list.
The
.B history
-builtin can be used to display the history list and manipulate the
-history file. When using the command-line editing, search commands
+builtin can be used to display or modify the history list and
+manipulate the history file.
+When using the command-line editing, search commands
are available in each editing mode that provide access to the
-history list. When an interactive shell exits, the last
-.SM
-.B HISTSIZE
-lines are copied from the history list to
+history list.
+.PP
+The shell allows control over which commands are saved on the history
+list. The
.SM
-.BR HISTFILE .
-If
+.B HISTCONTROL
+and
.SM
-.B HISTFILE
-is unset, or if the history file is unwritable, the history is
-not saved.
+.B HISTIGNORE
+variables may be set to cause the shell to save only a subset of the
+commands entered.
+The
+.B cmdhist
+shell option, if enabled, causes the shell to attempt to save each
+line of a multi-line command in the same history entry, adding
+semicolons where necessary to preserve syntactic correctness.
+The
+.B lithist
+shell option causes the shell to save the command with embedded newlines
+instead of semicolons. See the description of the
+.B shopt
+builtin below under
+.SM
+.B "SHELL BUILTIN COMMANDS"
+for information on setting and unsetting shell options.
.SH "HISTORY EXPANSION"
.PP
The shell supports a history expansion feature that
builtin command (see
.SM
.B SHELL BUILTIN COMMANDS
-below). Non-interactive shells do not perform history expansion.
+below). Non-interactive shells do not perform history expansion
+by default.
+.PP
+History expansions introduce words from the history list into
+the input stream, making it easy to repeat commands, insert the
+arguments to a previous command into the current input line, or
+fix errors in previous commands quickly.
.PP
History expansion is performed immediately after a complete line
is read, before the shell breaks it into words.
-It takes place in two parts. The first is to determine
-which line from the previous history to use during
-substitution. The second is to select portions of that line for
-inclusion into the current one. The line selected from the
-previous history is the \fIevent\fP, and the portions of that
-line that are acted upon are \fIwords\fP. The line is broken
-into words in the same fashion as when reading input, so that
-several \fImetacharacter\fP\-separated words surrounded by quotes
-are considered as one word. Only backslash (\^\fB\e\fP\^)
-and single quotes can quote
-the history escape character, which is \^\fB!\fP\^ by default.
+It takes place in two parts.
+The first is to determine which line from the previous history
+to use during substitution.
+The second is to select portions of that line for inclusion into
+the current one.
+The line selected from the previous history is the \fIevent\fP,
+and the portions of that line that are acted upon are \fIwords\fP.
+Various \fImodifiers\fP are available to manipulate the selected words.
+The line is broken into words in the same fashion as when reading input,
+so that several \fImetacharacter\fP-separated words surrounded by
+quotes are considered as one word.
+History expansions are introduced by the appearance of the
+history expansion character, which is \^\fB!\fP\^ by default.
+Only backslash (\^\fB\e\fP\^) and single quotes can quote
+the history expansion character.
+.PP
+Several shell options settable with the
+.B shopt
+builtin may be used to tailor the behavior of history expansion.
+If the
+.B histverify
+shell option is enabled (see the description of the
+.B shopt
+builtin), and
+.B readline
+is being used, history substitutions are not immediately passed to
+the shell parser.
+Instead, the expanded line is reloaded into the
+.B readline
+editing buffer for further modification.
+If
+.B readline
+is being used, and the
+.B histreedit
+shell option is enabled, a failed history substitution will be reloaded
+into the
+.B readline
+editing buffer for correction.
+The
+.B \-p
+option to the
+.B history
+builtin command may be used to see what a history expansion will
+do before using it.
+The
+.B \-s
+option to the
+.B history
+builtin may be used to add commands to the end of the history list
+without actually executing them, so that they are available for
+subsequent recall.
.PP
The shell allows control of the various characters used by the
history expansion mechanism (see the description of
.BR blank ,
newline, = or (.
.TP
-.B !!
-Refer to the previous command. This is a synonym for `!\-1'.
-.TP
.B !\fIn\fR
Refer to command line
.IR n .
Refer to the current command line minus
.IR n .
.TP
+.B !!
+Refer to the previous command. This is a synonym for `!\-1'.
+.TP
.B !\fIstring\fR
Refer to the most recent command starting with
.IR string .
.B !?\fIstring\fR\fB[?]\fR
Refer to the most recent command containing
.IR string .
+The trailing \fB?\fP may be omitted if
+.I string
+is followed immediately by a newline.
.TP
.B \d\s+2^\s-2\u\fIstring1\fP\d\s+2^\s-2\u\fIstring2\fP\d\s+2^\s-2\u
Quick substitution. Repeat the last command, replacing
.PD
.SS Word Designators
.PP
+Word designators are used to select desired words from the event.
A
.B :
-separates the event specification from the word
-designator. It can be omitted if the word designator begins with a
+separates the event specification from the word designator.
+It can be omitted if the word designator begins with a
.BR ^ ,
.BR $ ,
.BR * ,
+.BR \- ,
or
.BR % .
Words are numbered from the beginning of the line,
-with the first word being denoted by a 0 (zero).
+with the first word being denoted by 0 (zero).
+Words are inserted into the current line separated by single spaces.
.PP
.PD 0
.TP
.B x\-
Abbreviates \fIx\-$\fP like \fBx*\fP, but omits the last word.
.PD
+.PP
+If a word designator is supplied without an event specification, the
+previous command is used as the event.
.SS Modifiers
.PP
-After the optional word designator, you can add a sequence of one
-or more of the following modifiers, each preceded by a `:'.
+After the optional word designator, there may appear a sequence of
+one or more of the following modifiers, each preceded by a `:'.
.PP
.PD 0
.PP
.TP
.B h
-Remove a trailing pathname component, leaving only the head.
+Remove a trailing file name component, leaving only the head.
+.TP
+.B t
+Remove all leading file name components, leaving the tail.
.TP
.B r
Remove a trailing suffix of the form \fI.xxx\fP, leaving the
.B e
Remove all but the trailing suffix.
.TP
-.B t
-Remove all leading pathname components, leaving the tail.
-.TP
.B p
Print the new command but do not execute it.
.TP
.IR new ,
it is replaced by
.IR old .
-A single backslash will quote the &.
+A single backslash will quote the &. If
+.I old
+is null, it is set to the last
+.I old
+substituted, or, if no previous history substitutions took place,
+the last
+.I string
+in a
+.B !?\fIstring\fR\fB[?]\fR
+search.
.TP
.B &
Repeat the previous substitution.
.B ||
logical OR
.TP
+.B \fIexpr\fP?\fIexpr\fP:\fIexpr\fP
+conditional evaluation
+.TP
.B = *= /= %= += \-= <<= >>= &= ^= |=
assignment
.PD
turned on to be used in an expression.
.PP
Constants with a leading 0 are interpreted as octal numbers.
-A leading \fI0x\fP or \fI0X\fP denotes hexadecimal. Otherwise,
-numbers take the form [\fIbase#\fP]n, where \fIbase\fP is a
-decimal number between 2 and 36 representing the arithmetic
-base, and \fIn\fP is a number in that base. If \fIbase\fP is
-omitted, then base 10 is used.
+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.
+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
+letters may be used interchangably to represent numbers between 10
+and 35.
.PP
Operators are evaluated in order of precedence. Sub-expressions in
parentheses are evaluated first and may override the precedence
.SH "SHELL BUILTIN COMMANDS"
.\" start of bash_builtins
.zZ
+.PP
+Unless otherwise noted, each builtin command documented in this
+section as accepting options preceded by
+.B \-
+accepts
+.B \-\-
+to signify the end of the options.
+.sp .5
.PD 0
.TP
\fB:\fP [\fIarguments\fP]
.IR filename .
If
.I filename
-does not contain a slash, pathnames in
+does not contain a slash, file names in
.SM
.B PATH
are used to find the directory containing
searched if no file is found in
.SM
.BR PATH .
+If the
+.B sourcepath
+option to the
+.B shopt
+builtin command is turned off, the
+.SM
+.B PATH
+is not searched.
If any \fIarguments\fP are supplied, they become the positional
-parameters when \fIfile\fP is executed. Otherwise the positional
+parameters when \fIfilename\fP is executed. Otherwise the positional
parameters are unchanged.
The return status is the status of the last command exited within
the script (0 if no commands are executed), and false if
.I filename
is not found.
.TP
-\fBalias\fP [\fIname\fP[=\fIvalue\fP] ...]
-\fBAlias\fP with no arguments prints the list of aliases in the form
-\fIname\fP=\fIvalue\fP on standard output. When arguments are
-supplied, an alias is defined for
-each \fIname\fP
-whose \fIvalue\fP is given. A trailing space in
-\fIvalue\fP causes the next
-word to be checked for alias substitution when the alias is
-expanded. For each \fIname\fP in the argument list for which
-no \fIvalue\fP is supplied, the name and value of the alias is
-printed. \fBAlias\fP returns true
-unless a \fIname\fP is given for which no alias has been defined.
+\fBalias\fP [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
+\fBAlias\fP with no arguments or with the
+.B \-p
+option prints the list of aliases in the form
+\fBalias\fP \fIname\fP=\fIvalue\fP on standard output.
+When arguments are supplied, an alias is defined for
+each \fIname\fP whose \fIvalue\fP is given.
+A trailing space in \fIvalue\fP causes the next word to be
+checked for alias substitution when the alias is expanded.
+For each \fIname\fP in the argument list for which no \fIvalue\fP
+is supplied, the name and value of the alias is printed.
+\fBAlias\fP returns true unless a \fIname\fP is given for which
+no alias has been defined.
.TP
\fBbg\fP [\fIjobspec\fP]
Place \fIjobspec\fP in the background, as if it had been started with
job control.
.TP
.PD 0
-\fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-lvd\fP] [\fB-q\fP \fIname\fP]
+\fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-lpsvPSV\fP] [\fB\-q\fP \fIname\fP] [\fB\-r\fP \fIkeyseq\fP]
.TP
-\fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB-f\fP \fIfilename\fP
+\fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-f\fP \fIfilename\fP
.TP
-\fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fIkeyseq\fP:\fIfunction-name\fP
+\fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fIkeyseq\fP:\fIfunction\-name\fP
.PD
Display current
.B readline
function or macro. The binding syntax accepted is identical to that of
.IR .inputrc ,
but each binding must be passed as a separate argument;
-e.g., '"\eC-x\eC-r": re\-read\-init\-file'. Options, if supplied, have the
+e.g., '"\eC\-x\eC\-r": re\-read\-init\-file'. Options, if supplied, have the
following meanings:
.RS
.PD 0
Acceptable
.I keymap
names are
-\fIemacs, emacs-standard, emacs-meta, emacs-ctlx, vi, vi-move,
-vi-command\fP, and
-.IR vi-insert .
-\fIvi\fP is equivalent to \fIvi-command\fP; \fIemacs\fP is
-equivalent to \fIemacs-standard\fP.
+\fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi,
+vi\-command\fP, and
+.IR vi\-insert .
+\fIvi\fP is equivalent to \fIvi\-command\fP; \fIemacs\fP is
+equivalent to \fIemacs\-standard\fP.
.TP
.B \-l
-List the names of all \fBreadline\fP functions
+List the names of all \fBreadline\fP functions.
+.TP
+.B \-p
+Display \fBreadline\fP function names and bindings in such a way
+that they can be re-read.
+.TP
+.B \-P
+List current \fBreadline\fP function names and bindings.
.TP
.B \-v
-List current function names and bindings
+Display \fBreadline\fP variable names and values in such a way that they
+can be re-read.
.TP
-.B \-d
-Dump function names and bindings in such a way that they can be re-read
+.B \-V
+List current \fBreadline\fP variable names and values.
+.TP
+.B \-s
+Display \fBreadline\fP key sequences bound to macros and the strings
+they output in such a way that they can be re-read.
+.TP
+.B \-S
+Display \fBreadline\fP key sequences bound to macros and the strings
+they output.
.TP
.B \-f \fIfilename\fP
-Read key bindings from \fIfilename\fP
+Read key bindings from \fIfilename\fP.
.TP
.B \-q \fIfunction\fP
-Query about which keys invoke the named \fIfunction\fP
+Query about which keys invoke the named \fIfunction\fP.
+.TP
+.B \-r \fIkeyseq\fP
+Remove any current binding for \fIkeyseq\fP.
.PD
.PP
The return value is 0 unless an unrecognized option is given or an
Exit from within a
.BR for ,
.BR while ,
+.BR until ,
or
-.B until
+.B select
loop. If \fIn\fP is specified, break \fIn\fP levels.
.I n
must be \(>= 1. If
.I shell\-builtin
is not a shell builtin command.
.TP
-\fBcd\fP [\fIdir\fP]
+\fBcd\fP [\fB\-LP\fP] [\fIdir\fP]
Change the current directory to \fIdir\fP. The variable
.SM
.B HOME
The variable
.SM
.B CDPATH
-defines the search path for
-the directory containing
+defines the search path for the directory containing
.IR dir .
-Alternative directory names are
-separated by a colon (:). A null directory name in
+Alternative directory names in
+.SM
+.B CDPATH
+are separated by a colon (:). A null directory name in
.SM
.B CDPATH
-is the same as
-the current directory, i.e., ``\fB.\fP''. If
+is the same as the current directory, i.e., ``\fB.\fP''. If
.I dir
begins with a slash (/),
then
.SM
.B CDPATH
-is not used. An argument of
+is not used. The
+.B \-P
+option says to use the physical directory structure instead of
+following symbolic links (see also the
+.B \-P
+option to the
+.B set
+builtin command); the
+.B \-L
+option forces symbolic links to be followed. An argument of
.B \-
is equivalent to
.SM
The return value is true if the directory was successfully changed;
false otherwise.
.TP
-\fBcommand\fP [\fB-pVv\fP] \fIcommand\fP [\fIarg\fP ...]
+\fBcommand\fP [\fB\-pVv\fP] \fIcommand\fP [\fIarg\fP ...]
Run
.I command
with
.I command
is printed. The
.B \-v
-option causes a single word indicating the command or pathname
+option causes a single word indicating the command or file name
used to invoke
.I command
to be printed; the
.B \-V
option produces a more verbose description.
-An argument of
-.B \-\-
-disables option checking for the rest of the arguments.
If the
.B \-V
or
Resume the next iteration of the enclosing
.BR for ,
.BR while ,
+.BR until ,
or
-.B until
+.B select
loop.
If
.I n
must be \(>= 1. If
.I n
is greater than the number of enclosing loops, the last enclosing loop
-(the `top\-level' loop) is resumed. The return value is 0 unless the
+(the ``top-level'' loop) is resumed. The return value is 0 unless the
shell is not executing a loop when
.B continue
is executed.
.TP
.PD 0
-\fBdeclare\fP [\fB\-frxi\fP] [\fIname\fP[=\fIvalue\fP]]
+\fBdeclare\fP [\fB\-afFirx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP]]
.TP
-\fBtypeset\fP [\fB\-frxi\fP] [\fIname\fP[=\fIvalue\fP]]
+\fBtypeset\fP [\fB\-afFirx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP]]
.PD
-Declare variables and/or give them attributes. If no \fIname\fPs are
-given, then display the values of variables instead. The options can
-be used to restrict output to variables with the specified attribute.
+Declare variables and/or give them attributes.
+If no \fIname\fPs are given then display the values of variables.
+The
+.B \-p
+option will display the attributes and values of each
+.IR name .
+When
+.B \-p
+is used, additional options are ignored.
+The
+.B \-F
+option inhibits the display of function definitions; only the
+function name and attributes are printed.
+The
+.B \-F
+option implies
+.BR \-f .
+The following options can
+be used to restrict output to variables with the specified attribute or
+to give variables attributes:
.RS
.PD 0
.TP
+.B \-a
+Each \fIname\fP is an array variable (see
+.B Arrays
+above).
+.TP
.B \-f
-Use function names only
+Use function names only.
+.TP
+.B \-i
+The variable is treated as an integer; arithmetic evaluation (see
+.SM
+.B "ARITHMETIC EVALUATION" ") "
+is performed when the variable is assigned a value.
.TP
.B \-r
Make \fIname\fPs readonly. These names cannot then be assigned values
.TP
.B \-x
Mark \fIname\fPs for export to subsequent commands via the environment.
-.TP
-.B \-i
-The variable is treated as an integer; arithmetic evaluation (see
-.SM
-.B "ARITHMETIC EVALUATION" ") "
-is performed when the variable is assigned a value.
.PD
.PP
Using `+' instead of `\-'
-turns off the attribute instead. When used in a function, makes
-\fIname\fPs local, as with the
+turns off the attribute instead, with the exception that \fB+a\fP
+may not be used to destroy an array variable. When used in a function,
+makes each
+\fIname\fP local, as with the
.B local
command. The return value is 0 unless an illegal option is encountered,
-an attempt is made to define a function using "-f foo=bar",
-one of the \fInames\fP is not a legal shell variable name,
+an attempt is made to define a function using "\-f foo=bar",
+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
+.B Arrays
+above), one of the \fInames\fP is not a legal shell variable name,
an attempt is made to turn off readonly status for a readonly variable,
-or an attempt is made to display a non-existant function with -f.
+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.
.RE
.TP
-.B dirs [\fB-l\fP] [\fB+/\-n\fP]
-Display the list of currently remembered directories. Directories
-are added to the list with the
+.B dirs [\fB\-clpv\fP] [+\fIn\fP] [\-\fIn\fP]
+Without options, displays the list of currently remembered directories.
+The default display is on a single line with directory names separated
+by spaces.
+Directories are added to the list with the
.B pushd
command; the
.B popd
-command moves back up through the list.
+command removes entries from the list.
.RS
.PD 0
.TP
-.B +n
-displays the \fIn\fPth entry counting from the left of the list
+\fB+\fP\fIn\fP
+Displays the \fIn\fPth entry counting from the left of the list
shown by
.B dirs
when invoked without options, starting with zero.
.TP
-.B \-n
-displays the \fIn\fPth entry counting from the right of the list
+\fB\-\fP\fIn\fP
+Displays the \fIn\fPth entry counting from the right of the list
shown by
.B dirs
when invoked without options, starting with zero.
.TP
+.B \-c
+Clears the directory stack by deleting all of the entries.
+.TP
.B \-l
-produces a longer listing; the default listing format uses a
+Produces a longer listing; the default listing format uses a
tilde to denote the home directory.
+.TP
+.B \-p
+Print the directory stack with one entry per line.
+.TP
+.B \-v
+Print the directory stack with one entry per line,
+prefixing each entry with its index in the stack.
.PD
.PP
The return value is 0 unless an
of the directory stack.
.RE
.TP
+\fBdisown\fP [\fB\-h\fP] [\fIjobspec\fP ...]
+Without options, each
+.I jobspec
+is removed from the table of active jobs.
+If the \fB\-h\fP option is given, the job is not removed from the table,
+but is marked so that
+.SM
+.B SIGHUP
+is not sent to the job if the shell receives a
+.SM
+.BR SIGHUP .
+If no
+.I jobspec
+is present, the \fIcurrent job\fP is used. The return value is
+0 unless a
+.I jobspec
+does not specify a valid job.
+.TP
\fBecho\fP [\fB\-neE\fP] [\fIarg\fP ...]
-Output the \fIarg\fPs, separated by spaces. The return status is
-always 0. If \fB\-n\fP is specified, the trailing newline is
+Output the \fIarg\fPs, separated by spaces, followed by a newline.
+The return status is always 0.
+If \fB\-n\fP is specified, the trailing newline is
suppressed. If the \fB\-e\fP option is given, interpretation of
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.
+.B echo
+does not interpret
+.B \-\-
+to mean the end of options.
+.B echo
+interprets the following escape sequences:
.RS
.PD 0
.TP
.B \ec
suppress trailing newline
.TP
+.B \ee
+an escape character
+.TP
.B \ef
form feed
.TP
.PD
.RE
.TP
-\fBenable\fP [\fB\-n\fP] [\fB\-all\fP] [\fIname\fP ...]
+\fBenable\fP [\fB\-adnps\fP] [\fB\-f\fP \fIfilename\fP] [\fIname\fP ...]
Enable and disable builtin shell commands. This allows
the execution of a disk command which has the same name as a shell
-builtin without specifying a full pathname.
+builtin without specifying a full file name.
If \fB\-n\fP is used, each \fIname\fP
is disabled; otherwise,
\fInames\fP are enabled. For example, to use the
binary found via the
.SM
.B PATH
-instead of the shell builtin version, type
-``enable -n test''. If no arguments are given,
-a list of all enabled shell builtins is printed.
-If only \fB\-n\fP is supplied, a list of all disabled
-builtins is printed. If only \fB\-all\fP is supplied,
-the list printed includes all builtins, with an
+instead of the shell builtin version, run
+\f(CWenable -n test\fP.
+The
+.B \-f
+option means to load the new builtin command
+.I name
+from shared object
+.IR filename ,
+on systems that support dynamic loading. The
+.B \-d
+option will delete a builtin previously loaded with
+.BR \-f .
+If no \fIname\fP arguments are given, or if the
+.B \-p
+option is supplied, a list of shell builtins is printed.
+With no other option arguments, the list consists of all enabled
+shell builtins.
+If \fB\-n\fP is supplied, only disabled builtins are printed.
+If \fB\-a\fP is supplied, the list printed includes all builtins, with an
indication of whether or not each is enabled.
-.B enable
-accepts
-.B \-a
-as a synonym for
-.BR \-all .
+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.
+is not a shell builtin or there is a problem loading a new builtin
+from a shared object.
.TP
\fBeval\fP [\fIarg\fP ...]
The \fIarg\fPs are read and concatenated together into a single
command. This command is then read and executed by the shell, and
-its exit status is returned as the value of the
-.B eval
-command. If there are no
+its exit status is returned as the value of
+.BR eval .
+If there are no
.IR args ,
or only null arguments,
.B eval
-returns true.
+returns 0.
.TP
-\fBexec\fP [[\fB\-\fP] \fIcommand\fP [\fIarguments\fP]]
+\fBexec\fP [\fB\-cl\fP] [\fB\-a\fP \fIname\fP] [\fIcommand\fP] [\fIarguments\fP]
If
.I command
is specified, it replaces the shell.
No new process is created. The
.I arguments
become the arguments to \fIcommand\fP.
-If the first argument is
-.BR \- ,
+If the
+.B \-l
+option is supplied,
the shell places a dash in the zeroth arg passed to
.IR command .
-This is what login does. If the file
+This is what
+.IR login (1)
+does. The
+.B \-c
+option causes
+.I command
+to be executed with an empty environment. If
+.B \-a
+is supplied, the shell passes
+.I name
+as the zeroth argument to the executed command. If
+.I command
cannot be executed for some reason, a non-interactive shell exits,
-unless the shell variable \fBno_exit_on_failed_exec\fP exists, in
-which case it returns failure. An interactive shell returns failure
-if the file cannot be executed.
+unless the shell option
+.B execfail
+is enabled, in which case it returns failure.
+An interactive shell returns failure if the file cannot be executed.
If
.I command
is not specified, any redirections take effect in the current shell,
is executed before the shell terminates.
.TP
.PD 0
-\fBexport\fP [\fB\-nf\fP\^] [\fIname\fP[=\fIword\fP]] ...
+\fBexport\fP [\fB\-fn\fP\^] [\fIname\fP[=\fIword\fP]] ...
.TP
.B export \-p
.PD
The
.B \-n
option causes the export property to be removed from the
-named variables. An argument of
-.B \-\-
-disables option checking for the rest of the arguments.
+named variables.
.B export
returns an exit status of 0 unless an illegal option is
encountered,
.sp 1
In the second form, \fIcommand\fP is re-executed after each instance
of \fIpat\fP is replaced by \fIrep\fP.
-A useful alias to use with this is ``r=fc \-s'',
-so that typing ``r cc''
-runs the last command beginning with ``cc'' and typing ``r''
+A useful alias to use with this is
+.if n ``r=fc -s'',
+.if t \f(CWr='fc \-s'\fP,
+so that typing
+.if n ``r cc''
+.if t \f(CWr cc\fP
+runs the last command beginning with
+.if n ``cc''
+.if t \f(CWcc\fP
+and typing
+.if n ``r''
+.if t \f(CWr\fP
re-executes the last command.
.sp 1
If the first form is used, the return value is 0 unless an illegal
It returns false if the end of options is encountered or an
error occurs.
.TP
-\fBhash\fP [\fB\-r\fP] [\fIname\fP]
+\fBhash\fP [\fB\-r\fP] [\fB\-p\fP \fIfilename\fP] [\fIname\fP]
For each
.IR name ,
-the full pathname of the command is determined
-and remembered. The
+the full file name of the command is determined by searching
+the directories in
+.B $PATH
+and remembered.
+If the
+.B \-p
+option is supplied, no path search is performed, and
+.I filename
+is used as the full file name of the command.
+The
.B \-r
option causes the shell to forget all
remembered locations. If no arguments are given, information
about remembered commands is printed.
-An argument of
-.B \-\-
-disables option checking for the rest of the arguments. The return
-status is true unless a
+The return status is true unless a
.I name
is not found or an illegal option is supplied.
.TP
.B help
gives detailed help on all commands matching
.IR pattern ;
-otherwise a list of the builtins is printed. The return status is 0
-unless no command matches
+otherwise help for all the builtins and shell control structures
+is printed. The return status is 0 unless no command matches
.IR pattern .
.TP
.PD 0
-\fBhistory\fP [\fIn\fP]
+\fBhistory\fP [\fB\-c\fP] [\fIn\fP]
+.TP
+\fBhistory\fP \fB\-anrw\fP [\fIfilename\fP]
.TP
-\fBhistory\fP \fB\-rwan\fP [\fIfilename\fP]
-.\".TP
-.\"\fBhistory\fP \fB\-s\fP \fIargs\fP
+\fBhistory\fP \fB\-p\fP \fIarg\fP [\fIarg ...\fP]
+.TP
+\fBhistory\fP \fB\-s\fP \fIarg\fP [\fIarg ...\fP]
.PD
With no options, display the command
history list with line numbers. Lines listed
.I n
lists only the last
.I n
-lines. If a non-option argument is supplied, it is used as the
+lines. If \fIfilename\fP is supplied, it is used as the
name of the history file; if not, the value of
.SM
.B HISTFILE
.TP
.B \-a
Append the ``new'' history lines (history lines entered since the
-beginning of the current \fBbash\fP session) to the history file
+beginning of the current \fBbash\fP session) to the history file.
.TP
.B \-n
Read the history lines not already read from the history
.TP
.B \-r
Read the contents of the history file
-and use them as the current history
+and use them as the current history.
.TP
.B \-w
Write the current history to the history file, overwriting the
history file's contents.
-.\".TP
-.\".B \-s
-.\"perform history
-.\"substitution on the following \fIargs\fP and display
-.\"the result on the standard output.
+.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.
+Does not store the results in the history list.
+Each \fIarg\fP must be quoted to disable normal history expansion.
+.TP
+.B \-s
+Store the
+.I args
+in the history list as a single entry. The last command in the
+history list is removed before the
+.I args
+are added.
.PD
.PP
The return value is 0 unless an illegal option is encountered or an
.RE
.TP
.PD 0
-\fBjobs\fP [\fB\-lnp\fP] [ \fIjobspec\fP ... ]
+\fBjobs\fP [\fB\-lnprs\fP] [ \fIjobspec\fP ... ]
.TP
\fBjobs\fP \fB\-x\fP \fIcommand\fP [ \fIargs\fP ... ]
.PD
-The first form lists the active jobs. The
+The first form lists the active jobs. The options have the following
+meanings:
+.RS
+.PD 0
+.TP
.B \-l
-option lists process IDs
-in addition to the normal information; the
+List process IDs
+in addition to the normal information.
+.TP
.B \-p
-option lists only the process ID of the job's process group
-leader. The
+List only the process ID of the job's process group
+leader.
+.TP
.B \-n
-option displays only jobs that have changed status since
-last notified. If
+Display information only about jobs that have changed status since
+the user was last notified of their status.
+.TP
+.B \-r
+Restrict output to running jobs.
+.TP
+.B \-s
+Restrict output to stopped jobs.
+.PD
+.PP
+If
.I jobspec
is given, output is restricted to information about that job.
The return status is 0 unless an illegal option is encountered
or an illegal
.I jobspec
is supplied.
-.sp 1
+.PP
If the
.B \-x
option is supplied,
passing it
.IR args ,
returning its exit status.
+.RE
.TP
.PD 0
-\fBkill\fP [\fB-s sigspec\fP | \fB\-sigspec\fP] [\fIpid\fP | \fIjobspec\fP] ...
+\fBkill\fP [\fB\-s\fP \fIsigspec\fP | \fB\-n\fP \fIsignum\fP | \fB\-\fP\fIsigspec\fP] [\fIpid\fP | \fIjobspec\fP] ...
.TP
-\fBkill\fP \fB\-l\fP [\fIsignum\fP]
+\fBkill\fP \fB\-l\fP [\fIsignum\fP | \fIsigspec\fP]
.PD
Send the signal named by
.I sigspec
+or
+.I signum
to the processes named by
.I pid
or
is either a signal name such as
.SM
.B SIGKILL
-or a signal number. If
+or a signal number;
+.I signum
+is a signal number. If
.I sigspec
-is a signal name, the name is case insensitive and may be
+is a signal name, the name may be
given with or without the
.SM
.B SIG
lists the signal names. If any arguments are supplied when
.B \-l
is given, the names of the specified signals are listed, and
-the return status is 0.
-An argument of
-.B \-\-
-disables option checking for the rest of the arguments.
+the return status is 0. The arguments to
+.B \-l
+may be either signal names or signal numbers; if signal names
+are given, the corresponding signal number is displayed.
.B kill
returns true if at least one signal was successfully sent, or false
if an error occurs or an illegal option is encountered.
.B logout
Exit a login shell.
.TP
-\fBpopd\fP [\fB+/\-n\fP]
+\fBpopd\fP [\-\fBn\fP] [+\fIn\fP] [\-\fIn\fP]
Removes entries from the directory stack. With no arguments,
removes the top directory from the stack, and performs a
.B cd
to the new top directory.
+Arguments, if supplied, have the following meanings:
.RS
.PD 0
.TP
-.B +n
-removes the \fIn\fPth entry counting from the left of the list
+\fB+\fP\fIn\fP
+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.
.TP
-.B \-n
-removes the \fIn\fPth entry counting from the right of the list
+\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.
+.TP
+.B \-n
+Suppresses the normal change of directory when removing directories
+from the stack, so that only the stack is manipulated.
.PD
.PP
If the
.RE
.TP
.PD 0
-\fBpushd\fP [\fIdir\fP]
+\fBpushd\fP [\fB\-n\fP] [\fIdir\fP]
.TP
-\fBpushd\fP \fB+/\-n\fP
+\fBpushd\fP [\fB\-n\fP] [+\fIn\fP] [\-\fIn\fP]
.PD
Adds a directory to the top of the directory stack, or rotates
the stack, making the new top of the stack the current working
directory. With no arguments, exchanges the top two directories
and returns 0, unless the directory stack is empty.
+Arguments, if supplied, have the following meanings:
.RS
.PD 0
.TP
-.B +n
+\fB+\fP\fIn\fP
Rotates the stack so that the \fIn\fPth directory
(counting from the left of the list shown by
.BR dirs )
is at the top.
.TP
-.B \-n
+\fB\-\fP\fIn\fP
Rotates the stack so that the \fIn\fPth directory
(counting from the right) is at the top.
.TP
+.B \-n
+Suppresses the normal change of directory when adding directories
+to the stack, so that only the stack is manipulated.
+.TP
.B dir
-adds
+Adds
.I dir
to the directory stack at the top, making it the
new current working directory.
fails. With the second form,
.B pushd
returns 0 unless the directory stack is empty,
-a non-existant directory stack element is specified,
+a non-existent directory stack element is specified,
or the directory change to the specified new current directory
fails.
.RE
.TP
-\fBpwd\fP
-Print the absolute pathname of the current working directory.
-The path printed contains no symbolic links if the
+\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
.B \-P
+option is supplied or the
+.B \-o physical
option to the
.B set
-builtin command is set.
-See also the description of
-.B nolinks
-under
-.B Shell Variables
-above). The return status is 0 unless an error occurs while
-reading the pathname of the current directory.
+builtin command is enabled.
+If the
+.B \-L
+option is used, symbolic links are followed.
+The return status is 0 unless an error occurs while
+reading the name of the current directory.
.TP
-\fBread\fP [\fB\-r\fP] [\fIname\fP ...]
+\fBread\fP [\fB\-er\fP] [\fB\-a\fP \fIaname\fP] [\fB\-p\fP \fIprompt\fP] [\fIname\fP ...]
One line is read from the standard input, and the first word
is assigned to the first
.IR name ,
.IR name ,
and so on, with leftover words assigned to the last
.IR name .
-Only the
-characters in
+Only the characters in
.SM
.B IFS
-are recognized as word delimiters. If no
+are recognized as word delimiters. Options, if supplied, have the
+following meanings:
+.RS
+.PD 0
+.TP
+.B \-r
+A backslash-newline pair is not ignored, and
+the backslash is considered to be part of the line.
+.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
+The words are assigned to sequential indices
+of the array variable
+.IR aname ,
+starting at 0.
+.I aname
+is unset before any new values are assigned.
+.TP
+.B \-e
+If the standard input
+is coming from a terminal,
+.B readline
+(see
+.SM
+.B READLINE
+above) is used to obtain the line.
+.PD
+.PP
+If no
.I names
are supplied, the line read is assigned to the variable
.SM
.BR REPLY .
-The return code is zero, unless end-of-file is encountered. If the
-.B \-r
-option
-is given, a backslash-newline pair is not ignored, and
-the backslash is considered to be part of the line.
-.TP
-.PD 0
-\fBreadonly\fP [\fB\-f\fP] [\fIname\fP ...]
+The return code is zero, unless end-of-file is encountered.
+.RE
.TP
-\fBreadonly -p\fP
+\fBreadonly\fP [\fB\-apf\fP] [\fIname\fP ...]
.PD
The given
-\fInames\fP are marked readonly and the values of these
-\fInames\fP
+\fInames\fP are marked readonly; the values of these
+.I names
may not be changed by subsequent assignment.
If the
.B \-f
option is supplied, the functions corresponding to the
\fInames\fP are so
-marked. If no arguments are given, or if the
+marked.
+The
+.B \-a
+option restricts the variables to arrays.
+If no
+.I name
+arguments are given, or if the
.B \-p
-option is supplied, a list of all readonly names
-is printed.
-An argument of
-.B \-\-
-disables option checking for the rest of the arguments. The
-return status is 0 unless an illegal option is encountered,
-one of the \fInames\fP is not a legal shell variable name, or
+option is supplied, a list of all readonly names is printed.
+The return status is 0 unless an illegal option is encountered,
+one of the
+.I names
+is not a legal shell variable name, or
.B \-f
is supplied with a
.I name
function and not during execution of a script by \fB.\fP\^,
the return status is false.
.TP
-\fBset\fP [\fB\-\-abefhkmnptuvxldCHP\fP] [\fB-o\fP \fIoption\fP] [\fIarg\fP ...]
+\fBset\fP [\fB\-\-abefhkmnptuvxBCHP\fP] [\fB\-o\fP \fIoption\fP] [\fIarg\fP ...]
+Without options, the name and value of each shell variable are displayed
+in a format that can be re-used as input.
+When options are specified, they set or unset shell attributes.
+Any arguments remaining after the options are processed are treated
+as values for the positional parameters and are assigned, in order, to
+.BR $1 ,
+.BR $2 ,
+.B ...
+.BR $\fIn\fP .
+Options, if specified, have the following meanings:
.RS
.PD 0
.TP 8
to the environment of subsequent commands.
.TP 8
.B \-b
-Cause the status of terminated background jobs to be reported
-immediately, rather than before the next primary prompt.
-(Also see
-.B notify
-under
-.B Shell Variables
-above).
+Report the status of terminated background jobs
+immediately, rather than before the next primary prompt. This is
+effective only when job control is enabled.
.TP 8
.B \-e
-Exit immediately if a \fIsimple-command\fP (see
+Exit immediately if a \fIsimple command\fP (see
.SM
.B SHELL GRAMMAR
-above) exits with a non\-zero status. The shell does not exit if the
+above) exits with a non-zero status. The shell does not exit if the
command that fails is part of an
.I until
or
statement, part of a
.B &&
or
-.B \(bv\|\(bv
+.B \(bv\(bv
list, or if the command's return value is
being inverted via
.BR ! .
Disable pathname expansion.
.TP 8
.B \-h
-Locate and remember function commands as functions are
-defined. Function commands are normally looked up when
-the function is executed.
+Remember the location of commands as they are looked up for execution.
+This is on by default.
.TP 8
.B \-k
-All keyword arguments are placed in the environment for a
-command, not just those that precede the command name.
+All arguments in the form of assignment statements
+are placed in the environment for a command, not just
+those that precede the command name.
.TP 8
.B \-m
Monitor mode. Job control is enabled. This flag is on
.TP 8
.B \-n
Read commands but do not execute them. This may be used to
-check a shell script for syntax errors. This is ignored for
+check a shell script for syntax errors. This is ignored by
interactive shells.
.TP 8
-.B \-o \fIoption-name\fP
-The \fIoption-name\fP can be one of the following:
+.B \-o \fIoption\-name\fP
+The \fIoption\-name\fP can be one of the following:
.RS
.TP 8
.B allexport
.BR \-a .
.TP 8
.B braceexpand
-The shell performs brace expansion (see
-.B Brace Expansion
-above). This is on by default.
+Same as
+.BR \-B .
.TP 8
.B emacs
Use an emacs-style command line editing interface. This is enabled
by default when the shell is interactive, unless the shell is started
with the
-.B \-nolineediting
+.B \-\-noediting
option.
.TP 8
.B errexit
Same as
.BR \-e .
.TP 8
+.B hashall
+Same as
+.BR \-h .
+.TP 8
.B histexpand
Same as
.BR \-H .
.TP 8
+.B history
+Enable command history, as described above under
+.SM
+.BR HISTORY .
+This option is on by default in interactive shells.
+.TP 8
.B ignoreeof
-The effect is as if the shell command `IGNOREEOF=10' had been executed
+The effect is as if the shell command \f(CWIGNOREEOF=10\fP had been executed
(see
.B Shell Variables
above).
.TP 8
-.B interactive\-comments
-Allow a word beginning with
-.B #
-to cause that word and all remaining characters on that
-line to be ignored in an interactive shell (see
-.SM
-.B COMMENTS
-above).
+.B keyword
+Same as
+.BR \-k .
.TP 8
.B monitor
Same as
Same as
.BR \-f .
.TP 8
-.B nohash
-Same as
-.BR \-d .
-.TP 8
.B notify
Same as
.BR \-b .
Same as
.BR \-u .
.TP 8
+.B onecmd
+Same as
+.BR \-t .
+.TP 8
.B physical
Same as
.BR \-P .
.TP 8
.B posix
-Change the behavior of bash where the default operation differs
-from the Posix 1003.2 standard to match the standard.
+Change the behavior of
+.B bash
+where the default operation differs
+from the POSIX 1003.2 standard to match the standard.
.TP 8
.B privileged
Same as
.B xtrace
Same as
.BR \-x .
+.sp .5
.PP
-If no \fIoption-name\fP is supplied, the values of the current options are
+If
+.B \-o
+is supplied with no \fIoption\-name\fP, the values of the current options are
printed.
+If
+.B +o
+is supplied with no \fIoption\-name\fP, a series of
+.B set
+commands to recreate the current option settings is displayed on
+the standard output.
.RE
.TP 8
.B \-p
Treat unset variables as an error when performing
parameter expansion. If expansion is attempted on an
unset variable, the shell prints an error message, and,
-if not interactive, exits with a non\-zero status.
+if not interactive, exits with a non-zero status.
.TP 8
.B \-v
Print shell input lines as they are read.
.TP 8
.B \-x
-After expanding each
-.IR simple-command ,
-.B bash
-displays the expanded value of
+After expanding each \fIsimple command\fP,
+display the expanded value of
.SM
.BR PS4 ,
followed by the command and its expanded arguments.
.TP 8
-.B \-l
-Save and restore the binding of \fIname\fP in a
-\fBfor\fP \fIname\fP [in \fBword\fP] command (see
-.SM
-.B SHELL GRAMMAR
-above).
-.TP 8
-.B \-d
-Disable the hashing of commands that are looked up for execution.
-Normally, commands are remembered in a hash table, and once
-found, do not have to be looked up again.
+.B \-B
+The shell performs brace expansion (see
+.B Brace Expansion
+above). This is on by default.
.TP 8
.B \-C
-The effect is as if the shell command `noclobber=' had been executed
-(see
-.B Shell Variables
-above).
+If set,
+.B bash
+does not overwrite an existing file with the
+.BR > ,
+.BR >& ,
+and
+.B <>
+redirection operators. This may be overridden when
+creating output files by using the redirection operator
+.B >|
+instead of
+.BR > .
.TP 8
.B \-H
Enable
default when the shell is interactive.
.TP 8
.B \-P
-If set, do not follow symbolic links when performing commands such as
+If set, the shell does not follow symbolic links when executing
+commands such as
.B cd
-which change the current directory. The physical directory is
-used instead.
+that change the current working directory. It uses the
+physical directory structure instead. By default,
+.B bash
+follows the logical chain of directories when performing commands
+which change the current directory.
.TP 8
.B \-\-
If no arguments follow this flag, then the positional parameters are
invocation of the shell. The current
set of flags may be found in
.BR $\- .
-After the option arguments are processed,
-the remaining \fIn\fP \fIarg\fPs are treated
-as values for the positional
-parameters and are assigned, in order, to
-.BR $1 ,
-.BR $2 ,
-.B ...
-.BR $\fIn\fP .
-If no options or \fIarg\fPs are supplied,
-all shell variables are printed. The return status is always true
+The return status is always true
unless an illegal option is encountered.
.RE
.TP
.B ....
Parameters represented by the numbers \fB$#\fP
down to \fB$#\fP\-\fIn\fP+1 are unset.
+.I n
+must be a non-negative number less than or equal to \fB$#\fP.
If
.I n
is 0, no parameters are changed.
If
.I n
is not given, it is assumed to be 1.
-.I n
-must be a non-negative number less than or equal to \fB$#\fP.
If
.I n
is greater than \fB$#\fP, the positional parameters are not changed.
-The return status is greater than 0 if
+The return status is greater than zero if
.I n
is greater than
.B $#
-or less than 0; otherwise 0.
+or less than zero; otherwise 0.
+.TP
+\fBshopt\fP [\fB\-pqsu\fP] [\fB\-o\fP] [\fIoptname\fP ...]
+Toggle the values of variables controlling optional shell behavior.
+With no options, or with the
+.B \-p
+option, a list of all settable options is displayed, with
+an indication of whether or not each is set. Other options have
+the following meanings:
+.RS
+.PD 0
+.TP
+.B \-s
+Enable (set) each \fIoptname\fP.
+.TP
+.B \-u
+Disable (unset) each \fIoptname\fP.
+.TP
+.B \-q
+Suppresses normal output (quiet mode); the return status indicates
+whether the \fIoptname\fP is set or unset.
+If multiple \fIoptname\fP arguments are given with
+.BR \-q ,
+the return status is zero if all \fIoptnames\fP are enabled; non-zero
+otherwise.
+.TP
+.B \-o
+Restricts the values of \fIoptname\fP to be those defined for the
+.B \-o
+option to the
+.B set
+builtin.
+.PD
+.PP
+If either
+.B \-s
+or
+.B \-u
+is used with no \fIoptname\fP arguments, the display is limited to
+those options which are set or unset, respectively.
+Unless otherwise noted, the \fBshopt\fP options are disabled (unset)
+by default.
+.PP
+The return status when listing options is zero if all \fIoptnames\fP
+are enabled, non-zero otherwise. When setting or unsetting options,
+the return status is zero unless an \fIoptname\fP is not a legal shell
+option.
+.PP
+The list of \fBshopt\fP options is:
+.if t .sp .5v
+.if n .sp 1v
+.PD 0
+.TP 8
+.B cdable_vars
+If set, an argument to the
+.B cd
+builtin command that
+is not a directory is assumed to be the name of a variable whose
+value is the directory to change to.
+.TP 8
+.B cdspell
+If set, minor errors in the spelling of a directory component in a
+.B cd
+command will be corrected.
+The errors checked for are transposed characters,
+a missing character, and one character too many.
+If a correction is found, the corrected file name is printed,
+and the command proceeds.
+This option is enabled by default, but is only used by interactive shells.
+.TP 8
+.B checkhash
+If set, \fBbash\fP checks that a command found in the hash
+table exists before trying to execute it. If a hashed command no
+longer exists, a normal path search is performed.
+.TP 8
+.B checkwinsize
+If set, \fBbash\fP checks the window size after each command
+and, if necessary, updates the values of
+.SM
+.B LINES
+and
+.SM
+.BR COLUMNS .
+.TP 8
+.B cmdhist
+If set,
+.B bash
+attempts to save all lines of a multiple-line
+command in the same history entry. This allows
+easy re-editing of multi-line commands.
+.TP 8
+.B dotglob
+If set,
+.B bash
+includes filenames beginning with a `.' in the results of pathname
+expansion.
+.TP 8
+.B execfail
+If set, a non-interactive shell will not exit if
+it cannot execute the file specified as an argument to the
+.B exec
+builtin command. An interactive shell does not exit if
+.B exec
+fails.
+.TP 8
+.B expand_aliases
+If set, aliases are expanded as described above under
+.SM
+.BR ALIASES .
+This option is enabled by default for interactive shells.
+.TP 8
+.B histappend
+If set, the history list is appended to the file named by the value
+of the
+.B HISTFILE
+variable when the shell exits, rather than overwriting the file.
+.TP 8
+.B histreedit
+If set, and
+.B readline
+is being used, a user is given the opportunity to re-edit a
+failed history substitution.
+.TP 8
+.B histverify
+If set, and
+.B readline
+is being used, the results of history substitution are not immediately
+passed to the shell parser. Instead, the resulting line is loaded into
+the \fBreadline\fP editing buffer, allowing further modification.
+.TP 8
+.B hostcomplete
+If set, and
+.B readline
+is being used, bash will attempt to perform hostname completion when a
+word beginning with \fB@\fP is being completed (see
+.B Completing
+under
+.SM
+.B READLINE
+above).
+This is enabled by default.
+.TP 8
+.B interactive_comments
+If set, allow a word beginning with
+.B #
+to cause that word and all remaining characters on that
+line to be ignored in an interactive shell (see
+.SM
+.B COMMENTS
+above). This option is enabled by default.
+.TP 8
+.B lithist
+If set, and the
+.B cmdhist
+option is enabled, multi-line commands are saved to the history with
+embedded newlines rather than using semicolon separators where possible.
+.TP 8
+.B mailwarn
+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 nullglob
+If set,
+.B bash
+allows patterns which match no
+files (see
+.B Pathname Expansion
+above)
+to expand to a null string, rather than themselves.
+.TP 8
+.B promptvars
+If set, prompt strings undergo variable and parameter expansion after
+being expanded as described in
+.SM
+.B PROMPTING
+above. This option is enabled by default.
+.TP 8
+.B shift_verbose
+If set, the
+.B shift
+builtin prints an error message when the shift count exceeds the
+number of positional parameters.
+.TP 8
+.B sourcepath
+If set, the
+\fBsource\fP (\fB.\fP) builtin uses the value of
+.SM
+.B PATH
+to find the directory containing the file supplied as an argument.
+This is enabled by default.
+.RE
.TP
\fBsuspend\fP [\fB\-f\fP]
Suspend the execution of this shell until it receives a
\fBtest\fP \fIexpr\fP
.TP
\fB[\fP \fIexpr\fP \fB]\fP
-Return a status of 0 (true) or 1 (false) depending on
+Return a status of 0 or 1 depending on
the evaluation of the conditional expression
.IR expr .
Expressions may be unary or binary. Unary
are string operators and numeric comparison operators as well. Each
operator and operand must be a separate argument. If \fIfile\fP
is of the form /dev/fd/\fIn\fP, then file descriptor \fIn\fP is
-checked.
+checked. Expressions are composed of the following primaries:
.RS
.PD 0
.TP
.B \-b \fIfile\fP
-True if \fIfile\fP exists and is block special.
+True if \fIfile\fP exists and is a block special file.
.TP
.B \-c \fIfile\fP
-True if \fIfile\fP exists and is character special.
+True if \fIfile\fP exists and is a character special file.
.TP
.B \-d \fIfile\fP
True if \fIfile\fP exists and is a directory.
modification date) than \fIfile2\fP.
.TP
\fIfile1\fP \-\fBot\fP \fIfile2\fP
-True if \fIfile1\fP is older than file2.
+True if \fIfile1\fP is older than \fIfile2\fP.
.TP
-\fIfile1\fP \fB\-ef\fP \fIfile\fP
+\fIfile1\fP \fB\-ef\fP \fIfile2\fP
True if \fIfile1\fP and \fIfile2\fP have the same device and
inode numbers.
.TP
+.B \-o \fIoptname\fP
+True if shell option
+.I optname
+is enabled.
+See the list of options under the description of the
+.B \-o
+option to the
+.B set
+builtin above.
+.TP
.B \-z \fIstring\fP
True if the length of \fIstring\fP is zero.
.TP
\fIstring\fP
True if the length of
.I string
-is non\-zero.
+is non-zero.
.TP
\fIstring1\fP \fB=\fP \fIstring2\fP
-True if the strings are equal.
+True if the strings are equal. \fB==\fP may be used in place of
+\fB=\fP.
.TP
\fIstring1\fP \fB!=\fP \fIstring2\fP
True if the strings are not equal.
.TP
+\fIstring1\fP \fB<\fP \fIstring2\fP
+True if \fIstring1\fP sorts before \fIstring2\fP lexicographically.
+.TP
+\fIstring1\fP \fB>\fP \fIstring2\fP
+True if \fIstring1\fP sorts after \fIstring2\fP lexicographically.
+.TP
.B ! \fIexpr\fP
True if
.I expr
.I expr2
is true.
.TP
-.I arg1 \fBOP\fP arg2
+.I \fIarg1\fP \fBOP\fP \fIarg2\fP
.SM
.B OP
is one of
or
.BR \-ge .
These arithmetic binary operators return true if \fIarg1\fP
-is equal, not-equal, less-than, less-than-or-equal,
-greater-than, or greater-than-or-equal than \fIarg2\fP,
-respectively.
+is equal to, not equal to, less than, less than or equal to,
+greater than, or greater than or equal to \fIarg2\fP, respectively.
.I Arg1
and
.I arg2
-may be positive integers, negative integers, or the special
-expression \fB\-l\fP \fIstring\fP, which evaluates to the
-length of
-.IR string .
+may be positive or negative integers.
.PD
.RE
.TP
Print the accumulated user and system times for the shell and
for processes run from the shell. The return status is 0.
.TP
-\fBtrap\fP [\fB\-l\fP] [\fIarg\fP] [\fIsigspec\fP]
+\fBtrap\fP [\fB\-lp\fP] [\fIarg\fP] [\fIsigspec\fP]
The command
.I arg
is to be read and executed when the shell receives
is the null string this
signal is ignored by the shell and by the
commands it invokes.
+If
+.I arg
+is
+.B \-p
+then the trap commands associated with
+each
+.I sigspec
+are displayed. If no arguments are supplied or if
+only
+.B \-p
+is given,
+.B trap
+prints the list of commands associated with each signal number.
.I sigspec
is either
-a signal name defined in <\fIsignal.h\fP>, or a signal number.
-If
+a signal name defined in <\fIsignal.h\fP>, or a signal number. If
.I sigspec
is
.SM
.B EXIT
(0) the command
.I arg
-is executed on exit from
-the shell. With no arguments,
-.B trap
-prints the list of commands associated with each signal number.
-The
+is executed on exit from the shell. If
+.I sigspec
+is
+.SM
+.BR DEBUG ,
+the command
+.I arg
+is executed after every \fIsimple command\fP (see
+.SM
+.B SHELL GRAMMAR
+above).
+The
.B \-l
-option causes the shell to
-print a list of signal names and their corresponding
-numbers. An argument of
-.B \-\-
-disables option checking for the rest of the arguments.
+option causes the shell to print a list of signal names and
+their corresponding numbers.
Signals ignored upon entry to the shell cannot be trapped or reset.
Trapped signals are reset to their original values in a child
-process when it is created. The return status is false if either
-the trap name or number is invalid; otherwise
+process when it is created. The return status is false if any
+.I sigspec
+is invalid; otherwise
.B trap
returns true.
.TP
.B \-type
flag is used,
.B type
-prints a phrase which is one of
+prints a string which is one of
.IR alias ,
.IR keyword ,
.IR function ,
if
.I name
is an alias, shell reserved word, function, builtin, or disk file,
-respectively. If the name is not found, then nothing is printed,
-and an exit status of false is returned.
+respectively.
+If the
+.I name
+is not found, then nothing is printed, and an exit status of false
+is returned.
If the
.B \-path
flag is used,
and
.BR \-path ,
respectively.
-An argument of
-.B \-\-
-disables option checking for the rest of the arguments.
.B type
returns true if any of the arguments are found, false if
none are found.
.TP
-\fBulimit\fP [\fB\-SHacdfmstpnuv\fP [\fIlimit\fP]]
-.B Ulimit
-provides control over the resources available to the shell and to
+\fBulimit\fP [\fB\-SHacdflmnpstuv\fP [\fIlimit\fP]]
+Provides control over the resources available to the shell and to
processes started by it, on systems that allow such control. The
value of
.I limit
can be a number in the unit specified for the resource, or the
value
.BR unlimited .
-The \fBH\fP and \fBS\fP options specify that the hard or soft limit is
+The \fB\-H\fP and \fB\-S\fP options specify that the hard or soft limit is
set for the given resource. A hard limit cannot be increased once it
is set; a soft limit may be increased up to the value of the hard limit.
-If neither \fBH\fP nor \fBS\fP is specified, the command applies to the
-soft limit. If
+If neither \fB\-H\fP nor \fB\-S\fP is specified, both the soft and hard
+limits are set.
+If
.I limit
is omitted, the current value of the soft limit of the resource is
-printed, unless the \fBH\fP option is given. When more than one resource
-is specified, the limit name and unit is printed before the value.
+printed, unless the \fB\-H\fP option is given. When more than one
+resource is specified, the limit name and unit are printed before the value.
Other options are interpreted as follows:
.RS
.PD 0
.TP
.B \-a
-all current limits are reported
+All current limits are reported
.TP
.B \-c
-the maximum size of core files created
+The maximum size of core files created
.TP
.B \-d
-the maximum size of a process's data segment
+The maximum size of a process's data segment
.TP
.B \-f
-the maximum size of files created by the shell
+The maximum size of files created by the shell
.TP
-.B \-m
-the maximum resident set size
+.B \-l
+The maximum size that may be locked into memory
.TP
-.B \-s
-the maximum stack size
+.B \-m
+The maximum resident set size
.TP
-.B \-t
-the maximum amount of cpu time in seconds
+.B \-n
+The maximum number of open file descriptors (most systems do not
+allow this value to be set)
.TP
.B \-p
-the pipe size in 512-byte blocks (this may not be set)
+The pipe size in 512-byte blocks (this may not be set)
.TP
-.B \-n
-the maximum number of open file descriptors (most systems do not
-allow this value to be set, only displayed)
+.B \-s
+The maximum stack size
+.TP
+.B \-t
+The maximum amount of cpu time in seconds
.TP
.B \-u
-the maximum number of processes available to a single user
+The maximum number of processes available to a single user
.TP
.B \-v
The maximum amount of virtual memory available to the shell
.PD
.PP
-An argument of
-.B \-\-
-disables option checking for the rest of the arguments. If
+If
.I limit
is given, it is the new value of the specified resource (the
.B \-a
is omitted, or if the
.B \-S
option is supplied, the
-current value of the mask is printed. The
+current value of the mask is printed.
+The
.B \-S
option causes the mask to be printed in symbolic form; the
default output is an octal number.
-An argument of
-.B \-\-
-disables option checking for the rest of the arguments. The
-return status is 0 if the mode was successfully changed or if
+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 ...]
\fBunset\fP [\-\fBfv\fP] [\fIname\fP ...]
For each
.IR name ,
-remove the corresponding variable or, given the
+remove the corresponding variable or function.
+If no options are supplied, or the
+.B \-v
+option is given, each
+.I name
+refers to a shell variable.
+Read-only variables may not be unset.
+If
.B \-f
-option, function.
-An argument of
-.B \-\-
-disables option checking for the rest of the arguments.
-Note that
-.SM
-.BR PATH ,
-.SM
-.BR IFS ,
-.SM
-.BR PPID ,
-.SM
-.BR PS1 ,
-.SM
-.BR PS2 ,
-.SM
-.BR UID ,
-and
-.SM
-.B EUID
-cannot be unset. If any of
+is specifed,
+each
+.I name
+refers to a shell function, and the function definition
+is removed.
+Each unset variable or function is removed from the environment
+passed to subsequent commands.
+If any of
.SM
.BR RANDOM ,
.SM
.BR SECONDS ,
.SM
.BR LINENO ,
+.SM
+.BR HISTCMD ,
or
.SM
-.B HISTCMD
+.B DIRSTACK
are unset, they lose their special properties, even if they are
subsequently reset. The exit status is true unless a
.I name
-does not exist or is non-unsettable.
+does not exist or is readonly.
.TP
\fBwait\fP [\fIn\fP]
Wait for the specified process and return its termination
is not given, all currently active child processes
are waited for, and the return status is zero. If
.I n
-specifies a non-existant process or job, the return status is
+specifies a non-existent process or job, the return status is
127. Otherwise, the return status is the exit status of the last
process or job waited for.
.\" bash_builtins
.if \n(zZ=1 .ig zZ
-.SH INVOCATION
-A \fIlogin shell\fP is one whose first character of argument zero is a
-.BR \- ,
-or one started with the
-.B \-login
-flag.
+.SH "RESTRICTED SHELL"
.PP
-An \fIinteractive\fP shell is one whose standard input and output are
-both connected to terminals (as determined by
-.IR isatty (3)),
-or one started with the
-.B \-i
-option.
-.SM
-.B PS1
-is set and
-.B $\-
-includes
-.B i
-if
+If
.B bash
-is interactive,
-allowing a shell script or a startup file to test this state.
-.PP
-.nf
-Login shells:
- On login (subject to the \fB\-noprofile\fP option):
- if \fI/etc/profile\fP exists, source it.
-
- if \fI~/.bash_profile\fP exists, source it,
- else if \fI~/.bash_login\fP exists, source it,
- else if \fI~/.profile\fP exists, source it.
-
- On exit:
- if \fI~/.bash_logout\fP exists, source it.
-
-Non-login interactive shells:
- On startup (subject to the \fB\-norc\fP and \fB\-rcfile\fP options):
- if \fI~/.bashrc\fP exists, source it.
-
-Non-interactive shells:
- On startup:
- if the environment variable \fBENV\fP is non-null, expand
- it and source the file it names, as if the command
- if [ "$ENV" ]; then . $ENV; fi
- had been executed, but do not use \fBPATH\fP to search
- for the pathname. When not started in Posix mode, bash
- looks for \fBBASH_ENV\fP before \fBENV\fP.
-.PP
-.fi
-.PP
-If Bash is invoked as
-.BR sh ,
-it tries to mimic the behavior of
-.B sh
-as closely as possible. For a login shell, it attempts to
-source only
-.I /etc/profile
+is started with the name
+.BR rbash ,
+or the
+.B \-r
+option is supplied at invocation,
+the shell becomes restricted.
+A restricted shell is used to
+set up an environment more controlled than the standard shell.
+It behaves identically to
+.B bash
+with the exception that the following are disallowed:
+.IP \(bu
+changing directories with \fBcd\fP
+.IP \(bu
+setting or unsetting the values of
+.B SHELL
+or
+.B PATH
+.IP \(bu
+specifying command names containing
+.B /
+.IP \(bu
+specifying a file name containing a
+.B /
+as an argument to the
+.B .
+builtin command
+.IP \(bu
+importing function definitions from the shell environment at startup
+.IP \(bu
+redirecting output using the >, >|, <>, >&, &>, and >> redirection operators
+.IP \(bu
+using the
+.B exec
+builtin command to replace the shell with another command
+.IP \(bu
+adding or deleting builtin commands with the
+.B \-f
and
-.IR ~/.profile ,
-in that order. The
-.B \-noprofile
-option may still be used to disable this behavior.
-A shell invoked as
-.B sh
-does not attempt to source any other startup files.
+.B \-d
+options to the
+.B enable
+builtin command
+.IP \(bu
+specifying the
+.B \-p
+option to the
+.B command
+builtin command
+.IP \(bu
+turning off restricted mode with
+.BR "set +r" .
.PP
-When
-.B bash
-is started in
-.I posix
-mode, as with the
-.B \-posix
-command line option, it follows the Posix standard for
-startup files. In this mode, the
-.B ENV
-variable is expanded and that file sourced; no other startup
-files are read.
+These restrictions are enforced after any startup files are read.
+.PP
+When a command that is found to be a shell script is executed (see
+.SM
+.B "COMMAND EXECUTION"
+above),
+.B rbash
+turns off any restrictions in the shell spawned to execute the
+script.
.SH "SEE ALSO"
.PD 0
.TP
.TP
\fIThe Gnu History Library\fP, Brian Fox and Chet Ramey
.TP
-\fIA System V Compatible Implementation of 4.2\s-1BSD\s+1 Job Control\fP, David Lennert
-.TP
\fIPortable Operating System Interface (POSIX) Part 2: Shell and Utilities\fP, IEEE
.TP
\fIsh\fP(1), \fIksh\fP(1), \fIcsh\fP(1)
Individual \fIreadline\fP initialization file
.PD
.SH AUTHORS
-.RS
-Brian Fox, Free Software Foundation (primary author)
+Brian Fox, Free Software Foundation
.br
-bfox@ai.MIT.Edu
+bfox@gnu.ai.MIT.Edu
.PP
Chet Ramey, Case Western Reserve University
.br
specification.
.PP
Aliases are confusing in some uses.
+.PP
+Shell builtin commands and functions are not stoppable/restartable.
+.PP
+Compound commands and command sequences of the form `a ; b ; c'
+are not handled gracefully when process suspension is attempted.
+When a process is stopped, the shell immediately executes the next
+command in the sequence.
+It suffices to place the sequence of commands between
+parentheses to force it into a subshell, which may be stopped as
+a unit.
+.PP
+Commands inside of \fB$(\fP...\fB)\fP command substitution are not
+parsed until substitution is attempted. This will delay error
+reporting until some time after the command is entered.
+.PP
+Array variables may not (yet) be exported.
.zZ