aboutsummaryrefslogtreecommitdiff
path: root/toys/tty.c
diff options
context:
space:
mode:
Diffstat (limited to 'toys/tty.c')
-rw-r--r--toys/tty.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/toys/tty.c b/toys/tty.c
new file mode 100644
index 00000000..c6eeac0a
--- /dev/null
+++ b/toys/tty.c
@@ -0,0 +1,13 @@
+#include "toys.h"
+
+int tty_main(void)
+{
+ char *name = ttyname(0);
+ if (!toys.optflags) {
+ if (name)
+ puts(name);
+ else
+ puts("Not a tty");
+ }
+ return !name;
+}