From owner-freebsd-arch Wed Jul 24 7:44:39 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E4A0037B401 for ; Wed, 24 Jul 2002 07:44:34 -0700 (PDT) Received: from smtp.noos.fr (zola.noos.net [212.198.2.76]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8599343E65 for ; Wed, 24 Jul 2002 07:44:33 -0700 (PDT) (envelope-from root@gits.dyndns.org) Received: (qmail 47493197 invoked by uid 0); 24 Jul 2002 14:44:30 -0000 Received: from unknown (HELO gits.gits.dyndns.org) ([212.198.229.153]) (envelope-sender ) by 212.198.2.76 (qmail-ldap-1.03) with SMTP for ; 24 Jul 2002 14:44:30 -0000 Received: from gits.gits.dyndns.org (o35qbgfur5fsc04h@localhost [127.0.0.1]) by gits.gits.dyndns.org (8.12.5/8.12.5) with ESMTP id g6OEiTq4013967; Wed, 24 Jul 2002 16:44:30 +0200 (CEST) (envelope-from root@gits.dyndns.org) Received: (from root@localhost) by gits.gits.dyndns.org (8.12.5/8.12.5/Submit) id g6OEiSFp013966; Wed, 24 Jul 2002 16:44:28 +0200 (CEST) (envelope-from root) Date: Wed, 24 Jul 2002 16:44:28 +0200 From: Cyrille Lefevre To: freebsd-gnats-submit@FreeBSD.org, howardjp@wam.umd.edu Cc: freebsd arch Subject: Re: bin/13073: Extensions to mesg(1) Message-ID: <20020724144427.GA13514@gits.dyndns.org> Mail-Followup-To: Cyrille Lefevre , freebsd-gnats-submit@FreeBSD.org, howardjp@wam.umd.edu, freebsd arch Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.99i Organization: ACME X-Face: V|+c;4!|B?E%BE^{E6);aI.[< List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Hi, IMHO, there is no real need for such `-t tty' option. for instance, `mesg n 2< /dev/ttyXX' will do it. however, to match SUSv3, a simple indirection should suffice. http://www.opengroup.org/onlinepubs/007904975/utilities/mesg.html DESCRIPTION ... The terminal device affected shall be determined by searching for the first terminal in the sequence of devices associated with standard input, standard output, and standard error, respectively. ... STDOUT If no operand is specified, mesg shall display the current terminal state in an unspecified format. STDERR The standard error shall be used only for diagnostic messages. EXIT STATUS The following exit values shall be returned: 0 Receiving messages is allowed. 1 Receiving messages is not allowed. >1 An error occurred. also, biff and mesg don't match. the former display it's diagnostic message to stdout and the later to stderr. here is a patch to sync mesg w/ SUSv3. * string.h not needed * try stdin, stdout and stderr in turn * err(1 -> err(2 * fprintf(stderr -> printf( * other changes reduce diffs w/ biff. Index: /usr/src/usr.bin/mesg/Makefile =================================================================== RCS file: /home/ncvs/src/usr.bin/mesg/Makefile,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 Makefile --- /usr/src/usr.bin/mesg/Makefile 27 May 1994 12:30:44 -0000 1.1.1.1 +++ /usr/src/usr.bin/mesg/Makefile 24 Jul 2002 14:25:44 -0000 @@ -1,5 +1,6 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 PROG= mesg +WARNS?= 2 .include Index: /usr/src/usr.bin/mesg/mesg.c =================================================================== RCS file: /home/ncvs/src/usr.bin/mesg/mesg.c,v retrieving revision 1.4 diff -u -r1.4 mesg.c --- /usr/src/usr.bin/mesg/mesg.c 28 Aug 1999 01:03:59 -0000 1.4 +++ /usr/src/usr.bin/mesg/mesg.c 24 Jul 2002 14:39:28 -0000 @@ -56,7 +56,6 @@ #include #include #include -#include #include static void usage __P((void)); @@ -79,33 +78,32 @@ argc -= optind; argv += optind; - if ((tty = ttyname(STDERR_FILENO)) == NULL) - err(1, "ttyname"); + if ((tty = ttyname(STDIN_FILENO)) == NULL && + (tty = ttyname(STDOUT_FILENO)) == NULL && + (tty = ttyname(STDERR_FILENO)) == NULL) + err(2, "unknown tty"); + if (stat(tty, &sb) < 0) - err(1, "%s", tty); + err(2, "%s", tty); if (*argv == NULL) { - if (sb.st_mode & S_IWGRP) { - (void)fprintf(stderr, "is y\n"); - exit(0); - } - (void)fprintf(stderr, "is n\n"); - exit(1); + (void)printf("is %s\n", sb.st_mode & S_IWGRP ? "y" : "n"); + return(sb.st_mode & S_IWGRP ? 0 : 1); } - switch (*argv[0]) { + switch (argv[0][0]) { case 'y': if (chmod(tty, sb.st_mode | S_IWGRP) < 0) - err(1, "%s", tty); - exit(0); + err(2, "%s", tty); + break; case 'n': if (chmod(tty, sb.st_mode & ~S_IWGRP) < 0) - err(1, "%s", tty); - exit(1); + err(2, "%s", tty); + break; + default: + usage(); } - - usage(); - return(0); + return(sb.st_mode & S_IWGRP ? 0 : 1); } static void PS : see PR #13072 for a similar patch to biff. Cyrille. -- Cyrille Lefevre mailto:cyrille.lefevre@laposte.net To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message