X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=dus.git;a=blobdiff_plain;f=dus.c;h=6e39dcaca145dc371296c46a08d2078a074dbf67;hp=736b136f795c6d7953259a7a80a0a7666745b06a;hb=c59b1d9a2f8e2f78c175d073baea328952c3310a;hpb=906acfdd54b7b32869ffb6a113e7b232773b7f0a diff --git a/dus.c b/dus.c index 736b136..6e39dca 100644 --- a/dus.c +++ b/dus.c @@ -347,6 +347,7 @@ void print_help(FILE *out) { int main(int argc, char **argv) { int c; struct file_with_size *root; + struct winsize win; root = 0; @@ -420,12 +421,8 @@ int main(int argc, char **argv) { } } - if(isatty(STDOUT_FILENO)) { - struct winsize win; - if(ioctl (STDOUT_FILENO, TIOCGWINSZ, (char *) &win)) { - fprintf(stderr, "Can not get the tty size: %s\n", strerror(errno)); - exit (EXIT_FAILURE); - } + if(isatty(STDOUT_FILENO) && + !ioctl (STDOUT_FILENO, TIOCGWINSZ, (char *) &win)) { print_sorted(root, win.ws_col, win.ws_row - 2); } else { print_sorted(root, -1, -1);