Subject: bin/12533: /bin/sh incorrectly parse eval with semi-colon
To: None <gnats-bugs@gnats.netbsd.org>
From: None <mori@tri.asanuma.co.jp>
List: netbsd-bugs
Date: 04/03/2001 14:04:25
>Number:         12533
>Category:       bin
>Synopsis:       /bin/sh incorrectly parse "eval" with semi-colon in line end.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Apr 02 22:05:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Koji Mori
>Release:        NetBSD-current, 1.5-release.
>Organization:
Techinical Reserach Institute, Asanuma Corp., Takatsuki, Japan
>Environment:
System: NetBSD yashoda 1.5 NetBSD 1.5 (GENERIC) #2: Tue Dec 19 22:37:13 JST 2000 mori@shiva.tri.asanuma.co.jp:/u2/netbsd-1-5-RELEASE/src/sys/arch/i386/compile/GENERIC i386

>Description:
	bin/sh evaluates a string with `eval' statement and the string
	has semicolon at the end, then /bin/sh doesn't process the `eval'
	statement.
	
	see also, http://www.freebsd.org/cgi/query-pr.cgi?pr=18447

>How-To-Repeat:
	Do follow commands, please.

	$ sh -c 'eval "echo 1"'
	1
	$ sh -c 'eval "echo 1";'
	$ sh -c 'eval "echo 1"; eval "echo 2"; eval "echo 3"'
	1
	2
	3
	$ sh -c 'eval "echo 1"; eval "echo 2"; eval "echo 3";'
	2
	3
	$

>Fix:

	patch for basesrc/bin/sh/parser.c

diff -u -r1.46 parser.c
--- parser.c	2001/02/04 19:52:06	1.46
+++ parser.c	2001/04/03 04:33:28
@@ -130,6 +130,7 @@
 {
 	int t;
 
+	tokpushback = 0;
 	doprompt = interact;
 	if (doprompt)
 		setprompt(1);
>Release-Note:
>Audit-Trail:
>Unformatted: