aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/dump.h11
-rw-r--r--include/libbb.h216
-rw-r--r--include/usage.h97
3 files changed, 214 insertions, 110 deletions
diff --git a/include/dump.h b/include/dump.h
index 0e8dbe07f..3f4b480b2 100644
--- a/include/dump.h
+++ b/include/dump.h
@@ -38,5 +38,12 @@ typedef struct _fs { /* format strings */
38 int bcnt; 38 int bcnt;
39} FS; 39} FS;
40 40
41void add(char *fmt); 41extern void bb_dump_add(const char *fmt);
42int dump (char **argv); 42extern int bb_dump_dump (char **argv);
43extern int bb_dump_size(FS * fs);
44
45extern FS *bb_dump_fshead; /* head of format strings */
46extern int bb_dump_blocksize; /* data block size */
47extern int bb_dump_length; /* max bytes to read */
48extern enum _vflag bb_dump_vflag;
49extern off_t bb_dump_skip; /* bytes to skip */
diff --git a/include/libbb.h b/include/libbb.h
index 8cb72de8b..f79def321 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -28,6 +28,7 @@
28#include <stdarg.h> 28#include <stdarg.h>
29#include <sys/stat.h> 29#include <sys/stat.h>
30#include <sys/types.h> 30#include <sys/types.h>
31#include <termios.h>
31 32
32#include <netdb.h> 33#include <netdb.h>
33 34
@@ -86,84 +87,132 @@ char *strtok_r(char *s, const char *delim, char **ptrptr);
86#define MAX(a,b) (((a)>(b))?(a):(b)) 87#define MAX(a,b) (((a)>(b))?(a):(b))
87#endif 88#endif
88 89
89extern void show_usage(void) __attribute__ ((noreturn)); 90extern void bb_show_usage(void) __attribute__ ((noreturn));
90extern void error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))); 91extern void bb_error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
91extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))); 92extern void bb_error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
92extern void perror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))); 93extern void bb_perror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
93extern void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))); 94extern void bb_perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
94extern void vherror_msg(const char *s, va_list p); 95extern void bb_vherror_msg(const char *s, va_list p);
95extern void herror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))); 96extern void bb_herror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
96extern void herror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))); 97extern void bb_herror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
98
99extern void bb_perror_nomsg_and_die(void) __attribute__ ((noreturn));
100extern void bb_perror_nomsg(void);
97 101
98/* These two are used internally -- you shouldn't need to use them */ 102/* These two are used internally -- you shouldn't need to use them */
99extern void verror_msg(const char *s, va_list p); 103extern void bb_verror_msg(const char *s, va_list p) __attribute__ ((format (printf, 1, 0)));
100extern void vperror_msg(const char *s, va_list p); 104extern void bb_vperror_msg(const char *s, va_list p) __attribute__ ((format (printf, 1, 0)));
101 105
102const char *mode_string(int mode); 106extern const char *bb_mode_string(int mode);
103const char *time_string(time_t timeVal); 107extern int is_directory(const char *name, int followLinks, struct stat *statBuf);
104int is_directory(const char *name, int followLinks, struct stat *statBuf); 108
105int isDevice(const char *name); 109extern int remove_file(const char *path, int flags);
106 110extern int copy_file(const char *source, const char *dest, int flags);
107int remove_file(const char *path, int flags); 111extern ssize_t safe_read(int fd, void *buf, size_t count);
108int copy_file(const char *source, const char *dest, int flags); 112extern ssize_t bb_full_write(int fd, const void *buf, size_t len);
109int copy_file_chunk(FILE *src_file, FILE *dst_file, unsigned long long chunksize); 113extern ssize_t bb_full_read(int fd, void *buf, size_t len);
110char *buildName(const char *dirName, const char *fileName); 114extern int recursive_action(const char *fileName, int recurse,
111int makeString(int argc, const char **argv, char *buf, int bufLen); 115 int followLinks, int depthFirst,
112char *getChunk(int size);
113char *chunkstrdup(const char *str);
114void freeChunks(void);
115ssize_t safe_read(int fd, void *buf, size_t count);
116int full_write(int fd, const char *buf, int len);
117int full_read(int fd, char *buf, int len);
118int recursive_action(const char *fileName, int recurse, int followLinks, int depthFirst,
119 int (*fileAction) (const char *fileName, struct stat* statbuf, void* userData), 116 int (*fileAction) (const char *fileName, struct stat* statbuf, void* userData),
120 int (*dirAction) (const char *fileName, struct stat* statbuf, void* userData), 117 int (*dirAction) (const char *fileName, struct stat* statbuf, void* userData),
121 void* userData); 118 void* userData);
122 119
123extern int parse_mode( const char* s, mode_t* theMode); 120extern int bb_parse_mode( const char* s, mode_t* theMode);
124extern long bb_xgetlarg(char *arg, int base, long lower, long upper); 121extern long bb_xgetlarg(char *arg, int base, long lower, long upper);
125 122
123extern unsigned long bb_baud_to_value(speed_t speed);
124extern speed_t bb_value_to_baud(unsigned long value);
125
126extern int get_kernel_revision(void); 126extern int get_kernel_revision(void);
127 127
128extern int get_console_fd(void); 128extern int get_console_fd(void);
129extern struct mntent *find_mount_point(const char *name, const char *table); 129extern struct mntent *find_mount_point(const char *name, const char *table);
130extern void write_mtab(char* blockDevice, char* directory, 130extern void write_mtab(char* blockDevice, char* directory,
131 char* filesystemType, long flags, char* string_flags); 131 char* filesystemType, long flags, char* string_flags);
132extern void erase_mtab(const char * name); 132extern void erase_mtab(const char * name);
133extern long atoi_w_units (const char *cp); 133extern long *find_pid_by_name( const char* pidName);
134extern long* find_pid_by_name( const char* pidName);
135extern char *find_real_root_device_name(const char* name); 134extern char *find_real_root_device_name(const char* name);
136extern char *get_line_from_file(FILE *file); 135extern char *bb_get_line_from_file(FILE *file);
137extern void print_file(FILE *file); 136extern char *bb_get_chomped_line_from_file(FILE *file);
138extern int copyfd(int fd1, int fd2, const off_t chunksize); 137extern int bb_copyfd(int fd1, int fd2, const off_t chunksize);
139extern int print_file_by_name(char *filename); 138extern void bb_xprint_and_close_file(FILE *file);
140extern char process_escape_sequence(const char **ptr); 139extern int bb_xprint_file_by_name(const char *filename);
141extern char *get_last_path_component(char *path); 140extern char bb_process_escape_sequence(const char **ptr);
142extern FILE *wfopen(const char *path, const char *mode); 141extern char *bb_get_last_path_component(char *path);
143extern FILE *xfopen(const char *path, const char *mode); 142extern FILE *bb_wfopen(const char *path, const char *mode);
143extern FILE *bb_xfopen(const char *path, const char *mode);
144
145//#warning rename?
146extern int bb_fclose_nonstdin(FILE *f);
147extern void bb_fflush_stdout_and_exit(int retval) __attribute__ ((noreturn));
148extern unsigned long bb_getopt_ulflags(int argc, char **argv, const char *applet_opts);
149//#warning rename?
150extern FILE *bb_wfopen_input(const char *filename);
151
152extern int bb_vfprintf(FILE * __restrict stream, const char * __restrict format,
153 va_list arg) __attribute__ ((format (printf, 2, 0)));
154extern int bb_vprintf(const char * __restrict format, va_list arg)
155 __attribute__ ((format (printf, 1, 0)));
156extern int bb_fprintf(FILE * __restrict stream, const char * __restrict format, ...)
157 __attribute__ ((format (printf, 2, 3)));
158extern int bb_printf(const char * __restrict format, ...)
159 __attribute__ ((format (printf, 1, 2)));
160
161//#warning rename to xferror_filename?
162extern void bb_xferror(FILE *fp, const char *fn);
163extern void bb_xferror_stdout(void);
164extern void bb_xfflush_stdout(void);
165
166extern void bb_warn_ignoring_args(int n);
167
144extern void chomp(char *s); 168extern void chomp(char *s);
145extern void trim(char *s); 169extern void trim(char *s);
170extern const char *bb_skip_whitespace(const char *);
171
146extern struct BB_applet *find_applet_by_name(const char *name); 172extern struct BB_applet *find_applet_by_name(const char *name);
147void run_applet_by_name(const char *name, int argc, char **argv); 173void run_applet_by_name(const char *name, int argc, char **argv);
148 174
175//#warning is this needed anymore?
149#ifndef DMALLOC 176#ifndef DMALLOC
150extern void *xmalloc (size_t size); 177extern void *xmalloc (size_t size);
151extern void *xrealloc(void *old, size_t size); 178extern void *xrealloc(void *old, size_t size);
152extern void *xcalloc(size_t nmemb, size_t size); 179extern void *xcalloc(size_t nmemb, size_t size);
153extern char *xstrdup (const char *s); 180extern char *bb_xstrdup (const char *s);
154#endif 181#endif
155extern char *xstrndup (const char *s, int n); 182extern char *bb_xstrndup (const char *s, int n);
156extern char * safe_strncpy(char *dst, const char *src, size_t size); 183extern char * safe_strncpy(char *dst, const char *src, size_t size);
157 184
158struct suffix_mult { 185struct suffix_mult {
159 const char *suffix; 186 const char *suffix;
160 int mult; 187 unsigned int mult;
161}; 188};
162 189
163extern unsigned long parse_number(const char *numstr, 190extern unsigned long bb_xgetularg_bnd_sfx(const char *arg, int base,
191 unsigned long lower,
192 unsigned long upper,
193 const struct suffix_mult *suffixes);
194extern unsigned long bb_xgetularg_bnd(const char *arg, int base,
195 unsigned long lower,
196 unsigned long upper);
197extern unsigned long bb_xgetularg10_bnd(const char *arg,
198 unsigned long lower,
199 unsigned long upper);
200extern unsigned long bb_xgetularg10(const char *arg);
201
202extern long bb_xgetlarg_bnd_sfx(const char *arg, int base,
203 long lower,
204 long upper,
205 const struct suffix_mult *suffixes);
206extern long bb_xgetlarg10_sfx(const char *arg, const struct suffix_mult *suffixes);
207
208
209//#warning pitchable now?
210extern unsigned long bb_xparse_number(const char *numstr,
164 const struct suffix_mult *suffixes); 211 const struct suffix_mult *suffixes);
165 212
166 213
214//#warning change names?
215
167/* These parse entries in /etc/passwd and /etc/group. This is desirable 216/* These parse entries in /etc/passwd and /etc/group. This is desirable
168 * for BusyBox since we want to avoid using the glibc NSS stuff, which 217 * for BusyBox since we want to avoid using the glibc NSS stuff, which
169 * increases target size and is often not needed embedded systems. */ 218 * increases target size and is often not needed embedded systems. */
@@ -217,7 +266,7 @@ enum {
217}; 266};
218const char *make_human_readable_str(unsigned long size, unsigned long block_size, unsigned long display_unit); 267const char *make_human_readable_str(unsigned long size, unsigned long block_size, unsigned long display_unit);
219 268
220int ask_confirmation(void); 269int bb_ask_confirmation(void);
221int klogctl(int type, char * b, int len); 270int klogctl(int type, char * b, int len);
222 271
223char *xgetcwd(char *cwd); 272char *xgetcwd(char *cwd);
@@ -228,6 +277,7 @@ char *last_char_is(const char *s, int c);
228extern long arith (const char *startbuf, int *errcode); 277extern long arith (const char *startbuf, int *errcode);
229 278
230int read_package_field(const char *package_buffer, char **field_name, char **field_value); 279int read_package_field(const char *package_buffer, char **field_name, char **field_value);
280//#warning yuk!
231char *fgets_str(FILE *file, const char *terminating_string); 281char *fgets_str(FILE *file, const char *terminating_string);
232 282
233extern int uncompress(int fd_in, int fd_out); 283extern int uncompress(int fd_in, int fd_out);
@@ -239,19 +289,15 @@ extern int create_icmp_socket(void);
239extern int create_icmp6_socket(void); 289extern int create_icmp6_socket(void);
240extern int xconnect(const char *host, const char *port); 290extern int xconnect(const char *host, const char *port);
241 291
292//#warning wrap this?
242char *dirname (char *path); 293char *dirname (char *path);
243 294
244int make_directory (char *path, long mode, int flags); 295int bb_make_directory (char *path, long mode, int flags);
245 296
246const char *u_signal_names(const char *str_sig, int *signo, int startnum); 297const char *u_signal_names(const char *str_sig, int *signo, int startnum);
247char *simplify_path(const char *path); 298char *bb_simplify_path(const char *path);
248
249#define CT_AUTO 0
250#define CT_UNIX2DOS 1
251#define CT_DOS2UNIX 2
252/* extern int convert(char *fn, int ConvType); */
253 299
254enum { 300enum { /* DO NOT CHANGE THESE VALUES! cp.c depends on them. */
255 FILEUTILS_PRESERVE_STATUS = 1, 301 FILEUTILS_PRESERVE_STATUS = 1,
256 FILEUTILS_DEREFERENCE = 2, 302 FILEUTILS_DEREFERENCE = 2,
257 FILEUTILS_RECUR = 4, 303 FILEUTILS_RECUR = 4,
@@ -259,29 +305,31 @@ enum {
259 FILEUTILS_INTERACTIVE = 16 305 FILEUTILS_INTERACTIVE = 16
260}; 306};
261 307
262extern const char *applet_name; 308extern const char *bb_applet_name;
263extern const char * const full_version; 309
264extern const char * const name_too_long; 310extern const char * const bb_msg_full_version;
265extern const char * const omitting_directory; 311extern const char * const bb_msg_memory_exhausted;
266extern const char * const not_a_directory; 312extern const char * const bb_msg_invalid_date;
267extern const char * const memory_exhausted; 313extern const char * const bb_msg_io_error;
268extern const char * const invalid_date; 314extern const char * const bb_msg_write_error;
269extern const char * const invalid_option; 315extern const char * const bb_msg_name_longer_than_foo;
270extern const char * const io_error; 316extern const char * const bb_msg_unknown;
271extern const char * const dash_dash_help; 317extern const char * const bb_msg_can_not_create_raw_socket;
272extern const char * const write_error; 318extern const char * const bb_msg_perm_denied_are_you_root;
273extern const char * const too_few_args; 319extern const char * const bb_msg_standard_input;
274extern const char * const name_longer_than_foo; 320extern const char * const bb_msg_standard_output;
275extern const char * const unknown; 321
276extern const char * const can_not_create_raw_socket; 322extern const char * const bb_path_nologin_file;
277extern const char * const nologin_file; 323extern const char * const bb_path_passwd_file;
278extern const char * const passwd_file; 324extern const char * const bb_path_shadow_file;
279extern const char * const shadow_file; 325extern const char * const bb_path_gshadow_file;
280extern const char * const gshadow_file; 326extern const char * const bb_path_group_file;
281extern const char * const group_file; 327extern const char * const bb_path_securetty_file;
282extern const char * const securetty_file; 328extern const char * const bb_path_motd_file;
283extern const char * const motd_file; 329
284extern const char * const _path_login; 330extern const char bb_path_mtab_file[];
331
332extern int bb_default_error_retval;
285 333
286#ifdef CONFIG_FEATURE_DEVFS 334#ifdef CONFIG_FEATURE_DEVFS
287# define CURRENT_VC "/dev/vc/0" 335# define CURRENT_VC "/dev/vc/0"
@@ -309,6 +357,8 @@ extern const char * const _path_login;
309# define LOOP_FORMAT "/dev/loop%d" 357# define LOOP_FORMAT "/dev/loop%d"
310#endif 358#endif
311 359
360//#warning put these in .o files
361
312/* The following devices are the same on devfs and non-devfs systems. */ 362/* The following devices are the same on devfs and non-devfs systems. */
313#define CURRENT_TTY "/dev/tty" 363#define CURRENT_TTY "/dev/tty"
314#define CONSOLE_DEV "/dev/console" 364#define CONSOLE_DEV "/dev/console"
@@ -318,10 +368,10 @@ void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name);
318void reset_ino_dev_hashtable(void); 368void reset_ino_dev_hashtable(void);
319 369
320/* Stupid gcc always includes its own builtin strlen()... */ 370/* Stupid gcc always includes its own builtin strlen()... */
321extern size_t xstrlen(const char *string); 371extern size_t bb_strlen(const char *string);
322#define strlen(x) xstrlen(x) 372#define strlen(x) bb_strlen(x)
323 373
324void bb_asprintf(char **string_ptr, const char *format, ...) __attribute__ ((format (printf, 2, 3))); 374void bb_xasprintf(char **string_ptr, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
325 375
326 376
327#define FAIL_DELAY 3 377#define FAIL_DELAY 3
@@ -335,10 +385,10 @@ extern char *pw_encrypt(const char *clear, const char *salt);
335extern struct spwd *pwd_to_spwd(const struct passwd *pw); 385extern struct spwd *pwd_to_spwd(const struct passwd *pw);
336extern int obscure(const char *old, const char *newval, const struct passwd *pwdp); 386extern int obscure(const char *old, const char *newval, const struct passwd *pwdp);
337 387
338extern int xopen(const char *pathname, int flags); 388extern int bb_xopen(const char *pathname, int flags);
339extern ssize_t xread(int fd, void *buf, size_t count); 389extern ssize_t bb_xread(int fd, void *buf, size_t count);
340extern void xread_all(int fd, void *buf, size_t count); 390extern void bb_xread_all(int fd, void *buf, size_t count);
341extern unsigned char xread_char(int fd); 391extern unsigned char bb_xread_char(int fd);
342 392
343typedef struct { 393typedef struct {
344 int pid; 394 int pid;
diff --git a/include/usage.h b/include/usage.h
index 8fc12f151..bbc0babfc 100644
--- a/include/usage.h
+++ b/include/usage.h
@@ -98,9 +98,11 @@
98 "\t-y\tDisplay the entire year." 98 "\t-y\tDisplay the entire year."
99 99
100#define cat_trivial_usage \ 100#define cat_trivial_usage \
101 "[FILE]..." 101 "[-u] [FILE]..."
102#define cat_full_usage \ 102#define cat_full_usage \
103 "Concatenates FILE(s) and prints them to stdout." 103 "Concatenates FILE(s) and prints them to stdout.\n\n" \
104 "Options:\n" \
105 "\t-u\tignored since unbuffered i/o is always used"
104#define cat_example_usage \ 106#define cat_example_usage \
105 "$ cat /proc/uptime\n" \ 107 "$ cat /proc/uptime\n" \
106 "110716.72 17.67" 108 "110716.72 17.67"
@@ -397,20 +399,34 @@
397#define dpkg_deb_example_usage \ 399#define dpkg_deb_example_usage \
398 "$ dpkg-deb -X ./busybox_0.48-1_i386.deb /tmp\n" 400 "$ dpkg-deb -X ./busybox_0.48-1_i386.deb /tmp\n"
399 401
402#ifdef CONFIG_FEATURE_DU_DEFALT_BLOCKSIZE_1K
403#define USAGE_DU_DEFALT_BLOCKSIZE_1k(a) a
404#define USAGE_NOT_DU_DEFALT_BLOCKSIZE_1k(a)
405#else
406#define USAGE_DU_DEFALT_BLOCKSIZE_1k(a)
407#define USAGE_NOT_DU_DEFALT_BLOCKSIZE_1k(a) a
408#endif
409
400#define du_trivial_usage \ 410#define du_trivial_usage \
401 "[-lsx" USAGE_HUMAN_READABLE("hm") USAGE_NOT_HUMAN_READABLE("") "k] [FILE]..." 411 "[-aHLdclsx" USAGE_HUMAN_READABLE("hm") "k] [FILE]..."
402#define du_full_usage \ 412#define du_full_usage \
403 "Summarizes disk space used for each FILE and/or directory.\n" \ 413 "Summarizes disk space used for each FILE and/or directory.\n" \
404 "Disk space is printed in units of 1024 bytes.\n\n" \ 414 "Disk space is printed in units of " \
405 "Options:\n" \ 415 USAGE_DU_DEFALT_BLOCKSIZE_1k("1024") USAGE_NOT_DU_DEFALT_BLOCKSIZE_1k("512") \
416 " bytes.\n\n" \
417 "Options:\n" \
418 "\t-a\tshow sizes of files in addition to directories\n" \
419 "\t-H\tfollow symbolic links that are FILE command line args\n" \
420 "\t-L\tfollow all symbolic links encountered\n" \
421 "\t-d N\tlimit output to directories (and files with -a) of depth < N\n" \
422 "\t-c\toutput a grand total\n" \
406 "\t-l\tcount sizes many times if hard linked\n" \ 423 "\t-l\tcount sizes many times if hard linked\n" \
407 "\t-s\tdisplay only a total for each argument" \ 424 "\t-s\tdisplay only a total for each argument\n" \
408 USAGE_HUMAN_READABLE( \
409 "\n\t-h\tprint sizes in human readable format (e.g., 1K 243M 2G )\n" \
410 "\t-m\tprint sizes in megabytes\n" \
411 "\t-x\tskip directories on different filesystems\n" \ 425 "\t-x\tskip directories on different filesystems\n" \
412 "\t-k\tprint sizes in kilobytes(default)") USAGE_NOT_HUMAN_READABLE( \ 426 USAGE_HUMAN_READABLE( \
413 "\n\t-k\tprint sizes in kilobytes(compatibility)") 427 "\t-h\tprint sizes in human readable format (e.g., 1K 243M 2G )\n" \
428 "\t-m\tprint sizes in megabytes\n" ) \
429 "\t-k\tprint sizes in kilobytes" USAGE_DU_DEFALT_BLOCKSIZE_1k("(default)")
414#define du_example_usage \ 430#define du_example_usage \
415 "$ du\n" \ 431 "$ du\n" \
416 "16 ./CVS\n" \ 432 "16 ./CVS\n" \
@@ -451,25 +467,31 @@
451 "8|125||l4|||0|0|0|955637629|998367|0\n" \ 467 "8|125||l4|||0|0|0|955637629|998367|0\n" \
452 "6|245|tty1|1|LOGIN||0|0|0|955637630|998974|0\n" \ 468 "6|245|tty1|1|LOGIN||0|0|0|955637630|998974|0\n" \
453 "6|246|tty2|2|LOGIN||0|0|0|955637630|999498|0\n" \ 469 "6|246|tty2|2|LOGIN||0|0|0|955637630|999498|0\n" \
454 "7|336|pts/0|vt00andersen|andersen|:0.0|0|0|0|955637763|0|0\n" 470 "7|336|pts/0|vt00|andersen|:0.0|0|0|0|955637763|0|0\n"
471
472#ifdef CONFIG_FEATURE_FANCY_ECHO
473 #define USAGE_FANCY_ECHO(a) a
474#else
475 #define USAGE_FANCY_ECHO(a)
476#endif
455 477
456#define echo_trivial_usage \ 478#define echo_trivial_usage \
457 "[-neE] [ARG ...]" 479 USAGE_FANCY_ECHO("[-neE] ") "[ARG ...]"
458#define echo_full_usage \ 480#define echo_full_usage \
459 "Prints the specified ARGs to stdout\n\n" \ 481 "Prints the specified ARGs to stdout\n\n" \
460 "Options:\n" \ 482 USAGE_FANCY_ECHO("Options:\n" \
461 "\t-n\tsuppress trailing newline\n" \ 483 "\t-n\tsuppress trailing newline\n" \
462 "\t-e\tinterpret backslash-escaped characters (i.e., \\t=tab)\n" \ 484 "\t-e\tinterpret backslash-escaped characters (i.e., \\t=tab)\n" \
463 "\t-E\tdisable interpretation of backslash-escaped characters" 485 "\t-E\tdisable interpretation of backslash-escaped characters")
464#define echo_example_usage \ 486#define echo_example_usage \
465 "$ echo "Erik is cool"\n" \ 487 "$ echo "Erik is cool"\n" \
466 "Erik is cool\n" \ 488 "Erik is cool\n" \
467 "$ echo -e "Erik\\nis\\ncool"\n" \ 489 USAGE_FANCY_ECHO("$ echo -e "Erik\\nis\\ncool"\n" \
468 "Erik\n" \ 490 "Erik\n" \
469 "is\n" \ 491 "is\n" \
470 "cool\n" \ 492 "cool\n" \
471 "$ echo "Erik\\nis\\ncool"\n" \ 493 "$ echo "Erik\\nis\\ncool"\n" \
472 "Erik\\nis\\ncool\n" 494 "Erik\\nis\\ncool\n")
473 495
474#define env_trivial_usage \ 496#define env_trivial_usage \
475 "[-iu] [-] [name=value]... [command]" 497 "[-iu] [-] [name=value]... [command]"
@@ -757,6 +779,12 @@
757#define halt_full_usage \ 779#define halt_full_usage \
758 "Halt the system." 780 "Halt the system."
759 781
782#ifdef CONFIG_FEATURE_FANCY_HEAD
783#define USAGE_FANCY_HEAD(a) a
784#else
785#define USAGE_FANCY_HEAD(a)
786#endif
787
760#define head_trivial_usage \ 788#define head_trivial_usage \
761 "[OPTION] [FILE]..." 789 "[OPTION] [FILE]..."
762#define head_full_usage \ 790#define head_full_usage \
@@ -764,7 +792,11 @@
764 "With more than one FILE, precede each with a header giving the\n" \ 792 "With more than one FILE, precede each with a header giving the\n" \
765 "file name. With no FILE, or when FILE is -, read standard input.\n\n" \ 793 "file name. With no FILE, or when FILE is -, read standard input.\n\n" \
766 "Options:\n" \ 794 "Options:\n" \
767 "\t-n NUM\t\tPrint first NUM lines instead of first 10" 795 "\t-n NUM\t\tPrint first NUM lines instead of first 10" \
796 USAGE_FANCY_HEAD( \
797 "\n\t-c NUM\t\toutput the first NUM bytes\n" \
798 "\t-q\t\tnever output headers giving file names\n" \
799 "\t-v\t\talways output headers giving file names" )
768#define head_example_usage \ 800#define head_example_usage \
769 "$ head -n 2 /etc/passwd\n" \ 801 "$ head -n 2 /etc/passwd\n" \
770 "root:x:0:0:root:/root:/bin/bash\n" \ 802 "root:x:0:0:root:/root:/bin/bash\n" \
@@ -1762,7 +1794,7 @@
1762 "Remove (unlink) the FILE(s). You may use '--' to\n" \ 1794 "Remove (unlink) the FILE(s). You may use '--' to\n" \
1763 "indicate that all following arguments are non-options.\n\n" \ 1795 "indicate that all following arguments are non-options.\n\n" \
1764 "Options:\n" \ 1796 "Options:\n" \
1765 "\t-i\t\talways prompt before removing each destination" \ 1797 "\t-i\t\talways prompt before removing each destination\n" \
1766 "\t-f\t\tremove existing destinations, never prompt\n" \ 1798 "\t-f\t\tremove existing destinations, never prompt\n" \
1767 "\t-r or -R\tremove the contents of directories recursively" 1799 "\t-r or -R\tremove the contents of directories recursively"
1768#define rm_example_usage \ 1800#define rm_example_usage \
@@ -1864,14 +1896,26 @@
1864#define sha1sum_full_usage \ 1896#define sha1sum_full_usage \
1865 "[OPTION] [FILE]" 1897 "[OPTION] [FILE]"
1866 1898
1899#ifdef CONFIG_FEATURE_FANCY_SLEEP
1900 #define USAGE_FANCY_SLEEP(a) a
1901 #define USAGE_NOT_FANCY_SLEEP(a)
1902#else
1903 #define USAGE_FANCY_SLEEP(a)
1904 #define USAGE_NOT_FANCY_SLEEP(a) a
1905#endif
1906
1867#define sleep_trivial_usage \ 1907#define sleep_trivial_usage \
1868 "N" 1908 USAGE_FANCY_SLEEP("[") "N" USAGE_FANCY_SLEEP("]...")
1869#define sleep_full_usage \ 1909#define sleep_full_usage \
1870 "Pause for N seconds." 1910 USAGE_NOT_FANCY_SLEEP("Pause for N seconds.") \
1911 USAGE_FANCY_SLEEP( \
1912"Pause for a time equal to the total of the args given, where each arg can\n" \
1913"have an optional suffix of (s)econds, (m)inutes, (h)ours, or (d)ays.")
1871#define sleep_example_usage \ 1914#define sleep_example_usage \
1872 "$ sleep 2\n" \ 1915 "$ sleep 2\n" \
1873 "[2 second delay results]\n" 1916 "[2 second delay results]\n" \
1874 1917 USAGE_FANCY_SLEEP("$ sleep 1d 3h 22m 8s\n" \
1918 "[98528 second delay results]\n")
1875 1919
1876#ifdef CONFIG_FEATURE_SORT_UNIQUE 1920#ifdef CONFIG_FEATURE_SORT_UNIQUE
1877 #define USAGE_SORT_UNIQUE(a) a 1921 #define USAGE_SORT_UNIQUE(a) a
@@ -2077,7 +2121,8 @@
2077#define tee_full_usage \ 2121#define tee_full_usage \
2078 "Copy standard input to each FILE, and also to standard output.\n\n" \ 2122 "Copy standard input to each FILE, and also to standard output.\n\n" \
2079 "Options:\n" \ 2123 "Options:\n" \
2080 "\t-a\tappend to the given FILEs, do not overwrite" 2124 "\t-a\tappend to the given FILEs, do not overwrite\n" \
2125 "\t-i\tignore interrupt signals (SIGINT)"
2081#define tee_example_usage \ 2126#define tee_example_usage \
2082 "$ echo "Hello" | tee /tmp/foo\n" \ 2127 "$ echo "Hello" | tee /tmp/foo\n" \
2083 "$ cat /tmp/foo\n" \ 2128 "$ cat /tmp/foo\n" \
@@ -2312,7 +2357,9 @@
2312 "Options:\n" \ 2357 "Options:\n" \
2313 "\t-c\tprefix lines by the number of occurrences\n" \ 2358 "\t-c\tprefix lines by the number of occurrences\n" \
2314 "\t-d\tonly print duplicate lines\n" \ 2359 "\t-d\tonly print duplicate lines\n" \
2315 "\t-u\tonly print unique lines" 2360 "\t-u\tonly print unique lines\n" \
2361 "\t-f N\tskip the first N fields\n" \
2362 "\t-s N\tskip the first N chars (after any skipped fields)"
2316#define uniq_example_usage \ 2363#define uniq_example_usage \
2317 "$ echo -e \"a\\na\\nb\\nc\\nc\\na\" | sort | uniq\n" \ 2364 "$ echo -e \"a\\na\\nb\\nc\\nc\\na\" | sort | uniq\n" \
2318 "a\n" \ 2365 "a\n" \