dotfiles/sh/.local/bin/exist
Marty Oehme b7e13d649d
[sh] Add wording argument to exist script
Added optional third argument to exist script which can be used to
identify the program or process that needs the command exist looks for.
This makes it easier to identify *who* called exist and is missing
something.
2020-05-11 16:52:51 +02:00

16 lines
488 B
Bash
Executable file

#!/usr/bin/env sh
# check for existing implementations
# If $1 command is not available, error code
# If $2 is low, normal, urgent, also notify the user. (loud-mode)
if command -v "$1" >/dev/null; then
exit 0
else
if [ -n "$2" ]; then
if command -v notify-send >/dev/null; then
notify-send "📦 $1" --urgency="$2" "must be installed for ${3:-"this"} function."
fi
printf "%s: 📦 %s must be installed for %s function.\n" "$2" "$1" "${3:-"this"}"
fi
exit 1
fi