Chapter 5: Shell Variables

70

BASHOPTS

A colon-separated list of enabled shell options. Each word in the list is a valid argument for the -s option to the shopt builtin command (see Section 4.3.2

[The Shopt Builtin], page 62). The options appearing in BASHOPTS are those reported as ‘on’ by ‘shopt’. If this variable is in the environment when Bash starts up, each shell option in the list will be enabled before reading any startup files. This variable is readonly.

BASHPID

Expands to the process ID of the current Bash process. This differs from $$ under certain circumstances, such as subshells that do not require Bash to be re-initialized.

BASH_ALIASES

An associative array variable whose members correspond to the internal list of aliases as maintained by the alias builtin. (see Section 4.1 [Bourne Shell

Builtins], page 41). Elements added to this array appear in the alias list; un- setting array elements cause aliases to be removed from the alias list.

BASH_ARGC

An array variable whose values 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. When a subroutine is executed, the number of parameters passed is pushed onto BASH_ARGC. The shell sets BASH_ARGC only when in extended debugging mode (see Section 4.3.2 [The Shopt Builtin], page 62 for a description of the extdebug option to the shopt builtin).

BASH_ARGV

An array variable containing 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. When a subroutine is executed, the parameters supplied are pushed onto BASH_ARGV. The shell sets BASH_ARGV only when in extended debugging mode (see Section 4.3.2 [The

Shopt Builtin], page 62 for a description of the extdebug option to the shopt builtin).

BASH_CMDS

An associative array variable whose members correspond to the internal hash table of commands as maintained by the hash builtin (see Section 4.1 [Bourne

Shell Builtins], page 41). Elements added to this array appear in the hash table; unsetting array elements cause commands to be removed from the hash table.

BASH_COMMAND

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_COMPAT

The value is used to set the shell’s compatibility level. See Section 4.3.2 [The

Shopt Builtin], page 62, for a description of the various compatibility levels and their effects. The value may be a decimal number (e.g., 4.2) or an integer

(e.g., 42) corresponding to the desired compatibility level. If BASH_COMPAT is