This is a weird one - it should work.
I have this file /home/foo/waldo.sh
#!/usr/bin/env bash
waldo(){
if [[ -z $(command -v waldo) ]]; then
npm install -g '@oresoftware/waldo' || {
return 1;
}
fi
command waldo "$@"
}
export -f waldo;
if I source the file with:
. "/home/foo/waldo.sh";
and then run
waldo
I get:
No command 'waldo' found, did you mean:
Command 'aldo' from package 'aldo' (universe)
waldo: command not found
when I run $(which waldo), it's empty, nothing there.
however, when I run type waldo, I get:
waldo is a function
waldo ()
{
if [[ -z $(command -v waldo) ]]; then
npm install -g '@oresoftware/waldo' || {
return 1
};
fi;
command waldo "$@"
}
anyone know why it's not being sourced or whatever?
$(command ...)or$(which ...). Use the exit status of the command you're calling instead of checking for output. E.G.:if ! command -v waldo >/dev/null; then ...type -atowhichtype -a, why is it better than which tho?type -fis what I am looking for, since that suppresses bash function results