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

Reply via email to