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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 9237 invoked from network); 3 Jun 2021 07:31:36 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 3 Jun 2021 07:31:36 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1622705496; b=QYE/Avw5OwDgfFUpllxQ7ywlDz5WbEiRUUZbTy8dYQYFs0o+rsXC2OQiGqVdfoQCvLUu49Px8i tP/Lf23PigTuHmU16OWaBzMns6hwqREb3dGyeuGM+Le7xR1EsMmQhK7sJBcYM3w6yd6pBf463C vQBn5VePR65YiwW+eZTsgFkz7oHGxqyu2fiYxrtPSoW8tujAF9EaI/TvTgONGvV/PxDqB3ZPoO prw2BjEnZnQ3TsBs8Ac79khHOqmzQTqKgkjxCR2Pdt4Y08BQsxVMvAnwj1TxmB0XsU9F4h36bY YetffPdaliUmVsYU1E78SA1ZnUifpTDf/msfH5JYjEZbkg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (relay9-d.mail.gandi.net) smtp.remote-ip=217.70.183.199; dmarc=none header.from=chazelas.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1622705496; bh=jC5sevBqZPsdgZCQcUAST1+Zo2TELgSSENItv8mvZ9U=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:DKIM-Signature; b=pgz5mT6Pw6NdS0nM5SE4Jc6pQU/Asup81YmcFXP2/RPFmcxz7p5r2QtJp4EkCNiR+grrchhpWL YwrDwkUS/TrbZ6bEBKfvBiczdjqpOrxPyM7JDzRlsw42sgOZkjJ3+Ui28SbGCY5hnGBDp6b0Rr /m9jgtgu/xuBh0x2e2qLXBybigv1WKAv2WhX0Jwu8+w8LRD164CLLOjqAeRAGhqfMzarviD4n8 dW0ppBKUZd+a7Q6Xpx0ophcNPtez9Jqw+abmQc9lG0jccWG5SyKf0yRmbtGLItheO2+xctVDEK jE90vS2epNJKG5FQyx6zxYMJ8v2WzN/0sISe36T+1TJsDA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=cKKnBSukTyLl52wd1piCP7wXIWuesaP71k383J2fFAc=; b=AFcK8GJWvvJfltk9I7NTlG/uzx oi/KWAU0srbtGmaQenYyme/viPLhKqsutnC1d7zR0fe5sY/M5pC01tRMImegAjsrnc9C4OrjFSpQB X9iUkD8LvYjzZVSGedJ6doS9C9q13+5EAcELlEbHpRJd4vg9i7jG+O4oVHtDF9sk2LP/lXgTqfyH2 XlZjwH4rvq1UGaHLJ0S/vGQOtLwgeFUoaeEq6sw5UjGbGp8ewJ++a35nMIe1QkW+g6ufYX7wPArpY RahPuRt3O2So9mlO9Nh/CLJvL7lLO4b+t/cfBrui+s3+U762by02TQmhth+Q/ebYZ0nDumzc7NrF6 99KBzeXg==; Received: from authenticated user by zero.zsh.org with local id 1lohpH-000I6K-Di; Thu, 03 Jun 2021 07:31:35 +0000 Authentication-Results: zsh.org; iprev=pass (relay9-d.mail.gandi.net) smtp.remote-ip=217.70.183.199; dmarc=none header.from=chazelas.org; arc=none Received: from relay9-d.mail.gandi.net ([217.70.183.199]:55579) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1lohoz-000Hma-JL; Thu, 03 Jun 2021 07:31:17 +0000 Received: (Authenticated sender: stephane@chazelas.org) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id B7DC0FF810; Thu, 3 Jun 2021 07:31:16 +0000 (UTC) Date: Thu, 3 Jun 2021 08:31:16 +0100 From: Stephane Chazelas To: Bart Schaefer Cc: Zsh hackers list Subject: Re: [PATCH (not final)] (take three?) unset "array[$anything]" Message-ID: <20210603073116.wc7drrj553ymciwl@chazelas.org> Mail-Followup-To: Bart Schaefer , Zsh hackers list References: <20210601053235.b4junj6muuwegl7b@chazelas.org> <20210602091145.xvyymjxdors6kqya@chazelas.org> <20210602142005.b5tw2hj2c6q3psqv@chazelas.org> <20210603060546.lvai62egrinwrbni@chazelas.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Seq: 49000 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: 2021-06-02 23:43:50 -0700, Bart Schaefer: [...] > > There's also the question of what to do with > > ... a bunch of things that aren't documented to work with associative > array elements but accidentally do ... [...] That's quite a natural thing to want to do though and is supported by all shells with arrays (except yash it seems). See for instance CSV processing such as: typeset -A field IFS=, { read -rA headers (($#headers)) && while read -r 'field['$^headers']'; do typeset -p field do-something-with "$field[firstname]" "$field[lastname]" done } < file.csv That code above currently fails if the header contains some special characters and has a code injection vulnerability (like if the first line of the csv is $(reboot)), and making read a keyword wouldn't help. It can currently be avoided with: typeset -A field IFS=, { read -rA headers (($#headers)) && while read -r 'field[$headers['{1..$#headers}']]'; do typeset -p field do-something-with "$field[firstname]" "$field[lastname]" done } < file.csv -- Stephane