diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-07-16 20:36:48 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-07-16 20:36:48 +0200 |
commit | 68e980545af6a8ffb2980f94a6edac4dd89940f3 (patch) | |
tree | 821d730e4fcbe52666d4f43ae34f81681c395a5a | |
parent | b24e55da84093dd6bf6dff79627e32459c3da071 (diff) | |
download | busybox-w32-68e980545af6a8ffb2980f94a6edac4dd89940f3.tar.gz busybox-w32-68e980545af6a8ffb2980f94a6edac4dd89940f3.tar.bz2 busybox-w32-68e980545af6a8ffb2980f94a6edac4dd89940f3.zip |
ttysize: if stdin is not tty, try stdout, then stderr
function old new delta
ttysize_main 135 175 +40
packed_usage 31686 31672 -14
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | miscutils/ttysize.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/miscutils/ttysize.c b/miscutils/ttysize.c index 135ce8535..cba65b148 100644 --- a/miscutils/ttysize.c +++ b/miscutils/ttysize.c | |||
@@ -25,7 +25,7 @@ | |||
25 | //usage:#define ttysize_trivial_usage | 25 | //usage:#define ttysize_trivial_usage |
26 | //usage: "[w] [h]" | 26 | //usage: "[w] [h]" |
27 | //usage:#define ttysize_full_usage "\n\n" | 27 | //usage:#define ttysize_full_usage "\n\n" |
28 | //usage: "Print dimension(s) of stdin's terminal, on error return 80x25" | 28 | //usage: "Print dimensions of stdin tty, or 80x24" |
29 | 29 | ||
30 | #include "libbb.h" | 30 | #include "libbb.h" |
31 | 31 | ||
@@ -37,7 +37,10 @@ int ttysize_main(int argc UNUSED_PARAM, char **argv) | |||
37 | 37 | ||
38 | w = 80; | 38 | w = 80; |
39 | h = 24; | 39 | h = 24; |
40 | if (!ioctl(0, TIOCGWINSZ, &wsz)) { | 40 | if (ioctl(0, TIOCGWINSZ, &wsz) == 0 |
41 | || ioctl(1, TIOCGWINSZ, &wsz) == 0 | ||
42 | || ioctl(2, TIOCGWINSZ, &wsz) == 0 | ||
43 | ) { | ||
41 | w = wsz.ws_col; | 44 | w = wsz.ws_col; |
42 | h = wsz.ws_row; | 45 | h = wsz.ws_row; |
43 | } | 46 | } |