I'm writing a shell script, and I need to check for some dependencies being installed before executing anything. I found I can use which <package>
to see if it is installed or not. The problem is that when that dependency is not found, it throws the following error into console's output:
which: no abc in (/home/pace/.emacs.d/bin:/usr/local/bin:/home/pace/.emacs.d/bin:/usr/local/bin:/home/pace/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:...)
I want to avoid having such output, as I already have error messages shown when something fails. How can I avoid which
from writing anything?
function is_installed() {
if [[ ! $(which $1) ]]
then
echo "[ERROR]: $1 $2"
exit 1
fi
}