From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5833 invoked by alias); 5 Aug 2014 15:55:35 -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: 19010 Received: (qmail 27541 invoked from network); 5 Aug 2014 15:55:34 -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=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 From: Bart Schaefer Message-id: <140805085527.ZM28041@torch.brasslantern.com> Date: Tue, 05 Aug 2014 08:55:27 -0700 In-reply-to: <20140805054434.GA4390@linux.vnet.ibm.com> Comments: In reply to Dominik Vogt "copying an array" (Aug 5, 6:44am) References: <20140805054434.GA4390@linux.vnet.ibm.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: vogt@linux.vnet.ibm.com, Zsh Users Subject: Re: copying an array MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Aug 5, 6:44am, Dominik Vogt wrote: > > typeset -g -a G > G=("a b c" d e) > copy_array () { > typeset -g -a "$1" > # how can this be done? > $1="($G[@])" > } You probably don't need the function at all if this is the only thing it is doing: set -A "$1" "$G[@]" The only reason for the "typeset -g" would be if there is a local array in scope whose name is the same as the value of $1. Otherwise "set -A" will create the global array for you.