useful-scripts/bin/.inc/common

19 lines
389 B
Text
Raw Normal View History

2025-10-30 23:54:40 +00:00
#!/bin/sh
# check if a command is available
has_command() { # $command
command -v "${1}" 1>/dev/null 2>/dev/null
}
needs_commands() { # $status $cmd1 $cmd2 ...
_nc_status="${1}"
shift 1
for _nc_cmd in "${@}"; do
if ! has_command "${_nc_cmd}"; then
echo "Command '${_nc_cmd}' not available!" >&2
exit "${_nc_status}"
fi
done
}