From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Can't call multi-arg math function from array subscript
Date: Sun, 2 Apr 2017 11:51:56 -0700 [thread overview]
Message-ID: <170402115156.ZM27355@torch.brasslantern.com> (raw)
Single-argument functions are OK:
% string='abcde'
% onearg() { return $1 }
% functions -M onearg
% print ${string[1,onearg(3)]
abc
Add another argument and strange things start happening:
% twoarg() { return $(( $2 - $1 )) }
% functions -M twoarg
% print ${string[1,twoarg(1,4)]}
twoarg: bad math expression: operand expected at end of string
twoarg: bad math expression: operand expected at end of string
Why two error messages?
I assume the comma is messing things up; let's try it like this:
% print ${string[1,$(( twoarg(1,4) ))]}
zsh: parse error
zsh: parse error
Just to confirm:
% print ${string[1,$(( onearg(4) ))]}
abcd
next reply other threads:[~2017-04-02 18:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20170402185230epcas1p467fce7a708bf94d7f2c8e032327196d9@epcas1p4.samsung.com>
2017-04-02 18:51 ` Bart Schaefer [this message]
2017-04-02 20:36 ` Mikael Magnusson
2017-04-03 8:51 ` Peter Stephenson
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=170402115156.ZM27355@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--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).