Subshell Inheritance

The most important things you need to know about subshells are what characteristics they get, or inherit, from their parents. These are as follows:

 

广告:个人专属 VPN,独立 IP,无限流量,多机房切换,还可以屏蔽广告和恶意软件,每月最低仅 5 美元

 
  • The current directory
  • Environment variables
  • Standard input, output, and error, plus any other open file descriptors
  • Signals that are ignored

Just as important are the things that a subshell does not inherit from its parent:

 

 
  • Shell variables, except environment variables and those defined in the environment file (usually .bashrc)
  • Handling of signals that are not ignored

We covered some of this in Chapter 3, but these points are common sources of confusion, so they bear repeating.