Lines Matching refs:shp

59 static void	chkmail(Shell_t *shp, char*);
91 Shell_t *shp = (Shell_t*)context;
94 if(shp->trapnote&SH_SIGSET)
114 int sh_source(Shell_t *shp, Sfio_t *iop, const char *file)
120 if (!file || !*file || (fd = path_open(shp,file, PATHCOMP)) < 0)
127 shp->st.filename = path_fullname(shp,stakptr(PATH_OFFSET));
129 exfile(shp, iop, fd);
146 register Shell_t *shp;
161 shp = sh_init(ac,av,userinit);
166 fts_notify(fts_sigcheck,(void*)shp);
168 if(sigsetjmp(*((sigjmp_buf*)shp->jmpbuffer),0))
172 shp->gd->pid = getpid();
173 shp->gd->ppid = getppid();
175 shp->fn_depth = shp->dot_depth = 0;
178 srand(shp->gd->pid&0x7fff);
181 path_pwd(shp,1);
189 ((Lex_t*)shp->lex_context)->nonstandard = 0;
190 if(shp->gd->ppid==1)
191 shp->login_sh++;
192 if(shp->login_sh >= 2)
209 for(i=0; i<elementsof(shp->offoptions.v); i++)
210 shp->options.v[i] &= ~shp->offoptions.v[i];
221 job_init(shp,sh_isoption(SH_LOGIN_SHELL));
225 sh_source(shp, iop, e_sysprofile);
228 char **files = shp->gd->login_files;
229 while ((name = *files++) && !sh_source(shp, iop, sh_mactry(shp,name)));
233 path_pwd(shp,1);
242 sh_source(shp, iop, e_bash_sysrc);
244 sh_source(shp, iop, shp->gd->rcfile ? shp->gd->rcfile : sh_mactry(shp,(char*)e_bash_rc));
249 if(name = sh_mactry(shp,nv_getval(ENVNOD)))
253 sh_source(shp, iop, e_sysrc);
257 sh_source(shp, iop, name);
263 sh_source(shp, iop, e_suidprofile);
265 shp->st.cmdname = error_info.id = command;
270 if(shp->comdiv)
273 iop = sfnew(NIL(Sfio_t*),shp->comdiv,strlen(shp->comdiv),0,SF_STRING|SF_READ);
278 error_info.id = shp->shname;
299 if (shp->st.repl_index > 0)
300 av[shp->st.repl_index] = shp->st.repl_arg;
307 shp->st.dolv[0] = av[0];
308 fixargs(shp->st.dolv,1);
325 shp->st.filename = path_fullname(shp,name);
330 if(path_absolute(shp,name,NIL(Pathcomp_t*)))
333 sp = path_absolute(shp,name,NIL(char*));
338 shp->st.filename = path_fullname(shp,sp);
350 shp->comdiv = (char*)malloc(strlen(name)+7);
351 name = strcopy(shp->comdiv,name);
352 if(shp->st.dolc)
359 shp->readscript = shp->shname;
362 shp->comdiv--;
372 fdin = shp->infd;
373 fixargs(shp->st.dolv,1);
378 exfile(shp,iop,fdin);
379 sh_done(shp,0);
389 static void exfile(register Shell_t *shp, register Sfio_t *iop,register int fno)
396 sh_pushcontext(shp,&buff,SH_JMPERREXIT);
398 nv_putval(SH_PATHNAMENOD, shp->st.filename ,NV_NOFREE);
404 VALIDATE_FD(shp, fno);
407 VALIDATE_FD(shp, r);
408 shp->fdstatus[r] = shp->fdstatus[fno];
413 shp->fdstatus[fno] |= IOCLEX;
414 iop = sh_iostream((void*)shp,fno);
421 shp->infd = fno;
425 nv_putval(PS1NOD,(shp->gd->euserid?e_stdprompt:e_supprompt),NV_RDONLY);
427 if(sh_histinit((void*)shp))
448 sh_iorestore((void*)shp,0,jmpval);
449 hist_flush(shp->gd->hist_ptr);
450 sfsync(shp->outpool);
451 shp->st.execbrk = shp->st.breakcnt = 0;
458 if(!sh_isoption(SH_INTERACTIVE) || sh_isstate(SH_FORKED) || (jmpval > SH_JMPERREXIT && job_close(shp) >=0))
474 tcsetpgrp(job.fd,shp->gd->pid);
480 shp->st.optindex = 1;
482 shp->st.loopcnt = 0;
483 shp->trapnote = 0;
484 shp->intrap = 0;
486 shp->inlineno = 1;
487 shp->binscript = 0;
493 shp->nextprompt = 1;
494 sh_freeup(shp);
531 chkmail(shp,mail);
535 if(shp->gd->hist_ptr)
536 hist_eof(shp->gd->hist_ptr);
538 shp->timeout = shp->st.tmout;
540 if(shp->timeout <= 0 || shp->timeout > SHOPT_TIMEOUT)
541 shp->timeout = SHOPT_TIMEOUT;
543 shp->inlineno = 1;
545 shp->exitval = 0;
546 shp->trapnote = 0;
562 !sferror(sfstderr) && (shp->fdstatus[fno]&IOTTY))
568 else if(job_close(shp)<0)
580 if(sh_isstate(SH_INTERACTIVE) && shp->gd->hist_ptr)
583 hist_eof(shp->gd->hist_ptr);
590 t = (Shnode_t*)sh_parse(shp,iop,0);
593 shp->readscript = 0;
594 if(sh_isstate(SH_INTERACTIVE) && shp->gd->hist_ptr)
595 hist_flush(shp->gd->hist_ptr);
602 (fno<0 || !(shp->fdstatus[fno]&(IOTTY|IONOSEEK)))
607 shp->st.execbrk = 0;
609 if(shp->forked)
620 sh_popcontext(shp,&buff);
624 job_close(shp);
627 siglongjmp(*shp->jmplist,jmpval);
629 sh_done(shp,0);
632 if(shp->st.filename)
633 free((void*)shp->st.filename);
634 shp->st.filename = 0;
639 static void chkmail(Shell_t *shp, char *files)
673 path_complete(shp,cp,"/*",&arglist);
688 char *save = shp->lastarg;
689 shp->lastarg = cp;
690 errormsg(SH_DICT,0,sh_mactry(shp,qp?qp+1:(char*)e_mailmsg));
691 shp->lastarg = save;