From archie@whistle.com Sun Oct 24 20:44:58 1999
Return-Path: <archie@whistle.com>
Received: from bubba.whistle.com (bubba.whistle.com [207.76.205.7])
	by hub.freebsd.org (Postfix) with ESMTP id 3DDA81518D
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 24 Oct 1999 20:44:44 -0700 (PDT)
	(envelope-from archie@whistle.com)
Received: (from archie@localhost)
	by bubba.whistle.com (8.9.2/8.9.2) id UAA32837;
	Sun, 24 Oct 1999 20:44:41 -0700 (PDT)
Message-Id: <199910250344.UAA32837@bubba.whistle.com>
Date: Sun, 24 Oct 1999 20:44:41 -0700 (PDT)
From: Archie Cobbs <archie@whistle.com>
Reply-To: archie@whistle.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: bug in make(1)
X-Send-Pr-Version: 3.2

>Number:         14509
>Category:       bin
>Synopsis:       bug in make(1)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    cracauer
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Oct 24 20:50:01 PDT 1999
>Closed-Date:    Tue Oct 26 16:20:02 MEST 1999
>Last-Modified:  Tue Oct 26 16:21:00 MEST 1999
>Originator:     Archie Cobbs
>Release:        FreeBSD 3.1-STABLE i386
>Organization:
Whistle Communications, Inc.
>Environment:

	Happens in 3.x-stable and 4.x-current.

>Description:

	Make is incorrectly executing a shell command. Consider this
	makefile:

	foo1:
		var1=yes; test "$$var1" = "no" && var2=". $$var2"; echo OK

	The makefile should exit successfully, yet instead it bombs out.
	Removing the "var1=yes" should have no effect, but that seems
	to fix it (see foo2 below).

>How-To-Repeat:

	$ cat makefile
	foo1:
		var1=yes; test "$$var1" = "no" && var2=". $$var2"; echo OK
	foo2:
		test "$$var1" = "no" && var2=". $$var2"; echo OK
	$ make foo1
	var1=yes; test "$var1" = "no" && var2=". $var2"; echo OK
	*** Error code 1

	Stop.
	$ make foo2
	test "$var1" = "no" && var2=". $var2"; echo OK
	OK

>Fix:

	Uknown.



>Release-Note:
>Audit-Trail:

From: Ruslan Ermilov <ru@ucb.crimea.ua>
To: Archie Cobbs <archie@whistle.com>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/14509: bug in make(1)
Date: Mon, 25 Oct 1999 10:08:43 +0300

 On Sun, Oct 24, 1999 at 08:44:41PM -0700, Archie Cobbs wrote:
 > 
 > >How-To-Repeat:
 > 
 > 	$ cat makefile
 > 	foo1:
 > 		var1=yes; test "$$var1" = "no" && var2=". $$var2"; echo OK
 > 	foo2:
 > 		test "$$var1" = "no" && var2=". $$var2"; echo OK
 > 	$ make foo1
 > 	var1=yes; test "$var1" = "no" && var2=". $var2"; echo OK
 > 	*** Error code 1
 > 
 > 	Stop.
 > 	$ make foo2
 > 	test "$var1" = "no" && var2=". $var2"; echo OK
 > 	OK
 > 
 Certainly, there is a problem somewhere above, but the following makefiles
 work as expected:
 
 # cat ~/Makefile.1
 foo1:
 	var1=yes; test "$$var1" = "no" && var2=". $$var2" || :; echo OK
 
 foo2:
 	test "$$var1" = "no" && var2=". $$var2" || :; echo OK
 
 # cat ~/Makefile.2
 foo1:
 	var1=yes; if test "$$var1" = "no"; then var2=". $$var2"; fi; echo OK
 
 foo2:
 	if test "$$var1" = "no"; then var2=". $$var2"; fi; echo OK
 
 
 Cheers,
 -- 
 Ruslan Ermilov		Sysadmin and DBA of the
 ru@ucb.crimea.ua	United Commercial Bank,
 ru@FreeBSD.org		FreeBSD committer,
 +380.652.247.647	Simferopol, Ukraine
 
 http://www.FreeBSD.org	The Power To Serve
 http://www.oracle.com	Enabling The Information Age
 

From: Ruslan Ermilov <ru@ucb.crimea.ua>
To: Archie Cobbs <archie@whistle.com>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/14509: bug in make(1)
Date: Mon, 25 Oct 1999 11:15:31 +0300

 Hi!
 
 It turns out to be a sh(1) bug:
 
 $ sh -e -c 'test "yes" = "no" && :; echo OK'; echo $?
 OK
 0
 $ sh -e -c ':; test "yes" = "no" && :; echo OK'; echo $?
 1
 
 Here is what sh(1) manpage says about `-e' option:
 :
 :-e errexit
 :        If not interactive, exit immediately if any untested command
 :        fails.  The exit status of a command is considered to be explicitly
 :        tested if the command is used to control an if, elif, while,
 :        or until; or if the command is the left hand operand of an ``&&''
 :        or ``||'' operator.
 
 
 On Mon, Oct 25, 1999 at 10:08:43AM +0300, Ruslan Ermilov wrote:
 > On Sun, Oct 24, 1999 at 08:44:41PM -0700, Archie Cobbs wrote:
 > > 
 > > >How-To-Repeat:
 > > 
 > > 	$ cat makefile
 > > 	foo1:
 > > 		var1=yes; test "$$var1" = "no" && var2=". $$var2"; echo OK
 > > 	foo2:
 > > 		test "$$var1" = "no" && var2=". $$var2"; echo OK
 > > 	$ make foo1
 > > 	var1=yes; test "$var1" = "no" && var2=". $var2"; echo OK
 > > 	*** Error code 1
 > > 
 > > 	Stop.
 > > 	$ make foo2
 > > 	test "$var1" = "no" && var2=". $var2"; echo OK
 > > 	OK
 > > 
 > Certainly, there is a problem somewhere above, but the following makefiles
 > work as expected:
 > 
 > # cat ~/Makefile.1
 > foo1:
 > 	var1=yes; test "$$var1" = "no" && var2=". $$var2" || :; echo OK
 > 
 > foo2:
 > 	test "$$var1" = "no" && var2=". $$var2" || :; echo OK
 > 
 > # cat ~/Makefile.2
 > foo1:
 > 	var1=yes; if test "$$var1" = "no"; then var2=". $$var2"; fi; echo OK
 > 
 > foo2:
 > 	if test "$$var1" = "no"; then var2=". $$var2"; fi; echo OK
 > 
 
 -- 
 Ruslan Ermilov		Sysadmin and DBA of the
 ru@ucb.crimea.ua	United Commercial Bank,
 ru@FreeBSD.org		FreeBSD committer,
 +380.652.247.647	Simferopol, Ukraine
 
 http://www.FreeBSD.org	The Power To Serve
 http://www.oracle.com	Enabling The Information Age
 
Responsible-Changed-From-To: freebsd-bugs->cracauer 
Responsible-Changed-By: sheldonh 
Responsible-Changed-When: Mon Oct 25 02:54:07 PDT 1999 
Responsible-Changed-Why:  
I thought I'd seen this problem with sh(1) fixed. I'm sure 
Martin will be interested. 

From: Martin Cracauer <cracauer@cons.org>
To: sheldonh@FreeBSD.ORG
Cc: freebsd-gnats-submit@FreeBSD.ORG, cracauer@FreeBSD.ORG,
	archie@whistle.com, ru@ucb.crimea.ua
Subject: Re: bin/14509: bug in make(1)
Date: Mon, 25 Oct 1999 12:55:45 +0200

 --2fHTh5uZTiUOsy+g
 Content-Type: text/plain; charset=us-ascii
 
 Could you please test the appended diff?
 
 There are possibly other types of nodes that must be excluded from
 exiting, but this seems to be the most urgent.
 
 Martin
 -- 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 Martin Cracauer <cracauer@cons.org> http://www.cons.org/cracauer/
   Tel.: (private) +4940 5221829 Fax.: (private) +4940 5228536
 
 --2fHTh5uZTiUOsy+g
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="sh.diff"
 
 ? l
 Index: eval.c
 ===================================================================
 RCS file: /home/CVS-FreeBSD/src/bin/sh/eval.c,v
 retrieving revision 1.21
 diff -c -r1.21 eval.c
 *** eval.c	1999/08/27 23:15:10	1.21
 --- eval.c	1999/10/25 10:24:05
 ***************
 *** 275,281 ****
   out:
   	if (pendingsigs)
   		dotrap();
 ! 	if ((flags & EV_EXIT) || (eflag && exitstatus && !(flags & EV_TESTED)))
   		exitshell(exitstatus);
   }
   
 --- 275,282 ----
   out:
   	if (pendingsigs)
   		dotrap();
 ! 	if ((flags & EV_EXIT) || (eflag && exitstatus 
 ! 	    && !(flags & EV_TESTED) && !(n->type == NSEMI)))
   		exitshell(exitstatus);
   }
   
 
 --2fHTh5uZTiUOsy+g--
 

From: Ruslan Ermilov <ru@ucb.crimea.ua>
To: Martin Cracauer <cracauer@cons.org>
Cc: sheldonh@FreeBSD.ORG, freebsd-gnats-submit@FreeBSD.ORG,
	cracauer@FreeBSD.ORG, archie@whistle.com
Subject: Re: bin/14509: bug in make(1)
Date: Mon, 25 Oct 1999 14:27:06 +0300

 On Mon, Oct 25, 1999 at 12:55:45PM +0200, Martin Cracauer wrote:
 > Could you please test the appended diff?
 > 
 > There are possibly other types of nodes that must be excluded from
 > exiting, but this seems to be the most urgent.
 > 
 Yup, it works now!
 
 -- 
 Ruslan Ermilov		Sysadmin and DBA of the
 ru@ucb.crimea.ua	United Commercial Bank,
 ru@FreeBSD.org		FreeBSD committer,
 +380.652.247.647	Simferopol, Ukraine
 
 http://www.FreeBSD.org	The Power To Serve
 http://www.oracle.com	Enabling The Information Age
 
State-Changed-From-To: open->closed 
State-Changed-By: cracauer 
State-Changed-When: Tue Oct 26 16:20:02 MEST 1999 
State-Changed-Why:  
Diff I sent for testing committed to -current. Will be in -stable after 
some time. 
>Unformatted:
