News for hackers. Stuff that matters.
Re:Bash Debugging by klysm on Friday March 01, 2024 @09:42PM (#39569325)
I always put

set -euxo pipefail

at the top of my bash scripts. It makes some conditional testing more difficult but it has paid for itself many times over just because of pipefail

Re:Bash Debugging by ddlsmurf on Friday March 01, 2024 @09:53PM (#39569397)
You can also set it for a bunch of lines then deactivate it with `set +x`. It gets rather tedious otherwise...
Re:Bash Debugging by mellutussa on Saturday March 02, 2024 @09:02AM (#39572592)
This is a lifesaver. Although I save the -x until I really need to see all the garbage debug output.
Re:Bash Debugging by klysm on Saturday March 02, 2024 @09:55AM (#39572938)
I find it’s usually worth the noise to catch weirdness
Re:Bash Debugging by mrAssHat on Saturday March 02, 2024 @10:10AM (#39573043)
Re:Bash Debugging by klysm on Saturday March 02, 2024 @08:02PM (#39577377)
Thanks for the reference! Seems like a really good resource. I disagree with the reasoning about pipefail though. If I expect a command to return non-zero exit code I'd rather be explicit about it.