bug-bash
[Top][All Lists]
Advanced

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

Re: zsh style associative array assignment bug


From: Eric Cook
Subject: Re: zsh style associative array assignment bug
Date: Wed, 31 Mar 2021 12:00:37 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1

On 3/30/21 3:44 PM, Chet Ramey wrote:
Is this a serious piece of code, or just one to demonstrate a programming
error?
The latter

There is only one field, terminated by `|', which becomes one array
element. This is where you `lose' the null elements, not when you attempt
to copy. Nothing you do after it matters.


I wasn't trying to imply that there ever was an element that was `lost'.
(or code golf for the bystanders trying to optimize) just that the author
of an script can make an incorrect assumption on input and eventually try
to pass that along to an AA assignment that bash happily accepts and makes
an opinionated assumption of it's own, guessing at the author's intent.
bash's assumption can be equally as wrong compared to erroring out, telling
the user that something is wrong here.


Your point that the bash method of key-value pair assignment doesn't
protect you from programming errors is valid.


Thank you.



reply via email to

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