zsh-users
 help / color / mirror / code / Atom feed
From: "Mark J. Reed" <markjreed@gmail.com>
To: zsh-users@zsh.org
Subject: Re: for loop 'bad math expression'
Date: Mon, 5 Feb 2024 10:48:01 -0500	[thread overview]
Message-ID: <CAA=-s3wkzD6gToQrbxMpEkBazQFF6XLpNB-z39yjEn8=nK7e0g@mail.gmail.com> (raw)
In-Reply-To: <279c61c4-ef0b-4eb7-8a6c-619fbf70502d@eastlink.ca>

[-- Attachment #1: Type: text/plain, Size: 941 bytes --]

> I know and expect that $((()) has its
internal grammar.  But 'let' seems ... naked ... for lack of a better word
and it's a strain on grammatical rigor that it gets special, invisible
favors.

Well, it doesn't, really. Grammar-wise, let is treated as a normal command,
which is why you need quoting to use special characters or white space with
it. The ((...)) construct was added to the shell (and described in the
KornShell book) as effectively a version of let that is quoted for you -
that's where the special parsing comes in. let itself doesn't have that.

It does evaluate its arguments in an arithmetic context, and is one of the
main ways to achieve that effect, but it's not the only one, or even the
only one outside ((...)).  You've seen it kick in for variables declared as
integers; it also shows up in array subscripts:

zsh% ary=(a b c d e); i=2; j=1; k="i + j"
zsh% echo $ary[$k]
c


--
Mark J. Reed <markjreed@gmail.com>

[-- Attachment #2: Type: text/html, Size: 3401 bytes --]

  reply	other threads:[~2024-02-05 15:48 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-30  3:39 Ray Andrews
2024-01-30  3:46 ` Ray Andrews
2024-01-30  4:04   ` Bart Schaefer
2024-01-30  4:06     ` Bart Schaefer
2024-01-30  4:17       ` Ray Andrews
2024-01-30 13:44         ` Ray Andrews
2024-01-30 14:30           ` Lawrence Velázquez
2024-02-03 23:52           ` Bart Schaefer
2024-02-04  1:14             ` Ray Andrews
2024-02-04  2:05               ` Lawrence Velázquez
2024-02-04  4:20                 ` Bart Schaefer
2024-02-04 16:08                   ` Ray Andrews
2024-02-04 20:56                     ` Lawrence Velázquez
2024-02-04 15:51                 ` Ray Andrews
2024-02-04 20:48                   ` Lawrence Velázquez
2024-02-04 21:09                     ` Bart Schaefer
2024-02-04 21:23                       ` Bart Schaefer
2024-02-05  2:10                     ` Bart Schaefer
2024-02-05  2:43                       ` Mikael Magnusson
2024-02-05  2:50                         ` Bart Schaefer
2024-02-05 15:21                       ` Ray Andrews
2024-02-05 15:48                         ` Mark J. Reed [this message]
2024-02-04 14:43               ` Mark J. Reed
2024-02-04 16:37                 ` Ray Andrews
2024-02-04 21:09                   ` Lawrence Velázquez

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='CAA=-s3wkzD6gToQrbxMpEkBazQFF6XLpNB-z39yjEn8=nK7e0g@mail.gmail.com' \
    --to=markjreed@gmail.com \
    --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).