From 97310d025390e96f34140cff13034fcd2b5da18f Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Tue, 23 Mar 2004 23:15:36 +0000 Subject: Brian Pomerantz writes: I've noticed a bug in the "autowidth" feature more, and is probably in others. The call to the function get_terminal_width_height() passes in a file descriptor but that file descriptor is never used, instead the ioctl() is called with 0. In more_main() the call to get_terminal_width_height() passes 0 as the file descriptor instead of fileno(cin). This isn't a problem when you more a file (e.g. "more /etc/passwd") but when you pipe a file to it (e.g. "cat /etc/passwd | more") the size of the terminal cannot be determined because file descriptor 0 is not a terminal. The fix is simple, I've attached a patch for more.c and get_terminal_width_height.c. BAPper --- libbb/get_terminal_width_height.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libbb/get_terminal_width_height.c') diff --git a/libbb/get_terminal_width_height.c b/libbb/get_terminal_width_height.c index ef90463fb..7a1af6dc1 100644 --- a/libbb/get_terminal_width_height.c +++ b/libbb/get_terminal_width_height.c @@ -36,7 +36,7 @@ void get_terminal_width_height(int fd, int *width, int *height) { struct winsize win = { 0, 0, 0, 0 }; #ifdef CONFIG_FEATURE_AUTOWIDTH - if (ioctl(0, TIOCGWINSZ, &win) != 0) { + if (ioctl(fd, TIOCGWINSZ, &win) != 0) { win.ws_row = 24; win.ws_col = 80; } -- cgit v1.2.3