diff -crN busybox-1.00-pre10-orig/applets/applets.c busybox-1.00-pre10/applets/applets.c
*** busybox-1.00-pre10-orig/applets/applets.c	Tue Apr  6 23:28:35 2004
--- busybox-1.00-pre10/applets/applets.c	Sat Dec  4 19:49:29 2004
***************
*** 90,103 ****
  
  
  
! extern void
! bb_show_usage (void)
  {
    const char *format_string;
    const char *usage_string = usage_messages;
    int i;
  
!   for (i = applet_using - applets; i > 0;) {
  	if (!*usage_string++) {
  	  --i;
  	}
--- 90,105 ----
  
  
  
! extern int
! bb_show_usage_noexit (void)
  {
    const char *format_string;
    const char *usage_string = usage_messages;
+   struct BB_applet *applet_cur;
    int i;
  
!   applet_cur = find_applet_by_name (bb_applet_name);
!   for (i = applet_cur - applets; i > 0;) {
  	if (!*usage_string++) {
  	  --i;
  	}
***************
*** 106,115 ****
    format_string = "%s\n\nUsage: %s %s\n\n";
    if (*usage_string == '\b')
  	format_string = "%s\n\nNo help available.\n\n";
!   fprintf (stderr, format_string, bb_msg_full_version, applet_using->name,
  		   usage_string);
  
!   exit (EXIT_FAILURE);
  }
  
  static int
--- 108,123 ----
    format_string = "%s\n\nUsage: %s %s\n\n";
    if (*usage_string == '\b')
  	format_string = "%s\n\nNo help available.\n\n";
!   fprintf (stderr, format_string, bb_msg_full_version, applet_cur->name,
  		   usage_string);
+   return (EXIT_FAILURE);
+ }
  
! extern void
! bb_show_usage (void)
! {
!   
!   exit (bb_show_usage_noexit());
  }
  
  static int
diff -crN busybox-1.00-pre10-orig/coreutils/cp.c busybox-1.00-pre10/coreutils/cp.c
*** busybox-1.00-pre10-orig/coreutils/cp.c	Sun Jan 25 14:50:28 2004
--- busybox-1.00-pre10/coreutils/cp.c	Sat Dec  4 19:49:29 2004
***************
*** 77,83 ****
--- 77,87 ----
  	flags ^= FILEUTILS_DEREFERENCE;		/* The sense of this flag was reversed. */
  
  	if (optind + 2 > argc) {
+ #ifdef CONFIG_FEATURE_BUILTIN_CP
+ 		return bb_show_usage_noexit();
+ #else
  		bb_show_usage();
+ #endif
  	}
  
  	last = argv[argc - 1];
***************
*** 88,94 ****
--- 92,102 ----
  		s_flags = cp_mv_stat2(*argv, &source_stat,
  								 (flags & FILEUTILS_DEREFERENCE) ? stat : lstat);
  		if ((s_flags < 0) || ((d_flags = cp_mv_stat(last, &dest_stat)) < 0)) {
+ #ifdef CONFIG_FEATURE_BUILTIN_CP
+ 			return(EXIT_FAILURE);
+ #else
  			exit(EXIT_FAILURE);
+ #endif
  		}
  		/* ...if neither is a directory or...  */
  		if ( !((s_flags | d_flags) & 2) ||
***************
*** 115,119 ****
--- 123,131 ----
  		free((void *) dest);
  	} while (1);
  
+ #ifdef CONFIG_FEATURE_BUILTIN_CP
+ 	return(status);
+ #else
  	exit(status);
+ #endif
  }
diff -crN busybox-1.00-pre10-orig/coreutils/echo.c busybox-1.00-pre10/coreutils/echo.c
*** busybox-1.00-pre10-orig/coreutils/echo.c	Mon Mar 15 17:28:20 2004
--- busybox-1.00-pre10/coreutils/echo.c	Sat Dec  4 19:49:29 2004
***************
*** 122,128 ****
--- 122,132 ----
  #endif
  
  DONE:
+ #ifdef CONFIG_FEATURE_BUILTIN_ECHO
+ 	return (bb_fflush_stdout_and_noexit(EXIT_SUCCESS));
+ #else
  	bb_fflush_stdout_and_exit(EXIT_SUCCESS);
+ #endif
  }
  
  /*-
diff -crN busybox-1.00-pre10-orig/coreutils/mkdir.c busybox-1.00-pre10/coreutils/mkdir.c
*** busybox-1.00-pre10-orig/coreutils/mkdir.c	Fri Jun 20 18:01:53 2003
--- busybox-1.00-pre10/coreutils/mkdir.c	Sat Dec  4 19:49:29 2004
***************
*** 60,66 ****
--- 60,71 ----
  		flags |= FILEUTILS_RECUR;
  
  	if (optind == argc) {
+ #ifdef CONFIG_FEATURE_BUILTIN_MKDIR
+ 		bb_show_usage_noexit();
+ 		return(EXIT_FAILURE);
+ #else
  		bb_show_usage();
+ #endif
  	}
  
  	argv += optind;
diff -crN busybox-1.00-pre10-orig/coreutils/test.c busybox-1.00-pre10/coreutils/test.c
*** busybox-1.00-pre10-orig/coreutils/test.c	Mon Mar 15 17:28:21 2004
--- busybox-1.00-pre10/coreutils/test.c	Sat Dec  4 19:49:29 2004
***************
*** 188,206 ****
--- 188,222 ----
  	/* Implement special cases from POSIX.2, section 4.62.4 */
  	switch (argc) {
  	case 1:
+ #ifdef CONFIG_FEATURE_BUILTIN_TEST
+ 		return(1);
+ #else
  		exit(1);
+ #endif
  	case 2:
+ #ifdef CONFIG_FEATURE_BUILTIN_TEST
+ 		return(*argv[1] == '\0');
+ #else
  		exit(*argv[1] == '\0');
+ #endif
  	case 3:
  		if (argv[1][0] == '!' && argv[1][1] == '\0') {
+ #ifdef CONFIG_FEATURE_BUILTIN_TEST
+ 			return(!(*argv[2] == '\0'));
+ #else
  			exit(!(*argv[2] == '\0'));
+ #endif
  		}
  		break;
  	case 4:
  		if (argv[1][0] != '!' || argv[1][1] != '\0') {
  			if (t_lex(argv[2]), t_wp_op && t_wp_op->op_type == BINOP) {
  				t_wp = &argv[1];
+ #ifdef CONFIG_FEATURE_BUILTIN_TEST
+ 				return(binop() == 0);
+ #else
  				exit(binop() == 0);
+ #endif
  			}
  		}
  		break;
***************
*** 208,214 ****
--- 224,234 ----
  		if (argv[1][0] == '!' && argv[1][1] == '\0') {
  			if (t_lex(argv[3]), t_wp_op && t_wp_op->op_type == BINOP) {
  				t_wp = &argv[2];
+ #ifdef CONFIG_FEATURE_BUILTIN_TEST
+ 				return(!(binop() == 0));
+ #else
  				exit(!(binop() == 0));
+ #endif
  			}
  		}
  		break;
diff -crN busybox-1.00-pre10-orig/include/libbb.h busybox-1.00-pre10/include/libbb.h
*** busybox-1.00-pre10-orig/include/libbb.h	Mon Mar 15 17:28:38 2004
--- busybox-1.00-pre10/include/libbb.h	Sat Dec  4 19:49:29 2004
***************
*** 90,95 ****
--- 90,96 ----
  #endif
  
  extern void bb_show_usage(void) __attribute__ ((noreturn));
+ extern int bb_show_usage_noexit(void);
  extern void bb_error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
  extern void bb_error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
  extern void bb_perror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
diff -crN busybox-1.00-pre10-orig/include/usage.h busybox-1.00-pre10/include/usage.h
*** busybox-1.00-pre10-orig/include/usage.h	Wed Apr 14 04:27:20 2004
--- busybox-1.00-pre10/include/usage.h	Sat Dec  4 19:49:29 2004
***************
*** 1795,1800 ****
--- 1795,1807 ----
  	"quit\n" \
  	"221 foobar closing connection\n"
  
+ #define nice_trivial_usage \
+ 	"[OPTION] [COMMAND [ARG]...]"
+ #define nice_full_usage \
+ 	"Run  COMMAND with an adjusted scheduling priority."
+ #define nice_example_usage \
+ 	"$ nice -n 0 /tmp/foo \n"
+ 
  #define netstat_trivial_usage \
  	"[-laenrtuwx]"
  #define netstat_full_usage \
diff -crN busybox-1.00-pre10-orig/init/Config.in busybox-1.00-pre10/init/Config.in
*** busybox-1.00-pre10-orig/init/Config.in	Wed Oct 22 18:58:21 2003
--- busybox-1.00-pre10/init/Config.in	Sat Dec  4 19:49:29 2004
***************
*** 43,48 ****
--- 43,55 ----
  	  Prevent init from logging some messages to the console
  	  during boot.
  
+ config CONFIG_FEATURE_SYSINIT_IGNORE_SIGCHLD
+ 	bool "  Ignore SIGCHLD in sysinit"
+ 	default n
+ 	depends on CONFIG_INIT
+ 	help
+ 	  Ignore SIGCHLD signal on running sysinit
+ 
  config CONFIG_HALT
  	bool "halt"
  	default y
diff -crN busybox-1.00-pre10-orig/init/init.c busybox-1.00-pre10/init/init.c
*** busybox-1.00-pre10-orig/init/init.c	Tue Apr 13 04:21:54 2004
--- busybox-1.00-pre10/init/init.c	Sat Dec  4 19:49:29 2004
***************
*** 628,633 ****
--- 628,636 ----
  	int status, wpid;
  
  	pid = run(a);
+ #ifdef CONFIG_FEATURE_SYSINIT_IGNORE_SIGCHLD
+ 	signal(SIGCHLD,SIG_IGN);
+ #endif
  	while (1) {
  		wpid = waitpid(pid,&status,0);
  		if (wpid == pid)
***************
*** 639,644 ****
--- 642,650 ----
  		/* FIXME other errors should maybe trigger an error, but allow
  		 * the program to continue */
  	}
+ #ifdef CONFIG_FEATURE_SYSINIT_IGNORE_SIGCHLD
+ 	signal(SIGCHLD,SIG_DFL);
+ #endif
  	return wpid;
  }
  
diff -crN busybox-1.00-pre10-orig/libbb/fflush_stdout_and_exit.c busybox-1.00-pre10/libbb/fflush_stdout_and_exit.c
*** busybox-1.00-pre10-orig/libbb/fflush_stdout_and_exit.c	Wed Mar 19 18:12:06 2003
--- busybox-1.00-pre10/libbb/fflush_stdout_and_exit.c	Sat Dec  4 19:49:29 2004
***************
*** 35,37 ****
--- 35,45 ----
  	}
  	exit(retval);
  }
+ 
+ int bb_fflush_stdout_and_noexit(int retval)
+ {
+ 	if (fflush(stdout)) {
+ 		retval = bb_default_error_retval;
+ 	}
+ 	return(retval);
+ }
diff -crN busybox-1.00-pre10-orig/libbb/interface.c busybox-1.00-pre10/libbb/interface.c
*** busybox-1.00-pre10-orig/libbb/interface.c	Mon Mar 15 17:28:42 2004
--- busybox-1.00-pre10/libbb/interface.c	Mon Dec  6 15:59:17 2004
***************
*** 2074,2084 ****
--- 2074,2093 ----
  
  	/* Create a channel to the NET kernel. */
  	if ((skfd = sockets_open(0)) < 0) {
+ #ifdef CONFIG_FEATURE_BUILTIN_IFCONFIG
+ 		bb_perror_msg("socket");
+ 		return(EXIT_FAILURE);
+ #else
  		bb_perror_msg_and_die("socket");
+ #endif
  	}
  
  	/* Do we have to show the current setup? */
  	status = if_print(ifname);
  	close(skfd);
+ #ifdef CONFIG_FEATURE_BUILTIN_IFCONFIG
+ 	return(status < 0);
+ #else
  	exit(status < 0);
+ #endif
  }
diff -crN busybox-1.00-pre10-orig/modutils/insmod.c busybox-1.00-pre10/modutils/insmod.c
*** busybox-1.00-pre10-orig/modutils/insmod.c	Tue Apr  6 20:56:26 2004
--- busybox-1.00-pre10/modutils/insmod.c	Mon Dec  6 15:58:16 2004
***************
*** 108,113 ****
--- 108,116 ----
  #define LOADBITS 1
  #endif
  
+ #if defined(CONFIG_FEATURE_BUILTIN_INSMOD) && !defined(CONFIG_FEATURE_CLEAN_UP)
+ #define CONFIG_FEATURE_CLEAN_UP
+ #endif
  
  #if defined(__arm__)
  #define CONFIG_USE_PLT_ENTRIES
***************
*** 4104,4115 ****
--- 4107,4127 ----
  					break;
  #endif
  				default:
+ #ifdef CONFIG_FEATURE_BUILTIN_INSMOD
+ 					bb_show_usage_noexit();
+ 					return(EXIT_FAILURE);
+ #else
  					bb_show_usage();
+ #endif
  			}
  		}
  
  	if (argv[optind] == NULL) {
+ #ifdef CONFIG_FEATURE_BUILTIN_INSMOD
+ 		return bb_show_usage_noexit();
+ #else
  		bb_show_usage();
+ #endif
  	}
  
  	/* Grab the module name */
***************
*** 4387,4392 ****
--- 4399,4407 ----
  		free(m_name);
  	}
  	free(m_filename);
+ #ifdef CONFIG_FEATURE_BUILTIN_INSMOD
+ 	m_filename = 0;
+ #endif
  #endif
  	return(exit_status);
  }
***************
*** 4430,4436 ****
--- 4445,4455 ----
  
  	filename = argv[1];
  	if (!filename) {
+ #ifdef CONFIG_FEATURE_BUILTIN_INSMOD
+ 		return bb_show_usage_noexit();
+ #else
  		bb_show_usage();
+ #endif
  		return -1;
  	}
  
diff -crN busybox-1.00-pre10-orig/networking/ifconfig.c busybox-1.00-pre10/networking/ifconfig.c
*** busybox-1.00-pre10-orig/networking/ifconfig.c	Wed Mar 31 20:30:08 2004
--- busybox-1.00-pre10/networking/ifconfig.c	Sat Dec  4 19:49:29 2004
***************
*** 328,341 ****
--- 328,352 ----
  #ifdef CONFIG_FEATURE_IFCONFIG_STATUS
  		return display_interfaces(argc ? *argv : NULL);
  #else
+ #ifdef CONFIG_FEATURE_BUILTIN_IFCONFIG
+ 		bb_error_msg
+ 			("ifconfig was not compiled with interface status display support.");
+ 		return(bb_default_error_retval);
+ #else
  		bb_error_msg_and_die
  			("ifconfig was not compiled with interface status display support.");
  #endif
+ #endif
  	}
  
  	/* Create a channel to the NET kernel. */
  	if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+ #ifdef CONFIG_FEATURE_BUILTIN_IFCONFIG
+ 		bb_perror_msg("socket");
+ 		return(bb_default_error_retval);
+ #else
  		bb_perror_msg_and_die("socket");
+ #endif
  	}
  
  	/* get interface name */
***************
*** 371,381 ****
--- 382,400 ----
  			mask = op->arg_flags;
  			a1op = Arg1Opt + (op - OptArray);
  			if (mask & A_NETMASK & did_flags) {
+ #ifdef CONFIG_FEATURE_BUILTIN_IFCONFIG
+ 				return bb_show_usage_noexit();
+ #else
  				bb_show_usage();
+ #endif
  			}
  			if (*++argv == NULL) {
  				if (mask & A_ARG_REQ) {
+ #ifdef CONFIG_FEATURE_BUILTIN_IFCONFIG
+ 					return bb_show_usage_noexit();
+ #else
  					bb_show_usage();
+ #endif
  				} else {
  					--argv;
  					mask &= A_SET_AFTER;	/* just for broadcast */
***************
*** 465,471 ****
--- 484,494 ----
  					} else {	/* A_CAST_HOST_COPY_IN_ETHER */
  						/* This is the "hw" arg case. */
  						if (strcmp("ether", *argv) || (*++argv == NULL)) {
+ #ifdef CONFIG_FEATURE_BUILTIN_IFCONFIG
+ 							return bb_show_usage_noexit();
+ #else
  							bb_show_usage();
+ #endif
  						}
  						safe_strncpy(host, *argv, (sizeof host));
  						if (in_ether(host, &sa)) {
diff -crN busybox-1.00-pre10-orig/networking/route.c busybox-1.00-pre10/networking/route.c
*** busybox-1.00-pre10-orig/networking/route.c	Sat Mar 20 08:27:08 2004
--- busybox-1.00-pre10/networking/route.c	Sat Dec  4 19:49:29 2004
***************
*** 678,684 ****
--- 678,688 ----
  			opt |= ROUTE_OPT_INET6;	/* Set flag for ipv6. */
  		} else
  #endif
+ #ifdef CONFIG_FEATURE_BUILTIN_ROUTE
+ 		return bb_show_usage_noexit();
+ #else
  		bb_show_usage();
+ #endif
  	}
  
  	argv += optind;
***************
*** 694,706 ****
--- 698,718 ----
  			displayroutes(noresolve, opt & ROUTE_OPT_e);
  
  		bb_xferror_stdout();
+ #ifdef CONFIG_FEATURE_BUILTIN_ROUTE
+ 		return bb_fflush_stdout_and_noexit(EXIT_SUCCESS);
+ #else
  		bb_fflush_stdout_and_exit(EXIT_SUCCESS);
+ #endif
  	}
  
  	/* Check verb.  At the moment, must be add, del, or delete. */
  	what = kw_lookup(tbl_verb, &argv);
  	if (!what || !*argv) {		/* Unknown verb or no more args. */
+ #ifdef CONFIG_FEATURE_BUILTIN_ROUTE
+ 		return bb_show_usage_noexit();
+ #else
  		bb_show_usage();
+ #endif
  	}
  
  #ifdef CONFIG_FEATURE_IPV6
diff -crN busybox-1.00-pre10-orig/shell/Config.in busybox-1.00-pre10/shell/Config.in
*** busybox-1.00-pre10-orig/shell/Config.in	Wed Apr  7 18:34:26 2004
--- busybox-1.00-pre10/shell/Config.in	Sat Dec  4 19:49:29 2004
***************
*** 53,58 ****
--- 53,128 ----
  	help
  	  Enable job control in the ash shell.
  
+ config CONFIG_ASH_PIPE_OPTIMIZATION
+         bool "  Enable ash pipe optimization "
+         default y
+         depends on CONFIG_ASH
+         help
+           Eliminate cat at the beginning of the pipe.
+ 
+ config CONFIG_FEATURE_BUILTIN_TEST
+ 	bool "  Builtin test command"
+  	default y
+  	depends on CONFIG_ASH || CONFIG_TEST
+  	help
+ 	  Builtin test command"
+ 
+ config CONFIG_FEATURE_BUILTIN_ECHO
+         bool "  Builtin echo command"
+         default y
+         depends on CONFIG_ASH || CONFIG_ECHO
+         help
+           Builtin echo command"
+ 
+ config CONFIG_FEATURE_BUILTIN_PIDOF
+         bool "  Builtin pidof command"
+         default y
+         depends on CONFIG_ASH || CONFIG_PIDOF
+         help
+           Builtin pidof command"
+ 
+ config CONFIG_FEATURE_BUILTIN_MKDIR
+         bool "  Builtin mkdir command"
+         default y
+         depends on CONFIG_ASH || CONFIG_MKDIR
+         help
+           Builtin mkdir command"
+ 
+ config CONFIG_FEATURE_BUILTIN_MOUNT
+         bool "  Builtin mount command"
+         default y
+         depends on CONFIG_ASH || CONFIG_MOUNT
+         help
+           Builtin mount command"
+ 
+ config CONFIG_FEATURE_BUILTIN_INSMOD
+         bool "  Builtin insmod command"
+         default y
+         depends on CONFIG_ASH || CONFIG_INSMOD
+         help
+           Builtin insmod command"
+ 
+ config CONFIG_FEATURE_BUILTIN_ROUTE
+         bool "  Builtin route command"
+         default y
+         depends on CONFIG_ASH || CONFIG_ROUTE
+         help
+           Builtin route command"
+ 
+ config CONFIG_FEATURE_BUILTIN_IFCONFIG
+         bool "  Builtin ifconfig command"
+         default y
+         depends on CONFIG_ASH || CONFIG_IFCONFIG
+         help
+           Builtin ifconfig command"
+ 
+ config CONFIG_FEATURE_BUILTIN_CP
+         bool "  Builtin cp command"
+         default y
+         depends on CONFIG_ASH || CONFIG_CP
+         help
+           Builtin cp command"
+ 
  config CONFIG_ASH_ALIAS
  	bool "  Enable alias support"
  	default y
diff -crN busybox-1.00-pre10-orig/shell/ash.c busybox-1.00-pre10/shell/ash.c
*** busybox-1.00-pre10-orig/shell/ash.c	Tue Apr 13 04:12:13 2004
--- busybox-1.00-pre10/shell/ash.c	Sat Dec  4 19:49:29 2004
***************
*** 1286,1291 ****
--- 1286,1318 ----
  #ifdef JOBS
  static int killcmd(int, char **);
  #endif
+ #ifdef CONFIG_FEATURE_BUILTIN_TEST
+ static int testcmd(int, char **);
+ #endif
+ #ifdef CONFIG_FEATURE_BUILTIN_ECHO
+ static int echocmd(int, char**);
+ #endif
+ #ifdef CONFIG_FEATURE_BUILTIN_PIDOF
+ static int pidofcmd(int, char **); 
+ #endif
+ #ifdef CONFIG_FEATURE_BUILTIN_MKDIR
+ static int mkdircmd(int, char **); 
+ #endif
+ #ifdef CONFIG_FEATURE_BUILTIN_MOUNT
+ static int mountcmd(int, char **); 
+ #endif
+ #ifdef CONFIG_FEATURE_BUILTIN_INSMOD
+ static int insmodcmd(int, char **); 
+ #endif
+ #ifdef CONFIG_FEATURE_BUILTIN_ROUTE
+ static int routecmd(int, char **); 
+ #endif
+ #ifdef CONFIG_FEATURE_BUILTIN_IFCONFIG
+ static int ifconfigcmd(int, char **); 
+ #endif
+ #ifdef CONFIG_FEATURE_BUILTIN_CP
+ static int cpcmd(int, char **); 
+ #endif
  
  /*      $NetBSD: mail.h,v 1.9 2002/11/24 22:35:40 christos Exp $        */
  
***************
*** 1308,1346 ****
  	/* unsigned flags; */
  };
  
- #ifdef CONFIG_ASH_CMDCMD
- # ifdef JOBS
- #  ifdef CONFIG_ASH_ALIAS
- #    define COMMANDCMD (builtincmd + 7)
- #    define EXECCMD (builtincmd + 10)
- #  else
- #    define COMMANDCMD (builtincmd + 6)
- #    define EXECCMD (builtincmd + 9)
- #  endif
- # else /* ! JOBS */
- #  ifdef CONFIG_ASH_ALIAS
- #    define COMMANDCMD (builtincmd + 6)
- #    define EXECCMD (builtincmd + 9)
- #  else
- #    define COMMANDCMD (builtincmd + 5)
- #    define EXECCMD (builtincmd + 8)
- #  endif
- # endif /* JOBS */
- #else   /* ! CONFIG_ASH_CMDCMD */
- # ifdef JOBS
- #  ifdef CONFIG_ASH_ALIAS
- #    define EXECCMD (builtincmd + 9)
- #  else
- #    define EXECCMD (builtincmd + 8)
- #  endif
- # else /* ! JOBS */
- #  ifdef CONFIG_ASH_ALIAS
- #    define EXECCMD (builtincmd + 8)
- #  else
- #    define EXECCMD (builtincmd + 7)
- #  endif
- # endif /* JOBS */
- #endif /* CONFIG_ASH_CMDCMD */
  
  #define BUILTIN_NOSPEC  "0"
  #define BUILTIN_SPECIAL "1"
--- 1335,1340 ----
***************
*** 1355,1418 ****
  #define IS_BUILTIN_REGULAR(builtincmd) ((builtincmd)->name[0] & 2)
  
  static const struct builtincmd builtincmd[] = {
! 	{ BUILTIN_SPEC_REG      ".", dotcmd },
! 	{ BUILTIN_SPEC_REG      ":", truecmd },
! #ifdef CONFIG_ASH_ALIAS
! 	{ BUILTIN_REG_ASSG      "alias", aliascmd },
! #endif
! #ifdef JOBS
! 	{ BUILTIN_REGULAR       "bg", bgcmd },
! #endif
! 	{ BUILTIN_SPEC_REG      "break", breakcmd },
! 	{ BUILTIN_REGULAR       "cd", cdcmd },
! 	{ BUILTIN_NOSPEC        "chdir", cdcmd },
! #ifdef CONFIG_ASH_CMDCMD
! 	{ BUILTIN_REGULAR       "command", commandcmd },
! #endif
! 	{ BUILTIN_SPEC_REG      "continue", breakcmd },
! 	{ BUILTIN_SPEC_REG      "eval", evalcmd },
! 	{ BUILTIN_SPEC_REG      "exec", execcmd },
! 	{ BUILTIN_SPEC_REG      "exit", exitcmd },
! 	{ BUILTIN_SPEC_REG_ASSG "export", exportcmd },
! 	{ BUILTIN_REGULAR       "false", falsecmd },
! #ifdef JOBS
! 	{ BUILTIN_REGULAR       "fg", fgcmd },
! #endif
! #ifdef CONFIG_ASH_GETOPTS
! 	{ BUILTIN_REGULAR       "getopts", getoptscmd },
! #endif
! 	{ BUILTIN_NOSPEC        "hash", hashcmd },
! #ifndef CONFIG_FEATURE_SH_EXTRA_QUIET
! 	{ BUILTIN_NOSPEC        "help", helpcmd },
! #endif
! #ifdef JOBS
! 	{ BUILTIN_REGULAR       "jobs", jobscmd },
! 	{ BUILTIN_REGULAR       "kill", killcmd },
! #endif
! #ifdef CONFIG_ASH_MATH_SUPPORT
! 	{ BUILTIN_NOSPEC        "let", letcmd },
! #endif
! 	{ BUILTIN_ASSIGN        "local", localcmd },
! 	{ BUILTIN_NOSPEC        "pwd", pwdcmd },
! 	{ BUILTIN_REGULAR       "read", readcmd },
! 	{ BUILTIN_SPEC_REG_ASSG "readonly", exportcmd },
! 	{ BUILTIN_SPEC_REG      "return", returncmd },
! 	{ BUILTIN_SPEC_REG      "set", setcmd },
! 	{ BUILTIN_SPEC_REG      "shift", shiftcmd },
! 	{ BUILTIN_SPEC_REG      "times", timescmd },
! 	{ BUILTIN_SPEC_REG      "trap", trapcmd },
! 	{ BUILTIN_REGULAR       "true", truecmd },
! 	{ BUILTIN_NOSPEC        "type", typecmd },
! 	{ BUILTIN_NOSPEC        "ulimit", ulimitcmd },
! 	{ BUILTIN_REGULAR       "umask", umaskcmd },
! #ifdef CONFIG_ASH_ALIAS
! 	{ BUILTIN_REGULAR       "unalias", unaliascmd },
! #endif
! 	{ BUILTIN_SPEC_REG      "unset", unsetcmd },
! 	{ BUILTIN_REGULAR       "wait", waitcmd },
  };
  
! #define NUMBUILTINS  (sizeof (builtincmd) / sizeof (struct builtincmd) )
  
  
  
--- 1349,1369 ----
  #define IS_BUILTIN_REGULAR(builtincmd) ((builtincmd)->name[0] & 2)
  
  static const struct builtincmd builtincmd[] = {
! #define BUILTIN_COMMAND_SPEC(code, str, func) {str, func},
! #include "ash.d"
! {}
  };
  
! enum {
! #define BUILTIN_COMMAND_SPEC(code, str, func) code,
! #include "ash.d"
! NUMBUILTINS
! };
!  
! #ifdef CONFIG_ASH_CMDCMD
! #define COMMANDCMD (builtincmd + COMMAND_CMD)
! #endif
! #define EXECCMD (builtincmd + EXEC_CMD)
  
  
  
***************
*** 3051,3056 ****
--- 3002,3024 ----
  }
  
  
+ static int
+ cat_file(union node *n)
+ {
+ #ifdef CONFIG_ASH_PIPE_OPTIMIZATION
+   if (n->type == NCMD
+             && n->ncmd.args != NULL
+       && strcmp(n->ncmd.args->narg.text, "cat") == 0
+             && n->ncmd.args->narg.next != NULL
+             && *n->ncmd.args->narg.next->narg.text != '-'
+       && n->ncmd.args->narg.next->narg.next == NULL)
+     {
+       return open(n->ncmd.args->narg.next->narg.text, O_RDONLY);
+     }
+ #endif
+   return -1;
+ }
+ 
  
  /*
   * Evaluate a pipeline.  All the processes in the pipeline are children
***************
*** 3080,3085 ****
--- 3048,3059 ----
  		prehash(lp->n);
  		pip[1] = -1;
  		if (lp->next) {
+ #ifdef CONFIG_ASH_PIPE_OPTIMIZATION
+                         if (prevfd < 0 && (prevfd = cat_file(lp->n)) >= 0) {
+ 			        // it is cat at the beginning of the pipe
+                                 continue;
+                         }
+ #endif
  			if (pipe(pip) < 0) {
  				close(prevfd);
  				error("Pipe call failed");
***************
*** 3127,3137 ****
--- 3101,3119 ----
  {
  	int saveherefd;
  
+ #ifdef CONFIG_ASH_PIPE_OPTIMIZATION
+ 	result->fd = cat_file(n);
+ #else
  	result->fd = -1;
+ #endif
  	result->buf = NULL;
  	result->nleft = 0;
  	result->jp = NULL;
+ #ifdef CONFIG_ASH_PIPE_OPTIMIZATION
+ 	if (n == NULL || result->fd >= 0) {
+ #else
  	if (n == NULL) {
+ #endif
  		goto out;
  	}
  
***************
*** 3594,3599 ****
--- 3576,3617 ----
  	}
  }
  
+ #define BUILTIN_FUNC(cmdname) \
+ static int cmdname##cmd(int argc, char **argv) \
+ { \
+ 	bb_applet_name = argv[0]; \
+ 	optind=0; \
+         return cmdname##_main(argc, argv); \
+ }
+ 
+ #ifdef CONFIG_FEATURE_BUILTIN_ECHO
+ BUILTIN_FUNC(echo)
+ #endif
+ #ifdef CONFIG_FEATURE_BUILTIN_TEST
+ BUILTIN_FUNC(test)
+ #endif
+ #ifdef CONFIG_FEATURE_BUILTIN_PIDOF
+ BUILTIN_FUNC(pidof)
+ #endif
+ #ifdef CONFIG_FEATURE_BUILTIN_MOUNT
+ BUILTIN_FUNC(mount)
+ #endif
+ #ifdef CONFIG_FEATURE_BUILTIN_MKDIR
+ BUILTIN_FUNC(mkdir)
+ #endif
+ #ifdef CONFIG_FEATURE_BUILTIN_INSMOD
+ BUILTIN_FUNC(insmod)
+ #endif
+ #ifdef CONFIG_FEATURE_BUILTIN_ROUTE
+ BUILTIN_FUNC(route)
+ #endif
+ #ifdef CONFIG_FEATURE_BUILTIN_IFCONFIG
+ BUILTIN_FUNC(ifconfig)
+ #endif
+ #ifdef CONFIG_FEATURE_BUILTIN_CP
+ BUILTIN_FUNC(cp)
+ #endif
+ 
  
  static int
  falsecmd(int argc, char **argv)
***************
*** 4971,4977 ****
--- 4989,5001 ----
  		ckfree(in.buf);
  	if (in.fd >= 0) {
  		close(in.fd);
+ #if 1 /* XXX */
+ 		if (in.jp != NULL) { 
+ 			back_exitstatus = waitforjob(in.jp);
+ 		}
+ #else
  		back_exitstatus = waitforjob(in.jp);
+ #endif
  	}
  	INTON;
  
diff -crN busybox-1.00-pre10-orig/shell/ash.d busybox-1.00-pre10/shell/ash.d
*** busybox-1.00-pre10-orig/shell/ash.d	Thu Jan  1 09:00:00 1970
--- busybox-1.00-pre10/shell/ash.d	Sat Dec  4 19:49:29 2004
***************
*** 0 ****
--- 1,88 ----
+ BUILTIN_COMMAND_SPEC(DOT_CMD,     BUILTIN_SPEC_REG      ".", dotcmd)
+ BUILTIN_COMMAND_SPEC(COMMA_CMD,   BUILTIN_SPEC_REG      ":", truecmd)
+ #ifdef CONFIG_FEATURE_BUILTIN_TEST
+ BUILTIN_COMMAND_SPEC(RPAR_CMD,    BUILTIN_REGULAR       "[", testcmd)
+ #endif
+ #ifdef CONFIG_ASH_ALIAS
+ BUILTIN_COMMAND_SPEC(ALIAS_CMD,   BUILTIN_REG_ASSG      "alias", aliascmd)
+ #endif
+ #ifdef JOBS
+ BUILTIN_COMMAND_SPEC(BG_CMD,      BUILTIN_REGULAR       "bg", bgcmd)
+ #endif
+ BUILTIN_COMMAND_SPEC(BREAK_CMD,   BUILTIN_SPEC_REG      "break", breakcmd)
+ BUILTIN_COMMAND_SPEC(CD_CMD,      BUILTIN_REGULAR       "cd", cdcmd)
+ BUILTIN_COMMAND_SPEC(CHDIR_CMD,   BUILTIN_NOSPEC        "chdir", cdcmd)
+ #ifdef CONFIG_ASH__CMD_CMD
+ BUILTIN_COMMAND_SPEC(COMMAND_CMD, BUILTIN_REGULAR       "command", commandcmd)
+ #endif
+ BUILTIN_COMMAND_SPEC(CONTINUE_CMD,BUILTIN_SPEC_REG      "continue", breakcmd)
+ #ifdef CONFIG_FEATURE_BUILTIN_CP
+ BUILTIN_COMMAND_SPEC(CP_CMD,    BUILTIN_REGULAR         "cp", cpcmd)
+ #endif
+ #ifdef CONFIG_FEATURE_BUILTIN_ECHO
+ BUILTIN_COMMAND_SPEC(ECHO_CMD,    BUILTIN_REGULAR       "echo", echocmd)
+ #endif
+ BUILTIN_COMMAND_SPEC(EVAL_CMD,    BUILTIN_SPEC_REG      "eval", evalcmd)
+ BUILTIN_COMMAND_SPEC(EXEC_CMD,    BUILTIN_SPEC_REG      "exec", execcmd)
+ BUILTIN_COMMAND_SPEC(EXIT_CMD,    BUILTIN_SPEC_REG      "exit", exitcmd)
+ BUILTIN_COMMAND_SPEC(EXPORT_CMD,  BUILTIN_SPEC_REG_ASSG "export", exportcmd)
+ BUILTIN_COMMAND_SPEC(FALSE_CMD,   BUILTIN_REGULAR       "false", falsecmd)
+ #ifdef JOBS
+ BUILTIN_COMMAND_SPEC(FG_CMD,      BUILTIN_REGULAR       "fg", fgcmd)
+ #endif
+ #ifdef CONFIG_ASH_GETOPTS
+ BUILTIN_COMMAND_SPEC(GETOPTS_CMD, BUILTIN_REGULAR       "getopts", getoptscmd)
+ #endif
+ BUILTIN_COMMAND_SPEC(HASH_CMD,    BUILTIN_NOSPEC        "hash", hashcmd)
+ #ifndef CONFIG_FEATURE_SH_EXTRA_QUIET
+ BUILTIN_COMMAND_SPEC(HELP_CMD,    BUILTIN_NOSPEC        "help", helpcmd)
+ #endif
+ #ifdef CONFIG_FEATURE_BUILTIN_IFCONFIG
+ BUILTIN_COMMAND_SPEC(IFCONFIG_CMD,BUILTIN_REGULAR      "ifconfig", ifconfigcmd)
+ #endif
+ #ifdef CONFIG_FEATURE_BUILTIN_INSMOD
+ BUILTIN_COMMAND_SPEC(INSMOD_CMD,    BUILTIN_REGULAR     "insmod", insmodcmd)
+ #endif
+ #ifdef JOBS
+ BUILTIN_COMMAND_SPEC(JOBS_CMD,    BUILTIN_REGULAR       "jobs", jobscmd)
+ BUILTIN_COMMAND_SPEC(KILL_CMD,    BUILTIN_REGULAR       "kill", killcmd)
+ #endif
+ #ifdef CONFIG_ASH_MATH_SUPPORT
+ BUILTIN_COMMAND_SPEC(LET_CMD,     BUILTIN_NOSPEC        "let", letcmd)
+ #endif
+ BUILTIN_COMMAND_SPEC(LOCAL_CMD,   BUILTIN_ASSIGN        "local", localcmd)
+ #ifdef CONFIG_FEATURE_BUILTIN_MKDIR
+ BUILTIN_COMMAND_SPEC(MKDIR_CMD,   BUILTIN_REGULAR       "mkdir", mkdircmd)
+ #endif
+ #ifdef CONFIG_FEATURE_BUILTIN_MOUNT
+ BUILTIN_COMMAND_SPEC(MOUNT_CMD,   BUILTIN_REGULAR       "mount", mountcmd)
+ #endif
+ #ifdef CONFIG_FEATURE_BUILTIN_PIDOF
+ BUILTIN_COMMAND_SPEC(PIDOF_CMD,   BUILTIN_REGULAR       "pidof", pidofcmd)
+ #endif
+ BUILTIN_COMMAND_SPEC(PWD_CMD,     BUILTIN_NOSPEC        "pwd", pwdcmd)
+ BUILTIN_COMMAND_SPEC(READ_CMD,    BUILTIN_REGULAR       "read", readcmd)
+ BUILTIN_COMMAND_SPEC(READONLY_CMD,BUILTIN_SPEC_REG_ASSG "readonly", exportcmd)
+ BUILTIN_COMMAND_SPEC(RETURN_CMD,  BUILTIN_SPEC_REG      "return", returncmd)
+ #ifdef CONFIG_FEATURE_BUILTIN_ROUTE
+ BUILTIN_COMMAND_SPEC(ROUTE_CMD,   BUILTIN_REGULAR       "route", routecmd)
+ #endif
+ BUILTIN_COMMAND_SPEC(SET_CMD,     BUILTIN_SPEC_REG      "set", setcmd)
+ BUILTIN_COMMAND_SPEC(SHIFT_CMD,   BUILTIN_SPEC_REG      "shift", shiftcmd)
+ #ifdef CONFIG_FEATURE_BUILTIN_TEST
+ BUILTIN_COMMAND_SPEC(TEST_CMD,    BUILTIN_REGULAR       "test", testcmd)
+ #endif
+ BUILTIN_COMMAND_SPEC(TIMES_CMD,   BUILTIN_SPEC_REG      "times", timescmd)
+ BUILTIN_COMMAND_SPEC(TRAP_CMD,    BUILTIN_SPEC_REG      "trap", trapcmd)
+ BUILTIN_COMMAND_SPEC(TRUE_CMD,    BUILTIN_REGULAR       "true", truecmd)
+ BUILTIN_COMMAND_SPEC(TYPE_CMD,    BUILTIN_NOSPEC        "type", typecmd)
+ BUILTIN_COMMAND_SPEC(ULIMIT_CMD,  BUILTIN_NOSPEC        "ulimit", ulimitcmd)
+ BUILTIN_COMMAND_SPEC(UMASK_CMD,   BUILTIN_REGULAR       "umask", umaskcmd)
+ #ifdef CONFIG_ASH_ALIAS
+ BUILTIN_COMMAND_SPEC(UNALIAS_CMD, BUILTIN_REGULAR       "unalias", unaliascmd)
+ #endif
+ BUILTIN_COMMAND_SPEC(UNSET_CMD,   BUILTIN_SPEC_REG      "unset", unsetcmd)
+ BUILTIN_COMMAND_SPEC(WAIT_CMD,    BUILTIN_REGULAR       "wait", waitcmd)
+ 
+ 
+ #undef BUILTIN_COMMAND_SPEC
diff -crN busybox-1.00-pre10-orig/util-linux/mount.c busybox-1.00-pre10/util-linux/mount.c
*** busybox-1.00-pre10-orig/util-linux/mount.c	Tue Apr 13 00:02:53 2004
--- busybox-1.00-pre10/util-linux/mount.c	Sat Dec  4 22:30:43 2004
***************
*** 60,65 ****
--- 60,69 ----
  #endif
  #endif
  
+ #if defined(CONFIG_FEATURE_BUILTIN_MOUNT) && !defined(CONFIG_FEATURE_CLEAN_UP)
+ #define CONFIG_FEATURE_CLEAN_UP
+ #endif
+ 
  enum {
  	MS_MGC_VAL = 0xc0ed0000,	/* Magic number indicatng "new" flags */
  	MS_RDONLY = 1,		/* Mount read-only */
***************
*** 359,365 ****
--- 363,371 ----
  	} else {
  		bb_perror_msg_and_die(bb_path_mtab_file);
  	}
+ #ifndef CONFIG_FEATURE_BUILTIN_MOUNT
  	exit(EXIT_SUCCESS);
+ #endif
  }
  
  extern int mount_main(int argc, char **argv)
***************
*** 409,419 ****
--- 415,434 ----
  			break;
  		case 'v':
  			break;		/* ignore -v */
+ 		default:
+ #ifdef CONFIG_FEATURE_BUILTIN_MOUNT
+ 			return(bb_show_usage_noexit());
+ #else
+ 			bb_show_usage();
+ #endif
  		}
  	}
  
  	if (!all && (optind == argc)) {
  		show_mounts(got_filesystemType ? filesystemType : NULL);
+ #ifdef CONFIG_FEATURE_BUILTIN_MOUNT
+ 		return(EXIT_SUCCESS);
+ #endif
  	}
  
  	if (optind < argc) {
