Example #1
0
File: eval.c Project: dpl0/soc2013
void
evalstring(char *s, int flags)
{
	union node *n;
	struct stackmark smark;
	int flags_exit;
	int any;

	flags_exit = flags & EV_EXIT;
	flags &= ~EV_EXIT;
	any = 0;
	setstackmark(&smark);
	setinputstring(s, 1);
	while ((n = parsecmd(0)) != NEOF) {
		if (n != NULL && !nflag) {
			if (flags_exit && preadateof())
				evaltree(n, flags | EV_EXIT);
			else
				evaltree(n, flags);
			any = 1;
		}
		popstackmark(&smark);
		setstackmark(&smark);
	}
	popfile();
	popstackmark(&smark);
	if (!any)
		exitstatus = 0;
	if (flags_exit)
		exraise(EXEXIT);
}
Example #2
0
void
evalstring(char *s, int flags)
{
	union node *n;
	struct stackmark smark;
	int flags_exit;

	flags_exit = flags & EV_EXIT;
	flags &= ~EV_EXIT;
	setstackmark(&smark);
	setinputstring(s, 1);
	while ((n = parsecmd(0)) != NEOF) {
		if (n != NULL) {
			if (flags_exit && preadateof())
				evaltree(n, flags | EV_EXIT);
			else
				evaltree(n, flags);
		}
		popstackmark(&smark);
	}
	popfile();
	popstackmark(&smark);
	if (flags_exit)
		exitshell(exitstatus);
}