From owner-freebsd-bugs Mon May 12 21:20:04 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id VAA28066 for bugs-outgoing; Mon, 12 May 1997 21:20:04 -0700 (PDT) Received: (from gnats@localhost) by hub.freebsd.org (8.8.5/8.8.5) id VAA28034; Mon, 12 May 1997 21:20:02 -0700 (PDT) Resent-Date: Mon, 12 May 1997 21:20:02 -0700 (PDT) Resent-Message-Id: <199705130420.VAA28034@hub.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-bugs Resent-Reply-To: FreeBSD-gnats@FreeBSD.ORG, syspmc@dtir.qld.gov.au Received: from bunyip.cc.uq.edu.au (daemon@bunyip.cc.uq.edu.au [130.102.2.1]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id VAA27694 for ; Mon, 12 May 1997 21:12:52 -0700 (PDT) Received: (from daemon@localhost) by bunyip.cc.uq.edu.au (8.8.5/8.8.5) id OAA03776 for FreeBSD-gnats-submit@freebsd.org; Tue, 13 May 1997 14:12:07 +1000 Received: from goblin.devetir.qld.gov.au by ogre.dtir.qld.gov.au (8.7.5/DEVETIR-E0.3a) with ESMTP id OAA26967 for ; Tue, 13 May 1997 14:12:17 +1000 (EST) Received: (from syspmc@localhost) by goblin.devetir.qld.gov.au (8.8.5/8.7.3) id OAA14680; Tue, 13 May 1997 14:11:59 +1000 (EST) Message-Id: <199705130411.OAA14680@goblin.devetir.qld.gov.au> Date: Tue, 13 May 1997 14:11:59 +1000 (EST) From: Phil Chadwick Reply-To: syspmc@dtir.qld.gov.au To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: bin/3587: Bug report for FreeBSD 2.2.x /bin/sh Sender: owner-bugs@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk >Number: 3587 >Category: bin >Synopsis: FreeBSD 2.2.x /bin/sh functions return wrong exit status >Confidential: no >Severity: serious >Priority: high >Responsible: freebsd-bugs >State: open >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon May 12 21:20:01 PDT 1997 >Last-Modified: >Originator: Phil Chadwick >Organization: Department of Training & Industrial Relations >Release: FreeBSD 2.2.x >Environment: FreeBSD 2.2.x >Description: FreeBSD 2.2.x /bin/sh functions don't return exit values as expected with a Bourne (compatible) shell. Traditional Bourne shells implement the "return" command as follows (this from the Solaris 2.5 man page): return [ n ] Causes a function to exit with the return value specified by n. If n is omitted, the return status is that of the last command executed. The FreeBSD 2.2.x /bin/sh doesn't does not, when n is omitted, return the status of the last command executed. This bug was not present in 2.1.5, nor 2.1.7. I discovered it while running the configure scripts for Sam Leffer's HylaFAX and tiff library. >How-To-Repeat: Script started on Tue May 13 08:33:18 1997 $ uname -a FreeBSD scrubber.devetir.qld.gov.au 2.2-STABLE FreeBSD 2.2-STABLE #0: Thu May 1 18:41:39 EST 1997 wjh@scrubber.devetir.qld.gov.au:/usr/src/sys/compile/SCRUBBER i386 $ set PS1=$ PS2=> PATH=/bin:/usr/bin:/usr/local/bin IFS= $ cat bug.sh # fail() { false return # /bin/sh returns zero, wrong. } fail status=$? case $status in 0) echo "shell broken, return status is $status" ;; *) echo "shell OK, return status is $status" ;; esac $ /bin/sh bug.sh shell broken, return status is 0 $ /usr/local/bin/bash bug.sh shell OK, return status is 1 $ /usr/local/bin/ksh bug.sh shell OK, return status is 1 $ ^D Script done on Tue May 13 08:34:01 1997 >Fix: Use bash or ksh Phil -- Phil Chadwick Email: syspmc@dtir.qld.gov.au ,-_|\ Supervisor, UNIX Support Phone: +61 7 3247 9239 / * Department of Training Fax: +61 7 3247 9111 \_,-._/ and Industrial Relations v >Audit-Trail: >Unformatted: