From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id ab97729f for ; Sun, 1 Dec 2019 23:46:49 +0000 (UTC) Received: (qmail 3782 invoked by alias); 1 Dec 2019 23:46:43 -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: 24488 Received: (qmail 10881 invoked by uid 1010); 1 Dec 2019 23:46:43 -0000 X-Qmail-Scanner-Diagnostics: from wout2-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.0/25649. spamassassin: 3.4.2. Clear:RC:0(64.147.123.25):SA:0(-2.6/5.0):. Processed in 0.70646 secs); 01 Dec 2019 23:46:43 -0000 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrudejgedgudegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggugfgjfgesth ektddttderjeenucfhrhhomhepffgrnhhivghlucfuhhgrhhgrfhcuoegurdhssegurghn ihgvlhdrshhhrghhrghfrdhnrghmvgeqnecukfhppeejledrudektddrheejrdduudelne curfgrrhgrmhepmhgrihhlfhhrohhmpegurdhssegurghnihgvlhdrshhhrghhrghfrdhn rghmvgenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Date: Sun, 1 Dec 2019 23:46:07 +0000 From: Daniel Shahaf To: zsh-users@zsh.org Subject: Re: shuffle array Message-ID: <20191201234607.mrajutnpkfr5bmtq@tarpaulin.shahaf.local2> References: <867e3jxtao.fsf@zoho.eu> <20191129064215.GA14095@prometheus.u-strasbg.fr> <8636e7w0w9.fsf__36104.0529723809$1575015640$gmane$org@zoho.eu> <20191201200719.anzbs27c7phgdnmm@chaz.gmail.com> <86v9qzpwq4.fsf@zoho.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <86v9qzpwq4.fsf@zoho.eu> User-Agent: NeoMutt/20170113 (1.7.2) Emanuel Berg wrote on Sun, Dec 01, 2019 at 22:22:27 +0100: > How do I send the array as a name/pointer argument, i.e. not just the value? To read an array by name: f() { local array_name=$1 print -rl -- "${(@P)array_name}" } typeset -a foo=(bar baz) f foo To write an array by name: f() { set -A "$1" bar baz } typeset -a foo f foo > Or how can I return the new array and set the old one's value to that? f() { reply=( bar baz ) } typeset -a foo f foo=( "${reply[@]}" ) > # from SC on gmane.comp.shells.zsh.user gmane.comp.shells.zsh.user and zsh-users@zsh.org are the same thing. ☺