freebsd-helpers/util.sh

44 lines
908 B
Bash
Raw Permalink Normal View History

2021-04-27 16:33:31 +00:00
#!/bin/sh
# using "helpers." fake namespace to avoid name collisions with installed tools
# and builtins, so we can properly check existance with command -V
helpers.yesno(){
# usage:
# if helpers.yesno
# then
# whatever it is you want to do
# fi
echo "(y/N)"
read optin
case $optin in
y*|Y*)
return 0 # true
;;
*)
return 1 # false
;;
esac
}
helpers.checkhelp(){
# to use this just add "helpers.checkhelp $1" to your script
# right after importing util.sh
case $1 in
-h|--help)
if command -V helpers.help > /dev/null 2>&1
then
helpers.help
else
echo "No help for this script. This probably means it doesn't take any parameters."
echo "Just Run It™"
fi
exit
esac
}