From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: (qmail 6817 invoked from network); 15 Apr 2020 23:43:46 -0000 Received-SPF: pass (primenet.com.au: domain of zsh.org designates 203.24.36.2 as permitted sender) receiver=inbox.vuxu.org; client-ip=203.24.36.2 envelope-from= Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with UTF8ESMTPZ; 15 Apr 2020 23:43:46 -0000 Received: (qmail 14750 invoked by alias); 15 Apr 2020 23:43:39 -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: List-Unsubscribe: X-Seq: 24775 Received: (qmail 816 invoked by uid 1010); 15 Apr 2020 23:43:39 -0000 X-Qmail-Scanner-Diagnostics: from mail-il1-f172.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.2/25779. spamassassin: 3.4.4. Clear:RC:0(209.85.166.172):SA:0(-2.8/5.0):. Processed in 0.750481 secs); 15 Apr 2020 23:43:39 -0000 X-Envelope-From: pierpaolog@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.166.172 as permitted sender) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=D8WC1W8KQhhiV2vYVrCPi6IqVEEa9c1ztIs3eKWGrec=; b=AMBcgz9poxJ62cl6Y7ZoQQyn8uD95ixl6V2kHbv8uFUXiyBJGpQcXBg9DaDSAdW6g/ hHR+TUxZ5YPbLz0GMQdJ+jBDp8MgjG3lPWx+2uoXfc55+JfQjmK+2dMwajxXmIEih2yb QmB63H10LmAO1pb/JWn6nV7LzVDFQWWtYvJ3SJp/i3a4Qf+zlE7ZVz0DIuQaQrzw0BzL C5YD4nPD73x+8SZ0Nwyp3OB9BTETc8MyEZ2z79KLIPP2+FsrrUGN/UkqsTxwuuJlVzUp 8FUQap2UMp2xehplQY3LzhOcdo9OYgdClMCuwwxyABEP6rFbzNcuHm5AtqjZrqJE8AHX gA6A== X-Gm-Message-State: AGi0PubaEQZjWjduZSvmDmrz2BbdFMOVBi+vT+CRfzLY//EirPyPgCgs oo5mF+XnSYqkTKtpCkyBw9mMY3XdK6t6NJaRMFo= X-Google-Smtp-Source: APiQypICXAfade/AMuD6nV7fGDTmclp9gahBAh8K4mQpmrAM3EuBbh5287D1C++o5kxsanRRTVhHLokmOxfxZdPIweU= X-Received: by 2002:a92:351a:: with SMTP id c26mr8347998ila.141.1586994186063; Wed, 15 Apr 2020 16:43:06 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Pier Paolo Grassi Date: Thu, 16 Apr 2020 01:42:29 +0200 Message-ID: Subject: Re: indirect assignment to array To: Mikael Magnusson Cc: Zsh-Users List Content-Type: multipart/alternative; boundary="000000000000b8947e05a35ce0ed" --000000000000b8947e05a35ce0ed Content-Type: text/plain; charset="UTF-8" Thanks! I was afraid I had to resort to eval. By the way, I was trying to create an helper function like this: debugvar(){ typeset -g $1 typeset +m $1 typeset $1 } but I found out from the manual that -g "it has no effect when listing existing parameters" is there a way to use typeset from functions to print out the definition of global variables? thanks again Pier Paolo Grassi Il giorno gio 16 apr 2020 alle ore 01:13 Mikael Magnusson ha scritto: > On 4/16/20, Pier Paolo Grassi wrote: > > Hello, I'm trying to assign the content of an array to another which name > > is contained in a variable > > What I tried: > > > > varname=newarray > > typeset -a array=(1 2 3) > > typeset -a $varname=($array) > > > > but I get an > > zsh: bad pattern: newarray=(1 > > > > are there other methods to do indirect assignment that allow me to do > this? > > : ${(PA)varname::=$array} > (leave out the A for scalar assignment, and use AA for assoc arrays). > > -- > Mikael Magnusson > --000000000000b8947e05a35ce0ed--