Hi again,
Just a suggestion you might want to consider. There's a really cool technique for Bash scripts, which I've seen called a "collapsing function." It's especially useful for optional debug output. Here's an example:
function debug {
# A collapsing function. Cool.
if [[ $debug ]]
then
function debug {
echo -e "${COLOR_YELLOW}DEBUG: ${@}${COLOR_OFF}" >&2
}
debug "$@"
else
function debug {
true
}
fi
}
Then to send debug output, you just do:
instead of having to do:
if [[ $debug ]]
then
echo something >&2
fi
And by redefining or "collapsing" the function, it avoids the tests when debugging is disabled (though I doubt it matters in a shell script).
Hi again,
Just a suggestion you might want to consider. There's a really cool technique for Bash scripts, which I've seen called a "collapsing function." It's especially useful for optional debug output. Here's an example:
Then to send debug output, you just do:
debug "Something"instead of having to do:
And by redefining or "collapsing" the function, it avoids the tests when debugging is disabled (though I doubt it matters in a shell script).