From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20141 invoked by alias); 7 Mar 2013 21:18:33 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17679 Received: (qmail 22195 invoked from network); 7 Mar 2013 21:18:31 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.5 required=5.0 tests=BAYES_05,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_NONE, T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=no version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at yahoo.co.uk does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s1024; t=1362690732; bh=4xYHEvaz8g194RPV6uTpMFZfkuMxgq8DqCLGSnuQ0S0=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:Received:Received:Received:In-reply-to:From:References:To:cc:Subject:MIME-Version:Content-Type:Content-ID:Date:Message-ID; b=506rkuHtK14MuVFnBaCSm358bWASr684/ESJq3vOkk0Dy2ncqTMWa6HLyAd0ug43FB1l4/3WCyzKu83bzK6AAYPZgRgg/m/LW6QvEL00ODD7RgW5SxxC/ScOLrAlg7rG9SXkQIGKdhib09ffxN3JuTVvp4lTWrmofcw6wviDwMc= X-Yahoo-Newman-Id: 495035.39782.bm@smtp103.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: bE3TQfEVM1n9QqdOaJ_bEPjpMdElUJx_W9dPRp3_aH.q.wI wsLbP40xKxQsNbUCxUoiwGze8.wJ970okFdptWqaeyMyRUhbqBzbabvu23bP mdzb51hpuo3txM.KHLl5BPDtjPN4b1cfyiKOSABqYGmWblQD4PVAWbxPLYlW HRR9ZkycI242eFaYuA.A8iAe6j0DBOJeBG3RLVbVx9a3nYOGA4RmOB4nW1QK xtVhuwVwJaMgbXOWokdwU1yoVPn8Qottr4oXGwvz_tmJGzOKMDV02.xb5EAH p47e7vY1h3QZmo3L9w_7RZW_At24ZXIErhq.IM0WjRz81C3qjWT2lCponaM9 OqhLYyOLmHRNdwo0kbn1OUJ9Qp9HwFlhDQhVt1.AJu_FOWSAaPrFvMCXfjD7 EvAejxJSgqiAHIxH62n3Wlv8GBkxHJQs493s_eaFwFRO3gA-- X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- In-reply-to: <20130307190842.GA67680@redoubt.spodhuis.org> From: Oliver Kiddle References: <20130307190842.GA67680@redoubt.spodhuis.org> To: Zsh Users cc: Christopher Browne , rahul Subject: Re: Higher order functions in zsh (article link) MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <9673.1362690701.1@quattro> Date: Thu, 07 Mar 2013 22:12:11 +0100 Message-ID: <9685.1362690731@quattro> 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