Hi,
Currently the 'help' command prints the synopses of all the builtin
commands in two columns, but does this row by row, making it hard
to see whether a specific command is present or not, as the columns
aren't arranged alphabetically. Also, the text uses a total width
of only 70 characters, whereas almost all terminals are at least 80
positions wide nowadays.
Attached patch prints the builtin commands alphabetically per column
and uses a total width of 80 characters. (Better yet would be to
use the full width of the current terminal, up to a certain limit,
but I don't know how to get that.)
Of course the patch is ugly, but if you agree this is a good change,
I can attempt to make it cleaner and shorter.
Benno
diff -ur bash-3.2.orig/builtins/help.def bash-3.2.new/builtins/help.def
--- bash-3.2.orig/builtins/help.def 2004-12-30 19:59:55.000000000 +0100
+++ bash-3.2.new/builtins/help.def 2006-12-12 21:42:49.000000000 +0100
@@ -175,8 +175,8 @@
static void
show_builtin_command_help ()
{
- int i, j;
- char blurb[36];
+ int i, j, height, width;
+ char blurb[101];
printf (
_("These shell commands are defined internally. Type `help' to see this list.\n\
@@ -187,21 +187,33 @@
A star (*) next to a name means that the command is disabled.\n\
\n"));
- for (i = 0; i < num_shell_builtins; i++)
+ height = (num_shell_builtins + 1) / 2;
+ width = 40; /* XXX better use half of screen width */
+
+ for (i = 0; i < height; i++)
{
QUIT;
blurb[0] = (shell_builtins[i].flags & BUILTIN_ENABLED) ? ' ' : '*';
- strncpy (blurb + 1, shell_builtins[i].short_doc, 34);
- blurb[35] = '\0';
+ strncpy (blurb + 1, shell_builtins[i].short_doc, width - 1 );
+ blurb[width] = '\0';
+ printf ("%s", blurb);
+ for (j = strlen (blurb); j < width; j++)
+ putc (' ', stdout);
+
+ if ((i * 2) == num_shell_builtins)
+ {
+ printf ("\n");
+ break;
+ }
+
+ blurb[0] = (shell_builtins[i+height].flags & BUILTIN_ENABLED) ? ' ' : '*';
+ strncpy (blurb + 1, shell_builtins[i+height].short_doc, width - 1);
+ blurb[width] = '\0';
printf ("%s", blurb);
+ for (j = strlen (blurb); j < width; j++)
+ putc (' ', stdout);
- if (i % 2)
- printf ("\n");
- else
- for (j = strlen (blurb); j < 35; j++)
- putc (' ', stdout);
+ printf ("\n");
}
- if (i % 2)
- printf ("\n");
}
#endif /* HELP_BUILTIN */
_______________________________________________
Bug-bash mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-bash