Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: For loop bug
- X-seq: zsh-workers 17671
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx>
- To: Philippe Troin <phil@xxxxxxxx>
- Subject: Re: For loop bug
- Date: Sat, 14 Sep 2002 04:56:57 +0000
- Cc: zsh-workers@xxxxxxxxxx
- In-reply-to: <871y7xs7yd.fsf@xxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20020913233156.324A31C0E9@xxxxxxxxxxxxxxxxxxxxxxxx> <871y7xs7yd.fsf@xxxxxxxxxxxxxxxx>
On Sep 13, 5:58pm, Philippe Troin wrote:
} Subject: Re: For loop bug
}
} Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxx> writes:
}
} Does it fix this one as well?
}
} % for i in 1 2 3; do { {echo $i; [[ $i == 2 ]] && exit 1; } || break }; \
} > done && echo X
} 1
} X
} %
That is not a bug.
zagzig% [[ x == y ]] && true
zagzig% echo $?
1
Hence { [[ $i == 2 ]] && exit 1; } is false, and { false || break } means
break. The && expression is only true if -both- branches are true.
Further, { } is not a subshell, so { [[ 2 == 2 ]] && exit 1; } would most
likely produce something like
login:
which might surprise you even more.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
Messages sorted by:
Reverse Date,
Date,
Thread,
Author