1 diff -Naur busybox-1.00-pre3.orig/coreutils/echo.c busybox-1.00-pre3/coreutils/echo.c
2 --- busybox-1.00-pre3.orig/coreutils/echo.c 2003-03-19 12:11:33.000000000 +0300
3 +++ busybox-1.00-pre3/coreutils/echo.c 2003-11-07 17:47:35.000000000 +0300
8 - bb_fflush_stdout_and_exit(EXIT_SUCCESS);
9 +#ifdef CONFIG_FEATURE_BUILTIN_ECHO
10 + return EXIT_SUCCESS;
12 + bb_fflush_stdout_and_exit(EXIT_SUCCESS);
17 diff -Naur busybox-1.00-pre3.orig/coreutils/test.c busybox-1.00-pre3/coreutils/test.c
18 --- busybox-1.00-pre3.orig/coreutils/test.c 2003-07-15 01:20:45.000000000 +0400
19 +++ busybox-1.00-pre3/coreutils/test.c 2003-11-07 17:47:35.000000000 +0300
21 /* Implement special cases from POSIX.2, section 4.62.4 */
27 - exit(*argv[1] == '\0');
28 + return (*argv[1] == '\0');
30 if (argv[1][0] == '!' && argv[1][1] == '\0') {
31 - exit(!(*argv[2] == '\0'));
32 + return (!(*argv[2] == '\0'));
36 if (argv[1][0] != '!' || argv[1][1] != '\0') {
37 if (t_lex(argv[2]), t_wp_op && t_wp_op->op_type == BINOP) {
40 + return (binop() == 0);
45 if (argv[1][0] == '!' && argv[1][1] == '\0') {
46 if (t_lex(argv[3]), t_wp_op && t_wp_op->op_type == BINOP) {
48 - exit(!(binop() == 0));
49 + return (!(binop() == 0));
53 diff -Naur busybox-1.00-pre3.orig/include/usage.h busybox-1.00-pre3/include/usage.h
54 --- busybox-1.00-pre3.orig/include/usage.h 2003-08-29 18:18:26.000000000 +0400
55 +++ busybox-1.00-pre3/include/usage.h 2003-11-07 17:47:59.000000000 +0300
56 @@ -1760,6 +1760,13 @@
58 "221 foobar closing connection\n"
60 +#define nice_trivial_usage \
61 + "[OPTION] [COMMAND [ARG]...]"
62 +#define nice_full_usage \
63 + "Run COMMAND with an adjusted scheduling priority."
64 +#define nice_example_usage \
65 + "$ nice -n 0 /tmp/foo \n"
67 #define netstat_trivial_usage \
69 #define netstat_full_usage \
70 diff -Naur busybox-1.00-pre3.orig/shell/Config.in busybox-1.00-pre3/shell/Config.in
71 --- busybox-1.00-pre3.orig/shell/Config.in 2003-09-12 08:51:25.000000000 +0400
72 +++ busybox-1.00-pre3/shell/Config.in 2003-11-07 17:47:59.000000000 +0300
75 Enable job control in the ash shell.
77 +config CONFIG_ASH_PIPE_OPTIMIZATION
78 + bool " Enable ash pipe optimization "
80 + depends on CONFIG_ASH
82 + Eliminate cat at the beginning of the pipe.
84 +config CONFIG_FEATURE_BUILTIN_TEST
85 + bool " Builtin test command"
87 + depends on CONFIG_ASH
89 + Builtin test command"
91 +config CONFIG_FEATURE_BUILTIN_ECHO
92 + bool " Builtin echo command"
94 + depends on CONFIG_ASH
96 + Builtin echo command"
98 +config CONFIG_FEATURE_BUILTIN_PIDOF
99 + bool " Builtin pidof command"
101 + depends on CONFIG_ASH && CONFIG_PIDOF
103 + Builtin pidof command"
105 config CONFIG_ASH_ALIAS
106 bool " Enable alias support"
108 diff -Naur busybox-1.00-pre3.orig/shell/ash.c busybox-1.00-pre3/shell/ash.c
109 --- busybox-1.00-pre3.orig/shell/ash.c 2003-09-02 06:36:17.000000000 +0400
110 +++ busybox-1.00-pre3/shell/ash.c 2003-11-07 17:47:59.000000000 +0300
111 @@ -1259,6 +1259,16 @@
113 static int killcmd(int, char **);
115 +#ifdef CONFIG_FEATURE_BUILTIN_TEST
116 +static int testcmd(int, char **);
118 +#ifdef CONFIG_FEATURE_BUILTIN_ECHO
119 +static int echocmd(int, char**);
121 +#ifdef CONFIG_FEATURE_BUILTIN_PIDOF
122 +static int pidofcmd(int, char **);
126 /* $NetBSD: mail.h,v 1.9 2002/11/24 22:35:40 christos Exp $ */
128 @@ -1281,39 +1291,6 @@
129 /* unsigned flags; */
132 -#ifdef CONFIG_ASH_CMDCMD
134 -# ifdef CONFIG_ASH_ALIAS
135 -# define COMMANDCMD (builtincmd + 7)
136 -# define EXECCMD (builtincmd + 10)
138 -# define COMMANDCMD (builtincmd + 6)
139 -# define EXECCMD (builtincmd + 9)
142 -# ifdef CONFIG_ASH_ALIAS
143 -# define COMMANDCMD (builtincmd + 6)
144 -# define EXECCMD (builtincmd + 9)
146 -# define COMMANDCMD (builtincmd + 5)
147 -# define EXECCMD (builtincmd + 8)
150 -#else /* ! CONFIG_ASH_CMDCMD */
152 -# ifdef CONFIG_ASH_ALIAS
153 -# define EXECCMD (builtincmd + 9)
155 -# define EXECCMD (builtincmd + 8)
158 -# ifdef CONFIG_ASH_ALIAS
159 -# define EXECCMD (builtincmd + 8)
161 -# define EXECCMD (builtincmd + 7)
164 -#endif /* CONFIG_ASH_CMDCMD */
166 #define BUILTIN_NOSPEC "0"
167 #define BUILTIN_SPECIAL "1"
168 @@ -1328,65 +1305,21 @@
169 #define IS_BUILTIN_REGULAR(builtincmd) ((builtincmd)->name[0] & 2)
171 static const struct builtincmd builtincmd[] = {
172 - { BUILTIN_SPEC_REG ".", dotcmd },
173 - { BUILTIN_SPEC_REG ":", truecmd },
174 -#ifdef CONFIG_ASH_ALIAS
175 - { BUILTIN_REG_ASSG "alias", aliascmd },
178 - { BUILTIN_REGULAR "bg", bgcmd },
180 - { BUILTIN_SPEC_REG "break", breakcmd },
181 - { BUILTIN_REGULAR "cd", cdcmd },
182 - { BUILTIN_NOSPEC "chdir", cdcmd },
183 -#ifdef CONFIG_ASH_CMDCMD
184 - { BUILTIN_REGULAR "command", commandcmd },
186 - { BUILTIN_SPEC_REG "continue", breakcmd },
187 - { BUILTIN_SPEC_REG "eval", evalcmd },
188 - { BUILTIN_SPEC_REG "exec", execcmd },
189 - { BUILTIN_SPEC_REG "exit", exitcmd },
190 - { BUILTIN_SPEC_REG_ASSG "export", exportcmd },
191 - { BUILTIN_REGULAR "false", falsecmd },
193 - { BUILTIN_REGULAR "fg", fgcmd },
195 -#ifdef CONFIG_ASH_GETOPTS
196 - { BUILTIN_REGULAR "getopts", getoptscmd },
198 - { BUILTIN_NOSPEC "hash", hashcmd },
199 -#ifndef CONFIG_FEATURE_SH_EXTRA_QUIET
200 - { BUILTIN_NOSPEC "help", helpcmd },
203 - { BUILTIN_REGULAR "jobs", jobscmd },
204 - { BUILTIN_REGULAR "kill", killcmd },
206 -#ifdef CONFIG_ASH_MATH_SUPPORT
207 - { BUILTIN_NOSPEC "let", letcmd },
209 - { BUILTIN_ASSIGN "local", localcmd },
210 - { BUILTIN_NOSPEC "pwd", pwdcmd },
211 - { BUILTIN_REGULAR "read", readcmd },
212 - { BUILTIN_SPEC_REG_ASSG "readonly", exportcmd },
213 - { BUILTIN_SPEC_REG "return", returncmd },
214 - { BUILTIN_SPEC_REG "set", setcmd },
215 - { BUILTIN_SPEC_REG "shift", shiftcmd },
216 - { BUILTIN_SPEC_REG "times", timescmd },
217 - { BUILTIN_SPEC_REG "trap", trapcmd },
218 - { BUILTIN_REGULAR "true", truecmd },
219 - { BUILTIN_NOSPEC "type", typecmd },
220 - { BUILTIN_NOSPEC "ulimit", ulimitcmd },
221 - { BUILTIN_REGULAR "umask", umaskcmd },
222 -#ifdef CONFIG_ASH_ALIAS
223 - { BUILTIN_REGULAR "unalias", unaliascmd },
225 - { BUILTIN_SPEC_REG "unset", unsetcmd },
226 - { BUILTIN_REGULAR "wait", waitcmd },
227 +#define BUILTIN_COMMAND_SPEC(code, str, func) {str, func},
232 -#define NUMBUILTINS (sizeof (builtincmd) / sizeof (struct builtincmd) )
234 +#define BUILTIN_COMMAND_SPEC(code, str, func) code,
239 +#ifdef CONFIG_ASH_CMDCMD
240 +#define COMMANDCMD (builtincmd + COMMAND_CMD)
242 +#define EXECCMD (builtincmd + EXEC_CMD)
246 @@ -1678,7 +1611,8 @@
250 - basepf.nextc = basepf.buf = basebuf;
251 + struct parsefile* pf = &basepf;
252 + pf->nextc = pf->buf = basebuf;
256 @@ -2678,6 +2612,14 @@
257 * Called to reset things after an exception.
260 +#ifdef CONFIG_FEATURE_BUILTIN_ECHO
262 +echocmd(int argc, char **argv)
264 + return echo_main(argc, argv);
271 @@ -3028,6 +2970,23 @@
276 +cat_file(union node *n)
278 +#ifdef CONFIG_ASH_PIPE_OPTIMIZATION
279 + if (n->type == NCMD
280 + && n->ncmd.args != NULL
281 + && strcmp(n->ncmd.args->narg.text, "cat") == 0
282 + && n->ncmd.args->narg.next != NULL
283 + && *n->ncmd.args->narg.next->narg.text != '-'
284 + && n->ncmd.args->narg.next->narg.next == NULL)
286 + return open(n->ncmd.args->narg.next->narg.text, O_RDONLY);
294 * Evaluate a pipeline. All the processes in the pipeline are children
295 @@ -3057,7 +3016,11 @@
299 - if (pipe(pip) < 0) {
300 + if (prevfd < 0 && (prevfd = cat_file(lp->n)) >= 0) {
301 + // it is cat at the beginning of the pipe
304 + if (pipe(pip) < 0) {
306 error("Pipe call failed");
308 @@ -3104,11 +3067,11 @@
313 + result->fd = cat_file(n);
318 + if (n == NULL || result->fd >= 0) {
322 @@ -3562,6 +3525,24 @@
326 +#ifdef CONFIG_FEATURE_BUILTIN_TEST
328 +testcmd(int argc, char** argv)
330 + bb_applet_name = argv[0];
331 + return test_main(argc, argv);
335 +#ifdef CONFIG_FEATURE_BUILTIN_PIDOF
337 +pidofcmd(int argc, char** argv)
339 + bb_applet_name = argv[0];
340 + return pidof_main(argc, argv);
346 falsecmd(int argc, char **argv)
347 @@ -4943,7 +4924,9 @@
351 - back_exitstatus = waitforjob(in.jp);
352 + if (in.jp != NULL) {
353 + back_exitstatus = waitforjob(in.jp);
358 diff -Naur busybox-1.00-pre3.orig/shell/ash.d busybox-1.00-pre3/shell/ash.d
359 --- busybox-1.00-pre3.orig/shell/ash.d 1970-01-01 03:00:00.000000000 +0300
360 +++ busybox-1.00-pre3/shell/ash.d 2003-11-07 17:47:59.000000000 +0300
362 +BUILTIN_COMMAND_SPEC(DOT_CMD, BUILTIN_SPEC_REG ".", dotcmd)
363 +BUILTIN_COMMAND_SPEC(COMMA_CMD, BUILTIN_SPEC_REG ":", truecmd)
364 +#ifdef CONFIG_FEATURE_BUILTIN_TEST
365 +BUILTIN_COMMAND_SPEC(RPAR_CMD, BUILTIN_REGULAR "[", testcmd)
367 +#ifdef CONFIG_ASH_ALIAS
368 +BUILTIN_COMMAND_SPEC(ALIAS_CMD, BUILTIN_REG_ASSG "alias", aliascmd)
371 +BUILTIN_COMMAND_SPEC(BG_CMD, BUILTIN_REGULAR "bg", bgcmd)
373 +BUILTIN_COMMAND_SPEC(BREAK_CMD, BUILTIN_SPEC_REG "break", breakcmd)
374 +BUILTIN_COMMAND_SPEC(CD_CMD, BUILTIN_REGULAR "cd", cdcmd)
375 +BUILTIN_COMMAND_SPEC(CHDIR_CMD, BUILTIN_NOSPEC "chdir", cdcmd)
376 +#ifdef CONFIG_ASH__CMD_CMD
377 +BUILTIN_COMMAND_SPEC(COMMAND_CMD, BUILTIN_REGULAR "command", commandcmd)
379 +BUILTIN_COMMAND_SPEC(CONTINUE_CMD,BUILTIN_SPEC_REG "continue", breakcmd)
380 +#ifdef CONFIG_FEATURE_BUILTIN_ECHO
381 +BUILTIN_COMMAND_SPEC(ECHO_CMD, BUILTIN_REGULAR "echo", echocmd)
383 +BUILTIN_COMMAND_SPEC(EVAL_CMD, BUILTIN_SPEC_REG "eval", evalcmd)
384 +BUILTIN_COMMAND_SPEC(EXEC_CMD, BUILTIN_SPEC_REG "exec", execcmd)
385 +BUILTIN_COMMAND_SPEC(EXIT_CMD, BUILTIN_SPEC_REG "exit", exitcmd)
386 +BUILTIN_COMMAND_SPEC(EXPORT_CMD, BUILTIN_SPEC_REG_ASSG "export", exportcmd)
387 +BUILTIN_COMMAND_SPEC(FALSE_CMD, BUILTIN_REGULAR "false", falsecmd)
389 +BUILTIN_COMMAND_SPEC(FG_CMD, BUILTIN_REGULAR "fg", fgcmd)
391 +#ifdef CONFIG_ASH_GETOPTS
392 +BUILTIN_COMMAND_SPEC(GETOPTS_CMD, BUILTIN_REGULAR "getopts", getoptscmd)
394 +BUILTIN_COMMAND_SPEC(HASH_CMD, BUILTIN_NOSPEC "hash", hashcmd)
395 +#ifndef CONFIG_FEATURE_SH_EXTRA_QUIET
396 +BUILTIN_COMMAND_SPEC(HELP_CMD, BUILTIN_NOSPEC "help", helpcmd)
399 +BUILTIN_COMMAND_SPEC(JOBS_CMD, BUILTIN_REGULAR "jobs", jobscmd)
400 +BUILTIN_COMMAND_SPEC(KILL_CMD, BUILTIN_REGULAR "kill", killcmd)
402 +#ifdef CONFIG_ASH_MATH_SUPPORT
403 +BUILTIN_COMMAND_SPEC(LET_CMD, BUILTIN_NOSPEC "let", letcmd)
405 +BUILTIN_COMMAND_SPEC(LOCAL_CMD, BUILTIN_ASSIGN "local", localcmd)
406 +#ifdef CONFIG_FEATURE_BUILTIN_PIDOF
407 +BUILTIN_COMMAND_SPEC(PIDOF_CMD, BUILTIN_REGULAR "pidof", pidofcmd)
409 +BUILTIN_COMMAND_SPEC(PWD_CMD, BUILTIN_NOSPEC "pwd", pwdcmd)
410 +BUILTIN_COMMAND_SPEC(READ_CMD, BUILTIN_REGULAR "read", readcmd)
411 +BUILTIN_COMMAND_SPEC(READONLY_CMD,BUILTIN_SPEC_REG_ASSG "readonly", exportcmd)
412 +BUILTIN_COMMAND_SPEC(RETURN_CMD, BUILTIN_SPEC_REG "return", returncmd)
413 +BUILTIN_COMMAND_SPEC(SET_CMD, BUILTIN_SPEC_REG "set", setcmd)
414 +BUILTIN_COMMAND_SPEC(SHIFT_CMD, BUILTIN_SPEC_REG "shift", shiftcmd)
415 +#ifdef CONFIG_FEATURE_BUILTIN_TEST
416 +BUILTIN_COMMAND_SPEC(TEST_CMD, BUILTIN_REGULAR "test", testcmd)
418 +BUILTIN_COMMAND_SPEC(TIMES_CMD, BUILTIN_SPEC_REG "times", timescmd)
419 +BUILTIN_COMMAND_SPEC(TRAP_CMD, BUILTIN_SPEC_REG "trap", trapcmd)
420 +BUILTIN_COMMAND_SPEC(TRUE_CMD, BUILTIN_REGULAR "true", truecmd)
421 +BUILTIN_COMMAND_SPEC(TYPE_CMD, BUILTIN_NOSPEC "type", typecmd)
422 +BUILTIN_COMMAND_SPEC(ULIMIT_CMD, BUILTIN_NOSPEC "ulimit", ulimitcmd)
423 +BUILTIN_COMMAND_SPEC(UMASK_CMD, BUILTIN_REGULAR "umask", umaskcmd)
424 +#ifdef CONFIG_ASH_ALIAS
425 +BUILTIN_COMMAND_SPEC(UNALIAS_CMD, BUILTIN_REGULAR "unalias", unaliascmd)
427 +BUILTIN_COMMAND_SPEC(UNSET_CMD, BUILTIN_SPEC_REG "unset", unsetcmd)
428 +BUILTIN_COMMAND_SPEC(WAIT_CMD, BUILTIN_REGULAR "wait", waitcmd)
431 +#undef BUILTIN_COMMAND_SPEC