NetBSD Problem Report #36822

From oki@chiharu.e-neta.jp  Wed Aug 22 19:22:28 2007
Return-Path: <oki@chiharu.e-neta.jp>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by narn.NetBSD.org (Postfix) with ESMTP id C29AE63B898
	for <gnats-bugs@gnats.NetBSD.org>; Wed, 22 Aug 2007 19:22:27 +0000 (UTC)
Message-Id: <20070822171549.514FB183824@chiharu.e-neta.jp>
Date: Thu, 23 Aug 2007 02:15:49 +0900 (JST)
From: oki@NetBSD.org
Reply-To: oki@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: /bin/sh: incorrect exit status with file redirection error
X-Send-Pr-Version: 3.95

>Number:         36822
>Category:       standards
>Synopsis:       /bin/sh: incorrect exit status with file redirection error
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    msaitoh
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Aug 22 19:25:01 +0000 2007
>Closed-Date:    Mon Jan 21 06:51:05 +0000 2008
>Last-Modified:  Mon Jan 21 06:52:14 +0000 2008
>Originator:     oki@NetBSD.org
>Release:        NetBSD 3.1 (and -current 20070822)
>Organization:

>Environment:
System: NetBSD chiharu.e-neta.jp 3.99.15 NetBSD 3.99.15 (CHIHARU.MP) #25: Thu Feb 2 18:12:52 JST 2006 oki@chiharu.e-neta.jp:/usr/src/sys/arch/i386/compile/CHIHARU.MP i386
Architecture: i386
Machine: i386
>Description:
	if file redirection is failed, the exit status ($?) for the command
        is 0, that is incorrect.

        In Shell and Utilities volume (XCU)
        http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_08_02
        2.8.2 Exit Status for Commands
         ...
        If a command fails during word expansion or redirection,
        its exit status shall be greater than zero.

>How-To-Repeat:
	$ ls < no_such_file; echo $?
	sh: cannot open no_such_file: no such file
	0
	$

>Fix:
Index: redir.c
===================================================================
RCS file: /cvsroot/src/bin/sh/redir.c,v
retrieving revision 1.29
diff -u -r1.29 redir.c
--- redir.c	8 Jul 2004 03:57:33 -0000	1.29
+++ redir.c	22 Aug 2007 16:56:10 -0000
@@ -241,8 +241,10 @@
 	INTON;
 	return;
 ecreate:
+	exerrno = 1;
 	error("cannot create %s: %s", fname, errmsg(errno, E_CREAT));
 eopen:
+	exerrno = 1;
 	error("cannot open %s: %s", fname, errmsg(errno, E_OPEN));
 }


>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: bin-bug-people->msaitoh
Responsible-Changed-By: msaitoh@netbsd.org
Responsible-Changed-When: Tue, 13 Nov 2007 01:56:28 +0000
Responsible-Changed-Why:
take.


State-Changed-From-To: open->closed
State-Changed-By: msaitoh@narn.netbsd.org
State-Changed-When: Mon, 21 Jan 2008 06:51:05 +0000
State-Changed-Why:
fixed in rev. 1.30 and will be pulled up to netbsd-[234]


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.