3 ms·
If you rely on `(` instead of `{` to create a subshell and you don't comment the heck out of it, you are doing evil
by llimllib 8y ago
If you rely on `(` instead of `{` to create a subshell and you don't comment the heck out of it, you are doing evil
- psetq 8y agoI was about to comment about how it took me several reads and then finally reading the "compound commands" section of `BASH(1)` to recognize the use of `(` vs `{` in the examples. That distinction should have been made clear in the example IMO.
- ben509 8y agoEven more fun: I was working on an unholy bash script that had a long curly brace block, and I was wondering why none of the environment variables survived. Then I noticed, tucked away at the end: ... kill --all humans touch $children fork yourself } | log Because, you see, components of a pipeline have to be run in subshells...
- yjftsjthsd-h 8y agoWhy? () is the obvious way to get an independent subshell. I guess it's annoying if you're not used to the distinction, but it's not hard. Is it really not common knowledge?
- llimllib 8y agoBecause it parses, visually, EXTREMELY similarly to `{` in a place where almost everybody who programs in a brace-y language will expect a brace. Thus most people will not notice it unless you point it out very explicitly, and it has the potential to cause great confusion.