From: Bart Schaefer <schaefer@brasslantern.com> To: Zsh hackers list <zsh-workers@zsh.org> Subject: zsh/db oddities Date: Mon, 6 Sep 2021 21:29:07 -0700 [thread overview] Message-ID: <CAH+w=7bcLDkhMnRHjsFnD3+S3rbP4gMRLAK0YAFZ5bW9xndbww@mail.gmail.com> (raw) The only example so far is of course zsh/db/gdbm. Open a database as a global and assign something to it: % zmodload zsh/db/gdbm ztie -d db/gdbm -f sample.gdbm sampledb % sampledb[GLOBAL]=global % cksum sample.gdbm 3454148649 16384 sample.gdbm Now start messing with the declaration in a function: % () { cksum sample.gdbm local sampledb typeset +m sampledb cksum sample.gdbm sampledb[INFUNC]=set cksum sample.gdbm print $sampledb[INFUNC] } 3454148649 16384 sample.gdbm association local sampledb 2087515864 16384 sample.gdbm 2669724292 16384 sample.gdbm set As soon as the tied parameter is declared local, the file has been written, erasing all the existing values. This seems undesirable? Returning to the top level: % cksum sample.gdbm 1634404396 16384 sample.gdbm % typeset -p sampledb typeset -A sampledb=( [GLOBAL]=global ) The file has been written again and the original state is back. If instead you zuntie the local: % () { local sampledb sampledb[LOCAL]=local zuntie sampledb } % typeset -p sampledb typeset: no such variable: sampledb Untying the local destroys the global, too, and leaves the file as the local wrote it. % ztie -d db/gdbm -f sample.gdbm sampledb % typeset -p sampledb typeset -A sampledb=( [LOCAL]=local ) I think the correct thing might be to prohibit changing the scope, similar to what happens when an attempt is made to remove the readonly attribute? % ztie -r -d db/gdbm -f sample.gdbm sampledb % () { local -A +r sampledb } (anon):local:1: sampledb: can't change type of a special parameter Re-ztie-ing the database file while it is still tied, is already handled as an error.
next reply other threads:[~2021-09-07 4:29 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-09-07 4:29 Bart Schaefer [this message] 2022-06-12 21:19 ` [PATCH] " Bart Schaefer
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to='CAH+w=7bcLDkhMnRHjsFnD3+S3rbP4gMRLAK0YAFZ5bW9xndbww@mail.gmail.com' \ --to=schaefer@brasslantern.com \ --cc=zsh-workers@zsh.org \ --subject='Re: zsh/db oddities' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Code repositories for project(s) associated with this 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).