changeset 768:017b8fd3c9ac

A screen width of 1 is possible (in some weird setups), and gives ls -C a division by zero error.
author Rob Landley <rob@landley.net>
date Wed, 26 Dec 2012 19:39:51 -0600
parents 979d038c1688
children 098ab2654fa0
files toys/posix/ls.c
diffstat 1 files changed, 1 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/toys/posix/ls.c	Sun Dec 23 15:07:28 2012 -0600
+++ b/toys/posix/ls.c	Wed Dec 26 19:39:51 2012 -0600
@@ -425,6 +425,7 @@
   else {
     TT.screen_width = 80;
     terminal_size(&TT.screen_width, NULL);
+    if (TT.screen_width<2) TT.screen_width = 2;
     if (!(toys.optflags&(FLAG_1|FLAG_x|FLAG_m))) toys.optflags |= FLAG_C;
   }
   // The optflags parsing infrastructure should really do this for us,