The shell incorrectly gave & precedence over ;. This breaks the

traditional behaviour, and it violates Posix.2.

Fixes PR # bin/880: /bin/sh incorrectly parse...

Fixes also an earlier problem report about the shell not evaluating
loops correctly.  (Not files via GNATS.)

Submitted by:	nnd@itfs.nsk.su (Nickolay N. Dudorov)
This commit is contained in:
Joerg Wunsch 1995-12-10 17:59:23 +00:00
parent baadb8c9e4
commit 454bd7b924
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=12733

View File

@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: parser.c,v 1.8 1995/08/27 20:26:42 joerg Exp $
* $Id: parser.c,v 1.9 1995/08/28 19:24:35 joerg Exp $
*/
#ifndef lint
@ -149,30 +149,13 @@ list(nlflag) {
n1 = andor();
for (;;) {
switch (readtoken()) {
case TBACKGND:
if (n1->type == NCMD || n1->type == NPIPE) {
n1->ncmd.backgnd = 1;
} else if (n1->type == NREDIR) {
n1->type = NBACKGND;
} else {
n3 = (union node *)stalloc(sizeof (struct nredir));
n3->type = NBACKGND;
n3->nredir.n = n1;
n3->nredir.redirect = NULL;
n1 = n3;
}
goto tsemi;
case TNL:
tokpushback++;
parseheredoc();
if (nlflag)
return n1;
/* fall through */
tsemi: case TSEMI:
if (readtoken() == TNL) {
parseheredoc();
if (nlflag)
return n1;
} else {
tokpushback++;
}
case TBACKGND:
case TSEMI:
checkkwd = 2;
if (tokendlist[peektoken()])
return n1;
@ -212,6 +195,19 @@ andor() {
} else if (t == TOR) {
t = NOR;
} else {
if (t == TBACKGND) {
if (n1->type == NCMD || n1->type == NPIPE) {
n1->ncmd.backgnd = 1;
} else if (n1->type == NREDIR) {
n1->type = NBACKGND;
} else {
n3 = (union node *)stalloc(sizeof (struct nredir));
n3->type = NBACKGND;
n3->nredir.n = n1;
n3->nredir.redirect = NULL;
n1 = n3;
}
}
tokpushback++;
return n1;
}