From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22203 invoked from network); 15 Sep 2000 18:47:58 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 15 Sep 2000 18:47:58 -0000 Received: (qmail 28367 invoked by alias); 15 Sep 2000 18:47:30 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 12813 Received: (qmail 28353 invoked from network); 15 Sep 2000 18:47:25 -0000 From: "Bart Schaefer" Message-Id: <000915114622.ZM17315@candle.brasslantern.com> Date: Fri, 15 Sep 2000 11:46:22 -0700 In-Reply-To: <000001c01f3b$77210c80$21c9ca95@mow.siemens.ru> Comments: In reply to "Andrej Borsenkow" "RE: PATCH: "typeset -m" plays havoc" (Sep 15, 9:36pm) References: <000001c01f3b$77210c80$21c9ca95@mow.siemens.ru> X-Mailer: Z-Mail Lite (5.0.0 30July97) To: Subject: Re: PATCH: "typeset -m" plays havoc MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Sep 15, 9:36pm, Andrej Borsenkow wrote: > > I do not quite understand, what typeset -m is supposed to do. Historically (e.g., zsh 2.4, which I happen to have found on an old disk and recompiled recently): - `typeset -m' always works on existing parameters that are "visible" in the current scope, regardless of the scope in which they were set or will be unset/restored. - `typeset -m ...' with no other options prints those parameters. - with other options, it changes the associated attributes of all the existing, matching parameters. That last is a lot of rope with which to hang yourself, and zsh was never thoroughly tested to be sure you couldn't take the whole shell with you. What I propose is to make the rope slightly longer, and actually cause `+g' to mean something: typeset +g -m foo would mean to create a local parameter named foo if an only if there is already a parameter named foo visible in the current scope. (Without the `-m', `+g' already unconditionally creates a local parameter.) This would be useful mostly as a shorthand, e.g. (assuming the other bugs with localizing certain parameters get fixed) the prompt preview code may want to do something like: typeset +g -h -m '(#i)(prompt|ps)*' > *) I mean, allowing it to change global parameters makes things really > confusing. Typeset is expected normally to work for local parameters only. My position is that: - There's historical precedent for this behavior. - `typeset -m' is unique to zsh, so it's not a conflict with semantics for sh or ksh scripts. - You can't otherwise refer to a parameter by pattern, so it shouldn't be too difficult to realize you're doing something unusual. - It's useful to be able to dump the values of selected parameters in the current scope without jumping through the sorts of hoops that e.g. Util/reporter does. On the latter note, I'd like to change `typeset +m' to mean something akin to `typeset +' in that it would dump only the names and type information rather than the values. (`typeset + name' dumps the name and value.) But that's a more significant change, so I probably won't, just yet.