Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: uninvited members of associative array



On Thu, Dec 15, 2022, at 7:48 PM, Ray Andrews wrote:
> On 2022-12-15 16:05, Lawrence Velázquez wrote:
>> How are you creating and populating "main"? Can you provide a test
>> case that the rest of us can actually use?
>
> There's always the chance it doesn't even come to that, some artifact in 
> the way the array prints or something.

It makes no sense to question the code before verifying that your
data isn't garbage.


> But if you need to see an 
> initialization:
>
>
> # nlist(): Initialize 'main' array.  10 elements: 
> -----------------------------
> main[window]="main"
> main[list]='List'
> main[lastE]="$#List"
> main[hight]=$(( mainWH - 2 ))
> main[width]=$(( mainWW - 2 ))
> main[bottomE]="$main[hight]"
> main[topE]=1
> main[currentE]=1
> main[offset]=0
> main[active]=1

Still a bad test case because it depends on a bunch of other variables
that we have to guess about.  I don't understand why you can't provide
something self-contained.

Is that really all that's in "main"?  What does "typeset -p main"
say?


> ... all values assign properly, so where do the uninvited keywords come 
> from?

Still not seeing a problem.

	% cat foo.zsh
	typeset -A main

	main[window]=main
	main[list]=List
	main[lastE]=196
	main[height]=48
	main[width]=90
	main[bottomE]="$main[height]"
	main[topE]=1
	main[currentE]=1
	main[offset]=0
	main[active]=1

	typeset -p main

	printf '%-20s %s\n' ${(kv)main}

	% zsh foo.zsh
	typeset -A main=( [active]=1 [bottomE]=48 [currentE]=1 [height]=48 [lastE]=196 [list]=List [offset]=0 [topE]=1 [width]=90 [window]=main )
	width                90
	window               main
	offset               0
	topE                 1
	height               48
	active               1
	bottomE              48
	lastE                196
	list                 List
	currentE             1

-- 
vq




Messages sorted by: Reverse Date, Date, Thread, Author