Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: uninvited members of associative array
- X-seq: zsh-users 28554
- From: Dominik Vogt <dominik.vogt@xxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: uninvited members of associative array
- Date: Fri, 16 Dec 2022 11:05:26 +0100
- Archived-at: <https://zsh.org/users/28554>
- In-reply-to: <cf00d14b-389f-2de2-3a9a-91fec333ebab@eastlink.ca>
- List-id: <zsh-users.zsh.org>
- Mail-followup-to: zsh-users@xxxxxxx
- References: <e2358c69-b70f-8ed7-ce91-218e65a0189f@eastlink.ca> <b63cd138-fc96-4c4b-b6dd-49205652363a@app.fastmail.com> <0c2b1f8f-35bb-cd52-3d22-0964a73945b2@eastlink.ca> <Y5vTVe0/TdAd3W4p@localhost> <ef79416b-19cd-c530-019c-37908525df23@eastlink.ca> <46161d8a-c177-4134-836e-592e5c048887@app.fastmail.com> <cf00d14b-389f-2de2-3a9a-91fec333ebab@eastlink.ca>
- Reply-to: dominik.vogt@xxxxxx
- Ui-outboundreport: notjunk:1;M01:P0:AyjVY4H33gU=;1HX2F9qaxpNGEUQwC5ZxbATe8uW fftjP6CGFOhPBAGtvTSxaCGGLcRuCY0JUcKupSsxEglOkdzTce+C7c7hyUfVSBGVW1H86JjlH nMKrkxENVFtdnnQJ7kMM+cgZ8CQIphxxKRyO09hHsriuiAF/F3WXG80ywMfHDKadgxS42e0bS xsa7XGFesdpa+5Ex7ApYFFKMHP03vKgqiPmnabpjhc8PMlM3GGWk0/an+Wktlp94pG09zaj0o rND+PtHBEE03FEiRxxgWV/clF2uZ5au7dWdpuHzT91fooez5R5N1V6CniHE4MkV7d+E4zI3ts EKNZ594Wv+UDS/oqF+/GLBVoYqttxAJiyL7WjWL9WnS5r6Vmi2Hqg+1XwcLYEdPQ6KC0nQwNu qKzzP0NoVOOd7890xHvRHpXqDz9QFeErig5x9NZgHQ+I95rqgRqlgLhNNgeupJj/XpIy+R+ZX om4VN/7K5xf8PbW6iaMK+8GmMMNAoy/KWyMzytsxOIxww/IT7WBAlY1IRMNdcBYa9RwF1YnIH 1IPD8vF30YAc9LyN+zgp8PMJQ9j3xL3MRwffVJfsKRtlErwoXWpYPjWomrRD4i37iqxd2SkQe B0Lm9hSwEIYIjt65p/eAXOMhrV4UpQ0GttYTslq1NibbTDCIFIDKdfyLN3SyUUIsPoBRZi8EW iL3xcuJWLe0KEfWxmrRufqmddrcQsuEX5ikSOrQQAKwVnRz0ufrGfKzTVIyAWYi+bcZn0A+io 7fNjkW3ubaHKqCQNr7Per/FM2chBOs7WfS2s7wbiB5Au3nS3eygMYeMIsYZYFyFaSewbuGxka /j4BvlgSzMTBVZ2MuMrQA/ZnPL2SKks0G2iUDWoU1TQwLYxU+m1h3b6HKEeJTvH70rEEhZ09U XnW539lS3Gt2q8gtr2MSbxCi5M3nnLNTa/oN+PcYSPvjq0r90MJty2iGJtKc0ag/ajH8RelgU 70yT5g==
On Thu, Dec 15, 2022 at 08:16:46PM -0800, Ray Andrews wrote:
>
> On 2022-12-15 19:21, Lawrence Velázquez wrote:
> > Or before.
> Exactly the case here. This code has many global variables and ... well, no
> need to say more.
> > Wrong. It assumed that "main" contained the expected data and
> > nothing extra. I've already asked you to use "typeset -p" to verify
> > its actual contents, but you still haven't.
>
> No need, zeroing the array solves the issue. Mind, I suppose I could do a
> forensic on that, and figure out when and where the corruption occurs
The issue is not solved. You still have something that adds the
bogus values before the reinitialisation. Whether this has some
adverse effects depends on the scripts. (Sample script attached).
Basically you probably do ~ this:
init_main
# ...
main=($main) <-- Creates extra values
# ...
init_main
printf "%-20s %s\n" ${(kv)main}
This is a bug in your scripts and not in zsh.
> and then, of course I'll use typeset -p
Forget about the typeset, look for "main=$(main)" or similar.
Ciao
Dominik ^_^ ^_^
--
Dominik Vogt
#!/usr/bin/zsh
emulate zsh
List="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
mainWH="50"
mainWW="92"
typeset -A main
init_main () {
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; echo ${(kv)main}
}
init_main
main=($main)
init_main
printf "%-20s %s\n" ${(kv)main}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author