bash-errors
Permalink: https://wizardzines.com/comics/bash-errors/
bash-errors
Permalink: https://wizardzines.com/comics/bash-errors/
pipefail or referencing ${PIPESTATUS[0]} for curl's exit code, you won't know if curl failed or if its lack of pandas caused grep to fail.@b0rk_reruns
You can also use && to specify that you need both pieces to execute properly.
So you can do unzip fle.zip && cat file1 and if it can't unzip that file because it doesn't exist, then it won't run that cat command.
@b0rk the 'unzip' in there reminds me of finding out last year that
zip output.zip foo bar baz
exits with a failure status if _none_ of foo, bar and baz exists β but if just one of them exists, it will print warnings for the rest, carry on, and exit 0 as if there had been no problem!
Turned out a file had been left out of one of my distribution zips for several releases and the warnings had been lost in huge build logs :-(
I recently experienced the opposite behavior with bash arithmetics: errexit failed a rather valid script https://floss.social/@schnatterer/111838296606152661
TLDR - arithmetic expressions in bash return (obviously) a numerical result. In combination with errexit return values not equal zero are interpreted as error π€¦
Attached: 2 images You're all using "-o errexit" in your #bash scripts to fail early, right? Did you know, that this does not go well with bash arithmetics? Let me explain: I recently reviewed this script: while [ -z "$some_value" ]; do ((retries++)) After enabling errexit it failed. Why? The arithmetic expression not only increments the counter but also returns the new value as exit code. This is != 0, which is interpreted as an error, leading to exit π
@b0rk_reruns This is a great overview that highlights one of my deep frustrations with older tools: Sometimes all the functionality is there but the defaults are wrong.
That's a concern (and sometimes, enough of a concern to justify a whole new tool) because you have to teach every new user the "right way" to hold the tool. It's as if nobody ever invented the hammer and we all just pounded nails with the back of an axe blade... Folks learn to not stab themselves in the face on the backswing, but sooner or later someone just invents the hammer and life is better.
@b0rk_reruns that's all very nice, but I'll still default to a languages with formal definition instead of a shrug and a wink on top of 60 years of conventions.
Unless I inevitably can't, of course.
@b0rk_reruns Would this have helped Intuitive Machines get the lander on the moon in a snap?
No?
Oh well, bash on regardless.
Ah yes, the Steam bug which would literally nuke your drive. All caused by an empty string.