Blame SOURCES/ksh-20120801-oldenvinit.patch

dc1902
diff -up ksh-20120801/src/cmd/ksh93/sh/init.c.fixset ksh-20120801/src/cmd/ksh93/sh/init.c
dc1902
--- ksh-20120801/src/cmd/ksh93/sh/init.c.fixset	2014-11-03 15:45:36.510997271 +0100
dc1902
+++ ksh-20120801/src/cmd/ksh93/sh/init.c	2014-11-03 16:20:44.398917280 +0100
dc1902
@@ -2003,8 +2003,91 @@ static Dt_t *inittree(Shell_t *shp,const
dc1902
  * skip over items that are not name-value pairs
dc1902
  */
dc1902
 
dc1902
+
dc1902
 static void env_init(Shell_t *shp)
dc1902
 {
dc1902
+	register char *cp;
dc1902
+	register Namval_t	*np;
dc1902
+	register char **ep=environ;
dc1902
+	register char *next=0;
dc1902
+#ifdef _ENV_H
dc1902
+	shp->env = env_open(environ,3);
dc1902
+	env_delete(shp->env,"_");
dc1902
+#endif
dc1902
+	if(ep)
dc1902
+	{
dc1902
+		while(cp= *ep++)
dc1902
+		{
dc1902
+			if(*cp=='A' && cp[1]=='_' && cp[2]=='_' && cp[3]=='z' && cp[4]=='=')
dc1902
+				next = cp+4;
dc1902
+			else if(np=nv_open(cp,shp->var_tree,(NV_EXPORT|NV_IDENT|NV_ASSIGN|NV_NOFAIL))) 
dc1902
+			{
dc1902
+				nv_onattr(np,NV_IMPORT);
dc1902
+				np->nvenv = cp;
dc1902
+				nv_close(np);
dc1902
+			}
dc1902
+			else  /* swap with front */
dc1902
+			{
dc1902
+				ep[-1] = environ[shp->nenv];
dc1902
+				environ[shp->nenv++] = cp;
dc1902
+			}
dc1902
+		}
dc1902
+		while(cp=next)
dc1902
+		{
dc1902
+			if(next = strchr(++cp,'='))
dc1902
+				*next = 0;
dc1902
+			np = nv_search(cp+2,shp->var_tree,NV_ADD);
dc1902
+			if(np!=SHLVL && nv_isattr(np,NV_IMPORT|NV_EXPORT))
dc1902
+			{
dc1902
+				int flag = *(unsigned char*)cp-' ';
dc1902
+				int size = *(unsigned char*)(cp+1)-' ';
dc1902
+				if((flag&NV_INTEGER) && size==0)
dc1902
+				{
dc1902
+					/* check for floating*/
dc1902
+					char *ep,*val = nv_getval(np);
dc1902
+					strtol(val,&ep,10);
dc1902
+					if(*ep=='.' || *ep=='e' || *ep=='E')
dc1902
+					{
dc1902
+						char *lp;
dc1902
+						flag |= NV_DOUBLE;
dc1902
+						if(*ep=='.')
dc1902
+						{
dc1902
+							strtol(ep+1,&lp,10);
dc1902
+							if(*lp)
dc1902
+								ep = lp;
dc1902
+						}
dc1902
+						if(*ep && *ep!='.')
dc1902
+						{
dc1902
+							flag |= NV_EXPNOTE;
dc1902
+							size = ep-val;
dc1902
+						}
dc1902
+						else
dc1902
+							size = strlen(ep);
dc1902
+						size--;
dc1902
+					}
dc1902
+				}
dc1902
+				nv_newattr(np,flag|NV_IMPORT|NV_EXPORT,size);
dc1902
+			}
dc1902
+			else
dc1902
+				cp += 2;
dc1902
+		}
dc1902
+	}
dc1902
+#ifdef _ENV_H
dc1902
+	env_delete(shp->env,e_envmarker);
dc1902
+#endif
dc1902
+	if(nv_isnull(PWDNOD) || nv_isattr(PWDNOD,NV_TAGGED))
dc1902
+	{
dc1902
+		nv_offattr(PWDNOD,NV_TAGGED);
dc1902
+		path_pwd(shp,0);
dc1902
+	}
dc1902
+	if((cp = nv_getval(SHELLNOD)) && (sh_type(cp)&SH_TYPE_RESTRICTED))
dc1902
+		sh_onoption(SH_RESTRICTED); /* restricted shell */
dc1902
+	return;
dc1902
+}
dc1902
+
dc1902
+
dc1902
+static void env_init_backup(Shell_t *shp)
dc1902
+{
dc1902
 	register char		*cp;
dc1902
 	register Namval_t	*np,*mp;
dc1902
 	register char		**ep=environ;