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