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 ...
– phemmer Jun 23 '18 at 22:57type -a
towhich
– glenn jackman Jun 24 '18 at 00:56type -a
, why is it better than which tho? – Alexander Mills Jun 24 '18 at 05:35type -f
is what I am looking for, since that suppresses bash function results – Alexander Mills Jun 24 '18 at 05:40