summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog8
-rw-r--r--Makefile2
-rw-r--r--applets/busybox.c7
-rw-r--r--archival/gunzip.c17
-rw-r--r--archival/gzip.c17
-rw-r--r--archival/tar.c6
-rw-r--r--busybox.c7
-rw-r--r--busybox.def.h5
-rw-r--r--console-tools/loadacm.c7
-rw-r--r--console-tools/loadfont.c7
-rw-r--r--console-tools/loadkmap.c7
-rw-r--r--coreutils/cut.c372
-rw-r--r--coreutils/head.c11
-rw-r--r--coreutils/id.c9
-rw-r--r--coreutils/length.c6
-rw-r--r--coreutils/ln.c9
-rw-r--r--coreutils/logname.c8
-rw-r--r--coreutils/ls.c5
-rw-r--r--coreutils/mkdir.c9
-rw-r--r--coreutils/mkfifo.c10
-rw-r--r--coreutils/mknod.c9
-rw-r--r--coreutils/printf.c7
-rw-r--r--coreutils/pwd.c7
-rw-r--r--coreutils/rm.c10
-rw-r--r--coreutils/rmdir.c6
-rw-r--r--coreutils/sleep.c6
-rw-r--r--coreutils/sort.c8
-rw-r--r--coreutils/sync.c6
-rw-r--r--coreutils/tail.c23
-rw-r--r--coreutils/tee.c8
-rw-r--r--coreutils/test.c14
-rw-r--r--coreutils/touch.c8
-rw-r--r--coreutils/tty.c9
-rw-r--r--coreutils/uniq.c11
-rw-r--r--coreutils/usleep.c6
-rw-r--r--coreutils/wc.c9
-rw-r--r--coreutils/whoami.c7
-rw-r--r--coreutils/yes.c7
-rw-r--r--cut.c372
-rw-r--r--docs/busybox.pod12
-rw-r--r--editors/sed.c9
-rw-r--r--fbset.c16
-rw-r--r--fdflush.c6
-rw-r--r--find.c9
-rw-r--r--findutils/find.c9
-rw-r--r--findutils/grep.c9
-rw-r--r--free.c8
-rw-r--r--freeramdisk.c7
-rw-r--r--fsck_minix.c6
-rw-r--r--grep.c9
-rw-r--r--gunzip.c17
-rw-r--r--gzip.c17
-rw-r--r--head.c11
-rw-r--r--hostname.c11
-rw-r--r--id.c9
-rw-r--r--insmod.c9
-rw-r--r--internal.h5
-rw-r--r--kill.c18
-rw-r--r--lash.c7
-rw-r--r--length.c6
-rw-r--r--ln.c9
-rw-r--r--loadacm.c7
-rw-r--r--loadfont.c7
-rw-r--r--loadkmap.c7
-rw-r--r--logger.c9
-rw-r--r--logname.c8
-rw-r--r--ls.c5
-rw-r--r--makedevs.c9
-rw-r--r--math.c9
-rw-r--r--messages.c12
-rw-r--r--miscutils/makedevs.c9
-rw-r--r--miscutils/mt.c7
-rw-r--r--miscutils/update.c9
-rw-r--r--mkdir.c9
-rw-r--r--mkfifo.c10
-rw-r--r--mkfs_minix.c6
-rw-r--r--mknod.c9
-rw-r--r--mkswap.c9
-rw-r--r--modutils/insmod.c9
-rw-r--r--modutils/rmmod.c11
-rw-r--r--more.c11
-rw-r--r--mount.c18
-rw-r--r--mt.c7
-rw-r--r--nc.c (renamed from mnc.c)14
-rw-r--r--networking/hostname.c11
-rw-r--r--networking/nc.c133
-rw-r--r--networking/nslookup.c8
-rw-r--r--networking/ping.c17
-rw-r--r--networking/telnet.c9
-rw-r--r--nslookup.c8
-rw-r--r--ping.c17
-rw-r--r--printf.c7
-rw-r--r--procps/free.c8
-rw-r--r--procps/kill.c18
-rw-r--r--procps/ps.c12
-rw-r--r--ps.c12
-rw-r--r--pwd.c7
-rw-r--r--rm.c10
-rw-r--r--rmdir.c6
-rw-r--r--rmmod.c11
-rw-r--r--sed.c9
-rw-r--r--sfdisk.c12
-rw-r--r--sh.c7
-rw-r--r--shell/lash.c7
-rw-r--r--sleep.c6
-rw-r--r--sort.c8
-rw-r--r--swaponoff.c18
-rw-r--r--sync.c6
-rw-r--r--sysklogd/logger.c9
-rw-r--r--sysklogd/syslogd.c9
-rw-r--r--syslogd.c9
-rw-r--r--tail.c23
-rw-r--r--tar.c6
-rw-r--r--tee.c8
-rw-r--r--telnet.c9
-rw-r--r--test.c14
-rw-r--r--touch.c8
-rw-r--r--tty.c9
-rw-r--r--umount.c7
-rw-r--r--uniq.c11
-rw-r--r--update.c9
-rw-r--r--usleep.c6
-rw-r--r--util-linux/fbset.c16
-rw-r--r--util-linux/fdflush.c6
-rw-r--r--util-linux/freeramdisk.c7
-rw-r--r--util-linux/fsck_minix.c6
-rw-r--r--util-linux/mkfs_minix.c6
-rw-r--r--util-linux/mkswap.c9
-rw-r--r--util-linux/more.c11
-rw-r--r--util-linux/mount.c18
-rw-r--r--util-linux/swaponoff.c18
-rw-r--r--util-linux/umount.c7
-rw-r--r--utility.c74
-rw-r--r--wc.c9
-rw-r--r--whoami.c7
-rw-r--r--yes.c7
136 files changed, 1743 insertions, 454 deletions
diff --git a/Changelog b/Changelog
index 0cd58ef..54ec8d6 100644
--- a/Changelog
+++ b/Changelog
@@ -3,6 +3,8 @@
updated docs/busybox.pod accordingly. -beppu
* Added mktemp, contributed by Daniel Jacobowitz <dan@debian.org>
* Added setkeycodes, for those that have wierd keyboard buttons.
+ * Added cut and tr from minix, since due to the license change,
+ we can now use minix code. Minix tr saves 4k.
* Fix for ping warnings from Sascha Ziemann <szi@aibon.ping.de>
* Fixed update segfault
* Fixed mknod -- minor number was always 0
@@ -18,9 +20,6 @@
* added a simple id implementation; doesn't support sup. groups yet
* logname used getlogin(3) which uses utmp. Now it doesn't.
* whoami used getpwuid(3) which uses libc NSS. Now it behaves.
- * Due to the license change, I can now use minix code. Minux tr
- replaces the BSD derived tr, saving 4k and eliminating bsearch(3)
- from the list of used Libc symbols.
* Add support for "noatime" and "nodiratime" mount flags to mount.
* Changed 'umount -f' to mean force, and actually use umount2.
* Changed 'umount -l' to mean "Do not free loop device".
@@ -29,6 +28,9 @@
* More doc updates
* cp -fa now works as expected for symlinks (it didn't before)
* zcat now works (wasn't working since option parsing was broken)
+ * Renamed "mnc" to the more correct "nc".
+ * Added BB_FEATURE_TRIVIAL_HELP which compiles out most all of the
+ help messages (i.e --help). Saves 17k over a full compile.
-Erik
diff --git a/Makefile b/Makefile
index 1ea5368..6323bd3 100644
--- a/Makefile
+++ b/Makefile
@@ -26,7 +26,7 @@ export VERSION
# Set the following to `true' to make a debuggable build.
# Leave this set to `false' for production use.
# eg: `make DODEBUG=true tests'
-DODEBUG = true
+DODEBUG = false
# If you want a static binary, turn this on.
DOSTATIC = false
diff --git a/applets/busybox.c b/applets/busybox.c
index d8a38ad..85b42df 100644
--- a/applets/busybox.c
+++ b/applets/busybox.c
@@ -65,6 +65,9 @@ static const struct Applet applets[] = {
#ifdef BB_CP_MV
{"cp", cp_mv_main, _BB_DIR_BIN},
#endif
+#ifdef BB_CUT
+ {"cut", cut_main, _BB_DIR_USR_BIN},
+#endif
#ifdef BB_DATE
{"date", date_main, _BB_DIR_BIN},
#endif
@@ -203,8 +206,8 @@ static const struct Applet applets[] = {
#ifdef BB_MKTEMP
{"mktemp", mktemp_main, _BB_DIR_BIN},
#endif
-#ifdef BB_MNC
- {"mnc", mnc_main, _BB_DIR_USR_BIN},
+#ifdef BB_NC
+ {"nc", nc_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_MORE
{"more", more_main, _BB_DIR_BIN},
diff --git a/archival/gunzip.c b/archival/gunzip.c
index bdf8dc2..11fc3a8 100644
--- a/archival/gunzip.c
+++ b/archival/gunzip.c
@@ -28,13 +28,17 @@
*/
#include "internal.h"
+
static const char gunzip_usage[] =
- "gunzip [OPTION]... FILE\n\n"
- "Uncompress FILE (or standard input if FILE is '-').\n\n"
+ "gunzip [OPTION]... FILE\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nUncompress FILE (or standard input if FILE is '-').\n\n"
"Options:\n"
"\t-c\tWrite output to standard output\n"
- "\t-t\tTest compressed file integrity\n";
+ "\t-t\tTest compressed file integrity\n"
+#endif
+ ;
/* These defines are very important for BusyBox. Without these,
@@ -43,8 +47,9 @@ static const char gunzip_usage[] =
#define SMALL_MEM
#define DYN_ALLOC
-#define bb_need_name_too_long
#define BB_DECLARE_EXTERN
+#define bb_need_memory_exhausted
+#define bb_need_name_too_long
#include "messages.c"
@@ -206,7 +211,7 @@ extern int method; /* compression method */
# define DECLARE(type, array, size) type * array
# define ALLOC(type, array, size) { \
array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
- if (array == NULL) errorMsg("insufficient memory"); \
+ if (array == NULL) errorMsg(memory_exhausted, "gunzip"); \
}
# define FREE(array) {if (array != NULL) free(array), array=NULL;}
#else
@@ -1053,7 +1058,7 @@ int in, out; /* input and output file descriptors */
int res = inflate();
if (res == 3) {
- errorMsg("out of memory");
+ errorMsg(memory_exhausted, "gunzip");
} else if (res != 0) {
errorMsg("invalid compressed data--format violated");
}
diff --git a/archival/gzip.c b/archival/gzip.c
index cc6868b..17ebf6c 100644
--- a/archival/gzip.c
+++ b/archival/gzip.c
@@ -30,6 +30,9 @@
*/
#include "internal.h"
+#define BB_DECLARE_EXTERN
+#define bb_need_memory_exhausted
+#include "messages.c"
/* These defines are very important for BusyBox. Without these,
* huge chunks of ram are pre-allocated making the BusyBox bss
@@ -39,12 +42,15 @@
static const char gzip_usage[] =
- "gzip [OPTION]... FILE\n\n"
- "Compress FILE with maximum compression.\n"
+ "gzip [OPTION]... FILE\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCompress FILE with maximum compression.\n"
"When FILE is '-', reads standard input. Implies -c.\n\n"
"Options:\n"
- "\t-c\tWrite output to standard output instead of FILE.gz\n";
+ "\t-c\tWrite output to standard output instead of FILE.gz\n"
+#endif
+ ;
/* I don't like nested includes, but the string and io functions are used
@@ -121,7 +127,7 @@ extern int method; /* compression method */
# define DECLARE(type, array, size) type * array
# define ALLOC(type, array, size) { \
array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
- if (array == NULL) errorMsg("insufficient memory"); \
+ if (array == NULL) errorMsg(memory_exhausted, "gzip"); \
}
# define FREE(array) {if (array != NULL) free(array), array=NULL;}
#else
@@ -1778,7 +1784,6 @@ int part_nb; /* number of parts in .gz file */
long time_stamp; /* original time stamp (modification time) */
long ifile_size; /* input file size, -1 for devices (debug only) */
char *env; /* contents of GZIP env variable */
-char **args = NULL; /* argv pointer if GZIP env variable defined */
char z_suffix[MAX_SUFFIX + 1]; /* default suffix (can be set with --suffix) */
int z_len; /* strlen(z_suffix) */
@@ -3248,7 +3253,7 @@ char *env; /* name of environment variable */
nargv = (char **) calloc(*argcp + 1, sizeof(char *));
if (nargv == NULL)
- errorMsg("out of memory");
+ errorMsg(memory_exhausted, "gzip");
oargv = *argvp;
*argvp = nargv;
diff --git a/archival/tar.c b/archival/tar.c
index c82e51f..6784d80 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -60,8 +60,9 @@ static const char tar_usage[] =
#if defined BB_FEATURE_TAR_EXCLUDE
"[--exclude File] "
#endif
- "[-f tarFile] [FILE] ...\n\n"
- "Create, extract, or list files from a tar file. Note that\n"
+ "[-f tarFile] [FILE] ...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCreate, extract, or list files from a tar file. Note that\n"
"this version of tar treats hard links as separate files.\n\n"
"Main operation mode:\n"
#ifdef BB_FEATURE_TAR_CREATE
@@ -77,6 +78,7 @@ static const char tar_usage[] =
#endif
"\nInformative output:\n"
"\tv\t\tverbosely list files processed\n"
+#endif
;
/* Tar file constants */
diff --git a/busybox.c b/busybox.c
index d8a38ad..85b42df 100644
--- a/busybox.c
+++ b/busybox.c
@@ -65,6 +65,9 @@ static const struct Applet applets[] = {
#ifdef BB_CP_MV
{"cp", cp_mv_main, _BB_DIR_BIN},
#endif
+#ifdef BB_CUT
+ {"cut", cut_main, _BB_DIR_USR_BIN},
+#endif
#ifdef BB_DATE
{"date", date_main, _BB_DIR_BIN},
#endif
@@ -203,8 +206,8 @@ static const struct Applet applets[] = {
#ifdef BB_MKTEMP
{"mktemp", mktemp_main, _BB_DIR_BIN},
#endif
-#ifdef BB_MNC
- {"mnc", mnc_main, _BB_DIR_USR_BIN},
+#ifdef BB_NC
+ {"nc", nc_main, _BB_DIR_USR_BIN},
#endif
#ifdef BB_MORE
{"more", more_main, _BB_DIR_BIN},
diff --git a/busybox.def.h b/busybox.def.h
index a2d216f..744db85 100644
--- a/busybox.def.h
+++ b/busybox.def.h
@@ -14,6 +14,7 @@
#define BB_CHVT
#define BB_CLEAR
#define BB_CP_MV
+#define BB_CUT
#define BB_DATE
#define BB_DD
#define BB_DEALLOCVT
@@ -60,7 +61,7 @@
#define BB_MKNOD
#define BB_MKSWAP
#define BB_MKTEMP
-#define BB_MNC
+#define BB_NC
#define BB_MORE
#define BB_MOUNT
#define BB_MT
@@ -134,7 +135,7 @@
//
// This compiles out everything but the most
// trivial --help usage information (i.e. reduces binary size)
-//#define BB_FEATURE_TRIVIAL_HELP
+#define BB_FEATURE_TRIVIAL_HELP
//
// Use termios to manipulate the screen ('more' is prettier with this on)
//#define BB_FEATURE_USE_TERMIOS
diff --git a/console-tools/loadacm.c b/console-tools/loadacm.c
index 8f69234..cca5406 100644
--- a/console-tools/loadacm.c
+++ b/console-tools/loadacm.c
@@ -22,8 +22,11 @@
#include <sys/ioctl.h>
#include <sys/kd.h>
-static const char loadacm_usage[] = "loadacm\n\n"
- "Loads an acm from standard input.\n";
+static const char loadacm_usage[] = "loadacm\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nLoads an acm from standard input.\n"
+#endif
+ ;
typedef unsigned short unicode;
diff --git a/console-tools/loadfont.c b/console-tools/loadfont.c
index 5e1f04d..7eaf40e 100644
--- a/console-tools/loadfont.c
+++ b/console-tools/loadfont.c
@@ -30,8 +30,11 @@
#define PSF_MAXMODE 0x03
#define PSF_SEPARATOR 0xFFFF
-static const char loadfont_usage[] = "loadfont\n\n"
- "Loads a console font from standard input.\n";
+static const char loadfont_usage[] = "loadfont\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "Loads a console font from standard input.\n"
+#endif
+ ;
struct psf_header {
unsigned char magic1, magic2; /* Magic number */
diff --git a/console-tools/loadkmap.c b/console-tools/loadkmap.c
index 75e52e1..99efc51 100644
--- a/console-tools/loadkmap.c
+++ b/console-tools/loadkmap.c
@@ -29,8 +29,11 @@
#include <sys/ioctl.h>
-static const char loadkmap_usage[] = "loadkmap\n\n"
- "Loads a binary keyboard translation table from standard input.\n";
+static const char loadkmap_usage[] = "loadkmap\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "Loads a binary keyboard translation table from standard input.\n"
+#endif
+ ;
int loadkmap_main(int argc, char **argv)
diff --git a/coreutils/cut.c b/coreutils/cut.c
new file mode 100644
index 0000000..89a934e
--- /dev/null
+++ b/coreutils/cut.c
@@ -0,0 +1,372 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * cut implementation for busybox
+ *
+ * Copyright (c) Michael J. Holme
+ *
+ * This version of cut is adapted from Minix cut and was modified
+ * by Erik Andersen <andersee@debian.org> to be used in busybox.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Original copyright notice is retained at the end of this file.
+ */
+
+#include "internal.h"
+#include <sys/types.h>
+#include <ctype.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#define BB_DECLARE_EXTERN
+#define bb_need_help
+#include "messages.c"
+
+#define MAX_FIELD 80 /* Pointers to the beginning of each field
+ * are stored in columns[], if a line holds
+ * more than MAX_FIELD columns the array
+ * boundary is exceed. But unlikely at 80 */
+
+#define MAX_ARGS 32 /* Maximum number of fields following -f or
+ * -c switches */
+int args[MAX_ARGS * 2];
+int num_args;
+
+/* Lots of new defines, should easen maintainance... */
+#define DUMP_STDIN 0 /* define for mode: no options */
+#define OPTIONF 1 /* define for mode: option -f */
+#define OPTIONC 2 /* define for mode: option -c */
+#define OPTIONB 3 /* define for mode: option -b */
+#define NOTSET 0 /* option not selected */
+#define SET 1 /* option selected */
+
+/* Defines for the warnings */
+#define DELIMITER_NOT_APPLICABLE 0
+#define OVERRIDING_PREVIOUS_MODE 1
+#define OPTION_NOT_APPLICABLE 2
+#define UNKNOWN_OPTION 3
+#define FILE_NOT_READABLE 4
+
+/* Defines for the fatal errors */
+#define SYNTAX_ERROR 101
+#define POSITION_ERROR 102
+#define LINE_TO_LONG_ERROR 103
+#define RANGE_ERROR 104
+#define MAX_FIELDS_EXEEDED_ERROR 105
+#define MAX_ARGS_EXEEDED_ERROR 106
+
+
+int mode; /* 0 = dump stdin to stdout, 1=-f, 2=-c */
+char delim = '\t'; /* default delimiting character */
+FILE *fd;
+char *name;
+char line[BUFSIZ];
+int exit_status;
+
+int cut_main(int argc, char **argv);
+void warn(int warn_number, char *option);
+void cuterror(int err);
+void get_args(void);
+void cut(void);
+
+void warn(int warn_number, char *option)
+{
+ static char *warn_msg[] = {
+ "%s: Option -d allowed only with -f\n",
+ "%s: -%s overrides earlier option\n",
+ "%s: -%s not allowed in current mode\n",
+ "%s: Cannot open %s\n"
+ };
+
+ fprintf(stderr, warn_msg[warn_number], name, option);
+ exit_status = warn_number + 1;
+
+}
+
+void cuterror(int err)
+{
+ static char *err_mes[] = {
+ "%s: syntax error\n",
+ "%s: position must be >0\n",
+ "%s: line longer than BUFSIZ\n",
+ "%s: range must not decrease from left to right\n",
+ "%s: MAX_FIELD exceeded\n",
+ "%s: MAX_ARGS exceeded\n"
+ };
+
+ fprintf(stderr, err_mes[err - 101], name);
+ exit(err);
+}
+
+
+void get_args()
+{
+ int i = 0;
+ int arg_ptr = 0;
+ int flag;
+
+ num_args = 0;
+ do {
+ if (num_args == MAX_ARGS)
+ cuterror(MAX_ARGS_EXEEDED_ERROR);
+ if (!isdigit(line[i]) && line[i] != '-')
+ cuterror(SYNTAX_ERROR);
+
+ args[arg_ptr] = 1;
+ args[arg_ptr + 1] = BUFSIZ;
+ flag = 1;
+
+ while (line[i] != ',' && line[i] != 0) {
+ if (isdigit(line[i])) {
+ args[arg_ptr] = 0;
+ while (isdigit(line[i]))
+ args[arg_ptr] = 10 * args[arg_ptr] + line[i++] - '0';
+ if (!args[arg_ptr])
+ cuterror(POSITION_ERROR);
+ arg_ptr++;
+ }
+ if (line[i] == '-') {
+ arg_ptr |= 1;
+ i++;
+ flag = 0;
+ }
+ }
+ if (flag && arg_ptr & 1)
+ args[arg_ptr] = args[arg_ptr - 1];
+ if (args[num_args * 2] > args[num_args * 2 + 1])
+ cuterror(RANGE_ERROR);
+ num_args++;
+ arg_ptr = num_args * 2;
+ }
+ while (line[i++]);
+}
+
+
+void cut()
+{
+ int i, j, length, maxcol=0;
+ char *columns[MAX_FIELD];
+
+ while (fgets(line, BUFSIZ, fd)) {
+ length = strlen(line) - 1;
+ *(line + length) = 0;
+ switch (mode) {
+ case DUMP_STDIN:
+ printf("%s", line);
+ break;
+ case OPTIONF:
+ columns[maxcol++] = line;
+ for (i = 0; i < length; i++) {
+ if (*(line + i) == delim) {
+ *(line + i) = 0;
+ if (maxcol == MAX_FIELD)
+ cuterror(MAX_FIELDS_EXEEDED_ERROR);
+ columns[maxcol] = line + i + 1;
+ maxcol++;
+ }
+ }
+ if (maxcol != 1) {
+ for (i = 0; i < num_args; i++) {
+ for (j = args[i * 2]; j <= args[i * 2 + 1]; j++)
+ if (j <= maxcol) {
+ printf("%s", columns[j - 1]);
+ if (i != num_args - 1 || j != args[i * 2 + 1])
+ putchar(delim);
+ }
+ }
+ }
+ break;
+ case OPTIONC:
+ for (i = 0; i < num_args; i++) {
+ for (j = args[i * 2];
+ j <= (args[i * 2 + 1] >
+ length ? length : args[i * 2 + 1]); j++)
+ putchar(*(line + j - 1));
+ }
+ }
+ if (maxcol != 1)
+ putchar('\n');
+ }
+}
+
+
+int cut_main(int argc, char **argv)
+{
+ int i = 1;
+ int numberFilenames = 0;
+
+ name = argv[0];
+
+ if (argc == 1 || strcmp(argv[1], dash_dash_help)==0)
+ usage( "cut [OPTION]... [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrints selected fields from each input FILE to standard output.\n\n"
+ "Options:\n"
+ "\t-b LIST\tOutput only bytes from LIST\n"
+ "\t-c LIST\tOutput only characters from LIST\n"
+ "\t-d DELIM\tUse DELIM instead of tab as the field delimiter\n"
+ "\t-f N\tPrint only these fields\n"
+ "\t-n\tIgnored\n"
+#endif
+ );
+
+ while (i < argc) {
+ if (argv[i][0] == '-') {
+ switch (argv[i++][1]) {
+ case 'd':
+ if (mode == OPTIONC || mode == OPTIONB)
+ warn(DELIMITER_NOT_APPLICABLE, "d");
+ delim = argv[i++][0];
+ break;
+ case 'f':
+ sprintf(line, "%s", argv[i++]);
+ if (mode == OPTIONC || mode == OPTIONB)
+ warn(OVERRIDING_PREVIOUS_MODE, "f");
+ mode = OPTIONF;
+ break;
+ case 'b':
+ sprintf(line, "%s", argv[i++]);
+ if (mode == OPTIONF || mode == OPTIONC)
+ warn(OVERRIDING_PREVIOUS_MODE, "b");
+ mode = OPTIONB;
+ break;
+ case 'c':
+ sprintf(line, "%s", argv[i++]);
+ if (mode == OPTIONF || mode == OPTIONB)
+ warn(OVERRIDING_PREVIOUS_MODE, "c");
+ mode = OPTIONC;
+ break;
+ case '\0': /* - means: read from stdin */
+ numberFilenames++;
+ break;
+ case 'n': /* needed for Posix, but no effect here */
+ if (mode != OPTIONB)
+ warn(OPTION_NOT_APPLICABLE, "n");
+ break;
+ default:
+ warn(UNKNOWN_OPTION, &(argv[i - 1][1]));
+ }
+ } else {
+ i++;
+ numberFilenames++;
+ }
+ }
+
+/* Here follow the checks, if the selected options are reasonable. */
+ if (mode == OPTIONB) /* since in Minix char := byte */
+ mode = OPTIONC;
+ get_args();
+ if (numberFilenames != 0) {
+ i = 1;
+ while (i < argc) {
+ if (argv[i][0] == '-') {
+ switch (argv[i][1]) {
+ case 'f':
+ case 'c':
+ case 'b':
+ case 'd':
+ i += 2;
+ break;
+ case 'n':
+ case 'i':
+ case 's':
+ i++;
+ break;
+ case '\0':
+ fd = stdin;
+ i++;
+ cut();
+ break;
+ default:
+ i++;
+ }
+ } else {
+ if ((fd = fopen(argv[i++], "r")) == NULL) {
+ warn(FILE_NOT_READABLE, argv[i - 1]);
+ } else {
+ cut();
+ fclose(fd);
+ }
+ }
+ }
+ } else {
+ fd = stdin;
+ cut();
+ }
+
+ exit(exit_status);
+}
+
+/* cut - extract columns from a file or stdin. Author: Michael J. Holme
+ *
+ * Copyright 1989, Michael John Holme, All rights reserved.
+ * This code may be freely distributed, provided that this notice
+ * remains intact.
+ *
+ * V1.1: 6th September 1989
+ *
+ * Bugs, criticisms, etc,
+ * c/o Mark Powell
+ * JANET sq79@uk.ac.liv
+ * ARPA sq79%liv.ac.uk@nsfnet-relay.ac.uk
+ * UUCP ...!mcvax!ukc!liv.ac.uk!sq79
+ *-------------------------------------------------------------------------
+ * Changed for POSIX1003.2/Draft10 conformance
+ * Thomas Brupbacher (tobr@mw.lpc.ethz.ch), September 1990.
+ * Changes:
+ * - separation of error messages ( stderr) and output (stdout).
+ * - support for -b and -n (no effect, -b acts as -c)
+ * - support for -s
+ *-------------------------------------------------------------------------
+ */
+
+/*
+ * Copyright (c) 1987,1997, Prentice Hall
+ * All rights reserved.
+ *
+ * Redistribution and use of the MINIX operating system in source and
+ * binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * Neither the name of Prentice Hall nor the names of the software
+ * authors or contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS, AUTHORS, AND
+ * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL PRENTICE HALL OR ANY AUTHORS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+
diff --git a/coreutils/head.c b/coreutils/head.c
index 3db64b3..f4ebe05 100644
--- a/coreutils/head.c
+++ b/coreutils/head.c
@@ -27,12 +27,15 @@
#include <stdio.h>
const char head_usage[] =
- "head [OPTION] [FILE]...\n\n"
- "Print first 10 lines of each FILE to standard output.\n"
+ "head [OPTION] [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrint first 10 lines of each FILE to standard output.\n"
"With more than one FILE, precede each with a header giving the\n"
"file name. With no FILE, or when FILE is -, read standard input.\n\n"
- "Options:\n" "\t-n NUM\t\tPrint first NUM lines instead of first 10\n";
+ "Options:\n" "\t-n NUM\t\tPrint first NUM lines instead of first 10\n"
+#endif
+ ;
int head(int len, FILE * src)
{
@@ -109,4 +112,4 @@ int head_main(int argc, char **argv)
exit(0);
}
-/* $Id: head.c,v 1.9 2000/04/13 01:18:56 erik Exp $ */
+/* $Id: head.c,v 1.10 2000/05/12 19:41:47 erik Exp $ */
diff --git a/coreutils/id.c b/coreutils/id.c
index 8ded0e5..542f865 100644
--- a/coreutils/id.c
+++ b/coreutils/id.c
@@ -29,11 +29,14 @@
#include <sys/types.h>
static const char id_usage[] =
- "id [OPTIONS]... [USERNAME]\n\n"
- "Print information for USERNAME or the current user\n\n"
+ "id [OPTIONS]... [USERNAME]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrint information for USERNAME or the current user\n\n"
"\t-g\tprints only the group ID\n"
"\t-u\tprints only the user ID\n"
- "\t-r\tprints the real user ID instead of the effective ID (with -ug)\n\n";
+ "\t-r\tprints the real user ID instead of the effective ID (with -ug)\n\n"
+#endif
+ ;
extern int id_main(int argc, char **argv)
{
diff --git a/coreutils/length.c b/coreutils/length.c
index 4cbe7e1..c7df216 100644
--- a/coreutils/length.c
+++ b/coreutils/length.c
@@ -7,7 +7,11 @@
extern int length_main(int argc, char **argv)
{
if (argc != 2 || **(argv + 1) == '-') {
- usage("length string\n");
+ usage("length STRING\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrints out the length of the specified STRING.\n"
+#endif
+ );
}
printf("%lu\n", (long)strlen(argv[1]));
return (TRUE);
diff --git a/coreutils/ln.c b/coreutils/ln.c
index eb7c996..29ff938 100644
--- a/coreutils/ln.c
+++ b/coreutils/ln.c
@@ -32,13 +32,16 @@
#include <errno.h>
static const char ln_usage[] =
- "ln [OPTION] TARGET... LINK_NAME|DIRECTORY\n\n"
- "Create a link named LINK_NAME or DIRECTORY to the specified TARGET\n\n"
+ "ln [OPTION] TARGET... LINK_NAME|DIRECTORY\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCreate a link named LINK_NAME or DIRECTORY to the specified TARGET\n\n"
"Options:\n"
"\t-s\tmake symbolic links instead of hard links\n"
"\t-f\tremove existing destination files\n"
- "\t-n\tno dereference symlinks - treat like normal file\n";
+ "\t-n\tno dereference symlinks - treat like normal file\n"
+#endif
+ ;
static int symlinkFlag = FALSE;
static int removeoldFlag = FALSE;
diff --git a/coreutils/logname.c b/coreutils/logname.c
index bde1752..7c6153f 100644
--- a/coreutils/logname.c
+++ b/coreutils/logname.c
@@ -23,9 +23,11 @@
#include "internal.h"
#include <stdio.h>
-static const char logname_usage[] = "logname\n\n"
-
- "Print the name of the current user.\n";
+static const char logname_usage[] = "logname\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrint the name of the current user.\n"
+#endif
+ ;
extern int logname_main(int argc, char **argv)
{
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 3c518ab..6ab11c4 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -449,7 +449,9 @@ static const char ls_usage[] = "ls [-1a"
#ifdef BB_FEATURE_LS_FILETYPES
"F"
#endif
- "] [filenames...]\n\n"
+ "] [filenames...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nList directory contents\n\n"
"Options:\n"
"\t-a\tdo not hide entries starting with .\n"
#ifdef BB_FEATURE_LS_TIMESTAMPS
@@ -475,6 +477,7 @@ static const char ls_usage[] = "ls [-1a"
#ifdef BB_FEATURE_LS_FILETYPES
"\t-F\tappend indicator (one of */=@|) to entries\n"
#endif
+#endif
;
extern int ls_main(int argc, char **argv)
diff --git a/coreutils/mkdir.c b/coreutils/mkdir.c
index 54d9b72..9664986 100644
--- a/coreutils/mkdir.c
+++ b/coreutils/mkdir.c
@@ -30,12 +30,15 @@
#include <errno.h>
static const char mkdir_usage[] =
- "mkdir [OPTION] DIRECTORY...\n\n"
- "Create the DIRECTORY(ies), if they do not already exist\n\n"
+ "mkdir [OPTION] DIRECTORY...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCreate the DIRECTORY(ies), if they do not already exist\n\n"
"Options:\n"
"\t-m\tset permission mode (as in chmod), not rwxrwxrwx - umask\n"
- "\t-p\tno error if existing, make parent directories as needed\n";
+ "\t-p\tno error if existing, make parent directories as needed\n"
+#endif
+ ;
static int parentFlag = FALSE;
diff --git a/coreutils/mkfifo.c b/coreutils/mkfifo.c
index b273df0..ef3d667 100644
--- a/coreutils/mkfifo.c
+++ b/coreutils/mkfifo.c
@@ -26,11 +26,13 @@
#include <sys/stat.h>
#include <errno.h>
-static const char mkfifo_usage[] = "mkfifo [OPTIONS] name\n\n"
- "Creates a named pipe (identical to 'mknod name p')\n\n"
-
+static const char mkfifo_usage[] = "mkfifo [OPTIONS] name\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCreates a named pipe (identical to 'mknod name p')\n\n"
"Options:\n"
- "\t-m\tcreate the pipe using the specified mode (default a=rw)\n";
+ "\t-m\tcreate the pipe using the specified mode (default a=rw)\n"
+#endif
+ ;
extern int mkfifo_main(int argc, char **argv)
{
diff --git a/coreutils/mknod.c b/coreutils/mknod.c
index caa234f..8f411a3 100644
--- a/coreutils/mknod.c
+++ b/coreutils/mknod.c
@@ -28,14 +28,17 @@
#include <fcntl.h>
#include <unistd.h>
-static const char mknod_usage[] = "mknod [OPTIONS] NAME TYPE MAJOR MINOR\n\n"
- "Create a special file (block, character, or pipe).\n\n"
+static const char mknod_usage[] = "mknod [OPTIONS] NAME TYPE MAJOR MINOR\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCreate a special file (block, character, or pipe).\n\n"
"Options:\n"
"\t-m\tcreate the special file using the specified mode (default a=rw)\n\n"
"TYPEs include:\n"
"\tb:\tMake a block (buffered) device.\n"
"\tc or u:\tMake a character (un-buffered) device.\n"
- "\tp:\tMake a named pipe. MAJOR and MINOR are ignored for named pipes.\n";
+ "\tp:\tMake a named pipe. MAJOR and MINOR are ignored for named pipes.\n"
+#endif
+ ;
int mknod_main(int argc, char **argv)
{
diff --git a/coreutils/printf.c b/coreutils/printf.c
index bfe4081..28a011d 100644
--- a/coreutils/printf.c
+++ b/coreutils/printf.c
@@ -139,7 +139,12 @@ static void verify __P((char *s, char *end));
/* The value to return to the calling program. */
static int exit_status;
-static const char printf_usage[] = "printf format [argument...]\n\nFormats and prints the given data.\n";
+static const char printf_usage[] = "printf FORMAT [ARGUMENT...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nFormats and prints ARGUMENT(s) according to FORMAT,\n"
+ "Where FORMAT controls the output exactly as in C printf.\n"
+#endif
+ ;
int printf_main(int argc, char **argv)
{
diff --git a/coreutils/pwd.c b/coreutils/pwd.c
index e77a0ca..19494a9 100644
--- a/coreutils/pwd.c
+++ b/coreutils/pwd.c
@@ -24,15 +24,14 @@
#include "internal.h"
#include <stdio.h>
#include <dirent.h>
+#include <errno.h>
extern int pwd_main(int argc, char **argv)
{
char buf[BUFSIZ + 1];
- if (getcwd(buf, sizeof(buf)) == NULL) {
- perror("get working directory");
- exit(FALSE);
- }
+ if (getcwd(buf, sizeof(buf)) == NULL)
+ fatalError("pwd: %s", strerror(errno));
printf("%s\n", buf);
exit(TRUE);
diff --git a/coreutils/rm.c b/coreutils/rm.c
index 0cd7956..c62d68a 100644
--- a/coreutils/rm.c
+++ b/coreutils/rm.c
@@ -29,12 +29,14 @@
#include <dirent.h>
#include <errno.h>
-static const char *rm_usage = "rm [OPTION]... FILE...\n\n"
- "Remove (unlink) the FILE(s).\n\n"
+static const char *rm_usage = "rm [OPTION]... FILE...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nRemove (unlink) the FILE(s).\n\n"
"Options:\n"
-
"\t-f\t\tremove existing destinations, never prompt\n"
- "\t-r or -R\tremove the contents of directories recursively\n";
+ "\t-r or -R\tremove the contents of directories recursively\n"
+#endif
+ ;
static int recursiveFlag = FALSE;
diff --git a/coreutils/rmdir.c b/coreutils/rmdir.c
index 1d88de3..61d7f2a 100644
--- a/coreutils/rmdir.c
+++ b/coreutils/rmdir.c
@@ -31,7 +31,11 @@ extern int rmdir_main(int argc, char **argv)
{
if (argc == 1 || **(argv + 1) == '-') {
usage
- ("rmdir [OPTION]... DIRECTORY...\n\nRemove the DIRECTORY(ies), if they are empty.\n");
+ ("rmdir [OPTION]... DIRECTORY...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nRemove the DIRECTORY(ies), if they are empty.\n"
+#endif
+ );
}
while (--argc > 0) {
diff --git a/coreutils/sleep.c b/coreutils/sleep.c
index 9687b84..13f07c0 100644
--- a/coreutils/sleep.c
+++ b/coreutils/sleep.c
@@ -24,7 +24,11 @@
#include "internal.h"
#include <stdio.h>
-const char sleep_usage[] = "sleep N\n\n" "Pause for N seconds.\n";
+const char sleep_usage[] = "sleep N\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPause for N seconds.\n"
+#endif
+ ;
extern int sleep_main(int argc, char **argv)
{
diff --git a/coreutils/sort.c b/coreutils/sort.c
index 49eb4fd..1edc7d1 100644
--- a/coreutils/sort.c
+++ b/coreutils/sort.c
@@ -33,7 +33,11 @@ static const char sort_usage[] = "sort [-n]"
#ifdef BB_FEATURE_SORT_REVERSE
" [-r]"
#endif
-" [FILE]...\n\nSorts lines of text in the specified files\n";
+" [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+"\nSorts lines of text in the specified files\n"
+#endif
+;
#ifdef BB_FEATURE_SORT_REVERSE
#define APPLY_REVERSE(x) (reverse ? -(x) : (x))
@@ -300,4 +304,4 @@ int sort_main(int argc, char **argv)
exit(0);
}
-/* $Id: sort.c,v 1.15 2000/04/17 04:22:09 beppu Exp $ */
+/* $Id: sort.c,v 1.16 2000/05/12 19:41:47 erik Exp $ */
diff --git a/coreutils/sync.c b/coreutils/sync.c
index f8160c8..33c7922 100644
--- a/coreutils/sync.c
+++ b/coreutils/sync.c
@@ -27,7 +27,11 @@
extern int sync_main(int argc, char **argv)
{
if (argc > 1 && **(argv + 1) == '-') {
- usage("sync\n\nWrite all buffered filesystem blocks to disk.\n");
+ usage("sync\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nWrite all buffered filesystem blocks to disk.\n"
+#endif
+ );
}
exit(sync());
}
diff --git a/coreutils/tail.c b/coreutils/tail.c
index 321c5c4..3b3e2f5 100644
--- a/coreutils/tail.c
+++ b/coreutils/tail.c
@@ -47,6 +47,9 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <ctype.h>
+#define BB_DECLARE_EXTERN
+#define bb_need_help
+#include "messages.c"
#define XWRITE(fd, buffer, n_bytes) \
@@ -70,15 +73,18 @@ static int forever;
static int print_headers;
const char tail_usage[] =
- "tail [OPTION] [FILE]...\n\n"
- "Print last 10 lines of each FILE to standard output.\n"
+ "tail [OPTION] [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrint last 10 lines of each FILE to standard output.\n"
"With more than one FILE, precede each with a header giving the\n"
"file name. With no FILE, or when FILE is -, read standard input.\n\n"
"Options:\n"
"\t-n NUM\t\tPrint last NUM lines instead of first 10\n"
"\t-f\t\tOutput data as the file grows. This version\n"
- "\t\t\tof 'tail -f' supports only one file at a time.\n";
+ "\t\t\tof 'tail -f' supports only one file at a time.\n"
+#endif
+ ;
static void write_header(const char *filename)
@@ -512,9 +518,9 @@ char *program_name;
static int have_read_stdin;
-static const char tail_usage[] = "tail [OPTION]... [FILE]...\n\
-\n\
-Print last 10 lines of each FILE to standard output.\n\
+static const char tail_usage[] = "tail [OPTION]... [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+"\nPrint last 10 lines of each FILE to standard output.\n\
With more than one FILE, precede each with a header giving the file name.\n\
With no FILE, or when FILE is -, read standard input.\n\
\n\
@@ -523,11 +529,12 @@ With no FILE, or when FILE is -, read standard input.\n\
-n=N output the last N lines, instead of last 10\n\
-q never output headers giving file names\n\
-v always output headers giving file names\n\
- --help display this help and exit\n\
\n\
If the first character of N (bytes or lines) is a `+', output begins with \n\
the Nth item from the start of each file, otherwise, print the last N items\n\
-in the file. N bytes may be suffixed by k (x1024), b (x512), or m (1024^2).\n\n";
+in the file. N bytes may be suffixed by k (x1024), b (x512), or m (1024^2).\n"
+#endif
+;
static void write_header(const char *filename, const char *comment)
{
diff --git a/coreutils/tee.c b/coreutils/tee.c
index 95b75ed..a78edc0 100644
--- a/coreutils/tee.c
+++ b/coreutils/tee.c
@@ -27,12 +27,14 @@
#include <stdio.h>
static const char tee_usage[] =
- "tee [OPTION]... [FILE]...\n\n"
- "Copy standard input to each FILE, and also to standard output.\n\n"
+ "tee [OPTION]... [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCopy standard input to each FILE, and also to standard output.\n\n"
"Options:\n" "\t-a\tappend to the given FILEs, do not overwrite\n"
#if 0
"\t-i\tignore interrupt signals\n"
#endif
+#endif
;
@@ -131,4 +133,4 @@ int tee_main(int argc, char **argv)
exit(0);
}
-/* $Id: tee.c,v 1.9 2000/04/13 01:18:56 erik Exp $ */
+/* $Id: tee.c,v 1.10 2000/05/12 19:41:47 erik Exp $ */
diff --git a/coreutils/test.c b/coreutils/test.c
index 0ed7771..9b541e3 100644
--- a/coreutils/test.c
+++ b/coreutils/test.c
@@ -39,6 +39,9 @@
#include <errno.h>
#include <stdlib.h>
#include <string.h>
+#define BB_DECLARE_EXTERN
+#define bb_need_help
+#include "messages.c"
/* test(1) accepts the following grammar:
oexpr ::= aexpr | aexpr "-o" oexpr ;
@@ -185,11 +188,14 @@ test_main(int argc, char** argv)
fatalError("missing ]");
argv[argc] = NULL;
}
- if (strcmp(argv[1], "--help") == 0) {
+ if (strcmp(argv[1], dash_dash_help) == 0) {
usage("test EXPRESSION\n"
- "or [ EXPRESSION ]\n\n"
- "Checks file types and compares values returning an exit\n"
- "code determined by the value of EXPRESSION.\n");
+ "or [ EXPRESSION ]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nChecks file types and compares values returning an exit\n"
+ "code determined by the value of EXPRESSION.\n"
+#endif
+ );
}
/* Implement special cases from POSIX.2, section 4.62.4 */
diff --git a/coreutils/touch.c b/coreutils/touch.c
index f8972dc..2076928 100644
--- a/coreutils/touch.c
+++ b/coreutils/touch.c
@@ -31,9 +31,11 @@
#include <errno.h>
-static const char touch_usage[] = "touch [-c] file [file ...]\n\n"
-
- "Update the last-modified date on the given file[s].\n";
+static const char touch_usage[] = "touch [-c] file [file ...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nUpdate the last-modified date on the given file[s].\n"
+#endif
+ ;
diff --git a/coreutils/tty.c b/coreutils/tty.c
index 6f98d1b..3a318eb 100644
--- a/coreutils/tty.c
+++ b/coreutils/tty.c
@@ -24,10 +24,13 @@
#include <stdio.h>
#include <sys/types.h>
-static const char tty_usage[] = "tty\n\n"
- "Print the file name of the terminal connected to standard input.\n\n"
+static const char tty_usage[] = "tty\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrint the file name of the terminal connected to standard input.\n\n"
"Options:\n"
- "\t-s\tprint nothing, only return an exit status\n";
+ "\t-s\tprint nothing, only return an exit status\n"
+#endif
+ ;
extern int tty_main(int argc, char **argv)
{
diff --git a/coreutils/uniq.c b/coreutils/uniq.c
index 0324856..0cccbd5 100644
--- a/coreutils/uniq.c
+++ b/coreutils/uniq.c
@@ -28,9 +28,12 @@
#include <errno.h>
static const char uniq_usage[] =
- "uniq [OPTION]... [INPUT [OUTPUT]]\n\n"
- "Discard all but one of successive identical lines from INPUT\n"
- "(or standard input), writing to OUTPUT (or standard output).\n";
+ "uniq [OPTION]... [INPUT [OUTPUT]]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nDiscard all but one of successive identical lines from INPUT\n"
+ "(or standard input), writing to OUTPUT (or standard output).\n"
+#endif
+ ;
/* max chars in line */
#define UNIQ_MAX 4096
@@ -184,4 +187,4 @@ int uniq_main(int argc, char **argv)
exit(0);
}
-/* $Id: uniq.c,v 1.9 2000/04/17 16:16:10 erik Exp $ */
+/* $Id: uniq.c,v 1.10 2000/05/12 19:41:47 erik Exp $ */
diff --git a/coreutils/usleep.c b/coreutils/usleep.c
index dcb40d6..34008a6 100644
--- a/coreutils/usleep.c
+++ b/coreutils/usleep.c
@@ -25,7 +25,11 @@
#include <stdlib.h>
#include <unistd.h>
-const char usleep_usage[] = "usleep N\n\n" "Pause for N microseconds.\n";
+const char usleep_usage[] = "usleep N\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPause for N microseconds.\n"
+#endif
+ ;
extern int usleep_main(int argc, char **argv)
{
diff --git a/coreutils/wc.c b/coreutils/wc.c
index 030afa9..57bc713 100644
--- a/coreutils/wc.c
+++ b/coreutils/wc.c
@@ -23,15 +23,18 @@
#include "internal.h"
#include <stdio.h>
-static const char wc_usage[] = "wc [OPTION]... [FILE]...\n\n"
- "Print line, word, and byte counts for each FILE, and a total line if\n"
+static const char wc_usage[] = "wc [OPTION]... [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrint line, word, and byte counts for each FILE, and a total line if\n"
"more than one FILE is specified. With no FILE, read standard input.\n\n"
"Options:\n"
"\t-c\tprint the byte counts\n"
"\t-l\tprint the newline counts\n"
"\t-L\tprint the length of the longest line\n"
- "\t-w\tprint the word counts\n";
+ "\t-w\tprint the word counts\n"
+#endif
+ ;
static int total_lines, total_words, total_chars, max_length;
static int print_lines, print_words, print_chars, print_length;
diff --git a/coreutils/whoami.c b/coreutils/whoami.c
index f9d3f28..da58479 100644
--- a/coreutils/whoami.c
+++ b/coreutils/whoami.c
@@ -24,8 +24,11 @@
#include <stdio.h>
#include <pwd.h>
-static const char whoami_usage[] = "whoami\n\n"
- "Prints the user name associated with the current effective user id.\n";
+static const char whoami_usage[] = "whoami\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrints the user name associated with the current effective user id.\n"
+#endif
+ ;
extern int whoami_main(int argc, char **argv)
{
diff --git a/coreutils/yes.c b/coreutils/yes.c
index a822ebc..97b6f65 100644
--- a/coreutils/yes.c
+++ b/coreutils/yes.c
@@ -28,8 +28,11 @@ extern int yes_main(int argc, char **argv)
int i;
if (argc >=1 && *argv[1]=='-') {
- usage("yes [OPTION]... [STRING]...\n\n"
- "Repeatedly outputs a line with all specified STRING(s), or `y'.\n");
+ usage("yes [OPTION]... [STRING]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nRepeatedly outputs a line with all specified STRING(s), or `y'.\n"
+#endif
+ );
}
if (argc == 1) {
diff --git a/cut.c b/cut.c
new file mode 100644
index 0000000..89a934e
--- /dev/null
+++ b/cut.c
@@ -0,0 +1,372 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * cut implementation for busybox
+ *
+ * Copyright (c) Michael J. Holme
+ *
+ * This version of cut is adapted from Minix cut and was modified
+ * by Erik Andersen <andersee@debian.org> to be used in busybox.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Original copyright notice is retained at the end of this file.
+ */
+
+#include "internal.h"
+#include <sys/types.h>
+#include <ctype.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#define BB_DECLARE_EXTERN
+#define bb_need_help
+#include "messages.c"
+
+#define MAX_FIELD 80 /* Pointers to the beginning of each field
+ * are stored in columns[], if a line holds
+ * more than MAX_FIELD columns the array
+ * boundary is exceed. But unlikely at 80 */
+
+#define MAX_ARGS 32 /* Maximum number of fields following -f or
+ * -c switches */
+int args[MAX_ARGS * 2];
+int num_args;
+
+/* Lots of new defines, should easen maintainance... */
+#define DUMP_STDIN 0 /* define for mode: no options */
+#define OPTIONF 1 /* define for mode: option -f */
+#define OPTIONC 2 /* define for mode: option -c */
+#define OPTIONB 3 /* define for mode: option -b */
+#define NOTSET 0 /* option not selected */
+#define SET 1 /* option selected */
+
+/* Defines for the warnings */
+#define DELIMITER_NOT_APPLICABLE 0
+#define OVERRIDING_PREVIOUS_MODE 1
+#define OPTION_NOT_APPLICABLE 2
+#define UNKNOWN_OPTION 3
+#define FILE_NOT_READABLE 4
+
+/* Defines for the fatal errors */
+#define SYNTAX_ERROR 101
+#define POSITION_ERROR 102
+#define LINE_TO_LONG_ERROR 103
+#define RANGE_ERROR 104
+#define MAX_FIELDS_EXEEDED_ERROR 105
+#define MAX_ARGS_EXEEDED_ERROR 106
+
+
+int mode; /* 0 = dump stdin to stdout, 1=-f, 2=-c */
+char delim = '\t'; /* default delimiting character */
+FILE *fd;
+char *name;
+char line[BUFSIZ];
+int exit_status;
+
+int cut_main(int argc, char **argv);
+void warn(int warn_number, char *option);
+void cuterror(int err);
+void get_args(void);
+void cut(void);
+
+void warn(int warn_number, char *option)
+{
+ static char *warn_msg[] = {
+ "%s: Option -d allowed only with -f\n",
+ "%s: -%s overrides earlier option\n",
+ "%s: -%s not allowed in current mode\n",
+ "%s: Cannot open %s\n"
+ };
+
+ fprintf(stderr, warn_msg[warn_number], name, option);
+ exit_status = warn_number + 1;
+
+}
+
+void cuterror(int err)
+{
+ static char *err_mes[] = {
+ "%s: syntax error\n",
+ "%s: position must be >0\n",
+ "%s: line longer than BUFSIZ\n",
+ "%s: range must not decrease from left to right\n",
+ "%s: MAX_FIELD exceeded\n",
+ "%s: MAX_ARGS exceeded\n"
+ };
+
+ fprintf(stderr, err_mes[err - 101], name);
+ exit(err);
+}
+
+
+void get_args()
+{
+ int i = 0;
+ int arg_ptr = 0;
+ int flag;
+
+ num_args = 0;
+ do {
+ if (num_args == MAX_ARGS)
+ cuterror(MAX_ARGS_EXEEDED_ERROR);
+ if (!isdigit(line[i]) && line[i] != '-')
+ cuterror(SYNTAX_ERROR);
+
+ args[arg_ptr] = 1;
+ args[arg_ptr + 1] = BUFSIZ;
+ flag = 1;
+
+ while (line[i] != ',' && line[i] != 0) {
+ if (isdigit(line[i])) {
+ args[arg_ptr] = 0;
+ while (isdigit(line[i]))
+ args[arg_ptr] = 10 * args[arg_ptr] + line[i++] - '0';
+ if (!args[arg_ptr])
+ cuterror(POSITION_ERROR);
+ arg_ptr++;
+ }
+ if (line[i] == '-') {
+ arg_ptr |= 1;
+ i++;
+ flag = 0;
+ }
+ }
+ if (flag && arg_ptr & 1)
+ args[arg_ptr] = args[arg_ptr - 1];
+ if (args[num_args * 2] > args[num_args * 2 + 1])
+ cuterror(RANGE_ERROR);
+ num_args++;
+ arg_ptr = num_args * 2;
+ }
+ while (line[i++]);
+}
+
+
+void cut()
+{
+ int i, j, length, maxcol=0;
+ char *columns[MAX_FIELD];
+
+ while (fgets(line, BUFSIZ, fd)) {
+ length = strlen(line) - 1;
+ *(line + length) = 0;
+ switch (mode) {
+ case DUMP_STDIN:
+ printf("%s", line);
+ break;
+ case OPTIONF:
+ columns[maxcol++] = line;
+ for (i = 0; i < length; i++) {
+ if (*(line + i) == delim) {
+ *(line + i) = 0;
+ if (maxcol == MAX_FIELD)
+ cuterror(MAX_FIELDS_EXEEDED_ERROR);
+ columns[maxcol] = line + i + 1;
+ maxcol++;
+ }
+ }
+ if (maxcol != 1) {
+ for (i = 0; i < num_args; i++) {
+ for (j = args[i * 2]; j <= args[i * 2 + 1]; j++)
+ if (j <= maxcol) {
+ printf("%s", columns[j - 1]);
+ if (i != num_args - 1 || j != args[i * 2 + 1])
+ putchar(delim);
+ }
+ }
+ }
+ break;
+ case OPTIONC:
+ for (i = 0; i < num_args; i++) {
+ for (j = args[i * 2];
+ j <= (args[i * 2 + 1] >
+ length ? length : args[i * 2 + 1]); j++)
+ putchar(*(line + j - 1));
+ }
+ }
+ if (maxcol != 1)
+ putchar('\n');
+ }
+}
+
+
+int cut_main(int argc, char **argv)
+{
+ int i = 1;
+ int numberFilenames = 0;
+
+ name = argv[0];
+
+ if (argc == 1 || strcmp(argv[1], dash_dash_help)==0)
+ usage( "cut [OPTION]... [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrints selected fields from each input FILE to standard output.\n\n"
+ "Options:\n"
+ "\t-b LIST\tOutput only bytes from LIST\n"
+ "\t-c LIST\tOutput only characters from LIST\n"
+ "\t-d DELIM\tUse DELIM instead of tab as the field delimiter\n"
+ "\t-f N\tPrint only these fields\n"
+ "\t-n\tIgnored\n"
+#endif
+ );
+
+ while (i < argc) {
+ if (argv[i][0] == '-') {
+ switch (argv[i++][1]) {
+ case 'd':
+ if (mode == OPTIONC || mode == OPTIONB)
+ warn(DELIMITER_NOT_APPLICABLE, "d");
+ delim = argv[i++][0];
+ break;
+ case 'f':
+ sprintf(line, "%s", argv[i++]);
+ if (mode == OPTIONC || mode == OPTIONB)
+ warn(OVERRIDING_PREVIOUS_MODE, "f");
+ mode = OPTIONF;
+ break;
+ case 'b':
+ sprintf(line, "%s", argv[i++]);
+ if (mode == OPTIONF || mode == OPTIONC)
+ warn(OVERRIDING_PREVIOUS_MODE, "b");
+ mode = OPTIONB;
+ break;
+ case 'c':
+ sprintf(line, "%s", argv[i++]);
+ if (mode == OPTIONF || mode == OPTIONB)
+ warn(OVERRIDING_PREVIOUS_MODE, "c");
+ mode = OPTIONC;
+ break;
+ case '\0': /* - means: read from stdin */
+ numberFilenames++;
+ break;
+ case 'n': /* needed for Posix, but no effect here */
+ if (mode != OPTIONB)
+ warn(OPTION_NOT_APPLICABLE, "n");
+ break;
+ default:
+ warn(UNKNOWN_OPTION, &(argv[i - 1][1]));
+ }
+ } else {
+ i++;
+ numberFilenames++;
+ }
+ }
+
+/* Here follow the checks, if the selected options are reasonable. */
+ if (mode == OPTIONB) /* since in Minix char := byte */
+ mode = OPTIONC;
+ get_args();
+ if (numberFilenames != 0) {
+ i = 1;
+ while (i < argc) {
+ if (argv[i][0] == '-') {
+ switch (argv[i][1]) {
+ case 'f':
+ case 'c':
+ case 'b':
+ case 'd':
+ i += 2;
+ break;
+ case 'n':
+ case 'i':
+ case 's':
+ i++;
+ break;
+ case '\0':
+ fd = stdin;
+ i++;
+ cut();
+ break;
+ default:
+ i++;
+ }
+ } else {
+ if ((fd = fopen(argv[i++], "r")) == NULL) {
+ warn(FILE_NOT_READABLE, argv[i - 1]);
+ } else {
+ cut();
+ fclose(fd);
+ }
+ }
+ }
+ } else {
+ fd = stdin;
+ cut();
+ }
+
+ exit(exit_status);
+}
+
+/* cut - extract columns from a file or stdin. Author: Michael J. Holme
+ *
+ * Copyright 1989, Michael John Holme, All rights reserved.
+ * This code may be freely distributed, provided that this notice
+ * remains intact.
+ *
+ * V1.1: 6th September 1989
+ *
+ * Bugs, criticisms, etc,
+ * c/o Mark Powell
+ * JANET sq79@uk.ac.liv
+ * ARPA sq79%liv.ac.uk@nsfnet-relay.ac.uk
+ * UUCP ...!mcvax!ukc!liv.ac.uk!sq79
+ *-------------------------------------------------------------------------
+ * Changed for POSIX1003.2/Draft10 conformance
+ * Thomas Brupbacher (tobr@mw.lpc.ethz.ch), September 1990.
+ * Changes:
+ * - separation of error messages ( stderr) and output (stdout).
+ * - support for -b and -n (no effect, -b acts as -c)
+ * - support for -s
+ *-------------------------------------------------------------------------
+ */
+
+/*
+ * Copyright (c) 1987,1997, Prentice Hall
+ * All rights reserved.
+ *
+ * Redistribution and use of the MINIX operating system in source and
+ * binary forms, with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * Neither the name of Prentice Hall nor the names of the software
+ * authors or contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS, AUTHORS, AND
+ * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL PRENTICE HALL OR ANY AUTHORS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+
diff --git a/docs/busybox.pod b/docs/busybox.pod
index ea14459..408bbfa 100644
--- a/docs/busybox.pod
+++ b/docs/busybox.pod
@@ -488,7 +488,7 @@ Example:
Usage: free
-Displays the amount of free and used memory in the system.
+Displays the amount of free and used system memory.
Example:
@@ -504,7 +504,7 @@ Example:
Usage: freeramdisk DEVICE
-Free all memory used by the specified ramdisk.
+Frees all memory used by the specified ramdisk.
Example:
@@ -799,9 +799,9 @@ Example:
=item length
-Usage: length string
+Usage: length STRING
-Prints out the length of the specified string.
+Prints out the length of the specified STRING.
Example:
@@ -1120,7 +1120,7 @@ Flags:
-t fs-type: Specify the filesystem type.
-w: Mount for reading and writing (default).
-Options for use with the "-o" flag:
+Options for use with the "B<-o>" flag:
async/sync: Writes are asynchronous / synchronous.
atime/noatime: Enable / disable updates to inode access times.
@@ -1881,4 +1881,4 @@ Enrique Zanardi <ezanardi@ull.es>
=cut
-# $Id: busybox.pod,v 1.29 2000/05/10 05:00:31 erik Exp $
+# $Id: busybox.pod,v 1.30 2000/05/12 19:41:47 erik Exp $
diff --git a/editors/sed.c b/editors/sed.c
index 0d57a4a..9fed670 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -38,8 +38,9 @@
#include <ctype.h>
static const char sed_usage[] =
- "sed [-n] -e script [file...]\n\n"
- "Allowed sed scripts come in the following form:\n"
+ "sed [-n] -e script [file...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nAllowed sed scripts come in the following form:\n"
"\t'ADDR [!] COMMAND'\n\n"
"\twhere address ADDR can be:\n"
"\t NUMBER Match specified line number\n"
@@ -58,8 +59,10 @@ static const char sed_usage[] =
#if defined BB_REGEXP
"This version of sed matches full regular expresions.\n";
#else
- "This version of sed matches strings (not full regular expresions).\n";
+ "This version of sed matches strings (not full regular expresions).\n"
#endif
+#endif
+ ;
/* Flags & variables */
diff --git a/fbset.c b/fbset.c
index 4e5609e..de4c824 100644
--- a/fbset.c
+++ b/fbset.c
@@ -105,9 +105,9 @@ struct cmdoptions_t {
"-vsync", 1, CMD_VSYNC}, {
"-laced", 1, CMD_LACED}, {
"-double", 1, CMD_DOUBLE}, {
- "--help", 0, CMD_HELP}, {
+ "-help", 0, CMD_HELP}, {
#ifdef BB_FEATURE_FBSET_FANCY
- "--help", 0, CMD_HELP}, {
+ "-help", 0, CMD_HELP}, {
"-all", 0, CMD_ALL}, {
"-xres", 1, CMD_XRES}, {
"-yres", 1, CMD_YRES}, {
@@ -115,7 +115,7 @@ struct cmdoptions_t {
"-vyres", 1, CMD_VYRES}, {
"-depth", 1, CMD_DEPTH}, {
"-match", 0, CMD_MATCH}, {
- "--geometry", 5, CMD_GEOMETRY}, {
+ "-geometry", 5, CMD_GEOMETRY}, {
"-pixclock", 1, CMD_PIXCLOCK}, {
"-left", 1, CMD_LEFT}, {
"-right", 1, CMD_RIGHT}, {
@@ -123,7 +123,7 @@ struct cmdoptions_t {
"-lower", 1, CMD_LOWER}, {
"-hslen", 1, CMD_HSLEN}, {
"-vslen", 1, CMD_VSLEN}, {
- "--timings", 7, CMD_TIMING}, {
+ "-timings", 7, CMD_TIMING}, {
"-csync", 1, CMD_CSYNC}, {
"-gsync", 1, CMD_GSYNC}, {
"-extsync", 1, CMD_EXTSYNC}, {
@@ -221,17 +221,21 @@ static void showmode(struct fb_var_screeninfo *v)
static void fbset_usage(void)
{
+#ifndef BB_FEATURE_TRIVIAL_HELP
int i;
+#endif
#ifndef STANDALONE
fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n",
BB_VER, BB_BT);
#endif
- fprintf(stderr, "Usage: fbset [options] [mode]\n\n");
- fprintf(stderr, "Show and modify frame buffer device settings\n\n");
+ fprintf(stderr, "Usage: fbset [options] [mode]\n");
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ fprintf(stderr, "\nShows and modifies frame buffer device settings\n\n");
fprintf(stderr, "The following options are recognized:\n");
for (i = 0; g_cmdoptions[i].name; i++)
fprintf(stderr, "\t%s\n", g_cmdoptions[i].name);
+#endif
exit(-1);
}
diff --git a/fdflush.c b/fdflush.c
index 56ea224..4ec0a88 100644
--- a/fdflush.c
+++ b/fdflush.c
@@ -34,7 +34,11 @@ extern int fdflush_main(int argc, char **argv)
int fd;
if (argc <= 1 || **(++argv) == '-') {
- usage("fdflush device\n\nForce floppy disk drive to detect disk change\n");
+ usage("fdflush DEVICE\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nForces floppy disk drive to detect disk change\n"
+#endif
+ );
}
fd = open(*argv, 0);
diff --git a/find.c b/find.c
index f6e63af..53b85e6 100644
--- a/find.c
+++ b/find.c
@@ -33,13 +33,16 @@ static char *pattern = NULL;
static char *directory = ".";
static int dereferenceFlag = FALSE;
-static const char find_usage[] = "find [PATH...] [EXPRESSION]\n\n"
- "Search for files in a directory hierarchy. The default PATH is\n"
+static const char find_usage[] = "find [PATH...] [EXPRESSION]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nSearch for files in a directory hierarchy. The default PATH is\n"
"the current directory; default EXPRESSION is '-print'\n\n"
"\nEXPRESSION may consist of:\n"
"\t-follow\t\tDereference symbolic links.\n"
"\t-name PATTERN\tFile name (leading directories removed) matches PATTERN.\n"
- "\t-print\t\tprint the full file name followed by a newline to stdout.\n";
+ "\t-print\t\tprint the full file name followed by a newline to stdout.\n"
+#endif
+ ;
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
diff --git a/findutils/find.c b/findutils/find.c
index f6e63af..53b85e6 100644
--- a/findutils/find.c
+++ b/findutils/find.c
@@ -33,13 +33,16 @@ static char *pattern = NULL;
static char *directory = ".";
static int dereferenceFlag = FALSE;
-static const char find_usage[] = "find [PATH...] [EXPRESSION]\n\n"
- "Search for files in a directory hierarchy. The default PATH is\n"
+static const char find_usage[] = "find [PATH...] [EXPRESSION]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nSearch for files in a directory hierarchy. The default PATH is\n"
"the current directory; default EXPRESSION is '-print'\n\n"
"\nEXPRESSION may consist of:\n"
"\t-follow\t\tDereference symbolic links.\n"
"\t-name PATTERN\tFile name (leading directories removed) matches PATTERN.\n"
- "\t-print\t\tprint the full file name followed by a newline to stdout.\n";
+ "\t-print\t\tprint the full file name followed by a newline to stdout.\n"
+#endif
+ ;
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
diff --git a/findutils/grep.c b/findutils/grep.c
index 06b6980..6872ac2 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -41,8 +41,9 @@
#include <ctype.h>
static const char grep_usage[] =
- "grep [OPTIONS]... PATTERN [FILE]...\n\n"
- "Search for PATTERN in each FILE or standard input.\n\n"
+ "grep [OPTIONS]... PATTERN [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nSearch for PATTERN in each FILE or standard input.\n\n"
"OPTIONS:\n"
"\t-h\tsuppress the prefixing filename on output\n"
"\t-i\tignore case distinctions\n"
@@ -52,8 +53,10 @@ static const char grep_usage[] =
#if defined BB_REGEXP
"This version of grep matches full regular expresions.\n";
#else
- "This version of grep matches strings (not regular expresions).\n";
+ "This version of grep matches strings (not regular expresions).\n"
#endif
+#endif
+ ;
static int match = FALSE, beQuiet = FALSE;
diff --git a/free.c b/free.c
index 39594db..e6f130e 100644
--- a/free.c
+++ b/free.c
@@ -37,6 +37,14 @@ extern int free_main(int argc, char **argv)
info.sharedram/=DIVISOR;
info.bufferram/=DIVISOR;
+ if (argc > 1 && **(argv + 1) == '-') {
+ usage("free\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nDisplays the amount of free and used system memory\n"
+#endif
+ );
+ }
+
printf("%6s%13s%13s%13s%13s%13s\n", "", "total", "used", "free",
"shared", "buffers");
diff --git a/freeramdisk.c b/freeramdisk.c
index d373bcb..4106cf1 100644
--- a/freeramdisk.c
+++ b/freeramdisk.c
@@ -34,8 +34,11 @@
static const char freeramdisk_usage[] =
- "freeramdisk DEVICE\n\n"
- "Free all memory used by the specified ramdisk.\n";
+ "freeramdisk DEVICE\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nFrees all memory used by the specified ramdisk.\n"
+#endif
+ ;
extern int
freeramdisk_main(int argc, char **argv)
diff --git a/fsck_minix.c b/fsck_minix.c
index c890dff..7d27566 100644
--- a/fsck_minix.c
+++ b/fsck_minix.c
@@ -198,9 +198,10 @@ static void show_usage(void)
{
fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n",
BB_VER, BB_BT);
- fprintf(stderr, "Usage: %s [-larvsmf] /dev/name\n\n", program_name);
+ fprintf(stderr, "Usage: %s [-larvsmf] /dev/name\n", program_name);
+#ifndef BB_FEATURE_TRIVIAL_HELP
fprintf(stderr,
- "Performs a consistency check for MINIX filesystems.\n\n");
+ "\nPerforms a consistency check for MINIX filesystems.\n\n");
fprintf(stderr, "OPTIONS:\n");
fprintf(stderr, "\t-l\tLists all filenames\n");
fprintf(stderr, "\t-r\tPerform interactive repairs\n");
@@ -210,6 +211,7 @@ static void show_usage(void)
fprintf(stderr,
"\t-m\tActivates MINIX-like \"mode not cleared\" warnings\n");
fprintf(stderr, "\t-f\tForce file system check.\n\n");
+#endif
leave(16);
}
diff --git a/grep.c b/grep.c
index 06b6980..6872ac2 100644
--- a/grep.c
+++ b/grep.c
@@ -41,8 +41,9 @@
#include <ctype.h>
static const char grep_usage[] =
- "grep [OPTIONS]... PATTERN [FILE]...\n\n"
- "Search for PATTERN in each FILE or standard input.\n\n"
+ "grep [OPTIONS]... PATTERN [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nSearch for PATTERN in each FILE or standard input.\n\n"
"OPTIONS:\n"
"\t-h\tsuppress the prefixing filename on output\n"
"\t-i\tignore case distinctions\n"
@@ -52,8 +53,10 @@ static const char grep_usage[] =
#if defined BB_REGEXP
"This version of grep matches full regular expresions.\n";
#else
- "This version of grep matches strings (not regular expresions).\n";
+ "This version of grep matches strings (not regular expresions).\n"
#endif
+#endif
+ ;
static int match = FALSE, beQuiet = FALSE;
diff --git a/gunzip.c b/gunzip.c
index bdf8dc2..11fc3a8 100644
--- a/gunzip.c
+++ b/gunzip.c
@@ -28,13 +28,17 @@
*/
#include "internal.h"
+
static const char gunzip_usage[] =
- "gunzip [OPTION]... FILE\n\n"
- "Uncompress FILE (or standard input if FILE is '-').\n\n"
+ "gunzip [OPTION]... FILE\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nUncompress FILE (or standard input if FILE is '-').\n\n"
"Options:\n"
"\t-c\tWrite output to standard output\n"
- "\t-t\tTest compressed file integrity\n";
+ "\t-t\tTest compressed file integrity\n"
+#endif
+ ;
/* These defines are very important for BusyBox. Without these,
@@ -43,8 +47,9 @@ static const char gunzip_usage[] =
#define SMALL_MEM
#define DYN_ALLOC
-#define bb_need_name_too_long
#define BB_DECLARE_EXTERN
+#define bb_need_memory_exhausted
+#define bb_need_name_too_long
#include "messages.c"
@@ -206,7 +211,7 @@ extern int method; /* compression method */
# define DECLARE(type, array, size) type * array
# define ALLOC(type, array, size) { \
array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
- if (array == NULL) errorMsg("insufficient memory"); \
+ if (array == NULL) errorMsg(memory_exhausted, "gunzip"); \
}
# define FREE(array) {if (array != NULL) free(array), array=NULL;}
#else
@@ -1053,7 +1058,7 @@ int in, out; /* input and output file descriptors */
int res = inflate();
if (res == 3) {
- errorMsg("out of memory");
+ errorMsg(memory_exhausted, "gunzip");
} else if (res != 0) {
errorMsg("invalid compressed data--format violated");
}
diff --git a/gzip.c b/gzip.c
index cc6868b..17ebf6c 100644
--- a/gzip.c
+++ b/gzip.c
@@ -30,6 +30,9 @@
*/
#include "internal.h"
+#define BB_DECLARE_EXTERN
+#define bb_need_memory_exhausted
+#include "messages.c"
/* These defines are very important for BusyBox. Without these,
* huge chunks of ram are pre-allocated making the BusyBox bss
@@ -39,12 +42,15 @@
static const char gzip_usage[] =
- "gzip [OPTION]... FILE\n\n"
- "Compress FILE with maximum compression.\n"
+ "gzip [OPTION]... FILE\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCompress FILE with maximum compression.\n"
"When FILE is '-', reads standard input. Implies -c.\n\n"
"Options:\n"
- "\t-c\tWrite output to standard output instead of FILE.gz\n";
+ "\t-c\tWrite output to standard output instead of FILE.gz\n"
+#endif
+ ;
/* I don't like nested includes, but the string and io functions are used
@@ -121,7 +127,7 @@ extern int method; /* compression method */
# define DECLARE(type, array, size) type * array
# define ALLOC(type, array, size) { \
array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
- if (array == NULL) errorMsg("insufficient memory"); \
+ if (array == NULL) errorMsg(memory_exhausted, "gzip"); \
}
# define FREE(array) {if (array != NULL) free(array), array=NULL;}
#else
@@ -1778,7 +1784,6 @@ int part_nb; /* number of parts in .gz file */
long time_stamp; /* original time stamp (modification time) */
long ifile_size; /* input file size, -1 for devices (debug only) */
char *env; /* contents of GZIP env variable */
-char **args = NULL; /* argv pointer if GZIP env variable defined */
char z_suffix[MAX_SUFFIX + 1]; /* default suffix (can be set with --suffix) */
int z_len; /* strlen(z_suffix) */
@@ -3248,7 +3253,7 @@ char *env; /* name of environment variable */
nargv = (char **) calloc(*argcp + 1, sizeof(char *));
if (nargv == NULL)
- errorMsg("out of memory");
+ errorMsg(memory_exhausted, "gzip");
oargv = *argvp;
*argvp = nargv;
diff --git a/head.c b/head.c
index 3db64b3..f4ebe05 100644
--- a/head.c
+++ b/head.c
@@ -27,12 +27,15 @@
#include <stdio.h>
const char head_usage[] =
- "head [OPTION] [FILE]...\n\n"
- "Print first 10 lines of each FILE to standard output.\n"
+ "head [OPTION] [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrint first 10 lines of each FILE to standard output.\n"
"With more than one FILE, precede each with a header giving the\n"
"file name. With no FILE, or when FILE is -, read standard input.\n\n"
- "Options:\n" "\t-n NUM\t\tPrint first NUM lines instead of first 10\n";
+ "Options:\n" "\t-n NUM\t\tPrint first NUM lines instead of first 10\n"
+#endif
+ ;
int head(int len, FILE * src)
{
@@ -109,4 +112,4 @@ int head_main(int argc, char **argv)
exit(0);
}
-/* $Id: head.c,v 1.9 2000/04/13 01:18:56 erik Exp $ */
+/* $Id: head.c,v 1.10 2000/05/12 19:41:47 erik Exp $ */
diff --git a/hostname.c b/hostname.c
index 8cc334d..ef92102 100644
--- a/hostname.c
+++ b/hostname.c
@@ -1,6 +1,6 @@
/* vi: set sw=4 ts=4: */
/*
- * $Id: hostname.c,v 1.7 2000/02/08 19:58:47 erik Exp $
+ * $Id: hostname.c,v 1.8 2000/05/12 19:41:47 erik Exp $
* Mini hostname implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
@@ -31,15 +31,18 @@
#include <stdio.h>
static const char *hostname_usage =
- "hostname [OPTION] {hostname | -F file}\n\n"
- "Get or set the hostname or DNS domain name. If a hostname is given\n"
+ "hostname [OPTION] {hostname | -F file}\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nGet or set the hostname or DNS domain name. If a hostname is given\n"
"(or a file with the -F parameter), the host name will be set.\n\n"
"Options:\n"
"\t-s\t\tShort\n"
"\t-i\t\tAddresses for the hostname\n"
"\t-d\t\tDNS domain name\n"
- "\t-F FILE\t\tUse the contents of FILE to specify the hostname\n";
+ "\t-F FILE\t\tUse the contents of FILE to specify the hostname\n"
+#endif
+ ;
void do_sethostname(char *s, int isfile)
diff --git a/id.c b/id.c
index 8ded0e5..542f865 100644
--- a/id.c
+++ b/id.c
@@ -29,11 +29,14 @@
#include <sys/types.h>
static const char id_usage[] =
- "id [OPTIONS]... [USERNAME]\n\n"
- "Print information for USERNAME or the current user\n\n"
+ "id [OPTIONS]... [USERNAME]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrint information for USERNAME or the current user\n\n"
"\t-g\tprints only the group ID\n"
"\t-u\tprints only the user ID\n"
- "\t-r\tprints the real user ID instead of the effective ID (with -ug)\n\n";
+ "\t-r\tprints the real user ID instead of the effective ID (with -ug)\n\n"
+#endif
+ ;
extern int id_main(int argc, char **argv)
{
diff --git a/insmod.c b/insmod.c
index eafec7d..9d473ca 100644
--- a/insmod.c
+++ b/insmod.c
@@ -70,12 +70,15 @@ _syscall2(unsigned long, create_module, const char *, name, size_t, size)
static char m_filename[BUFSIZ + 1] = "\0";
static char m_fullName[BUFSIZ + 1] = "\0";
static const char insmod_usage[] =
- "insmod [OPTION]... MODULE [symbol=value]...\n\n"
- "Loads the specified kernel modules into the kernel.\n\n"
+ "insmod [OPTION]... MODULE [symbol=value]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nLoads the specified kernel modules into the kernel.\n\n"
"Options:\n"
"\t-f\tForce module to load into the wrong kernel version.\n"
- "\t-k\tMake module autoclean-able.\n";
+ "\t-k\tMake module autoclean-able.\n"
+#endif
+ ;
static int findNamedModule(const char *fileName, struct stat *statbuf)
diff --git a/internal.h b/internal.h
index a401477..a953ce2 100644
--- a/internal.h
+++ b/internal.h
@@ -100,11 +100,12 @@ extern int basename_main(int argc, char **argv);
extern int busybox_main(int argc, char** argv);
extern int block_device_main(int argc, char** argv);
extern int cat_main(int argc, char** argv);
-extern int cp_mv_main(int argc, char** argv);
extern int chmod_chown_chgrp_main(int argc, char** argv);
extern int chroot_main(int argc, char** argv);
extern int chvt_main(int argc, char** argv);
extern int clear_main(int argc, char** argv);
+extern int cp_mv_main(int argc, char** argv);
+extern int cut_main(int argc, char** argv);
extern int date_main(int argc, char** argv);
extern int dd_main(int argc, char** argv);
extern int dirname_main(int argc, char** argv);
@@ -151,7 +152,7 @@ extern int mkfs_minix_main(int argc, char **argv);
extern int mknod_main(int argc, char** argv);
extern int mkswap_main(int argc, char** argv);
extern int mktemp_main(int argc, char **argv);
-extern int mnc_main(int argc, char** argv);
+extern int nc_main(int argc, char** argv);
extern int more_main(int argc, char** argv);
extern int mount_main(int argc, char** argv);
extern int mt_main(int argc, char** argv);
diff --git a/kill.c b/kill.c
index 93f02ea..0487f6a 100644
--- a/kill.c
+++ b/kill.c
@@ -32,16 +32,22 @@
#include <unistd.h>
static const char *kill_usage =
- "kill [-signal] process-id [process-id ...]\n\n"
- "Send a signal (default is SIGTERM) to the specified process(es).\n\n"
- "Options:\n" "\t-l\tList all signal names and numbers.\n\n";
+ "kill [-signal] process-id [process-id ...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nSend a signal (default is SIGTERM) to the specified process(es).\n\n"
+ "Options:\n" "\t-l\tList all signal names and numbers.\n\n"
+#endif
+ ;
#ifdef BB_KILLALL
static const char *killall_usage =
- "killall [-signal] process-name [process-name ...]\n\n"
- "Send a signal (default is SIGTERM) to the specified process(es).\n\n"
- "Options:\n" "\t-l\tList all signal names and numbers.\n\n";
+ "killall [-signal] process-name [process-name ...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nSend a signal (default is SIGTERM) to the specified process(es).\n\n"
+ "Options:\n" "\t-l\tList all signal names and numbers.\n\n"
+#endif
#endif
+ ;
#define KILL 0
#define KILLALL 1
diff --git a/lash.c b/lash.c
index b96b464..e446ad1 100644
--- a/lash.c
+++ b/lash.c
@@ -127,8 +127,11 @@ static struct builtInCommand bltins[] = {
static const char shell_usage[] =
- "sh [FILE]...\n\n" "The BusyBox command interpreter (shell).\n\n";
-
+ "sh [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nlash: The BusyBox command interpreter (shell).\n\n"
+#endif
+ ;
static char cwd[1024];
static char *prompt = "# ";
diff --git a/length.c b/length.c
index 4cbe7e1..c7df216 100644
--- a/length.c
+++ b/length.c
@@ -7,7 +7,11 @@
extern int length_main(int argc, char **argv)
{
if (argc != 2 || **(argv + 1) == '-') {
- usage("length string\n");
+ usage("length STRING\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrints out the length of the specified STRING.\n"
+#endif
+ );
}
printf("%lu\n", (long)strlen(argv[1]));
return (TRUE);
diff --git a/ln.c b/ln.c
index eb7c996..29ff938 100644
--- a/ln.c
+++ b/ln.c
@@ -32,13 +32,16 @@
#include <errno.h>
static const char ln_usage[] =
- "ln [OPTION] TARGET... LINK_NAME|DIRECTORY\n\n"
- "Create a link named LINK_NAME or DIRECTORY to the specified TARGET\n\n"
+ "ln [OPTION] TARGET... LINK_NAME|DIRECTORY\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCreate a link named LINK_NAME or DIRECTORY to the specified TARGET\n\n"
"Options:\n"
"\t-s\tmake symbolic links instead of hard links\n"
"\t-f\tremove existing destination files\n"
- "\t-n\tno dereference symlinks - treat like normal file\n";
+ "\t-n\tno dereference symlinks - treat like normal file\n"
+#endif
+ ;
static int symlinkFlag = FALSE;
static int removeoldFlag = FALSE;
diff --git a/loadacm.c b/loadacm.c
index 8f69234..cca5406 100644
--- a/loadacm.c
+++ b/loadacm.c
@@ -22,8 +22,11 @@
#include <sys/ioctl.h>
#include <sys/kd.h>
-static const char loadacm_usage[] = "loadacm\n\n"
- "Loads an acm from standard input.\n";
+static const char loadacm_usage[] = "loadacm\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nLoads an acm from standard input.\n"
+#endif
+ ;
typedef unsigned short unicode;
diff --git a/loadfont.c b/loadfont.c
index 5e1f04d..7eaf40e 100644
--- a/loadfont.c
+++ b/loadfont.c
@@ -30,8 +30,11 @@
#define PSF_MAXMODE 0x03
#define PSF_SEPARATOR 0xFFFF
-static const char loadfont_usage[] = "loadfont\n\n"
- "Loads a console font from standard input.\n";
+static const char loadfont_usage[] = "loadfont\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "Loads a console font from standard input.\n"
+#endif
+ ;
struct psf_header {
unsigned char magic1, magic2; /* Magic number */
diff --git a/loadkmap.c b/loadkmap.c
index 75e52e1..99efc51 100644
--- a/loadkmap.c
+++ b/loadkmap.c
@@ -29,8 +29,11 @@
#include <sys/ioctl.h>
-static const char loadkmap_usage[] = "loadkmap\n\n"
- "Loads a binary keyboard translation table from standard input.\n";
+static const char loadkmap_usage[] = "loadkmap\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "Loads a binary keyboard translation table from standard input.\n"
+#endif
+ ;
int loadkmap_main(int argc, char **argv)
diff --git a/logger.c b/logger.c
index db6d9bf..118a5de 100644
--- a/logger.c
+++ b/logger.c
@@ -48,14 +48,17 @@ extern CODE facilitynames[];
#endif
static const char logger_usage[] =
- "logger [OPTION]... [MESSAGE]\n\n"
- "Write MESSAGE to the system log. If MESSAGE is '-', log stdin.\n\n"
+ "logger [OPTION]... [MESSAGE]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nWrite MESSAGE to the system log. If MESSAGE is '-', log stdin.\n\n"
"Options:\n"
"\t-s\tLog to stderr as well as the system log.\n"
"\t-t\tLog using the specified tag (defaults to user name).\n"
"\t-p\tEnter the message with the specified priority.\n"
- "\t\tThis may be numerical or a ``facility.level'' pair.\n";
+ "\t\tThis may be numerical or a ``facility.level'' pair.\n"
+#endif
+ ;
/* Decode a symbolic name to a numeric value
diff --git a/logname.c b/logname.c
index bde1752..7c6153f 100644
--- a/logname.c
+++ b/logname.c
@@ -23,9 +23,11 @@
#include "internal.h"
#include <stdio.h>
-static const char logname_usage[] = "logname\n\n"
-
- "Print the name of the current user.\n";
+static const char logname_usage[] = "logname\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrint the name of the current user.\n"
+#endif
+ ;
extern int logname_main(int argc, char **argv)
{
diff --git a/ls.c b/ls.c
index 3c518ab..6ab11c4 100644
--- a/ls.c
+++ b/ls.c
@@ -449,7 +449,9 @@ static const char ls_usage[] = "ls [-1a"
#ifdef BB_FEATURE_LS_FILETYPES
"F"
#endif
- "] [filenames...]\n\n"
+ "] [filenames...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nList directory contents\n\n"
"Options:\n"
"\t-a\tdo not hide entries starting with .\n"
#ifdef BB_FEATURE_LS_TIMESTAMPS
@@ -475,6 +477,7 @@ static const char ls_usage[] = "ls [-1a"
#ifdef BB_FEATURE_LS_FILETYPES
"\t-F\tappend indicator (one of */=@|) to entries\n"
#endif
+#endif
;
extern int ls_main(int argc, char **argv)
diff --git a/makedevs.c b/makedevs.c
index c8206e0..5072095 100644
--- a/makedevs.c
+++ b/makedevs.c
@@ -17,8 +17,9 @@
#include <sys/stat.h>
static const char makedevs_usage[] =
- "makedevs NAME TYPE MAJOR MINOR FIRST LAST [s]\n\n"
- "Creates a range of block or character special files\n\n"
+ "makedevs NAME TYPE MAJOR MINOR FIRST LAST [s]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCreates a range of block or character special files\n\n"
"TYPEs include:\n"
"\tb:\tMake a block (buffered) device.\n"
"\tc or u:\tMake a character (un-buffered) device.\n"
@@ -28,7 +29,9 @@ static const char makedevs_usage[] =
"If 's' is the last argument, the base device is created as well.\n\n"
"For example:\n"
"\tmakedevs /dev/ttyS c 4 66 2 63 -> ttyS2-ttyS63\n"
- "\tmakedevs /dev/hda b 3 0 0 8 s -> hda,hda1-hda8\n";
+ "\tmakedevs /dev/hda b 3 0 0 8 s -> hda,hda1-hda8\n"
+#endif
+ ;
int makedevs_main(int argc, char **argv)
{
diff --git a/math.c b/math.c
index 96afafd..18af353 100644
--- a/math.c
+++ b/math.c
@@ -7,10 +7,13 @@
/* Tiny RPN calculator, because "expr" didn't give me bitwise operations. */
-static const char math_usage[] = "math expression ...\n\n"
- "This is a Tiny RPN calculator that understands the\n"
+static const char math_usage[] = "math expression ...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nThis is a Tiny RPN calculator that understands the\n"
"following operations: +, -, /, *, and, or, not, eor.\n"
- "i.e. 'math 2 2 add' -> 4, and 'math 8 8 \\* 2 2 + /' -> 16\n";
+ "i.e. 'math 2 2 add' -> 4, and 'math 8 8 \\* 2 2 + /' -> 16\n"
+#endif
+ ;
static double stack[100];
static unsigned int pointer;
diff --git a/messages.c b/messages.c
index 305bcdb..73d6427 100644
--- a/messages.c
+++ b/messages.c
@@ -26,6 +26,13 @@
* Perhaps this will make it simpler to internationalize also, and
* may make the binary slightly smaller.
*/
+
+// TO use, do something like this
+//
+//#define BB_DECLARE_EXTERN
+//#define bb_need_memory_exhausted
+//#include "messages.c"
+//
#ifndef _BB_MESSAGES_C
#define _BB_MESSAGES_C
@@ -59,4 +66,9 @@ BB_DEF_MESSAGE(name_too_long, "%s: file name too long\n")
#if defined bb_need_io_error || ! defined BB_DECLARE_EXTERN
BB_DEF_MESSAGE(io_error, "%s: input/output error -- %s\n")
#endif
+#if defined bb_need_help || ! defined BB_DECLARE_EXTERN
+ BB_DEF_MESSAGE(dash_dash_help, "--help")
+#endif
+
#endif /* _BB_MESSAGES_C */
+
diff --git a/miscutils/makedevs.c b/miscutils/makedevs.c
index c8206e0..5072095 100644
--- a/miscutils/makedevs.c
+++ b/miscutils/makedevs.c
@@ -17,8 +17,9 @@
#include <sys/stat.h>
static const char makedevs_usage[] =
- "makedevs NAME TYPE MAJOR MINOR FIRST LAST [s]\n\n"
- "Creates a range of block or character special files\n\n"
+ "makedevs NAME TYPE MAJOR MINOR FIRST LAST [s]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCreates a range of block or character special files\n\n"
"TYPEs include:\n"
"\tb:\tMake a block (buffered) device.\n"
"\tc or u:\tMake a character (un-buffered) device.\n"
@@ -28,7 +29,9 @@ static const char makedevs_usage[] =
"If 's' is the last argument, the base device is created as well.\n\n"
"For example:\n"
"\tmakedevs /dev/ttyS c 4 66 2 63 -> ttyS2-ttyS63\n"
- "\tmakedevs /dev/hda b 3 0 0 8 s -> hda,hda1-hda8\n";
+ "\tmakedevs /dev/hda b 3 0 0 8 s -> hda,hda1-hda8\n"
+#endif
+ ;
int makedevs_main(int argc, char **argv)
{
diff --git a/miscutils/mt.c b/miscutils/mt.c
index cf20d17..28922f8 100644
--- a/miscutils/mt.c
+++ b/miscutils/mt.c
@@ -4,8 +4,11 @@
#include <sys/mtio.h>
#include <sys/fcntl.h>
-static const char mt_usage[] = "mt [-f device] opcode value\n\n"
- "Control magnetic tape drive operation\n";
+static const char mt_usage[] = "mt [-f device] opcode value\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nControl magnetic tape drive operation\n"
+#endif
+ ;
struct mt_opcodes {
char *name;
diff --git a/miscutils/update.c b/miscutils/update.c
index 18b13e8..14f1d3c 100644
--- a/miscutils/update.c
+++ b/miscutils/update.c
@@ -35,12 +35,15 @@ _syscall2(int, bdflush, int, func, int, data);
#endif /* __GLIBC__ */
static char update_usage[] =
- "update [options]\n\n"
- "Periodically flushes filesystem buffers.\n\n"
+ "update [options]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPeriodically flushes filesystem buffers.\n\n"
"Options:\n"
"\t-S\tforce use of sync(2) instead of flushing\n"
"\t-s SECS\tcall sync this often (default 30)\n"
- "\t-f SECS\tflush some buffers this often (default 5)\n";
+ "\t-f SECS\tflush some buffers this often (default 5)\n"
+#endif
+ ;
static unsigned int sync_duration = 30;
static unsigned int flush_duration = 5;
diff --git a/mkdir.c b/mkdir.c
index 54d9b72..9664986 100644
--- a/mkdir.c
+++ b/mkdir.c
@@ -30,12 +30,15 @@
#include <errno.h>
static const char mkdir_usage[] =
- "mkdir [OPTION] DIRECTORY...\n\n"
- "Create the DIRECTORY(ies), if they do not already exist\n\n"
+ "mkdir [OPTION] DIRECTORY...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCreate the DIRECTORY(ies), if they do not already exist\n\n"
"Options:\n"
"\t-m\tset permission mode (as in chmod), not rwxrwxrwx - umask\n"
- "\t-p\tno error if existing, make parent directories as needed\n";
+ "\t-p\tno error if existing, make parent directories as needed\n"
+#endif
+ ;
static int parentFlag = FALSE;
diff --git a/mkfifo.c b/mkfifo.c
index b273df0..ef3d667 100644
--- a/mkfifo.c
+++ b/mkfifo.c
@@ -26,11 +26,13 @@
#include <sys/stat.h>
#include <errno.h>
-static const char mkfifo_usage[] = "mkfifo [OPTIONS] name\n\n"
- "Creates a named pipe (identical to 'mknod name p')\n\n"
-
+static const char mkfifo_usage[] = "mkfifo [OPTIONS] name\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCreates a named pipe (identical to 'mknod name p')\n\n"
"Options:\n"
- "\t-m\tcreate the pipe using the specified mode (default a=rw)\n";
+ "\t-m\tcreate the pipe using the specified mode (default a=rw)\n"
+#endif
+ ;
extern int mkfifo_main(int argc, char **argv)
{
diff --git a/mkfs_minix.c b/mkfs_minix.c
index be180a4..bf4bda9 100644
--- a/mkfs_minix.c
+++ b/mkfs_minix.c
@@ -179,9 +179,10 @@ static volatile void show_usage()
fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n",
BB_VER, BB_BT);
fprintf(stderr,
- "Usage: %s [-c | -l filename] [-nXX] [-iXX] /dev/name [blocks]\n\n",
+ "Usage: %s [-c | -l filename] [-nXX] [-iXX] /dev/name [blocks]\n",
program_name);
- fprintf(stderr, "Make a MINIX filesystem.\n\n");
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ fprintf(stderr, "\nMake a MINIX filesystem.\n\n");
fprintf(stderr, "OPTIONS:\n");
fprintf(stderr, "\t-c\t\tCheck the device for bad blocks\n");
fprintf(stderr,
@@ -191,6 +192,7 @@ static volatile void show_usage()
fprintf(stderr,
"\t-l FILENAME\tRead the bad blocks list from FILENAME\n");
fprintf(stderr, "\t-v\t\tMake a Minix version 2 filesystem\n\n");
+#endif
exit(16);
}
diff --git a/mknod.c b/mknod.c
index caa234f..8f411a3 100644
--- a/mknod.c
+++ b/mknod.c
@@ -28,14 +28,17 @@
#include <fcntl.h>
#include <unistd.h>
-static const char mknod_usage[] = "mknod [OPTIONS] NAME TYPE MAJOR MINOR\n\n"
- "Create a special file (block, character, or pipe).\n\n"
+static const char mknod_usage[] = "mknod [OPTIONS] NAME TYPE MAJOR MINOR\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCreate a special file (block, character, or pipe).\n\n"
"Options:\n"
"\t-m\tcreate the special file using the specified mode (default a=rw)\n\n"
"TYPEs include:\n"
"\tb:\tMake a block (buffered) device.\n"
"\tc or u:\tMake a character (un-buffered) device.\n"
- "\tp:\tMake a named pipe. MAJOR and MINOR are ignored for named pipes.\n";
+ "\tp:\tMake a named pipe. MAJOR and MINOR are ignored for named pipes.\n"
+#endif
+ ;
int mknod_main(int argc, char **argv)
{
diff --git a/mkswap.c b/mkswap.c
index 17866a7..7d76916 100644
--- a/mkswap.c
+++ b/mkswap.c
@@ -49,13 +49,16 @@
static const char mkswap_usage[] =
- "mkswap [-c] [-v0|-v1] device [block-count]\n\n"
- "Prepare a disk partition to be used as a swap partition.\n\n"
+ "mkswap [-c] [-v0|-v1] device [block-count]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrepare a disk partition to be used as a swap partition.\n\n"
"Options:\n" "\t-c\t\tCheck for read-ability.\n"
"\t-v0\t\tMake version 0 swap [max 128 Megs].\n"
"\t-v1\t\tMake version 1 swap [big!] (default for kernels > 2.1.117).\n"
- "\tblock-count\tNumber of block to use (default is entire partition).\n";
+ "\tblock-count\tNumber of block to use (default is entire partition).\n"
+#endif
+ ;
#ifndef _IO
diff --git a/modutils/insmod.c b/modutils/insmod.c
index eafec7d..9d473ca 100644
--- a/modutils/insmod.c
+++ b/modutils/insmod.c
@@ -70,12 +70,15 @@ _syscall2(unsigned long, create_module, const char *, name, size_t, size)
static char m_filename[BUFSIZ + 1] = "\0";
static char m_fullName[BUFSIZ + 1] = "\0";
static const char insmod_usage[] =
- "insmod [OPTION]... MODULE [symbol=value]...\n\n"
- "Loads the specified kernel modules into the kernel.\n\n"
+ "insmod [OPTION]... MODULE [symbol=value]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nLoads the specified kernel modules into the kernel.\n\n"
"Options:\n"
"\t-f\tForce module to load into the wrong kernel version.\n"
- "\t-k\tMake module autoclean-able.\n";
+ "\t-k\tMake module autoclean-able.\n"
+#endif
+ ;
static int findNamedModule(const char *fileName, struct stat *statbuf)
diff --git a/modutils/rmmod.c b/modutils/rmmod.c
index bc5c03e..5ef4a60 100644
--- a/modutils/rmmod.c
+++ b/modutils/rmmod.c
@@ -36,10 +36,13 @@ _syscall1(int, delete_module, const char *, name)
static const char rmmod_usage[] =
- "rmmod [OPTION]... [MODULE]...\n\n"
- "Unloads the specified kernel modules from the kernel.\n\n"
-
- "Options:\n" "\t-a\tTry to remove all unused kernel modules.\n";
+ "rmmod [OPTION]... [MODULE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nUnloads the specified kernel modules from the kernel.\n\n"
+ "Options:\n"
+ "\t-a\tTry to remove all unused kernel modules.\n"
+#endif
+ ;
diff --git a/more.c b/more.c
index 30d2757..5044686 100644
--- a/more.c
+++ b/more.c
@@ -30,8 +30,15 @@
#include <fcntl.h>
#include <signal.h>
#include <sys/ioctl.h>
+#define BB_DECLARE_EXTERN
+#define bb_need_help
+#include "messages.c"
-static const char more_usage[] = "more [file ...]\n";
+static const char more_usage[] = "more [FILE ...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nMore is a filter for viewing FILE one screenful at a time.\n"
+#endif
+ ;
/* ED: sparc termios is broken: revert back to old termio handling. */
#ifdef BB_FEATURE_USE_TERMIOS
@@ -92,7 +99,7 @@ extern int more_main(int argc, char **argv)
argv++;
if (argc > 0
- && (strcmp(*argv, "--help") == 0 || strcmp(*argv, "-h") == 0)) {
+ && (strcmp(*argv, dash_dash_help) == 0 || strcmp(*argv, "-h") == 0)) {
usage(more_usage);
}
do {
diff --git a/mount.c b/mount.c
index 00a774a..bde55d1 100644
--- a/mount.c
+++ b/mount.c
@@ -64,10 +64,12 @@ static int use_loop = FALSE;
extern const char mtab_file[]; /* Defined in utility.c */
-static const char mount_usage[] = "\tmount [flags]\n"
- "\tmount [flags] device directory [-o options,more-options]\n"
- "\n" "Flags:\n"
- "\t-a:\t\tMount all file systems in fstab.\n"
+static const char mount_usage[] =
+ "mount [flags] device directory [-o options,more-options]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nMount a filesystem\n\n"
+ "Flags:\n"
+ "\t-a:\t\tMount all filesystems in fstab.\n"
#ifdef BB_MTAB
"\t-f:\t\t\"Fake\" mount. Add entry to mount table but don't mount it.\n"
"\t-n:\t\tDon't write a mount table entry.\n"
@@ -88,8 +90,10 @@ static const char mount_usage[] = "\tmount [flags]\n"
"\tsuid/nosuid:\tAllow set-user-id-root programs / disallow them.\n"
"\tremount:\tRe-mount a currently-mounted filesystem, changing its flags.\n"
"\tro/rw:\t\tMount for read-only / read-write.\n"
- "There are EVEN MORE flags that are specific to each filesystem.\n"
- "You'll have to see the written documentation for those.\n";
+ "\nThere are EVEN MORE flags that are specific to each filesystem.\n"
+ "You'll have to see the written documentation for those.\n"
+#endif
+ ;
struct mount_options {
@@ -451,7 +455,7 @@ extern int mount_main(int argc, char **argv)
fatalError( "\nCannot read /etc/fstab: %s\n", strerror (errno));
while ((m = getmntent(f)) != NULL) {
- // If the file system isn't noauto,
+ // If the filesystem isn't noauto,
// and isn't swap or nfs, then mount it
if ((!strstr(m->mnt_opts, "noauto")) &&
(!strstr(m->mnt_type, "swap")) &&
diff --git a/mt.c b/mt.c
index cf20d17..28922f8 100644
--- a/mt.c
+++ b/mt.c
@@ -4,8 +4,11 @@
#include <sys/mtio.h>
#include <sys/fcntl.h>
-static const char mt_usage[] = "mt [-f device] opcode value\n\n"
- "Control magnetic tape drive operation\n";
+static const char mt_usage[] = "mt [-f device] opcode value\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nControl magnetic tape drive operation\n"
+#endif
+ ;
struct mt_opcodes {
char *name;
diff --git a/mnc.c b/nc.c
index 60c18a9..a588587 100644
--- a/mnc.c
+++ b/nc.c
@@ -1,5 +1,5 @@
/* vi: set sw=4 ts=4: */
-/* mnc: mini-netcat - built from the ground up for LRP
+/* nc: mini-netcat - built from the ground up for LRP
Copyright (C) 1998 Charles P. Wright
0.0.1 6K It works.
@@ -40,11 +40,13 @@
#define BUFSIZE 100
-static const char mnc_usage[] =
+static const char nc_usage[] = "nc [IP] [port]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nNetcat opens a pipe to IP:port\n"
+#endif
+ ;
- "mnc [IP] [port]\n\n" "mini-netcat opens a pipe to IP:port\n";
-
-int mnc_main(int argc, char **argv)
+int nc_main(int argc, char **argv)
{
int sfd;
int result;
@@ -59,7 +61,7 @@ int mnc_main(int argc, char **argv)
argc--;
argv++;
if (argc < 2 || **(argv + 1) == '-') {
- usage(mnc_usage);
+ usage(nc_usage);
}
sfd = socket(AF_INET, SOCK_STREAM, 0);
diff --git a/networking/hostname.c b/networking/hostname.c
index 8cc334d..ef92102 100644
--- a/networking/hostname.c
+++ b/networking/hostname.c
@@ -1,6 +1,6 @@
/* vi: set sw=4 ts=4: */
/*
- * $Id: hostname.c,v 1.7 2000/02/08 19:58:47 erik Exp $
+ * $Id: hostname.c,v 1.8 2000/05/12 19:41:47 erik Exp $
* Mini hostname implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
@@ -31,15 +31,18 @@
#include <stdio.h>
static const char *hostname_usage =
- "hostname [OPTION] {hostname | -F file}\n\n"
- "Get or set the hostname or DNS domain name. If a hostname is given\n"
+ "hostname [OPTION] {hostname | -F file}\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nGet or set the hostname or DNS domain name. If a hostname is given\n"
"(or a file with the -F parameter), the host name will be set.\n\n"
"Options:\n"
"\t-s\t\tShort\n"
"\t-i\t\tAddresses for the hostname\n"
"\t-d\t\tDNS domain name\n"
- "\t-F FILE\t\tUse the contents of FILE to specify the hostname\n";
+ "\t-F FILE\t\tUse the contents of FILE to specify the hostname\n"
+#endif
+ ;
void do_sethostname(char *s, int isfile)
diff --git a/networking/nc.c b/networking/nc.c
new file mode 100644
index 0000000..a588587
--- /dev/null
+++ b/networking/nc.c
@@ -0,0 +1,133 @@
+/* vi: set sw=4 ts=4: */
+/* nc: mini-netcat - built from the ground up for LRP
+ Copyright (C) 1998 Charles P. Wright
+
+ 0.0.1 6K It works.
+ 0.0.2 5K Smaller and you can also check the exit condition if you wish.
+ 0.0.3 Uses select()
+
+ 19980918 Busy Boxed! Dave Cinege
+ 19990512 Uses Select. Charles P. Wright
+ 19990513 Fixes stdin stupidity and uses buffers. Charles P. Wright
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+#include "internal.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#include <sys/time.h>
+#include <sys/ioctl.h>
+
+#define BUFSIZE 100
+
+static const char nc_usage[] = "nc [IP] [port]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nNetcat opens a pipe to IP:port\n"
+#endif
+ ;
+
+int nc_main(int argc, char **argv)
+{
+ int sfd;
+ int result;
+ int len;
+ char ch[BUFSIZE];
+
+ struct sockaddr_in address;
+ struct hostent *hostinfo;
+
+ fd_set readfds, testfds;
+
+ argc--;
+ argv++;
+ if (argc < 2 || **(argv + 1) == '-') {
+ usage(nc_usage);
+ }
+
+ sfd = socket(AF_INET, SOCK_STREAM, 0);
+
+ hostinfo = (struct hostent *) gethostbyname(*argv);
+
+ if (!hostinfo) {
+ exit(1);
+ }
+
+ address.sin_family = AF_INET;
+ address.sin_addr = *(struct in_addr *) *hostinfo->h_addr_list;
+ address.sin_port = htons(atoi(*(++argv)));
+
+ len = sizeof(address);
+
+ result = connect(sfd, (struct sockaddr *) &address, len);
+
+ if (result < 0) {
+ exit(2);
+ }
+
+ FD_ZERO(&readfds);
+ FD_SET(sfd, &readfds);
+ FD_SET(fileno(stdin), &readfds);
+
+ while (1) {
+ int fd;
+ int ofd;
+ int nread;
+
+ testfds = readfds;
+
+ result =
+ select(FD_SETSIZE, &testfds, (fd_set *) NULL, (fd_set *) NULL,
+ (struct timeval *) 0);
+
+ if (result < 1) {
+ exit(3);
+ }
+
+ for (fd = 0; fd < FD_SETSIZE; fd++) {
+ if (FD_ISSET(fd, &testfds)) {
+ int trn = 0;
+ int rn;
+
+ ioctl(fd, FIONREAD, &nread);
+
+ if (fd == sfd) {
+ if (nread == 0)
+ exit(0);
+ ofd = fileno(stdout);
+ } else {
+ ofd = sfd;
+ }
+
+
+
+ do {
+ rn = (BUFSIZE < nread - trn) ? BUFSIZE : nread - trn;
+ trn += rn;
+ read(fd, ch, rn);
+ write(ofd, ch, rn);
+ }
+ while (trn < nread);
+ }
+ }
+ }
+}
diff --git a/networking/nslookup.c b/networking/nslookup.c
index e4bf52f..82bcf56 100644
--- a/networking/nslookup.c
+++ b/networking/nslookup.c
@@ -41,7 +41,11 @@
| + find out how the real nslookup gets the default name server
*/
-static const char nslookup_usage[] = "nslookup [HOST]\n\nQueries the nameserver for the IP address of the given HOST\n";
+static const char nslookup_usage[] = "nslookup [HOST]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nQueries the nameserver for the IP address of the given HOST\n"
+#endif
+;
/* I have to see how the real nslookup does this.
@@ -173,4 +177,4 @@ int nslookup_main(int argc, char **argv)
exit( TRUE);
}
-/* $Id: nslookup.c,v 1.8 2000/05/02 00:07:56 erik Exp $ */
+/* $Id: nslookup.c,v 1.9 2000/05/12 19:41:47 erik Exp $ */
diff --git a/networking/ping.c b/networking/ping.c
index 9f83002..14a56cd 100644
--- a/networking/ping.c
+++ b/networking/ping.c
@@ -1,6 +1,6 @@
/* vi: set sw=4 ts=4: */
/*
- * $Id: ping.c,v 1.14 2000/04/25 23:24:55 erik Exp $
+ * $Id: ping.c,v 1.15 2000/05/12 19:41:47 erik Exp $
* Mini ping implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
@@ -90,7 +90,11 @@ static int in_cksum(unsigned short *buf, int sz)
/* simple version */
#ifdef BB_SIMPLE_PING
-static const char *ping_usage = "ping host\n\n";
+static const char *ping_usage = "ping host\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nSend ICMP ECHO_REQUEST packets to network hosts\n"
+#endif
+ ;
static char *hostname = NULL;
@@ -179,12 +183,15 @@ extern int ping_main(int argc, char **argv)
#else
/* full(er) version */
-static const char *ping_usage = "ping [OPTION]... host\n\n"
- "Send ICMP ECHO_REQUEST packets to network hosts.\n\n"
+static const char *ping_usage = "ping [OPTION]... host\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nSend ICMP ECHO_REQUEST packets to network hosts.\n\n"
"Options:\n"
"\t-c COUNT\tSend only COUNT pings.\n"
"\t-q\t\tQuiet mode, only displays output at start\n"
- "\t\t\tand when finished.\n";
+ "\t\t\tand when finished.\n"
+#endif
+ ;
static char *hostname = NULL;
static struct sockaddr_in pingaddr;
diff --git a/networking/telnet.c b/networking/telnet.c
index 8c58521..8b6d5f5 100644
--- a/networking/telnet.c
+++ b/networking/telnet.c
@@ -1,5 +1,5 @@
/*
- * $Id: telnet.c,v 1.2 2000/05/01 19:10:52 erik Exp $
+ * $Id: telnet.c,v 1.3 2000/05/12 19:41:47 erik Exp $
* Mini telnet implementation for busybox
*
* Copyright (C) 2000 by Randolph Chung <tausq@debian.org>
@@ -46,7 +46,12 @@
static int STDIN = 0;
static int STDOUT = 1;
-static const char *telnet_usage = "telnet host [port]\n\n";
+static const char *telnet_usage = "telnet host [port]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nProvides interactive communication with another\n"
+ "networked host using the TELNET protocol\n"
+#endif
+ ;
static struct termios saved_tc;
static unsigned char options[NTELOPTS];
static char tr_state = 0; /* telnet send and receive state */
diff --git a/nslookup.c b/nslookup.c
index e4bf52f..82bcf56 100644
--- a/nslookup.c
+++ b/nslookup.c
@@ -41,7 +41,11 @@
| + find out how the real nslookup gets the default name server
*/
-static const char nslookup_usage[] = "nslookup [HOST]\n\nQueries the nameserver for the IP address of the given HOST\n";
+static const char nslookup_usage[] = "nslookup [HOST]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nQueries the nameserver for the IP address of the given HOST\n"
+#endif
+;
/* I have to see how the real nslookup does this.
@@ -173,4 +177,4 @@ int nslookup_main(int argc, char **argv)
exit( TRUE);
}
-/* $Id: nslookup.c,v 1.8 2000/05/02 00:07:56 erik Exp $ */
+/* $Id: nslookup.c,v 1.9 2000/05/12 19:41:47 erik Exp $ */
diff --git a/ping.c b/ping.c
index 9f83002..14a56cd 100644
--- a/ping.c
+++ b/ping.c
@@ -1,6 +1,6 @@
/* vi: set sw=4 ts=4: */
/*
- * $Id: ping.c,v 1.14 2000/04/25 23:24:55 erik Exp $
+ * $Id: ping.c,v 1.15 2000/05/12 19:41:47 erik Exp $
* Mini ping implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
@@ -90,7 +90,11 @@ static int in_cksum(unsigned short *buf, int sz)
/* simple version */
#ifdef BB_SIMPLE_PING
-static const char *ping_usage = "ping host\n\n";
+static const char *ping_usage = "ping host\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nSend ICMP ECHO_REQUEST packets to network hosts\n"
+#endif
+ ;
static char *hostname = NULL;
@@ -179,12 +183,15 @@ extern int ping_main(int argc, char **argv)
#else
/* full(er) version */
-static const char *ping_usage = "ping [OPTION]... host\n\n"
- "Send ICMP ECHO_REQUEST packets to network hosts.\n\n"
+static const char *ping_usage = "ping [OPTION]... host\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nSend ICMP ECHO_REQUEST packets to network hosts.\n\n"
"Options:\n"
"\t-c COUNT\tSend only COUNT pings.\n"
"\t-q\t\tQuiet mode, only displays output at start\n"
- "\t\t\tand when finished.\n";
+ "\t\t\tand when finished.\n"
+#endif
+ ;
static char *hostname = NULL;
static struct sockaddr_in pingaddr;
diff --git a/printf.c b/printf.c
index bfe4081..28a011d 100644
--- a/printf.c
+++ b/printf.c
@@ -139,7 +139,12 @@ static void verify __P((char *s, char *end));
/* The value to return to the calling program. */
static int exit_status;
-static const char printf_usage[] = "printf format [argument...]\n\nFormats and prints the given data.\n";
+static const char printf_usage[] = "printf FORMAT [ARGUMENT...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nFormats and prints ARGUMENT(s) according to FORMAT,\n"
+ "Where FORMAT controls the output exactly as in C printf.\n"
+#endif
+ ;
int printf_main(int argc, char **argv)
{
diff --git a/procps/free.c b/procps/free.c
index 39594db..e6f130e 100644
--- a/procps/free.c
+++ b/procps/free.c
@@ -37,6 +37,14 @@ extern int free_main(int argc, char **argv)
info.sharedram/=DIVISOR;
info.bufferram/=DIVISOR;
+ if (argc > 1 && **(argv + 1) == '-') {
+ usage("free\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nDisplays the amount of free and used system memory\n"
+#endif
+ );
+ }
+
printf("%6s%13s%13s%13s%13s%13s\n", "", "total", "used", "free",
"shared", "buffers");
diff --git a/procps/kill.c b/procps/kill.c
index 93f02ea..0487f6a 100644
--- a/procps/kill.c
+++ b/procps/kill.c
@@ -32,16 +32,22 @@
#include <unistd.h>
static const char *kill_usage =
- "kill [-signal] process-id [process-id ...]\n\n"
- "Send a signal (default is SIGTERM) to the specified process(es).\n\n"
- "Options:\n" "\t-l\tList all signal names and numbers.\n\n";
+ "kill [-signal] process-id [process-id ...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nSend a signal (default is SIGTERM) to the specified process(es).\n\n"
+ "Options:\n" "\t-l\tList all signal names and numbers.\n\n"
+#endif
+ ;
#ifdef BB_KILLALL
static const char *killall_usage =
- "killall [-signal] process-name [process-name ...]\n\n"
- "Send a signal (default is SIGTERM) to the specified process(es).\n\n"
- "Options:\n" "\t-l\tList all signal names and numbers.\n\n";
+ "killall [-signal] process-name [process-name ...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nSend a signal (default is SIGTERM) to the specified process(es).\n\n"
+ "Options:\n" "\t-l\tList all signal names and numbers.\n\n"
+#endif
#endif
+ ;
#define KILL 0
#define KILLALL 1
diff --git a/procps/ps.c b/procps/ps.c
index f8cf33b..0842a22 100644
--- a/procps/ps.c
+++ b/procps/ps.c
@@ -36,6 +36,9 @@
#include <fcntl.h>
#include <ctype.h>
#include <sys/ioctl.h>
+#define BB_DECLARE_EXTERN
+#define bb_need_help
+#include "messages.c"
#if ! defined BB_FEATURE_USE_DEVPS_PATCH
@@ -128,8 +131,13 @@ extern int ps_main(int argc, char **argv)
- if (argc > 1 && strcmp(argv[1], "--help") == 0) {
- usage ("ps\n\nReport process status\n\nThis version of ps accepts no options.\n");
+ if (argc > 1 && strcmp(argv[1], dash_dash_help) == 0) {
+ usage ("ps\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nReport process status\n"
+ "\nThis version of ps accepts no options.\n"
+#endif
+ );
}
dir = opendir("/proc");
diff --git a/ps.c b/ps.c
index f8cf33b..0842a22 100644
--- a/ps.c
+++ b/ps.c
@@ -36,6 +36,9 @@
#include <fcntl.h>
#include <ctype.h>
#include <sys/ioctl.h>
+#define BB_DECLARE_EXTERN
+#define bb_need_help
+#include "messages.c"
#if ! defined BB_FEATURE_USE_DEVPS_PATCH
@@ -128,8 +131,13 @@ extern int ps_main(int argc, char **argv)
- if (argc > 1 && strcmp(argv[1], "--help") == 0) {
- usage ("ps\n\nReport process status\n\nThis version of ps accepts no options.\n");
+ if (argc > 1 && strcmp(argv[1], dash_dash_help) == 0) {
+ usage ("ps\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nReport process status\n"
+ "\nThis version of ps accepts no options.\n"
+#endif
+ );
}
dir = opendir("/proc");
diff --git a/pwd.c b/pwd.c
index e77a0ca..19494a9 100644
--- a/pwd.c
+++ b/pwd.c
@@ -24,15 +24,14 @@
#include "internal.h"
#include <stdio.h>
#include <dirent.h>
+#include <errno.h>
extern int pwd_main(int argc, char **argv)
{
char buf[BUFSIZ + 1];
- if (getcwd(buf, sizeof(buf)) == NULL) {
- perror("get working directory");
- exit(FALSE);
- }
+ if (getcwd(buf, sizeof(buf)) == NULL)
+ fatalError("pwd: %s", strerror(errno));
printf("%s\n", buf);
exit(TRUE);
diff --git a/rm.c b/rm.c
index 0cd7956..c62d68a 100644
--- a/rm.c
+++ b/rm.c
@@ -29,12 +29,14 @@
#include <dirent.h>
#include <errno.h>
-static const char *rm_usage = "rm [OPTION]... FILE...\n\n"
- "Remove (unlink) the FILE(s).\n\n"
+static const char *rm_usage = "rm [OPTION]... FILE...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nRemove (unlink) the FILE(s).\n\n"
"Options:\n"
-
"\t-f\t\tremove existing destinations, never prompt\n"
- "\t-r or -R\tremove the contents of directories recursively\n";
+ "\t-r or -R\tremove the contents of directories recursively\n"
+#endif
+ ;
static int recursiveFlag = FALSE;
diff --git a/rmdir.c b/rmdir.c
index 1d88de3..61d7f2a 100644
--- a/rmdir.c
+++ b/rmdir.c
@@ -31,7 +31,11 @@ extern int rmdir_main(int argc, char **argv)
{
if (argc == 1 || **(argv + 1) == '-') {
usage
- ("rmdir [OPTION]... DIRECTORY...\n\nRemove the DIRECTORY(ies), if they are empty.\n");
+ ("rmdir [OPTION]... DIRECTORY...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nRemove the DIRECTORY(ies), if they are empty.\n"
+#endif
+ );
}
while (--argc > 0) {
diff --git a/rmmod.c b/rmmod.c
index bc5c03e..5ef4a60 100644
--- a/rmmod.c
+++ b/rmmod.c
@@ -36,10 +36,13 @@ _syscall1(int, delete_module, const char *, name)
static const char rmmod_usage[] =
- "rmmod [OPTION]... [MODULE]...\n\n"
- "Unloads the specified kernel modules from the kernel.\n\n"
-
- "Options:\n" "\t-a\tTry to remove all unused kernel modules.\n";
+ "rmmod [OPTION]... [MODULE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nUnloads the specified kernel modules from the kernel.\n\n"
+ "Options:\n"
+ "\t-a\tTry to remove all unused kernel modules.\n"
+#endif
+ ;
diff --git a/sed.c b/sed.c
index 0d57a4a..9fed670 100644
--- a/sed.c
+++ b/sed.c
@@ -38,8 +38,9 @@
#include <ctype.h>
static const char sed_usage[] =
- "sed [-n] -e script [file...]\n\n"
- "Allowed sed scripts come in the following form:\n"
+ "sed [-n] -e script [file...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nAllowed sed scripts come in the following form:\n"
"\t'ADDR [!] COMMAND'\n\n"
"\twhere address ADDR can be:\n"
"\t NUMBER Match specified line number\n"
@@ -58,8 +59,10 @@ static const char sed_usage[] =
#if defined BB_REGEXP
"This version of sed matches full regular expresions.\n";
#else
- "This version of sed matches strings (not full regular expresions).\n";
+ "This version of sed matches strings (not full regular expresions).\n"
#endif
+#endif
+ ;
/* Flags & variables */
diff --git a/sfdisk.c b/sfdisk.c
index d6ba537..8d2142b 100644
--- a/sfdisk.c
+++ b/sfdisk.c
@@ -54,10 +54,14 @@
#include <linux/hdreg.h> /* HDIO_GETGEO */
#include <linux/fs.h> /* BLKGETSIZE */
+#define BB_DECLARE_EXTERN
+#define bb_need_memory_exhausted
+#include "messages.c"
static const char sfdisk_usage[] =
"sfdisk [options] device ...\n"
- "device: something like /dev/hda or /dev/sda\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\ndevice: something like /dev/hda or /dev/sda\n"
"useful options:\n"
" -s [or --show-size]: list size of a partition\n"
" -c [or --id]: print or change partition Id\n"
@@ -86,7 +90,9 @@ static const char sfdisk_usage[] =
" -S# [or --sectors #]: set the number of sectors to use\n"
"You can disable all consistency checking with:\n"
- " -f [or --force]: do what I say, even if it is stupid\n";
+ " -f [or --force]: do what I say, even if it is stupid\n"
+#endif
+ ;
@@ -421,7 +427,7 @@ static int restore_sectors(char *dev)
return 0;
}
if (!(ss = (char *) malloc(statbuf.st_size))) {
- errorMsg("out of memory?\n");
+ errorMsg(memory_exhausted, "sfdisk");
return 0;
}
fdin = open(restore_sector_file, O_RDONLY);
diff --git a/sh.c b/sh.c
index b96b464..e446ad1 100644
--- a/sh.c
+++ b/sh.c
@@ -127,8 +127,11 @@ static struct builtInCommand bltins[] = {
static const char shell_usage[] =
- "sh [FILE]...\n\n" "The BusyBox command interpreter (shell).\n\n";
-
+ "sh [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nlash: The BusyBox command interpreter (shell).\n\n"
+#endif
+ ;
static char cwd[1024];
static char *prompt = "# ";
diff --git a/shell/lash.c b/shell/lash.c
index b96b464..e446ad1 100644
--- a/shell/lash.c
+++ b/shell/lash.c
@@ -127,8 +127,11 @@ static struct builtInCommand bltins[] = {
static const char shell_usage[] =
- "sh [FILE]...\n\n" "The BusyBox command interpreter (shell).\n\n";
-
+ "sh [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nlash: The BusyBox command interpreter (shell).\n\n"
+#endif
+ ;
static char cwd[1024];
static char *prompt = "# ";
diff --git a/sleep.c b/sleep.c
index 9687b84..13f07c0 100644
--- a/sleep.c
+++ b/sleep.c
@@ -24,7 +24,11 @@
#include "internal.h"
#include <stdio.h>
-const char sleep_usage[] = "sleep N\n\n" "Pause for N seconds.\n";
+const char sleep_usage[] = "sleep N\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPause for N seconds.\n"
+#endif
+ ;
extern int sleep_main(int argc, char **argv)
{
diff --git a/sort.c b/sort.c
index 49eb4fd..1edc7d1 100644
--- a/sort.c
+++ b/sort.c
@@ -33,7 +33,11 @@ static const char sort_usage[] = "sort [-n]"
#ifdef BB_FEATURE_SORT_REVERSE
" [-r]"
#endif
-" [FILE]...\n\nSorts lines of text in the specified files\n";
+" [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+"\nSorts lines of text in the specified files\n"
+#endif
+;
#ifdef BB_FEATURE_SORT_REVERSE
#define APPLY_REVERSE(x) (reverse ? -(x) : (x))
@@ -300,4 +304,4 @@ int sort_main(int argc, char **argv)
exit(0);
}
-/* $Id: sort.c,v 1.15 2000/04/17 04:22:09 beppu Exp $ */
+/* $Id: sort.c,v 1.16 2000/05/12 19:41:47 erik Exp $ */
diff --git a/swaponoff.c b/swaponoff.c
index aa961da..0f8c4f5 100644
--- a/swaponoff.c
+++ b/swaponoff.c
@@ -36,16 +36,22 @@ static int whichApp;
static const char *appName;
static const char swapoff_usage[] =
- "swapoff [OPTION] [device]\n\n"
- "Stop swapping virtual memory pages on the given device.\n\n"
+ "swapoff [OPTION] [device]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nStop swapping virtual memory pages on the given device.\n\n"
"Options:\n"
- "\t-a\tStop swapping on all swap devices\n";
+ "\t-a\tStop swapping on all swap devices\n"
+#endif
+ ;
static const char swapon_usage[] =
- "swapon [OPTION] [device]\n\n"
- "Start swapping virtual memory pages on the given device.\n\n"
+ "swapon [OPTION] [device]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nStart swapping virtual memory pages on the given device.\n\n"
"Options:\n"
- "\t-a\tStart swapping on all swap devices\n";
+ "\t-a\tStart swapping on all swap devices\n"
+#endif
+ ;
#define SWAPON_APP 1
diff --git a/sync.c b/sync.c
index f8160c8..33c7922 100644
--- a/sync.c
+++ b/sync.c
@@ -27,7 +27,11 @@
extern int sync_main(int argc, char **argv)
{
if (argc > 1 && **(argv + 1) == '-') {
- usage("sync\n\nWrite all buffered filesystem blocks to disk.\n");
+ usage("sync\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nWrite all buffered filesystem blocks to disk.\n"
+#endif
+ );
}
exit(sync());
}
diff --git a/sysklogd/logger.c b/sysklogd/logger.c
index db6d9bf..118a5de 100644
--- a/sysklogd/logger.c
+++ b/sysklogd/logger.c
@@ -48,14 +48,17 @@ extern CODE facilitynames[];
#endif
static const char logger_usage[] =
- "logger [OPTION]... [MESSAGE]\n\n"
- "Write MESSAGE to the system log. If MESSAGE is '-', log stdin.\n\n"
+ "logger [OPTION]... [MESSAGE]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nWrite MESSAGE to the system log. If MESSAGE is '-', log stdin.\n\n"
"Options:\n"
"\t-s\tLog to stderr as well as the system log.\n"
"\t-t\tLog using the specified tag (defaults to user name).\n"
"\t-p\tEnter the message with the specified priority.\n"
- "\t\tThis may be numerical or a ``facility.level'' pair.\n";
+ "\t\tThis may be numerical or a ``facility.level'' pair.\n"
+#endif
+ ;
/* Decode a symbolic name to a numeric value
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
index cacb629..faa6f15 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -64,8 +64,9 @@ static int MarkInterval = 20 * 60;
static char LocalHostName[32];
static const char syslogd_usage[] =
- "syslogd [OPTION]...\n\n"
- "Linux system and kernel (provides klogd) logging utility.\n"
+ "syslogd [OPTION]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nLinux system and kernel (provides klogd) logging utility.\n"
"Note that this version of syslogd/klogd ignores /etc/syslog.conf.\n\n"
"Options:\n"
"\t-m\tChange the mark timestamp interval. default=20min. 0=off\n"
@@ -73,7 +74,9 @@ static const char syslogd_usage[] =
#ifdef BB_KLOGD
"\t-K\tDo not start up the klogd process (by default syslogd spawns klogd).\n"
#endif
- "\t-O\tSpecify an alternate log file. default=/var/log/messages\n";
+ "\t-O\tSpecify an alternate log file. default=/var/log/messages\n"
+#endif
+ ;
/* Note: There is also a function called "message()" in init.c */
/* Print a message to the log file. */
diff --git a/syslogd.c b/syslogd.c
index cacb629..faa6f15 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -64,8 +64,9 @@ static int MarkInterval = 20 * 60;
static char LocalHostName[32];
static const char syslogd_usage[] =
- "syslogd [OPTION]...\n\n"
- "Linux system and kernel (provides klogd) logging utility.\n"
+ "syslogd [OPTION]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nLinux system and kernel (provides klogd) logging utility.\n"
"Note that this version of syslogd/klogd ignores /etc/syslog.conf.\n\n"
"Options:\n"
"\t-m\tChange the mark timestamp interval. default=20min. 0=off\n"
@@ -73,7 +74,9 @@ static const char syslogd_usage[] =
#ifdef BB_KLOGD
"\t-K\tDo not start up the klogd process (by default syslogd spawns klogd).\n"
#endif
- "\t-O\tSpecify an alternate log file. default=/var/log/messages\n";
+ "\t-O\tSpecify an alternate log file. default=/var/log/messages\n"
+#endif
+ ;
/* Note: There is also a function called "message()" in init.c */
/* Print a message to the log file. */
diff --git a/tail.c b/tail.c
index 321c5c4..3b3e2f5 100644
--- a/tail.c
+++ b/tail.c
@@ -47,6 +47,9 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <ctype.h>
+#define BB_DECLARE_EXTERN
+#define bb_need_help
+#include "messages.c"
#define XWRITE(fd, buffer, n_bytes) \
@@ -70,15 +73,18 @@ static int forever;
static int print_headers;
const char tail_usage[] =
- "tail [OPTION] [FILE]...\n\n"
- "Print last 10 lines of each FILE to standard output.\n"
+ "tail [OPTION] [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrint last 10 lines of each FILE to standard output.\n"
"With more than one FILE, precede each with a header giving the\n"
"file name. With no FILE, or when FILE is -, read standard input.\n\n"
"Options:\n"
"\t-n NUM\t\tPrint last NUM lines instead of first 10\n"
"\t-f\t\tOutput data as the file grows. This version\n"
- "\t\t\tof 'tail -f' supports only one file at a time.\n";
+ "\t\t\tof 'tail -f' supports only one file at a time.\n"
+#endif
+ ;
static void write_header(const char *filename)
@@ -512,9 +518,9 @@ char *program_name;
static int have_read_stdin;
-static const char tail_usage[] = "tail [OPTION]... [FILE]...\n\
-\n\
-Print last 10 lines of each FILE to standard output.\n\
+static const char tail_usage[] = "tail [OPTION]... [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+"\nPrint last 10 lines of each FILE to standard output.\n\
With more than one FILE, precede each with a header giving the file name.\n\
With no FILE, or when FILE is -, read standard input.\n\
\n\
@@ -523,11 +529,12 @@ With no FILE, or when FILE is -, read standard input.\n\
-n=N output the last N lines, instead of last 10\n\
-q never output headers giving file names\n\
-v always output headers giving file names\n\
- --help display this help and exit\n\
\n\
If the first character of N (bytes or lines) is a `+', output begins with \n\
the Nth item from the start of each file, otherwise, print the last N items\n\
-in the file. N bytes may be suffixed by k (x1024), b (x512), or m (1024^2).\n\n";
+in the file. N bytes may be suffixed by k (x1024), b (x512), or m (1024^2).\n"
+#endif
+;
static void write_header(const char *filename, const char *comment)
{
diff --git a/tar.c b/tar.c
index c82e51f..6784d80 100644
--- a/tar.c
+++ b/tar.c
@@ -60,8 +60,9 @@ static const char tar_usage[] =
#if defined BB_FEATURE_TAR_EXCLUDE
"[--exclude File] "
#endif
- "[-f tarFile] [FILE] ...\n\n"
- "Create, extract, or list files from a tar file. Note that\n"
+ "[-f tarFile] [FILE] ...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCreate, extract, or list files from a tar file. Note that\n"
"this version of tar treats hard links as separate files.\n\n"
"Main operation mode:\n"
#ifdef BB_FEATURE_TAR_CREATE
@@ -77,6 +78,7 @@ static const char tar_usage[] =
#endif
"\nInformative output:\n"
"\tv\t\tverbosely list files processed\n"
+#endif
;
/* Tar file constants */
diff --git a/tee.c b/tee.c
index 95b75ed..a78edc0 100644
--- a/tee.c
+++ b/tee.c
@@ -27,12 +27,14 @@
#include <stdio.h>
static const char tee_usage[] =
- "tee [OPTION]... [FILE]...\n\n"
- "Copy standard input to each FILE, and also to standard output.\n\n"
+ "tee [OPTION]... [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCopy standard input to each FILE, and also to standard output.\n\n"
"Options:\n" "\t-a\tappend to the given FILEs, do not overwrite\n"
#if 0
"\t-i\tignore interrupt signals\n"
#endif
+#endif
;
@@ -131,4 +133,4 @@ int tee_main(int argc, char **argv)
exit(0);
}
-/* $Id: tee.c,v 1.9 2000/04/13 01:18:56 erik Exp $ */
+/* $Id: tee.c,v 1.10 2000/05/12 19:41:47 erik Exp $ */
diff --git a/telnet.c b/telnet.c
index 8c58521..8b6d5f5 100644
--- a/telnet.c
+++ b/telnet.c
@@ -1,5 +1,5 @@
/*
- * $Id: telnet.c,v 1.2 2000/05/01 19:10:52 erik Exp $
+ * $Id: telnet.c,v 1.3 2000/05/12 19:41:47 erik Exp $
* Mini telnet implementation for busybox
*
* Copyright (C) 2000 by Randolph Chung <tausq@debian.org>
@@ -46,7 +46,12 @@
static int STDIN = 0;
static int STDOUT = 1;
-static const char *telnet_usage = "telnet host [port]\n\n";
+static const char *telnet_usage = "telnet host [port]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nProvides interactive communication with another\n"
+ "networked host using the TELNET protocol\n"
+#endif
+ ;
static struct termios saved_tc;
static unsigned char options[NTELOPTS];
static char tr_state = 0; /* telnet send and receive state */
diff --git a/test.c b/test.c
index 0ed7771..9b541e3 100644
--- a/test.c
+++ b/test.c
@@ -39,6 +39,9 @@
#include <errno.h>
#include <stdlib.h>
#include <string.h>
+#define BB_DECLARE_EXTERN
+#define bb_need_help
+#include "messages.c"
/* test(1) accepts the following grammar:
oexpr ::= aexpr | aexpr "-o" oexpr ;
@@ -185,11 +188,14 @@ test_main(int argc, char** argv)
fatalError("missing ]");
argv[argc] = NULL;
}
- if (strcmp(argv[1], "--help") == 0) {
+ if (strcmp(argv[1], dash_dash_help) == 0) {
usage("test EXPRESSION\n"
- "or [ EXPRESSION ]\n\n"
- "Checks file types and compares values returning an exit\n"
- "code determined by the value of EXPRESSION.\n");
+ "or [ EXPRESSION ]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nChecks file types and compares values returning an exit\n"
+ "code determined by the value of EXPRESSION.\n"
+#endif
+ );
}
/* Implement special cases from POSIX.2, section 4.62.4 */
diff --git a/touch.c b/touch.c
index f8972dc..2076928 100644
--- a/touch.c
+++ b/touch.c
@@ -31,9 +31,11 @@
#include <errno.h>
-static const char touch_usage[] = "touch [-c] file [file ...]\n\n"
-
- "Update the last-modified date on the given file[s].\n";
+static const char touch_usage[] = "touch [-c] file [file ...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nUpdate the last-modified date on the given file[s].\n"
+#endif
+ ;
diff --git a/tty.c b/tty.c
index 6f98d1b..3a318eb 100644
--- a/tty.c
+++ b/tty.c
@@ -24,10 +24,13 @@
#include <stdio.h>
#include <sys/types.h>
-static const char tty_usage[] = "tty\n\n"
- "Print the file name of the terminal connected to standard input.\n\n"
+static const char tty_usage[] = "tty\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrint the file name of the terminal connected to standard input.\n\n"
"Options:\n"
- "\t-s\tprint nothing, only return an exit status\n";
+ "\t-s\tprint nothing, only return an exit status\n"
+#endif
+ ;
extern int tty_main(int argc, char **argv)
{
diff --git a/umount.c b/umount.c
index 18a5afe..86833b7 100644
--- a/umount.c
+++ b/umount.c
@@ -30,8 +30,10 @@
static const char umount_usage[] =
- "umount [flags] filesystem|directory\n\n"
- "Flags:\n" "\t-a:\tUnmount all file systems"
+ "umount [flags] filesystem|directory\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "Unmount file systems\n"
+ "\nFlags:\n" "\t-a:\tUnmount all file systems"
#ifdef BB_MTAB
" in /etc/mtab\n\t-n:\tDon't erase /etc/mtab entries\n"
#else
@@ -44,6 +46,7 @@ static const char umount_usage[] =
#if defined BB_FEATURE_MOUNT_LOOP
"\t-l:\tDo not free loop device (if a loop device has been used)\n"
#endif
+#endif
;
struct _mtab_entry_t {
diff --git a/uniq.c b/uniq.c
index 0324856..0cccbd5 100644
--- a/uniq.c
+++ b/uniq.c
@@ -28,9 +28,12 @@
#include <errno.h>
static const char uniq_usage[] =
- "uniq [OPTION]... [INPUT [OUTPUT]]\n\n"
- "Discard all but one of successive identical lines from INPUT\n"
- "(or standard input), writing to OUTPUT (or standard output).\n";
+ "uniq [OPTION]... [INPUT [OUTPUT]]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nDiscard all but one of successive identical lines from INPUT\n"
+ "(or standard input), writing to OUTPUT (or standard output).\n"
+#endif
+ ;
/* max chars in line */
#define UNIQ_MAX 4096
@@ -184,4 +187,4 @@ int uniq_main(int argc, char **argv)
exit(0);
}
-/* $Id: uniq.c,v 1.9 2000/04/17 16:16:10 erik Exp $ */
+/* $Id: uniq.c,v 1.10 2000/05/12 19:41:47 erik Exp $ */
diff --git a/update.c b/update.c
index 18b13e8..14f1d3c 100644
--- a/update.c
+++ b/update.c
@@ -35,12 +35,15 @@ _syscall2(int, bdflush, int, func, int, data);
#endif /* __GLIBC__ */
static char update_usage[] =
- "update [options]\n\n"
- "Periodically flushes filesystem buffers.\n\n"
+ "update [options]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPeriodically flushes filesystem buffers.\n\n"
"Options:\n"
"\t-S\tforce use of sync(2) instead of flushing\n"
"\t-s SECS\tcall sync this often (default 30)\n"
- "\t-f SECS\tflush some buffers this often (default 5)\n";
+ "\t-f SECS\tflush some buffers this often (default 5)\n"
+#endif
+ ;
static unsigned int sync_duration = 30;
static unsigned int flush_duration = 5;
diff --git a/usleep.c b/usleep.c
index dcb40d6..34008a6 100644
--- a/usleep.c
+++ b/usleep.c
@@ -25,7 +25,11 @@
#include <stdlib.h>
#include <unistd.h>
-const char usleep_usage[] = "usleep N\n\n" "Pause for N microseconds.\n";
+const char usleep_usage[] = "usleep N\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPause for N microseconds.\n"
+#endif
+ ;
extern int usleep_main(int argc, char **argv)
{
diff --git a/util-linux/fbset.c b/util-linux/fbset.c
index 4e5609e..de4c824 100644
--- a/util-linux/fbset.c
+++ b/util-linux/fbset.c
@@ -105,9 +105,9 @@ struct cmdoptions_t {
"-vsync", 1, CMD_VSYNC}, {
"-laced", 1, CMD_LACED}, {
"-double", 1, CMD_DOUBLE}, {
- "--help", 0, CMD_HELP}, {
+ "-help", 0, CMD_HELP}, {
#ifdef BB_FEATURE_FBSET_FANCY
- "--help", 0, CMD_HELP}, {
+ "-help", 0, CMD_HELP}, {
"-all", 0, CMD_ALL}, {
"-xres", 1, CMD_XRES}, {
"-yres", 1, CMD_YRES}, {
@@ -115,7 +115,7 @@ struct cmdoptions_t {
"-vyres", 1, CMD_VYRES}, {
"-depth", 1, CMD_DEPTH}, {
"-match", 0, CMD_MATCH}, {
- "--geometry", 5, CMD_GEOMETRY}, {
+ "-geometry", 5, CMD_GEOMETRY}, {
"-pixclock", 1, CMD_PIXCLOCK}, {
"-left", 1, CMD_LEFT}, {
"-right", 1, CMD_RIGHT}, {
@@ -123,7 +123,7 @@ struct cmdoptions_t {
"-lower", 1, CMD_LOWER}, {
"-hslen", 1, CMD_HSLEN}, {
"-vslen", 1, CMD_VSLEN}, {
- "--timings", 7, CMD_TIMING}, {
+ "-timings", 7, CMD_TIMING}, {
"-csync", 1, CMD_CSYNC}, {
"-gsync", 1, CMD_GSYNC}, {
"-extsync", 1, CMD_EXTSYNC}, {
@@ -221,17 +221,21 @@ static void showmode(struct fb_var_screeninfo *v)
static void fbset_usage(void)
{
+#ifndef BB_FEATURE_TRIVIAL_HELP
int i;
+#endif
#ifndef STANDALONE
fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n",
BB_VER, BB_BT);
#endif
- fprintf(stderr, "Usage: fbset [options] [mode]\n\n");
- fprintf(stderr, "Show and modify frame buffer device settings\n\n");
+ fprintf(stderr, "Usage: fbset [options] [mode]\n");
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ fprintf(stderr, "\nShows and modifies frame buffer device settings\n\n");
fprintf(stderr, "The following options are recognized:\n");
for (i = 0; g_cmdoptions[i].name; i++)
fprintf(stderr, "\t%s\n", g_cmdoptions[i].name);
+#endif
exit(-1);
}
diff --git a/util-linux/fdflush.c b/util-linux/fdflush.c
index 56ea224..4ec0a88 100644
--- a/util-linux/fdflush.c
+++ b/util-linux/fdflush.c
@@ -34,7 +34,11 @@ extern int fdflush_main(int argc, char **argv)
int fd;
if (argc <= 1 || **(++argv) == '-') {
- usage("fdflush device\n\nForce floppy disk drive to detect disk change\n");
+ usage("fdflush DEVICE\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nForces floppy disk drive to detect disk change\n"
+#endif
+ );
}
fd = open(*argv, 0);
diff --git a/util-linux/freeramdisk.c b/util-linux/freeramdisk.c
index d373bcb..4106cf1 100644
--- a/util-linux/freeramdisk.c
+++ b/util-linux/freeramdisk.c
@@ -34,8 +34,11 @@
static const char freeramdisk_usage[] =
- "freeramdisk DEVICE\n\n"
- "Free all memory used by the specified ramdisk.\n";
+ "freeramdisk DEVICE\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nFrees all memory used by the specified ramdisk.\n"
+#endif
+ ;
extern int
freeramdisk_main(int argc, char **argv)
diff --git a/util-linux/fsck_minix.c b/util-linux/fsck_minix.c
index c890dff..7d27566 100644
--- a/util-linux/fsck_minix.c
+++ b/util-linux/fsck_minix.c
@@ -198,9 +198,10 @@ static void show_usage(void)
{
fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n",
BB_VER, BB_BT);
- fprintf(stderr, "Usage: %s [-larvsmf] /dev/name\n\n", program_name);
+ fprintf(stderr, "Usage: %s [-larvsmf] /dev/name\n", program_name);
+#ifndef BB_FEATURE_TRIVIAL_HELP
fprintf(stderr,
- "Performs a consistency check for MINIX filesystems.\n\n");
+ "\nPerforms a consistency check for MINIX filesystems.\n\n");
fprintf(stderr, "OPTIONS:\n");
fprintf(stderr, "\t-l\tLists all filenames\n");
fprintf(stderr, "\t-r\tPerform interactive repairs\n");
@@ -210,6 +211,7 @@ static void show_usage(void)
fprintf(stderr,
"\t-m\tActivates MINIX-like \"mode not cleared\" warnings\n");
fprintf(stderr, "\t-f\tForce file system check.\n\n");
+#endif
leave(16);
}
diff --git a/util-linux/mkfs_minix.c b/util-linux/mkfs_minix.c
index be180a4..bf4bda9 100644
--- a/util-linux/mkfs_minix.c
+++ b/util-linux/mkfs_minix.c
@@ -179,9 +179,10 @@ static volatile void show_usage()
fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n",
BB_VER, BB_BT);
fprintf(stderr,
- "Usage: %s [-c | -l filename] [-nXX] [-iXX] /dev/name [blocks]\n\n",
+ "Usage: %s [-c | -l filename] [-nXX] [-iXX] /dev/name [blocks]\n",
program_name);
- fprintf(stderr, "Make a MINIX filesystem.\n\n");
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ fprintf(stderr, "\nMake a MINIX filesystem.\n\n");
fprintf(stderr, "OPTIONS:\n");
fprintf(stderr, "\t-c\t\tCheck the device for bad blocks\n");
fprintf(stderr,
@@ -191,6 +192,7 @@ static volatile void show_usage()
fprintf(stderr,
"\t-l FILENAME\tRead the bad blocks list from FILENAME\n");
fprintf(stderr, "\t-v\t\tMake a Minix version 2 filesystem\n\n");
+#endif
exit(16);
}
diff --git a/util-linux/mkswap.c b/util-linux/mkswap.c
index 17866a7..7d76916 100644
--- a/util-linux/mkswap.c
+++ b/util-linux/mkswap.c
@@ -49,13 +49,16 @@
static const char mkswap_usage[] =
- "mkswap [-c] [-v0|-v1] device [block-count]\n\n"
- "Prepare a disk partition to be used as a swap partition.\n\n"
+ "mkswap [-c] [-v0|-v1] device [block-count]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrepare a disk partition to be used as a swap partition.\n\n"
"Options:\n" "\t-c\t\tCheck for read-ability.\n"
"\t-v0\t\tMake version 0 swap [max 128 Megs].\n"
"\t-v1\t\tMake version 1 swap [big!] (default for kernels > 2.1.117).\n"
- "\tblock-count\tNumber of block to use (default is entire partition).\n";
+ "\tblock-count\tNumber of block to use (default is entire partition).\n"
+#endif
+ ;
#ifndef _IO
diff --git a/util-linux/more.c b/util-linux/more.c
index 30d2757..5044686 100644
--- a/util-linux/more.c
+++ b/util-linux/more.c
@@ -30,8 +30,15 @@
#include <fcntl.h>
#include <signal.h>
#include <sys/ioctl.h>
+#define BB_DECLARE_EXTERN
+#define bb_need_help
+#include "messages.c"
-static const char more_usage[] = "more [file ...]\n";
+static const char more_usage[] = "more [FILE ...]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nMore is a filter for viewing FILE one screenful at a time.\n"
+#endif
+ ;
/* ED: sparc termios is broken: revert back to old termio handling. */
#ifdef BB_FEATURE_USE_TERMIOS
@@ -92,7 +99,7 @@ extern int more_main(int argc, char **argv)
argv++;
if (argc > 0
- && (strcmp(*argv, "--help") == 0 || strcmp(*argv, "-h") == 0)) {
+ && (strcmp(*argv, dash_dash_help) == 0 || strcmp(*argv, "-h") == 0)) {
usage(more_usage);
}
do {
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 00a774a..bde55d1 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -64,10 +64,12 @@ static int use_loop = FALSE;
extern const char mtab_file[]; /* Defined in utility.c */
-static const char mount_usage[] = "\tmount [flags]\n"
- "\tmount [flags] device directory [-o options,more-options]\n"
- "\n" "Flags:\n"
- "\t-a:\t\tMount all file systems in fstab.\n"
+static const char mount_usage[] =
+ "mount [flags] device directory [-o options,more-options]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nMount a filesystem\n\n"
+ "Flags:\n"
+ "\t-a:\t\tMount all filesystems in fstab.\n"
#ifdef BB_MTAB
"\t-f:\t\t\"Fake\" mount. Add entry to mount table but don't mount it.\n"
"\t-n:\t\tDon't write a mount table entry.\n"
@@ -88,8 +90,10 @@ static const char mount_usage[] = "\tmount [flags]\n"
"\tsuid/nosuid:\tAllow set-user-id-root programs / disallow them.\n"
"\tremount:\tRe-mount a currently-mounted filesystem, changing its flags.\n"
"\tro/rw:\t\tMount for read-only / read-write.\n"
- "There are EVEN MORE flags that are specific to each filesystem.\n"
- "You'll have to see the written documentation for those.\n";
+ "\nThere are EVEN MORE flags that are specific to each filesystem.\n"
+ "You'll have to see the written documentation for those.\n"
+#endif
+ ;
struct mount_options {
@@ -451,7 +455,7 @@ extern int mount_main(int argc, char **argv)
fatalError( "\nCannot read /etc/fstab: %s\n", strerror (errno));
while ((m = getmntent(f)) != NULL) {
- // If the file system isn't noauto,
+ // If the filesystem isn't noauto,
// and isn't swap or nfs, then mount it
if ((!strstr(m->mnt_opts, "noauto")) &&
(!strstr(m->mnt_type, "swap")) &&
diff --git a/util-linux/swaponoff.c b/util-linux/swaponoff.c
index aa961da..0f8c4f5 100644
--- a/util-linux/swaponoff.c
+++ b/util-linux/swaponoff.c
@@ -36,16 +36,22 @@ static int whichApp;
static const char *appName;
static const char swapoff_usage[] =
- "swapoff [OPTION] [device]\n\n"
- "Stop swapping virtual memory pages on the given device.\n\n"
+ "swapoff [OPTION] [device]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nStop swapping virtual memory pages on the given device.\n\n"
"Options:\n"
- "\t-a\tStop swapping on all swap devices\n";
+ "\t-a\tStop swapping on all swap devices\n"
+#endif
+ ;
static const char swapon_usage[] =
- "swapon [OPTION] [device]\n\n"
- "Start swapping virtual memory pages on the given device.\n\n"
+ "swapon [OPTION] [device]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nStart swapping virtual memory pages on the given device.\n\n"
"Options:\n"
- "\t-a\tStart swapping on all swap devices\n";
+ "\t-a\tStart swapping on all swap devices\n"
+#endif
+ ;
#define SWAPON_APP 1
diff --git a/util-linux/umount.c b/util-linux/umount.c
index 18a5afe..86833b7 100644
--- a/util-linux/umount.c
+++ b/util-linux/umount.c
@@ -30,8 +30,10 @@
static const char umount_usage[] =
- "umount [flags] filesystem|directory\n\n"
- "Flags:\n" "\t-a:\tUnmount all file systems"
+ "umount [flags] filesystem|directory\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "Unmount file systems\n"
+ "\nFlags:\n" "\t-a:\tUnmount all file systems"
#ifdef BB_MTAB
" in /etc/mtab\n\t-n:\tDon't erase /etc/mtab entries\n"
#else
@@ -44,6 +46,7 @@ static const char umount_usage[] =
#if defined BB_FEATURE_MOUNT_LOOP
"\t-l:\tDo not free loop device (if a loop device has been used)\n"
#endif
+#endif
;
struct _mtab_entry_t {
diff --git a/utility.c b/utility.c
index 5899fe9..11ee7c6 100644
--- a/utility.c
+++ b/utility.c
@@ -33,6 +33,7 @@
|| defined (BB_INSMOD)
/* same conditions as recursiveAction */
#define bb_need_name_too_long
+#define bb_need_memory_exhausted
#endif
#define BB_DECLARE_EXTERN
#include "messages.c"
@@ -111,7 +112,6 @@ extern void fatalError(const char *s, ...)
exit( FALSE);
}
-#if defined BB_INIT
/* Returns kernel version encoded as major*65536 + minor*256 + patch,
* so, for example, to check if the kernel is greater than 2.2.11:
* if (get_kernel_revision() <= 2*65536+2*256+11) { <stuff> }
@@ -128,9 +128,7 @@ extern int get_kernel_revision(void)
sscanf(name.version, "%d.%d.%d", &major, &minor, &patch);
return major * 65536 + minor * 256 + patch;
}
-#endif /* BB_INIT */
-#if defined (BB_CP_MV) || defined (BB_DU)
#define HASH_SIZE 311 /* Should be prime */
#define hash_inode(i) ((i) % HASH_SIZE)
@@ -197,9 +195,7 @@ void reset_ino_dev_hashtable(void)
}
}
-#endif /* BB_CP_MV || BB_DU */
-#if defined (BB_CP_MV) || defined (BB_DU) || defined (BB_LN)
/*
* Return TRUE if a fileName is a directory.
* Nonexistant files return FALSE.
@@ -230,9 +226,7 @@ int isDirectory(const char *fileName, const int followLinks, struct stat *statBu
}
return status;
}
-#endif
-#if defined (BB_CP_MV)
/*
* Copy one file to another, while possibly preserving its modes, times, and
* modes. Returns TRUE if successful, or FALSE on a failure with an error
@@ -382,11 +376,8 @@ copyFile(const char *srcName, const char *destName,
return FALSE;
}
-#endif /* BB_CP_MV */
-
-#if defined BB_TAR || defined BB_LS
#define TYPEINDEX(mode) (((mode) >> 12) & 0x0f)
#define TYPECHAR(mode) ("0pcCd?bB-?l?s???" [TYPEINDEX(mode)])
@@ -429,10 +420,8 @@ const char *modeString(int mode)
}
return buf;
}
-#endif /* BB_TAR || BB_LS */
-#if defined BB_TAR
/*
* Return the standard ls-like time string from a time_t
* This is static and so is overwritten on each call.
@@ -457,9 +446,7 @@ const char *timeString(time_t timeVal)
return buf;
}
-#endif /* BB_TAR */
-#if defined BB_TAR || defined BB_CP_MV
/*
* Write all of the supplied buffer out to a file.
* This does multiple writes as necessary.
@@ -485,10 +472,8 @@ int fullWrite(int fd, const char *buf, int len)
return total;
}
-#endif /* BB_TAR || BB_CP_MV */
-#if defined BB_TAR || defined BB_TAIL
/*
* Read all of the supplied buffer from a file.
* This does multiple reads as necessary.
@@ -518,16 +503,8 @@ int fullRead(int fd, char *buf, int len)
return total;
}
-#endif /* BB_TAR || BB_TAIL */
-#if defined (BB_CHMOD_CHOWN_CHGRP) \
- || defined (BB_CP_MV) \
- || defined (BB_FIND) \
- || defined (BB_INSMOD) \
- || defined (BB_RM) \
- || defined (BB_TAR)
-
/*
* Walk down all the directories under the specified
* location, and do something (something specified
@@ -640,11 +617,9 @@ int recursiveAction(const char *fileName,
return TRUE;
}
-#endif /* BB_CHMOD_CHOWN_CHGRP || BB_CP_MV || BB_FIND || BB_LS || BB_INSMOD */
-#if defined (BB_TAR) || defined (BB_MKDIR)
/*
* Attempt to create the directories along the specified path, except for
* the final component. The mode is given for the final directory only,
@@ -674,15 +649,10 @@ extern int createPath(const char *name, int mode)
}
return TRUE;
}
-#endif /* BB_TAR || BB_MKDIR */
-#if defined (BB_CHMOD_CHOWN_CHGRP) || defined (BB_MKDIR)
/* [ugoa]{+|-|=}[rwxst] */
-
-
-
extern int parse_mode(const char *s, mode_t * theMode)
{
mode_t andMode =
@@ -775,14 +745,9 @@ extern int parse_mode(const char *s, mode_t * theMode)
}
-#endif /* BB_CHMOD_CHOWN_CHGRP || BB_MKDIR */
-
-
-#if defined BB_CHMOD_CHOWN_CHGRP || defined BB_PS || defined BB_LS || defined BB_TAR || defined BB_ID
-
/* This parses entries in /etc/passwd and /etc/group. This is desirable
* for BusyBox, since we want to avoid using the glibc NSS stuff, which
* increases target size and is often not needed or wanted for embedded
@@ -887,10 +852,6 @@ gid_t my_getpwnamegid(char *name)
return gid;
}
-#endif /* BB_CHMOD_CHOWN_CHGRP || BB_PS || BB_LS || BB_TAR || BB_ID */
-
-
-#if (defined BB_CHVT) || (defined BB_DEALLOCVT)
#include <linux/kd.h>
@@ -975,11 +936,9 @@ int get_console_fd(char *tty_name)
}
-#endif /* BB_CHVT || BB_DEALLOCVT */
-#if !defined BB_REGEXP && (defined BB_GREP || defined BB_SED)
-
+#if !defined BB_REGEXP
/* Do a case insensitive strstr() */
char *stristr(char *haystack, const char *needle)
{
@@ -1050,11 +1009,9 @@ extern int replace_match(char *haystack, char *needle, char *newNeedle,
else
return FALSE;
}
-
-#endif /* ! BB_REGEXP && (BB_GREP || BB_SED) */
+#endif /* ! BB_REGEXP */
-#if defined BB_FIND
/*
* Routine to see if a text string is matched by a wildcard pattern.
* Returns TRUE if the text is matched, or FALSE if it is not matched
@@ -1154,12 +1111,10 @@ extern int check_wildcard_match(const char *text, const char *pattern)
return TRUE;
}
-#endif /* BB_FIND */
-#if defined BB_DF || defined BB_MTAB
/*
* Given a block device, find the mount table entry if that block device
* is mounted.
@@ -1198,11 +1153,9 @@ extern struct mntent *findMountPoint(const char *name, const char *table)
endmntent(mountTable);
return mountEntry;
}
-#endif /* BB_DF || BB_MTAB */
-#if defined BB_DD || defined BB_TAIL
/*
* Read a number with a possible multiplier.
* Returns -1 if the number format is illegal.
@@ -1249,10 +1202,8 @@ extern long getNum(const char *cp)
return value;
}
-#endif /* BB_DD || BB_TAIL */
-#if defined BB_INIT || defined BB_SYSLOGD
/* try to open up the specified device */
extern int device_open(char *device, int mode)
{
@@ -1271,15 +1222,11 @@ extern int device_open(char *device, int mode)
fcntl(fd, F_SETFL, mode);
return fd;
}
-#endif /* BB_INIT BB_SYSLOGD */
-#if defined BB_KILLALL || ( defined BB_FEATURE_LINUXRC && ( defined BB_HALT || defined BB_REBOOT || defined BB_POWEROFF ))
#ifdef BB_FEATURE_USE_DEVPS_PATCH
#include <linux/devps.h>
-#endif
-#if defined BB_FEATURE_USE_DEVPS_PATCH
/* findPidByName()
*
* This finds the pid of the specified process,
@@ -1336,7 +1283,7 @@ extern pid_t* findPidByName( char* pidName)
&& (strlen(pidName) == strlen(info.command_line))) {
pidList=realloc( pidList, sizeof(pid_t) * (j+2));
if (pidList==NULL)
- fatalError("out of memory\n");
+ fatalError(memory_exhausted, "");
pidList[j++]=info.pid;
}
}
@@ -1409,7 +1356,7 @@ extern pid_t* findPidByName( char* pidName)
&& (strlen(pidName) == strlen(p))) {
pidList=realloc( pidList, sizeof(pid_t) * (i+2));
if (pidList==NULL)
- fatalError("out of memory\n");
+ fatalError(memory_exhausted, "");
pidList[i++]=strtol(next->d_name, NULL, 0);
}
}
@@ -1418,7 +1365,6 @@ extern pid_t* findPidByName( char* pidName)
return pidList;
}
#endif /* BB_FEATURE_USE_DEVPS_PATCH */
-#endif /* BB_KILLALL || ( BB_FEATURE_LINUXRC && ( BB_HALT || BB_REBOOT || BB_POWEROFF )) */
/* this should really be farmed out to libbusybox.a */
extern void *xmalloc(size_t size)
@@ -1426,11 +1372,11 @@ extern void *xmalloc(size_t size)
void *cp = malloc(size);
if (cp == NULL)
- fatalError("out of memory\n");
+ fatalError(memory_exhausted, "");
return cp;
}
-#if (__GLIBC__ < 2) && (defined BB_SYSLOGD || defined BB_INIT)
+#if (__GLIBC__ < 2)
extern int vdprintf(int d, const char *format, va_list ap)
{
char buf[BUF_SIZE];
@@ -1439,9 +1385,8 @@ extern int vdprintf(int d, const char *format, va_list ap)
len = vsprintf(buf, format, ap);
return write(d, buf, len);
}
-#endif /* BB_SYSLOGD */
+#endif
-#if defined BB_FEATURE_MOUNT_LOOP
extern int del_loop(const char *device)
{
int fd;
@@ -1525,9 +1470,7 @@ extern char *find_unused_loop_device(void)
}
return NULL;
}
-#endif /* BB_FEATURE_MOUNT_LOOP */
-#if defined BB_MOUNT || defined BB_DF || ( defined BB_UMOUNT && ! defined BB_MTAB)
extern int find_real_root_device_name(char* name)
{
DIR *dir;
@@ -1569,7 +1512,6 @@ extern int find_real_root_device_name(char* name)
return( FALSE);
}
-#endif
const unsigned int CSTRING_BUFFER_LENGTH = 128;
/* recursive parser that returns cstrings of arbitrary length
diff --git a/wc.c b/wc.c
index 030afa9..57bc713 100644
--- a/wc.c
+++ b/wc.c
@@ -23,15 +23,18 @@
#include "internal.h"
#include <stdio.h>
-static const char wc_usage[] = "wc [OPTION]... [FILE]...\n\n"
- "Print line, word, and byte counts for each FILE, and a total line if\n"
+static const char wc_usage[] = "wc [OPTION]... [FILE]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrint line, word, and byte counts for each FILE, and a total line if\n"
"more than one FILE is specified. With no FILE, read standard input.\n\n"
"Options:\n"
"\t-c\tprint the byte counts\n"
"\t-l\tprint the newline counts\n"
"\t-L\tprint the length of the longest line\n"
- "\t-w\tprint the word counts\n";
+ "\t-w\tprint the word counts\n"
+#endif
+ ;
static int total_lines, total_words, total_chars, max_length;
static int print_lines, print_words, print_chars, print_length;
diff --git a/whoami.c b/whoami.c
index f9d3f28..da58479 100644
--- a/whoami.c
+++ b/whoami.c
@@ -24,8 +24,11 @@
#include <stdio.h>
#include <pwd.h>
-static const char whoami_usage[] = "whoami\n\n"
- "Prints the user name associated with the current effective user id.\n";
+static const char whoami_usage[] = "whoami\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nPrints the user name associated with the current effective user id.\n"
+#endif
+ ;
extern int whoami_main(int argc, char **argv)
{
diff --git a/yes.c b/yes.c
index a822ebc..97b6f65 100644
--- a/yes.c
+++ b/yes.c
@@ -28,8 +28,11 @@ extern int yes_main(int argc, char **argv)
int i;
if (argc >=1 && *argv[1]=='-') {
- usage("yes [OPTION]... [STRING]...\n\n"
- "Repeatedly outputs a line with all specified STRING(s), or `y'.\n");
+ usage("yes [OPTION]... [STRING]...\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nRepeatedly outputs a line with all specified STRING(s), or `y'.\n"
+#endif
+ );
}
if (argc == 1) {