Commit | Line | Data |
---|---|---|
fe0057bb | 1 | /* |
dd3bc3f0 KB |
2 | * Copyright (c) 1988 Regents of the University of California. |
3 | * All rights reserved. | |
4 | * | |
cb956e54 | 5 | * %sccs.include.redist.c% |
fe0057bb BJ |
6 | */ |
7 | ||
dd3bc3f0 KB |
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 | |
cb956e54 | 15 | static char sccsid[] = "@(#)tty.c 4.4 (Berkeley) %G%"; |
dd3bc3f0 KB |
16 | #endif /* not lint */ |
17 | ||
18 | #include <stdio.h> | |
fe0057bb BJ |
19 | |
20 | main(argc, argv) | |
dd3bc3f0 KB |
21 | int argc; |
22 | char **argv; | |
fe0057bb | 23 | { |
dd3bc3f0 KB |
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); | |
bd1737fa | 36 | exit(2); |
dd3bc3f0 | 37 | } |
fe0057bb | 38 | |
dd3bc3f0 KB |
39 | t = ttyname(0); |
40 | if (!sflag) | |
41 | puts(t ? t : "not a tty"); | |
42 | exit(t ? 0 : 1); | |
fe0057bb | 43 | } |