At 2013-01-12 00:40:23,"Greg Wooledge" <address@hidden> wrote:
>On Sat, Jan 12, 2013 at 12:16:27AM +0800, Ma Shimiao wrote:
>> On 01/12/2013 12:10 AM, Ma Shimiao wrote:
>> >hello,everyone:
>> >
>> >I'm learning to use bash. There is a question which confuses me for a
>> >long time.
>> >There are many places mentions subshell in bash's ManPage.
>> >But, what is subshell actually? Is it to exec a new bash script ?
>> >Could someone help me ?
>> and how to create subshells?
>
>The formal definition is in the man page under COMMAND EXECUTION ENVIRONMENT:
>
> Command substitution, commands grouped with parentheses, and
> asynchronous commands are invoked in a subshell environment that is a
> duplicate of the shell environment, except that traps caught by the
> shell are reset to the values that the shell inherited from its parent
> at invocation. Builtin commands that are invoked as part of a
> pipeline are also executed in a subshell environment. Changes made to
> the subshell environment cannot affect the shell's execution
> environment.
>
>Basically, a subshell is a Unix fork(). The child process gets a copy
>of all the parent's variables, open file descriptors and so on, but any
>changes that the child makes are not visible to the parent.
>
>With a separate script, the child would NOT get a copy of the parent
>shell's variables, except for ones that have been exported.
>
Thanks a lot, Greg. That is what I really need.
>See also
http://mywiki.wooledge.org/SubShell
I have read the web page, That's very helpful, I have known about subshell. Thanks again.