From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: Zsh Users <zsh-users@zsh.org>
Cc: Christopher Browne <cbbrowne@gmail.com>, rahul <rahul2012@gmail.com>
Subject: Re: Higher order functions in zsh (article link)
Date: Thu, 07 Mar 2013 22:12:11 +0100 [thread overview]
Message-ID: <9685.1362690731@quattro> (raw)
In-Reply-To: <20130307190842.GA67680@redoubt.spodhuis.org>
Phil Pennock wrote:
> Why does this code have an eval in there? It's:
I suspect that the eval was there to allow the command to include
arguments: e.g. map 'print -l' *
Using $=func_name will add word-splitting to get that back without
reintroducing the security flaw.
> Oh, and you need to quote the $@ to "$@" if you want to preserve empty
> elements -- whether you do or not depends on what you're mapping across,
> but I tend to think "present but empty" is distinct from "not present".
Actually "$@" is the default for a for loop so you don't need it. And I
can't see that the use of print and command-substitution gets you
anything unless I'm missing something. So:
function map {
local func_name=$1 elem
shift
for elem; $=func_name "${elem}"
}
This is unrelated but it seems the warncreateglobal option does't warn
about variables created using a for loop. Does anyone know if that is
intentional or a bug?
Oliver
next prev parent reply other threads:[~2013-03-07 21:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-07 5:25 rahul
2013-03-07 16:59 ` Christopher Browne
2013-03-07 19:08 ` Phil Pennock
2013-03-07 21:12 ` Oliver Kiddle [this message]
2013-03-08 8:40 ` Stephen Blott
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=9685.1362690731@quattro \
--to=okiddle@yahoo.co.uk \
--cc=cbbrowne@gmail.com \
--cc=rahul2012@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).