[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: suppressing shell error output
From: |
Martin Sebor |
Subject: |
Re: suppressing shell error output |
Date: |
Tue, 13 Sep 2005 18:34:26 -0600 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.10) Gecko/20050716 |
Mike Frysinger wrote:
[...]
which is pretty well ported ... OS X (Darwin), BSD, Linux have it by
default ...
True. I looked for a machine w/o it and couldn't find one. I do
recall that we had one where it wasn't available (AIX 4.2 maybe?)
In any case, it's not in POSIX.
(Looking some more... Ah, found one: z/OS UNIX System Services.)
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 ...
My point was that if I go to the trouble of implementing a workaround
for a missing which I might as well use it instead and save myself the
effort of maintaining two solutions.
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
POSIX should really add which as a requirement. It's essential,
non-trivial to work around when it doesn't exist, and widely
implemented.
Martin
- 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, 2005/09/13
- Re: suppressing shell error output,
Martin Sebor <=
- 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