Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH Re: let unset array element remove compatible with bash



On Jul 1,  7:15pm, Peter Stephenson wrote:
} Subject: Re: PATCH Re: let unset array element remove compatible with bash
}
} On Sun, 01 Jul 2012 09:53:54 -0700
} Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
} > So the patch below makes
} > 
} >     noglob unset foo[x]
} > 
} > work properly.  If x is an existing index (or valid slice), it is cut
} > from the array as if by foo[x]=().
} 
} Do you mean that?

For reference, the original question about this was users/16778, in
which Daniel wrote:

>  $unset var[2] ###### BASH only delete one element
>  $var[2]=() ###### ZSH only delete one element

so I made unset var[2] work like var[2]=().  On the other hand he also
wrote:

>   $echo "${#var[@]} ${#var[1]} ${#var[2]} ${#var[3]}"
>   2 4 0 14

so he is expecting var[2] to become an empty element that is not counted
as part of the array, which zsh has no way to represent internally.



Messages sorted by: Reverse Date, Date, Thread, Author