wrap bb help output if CONFIG_FEATURE_AUTOWIDTH
authorTim Riker <tim@rikers.org>
Fri, 7 Nov 2003 19:37:20 +0000 (19:37 -0000)
committerTim Riker <tim@rikers.org>
Fri, 7 Nov 2003 19:37:20 +0000 (19:37 -0000)
applets/busybox.c

index 997c155142a14a45ae90c7615b11284bbdc533bf..dfcf400e0aa803d24a53fbd1d24d4bb1d805e89e 100644 (file)
@@ -135,6 +135,14 @@ int busybox_main(int argc, char **argv)
        /* If we've already been here once, exit now */
        if (been_there_done_that == 1 || argc < 1) {
                const struct BB_applet *a = applets;
+               int output_width = 60;
+
+#ifdef CONFIG_FEATURE_AUTOWIDTH
+               /* Obtain the terminal width.  */
+               get_terminal_width_height(0, &output_width, NULL);
+               /* leading tab and room to wrap */
+               output_width -= 20;
+#endif
 
                fprintf(stderr, "%s\n\n"
                                "Usage: busybox [function] [arguments]...\n"
@@ -149,7 +157,7 @@ int busybox_main(int argc, char **argv)
                        col +=
                                fprintf(stderr, "%s%s", ((col == 0) ? "\t" : ", "),
                                                (a++)->name);
-                       if (col > 60 && a->name != 0) {
+                       if (col > output_width && a->name != 0) {
                                fprintf(stderr, ",\n");
                                col = 0;
                        }