From: Bart Schaefer <schaefer@brasslantern.com>
To: YAMAGUCHI Takanori <t-yama@iij.ad.jp>
Cc: "zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: arithmetic expression from outside
Date: Thu, 5 Sep 2019 11:22:53 -0700 [thread overview]
Message-ID: <CAH+w=7a_Av6w58cMXOw8CoOunAAfr--xnWHis8i6woHDphwH6A@mail.gmail.com> (raw)
In-Reply-To: <69f3c9f0-b91b-beb1-d36c-854bb4eb3ff3@iij.ad.jp>
On Thu, Sep 5, 2019 at 1:50 AM YAMAGUCHI Takanori <t-yama@iij.ad.jp> wrote:
>
> Is this an intended behaviour?
It's the way evaluation of variables in math expressions is defined,
yes. Similarly in ksh:
% echo 'sum[$(echo Hello, world!>&2)]' | ksh -c 'read n; echo $((n))
Hello, world!
ksh: sum: parameter not set
Also environment variables:
% N='sum[$(echo Hello, world!>&2)]' ksh -c 'echo $((N))'
Hello, world!
ksh: sum: parameter not set
(I have a 2012 ksh so maybe this is different now.)
Bash 3.2.57 does the same, although without complaining about the
unset parameter:
% N='sum[$(echo Hello, world!>&2)]' bash -c 'echo $((N))'
Hello, world!
0
Zsh at least does not do that with parameters from the environment,
although I'm not exactly sure what prevents it.
next prev parent reply other threads:[~2019-09-05 18:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-05 8:49 YAMAGUCHI Takanori
2019-09-05 18:22 ` Bart Schaefer [this message]
2019-09-05 19:49 ` Stephane Chazelas
2019-09-06 5:48 ` YAMAGUCHI Takanori
2019-09-07 12:01 ` Daniel Shahaf
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='CAH+w=7a_Av6w58cMXOw8CoOunAAfr--xnWHis8i6woHDphwH6A@mail.gmail.com' \
--to=schaefer@brasslantern.com \
--cc=t-yama@iij.ad.jp \
--cc=zsh-workers@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).