From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13926 invoked from network); 28 Sep 1999 13:40:51 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 28 Sep 1999 13:40:51 -0000 Received: (qmail 19263 invoked by alias); 28 Sep 1999 13:40:37 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8086 Received: (qmail 19253 invoked from network); 28 Sep 1999 13:40:33 -0000 Message-Id: <9909281304.AA18217@ibmth.df.unipi.it> To: zsh-workers@sunsite.auc.dk Subject: Re: assoc array assignment problem. In-Reply-To: "Peter Stephenson"'s message of "Tue, 28 Sep 1999 14:15:43 DFT." <9909281215.AA16286@ibmth.df.unipi.it> Date: Tue, 28 Sep 1999 15:04:48 +0200 From: Peter Stephenson I wrote: > Two comments: This is supposed to take care of the first and the third. Now the following works: typeset -A assoc foo=random arg='$foo' assoc[$arg]=bar print ${(kv)assoc} $foo bar and the restricted mode crash should go, too. I don't think either of these should have adverse effects. The other issue --- tokenization and retokenization of the subscript --- turns out to be more complicated. In an expression like "$foo[(r)b*]", you would indeed need to tokenize what you have already. Perhaps that could be done by paramsubst(), which knows if it's in quotes, but as the code that uses this is buried in fetchvalue() it's hard to be sure. Alternatively, it could be given a flag that it was in double quotes and so needed (with certain flags only) to retokenize the expression. Alternatively, it could be left as it is with consequent inefficiency. I discovered another problem. foo= assoc[$foo]=rod print ${(kv)assoc} rod $foo bar unset assoc[$foo] assoc[] "assoc[$foo]" "assoc[]" print ${(kv)assoc} rod $foo bar I haven't found anything which gets rid of it. --- Src/exec.c.subst Tue Sep 28 13:58:30 1999 +++ Src/exec.c Tue Sep 28 14:37:08 1999 @@ -1336,9 +1336,6 @@ for (n = firstnode(l); n; incnode(n)) { v = (Varasg) getdata(n); name = dupstring(v->name); - singsub(&name); - if (errflag) - return; untokenize(name); if (xtr) fprintf(stderr, "%s=", name); @@ -1370,15 +1367,13 @@ } if (xtr) fprintf(stderr, "%s ", val); - if (export) { - if (export < 0) { - /* We are going to fork so do not bother freeing this */ - pm = (Param) paramtab->removenode(paramtab, name); - if (isset(RESTRICTED) && (pm->flags & PM_RESTRICTED)) { - zerr("%s: restricted", pm->nam, 0); - zsfree(val); - return; - } + if (export && !strchr(name, '[')) { + if (export < 0 && isset(RESTRICTED) && + (pm = (Param) paramtab->removenode(paramtab, name)) && + (pm->flags & PM_RESTRICTED)) { + zerr("%s: restricted", pm->nam, 0); + zsfree(val); + return; } allexp = opts[ALLEXPORT]; opts[ALLEXPORT] = 1; -- Peter Stephenson Tel: +39 050 844536 WWW: http://www.ifh.de/~pws/ Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy