From owner-freebsd-bugs Mon May 8 4:40:19 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id E313037C06B for ; Mon, 8 May 2000 04:40:02 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id EAA12984; Mon, 8 May 2000 04:40:02 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from vinita.tri.asanuma.co.jp (vinita.tri.asanuma.co.jp [210.160.188.5]) by hub.freebsd.org (Postfix) with ESMTP id D8AD237B8D6 for ; Mon, 8 May 2000 04:38:34 -0700 (PDT) (envelope-from mori@tri.asanuma.co.jp) Received: from parvati.tri.asanuma.co.jp by vinita.tri.asanuma.co.jp (8.9.3/3.7W) with ESMTP id RAA39434 for ; Mon, 8 May 2000 17:26:45 +0900 (JST) Received: from kurishna.tri.asanuma.co.jp by parvati.tri.asanuma.co.jp (8.8.8/3.7W) with ESMTP id RAA28344 for ; Mon, 8 May 2000 17:27:16 +0900 (JST) Received: by kurishna.tri.asanuma.co.jp (8.9.3/3.7W) id RAA68289; Mon, 8 May 2000 17:26:45 +0900 (JST) Message-Id: <200005080826.RAA68289@kurishna.tri.asanuma.co.jp> Date: Mon, 8 May 2000 17:26:45 +0900 (JST) From: mori@tri.asanuma.co.jp Reply-To: mori@tri.asanuma.co.jp To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: bin/18447: /bin/sh: wrong parse eval Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 18447 >Category: bin >Synopsis: /bin/sh: wrong parse eval >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon May 08 04:40:02 PDT 2000 >Closed-Date: >Last-Modified: >Originator: Koji Mori >Release: FreeBSD 3.4-STABLE i386 >Organization: >Environment: FreeBSD kurishna.tri.asanuma.co.jp 3.4-STABLE FreeBSD 3.4-STABLE #26: Thu Apr 6 15:48:03 JST 2000 mori@kurishna.tri.asanuma.co.jp:/usr/src/sys/compile/KOTONE i386 >Description: This problem is on /bin/sh. If /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. for example: $ /bin/sh -c 'eval echo t' t $ /bin/sh -c 'eval echo t;' $ or $ cat test.sh #! /bin/sh cmd1='eval echo 1;' cmd2='eval echo 2' eval $cmd1 eval $cmd2 $ /bin/sh test.sh 2 $ And if the string has multiplue eval statement, then /bin/sh doesn't process first eval statements, but processes others. for example: $ /bin/sh -c 'eval echo 1; eval echo 2; eval echo 3;' 2 3 $ I think its behavior is /bin/sh's bug. Other shells reading Bourne shell script, such as bash or SunOS's /bin/sh, process all eval statement for above cases. But NetBSD's /bin/sh is same as FreeBSD. >How-To-Repeat: Simple example is $ /bin/sh -c 'eval echo 1; eval echo 2;' The result is 2 but we expected 1 2 >Fix: To fix, apply this patch to src/bin/sh/parser.c diff -u -r1.30 parser.c --- parser.c 2000/04/20 09:49:16 1.30 +++ parser.c 2000/04/29 01:22:14 @@ -137,6 +137,7 @@ { int t; + tokpushback = 0; doprompt = interact; if (doprompt) setprompt(1); >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message