Skip to main content
11 events
when toggle format what by license comment
S Jun 21, 2022 at 14:51 history suggested Amin.A CC BY-SA 4.0
Added a small example to explain the meaning behind "side effect".
Jun 17, 2022 at 18:34 review Suggested edits
S Jun 21, 2022 at 14:51
Mar 4, 2016 at 17:36 comment added schily See my new paragraph about side-effects. In your example, there is no visible difference.
Mar 4, 2016 at 17:36 vote accept Nelske
Mar 4, 2016 at 17:35 history edited schily CC BY-SA 3.0
side-effects added
Mar 4, 2016 at 17:32 comment added Nelske So if I understand correctly, the only difference is that: parentheses use a subshell and braces don't? And the output stays the same, regardless of the subshell (in this case). Thankyou, this helped!
Mar 4, 2016 at 17:22 history edited schily CC BY-SA 3.0
added 634 characters in body
Mar 4, 2016 at 17:20 comment added Stéphane Chazelas Yes, you'll notice that the POSIX spec is careful to talk only of subshell environment with no implication that it may involve a child process. And with many shells that implement subshells using a child process, (a;b) will not spawn more processes than {a;b;} (if b is not a builtin nor function nor compound command and there's no local trap) as b will be executed in that child subshell process.
Mar 4, 2016 at 17:14 comment added schily Well parentheses grant the commands to be in a subshell, with braces, it still may happen ;-) but ksh93 does not even create a real subshell for parentheses, but rather emulates the effects of a subshell by using a temporary new copy of parameters.
Mar 4, 2016 at 17:11 comment added Stéphane Chazelas (I wouldn't have bothered mentioning it but since you're maintaining a Bourne shell ;)), ...not in a subshell, except for the Bourne shell that runs compound commands in subshells when redirected.
Mar 4, 2016 at 17:07 history answered schily CC BY-SA 3.0