Lines Matching defs:shp
208 Shell_t *shp = nv_shell(np);
209 if(*name=='E' && nv_getval(sh_scoped(shp,VISINOD)))
211 if(!(cp=val) && (*name=='E' || !(cp=nv_getval(sh_scoped(shp,EDITNOD)))))
235 Shell_t *shp = nv_shell(np);
236 void *histopen = shp->hist_ptr;
244 hist_close(shp->hist_ptr);
250 sh_histinit(shp);
259 Shell_t *shp = nv_shell(np);
260 shp->st.opterror = shp->st.optchar = 0;
284 Shell_t *shp = nv_shell(np);
292 nv_scan(shp->track_tree,rehash,(void*)0,NV_TAGGED,NV_TAGGED);
299 shp->pathlist = (void*)path_unsetfpath((Pathcomp_t*)shp->pathlist);
301 shp->universe = 0;
302 if(shp->pathlist)
306 pp = (void*)path_addpath((Pathcomp_t*)shp->pathlist,val,PATH_PATH);
308 pp = (void*)path_addpath((Pathcomp_t*)shp->pathlist,val,PATH_FPATH);
311 if(shp->pathlist = (void*)pp)
312 pp->shp = shp;
315 Namval_t *mp = dtsearch(shp->var_tree,np);
321 path_dump((Pathcomp_t*)shp->pathlist);
329 Shell_t *shp = nv_shell(np);
331 if(!shp->cdpathlist)
334 pp = (void*)path_addpath((Pathcomp_t*)shp->cdpathlist,val,PATH_CDPATH);
335 if(shp->cdpathlist = (void*)pp)
336 pp->shp = shp;
361 Shell_t *shp = nv_shell(np);
398 if(!sh_isstate(SH_INIT) || shp->login_sh==0)
402 shp->decomma = (lc=localeconv()) && lc->decimal_point && *lc->decimal_point==',';
463 Shell_t *shp;
473 if(!val && !(flags&NV_CLONE) && (fp=np->nvfun) && !fp->disc && (shp=(Shell_t*)(fp->last)))
474 nv_stack(np,&((Init_t*)shp->init_context)->IFS_init.hdr);
486 register Shell_t *shp = nv_shell(np);
491 memset(shp->ifstable,0,(1<<CHAR_BIT));
505 shp->ifstable[c] = S_MBYTE;
516 shp->ifstable[c] = n;
521 shp->ifstable[' '] = shp->ifstable['\t'] = S_SPACE;
522 shp->ifstable['\n'] = S_NL;
565 Shell_t *shp = nv_shell(np);
572 sfprintf(shp->strbuf,"%.*f",places,d);
573 return(sfstruse(shp->strbuf));
649 Shell_t *shp = nv_shell(np);
662 shp->st.firstline += nget_lineno(np,fp)+1-n;
673 Shell_t *shp = nv_shell(np);
676 if(sh_isstate(SH_INIT) && (cp=shp->lastarg) && *cp=='*' && (pid=strtol(cp+1,&cp,10)) && *cp=='*')
678 return(shp->lastarg);
683 Shell_t *shp = nv_shell(np);
686 sfprintf(shp->strbuf,"%.*g",12,*((double*)val));
687 val = sfstruse(shp->strbuf);
691 if(shp->lastarg && !nv_isattr(np,NV_NOFREE))
692 free((void*)shp->lastarg);
695 shp->lastarg = (char*)val;
1025 Shell_t *shp = &sh;
1039 umask(shp->mask=umask(0));
1040 shp->mac_context = sh_macopen(shp);
1041 shp->arg_context = sh_argopen(shp);
1042 shp->lex_context = (void*)sh_lexopen(0,shp,1);
1043 shp->ed_context = (void*)ed_open(shp);
1044 shp->strbuf = sfstropen();
1045 shp->stk = stkstd;
1046 sfsetbuf(shp->strbuf,(char*)0,64);
1061 sh_regress_init(shp);
1064 /* NOTE: only shp is used by __regress__ at this point */
1065 shp->bltindata.shp = shp;
1083 b___regress__(2, regress, &shp->bltindata);
1088 shp->cpipe[0] = -1;
1089 shp->coutpipe = -1;
1090 shp->userid=getuid();
1091 shp->euserid=geteuid();
1092 shp->groupid=getgid();
1093 shp->egroupid=getegid();
1103 shp->lim.clk_tck = getconf("CLK_TCK");
1104 shp->lim.arg_max = getconf("ARG_MAX");
1105 shp->lim.open_max = getconf("OPEN_MAX");
1106 shp->lim.child_max = getconf("CHILD_MAX");
1107 shp->lim.ngroups_max = getconf("NGROUPS_MAX");
1108 shp->lim.posix_version = getconf("VERSION");
1109 shp->lim.posix_jobcontrol = getconf("JOB_CONTROL");
1110 if(shp->lim.arg_max <=0)
1111 shp->lim.arg_max = ARG_MAX;
1112 if(shp->lim.child_max <=0)
1113 shp->lim.child_max = CHILD_MAX;
1114 if((v = getconf("PID_MAX")) > 0 && shp->lim.child_max > v)
1115 shp->lim.child_max = v;
1116 if(shp->lim.open_max <0)
1117 shp->lim.open_max = OPEN_MAX;
1118 if(shp->lim.open_max > (SHRT_MAX-2))
1119 shp->lim.open_max = SHRT_MAX-2;
1120 if(shp->lim.clk_tck <=0)
1121 shp->lim.clk_tck = CLK_TCK;
1124 shp->lim.fs3d = 1;
1126 sh_ioinit(shp);
1128 sh_siginit(shp);
1131 shp->init_context = nv_init(shp);
1137 shp->login_sh = 2;
1139 env_init(shp);
1142 sfprintf(shp->strbuf,"%s/.kshrc",nv_getval(HOME));
1143 nv_putval(ENVNOD,sfstruse(shp->strbuf),NV_RDONLY);
1154 shp->shpath = 0;
1157 shp->shpath = strdup(buff);
1159 sfprintf(shp->strbuf,"/proc/%d/exe",getpid());
1160 if((n=readlink(sfstruse(shp->strbuf),buff,sizeof(buff)-1))>0)
1163 shp->shpath = strdup(buff);
1169 shp->shpath = strdup(cp);
1177 shp->shpath = strdup(stakptr(offset));
1189 shp->st.tmout = SHOPT_TIMEOUT;
1207 shp->userinit = userinit = bash_init;
1210 (*userinit)(shp, 0);
1215 /* shp->st.dolc is $# */
1216 if((shp->st.dolc = sh_argopts(-argc,argv,shp)) < 0)
1218 shp->exitval = 2;
1219 sh_done(shp,0);
1222 shp->st.dolv=argv+(argc-1)-shp->st.dolc;
1223 shp->st.dolv[0] = argv[0];
1224 if(shp->st.dolc < 1)
1228 shp->st.dolc--;
1229 shp->st.dolv++;
1233 name = shp->st.dolv[0];
1258 struct passwd *pw = getpwuid(shp->userid);
1260 shp->user = strdup(pw->pw_name);
1265 if(shp->userid!=shp->euserid || shp->groupid!=shp->egroupid)
1269 if(!sh_isoption(SH_PRIVILEGED) && shp->userid >= SHOPT_P_SUID)
1271 setuid(shp->euserid=shp->userid);
1272 setgid(shp->egroupid=shp->groupid);
1279 if(shp->login_sh && argv[1] && strcmp(argv[0],argv[1])==0)
1287 shp->shname = strdup(argv[0]);
1289 shp->shname = strdup(shp->st.dolv[0]);
1294 error_info.id = strdup(shp->st.dolv[0]); /* error_info.id is $0 */
1295 shp->jmpbuffer = (void*)&shp->checkbase;
1296 sh_pushcontext(&shp->checkbase,SH_JMPSCRIPT);
1297 shp->st.self = &shp->global;
1298 shp->topscope = (Shscope_t*)shp->st.self;
1302 shp->login_files = login_files;
1303 shp->bltindata.version = SH_VERSION;
1304 shp->bltindata.shp = shp;
1305 shp->bltindata.shrun = sh_run;
1306 shp->bltindata.shtrap = sh_trap;
1307 shp->bltindata.shexit = sh_exit;
1308 shp->bltindata.shbltin = sh_addbuiltin;
1310 shp->bltindata.shgetenv = sh_getenv;
1311 shp->bltindata.shsetenv = sh_setenviron;
1312 astintercept(&shp->bltindata,1);
1330 if(shp->userinit=userinit)
1331 (*userinit)(shp, 0);
1332 return(shp);
1345 Shell_t *shp = &sh;
1349 for(np=dtfirst(shp->fun_tree);np;np=npnext)
1351 if((dp=shp->fun_tree)->walk)
1353 npnext = (Namval_t*)dtnext(shp->fun_tree,np);
1354 if(np>= shp->bltin_cmds && np < &shp->bltin_cmds[nbltins])
1362 dtclose(shp->alias_tree);
1363 shp->alias_tree = inittree(shp,shtab_aliases);
1364 shp->last_root = shp->var_tree;
1365 shp->namespace = 0;
1366 shp->inuse_bits = 0;
1367 if(shp->userinit)
1368 (*shp->userinit)(shp, 1);
1369 if(shp->heredocs)
1371 sfclose(shp->heredocs);
1372 shp->heredocs = 0;
1376 nv_scan(shp->var_tree,sh_envnolocal,(void*)0,NV_EXPORT,0);
1377 nv_scan(shp->var_tree,sh_envnolocal,(void*)0,NV_ARRAY,NV_ARRAY);
1379 memset(shp->st.trapcom,0,(shp->st.trapmax+1)*sizeof(char*));
1391 shp->options = opt;
1394 shp->arglist = sh_argcreate(argv);
1395 if(shp->arglist)
1396 sh_argreset(shp,shp->arglist,NIL(struct dolnod*));
1397 shp->envlist=0;
1398 shp->curenv = 0;
1399 shp->shname = error_info.id = strdup(shp->st.dolv[0]);
1401 shp->fn_depth = shp->dot_depth = 0;
1410 shp->st.filename = strdup(shp->lastarg);
1456 Shell_t *shp = sp->sh;
1472 shp->last_table = SH_STATS;
1489 Shell_t *shp = sh_getinterp();
1490 sfprintf(shp->strbuf,".sh.stats.%s",np->nvname);
1491 return(sfstruse(shp->strbuf));
1505 static void stat_init(Shell_t *shp)
1512 shp->stats = (int*)calloc(sizeof(int*),nstat);
1513 sp->sh = shp;
1521 np->nvalue.ip = &shp->stats[i];
1536 static Init_t *nv_init(Shell_t *shp)
1544 shp->nvfun.last = (char*)shp;
1545 shp->nvfun.nofree = 1;
1546 ip->sh = shp;
1547 shp->var_base = shp->var_tree = inittree(shp,shtab_variables);
1612 d = (shp->pid&RANDMASK);
1627 (PPIDNOD)->nvalue.lp = (&shp->ppid);
1628 (TMOUTNOD)->nvalue.lp = (&shp->st.tmout);
1630 (OPTINDNOD)->nvalue.lp = (&shp->st.optindex);
1632 shp->alias_tree = inittree(shp,shtab_aliases);
1633 shp->track_tree = dtopen(&_Nvdisc,Dtset);
1634 shp->bltin_tree = inittree(shp,(const struct shtable2*)shtab_builtins);
1635 shp->fun_tree = dtopen(&_Nvdisc,Dtoset);
1636 dtview(shp->fun_tree,shp->bltin_tree);
1638 if(np = nv_mount(DOTSHNOD, "global", shp->var_tree))
1644 np = nv_mount(DOTSHNOD, "type", shp->typedict=dtopen(&_Nvdisc,Dtoset));
1646 SH_LINENO->nvalue.ip = &shp->st.lineno;
1652 stat_init(shp);
1660 static Dt_t *inittree(Shell_t *shp,const struct shtable2 *name_vals)
1670 if(!shp->bltin_nodes)
1672 shp->bltin_nodes = np;
1673 shp->bltin_nnodes = n;
1677 shp->bltin_cmds = np;
1681 treep->user = (void*)shp;
1719 static void env_init(Shell_t *shp)
1726 shp->env = env_open(environ,3);
1727 env_delete(shp->env,"_");
1735 else if(np=nv_open(cp,shp->var_tree,(NV_EXPORT|NV_IDENT|NV_ASSIGN|NV_NOFAIL)))
1743 ep[-1] = environ[shp->nenv];
1744 environ[shp->nenv++] = cp;
1751 np = nv_search(cp+2,shp->var_tree,NV_ADD);
1788 env_delete(shp->env,e_envmarker);