| Summary: | Extensions to mesg(1) | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Base System | Reporter: | howardjp <howardjp> | ||||
| Component: | bin | Assignee: | Johan Karlsson <johan> | ||||
| Status: | Closed FIXED | ||||||
| Severity: | Affects Only Me | ||||||
| Priority: | Normal | ||||||
| Version: | 3.2-STABLE | ||||||
| Hardware: | Any | ||||||
| OS: | Any | ||||||
| Attachments: |
|
||||||
|
Description
howardjp
1999-08-11 13:30:04 UTC
Responsible Changed From-To: freebsd-bugs->billf I'll look at this. Responsible Changed From-To: billf->johan Bill suggested I should have a look at this. State Changed From-To: open->analyzed This seems to be a good change. Pending no objection from -standards and -arch I will commit this soon. State Changed From-To: open->analyzed This seems to be a good change. Pending no objection from -standards and -arch I will commit this soon. 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 <bsd.prog.mk> 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 <err.h> #include <stdio.h> #include <stdlib.h> -#include <string.h> #include <unistd.h> 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 Tim (tjr) has already made mesg(1) SuSv3 compiant in current. /Johan -- Johan Karlsson mailto:johan@FreeBSD.org State Changed From-To: analyzed->closed One can now use redirection of stdin to select another tty. # mesg n < /dev/ttyp1 I think this is good enough. If you don't, please argu your case on freebsd-arch@freebsd.org. |