[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Logical expression works does not work as expected
From: |
Lawrence Velázquez |
Subject: |
Re: Logical expression works does not work as expected |
Date: |
Sat, 28 Dec 2024 15:23:41 -0500 |
On Fri, Dec 27, 2024, at 6:47 PM, Greg Wooledge wrote:
> You might have been raised on some other language where the && and ||
> operators have different precedence. In the shell language, they have
> the same precedence.
However, the && and || arithmetic operators do have C-like precedence.
$ echo "$((1 && 1 || 0 && 0))"
1
$ echo "$(( ((1 && 1) || 0) && 0 ))"
0
So be aware of context.
--
vq