1/* See LICENSE file for copyright and license details. */
2
3
4#include <stdio.h>
5#include <unistd.h>
6
7#include "util.h"
8
9static void
10usage(void)
11{
12 enprintf(2, "usage: %s\n", argv0);
13}
14
15// ?man tty: print terminal filename
16// ?man display the filename of the terminal connected to stdin
17int
18main(int argc, char *argv[])
19{
20 char *tty;
21
22 ARGBEGIN {
23 default:
24 usage();
25 } ARGEND
26
27 if (argc)
28 usage();
29
30 tty = ttyname(STDIN_FILENO);
31 puts(tty ? tty : "not a tty");
32
33 enfshut(2, stdout, "<stdout>");
34 return !tty;
35}