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.