6 ms·
I know $() invokes a subshell, but does () ? My guess was that the () affects the order of operations between ; and &&, so the first line is three commands, wh
by alanbernstein 6y ago
I know $() invokes a subshell, but does () ?
My guess was that the () affects the order of operations between ; and &&, so the first line is three commands, while the second line is two.
- aidenn0 6y agoIt's a subshell. Order of operations is unchanged, and if you just want a block of commands you can use { }
- asicsp 6y agoSee https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Command-Grouping https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.... "Placing a list of commands between parentheses causes a subshell environment to be created" "Placing a list of commands between curly braces causes the list to be executed in the current shell context"
- gravitas 6y agoIt's horribly more complex than just that, the person you're replying to is "more correct" because of the rules of `set -e` which is critical in this thread; a singular command followed by && is treated differently than a compound command. Pull up `man bash` and search `/set.*abef` to read the rather long and involved paragraph for the `-e` option, running in a subshell is only part of it.
- asicsp 6y ago>I know $() invokes a subshell, but does () ? >My guess was that the () affects the order of operations between ; and &&, so the first line is three commands, while the second line is two. Emphasis mine. My understanding was that the question is simply about whether () invokes a subshell or not (irrespective of set -e)