diff --git a/basic.bash b/basic.bash index bb6aaf0..050bd40 100755 --- a/basic.bash +++ b/basic.bash @@ -4,10 +4,21 @@ # Copyright _copyright_effective_year_ _copyright_holder_name_ <_copyright_holder_contact_> # SPDX-License-Identifier: CC-BY-SA-4.0 -set \ - -o errexit \ - -o errtrace \ +set_opts=( + # Terminate script execution when an unhandled error occurs + -o errexit + -o errtrace + + # Terminate script execution when an unset parameter variable is + # referenced -o nounset +) +if ! set "${set_opts[@]}"; then + printf \ + 'Error: Unable to set the defensive interpreter behavior.\n' \ + 1>&2 + exit 1 +fi required_commands=( realpath diff --git a/primitive.bash b/primitive.bash index 96470a2..1388efb 100755 --- a/primitive.bash +++ b/primitive.bash @@ -4,7 +4,18 @@ # Copyright _copyright_effective_year_ _copyright_holder_name_ <_copyright_holder_contact_> # SPDX-License-Identifier: CC-BY-SA-4.0 -set \ - -o errexit \ - -o errtrace \ +set_opts=( + # Terminate script execution when an unhandled error occurs + -o errexit + -o errtrace + + # Terminate script execution when an unset parameter variable is + # referenced -o nounset +) +if ! set "${set_opts[@]}"; then + printf \ + 'Error: Unable to set the defensive interpreter behavior.\n' \ + 1>&2 + exit 1 +fi