Re: [PATCH] when using `which` send errors to /dev/null
=- Luciano Rocha wrote on Wed 23.May'07 at 20:22:32 +0100 -=
> > It's easy enough to add a which-like command though.
>
> What about stopping to find where the binary is and check only if it can
> be run?
> if echo | md5sum &> /dev/null; then
> MD5=md5sum
> elif echo | md5 &> /dev/null; then
> MD5=md5
> elif echo | openssl md5 -hex &> /dev/null; then
> MD5="openssl md5 -hex"
> else
> echo No md5 found 1>&2
> exit 1
> fi
You still put redirects for each test.
With the {} capturing any future cases as well as localized
deviations where the noise is sent (err-out) will be taken care of.
--
© Rado S. -- You must provide YOUR effort for your goal!
EVERY effort counts: at least to show your attitude.
You're responsible for ALL you do: you get what you give.