If I run
set -x and then run a script in a shell, the option set by
set -x doesn't work inside the script.
I was wondering if all the shell options are not inherited by scripts?
I didn't find this is mentioned in bash manual. The only relevant that I found is "Unless otherwise noted, the values are inherited from the shell." So I guess shell options are inherited. Do I miss it in the manual?
I have read a related question which asked how to let scripts inherit shell options. I was wondering whether and why instead of how.
When a simple command other than a builtin or shell function is to be executed, it is invoked in a separate execution environment that consists of the following. Unless otherwise noted, the values are inherited from the shell.
• the shell’s open files, plus any modifications and additions specified by redirections to the command
• the current working directory
• the fi le creation mode mask
• shell variables and functions marked for export, along with variables exported for the command, passed in the environment (see Section 3.7.4 [Environment], page 37)
• traps caught by the shell are reset to the values inherited from the shell’s parent, and traps ignored by the shell are ignored A command invoked in this separate environment cannot aff ect the shell’s execution environment.