From owner-svn-src-head@FreeBSD.ORG Fri Oct 29 20:23:42 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3821910656A4; Fri, 29 Oct 2010 20:23:42 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 25E9D8FC1B; Fri, 29 Oct 2010 20:23:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o9TKNglF055302; Fri, 29 Oct 2010 20:23:42 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9TKNgL3055300; Fri, 29 Oct 2010 20:23:42 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201010292023.o9TKNgL3055300@svn.freebsd.org> From: Jilles Tjoelker Date: Fri, 29 Oct 2010 20:23:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214525 - head/bin/sh X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Oct 2010 20:23:42 -0000 Author: jilles Date: Fri Oct 29 20:23:41 2010 New Revision: 214525 URL: http://svn.freebsd.org/changeset/base/214525 Log: sh: Error out on various specials/keywords in the wrong place in backticks. Example: echo `date)` Exp-run done by: pav (with some other sh(1) changes) Obtained from: NetBSD (Christos Zoulas, NetBSD PR 11317) Modified: head/bin/sh/parser.c Modified: head/bin/sh/parser.c ============================================================================== --- head/bin/sh/parser.c Fri Oct 29 19:34:57 2010 (r214524) +++ head/bin/sh/parser.c Fri Oct 29 20:23:41 2010 (r214525) @@ -106,7 +106,7 @@ static struct parser_temp *parser_temp; static int noaliases = 0; -static union node *list(int); +static union node *list(int, int); static union node *andor(void); static union node *pipeline(void); static union node *command(void); @@ -220,12 +220,12 @@ parsecmd(int interact) if (t == TNL) return NULL; tokpushback++; - return list(1); + return list(1, 0); } static union node * -list(int nlflag) +list(int nlflag, int erflag) { union node *n1, *n2, *n3; int tok; @@ -287,7 +287,7 @@ list(int nlflag) pungetc(); /* push back EOF on input */ return n1; default: - if (nlflag) + if (nlflag || erflag) synexpect(-1); tokpushback++; return n1; @@ -398,24 +398,24 @@ command(void) case TIF: n1 = (union node *)stalloc(sizeof (struct nif)); n1->type = NIF; - if ((n1->nif.test = list(0)) == NULL) + if ((n1->nif.test = list(0, 0)) == NULL) synexpect(-1); if (readtoken() != TTHEN) synexpect(TTHEN); - n1->nif.ifpart = list(0); + n1->nif.ifpart = list(0, 0); n2 = n1; while (readtoken() == TELIF) { n2->nif.elsepart = (union node *)stalloc(sizeof (struct nif)); n2 = n2->nif.elsepart; n2->type = NIF; - if ((n2->nif.test = list(0)) == NULL) + if ((n2->nif.test = list(0, 0)) == NULL) synexpect(-1); if (readtoken() != TTHEN) synexpect(TTHEN); - n2->nif.ifpart = list(0); + n2->nif.ifpart = list(0, 0); } if (lasttoken == TELSE) - n2->nif.elsepart = list(0); + n2->nif.elsepart = list(0, 0); else { n2->nif.elsepart = NULL; tokpushback++; @@ -429,13 +429,13 @@ command(void) int got; n1 = (union node *)stalloc(sizeof (struct nbinary)); n1->type = (lasttoken == TWHILE)? NWHILE : NUNTIL; - if ((n1->nbinary.ch1 = list(0)) == NULL) + if ((n1->nbinary.ch1 = list(0, 0)) == NULL) synexpect(-1); if ((got=readtoken()) != TDO) { TRACE(("expecting DO got %s %s\n", tokname[got], got == TWORD ? wordtext : "")); synexpect(TDO); } - n1->nbinary.ch2 = list(0); + n1->nbinary.ch2 = list(0, 0); if (readtoken() != TDONE) synexpect(TDONE); checkkwd = 1; @@ -487,7 +487,7 @@ TRACE(("expecting DO got %s %s\n", tokna t = TEND; else synexpect(-1); - n1->nfor.body = list(0); + n1->nfor.body = list(0, 0); if (readtoken() != t) synexpect(t); checkkwd = 1; @@ -527,7 +527,7 @@ TRACE(("expecting DO got %s %s\n", tokna ap->narg.next = NULL; if (lasttoken != TRP) noaliases = 0, synexpect(TRP); - cp->nclist.body = list(0); + cp->nclist.body = list(0, 0); checkkwd = 2; if ((t = readtoken()) != TESAC) { @@ -545,14 +545,14 @@ TRACE(("expecting DO got %s %s\n", tokna case TLP: n1 = (union node *)stalloc(sizeof (struct nredir)); n1->type = NSUBSHELL; - n1->nredir.n = list(0); + n1->nredir.n = list(0, 0); n1->nredir.redirect = NULL; if (readtoken() != TRP) synexpect(TRP); checkkwd = 1; break; case TBEGIN: - n1 = list(0); + n1 = list(0, 0); if (readtoken() != TEND) synexpect(TEND); checkkwd = 1; @@ -1066,7 +1066,7 @@ done: doprompt = 0; } - n = list(0); + n = list(0, oldstyle); if (oldstyle) doprompt = saveprompt;