Hoi community,
I have a question that is a bit off topic, but I think you are the
right ones to ask.
I'm writing some shell scripts these days, and a common task is to
check if a particular program is installed (for example `convert').
How is this check done in a sane and portable way?
The two alternatives that I have in mind are:
which convert >/dev/null
if [ $? -ne 0 ] ; then
exit 1
fi
and
type convert >/dev/null
if [ $? -ne 0 ] ; then
exit 1
fi
`type' is a builtin in `bash', but not in `sh'. Maybe it is available
as external program aswell.
Which systems do have `which'?
I want to cover most of the unixoid systems.
But I dont want to walk through $PATH.
meillo
Received on Sat Dec 08 2007 - 21:40:36 UTC
This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:09:48 UTC