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

Re: Is this possible with MULTIOS



From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
Subject: Re: Is this possible with MULTIOS
Date: Sun, 22 Oct 2006 19:30:54 -0700

> On Oct 22,  4:16pm, Meino Christian Cramer wrote:
> } 
> }  upcnt=`<update-cmd> | <filter> | wc -l`
> }  if [ 0 -ne upcnt ]
> 
> If the filter is grep, it exits with a success code when it finds a
> matching line or with failure when it does not, so you should be able
> to do 
> 
>   if update-cmd | grep ...
>   then recompile
>   else ...
>   fi
> 
> This would behave differently only if grep matched some lines and then
> exited with an error.
> 
> However, to answer your literal question, yes, you can do this with
> multios.  You just have to open an extra descriptor outside of the
> subshell and redirect stdout to it inside the subshell.
> 
>   setopt multios
>   uncnt=$(update-cmd | filter 1>&3 | wc -l) 3>&1
> 

Hi Bart,

 *thanks a lot* :)

 Both solutions will help me !

 Have a nice week!
 mncc


 



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