From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24443 invoked by alias); 22 Feb 2012 05:41:58 -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: X-Seq: 16779 Received: (qmail 2023 invoked from network); 22 Feb 2012 05:41:57 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <120221214137.ZM13624@torch.brasslantern.com> Date: Tue, 21 Feb 2012 21:41:37 -0800 In-reply-to: Comments: In reply to Daniel Lin "let unset array element remove compatible with bash" (Feb 22, 3:28am) References: X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: let unset array element remove compatible with bash MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Feb 22, 3:28am, Daniel Lin wrote: } } Can any developer consider to enhance zsh's function like "unset var[2]"? } } $unset var[2] ###### BASH only delete one element } $var[2]=() ###### ZSH only delete one element I've started a thread on zsh-workers about this, but: var[3]=() does not mean the same thing that unset var[3] would imply. In zsh, if you assign to a position that is "off the end" of the array, zsh manufactures empty array elements to "fill in the gap". Try this in each of bash and zsh: unset gappy gappy[9]=nine for g in "${gappy[@]}"; do echo /$g/; done Now in zsh: unset gappy gappy=(one) gappy[3]=() for g in "${gappy[@]}"; do echo /$g/; done Note that assigning an empty array to the one-element slice gappy[3] has caused gappy[2] to exist as an empty element. Bash is using some kind of sparse structure to store its arrays.