On 2019 Feb 10, at 15:27, Christopher Stone <[email protected]> wrote:
> 
> Why does the parenthetic isolation of the command NOT change the working 
> directory of the shell?

Parentheses around shell commands create a "sub-shell". The sub-shell is a new 
shell environment separate from the parent shell session. It exits at the 
closing parenthesis. The environment in the sub-shell ceases to exist once it 
exits, and the parent shell remains unaffected.

This is similar to a script, where any environment setting -- such as a change 
of working directory -- affects only the environment within the script, not the 
environment of the parent session.

Another example of this is the sudo command: sudo creates a sub-shell with 
elevated privileges. So a command like

sudo cd /some/private/directory

accomplishes nothing. The sub-shell switches to the protected directory, then 
immediately exits, resulting in no net effect.

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or need technical support, please email
"[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <https://www.twitter.com/bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/bbedit.

Reply via email to