1 /* tty.c - Show stdin's terminal name
3 * Copyright 2011 Rob Landley <rob@landley.net>
5 * See http://opengroup.org/onlinepubs/9699919799/utilities/tty.html
7 USE_TTY(NEWTOY(tty, "s", TOYFLAG_USR|TOYFLAG_BIN))
15 Show filename of terminal connected to stdin.
17 Prints "not a tty" and exits with nonzero status if no terminal
18 is connected to stdin.
20 -s silent, exit code only
27 char *tty = ttyname(0);
29 if (!toys.optflags) puts(tty ? tty : "not a tty");