[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] Different methods of running scripts; subshells and exec
From: |
Greg Wooledge |
Subject: |
Re: [Help-bash] Different methods of running scripts; subshells and execute privileges |
Date: |
Mon, 24 Aug 2015 13:29:07 -0400 |
User-agent: |
Mutt/1.4.2.3i |
On Mon, Aug 24, 2015 at 09:55:00AM -0700, Michael Convey wrote:
> Most sources on the web and in books say the following creates a subshell:
>
> sh /path/to/script???
>
> But you are saying it doesn't create a true subshell and now I understand
> why. But the script above does fork() and exec() a different shell. What is
> the correct nomenclature for that shell? If not subshell, then what? A
> "Child Shell"?
That works. Or a child process. Or a new shell.
> Also, would there ever be a legitimate reason to run a
> script in a true subshell? Perhaps via the following?
>
> (source /path/to/script)
>
> The preceding would fork() a true subshell and run the script therein,
> right?
Uh... maybe? Why would you want to do this, exactly? Does the script
have code that assumes you are sourcing it (like "return") that you
need to work around?
Note that this is NOT equivalent to "bash /path/to/script" because
the subshell-plus-source keeps all of your existing shell variables.
Running bash does not (it only keeps environment variables).
- Re: [Help-bash] Different methods of running scripts; subshells and execute privileges, (continued)
- Re: [Help-bash] Different methods of running scripts; subshells and execute privileges, Michael Convey, 2015/08/19
- Re: [Help-bash] Different methods of running scripts; subshells and execute privileges, Greg Wooledge, 2015/08/19
- Re: [Help-bash] Different methods of running scripts; subshells and execute privileges, Michael Convey, 2015/08/19
- Re: [Help-bash] Different methods of running scripts; subshells and execute privileges, Greg Wooledge, 2015/08/20
- Re: [Help-bash] Different methods of running scripts; subshells and execute privileges, Michael Convey, 2015/08/20
- Re: [Help-bash] Different methods of running scripts; subshells and execute privileges, Michael Convey, 2015/08/24
- Re: [Help-bash] Different methods of running scripts; subshells and execute privileges, Greg Wooledge, 2015/08/24
- Re: [Help-bash] Different methods of running scripts; subshells and execute privileges, Michael Convey, 2015/08/24
- Re: [Help-bash] Different methods of running scripts; subshells and execute privileges, Greg Wooledge, 2015/08/24
- Re: [Help-bash] Different methods of running scripts; subshells and execute privileges, Michael Convey, 2015/08/24
- Re: [Help-bash] Different methods of running scripts; subshells and execute privileges,
Greg Wooledge <=