Check if a program exists from a Fish script
There is type -q
, as in
if type -q $program # do stuffend
which returns 0 if something is a function, builtin or external program (i.e. if it is something fish will execute).
There is also command -sq
, which will return 0 only if it is an external program.
For both of these the "-q" flag silences all output. For command the "-s" makes it just look for a command instead of executing it directly.