summaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils')
-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
27 files changed, 528 insertions, 72 deletions
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) {