source = old_source;
shell(s, toplevel)	Source *volatile s;		/* input source */	int volatile toplevel;{	struct op *t;	volatile int wastty = s->flags & SF_TTY;	volatile int attempts = 13;	volatile int interactive = Flag(FTALKING) && toplevel;	int i;	newenv(E_PARSE);	if (interactive)		really_exit = 0;	i = ksh_sigsetjmp(e->jbuf, 0);	if (i) {		s->start = s->str = null;		switch (i) {		  case LINTR: /* we get here if SIGINT not caught or ignored */		  case LERROR:		  case LSHELL:			if (interactive) {				if (i == LINTR)					shellf(newline);				/* Reset any eof that was read as part of a				 * multiline command.				 */				if (Flag(FIGNOREEOF) && s->type == SEOF				    && wastty)					s->type = SSTDIN;				/* Used by exit command to get back to				 * top level shell.  Kind of strange since				 * interactive is set if we are reading from				 * a tty, but to have stopped jobs, one only				 * needs FMONITOR set (not FTALKING/SF_TTY)...				 */				break;			}			/* fall through... */		  case LEXIT:		  case LLEAVE:		  case LRETURN:			quitenv();			unwind(i);	/* keep on going */			/*NOREACHED*/		  default:			quitenv();			internal_errorf(1, "shell: %d", i);			/*NOREACHED*/		}	}	while (1) {		if (trap)			runtraps(0);		if (s->next == NULL) {			if (Flag(FVERBOSE))				s->flags |= SF_ECHO;			else				s->flags &= ~SF_ECHO;		}		if (interactive) {			j_notify();#ifdef KSH			mcheck();#endif /* KSH */			set_prompt(PS1, s);		}		t = compile(s);		if (t != NULL && t->type == TEOF) {			if (wastty && Flag(FIGNOREEOF) && --attempts > 0) {				shellf("Use `exit' to leave ksh\n");				s->type = SSTDIN;			} else if (wastty && !really_exit				   && j_stopped_running())			{				really_exit = 1;				s->type = SSTDIN;			} else {				/* this for POSIX, which says EXIT traps				 * shall be taken in the environment				 * immediately after the last command				 * executed.				 */				if (toplevel)					unwind(LEXIT);				break;			}		}		if (t && (!Flag(FNOEXEC) || (s->flags & SF_TTY)))			exstat = execute(t, 0);		if (t != NULL && t->type != TEOF && interactive && really_exit)			really_exit = 0;		reclaim();	}	quitenv();	return exstat;}