From pwroot@jhome.DIALix.COM  Wed Jun 28 11:46:57 1995
Received: from jhome.DIALix.COM (jhome.DIALix.COM [192.203.228.69])
          by freefall.cdrom.com (8.6.10/8.6.6) with ESMTP id LAA17705
          for <FreeBSD-gnats-submit@freebsd.org>; Wed, 28 Jun 1995 11:46:51 -0700
Received: (from root@localhost) by jhome.DIALix.COM (8.6.11/8.6.9) id CAA06073; Thu, 29 Jun 1995 02:46:45 +0800
Message-Id: <199506281846.CAA06073@jhome.DIALix.COM>
Date: Thu, 29 Jun 1995 02:46:45 +0800
From: peter@haywire.dialix.com (Peter Wemm)
Reply-To: peter@haywire.dialix.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: /bin/stty gives obscure error message on non-tty stdin
X-Send-Pr-Version: 3.2

>Number:         573
>Category:       bin
>Synopsis:       /bin/stty gives obscure error message on non-tty stdin
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs (FreeBSD bugs mailing list)
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jun 28 11:50:00 1995
>Closed-Date:    Sun Jul 2 10:54:38 MET DST 1995
>Last-Modified:
>Originator:     Peter Wemm
>Release:        FreeBSD 2.0-BUILT-19950626 i386
>Organization:
DIALix Services
>Environment:

FreeBSD-current
FreeBSD jhome.DIALix.COM 2.0-BUILT-19950626 FreeBSD 2.0-BUILT-19950626 #7: Mon Jun 26 04:47:14 WST 1995     pwroot@jhome.DIALix.COM:/usr/src/sys/compile/JHOME  i386

>Description:

stty fails with a non-obvious error message if it's run on a non-tty stream,
such as a rsh or vi pipeline.

The error message is:
stty: TIOCGETD: Operation not supported

It's immediately obvious to the knowledgable hacker type, but not
exactly comforting to the user who's not native to unix.  It's especially
confusing if there's a stty command in their .cshrc and it's showing up
on rsh output.

>How-To-Repeat:

rsh localhost stty

>Fix:
	
I suggest a slight rewording, for example:

stty: tcgetattr: not running on a terminal: Operation not supported

There surely are better messages...

Note that this is a REAL LOW priority.

--- stty.c.dist	Tue May 30 17:51:44 1995
+++ stty.c	Thu Jun 29 02:30:23 1995
@@ -95,10 +95,12 @@
 args:	argc -= optind;
 	argv += optind;
 
+	if (tcgetattr(i.fd, &i.t) < 0) {
+		warn("tcgetattr: not running on a terminal");
+		exit(1);
+	}
 	if (ioctl(i.fd, TIOCGETD, &i.ldisc) < 0)
 		err(1, "TIOCGETD");
-	if (tcgetattr(i.fd, &i.t) < 0)
-		err(1, "tcgetattr");
 	if (ioctl(i.fd, TIOCGWINSZ, &i.win) < 0)
 		warn("TIOCGWINSZ: %s\n", strerror(errno));
 
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: joerg 
State-Changed-When: Sun Jul 2 10:54:38 MET DST 1995 
State-Changed-Why:  
Suggested fix applied, for stty.c revision 1.5 

>Unformatted:



