From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 10777 invoked from network); 12 Feb 2023 22:54:16 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 12 Feb 2023 22:54:16 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Message-ID:Date:Content-ID: Content-Type:MIME-Version:Subject:To:References:From:In-reply-to:cc:Reply-To: Content-Transfer-Encoding:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=gGTX2acP5zZyHRi/7TV7iiz0Rhly3IoIfRKmBvvvU2Y=; b=RxCsAtkoHcqtiOeMl2T9lNZsWF pWNjeOe+5QQqE0lZhrx9XAOWb7BYrYL4ZI5q2za4tV5dLpREgZlONfZ6uo56M/IDa3MbHIU22rQJu K/iOQYUQvbpzK+wYjCh/v8+6vfzDhLPcUwBVB4EGnhBAS/EHqeqyeopffnsNezCVRV2Vy8T4lKwNe pJnyKoW0aKn5yFUFnzNLXd8OuW+aa86hkvltmUgMjL5ru7TOU7CA4eMupRBEkMZvG8m5NlD2+BDNR kyCys3pb7amgrFzpOxkEKLFKQs8K62G02ud6izfLGaJgBWVBTETJI9ETjh4Ppg0/SxNZd6AS4wTEc aNz2srog==; Received: by zero.zsh.org with local id 1pRLEe-0008ex-1q; Sun, 12 Feb 2023 22:54:16 +0000 Received: by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1pRLEQ-0008LL-8O; Sun, 12 Feb 2023 22:54:02 +0000 Received: from [192.168.178.21] (helo=hydra) by mail.kiddle.eu with esmtp(Exim 4.95) (envelope-from ) id 1pRLEO-0006SP-VN; Sun, 12 Feb 2023 23:54:01 +0100 cc: Zsh hackers list In-reply-to: From: Oliver Kiddle References: <67689-1675827940.088548@BxvG.D9_b.7RzI> <12608-1675903622.800470@Xj82.e3y1.svhG> <66045-1675975796.128039@FBF_.0yMO.Y8fk> <94092-1676192523.865597@yGHQ.rexg.4E4Z> To: Bart Schaefer Subject: Re: [PATCH 1/3]: Add named references MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <24823.1676242440.1@hydra> Date: Sun, 12 Feb 2023 23:54:00 +0100 Message-ID: <24824-1676242440.969118@WPF6.6UmH.dMET> X-Seq: 51420 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: Bart Schaefer wrote: > On Sun, Feb 12, 2023 at 1:02 AM Oliver Kiddle wrote: > > > > % typeset -n ref=arr[1]whatever > > % echo $ref > > onewhatever > > Aha. OK, that's pretty easy to fix. That still leaves the oddities with a second subscript: typeset -n ref='arr[2][1]' arr=( one two three ) echo $ref echo ${ref} ref=Z typeset -p arr Only case where the second subscript works is when ref is in braces. > What about adding ${(K)array) to return array[1] array[2] ... ? > > for ref in ${(K)hash}; do ... That'd work. There's been a few times when I've wished (k) and (kv) would work for normal arrays. the former is just {1..$#arr} but would work in nested expansions. Oliver