From nobody  Sun Oct 13 20:06:54 1996
Received: (from nobody@localhost)
          by freefall.freebsd.org (8.7.5/8.7.3) id UAA21113;
          Sun, 13 Oct 1996 20:06:54 -0700 (PDT)
Message-Id: <199610140306.UAA21113@freefall.freebsd.org>
Date: Sun, 13 Oct 1996 20:06:54 -0700 (PDT)
From: george@cia-g.com
To: freebsd-gnats-submit@freebsd.org
Subject: /bin/sh return w/o exitstatus in a function sets exitstatus to true
X-Send-Pr-Version: www-1.0

>Number:         1793
>Category:       bin
>Synopsis:       /bin/sh return w/o exitstatus in a function sets exitstatus to true
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    cracauer
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Oct 13 20:10:01 PDT 1996
>Closed-Date:    Tue May 5 15:54:24 MEST 1998
>Last-Modified:  Tue May  5 15:57:46 MEST 1998
>Originator:     George Simunovich
>Release:        2.2-current
>Organization:
>Environment:
2.2-CURRENT FreeBSD 2.2-CURRENT #0: Sat Oct 12 13:26:46 MDT 1996
>Description:
A return without an exit status in a sh functino sets the exit status
to true.

bash works as does /bin/sh on FreeBSD 2.1.0-RELEASE
>How-To-Repeat:
When the following script is run it echos "True Condition".

#!/bin/sh

Tester()
{
        false
        return
}

if Tester
then
        echo "True Condition"
else
        echo "Not True Condition"
fi

>Fix:
use bash?

>Release-Note:
>Audit-Trail:

From: Steve Price <sprice@hiwaay.net>
To: george@cia-g.com
Cc: freebsd-gnats-submit@FreeBSD.org,
        GNATS Management <gnats@freefall.freebsd.org>,
        freebsd-bugs@freefall.freebsd.org, sprice@hiwaay.net
Subject: Re: bin/1793: /bin/sh return w/o exitstatus in a function sets exitstatus to true
Date: Mon, 14 Oct 1996 00:22:33 -0500 (CDT)

 On Sun, 13 Oct 1996 george@cia-g.com wrote:
 
 # 
 # >Number:         1793
 # >Category:       bin
 # >Synopsis:       /bin/sh return w/o exitstatus in a function sets exitstatus to true
 # >Confidential:   no
 # >Severity:       non-critical
 # >Priority:       low
 # >Responsible:    freebsd-bugs
 # >State:          open
 # >Class:          sw-bug
 # >Submitter-Id:   current-users
 # >Arrival-Date:   Sun Oct 13 20:10:01 PDT 1996
 # >Last-Modified:
 # >Originator:     George Simunovich
 # >Organization:
 # >Release:        2.2-current
 # >Environment:
 # 2.2-CURRENT FreeBSD 2.2-CURRENT #0: Sat Oct 12 13:26:46 MDT 1996
 # >Description:
 # A return without an exit status in a sh functino sets the exit status
 # to true.
 # 
 # bash works as does /bin/sh on FreeBSD 2.1.0-RELEASE
 # >How-To-Repeat:
 # When the following script is run it echos "True Condition".
 # 
 # #!/bin/sh
 # 
 # Tester()
 # {
 #         false
 #         return
 # }
 # 
 # if Tester
 # then
 #         echo "True Condition"
 # else
 #         echo "Not True Condition"
 # fi
 # 
 # >Fix:
 # use bash?
 # 
 # >Audit-Trail:
 # >Unformatted:
 # 
 
 Try doing a 'return $?' to return the exitstatus of the previously
 executed command.  Attached is a one-liner that fixes the case above
 but breaks this new case (at least wrt /bin/bash).
 
 steve[~]$ cat > testing
 tester()
 {
 	return
 }
 
 false
 
 if tester
 then
 	echo "true"
 else
 	echo "false"
 fi
 ^D
 steve[~] /tmp/sh testing
 true
 steve[~] /bin/bash testing
 false
 steve[~]
 
 I will look into this some more and see what I can find.
 
 Steve
 
 Index: eval.c
 ===================================================================
 RCS file: /home/ncvs/src/bin/sh/eval.c,v
 retrieving revision 1.6
 diff -u -r1.6 eval.c
 --- eval.c       1996/10/06 15:17:19    1.6
 +++ eval.c       1996/10/14 05:02:36
 @@ -958,7 +958,7 @@
  {
  	int ret;
  
 -	ret = exitstatus;
 +	ret = oexitstatus;
  	if (argc > 1)
  		ret = number(argv[1]);
  	if (funcnest) {
 
 
Responsible-Changed-From-To: freebsd-bugs->steve 
Responsible-Changed-By: steve 
Responsible-Changed-When: Tue Oct 15 19:13:58 PDT 1996 
Responsible-Changed-Why:  
I am working on this one. 
Responsible-Changed-From-To: steve->cracauer 
Responsible-Changed-By: steve 
Responsible-Changed-When: Tue Apr 28 05:58:25 PDT 1998 
Responsible-Changed-Why:  
Martin said he would take this one. 
State-Changed-From-To: open->closed 
State-Changed-By: cracauer 
State-Changed-When: Tue May 5 15:54:24 MEST 1998 
State-Changed-Why:  
This has been fixed when NetBSD changes were imported by Steve in Dec 1996 
>Unformatted:
