aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2022-08-12 18:50:07 -0300
committerEuAndreh <eu@euandre.org>2022-08-12 18:50:07 -0300
commitc659d80765fe5553058ab3c9b3d58c48fc632e3a (patch)
tree4a3be983b842a1c598b87f5404f897091e95e01b
parentbin/{min,max,clamp}: Add "Examples" section to help string (diff)
downloaddotfiles-c659d80765fe5553058ab3c9b3d58c48fc632e3a.tar.gz
dotfiles-c659d80765fe5553058ab3c9b3d58c48fc632e3a.tar.xz
bin/clamp: Replace ad-hoc `assert_arg()` with `assert-arg`
-rwxr-xr-xbin/clamp13
1 files changed, 3 insertions, 10 deletions
diff --git a/bin/clamp b/bin/clamp
index 652c978..a673f72 100755
--- a/bin/clamp
+++ b/bin/clamp
@@ -68,21 +68,14 @@ while getopts 'h' flag; do
done
shift $((OPTIND - 1))
-assert_arg() {
- if [ -z "$1" ]; then
- printf 'Missing %s\n\n' "$2" >&2
- usage >&2
- exit 2
- fi
-}
NUMBER="${1:-}"
MIN="${2:-}"
MAX="${3:-}"
-assert_arg "$NUMBER" 'NUMBER'
-assert_arg "$MIN" 'MIN'
-assert_arg "$MAX" 'MAX'
+eval "$(assert-arg "$NUMBER" 'NUMBER')"
+eval "$(assert-arg "$MIN" 'MIN')"
+eval "$(assert-arg "$MAX" 'MAX')"
if [ "$MIN" -gt "$MAX" ]; then