Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: arithmetic expression from outside
- X-seq: zsh-workers 44730
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: YAMAGUCHI Takanori <t-yama@xxxxxxxxx>
- Subject: Re: arithmetic expression from outside
- Date: Thu, 5 Sep 2019 11:22:53 -0700
- Cc: "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=j6UoP56tm00G9DX6ULKf4oKLIkJNjSZ2qAcSbd9IQSI=; b=v6lAMeWrUEL3ZFGUC8AI35sSDtbyfbbHseBWS7lQqwowbouFAgN7Tbyj6IrwwdaVvZ RF+vLO0jci7ESF2KThvrzE9F3UZM7IZEEuNGMKB6Qslk7JUgocjl+qIOKkBxxGpHZIzq 3kE8piXH1VMRIA+8WNrpVRJQKOHEiOC9ohskaKoCtel42dPhK4qbFR16gddiqbDwqlf0 6ZMiIBkA7lAlWh1FS2F9WJB3PhEgXRDoQWb+WWlPy48V299y8CbS3iIhu+IBBD5A4WWB pKdiK5cjIns0jpALOX/cu4ZXT2aur0rRD52ent7ifEuG880m8SOoncSjY8bAMW4ZiFqu tFBQ==
- In-reply-to: <69f3c9f0-b91b-beb1-d36c-854bb4eb3ff3@iij.ad.jp>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <69f3c9f0-b91b-beb1-d36c-854bb4eb3ff3@iij.ad.jp>
On Thu, Sep 5, 2019 at 1:50 AM YAMAGUCHI Takanori <t-yama@xxxxxxxxx> 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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author