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