From: "Lawrence Velázquez" <larryv@zsh.org>
To: sergio <sergio@outerface.net>
Cc: "Bart Schaefer" <schaefer@brasslantern.com>, zsh-users@zsh.org
Subject: Re: Arithmetic Zero
Date: Tue, 05 Mar 2024 00:02:42 -0500 [thread overview]
Message-ID: <06e34abe-9887-4ed4-9f04-534a84e6b0ae@app.fastmail.com> (raw)
In-Reply-To: <CAH+w=7ajHGSDi8pR5qb8k404UJ8ZybgXgyPdQ5PzvPRxccOm9A@mail.gmail.com>
On Mon, Mar 4, 2024, at 11:23 PM, Bart Schaefer wrote:
> On Mon, Mar 4, 2024 at 7:28 PM sergio <sergio@outerface.net> wrote:
>> 1. What is the reason for returning 1 when an arithmetic evaluation
>> succeeds but is zero?
>
> (( ... )) is intended to be useful in tests:
> if (( status == 1 )); then ...
Put another way, you can think of ((...)) as "translating" C's
notion of true/false into the shell's. C considers zero-valued
expressions to be false, so ((...)) "translates" them into an exit
status of 1, which the shell considers false/failing. Similarly,
C considers non-zero-valued expressions to be true, so for those
((...)) returns 0, which the shell considers true/successful.
--
vq
next prev parent reply other threads:[~2024-03-05 5:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-05 3:28 sergio
2024-03-05 4:23 ` Bart Schaefer
2024-03-05 5:02 ` Lawrence Velázquez [this message]
2024-03-05 7:09 ` Stephane Chazelas
2024-03-05 7:26 ` Roman Perepelitsa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=06e34abe-9887-4ed4-9f04-534a84e6b0ae@app.fastmail.com \
--to=larryv@zsh.org \
--cc=schaefer@brasslantern.com \
--cc=sergio@outerface.net \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).