Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
syntax:shellvars [2011/06/04 14:47]
thebonsai [BASH_REMATCH]
syntax:shellvars [2019/02/20 08:30]
steventhedev [PS0]
Line 24: Line 24:
  
 ==== BASHOPTS ==== ==== BASHOPTS ====
-^Variable: ​ |''​BASHOPTS'' ​ ^Since: ​ |unknown ​  |+^Variable: ​ |''​BASHOPTS'' ​ ^Since: ​ |4.1-alpha ​  |
 ^Type: ​ |normal variable ​  ​^Read-only: ​ |yes  | ^Type: ​ |normal variable ​  ​^Read-only: ​ |yes  |
 ^Set by Bash:  |yes  ^Default: |n/a  | ^Set by Bash:  |yes  ^Default: |n/a  |
  
-A colon-separated list of enabled shell options. Each word in +A colon-separated list of enabled shell options. 
-the list is a valid argument for the ''​-s''​ option to the+ 
 +Each word in the list is a valid argument for the ''​-s''​ option to the
 [[commands:​builtin:​shopt|shopt builtin command]]. The options appearing [[commands:​builtin:​shopt|shopt builtin command]]. The options appearing
 in ''​BASHOPTS''​ are those reported as on by ''​shopt''​. If this variable is in ''​BASHOPTS''​ are those reported as on by ''​shopt''​. If this variable is
Line 43: Line 44:
  
 ==== BASHPID ==== ==== BASHPID ====
-^Variable: ​ |''​BASHPID'' ​ ^Since: ​ |unknown ​  |+^Variable: ​ |''​BASHPID'' ​ ^Since: ​ |4.0-alpha ​  |
 ^Type: ​ |integer variable ​  ​^Read-only: ​ |yes  | ^Type: ​ |integer variable ​  ​^Read-only: ​ |yes  |
 ^Set by Bash:  |yes  ^Default: |n/a  | ^Set by Bash:  |yes  ^Default: |n/a  |
Line 65: Line 66:
  
 ==== BASH_ARGC ==== ==== BASH_ARGC ====
-^Variable: ​ |''​BASH_ARGC'' ​ ^Since: ​ |unknown ​  |+^Variable: ​ |''​BASH_ARGC'' ​ ^Since: ​ |3.0   |
 ^Type: ​ |integer indexed array   ​^Read-only: ​ |no  | ^Type: ​ |integer indexed array   ​^Read-only: ​ |no  |
 ^Set by Bash:  |only in extended debugging mode  ^Default: |n/a  | ^Set by Bash:  |only in extended debugging mode  ^Default: |n/a  |
  
 An array variable whose values are the number of parameters in An array variable whose values are the number of parameters in
-each frame of the current Bash execution call stack. The number +each frame of the current Bash execution call stack. 
-of parameters to the current subroutine (shell function or+ 
 +The number of parameters to the current subroutine (shell function or
 script executed with [[commands:​builtin:​source|''​.''​ or ''​source''​ builtin command]]) script executed with [[commands:​builtin:​source|''​.''​ or ''​source''​ builtin command]])
 is at the top of the stack. is at the top of the stack.
Line 78: Line 80:
 ==== BASH_ARGV ==== ==== BASH_ARGV ====
  
-^Variable: ​ |''​BASH_ARGV'' ​ ^Since: ​ |unknown ​  |+^Variable: ​ |''​BASH_ARGV'' ​ ^Since: ​ |3.0   |
 ^Type: ​ |integer indexed array  ^Read-only: ​ |no  | ^Type: ​ |integer indexed array  ^Read-only: ​ |no  |
 ^Set by Bash:  |only in extended debugging mode  ^Default: |n/a  | ^Set by Bash:  |only in extended debugging mode  ^Default: |n/a  |
  
 An array variable containing all of the parameters in the current Bash 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+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 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 bottom. When a subroutine is executed, the parameters supplied are pushed onto
 ''​BASH_ARGV''​. ''​BASH_ARGV''​.
 +
 +==== BASH_ARGV0 ====
 +
 +^Variable: ​ |''​BASH_ARGV0'' ​ ^Since: ​ |5.0-alpha ​  |
 +^Type: ​ |string ​ ^Read-only: ​ |no  |
 +^Set by Bash:  |yes  ^Default: |same as ''​$0'' ​ |
 +
 +Expands to the name of the shell or shell script - as the special parameter ''​$0''​ does. Assignments to ''​BASH_ARGV0''​ causes the value to be assigned to ''​$0''​.
 +
 +If this parameter is unset, it loses its special properties, even if subsequently reset.
 +
  
 ==== BASH_CMDS ==== ==== BASH_CMDS ====
Line 101: Line 116:
  
 ==== BASH_COMMAND ==== ==== BASH_COMMAND ====
-^Variable: ​ |''​BASH_COMMAND'' ​ ^Since: ​ |unknown ​  |+^Variable: ​ |''​BASH_COMMAND'' ​ ^Since: ​ |3.0   |
 ^Type: ​ |normal variable ​  ​^Read-only: ​ |no  | ^Type: ​ |normal variable ​  ​^Read-only: ​ |no  |
 ^Set by Bash:  |yes  ^Default: |n/a  | ^Set by Bash:  |yes  ^Default: |n/a  |
Line 108: Line 123:
 is executing a command as the result of a trap, in which case it is the command is executing a command as the result of a trap, in which case it is the command
 executing at the time of the trap. executing at the time of the trap.
 +
 +==== BASH_COMPAT ====
 +^Variable: ​ |''​BASH_COMPAT'' ​ ^Since: ​ |4.3-alpha ​ |
 +^Type: ​ |normal variable ​  ​^Read-only: ​ |no  |
 +^Set by Bash:  |no  ^Default: |n/a  |
 +
 +The value is used to set the shell'​s compatibility level. The value may be a decimal number (e.g., ''​4.2''​) or an integer (e.g., ''​42''​) corresponding to the desired com patibility level. If ''​BASH_COMPAT''​ is unset or set to the empty string, the compatibility level is set to the default for the current version. If  ''​BASH_COMPAT''​ is set to a value that is not one of the valid compatibility levels, the shell prints an error message and sets the compatibility level to the default for the current version. The valid compatibility levels correspond to the compatibility options accepted by the shopt builtin. The current version is also a valid value.
  
 ==== BASH_EXECUTION_STRING ==== ==== BASH_EXECUTION_STRING ====
-^Variable: ​ |''​BASH_EXECUTION_STRING'' ​ ^Since: ​ |unknown ​  |+^Variable: ​ |''​BASH_EXECUTION_STRING'' ​ ^Since: ​ |3.0   |
 ^Type: ​ |normal variable ​  ​^Read-only: ​ |no  | ^Type: ​ |normal variable ​  ​^Read-only: ​ |no  |
 ^Set by Bash:  |yes  ^Default: |n/a  | ^Set by Bash:  |yes  ^Default: |n/a  |
Line 117: Line 139:
  
 ==== BASH_LINENO ==== ==== BASH_LINENO ====
-^Variable: ​ |''​BASH_LINENO'' ​ ^Since: ​ |unknown ​  |+^Variable: ​ |''​BASH_LINENO'' ​ ^Since: ​ |3.0   |
 ^Type: ​ |integer indexed array   ​^Read-only: ​ |no  | ^Type: ​ |integer indexed array   ​^Read-only: ​ |no  |
 ^Set by Bash:  |yes  ^Default: |n/a  | ^Set by Bash:  |yes  ^Default: |n/a  |
Line 129: Line 151:
  
 ==== BASH_REMATCH ==== ==== BASH_REMATCH ====
-^Variable: ​ |''​BASH_REMATCH'' ​ ^Since: ​ |unknown ​  |+^Variable: ​ |''​BASH_REMATCH'' ​ ^Since: ​ |3.0   |
 ^Type: ​ |integer indexed array   ​^Read-only: ​ |yes  | ^Type: ​ |integer indexed array   ​^Read-only: ​ |yes  |
 ^Set by Bash:  |yes  ^Default: |n/a  | ^Set by Bash:  |yes  ^Default: |n/a  |
Line 141: Line 163:
  
 ==== BASH_SOURCE ==== ==== BASH_SOURCE ====
-^Variable: ​ |''​BASH_SOURCE'' ​ ^Since: ​ |unknown ​  |+^Variable: ​ |''​BASH_SOURCE'' ​ ^Since: ​ |3.0   |
 ^Type: ​ |integer indexed array   ​^Read-only: ​ |no  | ^Type: ​ |integer indexed array   ​^Read-only: ​ |no  |
 ^Set by Bash:  |yes  ^Default: |n/a  | ^Set by Bash:  |yes  ^Default: |n/a  |
Line 149: Line 171:
  
 ==== BASH_SUBSHELL ==== ==== BASH_SUBSHELL ====
-^Variable: ​ |''​BASH_SUBSHELL'' ​ ^Since: ​ |unknown ​  |+^Variable: ​ |''​BASH_SUBSHELL'' ​ ^Since: ​ |3.0   |
 ^Type: ​ |normal variable ​  ​^Read-only: ​ |no  | ^Type: ​ |normal variable ​  ​^Read-only: ​ |no  |
 ^Set by Bash:  |yes  ^Default: |n/a  | ^Set by Bash:  |yes  ^Default: |n/a  |
Line 157: Line 179:
  
 ==== BASH_VERSINFO ==== ==== BASH_VERSINFO ====
-^Variable: ​ |''​BASH_VERSINFO'' ​ ^Since: ​ |unknown ​  |+^Variable: ​ |''​BASH_VERSINFO'' ​ ^Since: ​ |2.0   |
 ^Type: ​ |integer indexed array   ​^Read-only: ​ |yes  | ^Type: ​ |integer indexed array   ​^Read-only: ​ |yes  |
 ^Set by Bash:  |yes  ^Default: |n/a  | ^Set by Bash:  |yes  ^Default: |n/a  |
Line 177: Line 199:
  
 Expands to a string describing the version of this instance of Bash. Expands to a string describing the version of this instance of Bash.
 +
 +Since Bash 2.0 it includes the shell'​s "​release status"​ (alpha[N], beta[N], release).
 +
 +==== CHILD_MAX ====
 +^Variable: ​ |''​CHILD_MAX'' ​ ^Since: ​ |4.3-alpha ​  |
 +^Type: ​ |normal variable ​  ​^Read-only: ​ |no  |
 +^Set by Bash:  |no  ^Default: |n/a  |
 +
 +Set the number of exited child status values for the shell to remember. Bash will not allow this value to be decreased below a POSIX-mandated minimum, and there is a maximum value (currently 8192) that this may not exceed. The minimum value is system-dependent.
 +
 +
  
 ==== COMP_CWORD ==== ==== COMP_CWORD ====
Line 268: Line 301:
  
 If this parameter is unset, it loses its special properties, even if it is subsequently reset. If this parameter is unset, it loses its special properties, even if it is subsequently reset.
 +
 +==== EPOCHREALTIME ====
 +^Variable: ​ |''​EPOCHREALTIME'' ​ ^Since: ​ |5.0-alpha ​  |
 +^Type: ​ |integer variable ​  ​^Read-only: ​ |no  |
 +^Set by Bash:  |yes  ^Default: |n/a  |
 +
 +Expands to the number of seconds since Unix expoch as a floating point value with micro-second granularity.
 +
 +Assignments to this parameter are ignored. If this parameter is unset, it loses its special properties, even if it is subsequently reset.
 +
 +==== EPOCHSECONDS ====
 +^Variable: ​ |''​EPOCHSECONDS'' ​ ^Since: ​ |5.0-alpha ​  |
 +^Type: ​ |integer indexed array   ​^Read-only: ​ |no  |
 +^Set by Bash:  |yes  ^Default: |n/a  |
 +
 +Expands to the number of seconds since Unix expoch.
 +
 +Assignments to this parameter are ignored. If this parameter is unset, it loses its special properties, even if it is subsequently reset.
 +
  
 ==== EUID ==== ==== EUID ====
Line 275: Line 327:
  
 Expands to the effective user ID of the current user, initialized at shell startup. Expands to the effective user ID of the current user, initialized at shell startup.
 +
 +:!: Do not rely on this variable when security is a concern.
  
 ==== FUNCNAME ==== ==== FUNCNAME ====
-^Variable: ​ |''​FUNCNAME'' ​ ^Since: ​ |unknown ​  |+^Variable: ​ |''​FUNCNAME'' ​ ^Since: ​ |2.04   |
 ^Type: ​ |integer indexed array   ​^Read-only: ​ |no  | ^Type: ​ |integer indexed array   ​^Read-only: ​ |no  |
 ^Set by Bash:  |only inside shell functions ​ ^Default: |n/a  | ^Set by Bash:  |only inside shell functions ​ ^Default: |n/a  |
Line 301: Line 355:
  
 ==== GROUPS ==== ==== GROUPS ====
-^Variable: ​ |''​GROUPS'' ​ ^Since: ​ |unknown ​  |+^Variable: ​ |''​GROUPS'' ​ ^Since: ​ |2.01   |
 ^Type: ​ |integer indexed array   ​^Read-only: ​ |no  | ^Type: ​ |integer indexed array   ​^Read-only: ​ |no  |
 ^Set by Bash:  |yes  ^Default: |n/a  | ^Set by Bash:  |yes  ^Default: |n/a  |
Line 313: Line 367:
  
 ==== HISTCMD ==== ==== HISTCMD ====
-^Variable: ​ |''​HISTCMD'' ​ ^Since: ​ |unknown ​  |+^Variable: ​ |''​HISTCMD'' ​ ^Since: ​ |1.14.0 ​  |
 ^Type: ​ |integer variable ​ ^Read-only: ​ |no  | ^Type: ​ |integer variable ​ ^Read-only: ​ |no  |
 ^Set by Bash:  |yes  ^Default: |n/a  | ^Set by Bash:  |yes  ^Default: |n/a  |
Line 415: Line 469:
  
 ==== PIPESTATUS ==== ==== PIPESTATUS ====
-^Variable: ​ |''​PIPESTATUS'' ​ ^Since: ​ |unknown ​  |+^Variable: ​ |''​PIPESTATUS'' ​ ^Since: ​ |2.0   |
 ^Type: ​ |integer indexed array  ^Read-only: ​ |no  | ^Type: ​ |integer indexed array  ^Read-only: ​ |no  |
 ^Set by Bash:  |yes  ^Default: |n/a  | ^Set by Bash:  |yes  ^Default: |n/a  |
Line 470: Line 524:
  
 Set to the line of input read by the Set to the line of input read by the
-[[commands:​builtin:​read|read builtin command]] when no arguments are supplied.+[[commands:​builtin:​read|read builtin command]] when no arguments are supplied ​that name target variables.
  
 ==== SECONDS ==== ==== SECONDS ====
Line 509: Line 563:
  
 Expands to the user ID of the current user, initialized at shell startup. Expands to the user ID of the current user, initialized at shell startup.
 +
 +:!: Do not rely on this variable when security is a concern.
  
 ==== BASH_ENV ==== ==== BASH_ENV ====
Line 526: Line 582:
  
 ==== BASH_XTRACEFD ==== ==== BASH_XTRACEFD ====
-^Variable: ​ |''​BASH_XTRACEFD'' ​ ^Since: ​ |unknown ​  |+^Variable: ​ |''​BASH_XTRACEFD'' ​ ^Since: ​ |4.1-alpha ​  |
 ^Type: ​ |normal variable ​ ^Read-only: ​ |no  | ^Type: ​ |normal variable ​ ^Read-only: ​ |no  |
 ^Set by Bash:  |no  ^Default: |n/a  | ^Set by Bash:  |no  ^Default: |n/a  |
Line 607: Line 663:
  
 ==== FUNCNEST ==== ==== FUNCNEST ====
-^Variable: ​ |''​FUNCNEST'' ​ ^Since: ​ |unknown ​  |+^Variable: ​ |''​FUNCNEST'' ​ ^Since: ​ |4.2-alpha ​  |
 ^Type: ​ |normal variable ​ ^Read-only: ​ |no  | ^Type: ​ |normal variable ​ ^Read-only: ​ |no  |
 ^Set by Bash:  |no  ^Default: |n/a  | ^Set by Bash:  |no  ^Default: |n/a  |
Line 619: Line 675:
  
 ==== GLOBIGNORE ==== ==== GLOBIGNORE ====
-^Variable: ​ |''​GLOBIGNORE'' ​ ^Since: ​ |unknown ​  |+^Variable: ​ |''​GLOBIGNORE'' ​ ^Since: ​ |2.0   |
 ^Type: ​ |normal variable ​ ^Read-only: ​ |no  | ^Type: ​ |normal variable ​ ^Read-only: ​ |no  |
 ^Set by Bash:  |no  ^Default: |n/a  | ^Set by Bash:  |no  ^Default: |n/a  |
Line 662: Line 718:
 ^Variable: ​ |''​HISTFILESIZE'' ​ ^Since: ​ |unknown ​  | ^Variable: ​ |''​HISTFILESIZE'' ​ ^Since: ​ |unknown ​  |
 ^Type: ​ |normal variable ​ ^Read-only: ​ |no  | ^Type: ​ |normal variable ​ ^Read-only: ​ |no  |
-^Set by Bash:  |if unset  ^Default: |500  |+^Set by Bash:  |if unset  ^Default: |''​HISTSIZE'' ​ |
  
 The maximum number of lines contained in the history file. The maximum number of lines contained in the history file.
Line 668: Line 724:
 When this variable is assigned a value, the history file is truncated, When this variable is assigned a value, the history file is truncated,
 if necessary, by removing the oldest entries, to contain no more than the if necessary, by removing the oldest entries, to contain no more than the
-given number of lines.+given number of lines. If the given number of lines is 0 (zero), the file is truncated to zero size. 
 +Non-numeric values and numeric values less than zero inhibit truncation.
  
 The history file is also truncated to this size after writing it The history file is also truncated to this size after writing it
Line 674: Line 731:
  
 ==== HISTIGNORE ==== ==== HISTIGNORE ====
-^Variable: ​ |''​HISTIGNORE'' ​ ^Since: ​ |unknown ​  |+^Variable: ​ |''​HISTIGNORE'' ​ ^Since: ​ |2.0   |
 ^Type: ​ |normal variable ​ ^Read-only: ​ |no  | ^Type: ​ |normal variable ​ ^Read-only: ​ |no  |
 ^Set by Bash:  |no  ^Default: |n/a  | ^Set by Bash:  |no  ^Default: |n/a  |
Line 698: Line 755:
  
 The number of commands to remember in the command history. The number of commands to remember in the command history.
 +
 +If the number is set to 0 (zero), then the history list is disabled. If the number is set to any negative number, then the history list is unlimited.
  
 ==== HISTTIMEFORMAT ==== ==== HISTTIMEFORMAT ====
Line 719: Line 778:
 The home directory of the current user. The home directory of the current user.
  
-The default argument for the [[commands:​builtin:​cd|cd builtin command]].++The default argument for the [[commands:​builtin:​cd|cd builtin command]].
  
 The value of this variable is also used when performing The value of this variable is also used when performing
Line 891: Line 950:
 ^Set by Bash:  |no  ^Default: |system-dependent (set on compile time)  | ^Set by Bash:  |no  ^Default: |system-dependent (set on compile time)  |
  
-The search path for commands. +The search path for commands. ​This is a colon-separated list of directories in which the shell looks for commands.
- +
-It is a colon-separated list of directories in which the shell looks for commands.+
  
 A zero-length (null) directory name in the value of ''​PATH''​ indicates the current directory. A zero-length (null) directory name in the value of ''​PATH''​ indicates the current directory.
Line 900: Line 957:
 trailing colon. trailing colon.
  
 +There can be a static path compiled in for use in a restricted shell.
 ==== POSIXLY_CORRECT ==== ==== POSIXLY_CORRECT ====
 ^Variable: ​ |''​POSIXLY_CORRECT'' ​ ^Since: ​ |unknown ​  | ^Variable: ​ |''​POSIXLY_CORRECT'' ​ ^Since: ​ |unknown ​  |
Line 930: Line 988:
  
 Characters removed are replaced with an ellipsis. Characters removed are replaced with an ellipsis.
 +
 +==== PS0 ====
 +^Variable: ​ |''​PS0'' ​ ^Since: ​ |4.4.0 ​  |
 +^Type: ​ |normal variable ​ ^Read-only: ​ |no  |
 +^Set by Bash:  |if unset  ^Default: |"''''" ​ |
 +
 +Expanded and displayed by interactive shells after reading a complete command but before executing it.
  
 ==== PS1 ==== ==== PS1 ====
Line 1003: Line 1068:
  
 ==== TMOUT ==== ==== TMOUT ====
-^Variable: ​ |''​TMOUT'' ​ ^Since: ​ |unknown ​  |+^Variable: ​ |''​TMOUT'' ​ ^Since: ​ |2.05b   |
 ^Type: ​ |normal variable ​ ^Read-only: ​ |no  | ^Type: ​ |normal variable ​ ^Read-only: ​ |no  |
 ^Set by Bash:  |no  ^Default: |n/a  | ^Set by Bash:  |no  ^Default: |n/a  |
  • syntax/shellvars.txt
  • Last modified: 2019/07/07 05:19
  • by thebonsai