[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: zsh style associative array assignment bug

From: Oğuz
Subject: Re: zsh style associative array assignment bug
Date: Sun, 28 Mar 2021 10:15:23 +0300

28 Mart 2021 Pazar tarihinde Eric Cook <llua@gmx.com> yazdı:
> 1) For consistency sake with the shell the idea was borrowed from mostly.

That an idea was borrowed from another shell doesn't mean it should be
implemented the same kludgy way. Besides, bash doesn't offer compatibility
with zsh.

> 2) Prior to this extension bash required specifying the key and value for
> AA assignments, so it seems weird to silently ignore that a value wasn't
> given now.

The oldest version of Bash I ever used is 4.4.20, and if my memory serves
me right, it didn't regard omission of a value inside a compound assignment
(like `foo=([bar]=)`) an error. If otherwise and it actually did, that was
a mistake.

> 2.5) I subjectively think passing an odd number of elements to declare is
> more often
> than not to be a mistake that the user would be interested in knowing
> about.
> With the way it is now, you could save a few characters to do a seen array.
> $ while read -r key; ... seen+=("$key") ...
> but not really much else.

I believe bash will eventually (if hasn't already done in devel) allow `$@'
and the like to expand to multiple words inside a compound assignment to an
associative array. Being forced to trim an array to an even number of
elements before using it inside such an assignment would be really
annoying, in my opinion.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]