I'm now using
silent! let l:status = system(l:command . ' > /dev/null')
if match(l:status, '\cunknown') != -1 || match(l:status, '\cnot') != -1
echo 'command not found'
return 0`enter code here`
endif
i know it's not complete but is there any better way to check?
edit
i'm now using
silent! let l:status = system('which espeak')
if l:status !~ '\w\+'
echo 'command not found'
return 0
endif
edit
changed from which
to command
https://unix.stackexchange.com/questions/85249/why-not-use-which-what-to-use-then
command -v <command name> >/dev/null
and check the exit code.which
better? i'm using fish and i just fundcommand -v
in bash iscommand -s
in fish, butwhich
is all the samewhich
only works on external utilities, so not shell builtins.