xref: /original-bsd/usr.bin/tty/tty.c (revision 08eb28af)
1 /*
2  * Copyright (c) 1988 Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 char copyright[] =
10 "@(#) Copyright (c) 1988 Regents of the University of California.\n\
11  All rights reserved.\n";
12 #endif /* not lint */
13 
14 #ifndef lint
15 static char sccsid[] = "@(#)tty.c	4.4 (Berkeley) 06/01/90";
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