[comp.os.minix] sh bugs

ddl@husc6.UUCP (12/04/87)

	There appear to be a few bugs in the sh clone:

1) sh parses and executes a;b& as if it were (a;b)&  That is, the commands
a and b are run sequentially but in the background.  Fix: change c_list (sh2.c)
to something like this:

static struct op *
c_list()
{
	register struct op *t, *p;
	register int c;

	t = andor();
	if (t != NULL) {
		if((peeksym = yylex(0)) == '&')
			t = block(TASYNC, t, NOBLOCK, NOWORDS);
		while ((c = yylex(0)) == ';' || c == '&' || multiline && c == '\n') {
			if ((p = andor()) == NULL)
				return(t);
			if((peeksym = yylex(0)) == '&')
				p = block(TASYNC, p, NOBLOCK, NOWORDS);
			t = list(t, p);
		}
		peeksym = c;
	}
	return(t);
}

2) (cmd) executes cmd with signals ignored.  Fix: change forkexec (sh3.c) such
that signals are reset before the check for TPAREN:

	if (resetsig) {
		signal(SIGINT, SIG_DFL);
		signal(SIGQUIT, SIG_DFL);
	}
	if (t->type == TPAREN)
		exit(execute(t->left, NOPIPE, NOPIPE, FEXEC));

3) Many chances to exec rather than fork a command are missed.  Most
anoying is that a | b & results in three, rather than two, processes.
Fix:  It appears that each case of execute (sh3.c) should pass the act
flag to its last (or only) recursive invocation of execute.  Although
this seems to be the intention of the code, I can't be sure it doesn't
break anything (works fine for me...) and there may be a problem with
freeing memory.

					Dan Lanciani
					ddl@harvard.*