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

Re: Environment Passed to Functions



shelton@xxxxxxxxxxxxxxxxxxxxxx wrote:
> If an environment variable is set on the command line for a function, then 
> that enviroment variable is only in effect for the first command in the 
> function.

Actually, the problem is slightly different: for shell functions and
builtins the parameter isn't put into the environment at all.  This
must be a bug.

It looks to me like the simplest thing is to export the variable for a
function, not for a builtin (the only two possibilities at that point
in the code).

*** Src/exec.c~	Mon Jun  5 10:34:30 1995
--- Src/exec.c	Thu Jun 15 09:43:27 1995
***************
*** 1416,1422 ****
  	    }
  	    
  	    if (cmd->vars) {
! 		addvars(cmd->vars, 0);
  		if (errflag) {
  		    lastval = 1;
  		    return;
--- 1416,1425 ----
  	    }
  	    
  	    if (cmd->vars) {
! 		/* Export this if the command is a shell function,
! 		 * but not if it's a builtin.
! 		 */
! 		addvars(cmd->vars, cn1->flags & SHFUNC);
  		if (errflag) {
  		    lastval = 1;
  		    return;

-- 
Peter Stephenson <P.Stephenson@xxxxxxxxxxxxx>  Tel: +44 1792 205678 extn. 4461
WWW:  http://python.swan.ac.uk/~pypeters/      Fax: +44 1792 295324
Department of Physics, University of Wales, Swansea,
Singleton Park, Swansea, SA2 8PP, U.K.



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