zsh-users
 help / color / mirror / code / Atom feed
* Is this possible with MULTIOS
@ 2006-10-22 14:16 Meino Christian Cramer
  2006-10-23  2:30 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Meino Christian Cramer @ 2006-10-22 14:16 UTC (permalink / raw)
  To: zsh-users

Hi,

 I have several cvs/svn-snapshots on my hd, which I update on a
 regular basis. 

 Sometimes not all snapshots are update.

 Currently my script, which does the cvs/svn updates, pipes the output
 of the according cvs/svn-command through a filter to echo all lines,
 which signals, that files have been uopdated/merged/modifed etc to
 stdout. I have to watch the output to decide whether I want to
 recompile the source.

 What I want is something like:

 upcnt=`<update-cmd> | <filter> | wc -l`
 if [ 0 -ne upcnt ]
 then
  <recompile source
 else
  echo "No file has been changed!"
 fi

 BUT!
 "<filter>" should still print all lines which signal changes to files
 to the terminal....


 Unfortunately the "| wc -l"-part catches stdout and supress echoing
 those lines that way.

 "tee" seems no to work here, since it copies stdout to a _file_ and I
 want to avoid writing temporary files.....it seems I need something
 like two stdouts here...

 Or may be I had thought for too long about this so I don't see the (for
 others) obvious solution ???

 Any light against my blindness ??? ;))))

 Keep hacking and thank you very much for any help in advance !
 Have a nice weekend!
 mcc


 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Is this possible with MULTIOS
  2006-10-22 14:16 Is this possible with MULTIOS Meino Christian Cramer
@ 2006-10-23  2:30 ` Bart Schaefer
  2006-10-23  4:41   ` Meino Christian Cramer
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2006-10-23  2:30 UTC (permalink / raw)
  To: zsh-users

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Is this possible with MULTIOS
  2006-10-23  2:30 ` Bart Schaefer
@ 2006-10-23  4:41   ` Meino Christian Cramer
  0 siblings, 0 replies; 3+ messages in thread
From: Meino Christian Cramer @ 2006-10-23  4:41 UTC (permalink / raw)
  To: schaefer; +Cc: zsh-users

From: Bart Schaefer <schaefer@brasslantern.com>
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


 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-10-23  4:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-22 14:16 Is this possible with MULTIOS Meino Christian Cramer
2006-10-23  2:30 ` Bart Schaefer
2006-10-23  4:41   ` Meino Christian Cramer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).