zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: ramos@ih4ess.ih.lucent.com, zsh-workers@math.gatech.edu
Subject: Re: this && that || the other && this too
Date: Tue, 7 Oct 1997 20:17:54 -0700	[thread overview]
Message-ID: <971007201754.ZM6858@candle.brasslantern.com> (raw)
In-Reply-To: <199710080047.TAA10231@ihnns581.ih.lucent.com>

On Oct 7,  7:47pm, ramos@ih4ess.ih.lucent.com wrote:
} Subject: this && that || the other && this too
}
} Apparently there is no way to construct an expression
} using "&&" and "||" of the form:
} 
} 	cmd1 XX cmd2 XX cmd3
} 
} such that both cmd2 and cmd3 execute when cmd1 succeeds,
} and neither cmd2 nor cmd3 execute when cmd1 fails.

Yes, that's correct.  `&&' and `||' behave mostly like the boolean
operators in C, so they execute exactly as many subexpressions, left to
right, as are needed to determine the success or failure status of the
entire expression.  They differ from C in having equal precedence, so
they evaluate strictly left to right unless grouped with ( ) or { }.

This is distinct from `;' and `&' which execute both the left and right
subexpressions regardless of the exit status of the left one.

} "It would be nice" to be able to do this without using ()'s, or
} if/then/fi, or some other contorted workaround.

It would be confusing, is what it would be.

What you want, it sounds like, is

	cmd1 && { cmd2 ; cmd3 }

The only way to get that without the { } would be to introduce a new
command separator that acted like `;' but that had higher precedence
than `&&'.  That behavior would be unlike any other separator in zsh
or any other shell.

There's nothing "contorted" about the { } form.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


      reply	other threads:[~1997-10-08  3:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-10-08  0:47 ramos
1997-10-08  3:17 ` Bart Schaefer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=971007201754.ZM6858@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=ramos@ih4ess.ih.lucent.com \
    --cc=zsh-workers@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).