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.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,NICE_REPLY_A,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 26598 invoked from network); 13 Dec 2022 22:47:46 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 13 Dec 2022 22:47:46 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1670971666; b=MQ+pa1fAwPSGBGXhkciiQPD5fcVGLVKb/cFMaRg7mNvbXoXpuvuuZTKxP1gCjanve7GeV/xncR U0GsPX6r6js1kdFFzrb4csN4pfkQS42YD9s9oliopOQujDrLYnCyjXjTUGpWJIKV698qpF9c5Y qiAGPVgpX8i3AwXQcFGGtu2dsMxEBUZHeIyTBdDQkt5ychR/36KRUYWwSc9oviHMzv17yYlkJk fjxTIdOie7z3+3Nu2vCvYvw/psnFLVtFDUTHxwRzXFo2PoSKtWMmrMKjysm0dX96kwg7z0mBAj PnsilfMIORB9TS2H6njKERoNMrZVpG/HNMN8JSbC1qyqhQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mta02.eastlink.ca) smtp.remote-ip=24.224.136.13; dmarc=none header.from=eastlink.ca; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1670971666; bh=2klbGbZ0CtH4B1X5Xbi4jDQuk9m+WiKp4fPGv+AVp2E=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:To:Subject:MIME-Version:Date:Message-ID:DKIM-Signature; b=C2F8cFd28f00tQkdw27e4a7lm3Ige2k4AuOShC0ueDJJFEBfwtQ7HJ/V8QnVp9moul6aYSqTBV GBEKmzEVlvYRn4+bQmUc5NZ6NCOVhazVqKikxbuAPhsr2PbNQsz3IGNmzLZKRl6DvDQ3UCJsFm Mzefz+e3ufFnN8LltBKn4vrsjfFC3gvXyWDyFTGLi/8hyEbxcpebfhNO2ISUswoY5bSyxqlx99 Sfw2fz8TA9G+I74m7//2UICb06z9vDl0CXo4imPaihfcplFJs+nsWdVvQ9xtpIsOCK7KiRjSQZ yRxjNlxBfvQqDJ8ipDYGPv9D5lPdqHYds6725tHwLt2OIg==; 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:Content-transfer-encoding: Content-type:In-reply-to:From:References:To:Subject:MIME-version:Date: Message-id:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=82XgCs4imHTUf0Q4tSBif85enZ97/zx94BZyi5wblcI=; b=MuKjJRwn30q4W0LhMvsTiODJX8 nBVBQwKRJQKzI2a/mHUccG8ctyZvvbqjEBQU0jMtgtkFk13UTWibLHv2CHcheRWMQCQg+5O6Lpx2/ SZ/72y7gYlrqm7Vt8EFGFnGswCOUAfTP6EwQ84LJk4TORdxuD6mAUS18dRkGtOSgu6eu9F1SdlyHD lV3NFJG0ymvtQSyqIK59JgDdGQXTNdqK9846Vs9NGk5691oAQS5owK70fZTlTKN1SQNy6SMfLr8LH j0iAWxXZsZw3+/+GBH2fCIgiITxi591ACJauNDHLjdQk2Pmj1MDDHpvc3SWM8mByrrZYPDHoKP0xC WCkAb/bg==; Received: by zero.zsh.org with local id 1p5E3t-0008NT-9u; Tue, 13 Dec 2022 22:47:45 +0000 Authentication-Results: zsh.org; iprev=pass (mta02.eastlink.ca) smtp.remote-ip=24.224.136.13; dmarc=none header.from=eastlink.ca; arc=none Received: from mta02.eastlink.ca ([24.224.136.13]:40801) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) id 1p5E3C-0007hj-9g; Tue, 13 Dec 2022 22:47:02 +0000 Received: from csp01.eastlink.ca ([71.7.199.166]) by mta02.eastlink.ca (Oracle Communications Messaging Server 8.0.2.2.20180531 64bit (built May 31 2018)) with ESMTPS id <0RMU00A8BEAWG350@mta02.eastlink.ca> for zsh-users@zsh.org; Tue, 13 Dec 2022 18:47:01 -0400 (AST) Received: from [192.168.0.4] ([24.207.18.108]) by Eastlink with ESMTPSA id 5E3ApYA75EN8v5E3ApiUWL; Tue, 13 Dec 2022 18:47:01 -0400 X-Authority-Analysis: v=2.4 cv=IPDESCjG c=1 sm=1 tr=0 ts=639900e5 a=xN66ZtSbq5jdJYpBp7G/jQ==:117 a=xN66ZtSbq5jdJYpBp7G/jQ==:17 a=IkcTkHD0fZMA:10 a=oazv7cMqYT41qwSoOAQA:9 a=QEXdDO2ut3YA:10 X-Vade-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfedvucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecugfetuffvnffkpffmpdfqfgfvnecuuegrihhlohhuthemuceftddtnecunecujfgurhepkfffgggfuffvfhfhjggtgfesthekredttdefjeenucfhrhhomheptfgrhicutehnughrvgifshcuoehrrgihrghnughrvgifshesvggrshhtlhhinhhkrdgtrgeqnecuggftrfgrthhtvghrnhepiedtjeffvefgtdehgefgteekueeggeeitedutddvvdduteetffdvveelgfeukedunecukfhppedvgedrvddtjedrudekrddutdeknecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvdegrddvtdejrddukedruddtkedphhgvlhhopegludelvddrudeikedrtddrgegnpdhmrghilhhfrhhomheprhgrhigrnhgurhgvfihssegvrghsthhlihhnkhdrtggrpdhnsggprhgtphhtthhopedvpdhrtghpthhtohepreerpdhrtghpthhtohepiihshhdquhhsvghrshesiihshhdrohhrghdpghgvthdqkghiphfrrghsshifugepthhruhgv X-Vade-Score: 0 X-Vade-State: 0 X-EL-AUTH: rayandrews@eastlink.ca Message-id: Date: Tue, 13 Dec 2022 14:47:00 -0800 MIME-version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: associative array questions Content-language: en-US To: zsh-users@zsh.org References: <859880bf-6808-ddf5-3376-5eff895daef3@eastlink.ca> <7390c1ea-746d-43c8-7480-f860db4ccf03@eastlink.ca> From: Ray Andrews In-reply-to: Content-type: text/plain; charset=UTF-8; format=flowed Content-transfer-encoding: 8bit X-Seq: 28534 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On 2022-12-13 12:06, Roman Perepelitsa wrote: > `set` is a builtin (not a reserved word), so you use it like a normal > command. Your first email in this thread used it correctly. You can > also refer to `man zshbuiltins` for documentation. Nuts, I didn't even consider the problem being the equal sign. One gets used to using it in assignment, it looks strange without it.  But yes, referring back, I see the mistake. set -A $list "${(@M)${(P)list}:#(#i)*$SEARCHBUF*}" ... that seems to be working.  BTW I know it's a builtin and it seems to me I used it like a normal command even if mistakenly, how not? Bart: > You missed where I said "if [$list in this case] names an array, you can only assign to the entire array"? It's nothing but the contents of a file broken down into lines. Yes, I'm assigning the whole thing. This little piece of ... ah, that's where the confusion comes in -- at this juncture I'm not worried about the entire A-A, just the data array, namely the contents of a file. So I suspect we're talking apples and oranges. Subtle change in the topic, pardon! Anyway ... : > eval 'list=( "${(@M)list:#(#i)*$SEARCHBUF*}" )' # filter the array. > That second line isn't doing anything like what you want. But it does work perfectly. Remembering of course that there could be some lurking gotcha, but it *seems* fine. > You don't have the (P) flag in there anywhere to use the value of $list as a parameter name, and you're just assigning that back to $list instead of to the name from $1. The eval accomplishes nothing because the whole thing being eval'd is in single quotes to begin with; you might as well drop both the single quotes and the word eval. Can't say much, only to report that it does work. If I drop the eval and the outer quotes it does nothing, the original array is not changed. As I think I understand it, the second "list" simply becomes the name of the source array and, as I said, eval 'just does it' -- accesses the named array via it's name exactly as I'd intuitively want it to do. So the '(P)' isn't needed. Seems so, anyway. But I've been known to completely misunderstand things. > set -A $list "${(P@M)list:#(#i)*$SEARCHBUF*}" is what Roman is driving at. Right, as above, I ... ah ... well maybe I didn't get it perfect, I don't have the '(P@M)' just '(P)' ... but so far so good. Once I dropped the equal sign I got it right the first time.