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

Re: zsh does not execute skripts on AIX?



> > > I have encountered a strange behavour of the zsh on AIX 3.2 .
> > > The zsh (2.5 and 3.1) does not execute scripts that are passed to the
> > > /bin/sh . The sh drops the error message:
> > > : 0402-026 The specified data is not a valid identifier.
> > 
> > Looks like there is some junk in the environment which confuses /bin/sh.
> > I've never had such problems on AIX.  Probably the program which calls zsh
> > put something into the environment which sh cannot handle.  Zsh just passes
> > this down to sh while ksh probably filters this out.

The patch below should take care of this problem.  It only adds those
variables to the new environment which are accessable via zsh parameters.
If an environment variable is multiply defined, only the second
definition is kept and the there will be only a single definition in the
new environment (this is consistent with ksh).

Zoltan


*** Src/params.c	1997/06/05 04:44:57	3.1.3.0
--- Src/params.c	1997/06/16 04:16:25
***************
*** 98,110 ****
  	old_environ = environ;
  	num_env = arrlen(old_environ);
  	environ = (char **) zalloc(sizeof(char *) * (num_env + 1));
! 	for (envp = environ, envp2 = old_environ; *envp2; envp2++)
! 	    *envp++ = ztrdup(*envp2);
! 	*envp = NULL;
  
  	/* Now incorporate environment variables we are inheriting *
  	 * into the parameter hash table.                          */
! 	for (envp = environ, envp2 = old_environ; *envp2; envp++, envp2++) {
  	    for (str = *envp2; *str && *str != '='; str++);
  	    if (*str == '=') {
  		iname = NULL;
--- 98,108 ----
  	old_environ = environ;
  	num_env = arrlen(old_environ);
  	environ = (char **) zalloc(sizeof(char *) * (num_env + 1));
! 	*environ = NULL;
  
  	/* Now incorporate environment variables we are inheriting *
  	 * into the parameter hash table.                          */
! 	for (envp = environ, envp2 = old_environ; *envp2; envp2++) {
  	    for (str = *envp2; *str && *str != '='; str++);
  	    if (*str == '=') {
  		iname = NULL;
***************
*** 113,125 ****
  		    iname = *envp2;
  		    if ((!(pm = (Param) paramtab->getnode(paramtab, iname)) ||
  			 !(pm->flags & PM_DONTIMPORT)) &&
! 			(pm = setsparam(iname, metafy(str + 1, -1, META_DUP)))) {
  			pm->flags |= PM_EXPORTED;
! 			pm->env = *envp;
  			if (pm->flags & PM_SPECIAL)
! 			    pm->env = replenv(pm->env, getsparam(iname));
! 		    } else if (pm)
! 			for (t = envp--; (t[0] = t[1]); t++);
  		}
  		*str = '=';
  	    }
--- 111,125 ----
  		    iname = *envp2;
  		    if ((!(pm = (Param) paramtab->getnode(paramtab, iname)) ||
  			 !(pm->flags & PM_DONTIMPORT)) &&
! 			(pm = setsparam(iname, metafy(str + 1, -1, META_DUP))) &&
! 			!(pm->flags & PM_EXPORTED)) {
! 			*str = '=';
  			pm->flags |= PM_EXPORTED;
! 			pm->env = *envp++ = ztrdup(*envp2);
! 			*envp = NULL;
  			if (pm->flags & PM_SPECIAL)
! 			    pm->env = replenv(pm->env, getsparam(pm->nam));
! 		    }
  		}
  		*str = '=';
  	    }



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