1 /* 2 * Copyright (c) 1988, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char copyright[] = 10 "@(#) Copyright (c) 1988, 1993\n\ 11 The Regents of the University of California. All rights reserved.\n"; 12 #endif /* not lint */ 13 14 #ifndef lint 15 static char sccsid[] = "@(#)tty.c 8.1 (Berkeley) 06/06/93"; 16 #endif /* not lint */ 17 18 #include <stdio.h> 19 20 main(argc, argv) 21 int argc; 22 char **argv; 23 { 24 int ch, sflag; 25 char *t, *ttyname(); 26 27 sflag = 0; 28 while ((ch = getopt(argc, argv, "s")) != EOF) 29 switch((char)ch) { 30 case 's': 31 sflag = 1; 32 break; 33 case '?': 34 default: 35 fputs("usage: tty [-s]\n", stderr); 36 exit(2); 37 } 38 39 t = ttyname(0); 40 if (!sflag) 41 puts(t ? t : "not a tty"); 42 exit(t ? 0 : 1); 43 } 44