Blame SOURCES/ksh-20120801-oldenvinit.patch

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