zsh-workers
 help / color / mirror / code / Atom feed
* Possible bug with ${(A)foo=} and ${(AA)foo=}
@ 1999-06-22 16:13 Andrej Borsenkow
  1999-06-22 17:36 ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Andrej Borsenkow @ 1999-06-22 16:13 UTC (permalink / raw)
  To: ZSH workers mailing list

While playing with something else I discovered, that it is impossible to create
empty array with this form and it is impossible to create hash in this way
without error message:

bor@itsrm2:~%> unset foo
bor@itsrm2:~%> : ${(A)foo=}
bor@itsrm2:~%> print ${#foo}
1

bor@itsrm2:~%> unset foo
bor@itsrm2:~%> : ${(A)foo=""}
bor@itsrm2:~%> print ${#foo}
1

bor@itsrm2:~%> unset foo
bor@itsrm2:~%> : ${(AA)foo=""}
zsh: bad set of key/value pairs for associative array

bor@itsrm2:~%> print ${#foo}
0

bor@itsrm2:~%> : ${(AA)foo=}
zsh: bad set of key/value pairs for associative array

bor@itsrm2:~%> print ${#foo}
0

I think, that if ${foo=} is valid at all, then we must distinguish between no
value and empty value. It is the same as in command line (and, after all, we
compute it using the same rules?) - empty value is lost but explict NULL like ""
is retained. In other words,

${(A)foo=} - creates empty array
${(A)foo=""} - creates array with one element of length 0
${(AA)foo=} - creates empty hash
${(AA)foo=""} - is invalid assignment as expected

[Background - ${(AA)foo=} seems currently to be the only way to create global
hash from within Zsh function]

/andrej


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1999-06-24 15:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-06-22 16:13 Possible bug with ${(A)foo=} and ${(AA)foo=} Andrej Borsenkow
1999-06-22 17:36 ` Bart Schaefer
1999-06-23 10:02   ` Peter Stephenson
1999-06-24 15:36     ` PATCH: " Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).