Mercurial > hg > toybox
annotate toys/posix/tty.c @ 1676:cbb1aca81eca draft
Make toy_exec() check if argc is in optargs and deal with it there so we don't need a separate xexec_optargs().
author | Rob Landley <rob@landley.net> |
---|---|
date | Sat, 07 Feb 2015 16:17:44 -0600 |
parents | bd1225873eb4 |
children |
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 | 2 * |
3 * Copyright 2011 Rob Landley <rob@landley.net> | |
4 * | |
5 * See http://opengroup.org/onlinepubs/9699919799/utilities/tty.html | |
6 | |
7 USE_TTY(NEWTOY(tty, "s", TOYFLAG_USR|TOYFLAG_BIN)) | |
8 | |
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 |
1012
bd1225873eb4
Fix usage: lines for a couple commands.
Rob Landley <rob@landley.net>
parents:
694
diff
changeset
|
13 usage: tty [-s] |
bd1225873eb4
Fix usage: lines for a couple commands.
Rob Landley <rob@landley.net>
parents:
694
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 Show filename of terminal connected to stdin. |
380 | 16 |
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
|
17 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
|
18 is connected to stdin. |
380 | 19 |
1012
bd1225873eb4
Fix usage: lines for a couple commands.
Rob Landley <rob@landley.net>
parents:
694
diff
changeset
|
20 -s silent, exit code only |
380 | 21 */ |
22 | |
23 #include "toys.h" | |
24 | |
25 void tty_main(void) | |
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 char *tty = ttyname(0); |
380 | 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 if (!toys.optflags) puts(tty ? tty : "not a tty"); |
380 | 30 |
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
|
31 toys.exitval = !tty; |
380 | 32 } |