Lines Matching refs:shp

259 	Shell_t *shp = nv_shell(np);
260 if(*name=='E' && nv_getval(sh_scoped(shp,VISINOD)))
262 if(!(cp=val) && (*name=='E' || !(cp=nv_getval(sh_scoped(shp,EDITNOD)))))
286 Shell_t *shp = nv_shell(np);
287 void *histopen = shp->gd->hist_ptr;
293 if(np==HISTSIZE && sh_arith(shp,val)==nv_getnum(HISTSIZE))
295 hist_close(shp->gd->hist_ptr);
301 sh_histinit(shp);
310 Shell_t *shp = nv_shell(np);
311 shp->st.opterror = shp->st.optchar = 0;
335 Shell_t *shp = nv_shell(np);
343 nv_scan(shp->track_tree,rehash,(void*)0,NV_TAGGED,NV_TAGGED);
350 shp->pathlist = (void*)path_unsetfpath(shp);
352 shp->universe = 0;
353 if(shp->pathlist)
357 pp = (void*)path_addpath(shp,(Pathcomp_t*)shp->pathlist,val,PATH_PATH);
359 pp = (void*)path_addpath(shp,(Pathcomp_t*)shp->pathlist,val,PATH_FPATH);
362 if(shp->pathlist = (void*)pp)
363 pp->shp = shp;
366 Namval_t *mp = dtsearch(shp->var_tree,np);
372 path_dump((Pathcomp_t*)shp->pathlist);
380 Shell_t *shp = nv_shell(np);
382 if(!shp->cdpathlist)
385 pp = (void*)path_addpath(shp,(Pathcomp_t*)shp->cdpathlist,val,PATH_CDPATH);
386 if(shp->cdpathlist = (void*)pp)
387 pp->shp = shp;
412 Shell_t *shp = nv_shell(np);
447 if(!sh_isstate(SH_INIT) || shp->login_sh==0)
541 register Shell_t *shp = nv_shell(np);
546 memset(shp->ifstable,0,(1<<CHAR_BIT));
560 shp->ifstable[c] = S_MBYTE;
571 shp->ifstable[c] = n;
576 shp->ifstable[' '] = shp->ifstable['\t'] = S_SPACE;
577 shp->ifstable['\n'] = S_NL;
620 Shell_t *shp = nv_shell(np);
627 sfprintf(shp->strbuf,"%.*f",places,d);
628 return(sfstruse(shp->strbuf));
704 Shell_t *shp = nv_shell(np);
716 n = sh_arith(shp,val);
717 shp->st.firstline += nget_lineno(np,fp)+1-n;
728 Shell_t *shp = nv_shell(np);
731 if(sh_isstate(SH_INIT) && (cp=shp->lastarg) && *cp=='*' && (pid=strtol(cp+1,&cp,10)) && *cp=='*')
732 nv_putval(np,(pid==shp->gd->ppid?cp+1:0),0);
733 return(shp->lastarg);
738 Shell_t *shp = nv_shell(np);
741 sfprintf(shp->strbuf,"%.*g",12,*((double*)val));
742 val = sfstruse(shp->strbuf);
746 if(shp->lastarg && !nv_isattr(np,NV_NOFREE))
747 free((void*)shp->lastarg);
750 shp->lastarg = (char*)val;
766 void sh_setmatch(Shell_t *shp,const char *v, int vsize, int nmatch, regoff_t match[],int index)
770 register int i,n,x, savesub=shp->subshell;
772 shp->subshell = 0;
827 shp->subshell = savesub;
978 Shell_t *shp = sh_getinterp();
979 sfprintf(shp->strbuf,".sh.math.%s",np->nvname);
980 return(sfstruse(shp->strbuf));
994 static void math_init(Shell_t *shp)
999 shp->mathnodes = (char*)calloc(1,MAX_MATH_ARGS*(NV_MINSZ+5));
1000 name = shp->mathnodes+MAX_MATH_ARGS*NV_MINSZ;
1003 np = nv_namptr(shp->mathnodes,i);
1015 Shell_t *shp = nv_shell(np);
1021 return(nv_namptr(shp->mathnodes,name[3]-'1'));
1026 Shell_t *shp = nv_shell(np);
1031 mp = (Namval_t*)dtprev(shp->fun_tree,&fake);
1032 while(mp=(Namval_t*)dtnext(shp->fun_tree,mp))
1037 sfputc(shp->strbuf,' ');
1038 sfputr(shp->strbuf,mp->nvname+9,-1);
1040 val = sfstruse(shp->strbuf);
1047 Shell_t *shp=nv_shell(np);
1056 mp = (Namval_t*)dtprev(shp->fun_tree,&fake);
1057 return((char*)dtnext(shp->fun_tree,mp));
1066 mp = nv_search(name, shp->fun_tree, action?NV_ADD:0);
1069 return(mp?(char*)dtnext(shp->fun_tree,mp):0);
1101 Shell_t *shp = sh_getinterp();
1107 shp->universe = 0;
1109 if(*(arg = path_pwd(shp,0))=='/')
1263 Shell_t *shp;
1279 shp = &sh;
1303 shgd->ed_context = (void*)ed_open(shp);
1308 shp = newof(0,Shell_t,1,0);
1309 umask(shp->mask=umask(0));
1310 shp->gd = shgd;
1311 shp->mac_context = sh_macopen(shp);
1312 shp->arg_context = sh_argopen(shp);
1313 shp->lex_context = (void*)sh_lexopen(0,shp,1);
1314 shp->strbuf = sfstropen();
1315 shp->stk = stkstd;
1316 sfsetbuf(shp->strbuf,(char*)0,64);
1329 sh_regress_init(shp);
1332 /* NOTE: only shp is used by __regress__ at this point */
1333 shp->bltindata.shp = shp;
1351 b___regress__(2, regress, &shp->bltindata);
1356 shp->cpipe[0] = -1;
1357 shp->coutpipe = -1;
1367 sh_ioinit(shp);
1369 sh_siginit(shp);
1372 shp->init_context = nv_init(shp);
1378 shp->login_sh = 2;
1380 env_init(shp);
1383 sfprintf(shp->strbuf,"%s/.kshrc",nv_getval(HOME));
1384 nv_putval(ENVNOD,sfstruse(shp->strbuf),NV_RDONLY);
1396 shp->gd->shpath = 0;
1399 shp->gd->shpath = strdup(buff);
1401 sfprintf(shp->strbuf,"/proc/%d/exe",getpid());
1402 if((n=readlink(sfstruse(shp->strbuf),buff,sizeof(buff)-1))>0)
1405 shp->gd->shpath = strdup(buff);
1411 shp->gd->shpath = strdup(cp);
1419 shp->gd->shpath = strdup(stakptr(offset));
1431 shp->st.tmout = SHOPT_TIMEOUT;
1450 shp>userinit = userinit = bash_init;
1453 (*userinit)(shp, 0);
1458 /* shp->st.dolc is $# */
1459 if((shp->st.dolc = sh_argopts(-argc,argv,shp)) < 0)
1461 shp->exitval = 2;
1462 sh_done(shp,0);
1465 shp->st.dolv=argv+(argc-1)-shp->st.dolc;
1466 shp->st.dolv[0] = argv[0];
1467 if(shp->st.dolc < 1)
1471 shp->st.dolc--;
1472 shp->st.dolv++;
1476 name = shp->st.dolv[0];
1500 shp->decomma = (lc=localeconv()) && lc->decimal_point && *lc->decimal_point==',';
1507 struct passwd *pw = getpwuid(shp->gd->userid);
1509 shp->gd->user = strdup(pw->pw_name);
1514 if(shp->gd->userid!=shp->gd->euserid || shp->gd->groupid!=shp->gd->egroupid)
1518 if(!sh_isoption(SH_PRIVILEGED) && shp->gd->userid >= SHOPT_P_SUID)
1520 setuid(shp->gd->euserid=shp->gd->userid);
1521 setgid(shp->gd->egroupid=shp->gd->groupid);
1528 if(shp->login_sh && argv[1] && strcmp(argv[0],argv[1])==0)
1536 shp->shname = strdup(argv[0]);
1538 shp->shname = strdup(shp->st.dolv[0]);
1543 error_info.id = strdup(shp->st.dolv[0]); /* error_info.id is $0 */
1544 shp->jmpbuffer = (void*)&shp->checkbase;
1545 sh_pushcontext(shp,&shp->checkbase,SH_JMPSCRIPT);
1546 shp->st.self = &shp->global;
1547 shp->topscope = (Shscope_t*)shp->st.self;
1551 shp->gd->login_files = login_files;
1552 shp->bltindata.version = SH_VERSION;
1553 shp->bltindata.shp = shp;
1554 shp->bltindata.shrun = sh_run;
1555 shp->bltindata.shtrap = sh_trap;
1556 shp->bltindata.shexit = sh_exit;
1557 shp->bltindata.shbltin = sh_addbuiltin;
1559 shp->bltindata.shgetenv = sh_getenv;
1560 shp->bltindata.shsetenv = sh_setenviron;
1561 astintercept(&shp->bltindata,1);
1579 if(shp->userinit=userinit)
1580 (*userinit)(shp, 0);
1581 return(shp);
1594 Shell_t *shp = sh_getinterp();
1603 for(np=dtfirst(shp->fun_tree);np;np=npnext)
1605 if((dp=shp->fun_tree)->walk)
1607 npnext = (Namval_t*)dtnext(shp->fun_tree,np);
1616 dtclose(shp->alias_tree);
1617 shp->alias_tree = inittree(shp,shtab_aliases);
1618 shp->last_root = shp->var_tree;
1619 shp->inuse_bits = 0;
1620 if(shp->userinit)
1621 (*shp->userinit)(shp, 1);
1622 if(shp->heredocs)
1624 sfclose(shp->heredocs);
1625 shp->heredocs = 0;
1630 data.sh = shp;
1631 nv_scan(shp->var_tree,sh_envnolocal,(void*)&data,NV_EXPORT,0);
1632 nv_scan(shp->var_tree,sh_envnolocal,(void*)&data,NV_ARRAY,NV_ARRAY);
1634 memset(shp->st.trapcom,0,(shp->st.trapmax+1)*sizeof(char*));
1637 if(shp->namespace)
1639 dp=nv_dict(shp->namespace);
1640 if(dp==shp->var_tree)
1641 shp->var_tree = dtview(dp,0);
1642 _nv_unset(shp->namespace,NV_RDONLY);
1643 shp->namespace = 0;
1656 shp->options = opt;
1659 shp->arglist = sh_argcreate(argv);
1660 if(shp->arglist)
1661 sh_argreset(shp,shp->arglist,NIL(struct dolnod*));
1662 shp->envlist=0;
1663 shp->curenv = 0;
1664 shp->shname = error_info.id = strdup(shp->st.dolv[0]);
1666 shp->fn_depth = shp->dot_depth = 0;
1676 shp->st.filename = strdup(shp->lastarg);
1679 shp->inpipe = shp->outpipe = 0;
1727 Shell_t *shp = sp->sh;
1743 shp->last_table = SH_STATS;
1760 Shell_t *shp = sh_getinterp();
1761 sfprintf(shp->strbuf,".sh.stats.%s",np->nvname);
1762 return(sfstruse(shp->strbuf));
1776 static void stat_init(Shell_t *shp)
1784 sp->sh = shp;
1807 static Init_t *nv_init(Shell_t *shp)
1813 shp->nvfun.last = (char*)shp;
1814 shp->nvfun.nofree = 1;
1815 ip->sh = shp;
1816 shp->var_base = shp->var_tree = inittree(shp,shtab_variables);
1843 ip->RAND_init.sh = shp;
1889 d = (shp->gd->pid&RANDMASK);
1904 (PPIDNOD)->nvalue.lp = (&shp->gd->ppid);
1905 (TMOUTNOD)->nvalue.lp = (&shp->st.tmout);
1907 (OPTINDNOD)->nvalue.lp = (&shp->st.optindex);
1909 shp->alias_tree = inittree(shp,shtab_aliases);
1910 shp->track_tree = dtopen(&_Nvdisc,Dtset);
1911 shp->bltin_tree = inittree(shp,(const struct shtable2*)shtab_builtins);
1912 shp->fun_tree = dtopen(&_Nvdisc,Dtoset);
1913 dtview(shp->fun_tree,shp->bltin_tree);
1914 nv_mount(DOTSHNOD, "type", shp->typedict=dtopen(&_Nvdisc,Dtoset));
1918 SH_LINENO->nvalue.ip = &shp->st.lineno;
1924 math_init(shp);
1926 stat_init(shp);
1934 static Dt_t *inittree(Shell_t *shp,const struct shtable2 *name_vals)
1955 treep->user = (void*)shp;
1971 np->nvfun = &shp->nvfun;
1993 static void env_init(Shell_t *shp)
2002 shp->env = env_open(environ,3);
2003 env_delete(shp->env,"_");
2016 if(mp = dtmatch(shp->var_base,cp))
2054 dtinsert(shp->var_base,np++);
2060 np = nv_search(cp+2,shp->var_tree,NV_ADD);
2099 env_delete(shp->env,e_envmarker);
2104 path_pwd(shp,0);
2141 void sh_sigcheck DISABLE (Shell_t *shp)
2143 if(!shp)
2144 shp = sh_getinterp();
2145 sh_sigcheck(shp);