Files
scripts/command_exists.sh
T
2026-09-29 15:24:09 -04:00

24 lines
568 B
Bash

# To have scripts not write everything out to stdout so results can be captured
# redirect any output not wanted to /dev/null
#
# This is the original that outputs 1 or 0 with echo
command_exists_1 () {
if type "$1" >> /dev/null; then
echo "1"
else
echo "0"
fi
}
# A better version is to use the return keyword
# This command can be used in an if statement, if needed
# The logic has to be reversed - the shell treats 0 as success
command_exists() {
if type "$1" >> /dev/null; then
return 0
else
return 1
fi
}