Bash Debugging
wizardzines.com
Bash Debugging
1–10 of 78 posts
Re: Bash Debugging
#2Re: Bash Debugging
#3Good stuff! I use set-x frequently and have used a similar thing to die (but Julia’s version is nicer). I’ll consider using the debugger thing but stepping through a bash script line by line sounds a bit tedious. Perhaps less so than having to reread a log and rerun the script a bunch.
Re: Bash Debugging
#4set -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
#5I 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
#6Re: Bash Debugging
#7Good stuff! I use set-x frequently and have used a similar thing to die (but Julia’s version is nicer). I’ll consider using the debugger thing but stepping through a bash script line by line sounds a bit tedious. Perhaps less so than having to reread a log and rerun the script a bunch.
fail-unless() {
local result
"$@"
result=$?
if ((result != 0)); then
echo >2&1 "Failed ${result} with command '$*'."
exit ${result}
fi
}
That way, I know exactly what failed in the script.Re: Bash Debugging
#8Re: Bash Debugging
#9Why doesn't set -e (or set -o errexit, or trap ERR) do what I expected? https://mywiki.wooledge.org/BashFAQ/105
What are the advantages and disadvantages of using set -u (or set -o nounset)? https://mywiki.wooledge.org/BashFAQ/112
Safe ways to do things in bash https://github.com/anordal/shellharden/blob/master/how_to_do...
Better Bash Scripting in 15 Minutes https://robertmuth.blogspot.com/2012/08/better-bash-scriptin...
Writing Robust Bash Shell Scripts https://www.davidpashley.com/articles/writing-robust-shell-s...