Chapter 4: Shell Builtin Commands

59

that may be reused as input for setting or resetting the currently-set variables.

Read-only variables cannot be reset. In posix mode, only shell variables are listed.

When options are supplied, they set or unset shell attributes. Options, if spec- ified, have the following meanings:

-a

Mark variables and function which are modified or created for ex- port to the environment of subsequent commands.

-b

Cause the status of terminated background jobs to be reported immediately, rather than before printing the next primary prompt.

-e

Exit immediately if a pipeline (see Section 3.2.2 [Pipelines], page 8), which may consist of a single simple command (see

Section 3.2.1 [Simple Commands], page 8), a list (see Section 3.2.3

[Lists], page 9), or a compound command (see Section 3.2.4

[Compound Commands], page 9) returns a non-zero status.

The shell does not exit if the command that fails is part of the command list immediately following a while or until keyword, part of the test in an if statement, part of any command executed in a && or || list except the command following the final && or ||, any command in a pipeline but the last, or if the command’s return status is being inverted with !. If a compound command other than a subshell returns a non-zero status because a command failed while -e was being ignored, the shell does not exit. A trap on ERR, if set, is executed before the shell exits.

This option applies to the shell environment and each subshell en- vironment separately (see Section 3.7.3 [Command Execution En- vironment], page 36), and may cause subshells to exit before exe- cuting all the commands in the subshell.

If a compound command or shell function executes in a context where -e is being ignored, none of the commands executed within the compound command or function body will be affected by the

-e setting, even if -e is set and a command returns a failure status.

If a compound command or shell function sets -e while executing in a context where -e is ignored, that setting will not have any effect until the compound command or the command containing the function call completes.

-f

Disable filename expansion (globbing).

-h

Locate and remember (hash) commands as they are looked up for execution. This option is enabled by default.

-k

All arguments in the form of assignment statements are placed in the environment for a command, not just those that precede the command name.

-m

Job control is enabled (see Chapter 7 [Job Control], page 97). All processes run in a separate process group. When a background job completes, the shell prints a line containing its exit status.