Created
September 8, 2023 17:12
-
-
Save kidd/4febd948aee1d0cef8052b3367d45114 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mb:maybehelp() { | |
local msg="$1";shift | |
if any equals_help "$@"; then | |
warn "$msg" | |
return 1 | |
fi | |
} | |
mb:maybehelp "mmsg" "$@" || return 1 | |
any() { | |
local pred="$1"; shift | |
for i in "$@"; do | |
if $pred $i; then | |
return 0 | |
fi | |
done | |
return 1 | |
} | |
every() { | |
local pred="$1"; shift | |
for i in "$@"; do | |
if ! $pred $i; then | |
return 1 | |
fi | |
done | |
return 0 | |
} | |
equals_help() { | |
[ "--help" = "$1" ] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment