Trying to find both a portable & posix method to test for the existence of a given file along the default system path using -only- builtins(1), if you have a more succinct method, I'd like to study your snippet. The following works, but somehow feels like I'm on the wrong track...
To clarify... Can't use 'test -e fubar' or '[ -e fubar ]' because these require a path, I simply want to confirm the file is along the users path somewhere.
Code:
#!/bin/sh
got_tool() {
builtin command -v $1 > \
/dev/null && return 0 || return 1;
}
got_tool cat
echo $?
got_tool maybe_not_on_users_system
echo $?
To clarify... Can't use 'test -e fubar' or '[ -e fubar ]' because these require a path, I simply want to confirm the file is along the users path somewhere.