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

Re: &&||

On Mon, 19 Feb 2018 23:54:38 -0800
Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:

> On 20/02/18 01:26 AM, Peter Stephenson wrote:
> > I think you were trying to make the status depend only on what was
> > before the first "&&".  You can certainly do
> But isn't that exactly what I did do?


> Appending to you code below:
> > first-statement && {
> >     any-old-stuff
> > } || {something-else-entirely}

The status of first-statement only controls what's *inside* the { }.
That's what I showed.  You've now stuck something after it.  That's got
completely different rules, interacting both with the && outside the braces
as well as the last status from within the braces.

You've now extended your demand so that it works with an else clause as
well.  That can't be done simply by combining &&s and ||s on the same
level (without other fix-ups) because they don't have the same rules.

You could do this, I suppose.

first-statement && {
} || {something-else-entirely}

That works because

- if you don't execute first-statmement, you go direct to what's
following the "||";

- if you do execute it you then get to the true, which is the last
status for the brace, which causes what's following the "||" to be

But you'd probably be (as my father would have said) stotting bonkers.
Though it is a pretty good illustration of the difference between the
two cases.


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