|

楼主 |
发表于 2006-3-19 22:48:18
|
显示全部楼层
多谢各位一直以来的帮助,小弟参考了Learning the bash Shell - 2nd Edition (o'reilly),在仔细的看了bash manual,发现了一些信息,我希望对大家有用
The most important things you need to know about subshells are what characteristics they get, or inherit, from their parents. These are as follows:
· 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
Code inside a nested subshell obeys the above rules of subshell inheritance, except that it knows about variables defined in the surrounding shell.
在bash manual中
$: Expands to the process ID of the shell. In a ( ) subshell, it expands to the process ID of the current shell, not the subshell.
从以上的信息可以看出nested subshell和脚本引用的subshell是有区别的
1.nested subshell除了可以继承环境变量,它对shell的其他变量也继承了,但是用脚本引用的subshell不会
2.(echo $$)将回显的是current shell的进程号
小弟个人意见,仅供参考,欢迎砸帖,呵呵! |
|