Bash reference manual 5 (shell variable) continued 1

Source: Internet
Author: User

5.2 Bash Variables

The following variables are set or used in Bash. Other shells generally do not process these variables.

Some variables used by Bash are also described in other chapters: for example, for variables used by tools for controlling jobs, see 'job control variable '.

BASH

Execute the full path name of the current Bash instance.

Basw.ts

List of enabled shell options separated by colons. Each word in the list is a valid parameter of the built-in command shopt-s (see 'shopt built-in command '). The options displayed in baseline Ts are those in the 'on' status when the shopt command is executed. When Bash is started, if this variable is in the environment, every shell option in the list will be enabled before reading the Startup File. This variable is read-only.

BASHPID

The ID of the process that expands to the current Bash process. In some cases, the result is different from that of $, for example, a subshell that does not require Bash reinitialization.

BASH_ALIASES

An associated array variable whose members correspond to the internal alias list, which is maintained by the built-in alias command. (Refer to 'Bourne Shell built-in command '). The elements added to this array will appear in the alias list. If you delete an array element, the corresponding alias will be removed from the alias list.

BASH_ARGC

An array variable whose value is the number of parameters in each frame in the current bash invocation call stack. The number of parameters of the current subroutine (shell function or script executed using. Or source) is located at the top of the stack. When a sub-program is executed, the number of input parameters is pushed to the top of BASH_ARGC. Shell only sets this variable when extending the debugging mode. (See the 'shopt builtin 'Section to describe extdebug options)

BASH_ARGV

Is an array variable that contains all parameters in the current bash execution call stack. The last parameter called by the last sub-program is at the top of the stack, and the first parameter of the initial call is at the bottom. When a child program is executed, its parameters are pushed into BASH_ARGV. Shell only sets BASH_ARGV when extending the debugging mode (see the description of the extdebug option in the built-in shopt command ).

BASH_CMDS

It is an array variable and contains members corresponding to the internal hash table of the commands maintained by the hash built-in commands (see the built-in commands of the bourne shell ). The elements added to this array will appear in the hash table, and the elements deleted from this array will also be deleted from the hash table.

BASH_COMMAND

The currently executing or Executing command, unless the shell is executing a command because of a trap, in this case it is the command being executed when a trap occurs.

BASH_ENV

If this variable is set, when Bash is called to execute a shell script, its value is extended and read as the Startup file before the script is executed. For details, see Bash Startup File.

BASH_EXECUTION_STRING

-C call option command parameters.

BASH_LINENO

Is an array variable. Its members are the row numbers in the source file. Each row number corresponds to the member of the called FUNCNAME. $ {BASH_LINENO [$ I]} is the row number when $ {FUNCNAME [$ I]} is called in the source file ($ {BASH_SOURCE [$ I + 1, (or, if referenced in another shell function, $ {BASH_LINENO [$ I-1]}). Use LINENO to obtain the current row number.

BASH_REMATCH

Is an array variable and its members use '= ~ The 'binary operator acts on the results of [condition commands (see condition constructor. The element indexed 0 is the part of the string that matches the entire regular expression. The element of index n is the part of the string that matches the nth parentheses subexpression. This variable is read-only.

BASH_SOURCE

Is an array variable, which is a member of the source file name. The defined shell function name corresponds to the FUNCNAME array variable. The shell function $ {FUNCNAME [$ I]} is defined in the $ {BASH_SOURCE [$ I]} file and called from $ {BASH_SOURCE [$ I + 1.

BASH_SUBSHELL

Increase by 1 every time a sub-shell or sub-shell environment is generated. The initial value is 0.

BASH_VERSINFO

Is a read-only array variable (see the array). Its members store the version information of the current Bash instance. The array members are as follows:

BASH_VERSINFO [0]

Major version (release ).

BASH_VERSINFO [1]

Minor version number (release version ).

BASH_VERSINFO [2]

Patch number.

BASH_VERSINFO [3]

Build a version.

BASH_VERSINFO [4]

Release status (for example, beta1 ).

BASH_VERSINFO [5]

The value of MACHTYPE.

BASH_VERSION

The version number of the current Bash instance.

BASH_XTRACEFD

If it is set to an integer corresponding to a valid file descriptor, when 'set-x' is enabled, Bash will output the generated trace to that file descriptor. In this way, the diagnosis and error information in the Trace Output content can be separated. When BASH_XTRACEFD is canceled or a new value is set, the file descriptor is disabled. Canceling BASH_XTRACEFD or setting it as an empty string will send the trace output to a standard error. Note: Setting BASH_XTRACEFD to 2 (standard error file descriptor) and then canceling the setting will cause the standard output to be disabled.

COLUMNS

When the selection list is printed, the select command is used to determine the terminal width. It is set automatically when the SIGWINCH signal is received.

COMP_CWORD

Is an index that contains the word $ {COMP_WORDS} at the current cursor position }. This variable is only available when the programmable completion tool calls the shell function. (See programmable completion)

COMP_LINE

The current command line. This variable is only available when shell functions and external commands are called by Programmable completion tools. (See programmable completion)

COMP_POINT

The current cursor position when the current command starts. If the current cursor is at the end of the current command, the variable value is equal to $ {# COMP_LINE }. This variable is only available when shell functions and external commands are called by Programmable completion tools. (See programmable completion)

COMP_TYPE

Set to an integer, corresponding to the type of the attempt to complete (This completes the call of a completion function): For general completion is TAB, for subsequent completion of the list after tabs is complete '? ', For the list of partially completed words, select '! '. If the word is not modified, the list is complete, or, for menu completion, it is' % '. This variable is only available when shell functions and external commands are called by Programmable completion tools. (See programmable completion)

COMP_KEY

The key used to call the current completed function (or the last key of the Key sequence ).

COMP_WORDBREAKS

A group of characters. When the execution is completed, the Readline library is used as a word delimiter. If COMP_WORDBREAKS is disabled, it loses its special attribute even if it is reset later.

COMP_WORDS

Is an array variable consisting of independent words in the current command line. This row is split by Readline and uses COMP_WORDBREAKS. This variable is only available when shell functions and external commands are called by Programmable completion tools. (See programmable completion)

COMPREPLY

Is an array variable from which Bash reads the possible completion of calls by shell functions and programmable completion tools. (See programmable completion)

COPROC

Is an array variable used to save the Untitled coprocess used for output and input. (See collaborative process)

DIRSTACK

Is an array variable that contains the current content of the Directory stack. The directory that appears in the stack is displayed in the order of the display results of the dirs built-in command. Assign a value to the member of this variable, which can be used to modify the directory in the stack. However, you must use pushd and popd built-in commands to add and delete directories. The value of this variable does not change the current directory. If DIRSTACK is unset, it loses its special attributes even if it is subsequently reset.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.