[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: suppressing shell error output
From: |
Mike Frysinger |
Subject: |
Re: suppressing shell error output |
Date: |
Tue, 13 Sep 2005 19:51:34 -0400 |
User-agent: |
KMail/1.8.2 |
On Tuesday 13 September 2005 07:44 pm, Martin Sebor wrote:
> Mike Frysinger wrote:
> > On Tuesday 13 September 2005 06:52 pm, Martin Sebor wrote:
> >>-- parse PATH and use test to see if the command exists in any of
> >> the directories (lots of work)
> >
> > you mean `which` ?
>
> Yes, like which but portable. Maybe I could try looking for which
> and use it if it exists, otherwise do the above. But wait, how do
> I look for which in the first place? ;-)
which is pretty well ported ... OS X (Darwin), BSD, Linux have it by
default ...
afaik, which should only error under really bad circumstances, so something
like this should work:
which_binary=`which which 2>/dev/null`
test -z "$which_binary" && echo no which available
i guess if you're going to be really super anal about it, you'd wrap the whole
thing in a local function:
function my_which() {
if test -z "$which_binary" ; then
... your workaround here ...
else
$which_binary "$@"
fi
}
note that you cant rely on exit status on which, just output ... stupid OS X
ships a broken which that always exits 0 even if the specified utility isnt
found
-mike
- suppressing shell error output, Martin Sebor, 2005/09/13
- Re: suppressing shell error output, Paul D. Smith, 2005/09/13
- Re: suppressing shell error output, Martin Sebor, 2005/09/13
- Re: suppressing shell error output, Mike Frysinger, 2005/09/13
- Re: suppressing shell error output, Martin Sebor, 2005/09/13
- Re: suppressing shell error output, Mike Frysinger, 2005/09/13
- Re: suppressing shell error output, Martin Sebor, 2005/09/13
- Re: suppressing shell error output,
Mike Frysinger <=
- Re: suppressing shell error output, Martin Sebor, 2005/09/13
- Re: suppressing shell error output, Mike Frysinger, 2005/09/13
- Re: suppressing shell error output, Martin Sebor, 2005/09/13
- Re: suppressing shell error output, Paul D. Smith, 2005/09/13
- Re: suppressing shell error output, Mike Frysinger, 2005/09/13
- Re: suppressing shell error output, Paul D. Smith, 2005/09/14
- Re: suppressing shell error output, Mike Frysinger, 2005/09/14
- Re: suppressing shell error output, David Boyce, 2005/09/13
- Re: suppressing shell error output, Paul D. Smith, 2005/09/14