[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: unset array[0] doesn't delete the element
From: |
Greg Wooledge |
Subject: |
Re: unset array[0] doesn't delete the element |
Date: |
Mon, 6 Mar 2017 08:31:42 -0500 |
User-agent: |
Mutt/1.4.2.3i |
On Sat, Mar 04, 2017 at 09:10:00PM -0800, Isaac Good wrote:
> Repeat-By:
> $ arr=(1 2 3); unset arr[-1]; echo "${arr[@]}"
> 1 2 3
On Sat, Mar 04, 2017 at 09:14:09PM -0800, Isaac Good wrote:
> Bug report being withdrawn. I had nullglob set so unset wasn't being
> invoked properly.
The bug is that you failed to quote the 'arr[-1]' word. Whether you
have nullglob enabled or not, that word *can* be globbed against a file
in the current directory, so it must always be quoted.
imadev:~$ arr=(1 2 3)
imadev:~$ unset 'arr[-1]'
imadev:~$ declare -p arr
declare -a arr=([0]="1" [1]="2")
Good job on detecting the interaction with nullglob, though.