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

Re: Is this possible with MULTIOS



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



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