18 lines
389 B
Bash
18 lines
389 B
Bash
#!/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
|
|
}
|