help-make
[Top][All Lists]
Advanced

[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 16:52:03 -0600
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.10) Gecko/20050716

Mike Frysinger wrote:
[...]
you're thinking one level too deep

simply do:
$(shell your_script_here 2>/dev/null)
-mike

Well, yes, that's what Paul suggested. The problem is that in my
your_script_here script I'll have to do the same to prevent the shell
from complaining about foo if it doesn't exist (such as executing foo
in another subshell). I guess what I'm really looking for is an easy
way to determine whether a command exists and is executable or not.
AFAIK, the only ways to do it are:

--  try to execute it and deal with the shell error message (i.e.,
    my original problem)
--  execute it in a subshell, silence its stderr, and use its exit
    status to determine whether it exists or not (128) (i.e., use
    my "inefficient hack")
--  parse PATH and use test to see if the command exists in any of
    the directories (lots of work)

Martin




reply via email to

[Prev in Thread] Current Thread [Next in Thread]