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

Re: pipelines and &&



On Mon, May 25, 1998 at 11:46:00AM +0200, Matthias Kopfermann wrote:

> I would very much like to know how sublists and pipelines are done:
> I read the following without understanding how to do it:
> 
> "If two pipelines are separated by ``&&'', the second
> pipeline is executed only if the first is successful (returns a zero
> value).  If two pipelines are separated by ``||'', the second is
> executed only if the first is unsuccessful (returns a nonzero value).
> Both operators have equal precedence and are left associative."
> 
> now i try something like:
> 	ls | wc && | less  (just to understand the mechanism)
>       
> 		^       ^
> 	There are two pipelines 1) | wc
> 									2) | less
> 	They are separated by &&.
> 		Result: "zsh: parse error near `|'"
> 
> I seem to do it wrong.
> could you give some examples here?

Try something like this:

ls -al | more && cat ~/.zshrc | grep setopt

Now if you're done with pipeline 1 ( ls -al | more ), its exit status
says whether or not to run pipeline 2 (cat ~/.zshrc | grep setopt).
If you kill the "more" process (so it doesn't exit with code 0), the
second pipeline will not be executed.

HTH,
Thomas

-- 
    Thomas Köhler    Email:     jean-luc@xxxxxxxxxxxxxxxxx
        <><           WWW:    http://home.pages.de/~jeanluc/
                      IRC:               jeanluc
      LCARS --- Linux for Computers on All Real Starships



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