Hacker News new | ask | show | jobs
by j1elo 1875 days ago
Note ShellCheck's SC2015, especially if you do stuff with permanent consequences in the place of "say":

"A && B || C is not if-then-else. C may run when A is true":

https://github.com/koalaman/shellcheck/wiki/SC2015

1 comments

Interesting! Good to know, thanks. I never mix && and || in the same line, but didn't know exactly why that is!

The problem is that "In this case, if A is true but B is false, C will run."

I guess with B as "say", B will never be false, but generally it's really not the same as if-then-else.