From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21581 invoked from network); 15 Sep 2000 17:37:24 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 15 Sep 2000 17:37:24 -0000 Received: (qmail 20820 invoked by alias); 15 Sep 2000 17:36:27 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 12811 Received: (qmail 20811 invoked from network); 15 Sep 2000 17:36:27 -0000 X-Envelope-Sender-Is: Andrej.Borsenkow@mow.siemens.ru (at relayer david.siemens.de) From: "Andrej Borsenkow" To: "Bart Schaefer" , Subject: RE: PATCH: "typeset -m" plays havoc Date: Fri, 15 Sep 2000 21:36:22 +0400 Message-ID: <000001c01f3b$77210c80$21c9ca95@mow.siemens.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) In-Reply-To: <1000915163540.ZM17226@candle.brasslantern.com> Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 > erase_PS1() { typeset PS1 prompt PROMPT } Hmm ... in case of prompts what (very probably) happens: - for the first parameter typeset_single() calls copyparam() to save old value; this creates new parameter and copies old *string* value. Then it sets value to "" creating new empty parameter - that actually sets variable "prompt" to empty string. - for the second and third parameters exactly the same happens ... but now the saved value is already empty string (all three actually refer to the same variable "prompt"). When functions exits it restores values - I think, it depends on order of paramtable scan which of three it hits. If it hits the one with empty value last, prompt gets reset to empty value. > flush_history() { typeset HISTSIZE } In case of HISTSIZE it preserves the value, of course, but in typeset_single() it sets value of new parameter that has side effect of flushing history. So far it is correct :-) assuming that set/get functions do what they are expected to. > > That's all I have time to hunt around for right now, but it does look as > if it's not necessary to force `typeset -m' to work on globals. AFAICT, > the reason it worked this way in previous versions was because of the > parameter table search: Since you can't possibly refer to a non-existing > parameter with `typeset -m', you must therefore be referring to the one > that already exists. Now that we have `+g', though, there's no reason > one can't say "find this global parameter and force it to be local". So > I'll send a revised patch (a subset of Andrej's 12806, really) as soon as > I have time to revise the doc slightly to match. > I do not quite understand, what typeset -m is supposed to do. 1. If used alone, typeset -m is expected to just print parameters. It is currently broken, because typeset_single() will print only if there are no flags to set, and bin_typeset() will (almost) always set at least PM_LOCAL. Patch in 12806 was wrong of course, but we should prevent setting PM_LOCAL in this case. 2. What I do not understand, what typeset -m es expected do if any flag is present? It may be interpreted as "print parameters that match and have this flag set" or "set flags for matching parameters". In the former case typeset_single() is broken. The semantic of latter is unclear (wrt global/local *) but in any case it should not create new parameters. But, unfortunately, this happens currently for all I can tell. *) I mean, allowing it to change global parameters makes things really confusing. Typeset is expected normally to work for local parameters only. -andrej