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