|
|
|
|
|
by _where
2082 days 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. |
|
Bash is brilliantly useful for a lot of things. I’m not bashing it.