From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1273 invoked from network); 4 Apr 2000 12:00:01 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 4 Apr 2000 12:00:01 -0000 Received: (qmail 12793 invoked by alias); 4 Apr 2000 11:59:42 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10463 Received: (qmail 12781 invoked from network); 4 Apr 2000 11:59:41 -0000 Date: Tue, 4 Apr 2000 13:59:39 +0200 (MET DST) Message-Id: <200004041159.NAA13164@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: Clint Adams's message of Mon, 3 Apr 2000 23:08:05 -0400 Subject: PATCH: Re: exporting -variables [was Re: PATCH: 3.1.6-dev-20: _dpkg thinko] Clint Adams wrote: > > Allegedly this is causing "-i=irs" to be exported, though I can't > > reproduce it. > > I can. If ALL_EXPORT is on, variables beginning with > hyphens will be exported during _arguments. Is this a problem? > bash seems to think such things are invalid. > > e.g.: > sh: invalid character 45 in exportstr for -f Aha. The problem behind the scenes, was, obviously, this: % setopt allexport % typeset -A foo % foo[bar]=baz % env|grep bar bar=baz The sub-parameters used in assocs get exported... The patch adds the PM_HASHELEM flag to be able to detect such param structs and then keeps them from being exported. Bye Sven Index: Src/builtin.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v retrieving revision 1.2 diff -u -r1.2 builtin.c --- Src/builtin.c 2000/04/01 20:49:47 1.2 +++ Src/builtin.c 2000/04/04 11:58:42 @@ -1630,7 +1630,8 @@ if (!(pm->flags & PM_UNSET) && !pm->env && !value) pm->env = addenv(pname, getsparam(pname), pm->flags); } else if (pm->env && - (!pm->level || (isset(ALLEXPORT) && !pm->old))) { + (!pm->level || (isset(ALLEXPORT) && !pm->old && + !(pm->flags & PM_HASHELEM)))) { delenv(pm->env); zsfree(pm->env); pm->env = NULL; Index: Src/params.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/params.c,v retrieving revision 1.2 diff -u -r1.2 params.c --- Src/params.c 2000/04/01 20:49:48 1.2 +++ Src/params.c 2000/04/04 11:58:43 @@ -617,6 +617,9 @@ { Param pm, oldpm; + if (paramtab != realparamtab) + flags = (flags & ~PM_EXPORTED) | PM_HASHELEM; + if (name != nulstring) { oldpm = (Param) (paramtab == realparamtab ? gethashnode2(paramtab, name) : @@ -646,7 +649,7 @@ paramtab->addnode(paramtab, ztrdup(name), pm); } - if (isset(ALLEXPORT) && !oldpm) + if (isset(ALLEXPORT) && !oldpm && !(flags & PM_HASHELEM)) flags |= PM_EXPORTED; } else { pm = (Param) zhalloc(sizeof *pm); @@ -1520,7 +1523,7 @@ break; } if ((!v->pm->env && !(v->pm->flags & PM_EXPORTED) && - !(isset(ALLEXPORT) && !v->pm->old)) || + !(isset(ALLEXPORT) && !v->pm->old && !(v->pm->flags & PM_HASHELEM))) || (v->pm->flags & PM_ARRAY) || v->pm->ename) return; if (PM_TYPE(v->pm->flags) == PM_INTEGER) @@ -2742,7 +2745,7 @@ */ if (t == path) cmdnamtab->emptytable(cmdnamtab); - if (isset(ALLEXPORT) ? !!pm->old : pm->level) + if ((pm->flags & PM_HASHELEM) || (isset(ALLEXPORT) ? !!pm->old : pm->level)) return; u = t ? zjoin(t, ':', 1) : ""; len_s = strlen(s); Index: Src/zsh.h =================================================================== RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v retrieving revision 1.2 diff -u -r1.2 zsh.h --- Src/zsh.h 2000/04/01 20:49:48 1.2 +++ Src/zsh.h 2000/04/04 11:58:43 @@ -1125,6 +1125,7 @@ #define PM_REMOVABLE (1<<21) /* special can be removed from paramtab */ #define PM_AUTOLOAD (1<<22) /* autoloaded from module */ #define PM_NORESTORE (1<<23) /* do not restore value of local special */ +#define PM_HASHELEM (1<<24) /* is a hash-element */ /* The option string corresponds to the first of the variables above */ #define TYPESET_OPTSTR "aiEFALRZlurtxUhT" -- Sven Wischnowsky wischnow@informatik.hu-berlin.de