NetBSD Problem Report #1240

From gnats  Tue Jul 18 10:30:55 1995
Received: from romford.Reston.mci.net (romford.Reston.mci.net [204.70.128.197]) by sun-lamp.pc.cs.cmu.edu (8.6.11/8.6.10) with ESMTP id KAA18451 for <gnats-bugs@gnats.netbsd.org>; Tue, 18 Jul 1995 10:30:54 -0400
Message-Id: <95Jul18.103006-0400_edt.196374+3@romford.reston.mci.net>
Date: Tue, 18 Jul 1995 10:30:04 -0400
From: dennis@mci.net
Sender: Dennis Ferguson <dennis@mci.net>
Reply-To: dennis@mci.net
To: gnats-bugs@gnats.netbsd.org
Subject: problem with /bin/sh builtin `exit'
X-Send-Pr-Version: 3.2

>Number:         1240
>Category:       bin
>Synopsis:       /bin/sh `exit' returns wrong status with no argument
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jul 18 10:35:00 +0000 1995
>Closed-Date:    Wed Jul 19 17:15:31 +0000 1995
>Last-Modified:  Wed Jul 19 17:15:58 +0000 1995
>Originator:     Dennis Ferguson
>Release:        NetBSD 1.0A (-current of July 8)
>Organization:
MCI
>Environment:
Sun SS-II
System: NetBSD romford.reston.mci.net 1.0A NetBSD 1.0A (ROMFORD) #0: Sun Jul 9 10:58:27 PDT 1995 dennis@romford.reston.mci.net:/usr/src/sys/arch/sparc/compile/ROMFORD sparc


>Description:
	The sh(1) manual page says the following about exit:
       exit [ exitstatus ]
              Terminate the shell process.  If exitstatus is
              given it is used as the exit status of the shell;
              otherwise the exit status of the preceding command
              is used.
	The exit status returned by `exit' with no argument does not
	match this description, but rather appears to be an unconditional
	`0'.  This may seem like an obscure problem, but is actually
	fairly serious in practice since the ./configure scripts for many
	packages depend on the manual page behaviour for correct results.

>How-To-Repeat:
	romford% /bin/sh
	$ (false ; exit) ; echo $?
	0	-- should be 1
	$ ((exit 222) ; exit) ; echo $?
	0	-- should be 222
	$ 

>Fix:
	I think applying this to /usr/src/bin/sh/main.c will fix it.

*** main.c	1995/07/15 22:58:55	1.1
--- main.c	1995/07/15 23:09:34
***************
*** 341,350 ****
--- 341,354 ----
  	int argc;
  	char **argv; 
  {
+ 	extern int oexitstatus;
+ 
  	if (stoppedjobs())
  		return 0;
  	if (argc > 1)
  		exitstatus = number(argv[1]);
+ 	else
+ 		exitstatus = oexitstatus;
  	exitshell(exitstatus);
  	/*NOTREACHED*/
  	return 0;
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: christos 
State-Changed-When: Wed Jul 19 13:15:31 EDT 1995 
State-Changed-Why:  
I applied the fix. 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.