Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Silent shell but not silent script



    Hi all :)

    This one is tricky ;) I have to invoke a command which writes its
diagnostic messages to stderr and its normal output to stdout. This
is important, because sometimes I will want to separate the output to
two files using redirections.

    The problem is this:

    $ ./command
    zsh: no such file or directory: ./command

    Sometimes the command I have to run won't exist, so zsh will
issue that error. How the heck can I make zsh not to spill the error
message but at the same time let the command to use stderr and
stdout? I mean, I can silent zsh doing this:

    $ ./command 2> /dev/null

    but that will silent the stderr output from the command if the
command exists.

    I cannot use MULTIOS and I cannot use any special option of zsh
because of portability, so... can this be done? Can I use any
subshell trick to do the job?

    The only solution I've found so far is to pipe stderr thru a sed
script and get rid of any shell message, but it is too much... Other
solution is doing something like this:

    $ { ./command 2>&1 } 2> /dev/null

    but then I completely loose the ability of separating the stdout
output from the stderr one :(

    Thanks a lot in advance :) and sorry for the weird question O:)

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736 | http://www.dervishd.net
http://www.pleyades.net & http://www.gotesdelluna.net
It's my PC and I'll cry if I want to...



Messages sorted by: Reverse Date, Date, Thread, Author