Built-in Shell Variables

Built-in variables are set automatically by the shell and are typically used inside shell scripts. Built-in variables can use the variable substitution patterns shown earlier. When setting variables, you don’t include dollar signs, but when referencing their values later, the dollar signs are necessary.

Tables 5-26 through Table 5-29 show the commonly used built-in variables in bash.

Table 5-26. Behavior-altering variables

Variable

Meaning

auto_resume

Allows a background job to be brought to the foreground simply by entering a substring of the job’s command line. Values can be substring (resume if the user’s string matches part of the command), exact (string must exactly match command), or another value (string must match at beginning of command).

BASH_ENV

Startup file of commands to execute, if bash is invoked to run a script.

CDPATH

Colon-separated list of directories to search for the directory passed in a cd command.

EDITOR

Pathname of your preferred text editor.

IFS

Word separator; used by shell to parse commands into their elements. The default separators are space, tab, and newline.

IGNOREEOF

If nonzero, don’t allow use of a single Ctrl-D (the end-of-file or EOF character) to log off; use the exit command to log off.

PATH

Colon-separated list of directories to search for each command.

PROMPT_COMMAND

Command that bash executes before issuing a prompt for a new command.

PS1

Prompt displayed before each new command; ...

Get Mac OS X Tiger in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.