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:
parent
baadb8c9e4
commit
454bd7b924
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user