3 ms·
If it’s not by default there’s a reason. Bash is literally running commands in a shell session. Think terminal session. When a command fails, would you want the
by _where 6y ago
If it’s not by default there’s a reason. Bash is literally running commands in a shell session. Think terminal session. When a command fails, would you want the terminal session to end? That’d be annoying.
Same theory for unset variable. Referencing an undefined variable shouldn’t break your session. Why initialize it anyway? It’s more code to change if you don’t use it if you have to initialize it when it might not be needed. And, you’d have to call the script with A= just to check A wasn’t defined, and in the process now you have A assigned to an empty string, instead of only defaulting to one when called, which uses more memory and execution time.
The pipeline doesn’t die because && and || and parens are seriously helpful for one-liners.
Don’t think of it as a script. Think of it as a script for a shell.
- pwdisswordfish4 6y agoSometimes the only reason is backwards compatibility.
- Waterluvian 6y agoThinking of it that way, it becomes clear why you would want to switch to something like Python for more complex workflows. Bash is brilliantly useful for a lot of things. I’m not bashing it.
- IshKebab 6y agoA compelling argument for why Bash scripts shouldn't exist at all.
- chubot 6y agohttps://www.oilshell.org/blog/2018/01/28.html#shouldnt-we-discourage-people-from-writing-shell-scripts https://www.oilshell.org/blog/2018/01/28.html#shouldnt-we-di...
- IshKebab 6y agoAh yes the "nothing can ever change" argument. It's the reason we still code everything in FORTRAN and COBOL.
- chubot 6y agohttp://www.oilshell.org/blog/2018/01/28.html#im-still-angry-and-i-dont-want-you-to-create-a-new-shell http://www.oilshell.org/blog/2018/01/28.html#im-still-angry-... The fallacy is: "By posting comments on the Internet, I can prevent people from using a tool I'm frustrated with. And I can make millions of lines of existing programs that I rely on go away."
- kasabali 6y ago> you’d have to call the script with A= just to check A wasn’t defined, and in the process now you have A assigned to an empty string You have ${var:-} for doing that