diff options
author | EuAndreh <eu@euandre.org> | 2022-08-12 18:50:07 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2022-08-12 18:50:07 -0300 |
commit | c659d80765fe5553058ab3c9b3d58c48fc632e3a (patch) | |
tree | 4a3be983b842a1c598b87f5404f897091e95e01b | |
parent | bin/{min,max,clamp}: Add "Examples" section to help string (diff) | |
download | dotfiles-c659d80765fe5553058ab3c9b3d58c48fc632e3a.tar.gz dotfiles-c659d80765fe5553058ab3c9b3d58c48fc632e3a.tar.xz |
bin/clamp: Replace ad-hoc `assert_arg()` with `assert-arg`
-rwxr-xr-x | bin/clamp | 13 |
1 files changed, 3 insertions, 10 deletions
@@ -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 |