1 /* vi: set sw=4 ts=4: */
3 * Replacement for "stty size", which is awkward for shell script use.
4 * - Allows to request width, height, or both, in any order.
5 * - Does not complain on error, but returns width 80, height 24.
6 * - Size: less than 200 bytes
8 * Copyright (C) 2007 by Denys Vlasenko <vda.linux@googlemail.com>
10 * Licensed under the GPL v2, see the file LICENSE in this tarball.
14 int ttysize_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
15 int ttysize_main(int argc, char **argv)
22 if (!ioctl(0, TIOCGWINSZ, &wsz)) {
28 printf("%u %u", w, h);
30 const char *fmt, *arg;
32 fmt = "%u %u" + 3; /* "%u" */
33 while ((arg = *++argv) != NULL) {
39 fmt = "%u %u" + 2; /* " %u" */