Mercurial > hg > toybox
comparison toys/posix/tty.c @ 694:786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
The actual code should be the same afterward, this is just cosmetic refactoring.
author | Rob Landley <rob@landley.net> |
---|---|
date | Tue, 13 Nov 2012 17:14:08 -0600 |
parents | 2986aa63a021 |
children | bd1225873eb4 |
comparison
equal
deleted
inserted
replaced
693:4a5a250e0633 | 694:786841fdb1e0 |
---|---|
1 /* vi: set sw=4 ts=4: | 1 /* tty.c - Show stdin's terminal name |
2 * | |
3 * tty.c - Show stdin's terminal name | |
4 * | 2 * |
5 * Copyright 2011 Rob Landley <rob@landley.net> | 3 * Copyright 2011 Rob Landley <rob@landley.net> |
6 * | 4 * |
7 * See http://opengroup.org/onlinepubs/9699919799/utilities/tty.html | 5 * See http://opengroup.org/onlinepubs/9699919799/utilities/tty.html |
8 | 6 |
9 USE_TTY(NEWTOY(tty, "s", TOYFLAG_USR|TOYFLAG_BIN)) | 7 USE_TTY(NEWTOY(tty, "s", TOYFLAG_USR|TOYFLAG_BIN)) |
10 | 8 |
11 config TTY | 9 config TTY |
12 bool "tty" | 10 bool "tty" |
13 default y | 11 default y |
14 help | 12 help |
15 Show filename of terminal connected to stdin. | 13 Show filename of terminal connected to stdin. |
16 | 14 |
17 Prints "not a tty" and exits with nonzero status if no terminal | 15 Prints "not a tty" and exits with nonzero status if no terminal |
18 is connected to stdin. | 16 is connected to stdin. |
19 | 17 |
20 -s silent mode | 18 -s silent mode |
21 */ | 19 */ |
22 | 20 |
23 #include "toys.h" | 21 #include "toys.h" |
24 | 22 |
25 void tty_main(void) | 23 void tty_main(void) |
26 { | 24 { |
27 char *tty = ttyname(0); | 25 char *tty = ttyname(0); |
28 | 26 |
29 if (!toys.optflags) puts(tty ? tty : "not a tty"); | 27 if (!toys.optflags) puts(tty ? tty : "not a tty"); |
30 | 28 |
31 toys.exitval = !tty; | 29 toys.exitval = !tty; |
32 } | 30 } |