bash: Command Execution Environment

1 
1 3.7.3 Command Execution Environment
1 -----------------------------------
1 
1 The shell has an EXECUTION ENVIRONMENT, which consists of the following:
1 
1    * open files inherited by the shell at invocation, as modified by
1      redirections supplied to the 'exec' builtin
1 
1    * the current working directory as set by 'cd', 'pushd', or 'popd',
1      or inherited by the shell at invocation
1 
1    * the file creation mode mask as set by 'umask' or inherited from the
1      shell's parent
1 
1    * current traps set by 'trap'
1 
1    * shell parameters that are set by variable assignment or with 'set'
1      or inherited from the shell's parent in the environment
1 
1    * shell functions defined during execution or inherited from the
1      shell's parent in the environment
1 
1    * options enabled at invocation (either by default or with
1      command-line arguments) or by 'set'
1 
1    * options enabled by 'shopt' (⇒The Shopt Builtin)
1 
1    * shell aliases defined with 'alias' (⇒Aliases)
1 
11    * various process IDs, including those of background jobs (⇒
      Lists), the value of '$$', and the value of '$PPID'
1 
1    When a simple command other than a builtin or shell function is to be
1 executed, it is invoked in a separate execution environment that
1 consists of the following.  Unless otherwise noted, the values are
1 inherited from the shell.
1 
1    * the shell's open files, plus any modifications and additions
1      specified by redirections to the command
1 
1    * the current working directory
1 
1    * the file creation mode mask
1 
1    * shell variables and functions marked for export, along with
1      variables exported for the command, passed in the environment
1      (⇒Environment)
1 
1    * traps caught by the shell are reset to the values inherited from
1      the shell's parent, and traps ignored by the shell are ignored
1 
1    A command invoked in this separate environment cannot affect the
1 shell's execution environment.
1 
1    Command substitution, commands grouped with parentheses, and
1 asynchronous commands are invoked in a subshell environment that is a
1 duplicate of the shell environment, except that traps caught by the
1 shell are reset to the values that the shell inherited from its parent
1 at invocation.  Builtin commands that are invoked as part of a pipeline
1 are also executed in a subshell environment.  Changes made to the
1 subshell environment cannot affect the shell's execution environment.
1 
1    Subshells spawned to execute command substitutions inherit the value
1 of the '-e' option from the parent shell.  When not in POSIX mode, Bash
1 clears the '-e' option in such subshells.
1 
1    If a command is followed by a '&' and job control is not active, the
1 default standard input for the command is the empty file '/dev/null'.
1 Otherwise, the invoked command inherits the file descriptors of the
1 calling shell as modified by redirections.
1