Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Precedence of operations in [[
- X-seq: zsh-users 23791
- From: Peng Yu <pengyu.ut@xxxxxxxxx>
- To: zsh-users <zsh-users@xxxxxxx>
- Subject: Precedence of operations in [[
- Date: Mon, 3 Dec 2018 09:14:30 -0600
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=JYx3qqIUu71LWujgdS1JsYsSJT75pE8OfzkPWNCZ5Ns=; b=o309E52jXb0X+kLzBRpzOTNgIXvJL3YhJ/SmESmge4O/KjLqUl5lh/bl5gExyibQXB MbsIYqW0B+8J99WxDOaV8AL3TG+Jr5CUyYusyCkgWi6R/2zVj3xYj2NroIfcCO+CD9AS HAU8nRNsFZHLvn7WlkVlk5CuEicCmj9CtvN127+MUPxIIiKcckCshgRkuBlhUnz9WAUF gnKvi9QF+w2gplmYz/a5L0LlWabU1nLFOSF+BpjGidRAX7PckRyU8Ef/oTAg75+ZvSNC oARKRnJIkC3UroB1UPbXa8wO+yor/EoG95zzH78ZZ9INYQwI+AN1ozo9b7sED0W52+CI 5i1g==
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author