Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
empty element in 'structure'.
- X-seq: zsh-users 30661
- From: Ray Andrews <rayandrews@xxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: empty element in 'structure'.
- Date: Thu, 14 May 2026 08:48:07 -0700
- Archived-at: <https://zsh.org/users/30661>
- List-id: <zsh-users.zsh.org>
Some of my functions use what is in practice a structure tho in
theory I guess it's just a collection of scalars and arrays, but
it's all copied in one go like this:
set -A IN "${(@Pkv)1}" # Copy the array to IN, the working
copy.
... anyway it's very fragile, the 'structure' must never change,
so even when a given 'element' isn't used, it must exist. Here's
a slice of one such structure:
body[window]="Body"
body[list]="body_list"
body[page_tops]="Btops"
Bclicks=()
body[mouse_clicks]="Bclicks"
# body[mouse_clicks]="()"
body[hight]=$((Hight))
body[width]=$BW
... now here's the issue: 'body[mouse_clicks]' isn't used but
again, it must exist otherwise the 'set' command above crashes. If
I use the rather phony:
Bclicks=()
body[mouse_clicks]="Bclicks"
... it works fine. But if I cut to the chase and do:
body[mouse_clicks]="()"
... it doesn't work, the 'structure' fails cuz the 'element'
vanishes -- I think. Purely as a question of semantics is there a
way to do it the 'direct' way and avoid the placeholder 'Bclicks'?
I know there's ways of hanging on to empty elements in an normal
array and I thought the quotes "()" would do it, but nada. Or is
this pushing zsh where she doesn't want to go? That is, preserving
an entire empty array withing a pseudo structure? But again, doing
it the 'long way' works fine.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author