Date: Mon, 8 May 2000 17:26:45 +0900 (JST) From: mori@tri.asanuma.co.jp To: FreeBSD-gnats-submit@freebsd.org Subject: bin/18447: /bin/sh: wrong parse eval Message-ID: <200005080826.RAA68289@kurishna.tri.asanuma.co.jp>
next in thread | raw e-mail | index | archive | help
>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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200005080826.RAA68289>