-
-int busybox_main(int argc, char **argv)
-{
- int col = 0;
- int ps_index;
- char *index, *index2;
-
- argc--;
-
- /* If we've already been here once, exit now */
- if (been_there_done_that == 1 || argc < 1) {
- const struct BB_applet *a = applets;
-
- fprintf(stderr, "%s\n\n"
- "Usage: busybox [function] [arguments]...\n"
- " or: [function] [arguments]...\n\n"
- "\tBusyBox is a multi-call binary that combines many common Unix\n"
- "\tutilities into a single executable. Most people will create a\n"
- "\tlink to busybox for each function they wish to use, and BusyBox\n"
- "\twill act like whatever it was invoked as.\n"
- "\nCurrently defined functions:\n", full_version);
-
- while (a->name != 0) {
- col +=
- fprintf(stderr, "%s%s", ((col == 0) ? "\t" : ", "),
- (a++)->name);
- if (col > 60 && a->name != 0) {
- fprintf(stderr, ",\n");
- col = 0;
+ /* Deal with --help. (Also print help when called with no arguments) */
+
+ if (argc==1 || !strcmp(argv[1],"--help") ) {
+ if (argc>2) {
+ run_applet_by_name(bb_applet_name=argv[2], 2, argv);
+ } else {
+ const struct BB_applet *a;
+ int col, output_width;
+
+ if (ENABLE_FEATURE_AUTOWIDTH) {
+ /* Obtain the terminal width. */
+ get_terminal_width_height(0, &output_width, NULL);
+ /* leading tab and room to wrap */
+ output_width -= 20;
+ } else output_width = 60;
+
+ printf("%s\n\n"
+ "Usage: busybox [function] [arguments]...\n"
+ " or: [function] [arguments]...\n\n"
+ "\tBusyBox is a multi-call binary that combines many common Unix\n"
+ "\tutilities into a single executable. Most people will create a\n"
+ "\tlink to busybox for each function they wish to use and BusyBox\n"
+ "\twill act like whatever it was invoked as!\n"
+ "\nCurrently defined functions:\n", bb_msg_full_version);
+
+ col=0;
+ for(a = applets; a->name;) {
+ col += printf("%s%s", (col ? ", " : "\t"), (a++)->name);
+ if (col > output_width && a->name) {
+ printf(",\n");
+ col = 0;
+ }