Mercurial > hg > toybox
comparison toys/posix/tty.c @ 653:2986aa63a021
Move commands into "posix", "lsb", and "other" menus/directories.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sat, 25 Aug 2012 14:25:22 -0500 |
parents | toys/tty.c@782859fadd20 |
children | 786841fdb1e0 |
comparison
equal
deleted
inserted
replaced
652:2d7c56913fda | 653:2986aa63a021 |
---|---|
1 /* vi: set sw=4 ts=4: | |
2 * | |
3 * tty.c - Show stdin's terminal name | |
4 * | |
5 * Copyright 2011 Rob Landley <rob@landley.net> | |
6 * | |
7 * See http://opengroup.org/onlinepubs/9699919799/utilities/tty.html | |
8 | |
9 USE_TTY(NEWTOY(tty, "s", TOYFLAG_USR|TOYFLAG_BIN)) | |
10 | |
11 config TTY | |
12 bool "tty" | |
13 default y | |
14 help | |
15 Show filename of terminal connected to stdin. | |
16 | |
17 Prints "not a tty" and exits with nonzero status if no terminal | |
18 is connected to stdin. | |
19 | |
20 -s silent mode | |
21 */ | |
22 | |
23 #include "toys.h" | |
24 | |
25 void tty_main(void) | |
26 { | |
27 char *tty = ttyname(0); | |
28 | |
29 if (!toys.optflags) puts(tty ? tty : "not a tty"); | |
30 | |
31 toys.exitval = !tty; | |
32 } |