Skip to content

Commit

Permalink
fix: Improve documentation and robustability of the defensive interpr…
Browse files Browse the repository at this point in the history
…eter behavior setting logic

Signed-off-by: 林博仁(Buo-ren, Lin) <[email protected]>
  • Loading branch information
brlin-tw committed Nov 30, 2023
1 parent edf953a commit 4652daf
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
17 changes: 14 additions & 3 deletions basic.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 14 additions & 3 deletions primitive.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 4652daf

Please sign in to comment.