3 ms·
Aside from the comments above, I would add "shopt -s shift_verbose" which enables "overshifting" detection. E.g. when a function receives less arguments than n
by spbnick 12y ago
Aside from the comments above, I would add "shopt -s shift_verbose" which
enables "overshifting" detection.
E.g. when a function receives less arguments than necessary and you retrieve them like this:
function f()
{
declare -r x="$1"; shift
declare -r y="$1"; shift
declare -r z="$1"; shift
}
with less than three arguments passed and shift_verbose on you will get an
error message the moment you shift and with "set -e" in addition, execution
will be aborted.
See https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html https://www.gnu.org/software/bash/manual/html_node/The-Shopt...
Also, "set -o noclobber" might be useful. If you try to
redirect to an existing file with ">", it will fail. If you explicitly want to overwrite the
file without triggering the error, use ">|".
See https://www.gnu.org/software/bash/manual/html_node/Redirections.html#Redirecting-Output https://www.gnu.org/software/bash/manual/html_node/Redirecti...