zsh-workers
 help / color / mirror / code / Atom feed
* ${#${(A)=name=word}} behavior depends on number of elements
@ 2016-08-12 22:11 Lawrence Velázquez
  2016-08-12 23:04 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Lawrence Velázquez @ 2016-08-12 22:11 UTC (permalink / raw)
  To: zsh-workers

As I would expect, ${#${(A)=name=word}} expands to the number of
elements in array "foo" after assignment.

	% unset foo; echo ${#${(A)=foo=a 'b c' d}}; typeset foo
	3
	foo=( a 'b c' d )

However, if "foo" ends up with just one element, the expression expands
to the number of characters in that element.

	% unset foo; echo ${#${(A)foo=abc}}; typeset foo    
	3
	foo=( abc )
	% unset foo; echo ${#${(A)=foo=abc}}; typeset foo 
	3
	foo=( abc )
	% unset foo; echo ${#${(A)foo=a b c}}; typeset foo  
	5
	foo=( 'a b c' )
	% unset foo; echo ${#${(A)=foo='a b c'}}; typeset foo
	5
	foo=( 'a b c' )

The behavior is the same for ":=" and "::=".

	% echo $ZSH_PATCHLEVEL
	zsh-5.2-0-gc86c20a
	% setopt
	combiningchars
	extendedhistory
	incappendhistorytime
	interactive
	login
	monitor
	promptsubst
	shinstdin
	zle

vq


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

end of thread, other threads:[~2016-08-12 23:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-12 22:11 ${#${(A)=name=word}} behavior depends on number of elements Lawrence Velázquez
2016-08-12 23:04 ` 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).