Lines Matching refs:shp

56 static void	chkmail(Shell_t *shp, char*);
94 int sh_source(Shell_t *shp, Sfio_t *iop, const char *file) in sh_source() argument
100 if (!file || !*file || (fd = path_open(shp,file, PATHCOMP)) < 0) in sh_source()
107 shp->st.filename = path_fullname(shp,stakptr(PATH_OFFSET)); in sh_source()
109 exfile(shp, iop, fd); in sh_source()
126 register Shell_t *shp; in sh_main() local
141 shp = sh_init(ac,av,userinit); in sh_main()
145 if(sigsetjmp(*((sigjmp_buf*)shp->jmpbuffer),0)) in sh_main()
149 shp->gd->pid = getpid(); in sh_main()
150 shp->gd->ppid = getppid(); in sh_main()
152 shp->fn_depth = shp->dot_depth = 0; in sh_main()
155 srand(shp->gd->pid&0x7fff); in sh_main()
158 path_pwd(shp,1); in sh_main()
166 ((Lex_t*)shp->lex_context)->nonstandard = 0; in sh_main()
167 if(shp->gd->ppid==1) in sh_main()
168 shp->login_sh++; in sh_main()
169 if(shp->login_sh >= 2) in sh_main()
186 for(i=0; i<elementsof(shp->offoptions.v); i++) in sh_main()
187 shp->options.v[i] &= ~shp->offoptions.v[i]; in sh_main()
198 job_init(shp,sh_isoption(SH_LOGIN_SHELL)); in sh_main()
202 sh_source(shp, iop, e_sysprofile); in sh_main()
205 char **files = shp->gd->login_files; in sh_main()
206 while ((name = *files++) && !sh_source(shp, iop, sh_mactry(shp,name))); in sh_main()
210 path_pwd(shp,1); in sh_main()
219 sh_source(shp, iop, e_bash_sysrc); in sh_main()
221 sh_source(shp, iop, shp->gd->rcfile ? shp->gd->rcfile : sh_mactry(shp,(char*)e_bash_rc)); in sh_main()
226 if(name = sh_mactry(shp,nv_getval(ENVNOD))) in sh_main()
230 sh_source(shp, iop, e_sysrc); in sh_main()
234 sh_source(shp, iop, name); in sh_main()
240 sh_source(shp, iop, e_suidprofile); in sh_main()
242 shp->st.cmdname = error_info.id = command; in sh_main()
247 if(shp->comdiv) in sh_main()
250 iop = sfnew(NIL(Sfio_t*),shp->comdiv,strlen(shp->comdiv),0,SF_STRING|SF_READ); in sh_main()
255 error_info.id = shp->shname; in sh_main()
282 shp->st.dolv[0] = av[0]; in sh_main()
283 fixargs(shp->st.dolv,1); in sh_main()
300 shp->st.filename = path_fullname(shp,name); in sh_main()
305 if(path_absolute(shp,name,NIL(Pathcomp_t*))) in sh_main()
308 sp = path_absolute(shp,name,NIL(char*)); in sh_main()
313 shp->st.filename = path_fullname(shp,sp); in sh_main()
325 shp->comdiv = (char*)malloc(strlen(name)+7); in sh_main()
326 name = strcopy(shp->comdiv,name); in sh_main()
327 if(shp->st.dolc) in sh_main()
334 shp->readscript = shp->shname; in sh_main()
337 shp->comdiv--; in sh_main()
347 fdin = shp->infd; in sh_main()
348 fixargs(shp->st.dolv,1); in sh_main()
353 exfile(shp,iop,fdin); in sh_main()
354 sh_done(shp,0); in sh_main()
364 static void exfile(register Shell_t *shp, register Sfio_t *iop,register int fno) in exfile() argument
371 sh_pushcontext(shp,&buff,SH_JMPERREXIT); in exfile()
373 nv_putval(SH_PATHNAMENOD, shp->st.filename ,NV_NOFREE); in exfile()
381 shp->fdstatus[r] = shp->fdstatus[fno]; in exfile()
386 shp->fdstatus[fno] |= IOCLEX; in exfile()
387 iop = sh_iostream((void*)shp,fno); in exfile()
394 shp->infd = fno; in exfile()
398 nv_putval(PS1NOD,(shp->gd->euserid?e_stdprompt:e_supprompt),NV_RDONLY); in exfile()
400 if(sh_histinit((void*)shp)) in exfile()
421 sh_iorestore((void*)shp,0,jmpval); in exfile()
422 hist_flush(shp->gd->hist_ptr); in exfile()
423 sfsync(shp->outpool); in exfile()
424 shp->st.execbrk = shp->st.breakcnt = 0; in exfile()
431 …soption(SH_INTERACTIVE) || sh_isstate(SH_FORKED) || (jmpval > SH_JMPERREXIT && job_close(shp) >=0)) in exfile()
448 tcsetpgrp(job.fd,shp->gd->pid); in exfile()
454 shp->st.optindex = 1; in exfile()
456 shp->st.loopcnt = 0; in exfile()
457 shp->trapnote = 0; in exfile()
458 shp->intrap = 0; in exfile()
460 shp->inlineno = 1; in exfile()
461 shp->binscript = 0; in exfile()
467 shp->nextprompt = 1; in exfile()
468 sh_freeup(shp); in exfile()
504 chkmail(shp,mail); in exfile()
508 if(shp->gd->hist_ptr) in exfile()
509 hist_eof(shp->gd->hist_ptr); in exfile()
511 shp->timeout = shp->st.tmout; in exfile()
513 if(shp->timeout <= 0 || shp->timeout > SHOPT_TIMEOUT) in exfile()
514 shp->timeout = SHOPT_TIMEOUT; in exfile()
516 shp->inlineno = 1; in exfile()
518 shp->trapnote = 0; in exfile()
534 !sferror(sfstderr) && (shp->fdstatus[fno]&IOTTY)) in exfile()
540 else if(job_close(shp)<0) in exfile()
551 shp->exitval = sh.savexit; in exfile()
553 if(sh_isstate(SH_INTERACTIVE) && shp->gd->hist_ptr) in exfile()
556 hist_eof(shp->gd->hist_ptr); in exfile()
563 t = (Shnode_t*)sh_parse(shp,iop,0); in exfile()
566 shp->readscript = 0; in exfile()
567 if(sh_isstate(SH_INTERACTIVE) && shp->gd->hist_ptr) in exfile()
568 hist_flush(shp->gd->hist_ptr); in exfile()
575 (fno<0 || !(shp->fdstatus[fno]&(IOTTY|IONOSEEK))) in exfile()
580 shp->st.execbrk = 0; in exfile()
582 if(shp->forked) in exfile()
593 sh_popcontext(shp,&buff); in exfile()
597 job_close(shp); in exfile()
600 siglongjmp(*shp->jmplist,jmpval); in exfile()
602 sh_done(shp,0); in exfile()
605 if(shp->st.filename) in exfile()
606 free((void*)shp->st.filename); in exfile()
607 shp->st.filename = 0; in exfile()
612 static void chkmail(Shell_t *shp, char *files) in chkmail() argument
646 path_complete(shp,cp,"/*",&arglist); in chkmail()
661 char *save = shp->lastarg; in chkmail()
662 shp->lastarg = cp; in chkmail()
663 errormsg(SH_DICT,0,sh_mactry(shp,qp?qp+1:(char*)e_mailmsg)); in chkmail()
664 shp->lastarg = save; in chkmail()