From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2322 invoked by alias); 19 Dec 2011 18:13:58 -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: 16649 Received: (qmail 16546 invoked from network); 19 Dec 2011 18:13:55 -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=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Date: Mon, 19 Dec 2011 18:13:47 +0000 From: Peter Stephenson To: Subject: Re: arrays as arguments to functions Message-ID: <20111219181347.25c0b612@pwslap01u.europe.root.pri> In-Reply-To: <20111219175812.GA2910@solfire> References: <20111219175812.GA2910@solfire> Organization: Cambridge Silicon Radio X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.101.11.233] X-Scanned-By: MailControl 7.6.5 (www.mailcontrol.com) on 10.68.0.158 On Mon, 19 Dec 2011 18:58:12 +0100 wrote: > is it possible to pass an array as an argument to a function and > if yes: How can I acchieve this? It's not very comfortable: you just have to pass it by name and refer to the variable by dereferencing the passed parameter. % deref() { print ${(P)1}; print ${(P)1[-1]}; } % array=(there once was a hacker named dave) % deref array there once was a hacker named dave dave -- Peter Stephenson Software Engineer Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog