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