* Precedence of operations in [[
@ 2018-12-03 15:14 ` Peng Yu
2018-12-03 15:57 ` Peter Stephenson
0 siblings, 1 reply; 2+ messages in thread
From: Peng Yu @ 2018-12-03 15:14 UTC (permalink / raw)
To: zsh-users
Hi,
It seems that there is precedence of the operations in [[. For
example, && is of a higher precedence than ||. I don't find where it
is documented in the man page. Could anybody show me? Thanks.
I see ARITHMETIC EVALUATION discusses precedence. But I don't think it
is for [[.
$ ./main.sh
for x1 in '' x
do
for x2 in '' x
do
for x3 in '' x
do
echo "==> $x1, $x2, $x3 <=="
[[ $x1 || $x2 && $x3 ]]
echo $?
[[ $x1 || ($x2 && $x3) ]]
echo $?
[[ ($x1 || $x2) && $x3 ]]
echo $?
done
done
done
==> , , <==
1
1
1
==> , , x <==
1
1
1
==> , x, <==
1
1
1
==> , x, x <==
0
0
0
==> x, , <==
0
0
1
==> x, , x <==
0
0
0
==> x, x, <==
0
0
1
==> x, x, x <==
0
0
0
--
Regards,
Peng
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Precedence of operations in [[
2018-12-03 15:14 ` Precedence of operations in [[ Peng Yu
@ 2018-12-03 15:57 ` Peter Stephenson
0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2018-12-03 15:57 UTC (permalink / raw)
To: zsh-users
On Mon, 2018-12-03 at 09:14 -0600, Peng Yu wrote:
> It seems that there is precedence of the operations in [[. For
> example, && is of a higher precedence than ||. I don't find where it
> is documented in the man page. Could anybody show me? Thanks.
>
> I see ARITHMETIC EVALUATION discusses precedence. But I don't think it
> is for [[.
Precedence is basically the same as for arithmetic, && higher than ||
higher than equality and inequality, but you're right that it isn't
explicitly documented in the case of [[.
pws
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-12-03 16:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20181203151634epcas1p13aad5853fb952923ce1e124680834647@epcas1p1.samsung.com>
2018-12-03 15:14 ` Precedence of operations in [[ Peng Yu
2018-12-03 15:57 ` Peter Stephenson
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).