annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
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.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
1 /* tty.c - Show stdin's terminal name
380
782859fadd20 Implement tty command.
Rob Landley <rob@landley.net>
parents:
diff changeset
2 *
782859fadd20 Implement tty command.
Rob Landley <rob@landley.net>
parents:
diff changeset
3 * Copyright 2011 Rob Landley <rob@landley.net>
782859fadd20 Implement tty command.
Rob Landley <rob@landley.net>
parents:
diff changeset
4 *
782859fadd20 Implement tty command.
Rob Landley <rob@landley.net>
parents:
diff changeset
5 * See http://opengroup.org/onlinepubs/9699919799/utilities/tty.html
782859fadd20 Implement tty command.
Rob Landley <rob@landley.net>
parents:
diff changeset
6
782859fadd20 Implement tty command.
Rob Landley <rob@landley.net>
parents:
diff changeset
7 USE_TTY(NEWTOY(tty, "s", TOYFLAG_USR|TOYFLAG_BIN))
782859fadd20 Implement tty command.
Rob Landley <rob@landley.net>
parents:
diff changeset
8
782859fadd20 Implement tty command.
Rob Landley <rob@landley.net>
parents:
diff changeset
9 config TTY
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.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
10 bool "tty"
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.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
11 default y
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.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
12 help
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.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
13 Show filename of terminal connected to stdin.
380
782859fadd20 Implement tty command.
Rob Landley <rob@landley.net>
parents:
diff changeset
14
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.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
15 Prints "not a tty" and exits with nonzero status if no terminal
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.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
16 is connected to stdin.
380
782859fadd20 Implement tty command.
Rob Landley <rob@landley.net>
parents:
diff changeset
17
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.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
18 -s silent mode
380
782859fadd20 Implement tty command.
Rob Landley <rob@landley.net>
parents:
diff changeset
19 */
782859fadd20 Implement tty command.
Rob Landley <rob@landley.net>
parents:
diff changeset
20
782859fadd20 Implement tty command.
Rob Landley <rob@landley.net>
parents:
diff changeset
21 #include "toys.h"
782859fadd20 Implement tty command.
Rob Landley <rob@landley.net>
parents:
diff changeset
22
782859fadd20 Implement tty command.
Rob Landley <rob@landley.net>
parents:
diff changeset
23 void tty_main(void)
782859fadd20 Implement tty command.
Rob Landley <rob@landley.net>
parents:
diff changeset
24 {
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.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
25 char *tty = ttyname(0);
380
782859fadd20 Implement tty command.
Rob Landley <rob@landley.net>
parents:
diff changeset
26
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.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
27 if (!toys.optflags) puts(tty ? tty : "not a tty");
380
782859fadd20 Implement tty command.
Rob Landley <rob@landley.net>
parents:
diff changeset
28
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.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
29 toys.exitval = !tty;
380
782859fadd20 Implement tty command.
Rob Landley <rob@landley.net>
parents:
diff changeset
30 }