Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug Report: Env Vars and shell functions



There is still a bug here:

% bug () { : }
% export FOO=foo
% FOO=bar bug
% printenv FOO
bar

The patch below hepefully fixes that.

Zoltan


*** Src/exec.c	1996/07/10 02:15:42	2.55
--- Src/exec.c	1996/07/10 02:15:50
***************
*** 1696,1701 ****
--- 1696,1706 ----
  		paramtab->removenode(paramtab, s);
  		addlinknode(*remove_p, s);
  		addlinknode(*restore_p, pm);
+ 		if ((pm->flags & PM_EXPORTED) && pm->env) {
+ 		    delenv(pm->env);
+ 		    zsfree(pm->env);
+ 		    pm->env = NULL;
+ 		}
  	    }
  	} else {
  	    addlinknode(*remove_p, s);
***************
*** 1721,1728 ****
  
      if (restorelist) {
  	/* restore saved parameters */
! 	while ((pm = (Param) getlinknode(restorelist)))
  	    paramtab->addnode(paramtab, pm->nam, pm);
  	freelinklist(restorelist, 0);
      }
  }
--- 1726,1736 ----
  
      if (restorelist) {
  	/* restore saved parameters */
! 	while ((pm = (Param) getlinknode(restorelist))) {
  	    paramtab->addnode(paramtab, pm->nam, pm);
+ 	    if (pm->flags & PM_EXPORTED)
+ 		pm->env = addenv(pm->nam, getsparam(pm->nam));
+ 	}
  	freelinklist(restorelist, 0);
      }
  }




Messages sorted by: Reverse Date, Date, Thread, Author