From nobody@FreeBSD.org  Tue Feb 21 14:08:01 2006
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id CD0A716A420
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 21 Feb 2006 14:08:01 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 6DE2643D53
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 21 Feb 2006 14:08:01 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k1LE809Z024361
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 21 Feb 2006 14:08:00 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id k1LE80rW024360;
	Tue, 21 Feb 2006 14:08:00 GMT
	(envelope-from nobody)
Message-Id: <200602211408.k1LE80rW024360@www.freebsd.org>
Date: Tue, 21 Feb 2006 14:08:00 GMT
From: Martin Beran <mb@tns.cz>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Wrong handling of 'return 1' in /bin/sh with 'set -e'
X-Send-Pr-Version: www-2.3

>Number:         93644
>Category:       bin
>Synopsis:       sh(1): Wrong handling of 'return 1' in /bin/sh with 'set -e'
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Feb 21 14:10:05 GMT 2006
>Closed-Date:    Thu Jun 15 07:26:07 GMT 2006
>Last-Modified:  Thu Jun 15 07:26:07 GMT 2006
>Originator:     Martin Beran
>Release:        6.0-RELEASE-p4
>Organization:
Trusted Network Solutions, a.s.
>Environment:
FreeBSD mb.tns.cz 6.0-RELEASE-p4 FreeBSD 6.0-RELEASE-p4 #4: Fri Feb  3 12:09:35 CET 2006     root@mb.tns.cz:/usr/obj/usr/src/sys/MB  i386
>Description:
Shell /bin/sh terminates a script when a function returns with a nonzero return value and 'set -e' is in effect, even when the return value of the function is tested, e.g., by 'if'. This bug occurs only if return is not the last command in the function.
>How-To-Repeat:
#!/bin/sh -e
f() {
    return 1
    :
}
if f; then :; fi
echo END

I think this script should print "END", but is does not. It works as expected after changing function f to
f() {
    return 1
}
or
f() {
    return 1 || :
    :
}
>Fix:
              
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: stefanf 
State-Changed-When: Thu Jun 15 07:25:29 UTC 2006 
State-Changed-Why:  
This bug is already fixed.  Please update to 6.1. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=93644 
>Unformatted:
