Users browsing this thread: 3 Guest(s)
yossarian
Members
I usually use bash's (POSIX) "command" built-in, since it catches aliases and functions in addition to normal utilities on the PATH:

Code:
$ command -v ls
/bin/ls

$ command -v gs
alias gs='git show'

I usually add a function like this to my scripts:

Code:
installed() {
    cmd=$(command -v "${1}")

    [[ -n "${cmd}" ]] && [[ -f "${cmd}" ]]
    return ${?}
}

installed "gcc" || { echo "I need gcc."; exit 1; }

I used to use "which" for the same purpose, but the fact that OS X's version is slightly different was a source of great annoyance when scripting.


Messages In This Thread
Where is what - by venam - 05-06-2017, 11:19 AM
RE: Where is what - by evbo - 05-06-2017, 12:20 PM
RE: Where is what - by xero - 05-06-2017, 12:58 PM
RE: Where is what - by alxndr - 05-06-2017, 03:13 PM
RE: Where is what - by yossarian - 05-06-2017, 10:02 PM
RE: Where is what - by venam - 06-06-2017, 01:13 PM
RE: Where is what - by jkl - 06-06-2017, 01:17 PM
RE: Where is what - by venam - 06-06-2017, 01:26 PM
RE: Where is what - by venam - 23-11-2021, 01:45 PM
RE: Where is what - by neeasade - 29-11-2021, 02:03 PM
RE: Where is what - by z3bra - 29-11-2021, 07:50 PM
RE: Where is what - by neeasade - 30-11-2021, 02:26 AM