Note that the variables beginning BASH_, beginning COMP, DIRSTACK,
FUNCNAME, GLOBIGNORE, GROUPS, HISTIGNORE, HOSTNAME, HISTTIMEFORMAT,
LANG, LC_ALL, LC_COLLATE, LC_MESSAGE, MACHTYPE, PIPESTATUS,
SHELLOPTS, and TIMEFORMAT are not available in versions prior to 2.0.
BASH_ENV replaces ENV found in earlier versions.
Table B-5. Environment variables
Variable
|
Chapter
|
Type
|
Description
|
---|
*
|
4
|
R
|
The positional parameters given to
the current script or function.
|
@
|
4
|
R
|
The positional parameters given to
the current script or function.
|
#
|
4
|
R
|
The number of arguments given to the
current script or function.
|
-
| |
R
|
Options given to the shell on
invocation.
|
?
|
5
|
R
|
Exit status of the previous command.
|
| |
R
|
Last argument to the previous command.
|
$
|
8
|
R
|
Process ID of the shell process.
|
!
|
8
|
R
|
Process ID of the last background
command.
|
0
|
4
|
R
|
Name of
the shell or shell script.
|
BASH
|
3
| |
The full
pathname used to invoke this instance of bash.
|
BASH_ARGC
|
9
|
A
|
An
array of values which are the number of parameters in each frame of
the current bash execution call stack. The
number of parameters to the current subroutine (shell function or
script executed with . or source) is at the top of the stack.
|
BASH_ARGV
|
9
|
A
|
All of
the parameters in the current bash execution
call stack. The final parameter of the last subroutine call is at the
top of the stack; the first parameter of the initial call is at the
bottom.
|
BASH_COMMAND
|
9
| |
The
command currently being executed or about to be executed, unless the
shell is executing a command as the result of a trap, in which case
it is the command executing at the time of the trap.
|
BASH_EXECUTION_STRING
| | |
The
command argument to the -c invocation option.
|
BASH_ENV
|
3
| |
The
name of a file to run as the environment file when the shell is
invoked.
|
BASH_LINENO
|
9
|
A
|
An
array whose members are the line numbers in source files
corresponding to each member of @var{FUNCNAME}. ${BASH_LINENO[$i]} is the line number in the
source file where ${FUNCNAME[$i +
1]} was called. The corresponding source file name is
${BASH_SOURCE[$i + 1]}.
|
BASH_REMATCH
| |
AR
|
An
array whose members are assigned by the =~
binary operator to the [[ conditional command.
The element with index 0 is the portion of the string matching the
entire regular expression. The element with index
n is the portion of the string matching the
nth parenthesized subexpression.
|
BASH_SOURCE
|
9
|
A
|
An
array containing the source filenames corresponding to the elements
in the FUNCNAME array variable.
|
BASH_SUBSHELL
| | |
Incremented
by one each time a subshell or subshell environment is spawned. The
initial value is 0.
|
BASH_VERSION
|
3
| |
The
version number of this instance of bash.
|
BASH_VERSINFO
|
3,6
|
AR
|
Version
information for this instance of bash. Each
element of the array holds parts of the version number.
|
CDPATH
|
3
|
L
|
A list of
directories for the cd command to search.
|
COMP_CWORD
| | |
An
index into ${COMP_WORDS} of the word
containing the current cursor position. This variable is available
only in shell functions invoked by the programmable completion
facilities.
|
COMP_LINE
| | |
The
current command line. This variable is available only in shell
functions and external commands invoked by the programmable
completion facilities.
|
COMP_POINT
| | |
The
index of the current cursor position relative to the beginning of the
current command. If the current cursor position is at the end of the
current command, the value of this variable is equal to ${#COMP_LINE}. This variable is available only
in shell functions and external commands invoked by the programmable
completion facilities.
|
COMP_WORDBREAKS
| |
U
|
The
set of characters that the Readline library treats as word separators
when performing word completion. If COMP_WORDBREAKS is unset, it loses its special
properties, even if it is subsequently reset.
|
COMP_WORDS
| |
A
|
An
array of the individual words in the current command line. This
variable is available only in shell functions invoked by the
programmable completion facilities.
|
COMPREPLY
| |
A
|
The
possible completions generated by a shell function invoked by the
programmable completion facility.
|
DIRSTACK
|
4,6
|
ARU
|
The
current contents of the directory stack.
|
EUID
| |
R
|
The
effective user ID of the current user.
|
FUNCNAME
|
9
|
ARU
|
An
array containing the names of all shell functions currently in the
execution call stack. The element with index 0 is the name of any
currently-executing shell function. The bottom-most element is
"main". This variable exists only
when a shell function is executing.
|
FCEDIT
|
2
| |
The
default editor for the fc command.
|
FIGNORE
| |
L
|
A list
of names to ignore when doing filename completion.
|
GLOBIGNORE
| |
L
|
A list of patterns defining filenames to
ignore during pathname expansion.
|
GROUPS
| |
AR
|
An array
containing a list of groups of which the current user is a member.
|
IFS
|
7
| |
The Internal
Field Separator: a list of characters that act as word separators.
Normally set to SPACE, TAB, and NEWLINE.
|
HISTCMD
|
3
|
U
|
The
history number of the current command.
|
HISTCONTROL
|
3
| |
A
list of patterns, separated by colons (:), which can have the
following values. ignorespace: lines beginning
with a space are not entered into the history list.
ignoredups: lines matching the last history line
are not entered. erasedups: all previous lines
matching the current line to are removed from the history list before
the line is saved. ignoreboth: enables both
ignorespace and ignoredups.
|
HISTFILE
|
2
| |
The
name of the command history file.
|
HISTIGNORE
|
3
| |
A
list of patterns to decide what should be retained in the history
list.
|
HISTSIZE
|
2
| |
The
number of lines kept in the command history.
|
HISTFILESIZE
|
3
| |
The
maximum number of lines kept in the history file.
|
HISTTIMEFORMAT
|
3
| |
If
set and not null, its value is used as a format string for
strftime(3) to print the time stamp associated
with each history entry displayed by the history builtin. If this variable is set, time
stamps are written to the history file so they may be preserved
across shell sessions.
|
HOME
|
3
| |
The home
(login) directory.
|
HOSTFILE
|
3
| |
The
file to be used for hostname completion.
|
HOSTNAME
| | |
The
name of the current host.
|
HOSTTYPE
|
3
| |
The
type of machine bash is running on.
|
IGNOREEOF
|
3
| |
The
number of EOF characters received before exiting an interactive
shell.
|
INPUTRC
|
2
| |
The
readline startup file.
|
LANG
| | |
Used to
determine the locale category for any category not specifically
selected with a variable starting with LC_.
|
LC_ALL
| | |
Overrides
the value of LANG and any other LC_
variable specifying a locale category.
|
LC_COLLATE
| | |
Determines
the collation order used when sorting the results of pathname
expansion.
|
LC_CTYPE
| | |
Determines
the interpretation of characters and the behavior of character
classes within pathname expansion and pattern matching.
|
LC_MESSAGES
| | |
This
variable determines the locale used to translate double-quoted
strings preceded by a $.
|
LC_NUMERIC
| | |
Determines
the locale category used for number formatting.
|
LINENO
|
9
|
U
|
The
number of the line that just ran in a script or function.
|
MACHTYPE
| | |
A
string describing the system on which bash is
executing.
|
MAIL
|
3
| |
The name of
the file to check for new mail.
|
MAILCHECK
|
3
| |
How
often (in seconds) to check for new mail.
|
MAILPATH
|
3
|
L
|
A list
of file names to check for new mail, if MAIL is not set.
|
OLDPWD
|
3
| |
The
previous working directory.
|
OPTARG
|
6
| |
The value
of the last option argument processed by getopts.
|
OPTERR
|
6
| |
If set to
1, display error messages from getopts.
|
OPTIND
|
6
| |
The
number of the first argument after options.
|
OSTYPE
| | |
The
operating system on which bash is executing.
|
PATH
|
3
|
L
|
The search
path for commands.
|
PIPESTATUS
|
6
|
A
|
An
array variable containing a list of exit status values from the
processes in the most recently executed foreground pipeline.
|
POSIXLY_CORRECT
| | |
If
in the environment when bash starts, the shell
enters posix mode before reading the startup
files, as if the —posix
invocation option had been supplied. If it is set while the shell is
running, bash enables posix
mode, as if the command set -o
posix had been executed.
|
PROMPT_COMMAND
| | |
The
value is executed as a command before the primary prompt is issued.
|
PS1
|
3
| |
The primary
command prompt string.
|
PS2
|
3
| |
The prompt
string for line continuations.
|
PS3
|
5
| |
The prompt
string for the select command.
|
PS4
|
9
| |
The prompt
string for the xtrace option.
|
PPID
|
8
|
R
|
The process
ID of the parent process.
|
PWD
|
3
| |
The current
working directory.
|
RANDOM
|
9
|
U
|
A random
number between 0 and 32767 (215-1).
|
REPLY
|
5, 7
| |
The
user's response to the select command; result of the read command if no variable names are given.
|
SECONDS
|
3
|
U
|
The
number of seconds since the shell was invoked.
|
SHELL
|
3
| |
The full
pathname of the shell.
|
SHELLOPTS
| |
LR
|
A list
of enabled shell options.
|
SHLVL
| | |
Incremented
by one each time an instance of bash is invoked.
|
TIMEFORMAT
| | |
Specifies
the format for the output from using the time reserved word on a command pipeline.
|
TMOUT
|
10
| |
If set to
a positive integer, the number of seconds after which the shell
automatically terminates if no input is received.
|
UID
| |
R
|
The user ID
of the current user.
|
auto_resume
| | |
Controls
how job control works.
|
histchars
| | |
Specifies
what to use as the history control characters. Normally set to the
string
`!^#'.
|