Re: [dwm] OT: which or type or what else?

From: Rickard Gustafsson <rickard_AT_allyourbase.se>
Date: Sat, 8 Dec 2007 21:48:57 +0100

That's a pretty nasty solution if you ask me. I would have used:
if [ ! -f `which convert` ]

/Rickard

On [Sat 08.12.2007 21:40], markus schnalke wrote:
>
> 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:48:58 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:09:50 UTC