zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: Re: exporting -variables [was Re: PATCH: 3.1.6-dev-20: _dpkg thinko]
Date: Tue, 4 Apr 2000 13:59:39 +0200 (MET DST)	[thread overview]
Message-ID: <200004041159.NAA13164@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Clint Adams's message of Mon, 3 Apr 2000 23:08:05 -0400


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


                 reply	other threads:[~2000-04-04 12:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=200004041159.NAA13164@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@sunsite.auc.dk \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public 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).