NetBSD Problem Report #52406

From www@NetBSD.org  Sat Jul 15 13:25:20 2017
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 69F697A169
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 15 Jul 2017 13:25:20 +0000 (UTC)
Message-Id: <20170715132519.842F87A2AB@mollari.NetBSD.org>
Date: Sat, 15 Jul 2017 13:25:19 +0000 (UTC)
From: steffen@sdaoden.eu
Reply-To: steffen@sdaoden.eu
To: gnats-bugs@NetBSD.org
Subject: POSIX requires sh(1)ell interactivity for IN/ERR, not IN/OUT
X-Send-Pr-Version: www-1.0

>Number:         52406
>Category:       standards
>Synopsis:       POSIX requires sh(1)ell interactivity for IN/ERR, not IN/OUT
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kre
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jul 15 13:30:00 +0000 2017
>Closed-Date:    Tue Jul 25 02:09:13 +0000 2017
>Last-Modified:  Tue Jul 25 02:09:13 +0000 2017
>Originator:     Steffen
>Release:        kre
>Organization:
>Environment:
Subject: Re: Future shell work - comments reqyuested
Date: Sat, 15 Jul 2017 19:52:42 +0700
Message-ID: <16608.1500123162@andromeda.noi.kre.to>
>Description:
In said thread it was revealed that NetBSD shell (and BSD Mail) treat isatty(STDIN/STDOUT) as being interactive, whereas POSIX requires isatty(STDIN/STDERR) for this condition.

POSIX 2008/Cor 2-2016, p. 3226, line 108308 ff.:

If the &#8722;i option is present, or if there are no operands and the shell’s standard input and
standard error are attached to a terminal, the shell is considered to be interactive.

and, ditto, p. 3239, line 108848 ff.:

Standard input and standard error are the files that determine whether a shell is interactive
when &#8722;i is not specified. For example:

       sh > file
       and:
       sh 2> file

create interactive and non-interactive shells, respectively. Although both accept terminal input, the results of error conditions are different, as described in Section 2.8.1 (on page 2363); in the second example a redirection error encountered by a special built-in utility aborts the shell.
>How-To-Repeat:

>Fix:
I expect a painful and lengthy code audit for BSD Mail.   I do not know about the shell.

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: standards-manager->kre
Responsible-Changed-By: kre@NetBSD.org
Responsible-Changed-When: Sat, 15 Jul 2017 17:16:50 +0000
Responsible-Changed-Why:
I am looking into this PR


From: "Robert Elz" <kre@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/52406 CVS commit: src/bin/sh
Date: Mon, 24 Jul 2017 12:35:37 +0000

 Module Name:	src
 Committed By:	kre
 Date:		Mon Jul 24 12:35:37 UTC 2017

 Modified Files:
 	src/bin/sh: options.c

 Log Message:
 PR standards/52406

 Absent other information, the shell should be interactive if reading
 from stdin, and stdin and stderr are ttys, not stdin and stdout.

 So sayeth the great lord posix.


 To generate a diff of this commit:
 cvs rdiff -u -r1.49 -r1.50 src/bin/sh/options.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: kre@NetBSD.org
State-Changed-When: Tue, 25 Jul 2017 02:09:13 +0000
State-Changed-Why:
Fixed


>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-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.