diff --git a/shell/ash.c b/shell/ash.c
index 1a91f40..334dc22 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -24,27 +24,52 @@
  *
  * This version of ash is adapted from the source in Debian's ash 0.3.8-5
  * package.
+ * Maintainer Herbert Xu <herbert@debian.org> (C) 1997-2002
  *
- * Modified by Erik Andersen <andersen@codepoet.org> and
- * Vladimir Oleynik <dzo@simtreas.ru> to be used in busybox
+ * Modified by Vladimir Oleynik <dzo@simtreas.ru> to be used in busybox
  *
  *
  * Original copyright notice is retained at the end of this file.
  */
 
+/*
+ * The follow should be set to reflect the type of system you have:
+ *      JOBS -> 1 if you have Berkeley job control, 0 otherwise.
+ *      define SYSV if you are running under System V.
+ *      define DEBUG=1 to compile in debugging ('set -o debug' to turn on)
+ *      define DEBUG=2 to compile in and turn on debugging.
+ *
+ * When debugging is on, debugging info will be written to ./trace and
+ * a quit signal will generate a core dump.
+ */
 
-/* Enable this to compile in extra debugging noise.  When debugging is
- * on, debugging info will be written to $HOME/trace and a quit signal
- * will generate a core dump. */
-#undef DEBUG
 
-/* These are here to work with glibc -- Don't change these... */
-#undef FNMATCH_BROKEN
-#undef GLOB_BROKEN
+
 #define IFS_BROKEN
 
-#include <assert.h>
+#define PROFILE 0
+
+#ifdef DEBUG
+#define _GNU_SOURCE
+#endif
+
+#include <sys/types.h>
+#include <sys/cdefs.h>
+#include <sys/ioctl.h>
+#include <sys/param.h>
+#include <sys/resource.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <stdarg.h>
 #include <stddef.h>
+#include <assert.h>
 #include <ctype.h>
 #include <dirent.h>
 #include <errno.h>
@@ -53,185 +78,122 @@
 #include <paths.h>
 #include <setjmp.h>
 #include <signal.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <stdint.h>
 #include <sysexits.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/cdefs.h>
-#include <sys/ioctl.h>
-#include <sys/param.h>
-#include <sys/resource.h>
-#include <sys/time.h>
-#include <sys/times.h>
-#include <sys/types.h>
-#include <sys/wait.h>
+
+#include <fnmatch.h>
+#include <glob.h>
+
+
+
 #include "busybox.h"
 #include "pwd_.h"
 
-
-#if !defined(FNMATCH_BROKEN)
-#include <fnmatch.h>
-#endif
-#if !defined(GLOB_BROKEN)
-#include <glob.h>
-#endif
-
 #ifdef CONFIG_ASH_JOB_CONTROL
+#define JOBS 1
+#else
+#undif JOBS
+#endif
+
+#if JOBS
 #include <termios.h>
 #endif
 
 #include "cmdedit.h"
 
+#ifdef __GLIBC__
+/* glibc sucks */
+static int *dash_errno;
+#undef errno
+#define errno (*dash_errno)
+#endif
+
 #if defined(__uClinux__)
 #error "Do not even bother, ash will not run on uClinux"
 #endif
 
-/*
- * This file was generated by the mksyntax program.
- */
-
-/* Syntax classes */
-#define CWORD 0			/* character is nothing special */
-#define CNL 1			/* newline character */
-#define CBACK 2			/* a backslash character */
-#define CSQUOTE 3		/* single quote */
-#define CDQUOTE 4		/* double quote */
-#define CENDQUOTE 5		/* a terminating quote */
-#define CBQUOTE 6		/* backwards single quote */
-#define CVAR 7			/* a dollar sign */
-#define CENDVAR 8		/* a '}' character */
-#define CLP 9			/* a left paren in arithmetic */
-#define CRP 10			/* a right paren in arithmetic */
-#define CENDFILE 11		/* end of file */
-#define CCTL 12			/* like CWORD, except it must be escaped */
-#define CSPCL 13		/* these terminate a word */
-#define CIGN 14			/* character should be ignored */
-
-#define SYNBASE 130
-#define PEOF -130
-
-#define PEOA -129
-
-#define TEOF 0
-#define TNL 1
-#define TREDIR 2
-#define TWORD 3
-#define TASSIGN 4
-#define TSEMI 5
-#define TBACKGND 6
-#define TAND 7
-#define TOR 8
-#define TPIPE 9
-#define TLP 10
-#define TRP 11
-#define TENDCASE 12
-#define TENDBQUOTE 13
-#define TNOT 14
-#define TCASE 15
-#define TDO 16
-#define TDONE 17
-#define TELIF 18
-#define TELSE 19
-#define TESAC 20
-#define TFI 21
-#define TFOR 22
-#define TIF 23
-#define TIN 24
-#define TTHEN 25
-#define TUNTIL 26
-#define TWHILE 27
-#define TBEGIN 28
-#define TEND 29
-
-
-
-/* control characters in argument strings */
-#define CTLESC '\201'
-#define CTLVAR '\202'
-#define CTLENDVAR '\203'
-#define CTLBACKQ '\204'
-#define CTLQUOTE 01		/* ored with CTLBACKQ code if in quotes */
-/*      CTLBACKQ | CTLQUOTE == '\205' */
-#define CTLARI  '\206'
-#define CTLENDARI '\207'
-#define CTLQUOTEMARK '\210'
-
-
-#define is_digit(c)     ((c)>='0' && (c)<='9')
-#define is_name(c)      (((c) < CTLESC || (c) > CTLENDARI) && ((c) == '_' || isalpha((unsigned char) (c))))
-#define is_in_name(c)   (((c) < CTLESC || (c) > CTLENDARI) && ((c) == '_' || isalnum((unsigned char) (c))))
-
-/*
- * is_special(c) evaluates to 1 for c in "!#$*-0123456789?@"; 0 otherwise
- * (assuming ascii char codes, as the original implementation did)
- */
-#define is_special(c) \
-    ( (((unsigned int)c) - 33 < 32) \
-			 && ((0xc1ff920dUL >> (((unsigned int)c) - 33)) & 1))
-
-#define digit_val(c)    ((c) - '0')
-
-
-#define S_DFL 1			/* default signal handling (SIG_DFL) */
-#define S_CATCH 2		/* signal is caught */
-#define S_IGN 3			/* signal is ignored (SIG_IGN) */
-#define S_HARD_IGN 4	/* signal is ignored permenantly */
-#define S_RESET 5		/* temporary - to reset a hard ignored sig */
-
-
-/* variable substitution byte (follows CTLVAR) */
-#define VSTYPE  0x0f	/* type of variable substitution */
-#define VSNUL   0x10	/* colon--treat the empty string as unset */
-#define VSQUOTE 0x80	/* inside double quotes--suppress splitting */
-
-/* values of VSTYPE field */
-#define VSNORMAL        0x1	/* normal variable:  $var or ${var} */
-#define VSMINUS         0x2	/* ${var-text} */
-#define VSPLUS          0x3	/* ${var+text} */
-#define VSQUESTION      0x4	/* ${var?message} */
-#define VSASSIGN        0x5	/* ${var=text} */
-#define VSTRIMLEFT      0x6	/* ${var#pattern} */
-#define VSTRIMLEFTMAX   0x7	/* ${var##pattern} */
-#define VSTRIMRIGHT     0x8	/* ${var%pattern} */
-#define VSTRIMRIGHTMAX  0x9	/* ${var%%pattern} */
-#define VSLENGTH        0xa	/* ${#var} */
-
-/* flags passed to redirect */
-#define REDIR_PUSH 01	/* save previous values of file descriptors */
-#define REDIR_BACKQ 02	/* save the command output to pipe */
-
-/*
- * BSD setjmp saves the signal mask, which violates ANSI C and takes time,
- * so we use _setjmp instead.
- */
-
-#if defined(BSD)
-#define setjmp(jmploc)  _setjmp(jmploc)
-#define longjmp(jmploc, val)    _longjmp(jmploc, val)
+#ifdef DEBUG
+#define _DIAGASSERT(assert_expr) assert(assert_expr)
+#else
+#define _DIAGASSERT(assert_expr)
 #endif
 
-/*
- * Most machines require the value returned from malloc to be aligned
- * in some way.  The following macro will get this right on many machines.
- */
 
-#ifndef ALIGN
-union align {
-	int i;
-	char *cp;
+#ifdef CONFIG_ASH_ALIAS
+/*      $NetBSD: alias.h,v 1.5 2002/11/24 22:35:38 christos Exp $       */
+
+#define ALIASINUSE      1
+#define ALIASDEAD       2
+
+struct alias {
+	struct alias *next;
+	char *name;
+	char *val;
+	int flag;
 };
 
-#define ALIGN(nbytes)   (((nbytes) + sizeof(union align) - 1) & ~(sizeof(union align) - 1))
+static struct alias *lookupalias(const char *, int);
+static int aliascmd(int, char **);
+static int unaliascmd(int, char **);
+static void rmaliases(void);
+static int unalias(const char *);
+static void printalias(const struct alias *);
 #endif
 
-#ifdef CONFIG_LOCALE_SUPPORT
-#include <locale.h>
-static void change_lc_all(const char *value);
-static void change_lc_ctype(const char *value);
-#endif
+/*      $NetBSD: cd.h,v 1.3 2002/11/24 22:35:39 christos Exp $  */
+
+
+static void    setpwd(const char *, int);
+
+/*      $NetBSD: error.h,v 1.15 2002/11/24 22:35:39 christos Exp $      */
+
+
+/*
+ * Types of operations (passed to the errmsg routine).
+ */
+
+
+static const char not_found_msg[] = "%s: not found";
+
+
+#define E_OPEN  "No such file"          /* opening a file */
+#define E_CREAT "Directory nonexistent" /* creating a file */
+#define E_EXEC  not_found_msg+4         /* executing a program */
+
+/*
+ * We enclose jmp_buf in a structure so that we can declare pointers to
+ * jump locations.  The global variable handler contains the location to
+ * jump to when an exception occurs, and the global variable exception
+ * contains a code identifying the exeception.  To implement nested
+ * exception handlers, the user should save the value of handler on entry
+ * to an inner scope, set handler to point to a jmploc structure for the
+ * inner scope, and restore handler on exit from the scope.
+ */
+
+struct jmploc {
+	jmp_buf loc;
+};
+
+static struct jmploc *handler;
+static int exception;
+static volatile int suppressint;
+static volatile sig_atomic_t intpending;
+
+static int exerrno;            /* Last exec error, error for EXEXEC */
+
+/* exceptions */
+#define EXINT 0         /* SIGINT received */
+#define EXERROR 1       /* a generic error */
+#define EXSHELLPROC 2   /* execute a shell procedure */
+#define EXEXEC 3        /* command execution failed */
+#define EXEXIT 4        /* exit the shell */
+#define EXSIG 5         /* trapped signal in wait(1) */
+
+
+/* do we generate EXSIG events */
+static int exsig;
+/* last pending signal */
+static volatile sig_atomic_t pendingsigs;
 
 /*
  * These macros allow the user to suspend the handling of interrupt signals
@@ -240,321 +202,81 @@
  * more fun than worrying about efficiency and portability. :-))
  */
 
-static void onint(void);
-static volatile int suppressint;
-static volatile int intpending;
+#define barrier() ({ __asm__ __volatile__ ("": : :"memory"); })
+#define INTOFF \
+	({ \
+		suppressint++; \
+		barrier(); \
+		0; \
+	})
+#define SAVEINT(v) ((v) = suppressint)
+#define RESTOREINT(v) \
+	({ \
+		barrier(); \
+		if ((suppressint = (v)) == 0 && intpending) onint(); \
+		0; \
+	})
+#define EXSIGON() \
+	({ \
+		exsig++; \
+		barrier(); \
+		if (pendingsigs) \
+			exraise(EXSIG); \
+		0; \
+	})
+/* EXSIG is turned off by evalbltin(). */
 
-#define INTOFF suppressint++
-#ifndef CONFIG_ASH_OPTIMIZE_FOR_SIZE
-#define INTON { if (--suppressint == 0 && intpending) onint(); }
-#define FORCEINTON {suppressint = 0; if (intpending) onint();}
-#else
-static void __inton(void);
-static void forceinton(void);
 
-#define INTON __inton()
+static void exraise(int) __attribute__((__noreturn__));
+static void onint(void) __attribute__((__noreturn__));
+
+static void error(const char *, ...) __attribute__((__noreturn__));
+static void exerror(int, const char *, ...) __attribute__((__noreturn__));
+
+static void sh_warnx(const char *, ...);
+
+#ifdef CONFIG_ASH_OPTIMIZE_FOR_SIZE
+static void
+inton(void) {
+	if (--suppressint == 0 && intpending) {
+		onint();
+	}
+}
+#define INTON inton()
+static void forceinton(void)
+{
+	suppressint = 0;
+	if (intpending)
+		onint();
+}
 #define FORCEINTON forceinton()
-#endif
-
-#define CLEAR_PENDING_INT intpending = 0
-#define int_pending() intpending
-
-
-typedef void *pointer;
-
-#ifndef NULL
-#define NULL (void *)0
-#endif
-
-static pointer stalloc(int);
-static void stunalloc(pointer);
-static void ungrabstackstr(char *, char *);
-static char *growstackstr(void);
-static char *makestrspace(size_t newlen);
-
-/*
- * Parse trees for commands are allocated in lifo order, so we use a stack
- * to make this more efficient, and also to avoid all sorts of exception
- * handling code to handle interrupts in the middle of a parse.
- *
- * The size 504 was chosen because the Ultrix malloc handles that size
- * well.
- */
-
-#define MINSIZE 504		/* minimum size of a block */
-
-
-struct stack_block {
-	struct stack_block *prev;
-	char space[MINSIZE];
-};
-
-static struct stack_block stackbase;
-static struct stack_block *stackp = &stackbase;
-static struct stackmark *markp;
-static char *stacknxt = stackbase.space;
-static int stacknleft = MINSIZE;
-
-
-#define equal(s1, s2)   (strcmp(s1, s2) == 0)
-
-#define stackblock() stacknxt
-#define stackblocksize() stacknleft
-#define STARTSTACKSTR(p)        p = stackblock(), sstrnleft = stackblocksize()
-
-#define STPUTC(c, p)    (--sstrnleft >= 0? (*p++ = (c)) : (p = growstackstr(), *p++ = (c)))
-#define CHECKSTRSPACE(n, p)     { if (sstrnleft < n) p = makestrspace(n); }
-#define STACKSTRNUL(p)  (sstrnleft == 0? (p = growstackstr(), *p = '\0') : (*p = '\0'))
-
-
-#define USTPUTC(c, p)   (--sstrnleft, *p++ = (c))
-#define STUNPUTC(p)     (++sstrnleft, --p)
-#define STTOPC(p)       p[-1]
-#define STADJUST(amount, p)     (p += (amount), sstrnleft -= (amount))
-#define grabstackstr(p) stalloc(stackblocksize() - sstrnleft)
-
-
-#ifdef DEBUG
-#define TRACE(param)    trace param
-typedef union node unode;
-static void trace(const char *, ...);
-static void trargs(char **);
-static void showtree(unode *);
-static void trputc(int);
-static void trputs(const char *);
-static void opentrace(void);
 #else
-#define TRACE(param)
-#endif
-
-#define NSEMI 0
-#define NCMD 1
-#define NPIPE 2
-#define NREDIR 3
-#define NBACKGND 4
-#define NSUBSHELL 5
-#define NAND 6
-#define NOR 7
-#define NIF 8
-#define NWHILE 9
-#define NUNTIL 10
-#define NFOR 11
-#define NCASE 12
-#define NCLIST 13
-#define NDEFUN 14
-#define NARG 15
-#define NTO 16
-#define NFROM 17
-#define NFROMTO 18
-#define NAPPEND 19
-#define NTOOV 20
-#define NTOFD 21
-#define NFROMFD 22
-#define NHERE 23
-#define NXHERE 24
-#define NNOT 25
+#define INTON \
+	({ \
+		barrier(); \
+		if (--suppressint == 0 && intpending) onint(); \
+		0; \
+	})
+#define FORCEINTON \
+	({ \
+		barrier(); \
+		suppressint = 0; \
+		if (intpending) onint(); \
+		0; \
+	})
+#endif /* CONFIG_ASH_OPTIMIZE_FOR_SIZE */
 
 /*
- * expandarg() flags
+ * BSD setjmp saves the signal mask, which violates ANSI C and takes time,
+ * so we use _setjmp instead.
  */
-#define EXP_FULL        0x1	/* perform word splitting & file globbing */
-#define EXP_TILDE       0x2	/* do normal tilde expansion */
-#define EXP_VARTILDE    0x4	/* expand tildes in an assignment */
-#define EXP_REDIR       0x8	/* file glob for a redirection (1 match only) */
-#define EXP_CASE        0x10	/* keeps quotes around for CASE pattern */
-#define EXP_RECORD      0x20	/* need to record arguments for ifs breakup */
 
+#if defined(BSD) && !defined(__SVR4) && !defined(__GLIBC__)
+#define setjmp(jmploc)  _setjmp(jmploc)
+#define longjmp(jmploc, val)    _longjmp(jmploc, val)
+#endif
 
-#define NOPTS   16
-
-static char optet_vals[NOPTS];
-
-static const char *const optlist[NOPTS] = {
-	"e" "errexit",
-	"f" "noglob",
-	"I" "ignoreeof",
-	"i" "interactive",
-	"m" "monitor",
-	"n" "noexec",
-	"s" "stdin",
-	"x" "xtrace",
-	"v" "verbose",
-	"V" "vi",
-	"E" "emacs",
-	"C" "noclobber",
-	"a" "allexport",
-	"b" "notify",
-	"u" "nounset",
-	"q" "quietprofile"
-};
-
-#define optent_name(optent) (optent+1)
-#define optent_letter(optent) optent[0]
-#define optent_val(optent) optet_vals[optent]
-
-#define eflag optent_val(0)
-#define fflag optent_val(1)
-#define Iflag optent_val(2)
-#define iflag optent_val(3)
-#define mflag optent_val(4)
-#define nflag optent_val(5)
-#define sflag optent_val(6)
-#define xflag optent_val(7)
-#define vflag optent_val(8)
-#define Vflag optent_val(9)
-#define Eflag optent_val(10)
-#define Cflag optent_val(11)
-#define aflag optent_val(12)
-#define bflag optent_val(13)
-#define uflag optent_val(14)
-#define qflag optent_val(15)
-
-
-/* Mode argument to forkshell.  Don't change FORK_FG or FORK_BG. */
-#define FORK_FG 0
-#define FORK_BG 1
-#define FORK_NOJOB 2
-
-
-struct nbinary {
-	int type;
-	union node *ch1;
-	union node *ch2;
-};
-
-
-struct ncmd {
-	int type;
-	int backgnd;
-	union node *assign;
-	union node *args;
-	union node *redirect;
-};
-
-
-struct npipe {
-	int type;
-	int backgnd;
-	struct nodelist *cmdlist;
-};
-
-
-struct nredir {
-	int type;
-	union node *n;
-	union node *redirect;
-};
-
-
-struct nif {
-	int type;
-	union node *test;
-	union node *ifpart;
-	union node *elsepart;
-};
-
-
-struct nfor {
-	int type;
-	union node *args;
-	union node *body;
-	char *var;
-};
-
-
-struct ncase {
-	int type;
-	union node *expr;
-	union node *cases;
-};
-
-
-struct nclist {
-	int type;
-	union node *next;
-	union node *pattern;
-	union node *body;
-};
-
-
-struct narg {
-	int type;
-	union node *next;
-	char *text;
-	struct nodelist *backquote;
-};
-
-
-struct nfile {
-	int type;
-	union node *next;
-	int fd;
-	union node *fname;
-	char *expfname;
-};
-
-
-struct ndup {
-	int type;
-	union node *next;
-	int fd;
-	int dupfd;
-	union node *vname;
-};
-
-
-struct nhere {
-	int type;
-	union node *next;
-	int fd;
-	union node *doc;
-};
-
-
-struct nnot {
-	int type;
-	union node *com;
-};
-
-
-union node {
-	int type;
-	struct nbinary nbinary;
-	struct ncmd ncmd;
-	struct npipe npipe;
-	struct nredir nredir;
-	struct nif nif;
-	struct nfor nfor;
-	struct ncase ncase;
-	struct nclist nclist;
-	struct narg narg;
-	struct nfile nfile;
-	struct ndup ndup;
-	struct nhere nhere;
-	struct nnot nnot;
-};
-
-
-struct nodelist {
-	struct nodelist *next;
-	union node *n;
-};
-
-struct backcmd {		/* result of evalbackcmd */
-	int fd;				/* file descriptor to read from */
-	char *buf;			/* buffer */
-	int nleft;			/* number of chars in buffer */
-	struct job *jp;		/* job structure for command */
-};
-
-struct cmdentry {
-	int cmdtype;
-	union param {
-		int index;
-		union node *func;
-		const struct builtincmd *cmd;
-	} u;
-};
+/*      $NetBSD: expand.h,v 1.13 2002/11/24 22:35:40 christos Exp $     */
 
 struct strlist {
 	struct strlist *next;
@@ -567,135 +289,511 @@
 	struct strlist **lastp;
 };
 
-struct strpush {
-	struct strpush *prev;	/* preceding string on stack */
-	char *prevstring;
-	int prevnleft;
-#ifdef CONFIG_ASH_ALIAS
-	struct alias *ap;	/* if push was associated with an alias */
+/*
+ * expandarg() flags
+ */
+#define EXP_FULL        0x1     /* perform word splitting & file globbing */
+#define EXP_TILDE       0x2     /* do normal tilde expansion */
+#define EXP_VARTILDE    0x4     /* expand tildes in an assignment */
+#define EXP_REDIR       0x8     /* file glob for a redirection (1 match only) */
+#define EXP_CASE        0x10    /* keeps quotes around for CASE pattern */
+#define EXP_RECORD      0x20    /* need to record arguments for ifs breakup */
+#define EXP_VARTILDE2   0x40    /* expand tildes after colons only */
+#define EXP_WORD        0x80    /* expand word in parameter expansion */
+#define EXP_QWORD       0x100   /* expand word in quoted parameter expansion */
+
+
+union node;
+static void expandarg(union node *, struct arglist *, int);
+#define rmescapes(p) _rmescapes((p), 0)
+static char *_rmescapes(char *, int);
+static int casematch(union node *, char *);
+
+#ifdef CONFIG_ASH_MATH_SUPPORT
+static void expari(int);
 #endif
-	char *string;		/* remember the string since it may change */
-};
 
-struct parsefile {
-	struct parsefile *prev;	/* preceding file on stack */
-	int linno;			/* current line */
-	int fd;				/* file descriptor (or -1 if string) */
-	int nleft;			/* number of chars left in this line */
-	int lleft;			/* number of chars left in this buffer */
-	char *nextc;		/* next char in buffer */
-	char *buf;			/* input buffer */
-	struct strpush *strpush;	/* for pushing strings at this level */
-	struct strpush basestrpush;	/* so pushing one is fast */
-};
+/*      $NetBSD: eval.h,v 1.13 2002/11/24 22:35:39 christos Exp $       */
 
-struct stackmark {
-	struct stack_block *stackp;
-	char *stacknxt;
-	int stacknleft;
-	struct stackmark *marknext;
-};
+static char *commandname;              /* currently executing command */
+static struct strlist *cmdenviron;     /* environment for builtin command */
+static int exitstatus;                 /* exit status of last command */
+static int back_exitstatus;            /* exit status of backquoted command */
 
-struct shparam {
-	int nparam;			/* # of positional parameters (without $0) */
-	unsigned char malloc;	/* if parameter list dynamically allocated */
-	char **p;			/* parameter list */
-	int optind;			/* next parameter to be processed by getopts */
-	int optoff;			/* used by getopts */
+
+struct backcmd {                /* result of evalbackcmd */
+	int fd;                 /* file descriptor to read from */
+	char *buf;              /* buffer */
+	int nleft;              /* number of chars in buffer */
+	struct job *jp;         /* job structure for command */
 };
 
 /*
- * When commands are first encountered, they are entered in a hash table.
- * This ensures that a full path search will not have to be done for them
- * on each invocation.
- *
- * We should investigate converting to a linear search, even though that
- * would make the command name "hash" a misnomer.
+ * This file was generated by the mknodes program.
  */
-#define CMDTABLESIZE 31	/* should be prime */
-#define ARB 1			/* actual size determined at run time */
+
+#define NCMD 0
+#define NPIPE 1
+#define NREDIR 2
+#define NBACKGND 3
+#define NSUBSHELL 4
+#define NAND 5
+#define NOR 6
+#define NSEMI 7
+#define NIF 8
+#define NWHILE 9
+#define NUNTIL 10
+#define NFOR 11
+#define NCASE 12
+#define NCLIST 13
+#define NDEFUN 14
+#define NARG 15
+#define NTO 16
+#define NCLOBBER 17
+#define NFROM 18
+#define NFROMTO 19
+#define NAPPEND 20
+#define NTOFD 21
+#define NFROMFD 22
+#define NHERE 23
+#define NXHERE 24
+#define NNOT 25
 
 
 
-struct tblentry {
-	struct tblentry *next;	/* next entry in hash chain */
-	union param param;	/* definition of builtin function */
-	short cmdtype;		/* index identifying command */
-	char rehash;		/* if set, cd done since entry created */
-	char cmdname[ARB];	/* name of command */
+struct ncmd {
+      int type;
+      union node *assign;
+      union node *args;
+      union node *redirect;
 };
 
 
-static struct tblentry *cmdtable[CMDTABLESIZE];
-static int builtinloc = -1;	/* index in path of %builtin, or -1 */
-static int exerrno = 0;	/* Last exec error */
+struct npipe {
+      int type;
+      int backgnd;
+      struct nodelist *cmdlist;
+};
 
 
-static void tryexec(char *, char **, char **);
-static void printentry(struct tblentry *, int);
-static void clearcmdentry(int);
-static struct tblentry *cmdlookup(const char *, int);
-static void delete_cmd_entry(void);
-static int path_change(const char *, int *);
+struct nredir {
+      int type;
+      union node *n;
+      union node *redirect;
+};
 
 
-static void flushall(void);
-static void out2fmt(const char *, ...)
-	__attribute__ ((__format__(__printf__, 1, 2)));
-static int xwrite(int, const char *, int);
+struct nbinary {
+      int type;
+      union node *ch1;
+      union node *ch2;
+};
 
-static inline void outstr(const char *p, FILE * file)
-{
-	fputs(p, file);
-}
-static void out1str(const char *p)
-{
-	outstr(p, stdout);
-}
-static void out2str(const char *p)
-{
-	outstr(p, stderr);
-}
 
-#ifndef CONFIG_ASH_OPTIMIZE_FOR_SIZE
-#define out2c(c)        putc((c), stderr)
+struct nif {
+      int type;
+      union node *test;
+      union node *ifpart;
+      union node *elsepart;
+};
+
+
+struct nfor {
+      int type;
+      union node *args;
+      union node *body;
+      char *var;
+};
+
+
+struct ncase {
+      int type;
+      union node *expr;
+      union node *cases;
+};
+
+
+struct nclist {
+      int type;
+      union node *next;
+      union node *pattern;
+      union node *body;
+};
+
+
+struct narg {
+      int type;
+      union node *next;
+      char *text;
+      struct nodelist *backquote;
+};
+
+
+struct nfile {
+      int type;
+      union node *next;
+      int fd;
+      union node *fname;
+      char *expfname;
+};
+
+
+struct ndup {
+      int type;
+      union node *next;
+      int fd;
+      int dupfd;
+      union node *vname;
+};
+
+
+struct nhere {
+      int type;
+      union node *next;
+      int fd;
+      union node *doc;
+};
+
+
+struct nnot {
+      int type;
+      union node *com;
+};
+
+
+union node {
+      int type;
+      struct ncmd ncmd;
+      struct npipe npipe;
+      struct nredir nredir;
+      struct nbinary nbinary;
+      struct nif nif;
+      struct nfor nfor;
+      struct ncase ncase;
+      struct nclist nclist;
+      struct narg narg;
+      struct nfile nfile;
+      struct ndup ndup;
+      struct nhere nhere;
+      struct nnot nnot;
+};
+
+
+struct nodelist {
+	struct nodelist *next;
+	union node *n;
+};
+
+
+struct funcnode {
+	int count;
+	union node n;
+};
+
+
+static void freefunc(struct funcnode *);
+/*      $NetBSD: parser.h,v 1.15 2002/11/24 22:35:42 christos Exp $     */
+
+/* control characters in argument strings */
+#define CTL_FIRST '\201'        /* first 'special' character */
+#define CTLESC '\201'           /* escape next character */
+#define CTLVAR '\202'           /* variable defn */
+#define CTLENDVAR '\203'
+#define CTLBACKQ '\204'
+#define CTLQUOTE 01             /* ored with CTLBACKQ code if in quotes */
+/*      CTLBACKQ | CTLQUOTE == '\205' */
+#define CTLARI  '\206'          /* arithmetic expression */
+#define CTLENDARI '\207'
+#define CTLQUOTEMARK '\210'
+#define CTL_LAST '\210'         /* last 'special' character */
+
+/* variable substitution byte (follows CTLVAR) */
+#define VSTYPE  0x0f            /* type of variable substitution */
+#define VSNUL   0x10            /* colon--treat the empty string as unset */
+#define VSQUOTE 0x80            /* inside double quotes--suppress splitting */
+
+/* values of VSTYPE field */
+#define VSNORMAL        0x1             /* normal variable:  $var or ${var} */
+#define VSMINUS         0x2             /* ${var-text} */
+#define VSPLUS          0x3             /* ${var+text} */
+#define VSQUESTION      0x4             /* ${var?message} */
+#define VSASSIGN        0x5             /* ${var=text} */
+#define VSTRIMRIGHT     0x6             /* ${var%pattern} */
+#define VSTRIMRIGHTMAX  0x7             /* ${var%%pattern} */
+#define VSTRIMLEFT      0x8             /* ${var#pattern} */
+#define VSTRIMLEFTMAX   0x9             /* ${var##pattern} */
+#define VSLENGTH        0xa             /* ${#var} */
+
+/* values of checkkwd variable */
+#define CHKALIAS        0x1
+#define CHKKWD          0x2
+#define CHKNL           0x4
+
+#define IBUFSIZ (BUFSIZ + 1)
+
+/*
+ * NEOF is returned by parsecmd when it encounters an end of file.  It
+ * must be distinct from NULL, so we use the address of a variable that
+ * happens to be handy.
+ */
+static int plinno = 1;                  /* input line number */
+
+/* number of characters left in input buffer */
+static int parsenleft;                  /* copy of parsefile->nleft */
+static int parselleft;                  /* copy of parsefile->lleft */
+
+/* next character in input buffer */
+static char *parsenextc;               /* copy of parsefile->nextc */
+static struct parsefile basepf;         /* top level input file */
+static char basebuf[IBUFSIZ];           /* buffer for top level input file */
+static struct parsefile *parsefile = &basepf;  /* current input file */
+
+
+static int tokpushback;                 /* last token pushed back */
+#define NEOF ((union node *)&tokpushback)
+static int parsebackquote;             /* nonzero if we are inside backquotes */
+static int doprompt;                   /* if set, prompt the user */
+static int needprompt;                 /* true if interactive and at start of line */
+static int lasttoken;                  /* last token read */
+static char *wordtext;                 /* text of last word returned by readtoken */
+static int checkkwd;
+static struct nodelist *backquotelist;
+static union node *redirnode;
+static struct heredoc *heredoc;
+static int quoteflag;                  /* set if (part of) last token was quoted */
+static int startlinno;                 /* line # where last token started */
+
+static union node *parsecmd(int);
+static void fixredir(union node *, const char *, int);
+static const char *const *findkwd(const char *);
+static char *endofname(const char *);
+
+/*      $NetBSD: shell.h,v 1.16 2003/01/22 20:36:04 dsl Exp $   */
+
+typedef void *pointer;
+
+static char nullstr[1];                /* zero length string */
+static const char spcstr[] = " ";
+static const char snlfmt[] = "%s\n";
+static const char dolatstr[] = { CTLVAR, VSNORMAL|VSQUOTE, '@', '=', '\0' };
+static const char illnum[] = "Illegal number: %s";
+static const char homestr[] = "HOME";
+
+#ifdef DEBUG
+#define TRACE(param)    trace param
+#define TRACEV(param)   tracev param
 #else
-static void out2c(int c)
-{
-	putc(c, stderr);
-}
+#define TRACE(param)
+#define TRACEV(param)
 #endif
 
+#if defined(__GNUC__) && __GNUC__ < 3
+#define va_copy __va_copy
+#endif
+
+#if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
+#define __builtin_expect(x, expected_value) (x)
+#endif
+
+#define likely(x)       __builtin_expect((x),1)
+#define unlikely(x)     __builtin_expect((x),0)
+
+#define TEOF 0
+#define TNL 1
+#define TREDIR 2
+#define TWORD 3
+#define TSEMI 4
+#define TBACKGND 5
+#define TAND 6
+#define TOR 7
+#define TPIPE 8
+#define TLP 9
+#define TRP 10
+#define TENDCASE 11
+#define TENDBQUOTE 12
+#define TNOT 13
+#define TCASE 14
+#define TDO 15
+#define TDONE 16
+#define TELIF 17
+#define TELSE 18
+#define TESAC 19
+#define TFI 20
+#define TFOR 21
+#define TIF 22
+#define TIN 23
+#define TTHEN 24
+#define TUNTIL 25
+#define TWHILE 26
+#define TBEGIN 27
+#define TEND 28
+
+/* first char is indicating which tokens mark the end of a list */
+static const char *const tokname_array[] = {
+	"\1end of file",
+	"\0newline",
+	"\0redirection",
+	"\0word",
+	"\0;",
+	"\0&",
+	"\0&&",
+	"\0||",
+	"\0|",
+	"\0(",
+	"\1)",
+	"\1;;",
+	"\1`",
+#define KWDOFFSET 13
+	/* the following are keywords */
+	"\0!",
+	"\0case",
+	"\1do",
+	"\1done",
+	"\1elif",
+	"\1else",
+	"\1esac",
+	"\1fi",
+	"\0for",
+	"\0if",
+	"\0in",
+	"\1then",
+	"\0until",
+	"\0while",
+	"\0{",
+	"\1}",
+};
+
+static const char *tokname(int tok)
+{
+	static char buf[16];
+
+	if (tok >= TSEMI)
+		buf[0] = '"';
+	sprintf(buf + (tok >= TSEMI), "%s%c",
+			tokname_array[tok] + 1, (tok >= TSEMI ? '"' : 0));
+	return buf;
+}
+
+/*      $NetBSD: machdep.h,v 1.10 2002/10/07 14:26:08 christos Exp $    */
+
+/*
+ * Most machines require the value returned from malloc to be aligned
+ * in some way.  The following macro will get this right on many machines.
+ */
+
+#define SHELL_SIZE (sizeof(union {int i; char *cp; double d; }) - 1)
+/*
+ * It appears that grabstackstr() will barf with such alignments
+ * because stalloc() will return a string allocated in a new stackblock.
+ */
+#define SHELL_ALIGN(nbytes) (((nbytes) + SHELL_SIZE) & ~SHELL_SIZE)
+
+/*
+ * This file was generated by the mksyntax program.
+ */
+
+
+/* Syntax classes */
+#define CWORD 0                 /* character is nothing special */
+#define CNL 1                   /* newline character */
+#define CBACK 2                 /* a backslash character */
+#define CSQUOTE 3               /* single quote */
+#define CDQUOTE 4               /* double quote */
+#define CENDQUOTE 5             /* a terminating quote */
+#define CBQUOTE 6               /* backwards single quote */
+#define CVAR 7                  /* a dollar sign */
+#define CENDVAR 8               /* a '}' character */
+#define CLP 9                   /* a left paren in arithmetic */
+#define CRP 10                  /* a right paren in arithmetic */
+#define CENDFILE 11             /* end of file */
+#define CCTL 12                 /* like CWORD, except it must be escaped */
+#define CSPCL 13                /* these terminate a word */
+#define CIGN 14                 /* character should be ignored */
+
+#ifdef CONFIG_ASH_ALIAS
+#define SYNBASE 130
+#define PEOF -130
+#define PEOA -129
+#define PEOA_OR_PEOF PEOA
+#else
+#define SYNBASE 129
+#define PEOF -129
+#define PEOA_OR_PEOF PEOF
+#endif
+
+#define is_digit(c)     ((unsigned)((c) - '0') <= 9)
+#define is_name(c)      ((c) == '_' || isalpha((unsigned char)(c)))
+#define is_in_name(c)   ((c) == '_' || isalnum((unsigned char)(c)))
+
+/*
+ * is_special(c) evaluates to 1 for c in "!#$*-0123456789?@"; 0 otherwise
+ * (assuming ascii char codes, as the original implementation did)
+ */
+#define is_special(c) \
+    ( (((unsigned int)c) - 33 < 32) \
+			 && ((0xc1ff920dUL >> (((unsigned int)c) - 33)) & 1))
+
+#define digit_val(c)    ((c) - '0')
+
+/*
+ * This file was generated by the mksyntax program.
+ */
 
 #ifdef CONFIG_ASH_OPTIMIZE_FOR_SIZE
 #define USE_SIT_FUNCTION
 #endif
 
 /* number syntax index */
-#define  BASESYNTAX  0	/* not in quotes */
-#define  DQSYNTAX    1	/* in double quotes */
-#define  SQSYNTAX    2	/* in single quotes */
-#define  ARISYNTAX   3	/* in arithmetic */
+#define  BASESYNTAX  0  /* not in quotes */
+#define  DQSYNTAX    1  /* in double quotes */
+#define  SQSYNTAX    2  /* in single quotes */
+#define  ARISYNTAX   3  /* in arithmetic */
 
+#ifdef CONFIG_ASH_MATH_SUPPORT
 static const char S_I_T[][4] = {
-	{CSPCL, CIGN, CIGN, CIGN},	/* 0, PEOA */
-	{CSPCL, CWORD, CWORD, CWORD},	/* 1, ' ' */
-	{CNL, CNL, CNL, CNL},	/* 2, \n */
-	{CWORD, CCTL, CCTL, CWORD},	/* 3, !*-/:=?[]~ */
-	{CDQUOTE, CENDQUOTE, CWORD, CDQUOTE},	/* 4, '"' */
-	{CVAR, CVAR, CWORD, CVAR},	/* 5, $ */
-	{CSQUOTE, CWORD, CENDQUOTE, CSQUOTE},	/* 6, "'" */
-	{CSPCL, CWORD, CWORD, CLP},	/* 7, ( */
-	{CSPCL, CWORD, CWORD, CRP},	/* 8, ) */
-	{CBACK, CBACK, CCTL, CBACK},	/* 9, \ */
-	{CBQUOTE, CBQUOTE, CWORD, CBQUOTE},	/* 10, ` */
-	{CENDVAR, CENDVAR, CWORD, CENDVAR},	/* 11, } */
+#ifdef CONFIG_ASH_ALIAS
+	{CSPCL, CIGN, CIGN, CIGN},              /* 0, PEOA */
+#endif
+	{CSPCL, CWORD, CWORD, CWORD},           /* 1, ' ' */
+	{CNL, CNL, CNL, CNL},                   /* 2, \n */
+	{CWORD, CCTL, CCTL, CWORD},             /* 3, !*-/:=?[]~ */
+	{CDQUOTE, CENDQUOTE, CWORD, CWORD},     /* 4, '"' */
+	{CVAR, CVAR, CWORD, CVAR},              /* 5, $ */
+	{CSQUOTE, CWORD, CENDQUOTE, CWORD},     /* 6, "'" */
+	{CSPCL, CWORD, CWORD, CLP},             /* 7, ( */
+	{CSPCL, CWORD, CWORD, CRP},             /* 8, ) */
+	{CBACK, CBACK, CCTL, CBACK},            /* 9, \ */
+	{CBQUOTE, CBQUOTE, CWORD, CBQUOTE},     /* 10, ` */
+	{CENDVAR, CENDVAR, CWORD, CENDVAR},     /* 11, } */
 #ifndef USE_SIT_FUNCTION
-	{CENDFILE, CENDFILE, CENDFILE, CENDFILE},	/* 12, PEOF */
-	{CWORD, CWORD, CWORD, CWORD},	/* 13, 0-9A-Za-z */
-	{CCTL, CCTL, CCTL, CCTL}	/* 14, CTLESC ... */
+	{CENDFILE, CENDFILE, CENDFILE, CENDFILE},       /* 12, PEOF */
+	{CWORD, CWORD, CWORD, CWORD},           /* 13, 0-9A-Za-z */
+	{CCTL, CCTL, CCTL, CCTL}                /* 14, CTLESC ... */
 #endif
 };
+#else
+static const char S_I_T[][3] = {
+#ifdef CONFIG_ASH_ALIAS
+	{CSPCL, CIGN, CIGN},                    /* 0, PEOA */
+#endif
+	{CSPCL, CWORD, CWORD},                  /* 1, ' ' */
+	{CNL, CNL, CNL},                        /* 2, \n */
+	{CWORD, CCTL, CCTL},                    /* 3, !*-/:=?[]~ */
+	{CDQUOTE, CENDQUOTE, CWORD},            /* 4, '"' */
+	{CVAR, CVAR, CWORD},                    /* 5, $ */
+	{CSQUOTE, CWORD, CENDQUOTE},            /* 6, "'" */
+	{CSPCL, CWORD, CWORD},                  /* 7, ( */
+	{CSPCL, CWORD, CWORD},                  /* 8, ) */
+	{CBACK, CBACK, CCTL},                   /* 9, \ */
+	{CBQUOTE, CBQUOTE, CWORD},              /* 10, ` */
+	{CENDVAR, CENDVAR, CWORD},              /* 11, } */
+#ifndef USE_SIT_FUNCTION
+	{CENDFILE, CENDFILE, CENDFILE},         /* 12, PEOF */
+	{CWORD, CWORD, CWORD},                  /* 13, 0-9A-Za-z */
+	{CCTL, CCTL, CCTL}                      /* 14, CTLESC ... */
+#endif
+};
+#endif /* CONFIG_ASH_MATH_SUPPORT */
 
 #ifdef USE_SIT_FUNCTION
 
@@ -704,41 +802,54 @@
 static int SIT(int c, int syntax)
 {
 	static const char spec_symbls[] = "\t\n !\"$&'()*-/:;<=>?[\\]`|}~";
+#ifdef CONFIG_ASH_ALIAS
 	static const char syntax_index_table[] = {
-		1, 2, 1, 3, 4, 5, 1, 6,	/* "\t\n !\"$&'" */
-		7, 8, 3, 3, 3, 3, 1, 1,	/* "()*-/:;<" */
-		3, 1, 3, 3, 9, 3, 10, 1,	/* "=>?[\\]`|" */
-		11, 3
-	};					/* "}~" */
+		1, 2, 1, 3, 4, 5, 1, 6,         /* "\t\n !\"$&'" */
+		7, 8, 3, 3, 3, 3, 1, 1,         /* "()*-/:;<" */
+		3, 1, 3, 3, 9, 3, 10, 1,        /* "=>?[\\]`|" */
+		11, 3                           /* "}~" */
+	};
+#else
+	static const char syntax_index_table[] = {
+		0, 1, 0, 2, 3, 4, 0, 5,         /* "\t\n !\"$&'" */
+		6, 7, 2, 2, 2, 2, 0, 0,         /* "()*-/:;<" */
+		2, 0, 2, 2, 8, 2, 9, 0,         /* "=>?[\\]`|" */
+		10, 2                           /* "}~" */
+	};
+#endif
 	const char *s;
 	int indx;
 
-	if (c == PEOF)		/* 2^8+2 */
+	if (c == PEOF)          /* 2^8+2 */
 		return CENDFILE;
-	if (c == PEOA)		/* 2^8+1 */
+#ifdef CONFIG_ASH_ALIAS
+	if (c == PEOA)          /* 2^8+1 */
 		indx = 0;
-	else if (U_C(c) >= U_C(CTLESC) && U_C(c) <= U_C(CTLQUOTEMARK))
-		return CCTL;
+	else
+#endif
+		if (U_C(c) >= U_C(CTLESC) && U_C(c) <= U_C(CTLQUOTEMARK))
+			return CCTL;
 	else {
 		s = strchr(spec_symbls, c);
-		if (s == 0)
+		if (s == 0 || *s == 0)
 			return CWORD;
 		indx = syntax_index_table[(s - spec_symbls)];
 	}
 	return S_I_T[indx][syntax];
 }
 
-#else							/* USE_SIT_FUNCTION */
+#else                                                   /* USE_SIT_FUNCTION */
 
 #define SIT(c, syntax) S_I_T[(int)syntax_index_table[((int)c)+SYNBASE]][syntax]
 
+#ifdef CONFIG_ASH_ALIAS
 #define CSPCL_CIGN_CIGN_CIGN                           0
 #define CSPCL_CWORD_CWORD_CWORD                        1
 #define CNL_CNL_CNL_CNL                                2
 #define CWORD_CCTL_CCTL_CWORD                          3
-#define CDQUOTE_CENDQUOTE_CWORD_CDQUOTE                4
+#define CDQUOTE_CENDQUOTE_CWORD_CWORD                  4
 #define CVAR_CVAR_CWORD_CVAR                           5
-#define CSQUOTE_CWORD_CENDQUOTE_CSQUOTE                6
+#define CSQUOTE_CWORD_CENDQUOTE_CWORD                  6
 #define CSPCL_CWORD_CWORD_CLP                          7
 #define CSPCL_CWORD_CWORD_CRP                          8
 #define CBACK_CBACK_CCTL_CBACK                         9
@@ -747,22 +858,38 @@
 #define CENDFILE_CENDFILE_CENDFILE_CENDFILE           12
 #define CWORD_CWORD_CWORD_CWORD                       13
 #define CCTL_CCTL_CCTL_CCTL                           14
+#else
+#define CSPCL_CWORD_CWORD_CWORD                        0
+#define CNL_CNL_CNL_CNL                                1
+#define CWORD_CCTL_CCTL_CWORD                          2
+#define CDQUOTE_CENDQUOTE_CWORD_CWORD                  3
+#define CVAR_CVAR_CWORD_CVAR                           4
+#define CSQUOTE_CWORD_CENDQUOTE_CWORD                  5
+#define CSPCL_CWORD_CWORD_CLP                          6
+#define CSPCL_CWORD_CWORD_CRP                          7
+#define CBACK_CBACK_CCTL_CBACK                         8
+#define CBQUOTE_CBQUOTE_CWORD_CBQUOTE                  9
+#define CENDVAR_CENDVAR_CWORD_CENDVAR                 10
+#define CENDFILE_CENDFILE_CENDFILE_CENDFILE           11
+#define CWORD_CWORD_CWORD_CWORD                       12
+#define CCTL_CCTL_CCTL_CCTL                           13
+#endif
 
 static const char syntax_index_table[258] = {
 	/* BASESYNTAX_DQSYNTAX_SQSYNTAX_ARISYNTAX */
-	/*   0  -130 PEOF */ CENDFILE_CENDFILE_CENDFILE_CENDFILE,
-	/*   1  -129 PEOA */ CSPCL_CIGN_CIGN_CIGN,
-	/*   2  -128 0xff */ CWORD_CWORD_CWORD_CWORD,
-	/*   3  -127      */ CCTL_CCTL_CCTL_CCTL,
-	/* CTLQUOTEMARK */
-	/*   4  -126      */ CCTL_CCTL_CCTL_CCTL,
-	/*   5  -125      */ CCTL_CCTL_CCTL_CCTL,
-	/*   6  -124      */ CCTL_CCTL_CCTL_CCTL,
-	/*   7  -123      */ CCTL_CCTL_CCTL_CCTL,
-	/*   8  -122      */ CCTL_CCTL_CCTL_CCTL,
-	/*   9  -121      */ CCTL_CCTL_CCTL_CCTL,
-	/*  10  -120      */ CCTL_CCTL_CCTL_CCTL,
-	/* CTLESC */
+	/*   0  PEOF */      CENDFILE_CENDFILE_CENDFILE_CENDFILE,
+#ifdef CONFIG_ASH_ALIAS
+	/*   1  PEOA */      CSPCL_CIGN_CIGN_CIGN,
+#endif
+	/*   2  -128 0x80 */ CWORD_CWORD_CWORD_CWORD,
+	/*   3  -127 CTLESC       */ CCTL_CCTL_CCTL_CCTL,
+	/*   4  -126 CTLVAR       */ CCTL_CCTL_CCTL_CCTL,
+	/*   5  -125 CTLENDVAR    */ CCTL_CCTL_CCTL_CCTL,
+	/*   6  -124 CTLBACKQ     */ CCTL_CCTL_CCTL_CCTL,
+	/*   7  -123 CTLQUOTE     */ CCTL_CCTL_CCTL_CCTL,
+	/*   8  -122 CTLARI       */ CCTL_CCTL_CCTL_CCTL,
+	/*   9  -121 CTLENDARI    */ CCTL_CCTL_CCTL_CCTL,
+	/*  10  -120 CTLQUOTEMARK */ CCTL_CCTL_CCTL_CCTL,
 	/*  11  -119      */ CWORD_CWORD_CWORD_CWORD,
 	/*  12  -118      */ CWORD_CWORD_CWORD_CWORD,
 	/*  13  -117      */ CWORD_CWORD_CWORD_CWORD,
@@ -916,12 +1043,12 @@
 	/* 161    31      */ CWORD_CWORD_CWORD_CWORD,
 	/* 162    32  " " */ CSPCL_CWORD_CWORD_CWORD,
 	/* 163    33  "!" */ CWORD_CCTL_CCTL_CWORD,
-	/* 164    34  """ */ CDQUOTE_CENDQUOTE_CWORD_CDQUOTE,
+	/* 164    34  """ */ CDQUOTE_CENDQUOTE_CWORD_CWORD,
 	/* 165    35  "#" */ CWORD_CWORD_CWORD_CWORD,
 	/* 166    36  "$" */ CVAR_CVAR_CWORD_CVAR,
 	/* 167    37  "%" */ CWORD_CWORD_CWORD_CWORD,
 	/* 168    38  "&" */ CSPCL_CWORD_CWORD_CWORD,
-	/* 169    39  "'" */ CSQUOTE_CWORD_CENDQUOTE_CSQUOTE,
+	/* 169    39  "'" */ CSQUOTE_CWORD_CENDQUOTE_CWORD,
 	/* 170    40  "(" */ CSPCL_CWORD_CWORD_CLP,
 	/* 171    41  ")" */ CSPCL_CWORD_CWORD_CRP,
 	/* 172    42  "*" */ CWORD_CCTL_CCTL_CWORD,
@@ -1012,90 +1139,66 @@
 	/* 257   127      */ CWORD_CWORD_CWORD_CWORD,
 };
 
-#endif							/* USE_SIT_FUNCTION */
+#endif                                                  /* USE_SIT_FUNCTION */
+
+/*      $NetBSD: alias.c,v 1.11 2002/11/24 22:35:38 christos Exp $      */
 
 
-/* first char is indicating which tokens mark the end of a list */
-static const char *const tokname_array[] = {
-	"\1end of file",
-	"\0newline",
-	"\0redirection",
-	"\0word",
-	"\0assignment",
-	"\0;",
-	"\0&",
-	"\0&&",
-	"\0||",
-	"\0|",
-	"\0(",
-	"\1)",
-	"\1;;",
-	"\1`",
-#define KWDOFFSET 14
-	/* the following are keywords */
-	"\0!",
-	"\0case",
-	"\1do",
-	"\1done",
-	"\1elif",
-	"\1else",
-	"\1esac",
-	"\1fi",
-	"\0for",
-	"\0if",
-	"\0in",
-	"\1then",
-	"\0until",
-	"\0while",
-	"\0{",
-	"\1}",
+#define ATABSIZE 39
+
+static int     funcblocksize;          /* size of structures in function */
+static int     funcstringsize;         /* size of strings in node */
+static pointer funcblock;              /* block to allocate function from */
+static char   *funcstring;             /* block to allocate strings from */
+
+static const short nodesize[26] = {
+      SHELL_ALIGN(sizeof (struct ncmd)),
+      SHELL_ALIGN(sizeof (struct npipe)),
+      SHELL_ALIGN(sizeof (struct nredir)),
+      SHELL_ALIGN(sizeof (struct nredir)),
+      SHELL_ALIGN(sizeof (struct nredir)),
+      SHELL_ALIGN(sizeof (struct nbinary)),
+      SHELL_ALIGN(sizeof (struct nbinary)),
+      SHELL_ALIGN(sizeof (struct nbinary)),
+      SHELL_ALIGN(sizeof (struct nif)),
+      SHELL_ALIGN(sizeof (struct nbinary)),
+      SHELL_ALIGN(sizeof (struct nbinary)),
+      SHELL_ALIGN(sizeof (struct nfor)),
+      SHELL_ALIGN(sizeof (struct ncase)),
+      SHELL_ALIGN(sizeof (struct nclist)),
+      SHELL_ALIGN(sizeof (struct narg)),
+      SHELL_ALIGN(sizeof (struct narg)),
+      SHELL_ALIGN(sizeof (struct nfile)),
+      SHELL_ALIGN(sizeof (struct nfile)),
+      SHELL_ALIGN(sizeof (struct nfile)),
+      SHELL_ALIGN(sizeof (struct nfile)),
+      SHELL_ALIGN(sizeof (struct nfile)),
+      SHELL_ALIGN(sizeof (struct ndup)),
+      SHELL_ALIGN(sizeof (struct ndup)),
+      SHELL_ALIGN(sizeof (struct nhere)),
+      SHELL_ALIGN(sizeof (struct nhere)),
+      SHELL_ALIGN(sizeof (struct nnot)),
 };
 
-static const char *tokname(int tok)
-{
-	static char buf[16];
 
-	if (tok >= TSEMI)
-		buf[0] = '"';
-	sprintf(buf + (tok >= TSEMI), "%s%c",
-			tokname_array[tok] + 1, (tok >= TSEMI ? '"' : 0));
-	return buf;
-}
-
-static int plinno = 1;	/* input line number */
-
-static int parselleft;	/* copy of parsefile->lleft */
-
-static struct parsefile basepf;	/* top level input file */
-static char basebuf[BUFSIZ];	/* buffer for top level input file */
-static struct parsefile *parsefile = &basepf;	/* current input file */
-
-/*
- * NEOF is returned by parsecmd when it encounters an end of file.  It
- * must be distinct from NULL, so we use the address of a variable that
- * happens to be handy.
- */
-
-static int tokpushback;	/* last token pushed back */
-
-#define NEOF ((union node *)&tokpushback)
-static int checkkwd;	/* 1 == check for kwds, 2 == also eat newlines */
+static void calcsize(union node *);
+static void sizenodelist(struct nodelist *);
+static union node *copynode(union node *);
+static struct nodelist *copynodelist(struct nodelist *);
+static char *nodesavestr(char *);
 
 
-static void error(const char *, ...) __attribute__ ((__noreturn__));
-static void exerror(int, const char *, ...) __attribute__ ((__noreturn__));
-static void shellexec(char **, char **, const char *, int)
-	__attribute__ ((noreturn));
-static void exitshell(int) __attribute__ ((noreturn));
 
-static int goodname(const char *);
-static void ignoresig(int);
-static void onsig(int);
-static void dotrap(void);
-static int decode_signal(const char *, int);
+static void evalstring(char *, int);
+union node;     /* BLETCH for ansi C */
+static void evaltree(union node *, int);
+static void evalbackcmd(union node *, struct backcmd *);
 
-static void setparam(char **);
-static void freeparam(volatile struct shparam *);
+/* in_function returns nonzero if we are currently evaluating a function */
+#define in_function()   funcnest
+static int evalskip;                   /* set if we are skipping commands */
+static int skipcount;           /* number of levels to skip */
+static int funcnest;                   /* depth of function calls */
 
 /* reasons for skipping commands (see comment on breakcmd routine) */
 #define SKIPBREAK       1
@@ -1103,160 +1206,330 @@
 #define SKIPFUNC        3
 #define SKIPFILE        4
 
-/* values of cmdtype */
-#define CMDUNKNOWN -1	/* no entry in table for command */
-#define CMDNORMAL 0		/* command is an executable program */
-#define CMDBUILTIN 1	/* command is a shell builtin */
-#define CMDFUNCTION 2	/* command is a shell function */
+/*
+ * This file was generated by the mkbuiltins program.
+ */
 
-#define DO_ERR  1		/* find_command prints errors */
-#define DO_ABS  2		/* find_command checks absolute paths */
-#define DO_NOFUN        4	/* find_command ignores functions */
-#define DO_BRUTE        8	/* find_command ignores hash table */
+#ifdef JOBS
+static int bgcmd(int, char **);
+#endif
+static int breakcmd(int, char **);
+static int cdcmd(int, char **);
+#ifdef CONFIG_ASH_CMDCMD
+static int commandcmd(int, char **);
+#endif
+static int dotcmd(int, char **);
+static int evalcmd(int, char **);
+static int execcmd(int, char **);
+static int exitcmd(int, char **);
+#ifdef CONFIG_ASH_MATH_SUPPORT
+static int expcmd(int, char **);
+#endif
+static int exportcmd(int, char **);
+static int falsecmd(int, char **);
+#ifdef JOBS
+static int fgcmd(int, char **);
+#endif
+#ifdef CONFIG_ASH_GETOPTS
+static int getoptscmd(int, char **);
+#endif
+static int hashcmd(int, char **);
+#ifndef CONFIG_FEATURE_SH_EXTRA_QUIET
+static int helpcmd(int argc, char **argv);
+#endif
+#ifdef JOBS
+static int jobscmd(int, char **);
+#endif
+static int localcmd(int, char **);
+static int pwdcmd(int, char **);
+static int readcmd(int, char **);
+static int returncmd(int, char **);
+static int setcmd(int, char **);
+static int shiftcmd(int, char **);
+static int timescmd(int, char **);
+static int trapcmd(int, char **);
+static int truecmd(int, char **);
+static int typecmd(int, char **);
+static int umaskcmd(int, char **);
+static int unsetcmd(int, char **);
+static int waitcmd(int, char **);
+static int ulimitcmd(int, char **);
+#ifdef JOBS
+static int killcmd(int, char **);
+#endif
+
+/*      $NetBSD: mail.h,v 1.9 2002/11/24 22:35:40 christos Exp $        */
+
+#ifdef CONFIG_ASH_MAIL
+static void chkmail(void);
+static void changemail(const char *);
+#endif
+
+/*      $NetBSD: exec.h,v 1.20 2003/01/22 20:36:04 dsl Exp $    */
+
+/* values of cmdtype */
+#define CMDUNKNOWN      -1      /* no entry in table for command */
+#define CMDNORMAL       0       /* command is an executable program */
+#define CMDFUNCTION     1       /* command is a shell function */
+#define CMDBUILTIN      2       /* command is a shell builtin */
+
+struct builtincmd {
+	const char *name;
+	int (*builtin)(int, char **);
+	/* 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"
+#define BUILTIN_REGULAR "2"
+#define BUILTIN_SPEC_REG "3"
+#define BUILTIN_ASSIGN  "4"
+#define BUILTIN_SPEC_ASSG  "5"
+#define BUILTIN_REG_ASSG   "6"
+#define BUILTIN_SPEC_REG_ASSG   "7"
+
+#define IS_BUILTIN_SPECIAL(builtincmd) ((builtincmd)->name[0] & 1)
+#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 },
+#ifdef CONFIG_ASH_MATH_SUPPORT
+	{ BUILTIN_NOSPEC        "exp", expcmd },
+#endif
+	{ 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", expcmd },
+#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) )
+
+
+
+struct cmdentry {
+	int cmdtype;
+	union param {
+		int index;
+		const struct builtincmd *cmd;
+		struct funcnode *func;
+	} u;
+};
+
+
+/* action to find_command() */
+#define DO_ERR          0x01    /* prints errors */
+#define DO_ABS          0x02    /* checks absolute paths */
+#define DO_NOFUNC       0x04    /* don't return shell functions, for command */
+#define DO_ALTPATH      0x08    /* using alternate path */
+#define DO_ALTBLTIN     0x20    /* %builtin in alt. path */
+
+static const char *pathopt;     /* set by padvance */
+
+static void shellexec(char **, const char *, int)
+    __attribute__((__noreturn__));
+static char *padvance(const char **, const char *);
+static void find_command(char *, struct cmdentry *, int, const char *);
+static struct builtincmd *find_builtin(const char *);
+static void hashcd(void);
+static void changepath(const char *);
+static void defun(char *, union node *);
+static void unsetfunc(const char *);
+
+#ifdef CONFIG_ASH_MATH_SUPPORT
+/* From arith.y */
+static int dash_arith(const char *);
+#endif
+
+/*      $NetBSD: init.h,v 1.9 2002/11/24 22:35:40 christos Exp $        */
+
+static void reset(void);
+
+/*      $NetBSD: var.h,v 1.21 2003/01/22 20:36:04 dsl Exp $     */
 
 /*
  * Shell variables.
  */
 
 /* flags */
-#define VEXPORT         0x01	/* variable is exported */
-#define VREADONLY       0x02	/* variable cannot be modified */
-#define VSTRFIXED       0x04	/* variable struct is staticly allocated */
-#define VTEXTFIXED      0x08	/* text is staticly allocated */
-#define VSTACK          0x10	/* text is allocated on the stack */
-#define VUNSET          0x20	/* the variable is not set */
-#define VNOFUNC         0x40	/* don't call the callback function */
+#define VEXPORT         0x01    /* variable is exported */
+#define VREADONLY       0x02    /* variable cannot be modified */
+#define VSTRFIXED       0x04    /* variable struct is statically allocated */
+#define VTEXTFIXED      0x08    /* text is statically allocated */
+#define VSTACK          0x10    /* text is allocated on the stack */
+#define VUNSET          0x20    /* the variable is not set */
+#define VNOFUNC         0x40    /* don't call the callback function */
+#define VNOSET          0x80    /* do not set variable - just readonly test */
+#define VNOSAVE         0x100   /* when text is on the heap before setvareq */
 
 
 struct var {
-	struct var *next;	/* next entry in hash list */
-	int flags;			/* flags are defined above */
-	char *text;			/* name=value */
-	void (*func) (const char *);
-	/* function to be called when  */
-	/* the variable gets set/unset */
+	struct var *next;               /* next entry in hash list */
+	int flags;                      /* flags are defined above */
+	const char *text;               /* name=value */
+	void (*func)(const char *);
+					/* function to be called when  */
+					/* the variable gets set/unset */
 };
 
 struct localvar {
-	struct localvar *next;	/* next local variable in list */
-	struct var *vp;		/* the variable that was made local */
-	int flags;			/* saved flags */
-	char *text;			/* saved text */
+	struct localvar *next;          /* next local variable in list */
+	struct var *vp;                 /* the variable that was made local */
+	int flags;                      /* saved flags */
+	const char *text;               /* saved text */
 };
 
 
-#if defined(__GLIBC__) && __GLIBC__ >= 2 && !defined(FNMATCH_BROKEN)
-#define rmescapes(p) _rmescapes((p), 0)
-static char *_rmescapes(char *, int);
-#else
-static void rmescapes(char *);
-#endif
-
-static int casematch(union node *, const char *);
-static void clearredir(void);
-static void popstring(void);
-static void readcmdfile(const char *);
-
-static int number(const char *);
-static int is_number(const char *, int *num);
-static char *single_quote(const char *);
-static int nextopt(const char *);
-
-static void redirect(union node *, int);
-static void popredir(void);
-static int dup_as_newfd(int, int);
-
-static void changepath(const char *newval);
-static void getoptsreset(const char *value);
-
-
-static int parsenleft;	/* copy of parsefile->nleft */
-static char *parsenextc;	/* copy of parsefile->nextc */
-static int rootpid;		/* pid of main shell */
-static int rootshell;	/* true if we aren't a child of the main shell */
-
-static const char spcstr[] = " ";
-static const char snlfmt[] = "%s\n";
-
-static int sstrnleft;
-static int herefd = -1;
-
 static struct localvar *localvars;
 
-static struct var vifs;
-static struct var vmail;
-static struct var vmpath;
-static struct var vpath;
-static struct var vps1;
-static struct var vps2;
-static struct var voptind;
+/*
+ * Shell variables.
+ */
+
+#ifdef CONFIG_ASH_GETOPTS
+static void getoptsreset(const char *);
+#endif
 
 #ifdef CONFIG_LOCALE_SUPPORT
-static struct var vlc_all;
-static struct var vlc_ctype;
+#include <locale.h>
+static void change_lc_all(const char *value);
+static void change_lc_ctype(const char *value);
 #endif
 
-#ifdef CONFIG_FEATURE_COMMAND_SAVEHISTORY
-static struct var vhistfile;
-#endif
-
-struct varinit {
-	struct var *var;
-	int flags;
-	const char *text;
-	void (*func) (const char *);
-};
-
-static const char defpathvar[] =
-	"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";
-#define defpath (defpathvar + 5)
-
-#ifdef IFS_BROKEN
-static const char defifsvar[] = "IFS= \t\n";
-
-#define defifs (defifsvar + 4)
-#else
-static const char defifs[] = " \t\n";
-#endif
-
-static const struct varinit varinit[] = {
-#ifdef IFS_BROKEN
-	{&vifs, VSTRFIXED | VTEXTFIXED, defifsvar,
-#else
-	{&vifs, VSTRFIXED | VTEXTFIXED | VUNSET, "IFS=",
-#endif
-	 NULL},
-	{&vmail, VSTRFIXED | VTEXTFIXED | VUNSET, "MAIL=",
-	 NULL},
-	{&vmpath, VSTRFIXED | VTEXTFIXED | VUNSET, "MAILPATH=",
-	 NULL},
-	{&vpath, VSTRFIXED | VTEXTFIXED, defpathvar,
-	 changepath},
-#if defined(CONFIG_FEATURE_COMMAND_EDITING) && defined(CONFIG_FEATURE_SH_FANCY_PROMPT)
-	{&vps1, VSTRFIXED | VTEXTFIXED, "PS1=\\w \\$ ",
-	 NULL},
-#endif							/* else vps1 depends on uid */
-	{&vps2, VSTRFIXED | VTEXTFIXED, "PS2=> ",
-	 NULL},
-	{&voptind, VSTRFIXED | VTEXTFIXED, "OPTIND=1",
-	 getoptsreset},
-#ifdef CONFIG_LOCALE_SUPPORT
-	{&vlc_all, VSTRFIXED | VTEXTFIXED | VUNSET, "LC_ALL=",
-	 change_lc_all},
-	{&vlc_ctype, VSTRFIXED | VTEXTFIXED | VUNSET, "LC_CTYPE=",
-	 change_lc_ctype},
-#endif
-#ifdef CONFIG_FEATURE_COMMAND_SAVEHISTORY
-	{&vhistfile, VSTRFIXED | VTEXTFIXED | VUNSET, "HISTFILE=",
-	 NULL},
-#endif
-	{NULL, 0, NULL,
-	 NULL}
-};
-
 #define VTABSIZE 39
 
-static struct var *vartab[VTABSIZE];
+static const char defpathvar[] =
+	"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";
+#ifdef IFS_BROKEN
+static const char defifsvar[] = "IFS= \t\n";
+#endif
+static const char defifs[] = " \t\n";
+
+static struct var varinit[] = {
+#ifdef IFS_BROKEN
+	{ 0,    VSTRFIXED|VTEXTFIXED,           defifsvar,      0 },
+#else
+	{ 0,    VSTRFIXED|VTEXTFIXED|VUNSET,    "IFS\0",        0 },
+#endif
+
+#ifdef CONFIG_ASH_MAIL
+	{ 0,    VSTRFIXED|VTEXTFIXED|VUNSET,    "MAIL\0",       changemail },
+	{ 0,    VSTRFIXED|VTEXTFIXED|VUNSET,    "MAILPATH\0",   changemail },
+#endif
+
+	{ 0,    VSTRFIXED|VTEXTFIXED,           defpathvar,     changepath },
+	{ 0,    VSTRFIXED|VTEXTFIXED,           "PS1=$ ",       0 },
+	{ 0,    VSTRFIXED|VTEXTFIXED,           "PS2=> ",       0 },
+	{ 0,    VSTRFIXED|VTEXTFIXED,           "PS4=+ ",       0 },
+#ifdef CONFIG_ASH_GETOPTS
+	{ 0,    VSTRFIXED|VTEXTFIXED,           "OPTIND=1",     getoptsreset },
+#endif
+#ifdef CONFIG_LOCALE_SUPPORT
+	{0, VSTRFIXED | VTEXTFIXED | VUNSET, "LC_ALL=", change_lc_all},
+	{0, VSTRFIXED | VTEXTFIXED | VUNSET, "LC_CTYPE=", change_lc_ctype},
+#endif
+#ifdef CONFIG_FEATURE_COMMAND_SAVEHISTORY
+	{0, VSTRFIXED | VTEXTFIXED | VUNSET, "HISTFILE=", NULL},
+#endif
+};
+
+#define vifs varinit[0]
+#ifdef CONFIG_ASH_MAIL
+#define vmail (&vifs)[1]
+#define vmpath (&vmail)[1]
+#else
+#define vmpath vifs
+#endif
+#define vpath (&vmpath)[1]
+#define vps1 (&vpath)[1]
+#define vps2 (&vps1)[1]
+#define vps4 (&vps2)[1]
+#define voptind (&vps4)[1]
+
+#define defpath (defpathvar + 5)
 
 /*
  * The following macros access the values of the above variables.
@@ -1271,54 +1544,533 @@
 #define pathval()       (vpath.text + 5)
 #define ps1val()        (vps1.text + 4)
 #define ps2val()        (vps2.text + 4)
+#define ps4val()        (vps4.text + 4)
 #define optindval()     (voptind.text + 7)
 
 #define mpathset()      ((vmpath.flags & VUNSET) == 0)
 
-static void initvar(void);
 static void setvar(const char *, const char *, int);
 static void setvareq(char *, int);
-static void listsetvar(struct strlist *);
-static const char *lookupvar(const char *);
-static const char *bltinlookup(const char *);
-static char **environment(void);
-static int showvarscmd(int, char **);
-static void mklocal(char *);
+static void listsetvar(struct strlist *, int);
+static char *lookupvar(const char *);
+static char *bltinlookup(const char *);
+static char **listvars(int, int, char ***);
+#define environment() listvars(VEXPORT, VUNSET, 0)
+static int showvars(const char *, int, int);
 static void poplocalvars(void);
 static int unsetvar(const char *);
-static int varequal(const char *, const char *);
+#ifdef CONFIG_ASH_GETOPTS
+static int setvarsafe(const char *, const char *, int);
+#endif
+static int varcmp(const char *, const char *);
+static struct var **hashvar(const char *);
 
 
-static char *arg0;		/* value of $0 */
-static struct shparam shellparam;	/* current positional parameters */
-static char **argptr;	/* argument list for builtin commands */
-static char *optionarg;	/* set by nextopt (like getopt) */
-static char *optptr;	/* used by nextopt */
-static char *minusc;	/* argument to -c option */
+static inline int varequal(const char *a, const char *b) {
+	return !varcmp(a, b);
+}
 
 
+static int loopnest;            /* current loop nesting level */
+
+struct strpush {
+	struct strpush *prev;   /* preceding string on stack */
+	char *prevstring;
+	int prevnleft;
 #ifdef CONFIG_ASH_ALIAS
-
-#define ALIASINUSE      1
-#define ALIASDEAD       2
-
-#define ATABSIZE 39
-
-struct alias {
-	struct alias *next;
-	char *name;
-	char *val;
-	int flag;
+	struct alias *ap;       /* if push was associated with an alias */
+#endif
+	char *string;           /* remember the string since it may change */
 };
 
+struct parsefile {
+	struct parsefile *prev; /* preceding file on stack */
+	int linno;              /* current line */
+	int fd;                 /* file descriptor (or -1 if string) */
+	int nleft;              /* number of chars left in this line */
+	int lleft;              /* number of chars left in this buffer */
+	char *nextc;            /* next char in buffer */
+	char *buf;              /* input buffer */
+	struct strpush *strpush; /* for pushing strings at this level */
+	struct strpush basestrpush; /* so pushing one is fast */
+};
+
+/*
+ * The parsefile structure pointed to by the global variable parsefile
+ * contains information about the current file being read.
+ */
+
+
+struct redirtab {
+	struct redirtab *next;
+	int renamed[10];
+	int nullredirs;
+};
+
+static struct redirtab *redirlist;
+static int nullredirs;
+
+extern char **environ;
+
+/*      $NetBSD: output.h,v 1.16 2002/11/24 22:35:42 christos Exp $     */
+
+
+static void outstr(const char *, FILE *);
+static void outcslow(int, FILE *);
+static void flushall(void);
+static void flushout(FILE *);
+static int  out1fmt(const char *, ...)
+    __attribute__((__format__(__printf__,1,2)));
+static int fmtstr(char *, size_t, const char *, ...)
+    __attribute__((__format__(__printf__,3,4)));
+static void xwrite(int, const void *, size_t);
+
+
+#define outerr(f)       ferror(f)
+#define out2c(c)        outcslow((c), stderr)
+
+static void out1str(const char *p)
+{
+	outstr(p, stdout);
+}
+
+static void out2str(const char *p)
+{
+	outstr(p, stderr);
+}
+
+static void out1c(char c)
+{
+	char s[2];
+
+	s[0] = c;
+	s[1] = 0;
+	outstr(s, stdout);
+}
+
+/*
+ * Initialization code.
+ */
+
+/*
+ * This routine initializes the builtin variables.
+ */
+
+static inline void
+initvar(void)
+{
+	struct var *vp;
+	struct var *end;
+	struct var **vpp;
+
+	/*
+	 * PS1 depends on uid
+	 */
+#if defined(CONFIG_FEATURE_COMMAND_EDITING) && defined(CONFIG_FEATURE_SH_FANCY_PROMPT)
+	vps1.text = "PS1=\\w \\$ ";
+#else
+	if (!geteuid())
+		vps1.text = "PS1=# ";
+#endif
+	vp = varinit;
+	end = vp + sizeof(varinit) / sizeof(varinit[0]);
+	do {
+		vpp = hashvar(vp->text);
+		vp->next = *vpp;
+		*vpp = vp;
+	} while (++vp < end);
+}
+
+static inline void
+init(void)
+{
+
+      /* from input.c: */
+      {
+	      basepf.nextc = basepf.buf = basebuf;
+      }
+
+      /* from trap.c: */
+      {
+	      signal(SIGCHLD, SIG_DFL);
+      }
+
+      /* from var.c: */
+      {
+	      char **envp;
+	      char ppid[32];
+
+	      initvar();
+	      for (envp = environ ; *envp ; envp++) {
+		      if (strchr(*envp, '=')) {
+			      setvareq(*envp, VEXPORT|VTEXTFIXED);
+		      }
+	      }
+
+	      snprintf(ppid, sizeof(ppid), "%d", (int) getppid());
+	      setvar("PPID", ppid, 0);
+	      setpwd(0, 0);
+      }
+}
+
+/* PEOF (the end of file marker) */
+
+/*
+ * The input line number.  Input.c just defines this variable, and saves
+ * and restores it when files are pushed and popped.  The user of this
+ * package must set its value.
+ */
+
+static int pgetc(void);
+static int pgetc2(void);
+static int preadbuffer(void);
+static void pungetc(void);
+static void pushstring(char *, void *);
+static void popstring(void);
+static void setinputfile(const char *, int);
+static void setinputfd(int, int);
+static void setinputstring(char *);
+static void popfile(void);
+static void popallfiles(void);
+static void closescript(void);
+
+
+/*      $NetBSD: jobs.h,v 1.17 2003/01/22 20:36:04 dsl Exp $    */
+
+
+/* Mode argument to forkshell.  Don't change FORK_FG or FORK_BG. */
+#define FORK_FG 0
+#define FORK_BG 1
+#define FORK_NOJOB 2
+
+/* mode flags for showjob(s) */
+#define SHOW_PGID       0x01    /* only show pgid - for jobs -p */
+#define SHOW_PID        0x04    /* include process pid */
+#define SHOW_CHANGED    0x08    /* only jobs whose state has changed */
+
+
+/*
+ * A job structure contains information about a job.  A job is either a
+ * single process or a set of processes contained in a pipeline.  In the
+ * latter case, pidlist will be non-NULL, and will point to a -1 terminated
+ * array of pids.
+ */
+
+struct procstat {
+	pid_t   pid;            /* process id */
+	int     status;         /* last process status from wait() */
+	char    *cmd;           /* text of command being run */
+};
+
+struct job {
+	struct procstat ps0;    /* status of process */
+	struct procstat *ps;    /* status or processes when more than one */
+#if JOBS
+	int stopstatus;         /* status of a stopped job */
+#endif
+	uint32_t
+		nprocs: 16,     /* number of processes */
+		state: 8,
+#define JOBRUNNING      0       /* at least one proc running */
+#define JOBSTOPPED      1       /* all procs are stopped */
+#define JOBDONE         2       /* all procs are completed */
+#if JOBS
+		sigint: 1,      /* job was killed by SIGINT */
+		jobctl: 1,      /* job running under job control */
+#endif
+		waited: 1,      /* true if this entry has been waited for */
+		used: 1,        /* true if this entry is in used */
+		changed: 1;     /* true if status has changed */
+	struct job *prev_job;   /* previous job */
+};
+
+static pid_t backgndpid;        /* pid of last background process */
+static int job_warning;         /* user was warned about stopped jobs */
+#if JOBS
+static int jobctl;              /* true if doing job control */
+#endif
+
+static struct job *makejob(union node *, int);
+static int forkshell(struct job *, union node *, int);
+static int waitforjob(struct job *);
+static int stoppedjobs(void);
+
+#if ! JOBS
+#define setjobctl(on)   /* do nothing */
+#else
+static void setjobctl(int);
+static void showjobs(FILE *, int);
+#endif
+
+/*      $NetBSD: main.h,v 1.9 2002/11/24 22:35:41 christos Exp $        */
+
+
+/* pid of main shell */
+static int rootpid;
+/* true if we aren't a child of the main shell */
+static int rootshell;
+
+static void readcmdfile(char *);
+static void cmdloop(int);
+
+/*      $NetBSD: memalloc.h,v 1.13 2003/01/22 20:36:04 dsl Exp $        */
+
+
+struct stackmark {
+	struct stack_block *stackp;
+	char *stacknxt;
+	size_t stacknleft;
+	struct stackmark *marknext;
+};
+
+/* minimum size of a block */
+#define MINSIZE SHELL_ALIGN(504)
+
+struct stack_block {
+	struct stack_block *prev;
+	char space[MINSIZE];
+};
+
+static struct stack_block stackbase;
+static struct stack_block *stackp = &stackbase;
+static struct stackmark *markp;
+static char *stacknxt = stackbase.space;
+static size_t stacknleft = MINSIZE;
+static char *sstrend = stackbase.space + MINSIZE;
+static int herefd = -1;
+
+
+static pointer ckmalloc(size_t);
+static pointer ckrealloc(pointer, size_t);
+static char *savestr(const char *);
+static pointer stalloc(size_t);
+static void stunalloc(pointer);
+static void setstackmark(struct stackmark *);
+static void popstackmark(struct stackmark *);
+static void growstackblock(void);
+static void *growstackstr(void);
+static char *makestrspace(size_t, char *);
+static char *stnputs(const char *, size_t, char *);
+static char *stputs(const char *, char *);
+
+
+static inline char *_STPUTC(char c, char *p) {
+	if (p == sstrend)
+		p = growstackstr();
+	*p++ = c;
+	return p;
+}
+
+#define stackblock() ((void *)stacknxt)
+#define stackblocksize() stacknleft
+#define STARTSTACKSTR(p) ((p) = stackblock())
+#define STPUTC(c, p) ((p) = _STPUTC((c), (p)))
+#define CHECKSTRSPACE(n, p) \
+	({ \
+		char *q = (p); \
+		size_t l = (n); \
+		size_t m = sstrend - q; \
+		if (l > m) \
+			(p) = makestrspace(l, q); \
+		0; \
+	})
+#define USTPUTC(c, p)   (*p++ = (c))
+#define STACKSTRNUL(p)  ((p) == sstrend? (p = growstackstr(), *p = '\0') : (*p = '\0'))
+#define STUNPUTC(p)     (--p)
+#define STTOPC(p)       p[-1]
+#define STADJUST(amount, p)     (p += (amount))
+
+#define grabstackstr(p) stalloc((char *)(p) - (char *)stackblock())
+#define ungrabstackstr(s, p) stunalloc((s))
+#define stackstrend() ((void *)sstrend)
+
+#define ckfree(p)       free((pointer)(p))
+
+/*      $NetBSD: mystring.h,v 1.10 2002/11/24 22:35:42 christos Exp $   */
+
+
+#define DOLATSTRLEN 4
+
+static char *prefix(const char *, const char *);
+static int number(const char *);
+static int is_number(const char *);
+static char *single_quote(const char *);
+static char *sstrdup(const char *);
+
+#define equal(s1, s2)   (strcmp(s1, s2) == 0)
+#define scopy(s1, s2)   ((void)strcpy(s2, s1))
+
+/*      $NetBSD: options.h,v 1.16 2003/01/22 20:36:04 dsl Exp $ */
+
+struct shparam {
+	int nparam;             /* # of positional parameters (without $0) */
+	unsigned char malloc;   /* if parameter list dynamically allocated */
+	char **p;               /* parameter list */
+#ifdef CONFIG_ASH_GETOPTS
+	int optind;             /* next parameter to be processed by getopts */
+	int optoff;             /* used by getopts */
+#endif
+};
+
+
+#define eflag optlist[0]
+#define fflag optlist[1]
+#define Iflag optlist[2]
+#define iflag optlist[3]
+#define mflag optlist[4]
+#define nflag optlist[5]
+#define sflag optlist[6]
+#define xflag optlist[7]
+#define vflag optlist[8]
+#define Cflag optlist[9]
+#define aflag optlist[10]
+#define bflag optlist[11]
+#define uflag optlist[12]
+#define qflag optlist[13]
+
+#ifdef DEBUG
+#define nolog optlist[14]
+#define debug optlist[15]
+#define NOPTS   16
+#else
+#define NOPTS   14
+#endif
+
+/*      $NetBSD: options.c,v 1.33 2003/01/22 20:36:04 dsl Exp $ */
+
+
+static const char *const optletters_optnames[NOPTS] = {
+	"e"   "errexit",
+	"f"   "noglob",
+	"I"   "ignoreeof",
+	"i"   "interactive",
+	"m"   "monitor",
+	"n"   "noexec",
+	"s"   "stdin",
+	"x"   "xtrace",
+	"v"   "verbose",
+	"C"   "noclobber",
+	"a"   "allexport",
+	"b"   "notify",
+	"u"   "nounset",
+	"q"   "quietprofile",
+#ifdef DEBUG
+	"\0"  "nolog",
+	"\0"  "debug",
+#endif
+};
+
+#define optletters(n) optletters_optnames[(n)][0]
+#define optnames(n) (&optletters_optnames[(n)][1])
+
+
+static char optlist[NOPTS];
+
+
+static char *arg0;                     /* value of $0 */
+static struct shparam shellparam;      /* $@ current positional parameters */
+static char **argptr;                  /* argument list for builtin commands */
+static char *optionarg;                /* set by nextopt (like getopt) */
+static char *optptr;                   /* used by nextopt */
+
+static char *minusc;                   /* argument to -c option */
+
+
+static void procargs(int, char **);
+static void optschanged(void);
+static void setparam(char **);
+static void freeparam(volatile struct shparam *);
+static int shiftcmd(int, char **);
+static int setcmd(int, char **);
+static int nextopt(const char *);
+
+/*      $NetBSD: redir.h,v 1.14 2002/11/24 22:35:43 christos Exp $      */
+
+/* flags passed to redirect */
+#define REDIR_PUSH 01           /* save previous values of file descriptors */
+
+union node;
+static void redirect(union node *, int);
+static void popredir(int);
+static void clearredir(int);
+static int copyfd(int, int);
+static int redirectsafe(union node *, int);
+
+/*      $NetBSD: show.h,v 1.6 2003/01/22 20:36:04 dsl Exp $     */
+
+
+#ifdef DEBUG
+static void showtree(union node *);
+static void trace(const char *, ...);
+static void tracev(const char *, va_list);
+static void trargs(char **);
+static void trputc(int);
+static void trputs(const char *);
+static void opentrace(void);
+#endif
+
+/*      $NetBSD: trap.h,v 1.16 2002/11/24 22:35:43 christos Exp $       */
+
+
+/* trap handler commands */
+static char *trap[NSIG];
+/* current value of signal */
+static char sigmode[NSIG - 1];
+/* indicates specified signal received */
+static char gotsig[NSIG - 1];
+
+static void clear_traps(void);
+static void setsignal(int);
+static void ignoresig(int);
+static void onsig(int);
+static void dotrap(void);
+static void setinteractive(int);
+static void exitshell(void) __attribute__((__noreturn__));
+static int decode_signal(const char *, int);
+
+/*
+ * This routine is called when an error or an interrupt occurs in an
+ * interactive shell and control is returned to the main command loop.
+ */
+
+static void
+reset(void)
+{
+      /* from eval.c: */
+      {
+	      evalskip = 0;
+	      loopnest = 0;
+	      funcnest = 0;
+      }
+
+      /* from input.c: */
+      {
+	      parselleft = parsenleft = 0;      /* clear input buffer */
+	      popallfiles();
+      }
+
+      /* from parser.c: */
+      {
+	      tokpushback = 0;
+	      checkkwd = 0;
+      }
+
+      /* from redir.c: */
+      {
+	      clearredir(0);
+      }
+
+}
+
+#ifdef CONFIG_ASH_ALIAS
 static struct alias *atab[ATABSIZE];
 
-static void setalias(char *, char *);
-static struct alias **hashalias(const char *);
+static void setalias(const char *, const char *);
 static struct alias *freealias(struct alias *);
 static struct alias **__lookupalias(const char *);
 
-static void setalias(char *name, char *val)
+static void
+setalias(const char *name, const char *val)
 {
 	struct alias *ap, **app;
 
@@ -1327,15 +2079,15 @@
 	INTOFF;
 	if (ap) {
 		if (!(ap->flag & ALIASINUSE)) {
-			free(ap->val);
+			ckfree(ap->val);
 		}
-		ap->val = bb_xstrdup(val);
+		ap->val = savestr(val);
 		ap->flag &= ~ALIASDEAD;
 	} else {
 		/* not found */
-		ap = xmalloc(sizeof(struct alias));
-		ap->name = bb_xstrdup(name);
-		ap->val = bb_xstrdup(val);
+		ap = ckmalloc(sizeof (struct alias));
+		ap->name = savestr(name);
+		ap->val = savestr(val);
 		ap->flag = 0;
 		ap->next = 0;
 		*app = ap;
@@ -1343,7 +2095,8 @@
 	INTON;
 }
 
-static int unalias(char *name)
+static int
+unalias(const char *name)
 {
 	struct alias **app;
 
@@ -1359,7 +2112,8 @@
 	return (1);
 }
 
-static void rmaliases(void)
+static void
+rmaliases(void)
 {
 	struct alias *ap, **app;
 	int i;
@@ -1377,20 +2131,21 @@
 	INTON;
 }
 
-static void printalias(const struct alias *ap)
+static struct alias *
+lookupalias(const char *name, int check)
 {
-	char *p;
+	struct alias *ap = *__lookupalias(name);
 
-	p = single_quote(ap->val);
-	printf("alias %s=%s\n", ap->name, p);
-	stunalloc(p);
+	if (check && ap && (ap->flag & ALIASINUSE))
+		return (NULL);
+	return (ap);
 }
 
-
 /*
  * TODO - sort output
  */
-static int aliascmd(int argc, char **argv)
+static int
+aliascmd(int argc, char **argv)
 {
 	char *n, *v;
 	int ret = 0;
@@ -1406,9 +2161,9 @@
 		return (0);
 	}
 	while ((n = *++argv) != NULL) {
-		if ((v = strchr(n + 1, '=')) == NULL) {	/* n+1: funny ksh stuff */
+		if ((v = strchr(n+1, '=')) == NULL) { /* n+1: funny ksh stuff */
 			if ((ap = *__lookupalias(n)) == NULL) {
-				out2fmt("%s: %s not found\n", "alias", n);
+				fprintf(stderr, "%s: %s not found\n", "alias", n);
 				ret = 1;
 			} else
 				printalias(ap);
@@ -1421,7 +2176,8 @@
 	return (ret);
 }
 
-static int unaliascmd(int argc, char **argv)
+static int
+unaliascmd(int argc, char **argv)
 {
 	int i;
 
@@ -1433,7 +2189,7 @@
 	}
 	for (i = 0; *argptr; argptr++) {
 		if (unalias(*argptr)) {
-			out2fmt("%s: %s not found\n", "unalias", *argptr);
+			fprintf(stderr, "%s: %s not found\n", "unalias", *argptr);
 			i = 1;
 		}
 	}
@@ -1441,18 +2197,8 @@
 	return (i);
 }
 
-static struct alias **hashalias(const char *p)
-{
-	unsigned int hashval;
-
-	hashval = *p << 4;
-	while (*p)
-		hashval += *p++;
-	return &atab[hashval % ATABSIZE];
-}
-
-static struct alias *freealias(struct alias *ap)
-{
+static struct alias *
+freealias(struct alias *ap) {
 	struct alias *next;
 
 	if (ap->flag & ALIASINUSE) {
@@ -1461,16 +2207,33 @@
 	}
 
 	next = ap->next;
-	free(ap->name);
-	free(ap->val);
-	free(ap);
+	ckfree(ap->name);
+	ckfree(ap->val);
+	ckfree(ap);
 	return next;
 }
 
+static void
+printalias(const struct alias *ap) {
+	out1fmt("%s=%s\n", ap->name, single_quote(ap->val));
+}
 
-static struct alias **__lookupalias(const char *name)
-{
-	struct alias **app = hashalias(name);
+static struct alias **
+__lookupalias(const char *name) {
+	unsigned int hashval;
+	struct alias **app;
+	const char *p;
+	unsigned int ch;
+
+	p = name;
+
+	ch = (unsigned char)*p;
+	hashval = ch << 4;
+	while (ch) {
+		hashval += ch;
+		ch = (unsigned char)*++p;
+	}
+	app = &atab[hashval % ATABSIZE];
 
 	for (; *app; app = &(*app)->next) {
 		if (equal(name, (*app)->name)) {
@@ -1480,362 +2243,257 @@
 
 	return app;
 }
-#endif
+#endif /* CONFIG_ASH_ALIAS */
 
-#ifdef CONFIG_ASH_MATH_SUPPORT
-/* The generated file arith.c has been replaced with a custom hand
- * written implementation written by Aaron Lehmann <aaronl@vitelus.com>.
- * This is now part of libbb, so that it can be used by all the shells
- * in busybox. */
-static void expari(int);
-#endif
 
-static char *trap[NSIG];	/* trap handler commands */
-static char sigmode[NSIG - 1];	/* current value of signal */
-static char gotsig[NSIG - 1];	/* indicates specified signal received */
-static int pendingsigs;	/* indicates some signal received */
+/*      $NetBSD: cd.c,v 1.30 2003/01/22 20:36:03 dsl Exp $      */
 
 /*
- * This file was generated by the mkbuiltins program.
+ * The cd and pwd commands.
  */
 
-#ifdef CONFIG_ASH_JOB_CONTROL
-static int bgcmd(int, char **);
-static int fgcmd(int, char **);
-static int killcmd(int, char **);
-#endif
-static int bltincmd(int, char **);
-static int cdcmd(int, char **);
-static int breakcmd(int, char **);
+#define CD_PHYSICAL 1
+#define CD_PRINT 2
 
-#ifdef CONFIG_ASH_CMDCMD
-static int commandcmd(int, char **);
-#endif
-static int dotcmd(int, char **);
-static int evalcmd(int, char **);
-static int execcmd(int, char **);
-static int exitcmd(int, char **);
-static int exportcmd(int, char **);
-static int histcmd(int, char **);
-static int hashcmd(int, char **);
-static int helpcmd(int, char **);
-static int jobscmd(int, char **);
-static int localcmd(int, char **);
-static int pwdcmd(int, char **);
-static int readcmd(int, char **);
-static int returncmd(int, char **);
-static int setcmd(int, char **);
-static int setvarcmd(int, char **);
-static int shiftcmd(int, char **);
-static int trapcmd(int, char **);
-static int umaskcmd(int, char **);
+static int docd(const char *, int);
+static int cdopt(void);
 
-#ifdef CONFIG_ASH_ALIAS
-static int aliascmd(int, char **);
-static int unaliascmd(int, char **);
-#endif
-static int unsetcmd(int, char **);
-static int waitcmd(int, char **);
-static int ulimitcmd(int, char **);
-static int timescmd(int, char **);
+static char *curdir = nullstr;          /* current working directory */
+static char *physdir = nullstr;         /* physical working directory */
 
-#ifdef CONFIG_ASH_MATH_SUPPORT
-static int letcmd(int, char **);
-#endif
-static int typecmd(int, char **);
+static int
+cdopt(void)
+{
+	int flags = 0;
+	int i, j;
 
-#ifdef CONFIG_ASH_GETOPTS
-static int getoptscmd(int, char **);
-#endif
+	j = 'L';
+	while ((i = nextopt("LP"))) {
+		if (i != j) {
+			flags ^= CD_PHYSICAL;
+			j = i;
+		}
+	}
 
-#ifndef CONFIG_TRUE
-static int true_main(int, char **);
-#endif
-#ifndef CONFIG_FALSE
-static int false_main(int, char **);
-#endif
+	return flags;
+}
 
-static void setpwd(const char *, int);
-
-
-#define BUILTIN_NOSPEC  "0"
-#define BUILTIN_SPECIAL "1"
-#define BUILTIN_REGULAR "2"
-#define BUILTIN_ASSIGN  "4"
-#define BUILTIN_SPEC_ASSG  "5"
-#define BUILTIN_REG_ASSG   "6"
-
-#define IS_BUILTIN_SPECIAL(builtincmd) ((builtincmd)->name[0] & 1)
-#define IS_BUILTIN_REGULAR(builtincmd) ((builtincmd)->name[0] & 2)
-#define IS_BUILTIN_ASSIGN(builtincmd) ((builtincmd)->name[0] & 4)
-
-struct builtincmd {
-	const char *name;
-	int (*const builtinfunc) (int, char **);
-	//unsigned flags;
-};
-
-
-/* It is CRUCIAL that this listing be kept in ascii order, otherwise
- * the binary search in find_builtin() will stop working. If you value
- * your kneecaps, you'll be sure to *make sure* that any changes made
- * to this array result in the listing remaining in ascii order. You
- * have been warned.
- */
-static const struct builtincmd builtincmds[] = {
-	{BUILTIN_SPECIAL ".", dotcmd},	/* first, see declare DOTCMD */
-	{BUILTIN_SPECIAL ":", true_main},
-#ifdef CONFIG_ASH_ALIAS
-	{BUILTIN_REG_ASSG "alias", aliascmd},
-#endif
-#ifdef CONFIG_ASH_JOB_CONTROL
-	{BUILTIN_REGULAR "bg", bgcmd},
-#endif
-	{BUILTIN_SPECIAL "break", breakcmd},
-	{BUILTIN_SPECIAL "builtin", bltincmd},
-	{BUILTIN_REGULAR "cd", cdcmd},
-	{BUILTIN_NOSPEC "chdir", cdcmd},
-#ifdef CONFIG_ASH_CMDCMD
-	{BUILTIN_REGULAR "command", commandcmd},
-#endif
-	{BUILTIN_SPECIAL "continue", breakcmd},
-	{BUILTIN_SPECIAL "eval", evalcmd},
-	{BUILTIN_SPECIAL "exec", execcmd},
-	{BUILTIN_SPECIAL "exit", exitcmd},
-	{BUILTIN_SPEC_ASSG "export", exportcmd},
-	{BUILTIN_REGULAR "false", false_main},
-	{BUILTIN_REGULAR "fc", histcmd},
-#ifdef CONFIG_ASH_JOB_CONTROL
-	{BUILTIN_REGULAR "fg", fgcmd},
-#endif
-#ifdef CONFIG_ASH_GETOPTS
-	{BUILTIN_REGULAR "getopts", getoptscmd},
-#endif
-	{BUILTIN_NOSPEC "hash", hashcmd},
-	{BUILTIN_NOSPEC "help", helpcmd},
-	{BUILTIN_REGULAR "jobs", jobscmd},
-#ifdef CONFIG_ASH_JOB_CONTROL
-	{BUILTIN_REGULAR "kill", killcmd},
-#endif
-#ifdef CONFIG_ASH_MATH_SUPPORT
-	{BUILTIN_REGULAR "let", letcmd},
-#endif
-	{BUILTIN_ASSIGN "local", localcmd},
-	{BUILTIN_NOSPEC "pwd", pwdcmd},
-	{BUILTIN_REGULAR "read", readcmd},
-	{BUILTIN_SPEC_ASSG "readonly", exportcmd},
-	{BUILTIN_SPECIAL "return", returncmd},
-	{BUILTIN_SPECIAL "set", setcmd},
-	{BUILTIN_NOSPEC "setvar", setvarcmd},
-	{BUILTIN_SPECIAL "shift", shiftcmd},
-	{BUILTIN_SPECIAL "times", timescmd},
-	{BUILTIN_SPECIAL "trap", trapcmd},
-	{BUILTIN_REGULAR "true", true_main},
-	{BUILTIN_NOSPEC "type", typecmd},
-	{BUILTIN_NOSPEC "ulimit", ulimitcmd},
-	{BUILTIN_REGULAR "umask", umaskcmd},
-#ifdef CONFIG_ASH_ALIAS
-	{BUILTIN_REGULAR "unalias", unaliascmd},
-#endif
-	{BUILTIN_SPECIAL "unset", unsetcmd},
-	{BUILTIN_REGULAR "wait", waitcmd},
-};
-
-#define NUMBUILTINS  (sizeof (builtincmds) / sizeof (struct builtincmd) )
-
-#define DOTCMD &builtincmds[0]
-static struct builtincmd *BLTINCMD;
-static struct builtincmd *EXECCMD;
-static struct builtincmd *EVALCMD;
-
-/* states */
-#define JOBSTOPPED 1	/* all procs are stopped */
-#define JOBDONE 2		/* all procs are completed */
-
-/*
- * A job structure contains information about a job.  A job is either a
- * single process or a set of processes contained in a pipeline.  In the
- * latter case, pidlist will be non-NULL, and will point to a -1 terminated
- * array of pids.
- */
-
-struct procstat {
-	pid_t pid;			/* process id */
-	int status;			/* status flags (defined above) */
-	char *cmd;			/* text of command being run */
-};
-
-
-static int job_warning;	/* user was warned about stopped jobs */
-
-#ifdef CONFIG_ASH_JOB_CONTROL
-static void setjobctl(int enable);
-#else
-#define setjobctl(on)	/* do nothing */
-#endif
-
-
-struct job {
-	struct procstat ps0;	/* status of process */
-	struct procstat *ps;	/* status or processes when more than one */
-	short nprocs;		/* number of processes */
-	short pgrp;			/* process group of this job */
-	char state;			/* true if job is finished */
-	char used;			/* true if this entry is in used */
-	char changed;		/* true if status has changed */
-#ifdef CONFIG_ASH_JOB_CONTROL
-	char jobctl;		/* job running under job control */
-#endif
-};
-
-static struct job *jobtab;	/* array of jobs */
-static int njobs;		/* size of array */
-static int backgndpid = -1;	/* pid of last background process */
-
-#ifdef CONFIG_ASH_JOB_CONTROL
-static int initialpgrp;	/* pgrp of shell on invocation */
-static int curjob;		/* current job */
-static int jobctl;
-#endif
-
-static struct job *makejob(const union node *, int);
-static int forkshell(struct job *, const union node *, int);
-static int waitforjob(struct job *);
-
-static int docd(char *, int);
-static void getpwd(void);
-
-static char *padvance(const char **, const char *);
-
-static char nullstr[1];	/* zero length string */
-static char *curdir = nullstr;	/* current working directory */
-
-static int cdcmd(int argc, char **argv)
+static int
+cdcmd(int argc, char **argv)
 {
 	const char *dest;
 	const char *path;
-	char *p;
+	const char *p;
+	char c;
 	struct stat statb;
-	int print = 0;
+	int flags;
 
-	nextopt(nullstr);
-	if ((dest = *argptr) == NULL && (dest = bltinlookup("HOME")) == NULL)
-		error("HOME not set");
-	if (*dest == '\0')
-		dest = ".";
-	if (dest[0] == '-' && dest[1] == '\0') {
+	flags = cdopt();
+	dest = *argptr;
+	if (!dest)
+		dest = bltinlookup(homestr);
+	else if (dest[0] == '-' && dest[1] == '\0') {
 		dest = bltinlookup("OLDPWD");
-		if (!dest || !*dest) {
-			dest = curdir;
-		}
-		print = 1;
-		if (dest)
-			print = 1;
-		else
-			dest = ".";
+		flags |= CD_PRINT;
+		goto step7;
 	}
-	if (*dest == '/' || (path = bltinlookup("CDPATH")) == NULL)
-		path = nullstr;
-	while ((p = padvance(&path, dest)) != NULL) {
+	if (!dest)
+		dest = nullstr;
+	if (*dest == '/')
+		goto step7;
+	if (*dest == '.') {
+		c = dest[1];
+dotdot:
+		switch (c) {
+		case '\0':
+		case '/':
+			goto step6;
+		case '.':
+			c = dest[2];
+			if (c != '.')
+				goto dotdot;
+		}
+	}
+	if (!*dest)
+		dest = ".";
+	if (!(path = bltinlookup("CDPATH"))) {
+step6:
+step7:
+		p = dest;
+		goto docd;
+	}
+	do {
+		c = *path;
+		p = padvance(&path, dest);
 		if (stat(p, &statb) >= 0 && S_ISDIR(statb.st_mode)) {
-			if (!print) {
-				/*
-				 * XXX - rethink
-				 */
-				if (p[0] == '.' && p[1] == '/' && p[2] != '\0')
-					p += 2;
-				print = strcmp(p, dest);
-			}
-			if (docd(p, print) >= 0)
-				return 0;
-
+			if (c && c != ':')
+				flags |= CD_PRINT;
+docd:
+			if (!docd(p, flags))
+				goto out;
+			break;
 		}
-	}
+	} while (path);
 	error("can't cd to %s", dest);
 	/* NOTREACHED */
+out:
+	if (flags & CD_PRINT)
+		out1fmt(snlfmt, curdir);
+	return 0;
 }
 
 
 /*
  * Update curdir (the name of the current directory) in response to a
- * cd command.  We also call hashcd to let the routines in exec.c know
- * that the current directory has changed.
+ * cd command.
  */
 
-static void hashcd(void);
-
-static inline void updatepwd(const char *dir)
+static inline const char *
+updatepwd(const char *dir)
 {
-	hashcd();			/* update command hash table */
+	char *new;
+	char *p;
+	char *cdcomppath;
+	const char *lim;
 
-	/*
-	 * If our argument is NULL, we don't know the current directory
-	 */
-	if (dir == NULL || curdir == nullstr) {
-		setpwd(0, 1);
-	} else {
-		setpwd(dir, 1);
+	cdcomppath = sstrdup(dir);
+	STARTSTACKSTR(new);
+	if (*dir != '/') {
+		if (curdir == nullstr)
+			return 0;
+		new = stputs(curdir, new);
 	}
+	new = makestrspace(strlen(dir) + 2, new);
+	lim = stackblock() + 1;
+	if (*dir != '/') {
+		if (new[-1] != '/')
+			USTPUTC('/', new);
+		if (new > lim && *lim == '/')
+			lim++;
+	} else {
+		USTPUTC('/', new);
+		cdcomppath++;
+		if (dir[1] == '/' && dir[2] != '/') {
+			USTPUTC('/', new);
+			cdcomppath++;
+			lim++;
+		}
+	}
+	p = strtok(cdcomppath, "/");
+	while (p) {
+		switch(*p) {
+		case '.':
+			if (p[1] == '.' && p[2] == '\0') {
+				while (new > lim) {
+					STUNPUTC(new);
+					if (new[-1] == '/')
+						break;
+				}
+				break;
+			} else if (p[1] == '\0')
+				break;
+			/* fall through */
+		default:
+			new = stputs(p, new);
+			USTPUTC('/', new);
+		}
+		p = strtok(0, "/");
+	}
+	if (new > lim)
+		STUNPUTC(new);
+	*new = 0;
+	return stackblock();
 }
 
 /*
- * Actually do the chdir.  In an interactive shell, print the
- * directory name if "print" is nonzero.
+ * Actually do the chdir.  We also call hashcd to let the routines in exec.c
+ * know that the current directory has changed.
  */
 
-static int docd(char *dest, int print)
+static int
+docd(const char *dest, int flags)
 {
-	TRACE(("docd(\"%s\", %d) called\n", dest, print));
+	const char *dir = 0;
+	int err;
+
+	TRACE(("docd(\"%s\", %d) called\n", dest, flags));
+
 	INTOFF;
-	if (chdir(dest) < 0) {
-		INTON;
-		return -1;
+	if (!(flags & CD_PHYSICAL)) {
+		dir = updatepwd(dest);
+		if (dir)
+			dest = dir;
 	}
-	updatepwd(dest);
+	err = chdir(dest);
+	if (err)
+		goto out;
+	setpwd(dir, 1);
+	hashcd();
+out:
 	INTON;
-	if (print && iflag)
-		puts(curdir);
+	return err;
+}
+
+/*
+ * Find out what the current directory is. If we already know the current
+ * directory, this routine returns immediately.
+ */
+static inline char *
+getpwd(void)
+{
+	char *dir = getcwd(0, 0);
+	return dir ? dir : nullstr;
+}
+
+static int
+pwdcmd(int argc, char **argv)
+{
+	int flags;
+	const char *dir = curdir;
+
+	flags = cdopt();
+	if (flags) {
+		if (physdir == nullstr)
+			setpwd(dir, 0);
+		dir = physdir;
+	}
+	out1fmt(snlfmt, dir);
 	return 0;
 }
 
-
-static int pwdcmd(int argc, char **argv)
+static void
+setpwd(const char *val, int setold)
 {
-	puts(curdir);
-	return 0;
-}
+	char *oldcur, *dir;
 
-/* Ask system the current directory */
-static void getpwd(void)
-{
-	curdir = xgetcwd(0);
-	if (curdir == 0)
-		curdir = nullstr;
-}
-
-static void setpwd(const char *val, int setold)
-{
-	char *cated = NULL;
+	oldcur = dir = curdir;
 
 	if (setold) {
-		setvar("OLDPWD", curdir, VEXPORT);
+		setvar("OLDPWD", oldcur, VEXPORT);
 	}
 	INTOFF;
-	if (curdir != nullstr) {
-		if (val != NULL && *val != '/')
-			val = cated = concat_path_file(curdir, val);
-		free(curdir);
+	if (physdir != nullstr) {
+		if (physdir != oldcur)
+			free(physdir);
+		physdir = nullstr;
 	}
-	if (!val)
-		getpwd();
-	else
-		curdir = bb_simplify_path(val);
-	if (cated)
-		free(cated);
+	if (oldcur == val || !val) {
+		char *s = getpwd();
+		physdir = s;
+		if (!val)
+			dir = s;
+	} else
+		dir = savestr(val);
+	if (oldcur != dir && oldcur != nullstr) {
+		free(oldcur);
+	}
+	curdir = dir;
 	INTON;
-	setvar("PWD", curdir, VEXPORT);
+	setvar("PWD", dir, VEXPORT);
 }
 
+/*      $NetBSD: error.c,v 1.30 2003/01/22 20:36:03 dsl Exp $   */
+
 /*
  * Errors and exceptions.
  */
@@ -1844,32 +2502,10 @@
  * Code to handle exceptions in C.
  */
 
-/*
- * We enclose jmp_buf in a structure so that we can declare pointers to
- * jump locations.  The global variable handler contains the location to
- * jump to when an exception occurs, and the global variable exception
- * contains a code identifying the exeception.  To implement nested
- * exception handlers, the user should save the value of handler on entry
- * to an inner scope, set handler to point to a jmploc structure for the
- * inner scope, and restore handler on exit from the scope.
- */
 
-struct jmploc {
-	jmp_buf loc;
-};
-
-/* exceptions */
-#define EXINT 0			/* SIGINT received */
-#define EXERROR 1		/* a generic error */
-#define EXSHELLPROC 2	/* execute a shell procedure */
-#define EXEXEC 3		/* command execution failed */
-#define EXREDIR 4		/* redirection error */
-
-static struct jmploc *handler;
-static int exception;
 
 static void exverror(int, const char *, va_list)
-	__attribute__ ((__noreturn__));
+    __attribute__((__noreturn__));
 
 /*
  * Called to raise an exception.  Since C doesn't include exceptions, we
@@ -1877,15 +2513,15 @@
  * stored in the global variable "exception".
  */
 
-static void exraise(int) __attribute__ ((__noreturn__));
-
-static void exraise(int e)
+static void
+exraise(int e)
 {
 #ifdef DEBUG
 	if (handler == NULL)
 		abort();
 #endif
-	flushall();
+	INTOFF;
+
 	exception = e;
 	longjmp(handler->loc, 1);
 }
@@ -1895,62 +2531,74 @@
  * Called from trap.c when a SIGINT is received.  (If the user specifies
  * that SIGINT is to be trapped or ignored using the trap builtin, then
  * this routine is not called.)  Suppressint is nonzero when interrupts
- * are held using the INTOFF macro.  The call to _exit is necessary because
- * there is a short period after a fork before the signal handlers are
- * set to the appropriate value for the child.  (The test for iflag is
- * just defensive programming.)
+ * are held using the INTOFF macro.  (The test for iflag is just
+ * defensive programming.)
  */
 
-static void onint(void)
-{
-	sigset_t mysigset;
+static void
+onint(void) {
+	int i;
 
-	if (suppressint) {
-		intpending++;
-		return;
-	}
 	intpending = 0;
-	sigemptyset(&mysigset);
-	sigprocmask(SIG_SETMASK, &mysigset, NULL);
-	if (!(rootshell && iflag)) {
-		signal(SIGINT, SIG_DFL);
-		raise(SIGINT);
+	sigsetmask(0);
+	i = EXSIG;
+	if (gotsig[SIGINT - 1] && !trap[SIGINT]) {
+		if (!(rootshell && iflag)) {
+			signal(SIGINT, SIG_DFL);
+			raise(SIGINT);
+		}
+		i = EXINT;
 	}
-	exraise(EXINT);
+	exraise(i);
 	/* NOTREACHED */
 }
 
+static void
+exvwarning(const char *msg, va_list ap)
+{
+	FILE *errs;
+	const char *name;
+	const char *fmt;
 
-static char *commandname;	/* currently executing command */
+	errs = stderr;
+	name = arg0;
+	fmt = "%s: ";
+	if (commandname) {
+		name = commandname;
+		fmt = "%s: %d: ";
+	}
+	fprintf(errs, fmt, name, startlinno);
+	vfprintf(errs, msg, ap);
+	outcslow('\n', errs);
+}
 
 /*
- * Exverror is called to raise the error exception.  If the first argument
+ * Exverror is called to raise the error exception.  If the second argument
  * is not NULL then error prints an error message using printf style
  * formatting.  It then raises the error exception.
  */
-static void exverror(int cond, const char *msg, va_list ap)
+static void
+exverror(int cond, const char *msg, va_list ap)
 {
-	CLEAR_PENDING_INT;
-	INTOFF;
-
 #ifdef DEBUG
-	if (msg)
-		TRACE(("exverror(%d, \"%s\") pid=%d\n", cond, msg, getpid()));
-	else
-		TRACE(("exverror(%d, NULL) pid=%d\n", cond, getpid()));
-#endif
 	if (msg) {
-		if (commandname)
-			out2fmt("%s: ", commandname);
-		vfprintf(stderr, msg, ap);
-		out2c('\n');
-	}
+		TRACE(("exverror(%d, \"", cond));
+		TRACEV((msg, ap));
+		TRACE(("\") pid=%d\n", getpid()));
+	} else
+		TRACE(("exverror(%d, NULL) pid=%d\n", cond, getpid()));
+	if (msg)
+#endif
+		exvwarning(msg, ap);
+
+	flushall();
 	exraise(cond);
 	/* NOTREACHED */
 }
 
 
-static void error(const char *msg, ...)
+static void
+error(const char *msg, ...)
 {
 	va_list ap;
 
@@ -1961,7 +2609,8 @@
 }
 
 
-static void exerror(int cond, const char *msg, ...)
+static void
+exerror(int cond, const char *msg, ...)
 {
 	va_list ap;
 
@@ -1971,82 +2620,20 @@
 	va_end(ap);
 }
 
-
-
 /*
- * Table of error messages.
+ * error/warning routines for external builtins
  */
 
-struct errname {
-	short errcode;		/* error number */
-	short action;		/* operation which encountered the error */
-};
+static void
+sh_warnx(const char *fmt, ...)
+{
+	va_list ap;
 
-/*
- * Types of operations (passed to the errmsg routine).
- */
+	va_start(ap, fmt);
+	exvwarning(fmt, ap);
+	va_end(ap);
+}
 
-#define E_OPEN 01		/* opening a file */
-#define E_CREAT 02		/* creating a file */
-#define E_EXEC 04		/* executing a program */
-
-#define ALL (E_OPEN|E_CREAT|E_EXEC)
-
-static const struct errname errormsg[] = {
-	{EINTR, ALL},
-	{EACCES, ALL},
-	{EIO, ALL},
-	{ENOENT, E_OPEN},
-	{ENOENT, E_CREAT},
-	{ENOENT, E_EXEC},
-	{ENOTDIR, E_OPEN},
-	{ENOTDIR, E_CREAT},
-	{ENOTDIR, E_EXEC},
-	{EISDIR, ALL},
-	{EEXIST, E_CREAT},
-#ifdef EMFILE
-	{EMFILE, ALL},
-#endif
-	{ENFILE, ALL},
-	{ENOSPC, ALL},
-#ifdef EDQUOT
-	{EDQUOT, ALL},
-#endif
-#ifdef ENOSR
-	{ENOSR, ALL},
-#endif
-	{ENXIO, ALL},
-	{EROFS, ALL},
-	{ETXTBSY, ALL},
-#ifdef EAGAIN
-	{EAGAIN, E_EXEC},
-#endif
-	{ENOMEM, ALL},
-#ifdef ENOLINK
-	{ENOLINK, ALL},
-#endif
-#ifdef EMULTIHOP
-	{EMULTIHOP, ALL},
-#endif
-#ifdef ECOMM
-	{ECOMM, ALL},
-#endif
-#ifdef ESTALE
-	{ESTALE, ALL},
-#endif
-#ifdef ETIMEDOUT
-	{ETIMEDOUT, ALL},
-#endif
-#ifdef ELOOP
-	{ELOOP, ALL},
-#endif
-	{E2BIG, E_EXEC},
-#ifdef ELIBACC
-	{ELIBACC, E_EXEC},
-#endif
-};
-
-#define ERRNAME_SIZE (sizeof(errormsg)/sizeof(struct errname))
 
 /*
  * Return a string describing an error.  The returned string may be a
@@ -2054,57 +2641,47 @@
  * Action describes the operation that got the error.
  */
 
-static const char *errmsg(int e, int action)
+static const char *
+errmsg(int e, const char *em)
 {
-	struct errname const *ep;
-	static char buf[12];
+	if(e == ENOENT || e == ENOTDIR) {
 
-	for (ep = errormsg; ep < errormsg + ERRNAME_SIZE; ep++) {
-		if (ep->errcode == e && (ep->action & action) != 0)
-			return strerror(e);
+		return em;
 	}
-
-	snprintf(buf, sizeof buf, "error %d", e);
-	return buf;
+	return strerror(e);
 }
 
 
-#ifdef CONFIG_ASH_OPTIMIZE_FOR_SIZE
-static void __inton()
-{
-	if (--suppressint == 0 && intpending) {
-		onint();
-	}
-}
-static void forceinton(void)
-{
-	suppressint = 0;
-	if (intpending)
-		onint();
-}
-#endif
+/*      $NetBSD: eval.c,v 1.71 2003/01/23 03:33:16 rafal Exp $  */
+
+/*
+ * Evaluate a command.
+ */
 
 /* flags in argument to evaltree */
-#define EV_EXIT 01		/* exit after evaluating tree */
-#define EV_TESTED 02	/* exit status is checked; ignore -e flag */
-#define EV_BACKCMD 04	/* command executing within back quotes */
-
-static int evalskip;	/* set if we are skipping commands */
-static int skipcount;	/* number of levels to skip */
-static int loopnest;	/* current loop nesting level */
-static int funcnest;	/* depth of function calls */
+#define EV_EXIT 01              /* exit after evaluating tree */
+#define EV_TESTED 02            /* exit status is checked; ignore -e flag */
+#define EV_BACKCMD 04           /* command executing within back quotes */
 
 
-static struct strlist *cmdenviron;	/* environment for builtin command */
-static int exitstatus;	/* exit status of last command */
-static int oexitstatus;	/* saved exit status */
-
-static void evalsubshell(const union node *, int);
+static void evalloop(union node *, int);
+static void evalfor(union node *, int);
+static void evalcase(union node *, int);
+static void evalsubshell(union node *, int);
 static void expredir(union node *);
+static void evalpipe(union node *, int);
+static void evalcommand(union node *, int);
+static int evalbltin(const struct builtincmd *, int, char **);
+static int evalfun(struct funcnode *, int, char **, int);
 static void prehash(union node *);
-static void eprintlist(struct strlist *);
+static int eprintlist(struct strlist *, int);
+static int bltincmd(int, char **);
 
-static union node *parsecmd(int);
+
+static const struct builtincmd bltin = {
+	"\0\0", bltincmd
+};
+
 
 /*
  * Called to reset things after an exception.
@@ -2113,9 +2690,9 @@
 /*
  * The eval commmand.
  */
-static void evalstring(char *, int);
 
-static int evalcmd(int argc, char **argv)
+static int
+evalcmd(int argc, char **argv)
 {
 	char *p;
 	char *concat;
@@ -2127,8 +2704,7 @@
 			STARTSTACKSTR(concat);
 			ap = argv + 2;
 			for (;;) {
-				while (*p)
-					STPUTC(*p++, concat);
+				concat = stputs(p, concat);
 				if ((p = *ap++) == NULL)
 					break;
 				STPUTC(' ', concat);
@@ -2141,79 +2717,154 @@
 	return exitstatus;
 }
 
+
 /*
  * Execute a command or commands contained in a string.
  */
 
-static void evaltree(union node *, int);
-static void setinputstring(char *);
-static void popfile(void);
-static void setstackmark(struct stackmark *mark);
-static void popstackmark(struct stackmark *mark);
-
-
-static void evalstring(char *s, int flag)
+static void
+evalstring(char *s, int flag)
 {
 	union node *n;
 	struct stackmark smark;
 
 	setstackmark(&smark);
 	setinputstring(s);
+
 	while ((n = parsecmd(0)) != NEOF) {
 		evaltree(n, flag);
 		popstackmark(&smark);
+		if (evalskip)
+			break;
 	}
 	popfile();
 	popstackmark(&smark);
 }
 
-static struct builtincmd *find_builtin(const char *);
-static void expandarg(union node *, struct arglist *, int);
-static void calcsize(const union node *);
-static union node *copynode(const union node *);
+
 
 /*
- * Make a copy of a parse tree.
+ * Evaluate a parse tree.  The value is left in the global variable
+ * exitstatus.
  */
 
-static int funcblocksize;	/* size of structures in function */
-static int funcstringsize;	/* size of strings in node */
-static pointer funcblock;	/* block to allocate function from */
-static char *funcstring;	/* block to allocate strings from */
-
-
-static inline union node *copyfunc(union node *n)
+static void
+evaltree(union node *n, int flags)
 {
-	if (n == NULL)
-		return NULL;
-	funcblocksize = 0;
-	funcstringsize = 0;
-	calcsize(n);
-	funcblock = xmalloc(funcblocksize + funcstringsize);
-	funcstring = (char *) funcblock + funcblocksize;
-	return copynode(n);
-}
-
-/*
- * Add a new command entry, replacing any existing command entry for
- * the same name.
- */
-
-static inline void addcmdentry(char *name, struct cmdentry *entry)
-{
-	struct tblentry *cmdp;
-
-	INTOFF;
-	cmdp = cmdlookup(name, 1);
-	if (cmdp->cmdtype == CMDFUNCTION) {
-		free(cmdp->param.func);
+	int checkexit = 0;
+	void (*evalfn)(union node *, int);
+	unsigned isor;
+	int status;
+	if (n == NULL) {
+		TRACE(("evaltree(NULL) called\n"));
+		goto out;
 	}
-	cmdp->cmdtype = entry->cmdtype;
-	cmdp->param = entry->u;
-	INTON;
+	TRACE(("pid %d, evaltree(%p: %d, %d) called\n",
+	    getpid(), n, n->type, flags));
+	switch (n->type) {
+	default:
+#ifdef DEBUG
+		out1fmt("Node type = %d\n", n->type);
+		flushout(stdout);
+		break;
+#endif
+	case NNOT:
+		evaltree(n->nnot.com, EV_TESTED);
+		status = !exitstatus;
+		goto setstatus;
+	case NREDIR:
+		expredir(n->nredir.redirect);
+		status = redirectsafe(n->nredir.redirect, REDIR_PUSH);
+		if (!status) {
+			evaltree(n->nredir.n, flags & EV_TESTED);
+			status = exitstatus;
+		}
+		popredir(0);
+		goto setstatus;
+	case NCMD:
+		evalfn = evalcommand;
+checkexit:
+		if (eflag && !(flags & EV_TESTED))
+			checkexit = ~0;
+		goto calleval;
+	case NFOR:
+		evalfn = evalfor;
+		goto calleval;
+	case NWHILE:
+	case NUNTIL:
+		evalfn = evalloop;
+		goto calleval;
+	case NSUBSHELL:
+	case NBACKGND:
+		evalfn = evalsubshell;
+		goto calleval;
+	case NPIPE:
+		evalfn = evalpipe;
+		goto checkexit;
+	case NCASE:
+		evalfn = evalcase;
+		goto calleval;
+	case NAND:
+	case NOR:
+	case NSEMI:
+#if NAND + 1 != NOR
+#error NAND + 1 != NOR
+#endif
+#if NOR + 1 != NSEMI
+#error NOR + 1 != NSEMI
+#endif
+		isor = n->type - NAND;
+		evaltree(
+			n->nbinary.ch1,
+			(flags | ((isor >> 1) - 1)) & EV_TESTED
+		);
+		if (!exitstatus == isor)
+			break;
+		if (!evalskip) {
+			n = n->nbinary.ch2;
+evaln:
+			evalfn = evaltree;
+calleval:
+			evalfn(n, flags);
+			break;
+		}
+		break;
+	case NIF:
+		evaltree(n->nif.test, EV_TESTED);
+		if (evalskip)
+			break;
+		if (exitstatus == 0) {
+			n = n->nif.ifpart;
+			goto evaln;
+		} else if (n->nif.elsepart) {
+			n = n->nif.elsepart;
+			goto evaln;
+		}
+		goto success;
+	case NDEFUN:
+		defun(n->narg.text, n->narg.next);
+success:
+		status = 0;
+setstatus:
+		exitstatus = status;
+		break;
+	}
+out:
+	if (pendingsigs)
+		dotrap();
+	if (flags & EV_EXIT || checkexit & exitstatus)
+		exraise(EXEXIT);
 }
 
-static inline void evalloop(const union node *n, int flags)
+
+#if !defined(__alpha__) || (defined(__GNUC__) && __GNUC__ >= 3)
+static
+#endif
+void evaltreenr(union node *, int) __attribute__ ((alias("evaltree"),__noreturn__));
+
+
+static void
+evalloop(union node *n, int flags)
 {
 	int status;
 
@@ -2221,9 +2872,11 @@
 	status = 0;
 	flags &= EV_TESTED;
 	for (;;) {
+		int i;
+
 		evaltree(n->nbinary.ch1, EV_TESTED);
 		if (evalskip) {
-		  skipping:if (evalskip == SKIPCONT && --skipcount <= 0) {
+skipping:         if (evalskip == SKIPCONT && --skipcount <= 0) {
 				evalskip = 0;
 				continue;
 			}
@@ -2231,13 +2884,11 @@
 				evalskip = 0;
 			break;
 		}
-		if (n->type == NWHILE) {
-			if (exitstatus != 0)
-				break;
-		} else {
-			if (exitstatus == 0)
-				break;
-		}
+		i = exitstatus;
+		if (n->type != NWHILE)
+			i = !i;
+		if (i != 0)
+			break;
 		evaltree(n->nbinary.ch2, flags);
 		status = exitstatus;
 		if (evalskip)
@@ -2247,7 +2898,10 @@
 	exitstatus = status;
 }
 
-static void evalfor(const union node *n, int flags)
+
+
+static void
+evalfor(union node *n, int flags)
 {
 	struct arglist arglist;
 	union node *argp;
@@ -2256,9 +2910,9 @@
 
 	setstackmark(&smark);
 	arglist.lastp = &arglist.list;
-	for (argp = n->nfor.args; argp; argp = argp->narg.next) {
-		oexitstatus = exitstatus;
+	for (argp = n->nfor.args ; argp ; argp = argp->narg.next) {
 		expandarg(argp, &arglist, EXP_FULL | EXP_TILDE | EXP_RECORD);
+		/* XXX */
 		if (evalskip)
 			goto out;
 	}
@@ -2267,7 +2921,7 @@
 	exitstatus = 0;
 	loopnest++;
 	flags &= EV_TESTED;
-	for (sp = arglist.list; sp; sp = sp->next) {
+	for (sp = arglist.list ; sp ; sp = sp->next) {
 		setvar(n->nfor.var, sp->text, 0);
 		evaltree(n->nfor.body, flags);
 		if (evalskip) {
@@ -2281,11 +2935,14 @@
 		}
 	}
 	loopnest--;
-  out:
+out:
 	popstackmark(&smark);
 }
 
-static inline void evalcase(const union node *n, int flags)
+
+
+static void
+evalcase(union node *n, int flags)
 {
 	union node *cp;
 	union node *patp;
@@ -2294,10 +2951,10 @@
 
 	setstackmark(&smark);
 	arglist.lastp = &arglist.list;
-	oexitstatus = exitstatus;
 	expandarg(n->ncase.expr, &arglist, EXP_TILDE);
-	for (cp = n->ncase.cases; cp && evalskip == 0; cp = cp->nclist.next) {
-		for (patp = cp->nclist.pattern; patp; patp = patp->narg.next) {
+	exitstatus = 0;
+	for (cp = n->ncase.cases ; cp && evalskip == 0 ; cp = cp->nclist.next) {
+		for (patp = cp->nclist.pattern ; patp ; patp = patp->narg.next) {
 			if (casematch(patp, arglist.list->text)) {
 				if (evalskip == 0) {
 					evaltree(cp->nclist.body, flags);
@@ -2306,10 +2963,81 @@
 			}
 		}
 	}
-  out:
+out:
 	popstackmark(&smark);
 }
 
+
+
+/*
+ * Kick off a subshell to evaluate a tree.
+ */
+
+static void
+evalsubshell(union node *n, int flags)
+{
+	struct job *jp;
+	int backgnd = (n->type == NBACKGND);
+	int status;
+
+	expredir(n->nredir.redirect);
+	if (!backgnd && flags & EV_EXIT && !trap[0])
+		goto nofork;
+	INTOFF;
+	jp = makejob(n, 1);
+	if (forkshell(jp, n, backgnd) == 0) {
+		INTON;
+		flags |= EV_EXIT;
+		if (backgnd)
+			flags &=~ EV_TESTED;
+nofork:
+		redirect(n->nredir.redirect, 0);
+		evaltreenr(n->nredir.n, flags);
+		/* never returns */
+	}
+	status = 0;
+	if (! backgnd)
+		status = waitforjob(jp);
+	exitstatus = status;
+	INTON;
+}
+
+
+
+/*
+ * Compute the names of the files in a redirection list.
+ */
+
+static void
+expredir(union node *n)
+{
+	union node *redir;
+
+	for (redir = n ; redir ; redir = redir->nfile.next) {
+		struct arglist fn;
+		fn.lastp = &fn.list;
+		switch (redir->type) {
+		case NFROMTO:
+		case NFROM:
+		case NTO:
+		case NCLOBBER:
+		case NAPPEND:
+			expandarg(redir->nfile.fname, &fn, EXP_TILDE | EXP_REDIR);
+			redir->nfile.expfname = fn.list->text;
+			break;
+		case NFROMFD:
+		case NTOFD:
+			if (redir->ndup.vname) {
+				expandarg(redir->ndup.vname, &fn, EXP_FULL | EXP_TILDE);
+				fixredir(redir, fn.list->text, 1);
+			}
+			break;
+		}
+	}
+}
+
+
+
 /*
  * Evaluate a pipeline.  All the processes in the pipeline are children
  * of the process creating the pipeline.  (This differs from some versions
@@ -2317,7 +3045,8 @@
  * of all the rest.)
  */
 
-static inline void evalpipe(union node *n, int flags)
+static void
+evalpipe(union node *n, int flags)
 {
 	struct job *jp;
 	struct nodelist *lp;
@@ -2325,15 +3054,15 @@
 	int prevfd;
 	int pip[2];
 
-	TRACE(("evalpipe(0x%lx) called\n", (long) n));
+	TRACE(("evalpipe(0x%lx) called\n", (long)n));
 	pipelen = 0;
-	for (lp = n->npipe.cmdlist; lp; lp = lp->next)
+	for (lp = n->npipe.cmdlist ; lp ; lp = lp->next)
 		pipelen++;
 	flags |= EV_EXIT;
 	INTOFF;
 	jp = makejob(n, pipelen);
 	prevfd = -1;
-	for (lp = n->npipe.cmdlist; lp; lp = lp->next) {
+	for (lp = n->npipe.cmdlist ; lp ; lp = lp->next) {
 		prehash(lp->n);
 		pip[1] = -1;
 		if (lp->next) {
@@ -2355,7 +3084,8 @@
 				dup2(pip[1], 1);
 				close(pip[1]);
 			}
-			evaltree(lp->n, flags);
+			evaltreenr(lp->n, flags);
+			/* never returns */
 		}
 		if (prevfd >= 0)
 			close(prevfd);
@@ -2369,497 +3099,6 @@
 	INTON;
 }
 
-static void find_command(const char *, struct cmdentry *, int, const char *);
-
-static int isassignment(const char *word)
-{
-	if (!is_name(*word)) {
-		return 0;
-	}
-	do {
-		word++;
-	} while (is_in_name(*word));
-	return *word == '=';
-}
-
-
-static void evalcommand(union node *cmd, int flags)
-{
-	struct stackmark smark;
-	union node *argp;
-	struct arglist arglist;
-	struct arglist varlist;
-	char **argv;
-	int argc;
-	char **envp;
-	struct strlist *sp;
-	int mode;
-	struct cmdentry cmdentry;
-	struct job *jp;
-	char *volatile savecmdname;
-	volatile struct shparam saveparam;
-	struct localvar *volatile savelocalvars;
-	volatile int e;
-	char *lastarg;
-	const char *path;
-	int spclbltin;
-	struct jmploc *volatile savehandler;
-	struct jmploc jmploc;
-
-#if __GNUC__
-	/* Avoid longjmp clobbering */
-	(void) &argv;
-	(void) &argc;
-	(void) &lastarg;
-	(void) &flags;
-	(void) &spclbltin;
-#endif
-
-	/* First expand the arguments. */
-	TRACE(("evalcommand(0x%lx, %d) called\n", (long) cmd, flags));
-	setstackmark(&smark);
-	arglist.lastp = &arglist.list;
-	varlist.lastp = &varlist.list;
-	arglist.list = 0;
-	oexitstatus = exitstatus;
-	exitstatus = 0;
-	path = pathval();
-	for (argp = cmd->ncmd.assign; argp; argp = argp->narg.next) {
-		expandarg(argp, &varlist, EXP_VARTILDE);
-	}
-	for (argp = cmd->ncmd.args; argp && !arglist.list; argp = argp->narg.next) {
-		expandarg(argp, &arglist, EXP_FULL | EXP_TILDE);
-	}
-	if (argp) {
-		struct builtincmd *bcmd;
-		int pseudovarflag;
-
-		bcmd = find_builtin(arglist.list->text);
-		pseudovarflag = bcmd && IS_BUILTIN_ASSIGN(bcmd);
-		for (; argp; argp = argp->narg.next) {
-			if (pseudovarflag && isassignment(argp->narg.text)) {
-				expandarg(argp, &arglist, EXP_VARTILDE);
-				continue;
-			}
-			expandarg(argp, &arglist, EXP_FULL | EXP_TILDE);
-		}
-	}
-	*arglist.lastp = NULL;
-	*varlist.lastp = NULL;
-	expredir(cmd->ncmd.redirect);
-	argc = 0;
-	for (sp = arglist.list; sp; sp = sp->next)
-		argc++;
-	argv = stalloc(sizeof(char *) * (argc + 1));
-
-	for (sp = arglist.list; sp; sp = sp->next) {
-		TRACE(("evalcommand arg: %s\n", sp->text));
-		*argv++ = sp->text;
-	}
-	*argv = NULL;
-	lastarg = NULL;
-	if (iflag && funcnest == 0 && argc > 0)
-		lastarg = argv[-1];
-	argv -= argc;
-
-	/* Print the command if xflag is set. */
-	if (xflag) {
-		out2c('+');
-		eprintlist(varlist.list);
-		eprintlist(arglist.list);
-		out2c('\n');
-	}
-
-	/* Now locate the command. */
-	if (argc == 0) {
-		cmdentry.cmdtype = CMDBUILTIN;
-		cmdentry.u.cmd = BLTINCMD;
-		spclbltin = 1;
-	} else {
-		const char *oldpath;
-		int findflag = DO_ERR;
-		int oldfindflag;
-
-		/*
-		 * Modify the command lookup path, if a PATH= assignment
-		 * is present
-		 */
-		for (sp = varlist.list; sp; sp = sp->next)
-			if (varequal(sp->text, defpathvar)) {
-				path = sp->text + 5;
-				findflag |= DO_BRUTE;
-			}
-		oldpath = path;
-		oldfindflag = findflag;
-		spclbltin = -1;
-		for (;;) {
-			find_command(argv[0], &cmdentry, findflag, path);
-			if (cmdentry.cmdtype == CMDUNKNOWN) {	/* command not found */
-				exitstatus = 127;
-				goto out;
-			}
-			/* implement bltin and command here */
-			if (cmdentry.cmdtype != CMDBUILTIN) {
-				break;
-			}
-			if (spclbltin < 0) {
-				spclbltin = !!(IS_BUILTIN_SPECIAL(cmdentry.u.cmd)) * 2;
-			}
-			if (cmdentry.u.cmd == BLTINCMD) {
-				for (;;) {
-					struct builtincmd *bcmd;
-
-					argv++;
-					if (--argc == 0)
-						goto found;
-					if (!(bcmd = find_builtin(*argv))) {
-						out2fmt("%s: not found\n", *argv);
-						exitstatus = 127;
-						goto out;
-					}
-					cmdentry.u.cmd = bcmd;
-					if (bcmd != BLTINCMD)
-						break;
-				}
-			}
-			if (cmdentry.u.cmd == find_builtin("command")) {
-				argv++;
-				if (--argc == 0) {
-					goto found;
-				}
-				if (*argv[0] == '-') {
-					if (!equal(argv[0], "-p")) {
-						argv--;
-						argc++;
-						break;
-					}
-					argv++;
-					if (--argc == 0) {
-						goto found;
-					}
-					path = defpath;
-					findflag |= DO_BRUTE;
-				} else {
-					path = oldpath;
-					findflag = oldfindflag;
-				}
-				findflag |= DO_NOFUN;
-				continue;
-			}
-		  found:
-			break;
-		}
-	}
-
-	/* Fork off a child process if necessary. */
-	if (cmd->ncmd.backgnd
-		|| (cmdentry.cmdtype == CMDNORMAL && (!(flags & EV_EXIT) || trap[0]))
-		) {
-		INTOFF;
-		jp = makejob(cmd, 1);
-		mode = cmd->ncmd.backgnd;
-		if (forkshell(jp, cmd, mode) != 0)
-			goto parent;	/* at end of routine */
-		FORCEINTON;
-		flags |= EV_EXIT;
-	} else {
-		flags &= ~EV_EXIT;
-	}
-
-	/* This is the child process if a fork occurred. */
-	/* Execute the command. */
-	if (cmdentry.cmdtype == CMDFUNCTION) {
-#ifdef DEBUG
-		trputs("Shell function:  ");
-		trargs(argv);
-#endif
-		exitstatus = oexitstatus;
-		saveparam = shellparam;
-		shellparam.malloc = 0;
-		shellparam.nparam = argc - 1;
-		shellparam.p = argv + 1;
-		INTOFF;
-		savelocalvars = localvars;
-		localvars = NULL;
-		INTON;
-		if (setjmp(jmploc.loc)) {
-			if (exception == EXREDIR) {
-				exitstatus = 2;
-				goto funcdone;
-			}
-			saveparam.optind = shellparam.optind;
-			saveparam.optoff = shellparam.optoff;
-			freeparam(&shellparam);
-			shellparam = saveparam;
-			poplocalvars();
-			localvars = savelocalvars;
-			handler = savehandler;
-			longjmp(handler->loc, 1);
-		}
-		savehandler = handler;
-		handler = &jmploc;
-		redirect(cmd->ncmd.redirect, REDIR_PUSH);
-		listsetvar(varlist.list);
-		funcnest++;
-		evaltree(cmdentry.u.func, flags & EV_TESTED);
-		funcnest--;
-	  funcdone:
-		INTOFF;
-		poplocalvars();
-		localvars = savelocalvars;
-		saveparam.optind = shellparam.optind;
-		saveparam.optoff = shellparam.optoff;
-		freeparam(&shellparam);
-		shellparam = saveparam;
-		handler = savehandler;
-		popredir();
-		INTON;
-		if (evalskip == SKIPFUNC) {
-			evalskip = 0;
-			skipcount = 0;
-		}
-	} else if (cmdentry.cmdtype == CMDBUILTIN) {
-		int redir;
-
-#ifdef DEBUG
-		trputs("builtin command:  ");
-		trargs(argv);
-#endif
-		redir = (cmdentry.u.cmd == EXECCMD) ? 0 : REDIR_PUSH;
-		savecmdname = commandname;
-		if (spclbltin) {
-			listsetvar(varlist.list);
-		} else {
-			cmdenviron = varlist.list;
-		}
-		e = -1;
-		if (setjmp(jmploc.loc)) {
-			e = exception;
-			exitstatus = (e == EXINT) ? SIGINT + 128 : 2;
-			goto cmddone;
-		}
-		savehandler = handler;
-		handler = &jmploc;
-		redirect(cmd->ncmd.redirect, redir);
-		commandname = argv[0];
-		argptr = argv + 1;
-		optptr = NULL;	/* initialize nextopt */
-		exitstatus = (*cmdentry.u.cmd->builtinfunc) (argc, argv);
-		flushall();
-	  cmddone:
-		cmdenviron = NULL;
-		commandname = savecmdname;
-		handler = savehandler;
-		if (e != -1) {
-			if (e == EXINT || spclbltin & 2) {
-				if (e == EXREDIR)
-					exraise(e);
-			}
-			FORCEINTON;
-		}
-		if (cmdentry.u.cmd != EXECCMD)
-			popredir();
-	} else {
-#ifdef DEBUG
-		trputs("normal command:  ");
-		trargs(argv);
-#endif
-		redirect(cmd->ncmd.redirect, 0);
-		clearredir();
-		for (sp = varlist.list; sp; sp = sp->next)
-			setvareq(sp->text, VEXPORT | VSTACK);
-		envp = environment();
-		shellexec(argv, envp, path, cmdentry.u.index);
-	}
-	if (flags & EV_EXIT)
-		exitshell(exitstatus);
-	goto out;
-
-  parent:				/* parent process gets here (if we forked) */
-	if (mode == 0) {	/* argument to fork */
-		exitstatus = waitforjob(jp);
-	}
-	INTON;
-
-  out:
-	if (lastarg)
-		setvar("_", lastarg, 0);
-	popstackmark(&smark);
-}
-
-/*
- * Evaluate a parse tree.  The value is left in the global variable
- * exitstatus.
- */
-static void evaltree(union node *n, int flags)
-{
-	int checkexit = 0;
-
-	if (n == NULL) {
-		TRACE(("evaltree(NULL) called\n"));
-		goto out;
-	}
-	TRACE(("evaltree(0x%lx: %d) called\n", (long) n, n->type));
-	switch (n->type) {
-	case NSEMI:
-		evaltree(n->nbinary.ch1, flags & EV_TESTED);
-		if (evalskip)
-			goto out;
-		evaltree(n->nbinary.ch2, flags);
-		break;
-	case NAND:
-		evaltree(n->nbinary.ch1, EV_TESTED);
-		if (evalskip || exitstatus != 0)
-			goto out;
-		evaltree(n->nbinary.ch2, flags);
-		break;
-	case NOR:
-		evaltree(n->nbinary.ch1, EV_TESTED);
-		if (evalskip || exitstatus == 0)
-			goto out;
-		evaltree(n->nbinary.ch2, flags);
-		break;
-	case NREDIR:
-		expredir(n->nredir.redirect);
-		redirect(n->nredir.redirect, REDIR_PUSH);
-		evaltree(n->nredir.n, flags);
-		popredir();
-		break;
-	case NSUBSHELL:
-		evalsubshell(n, flags);
-		break;
-	case NBACKGND:
-		evalsubshell(n, flags);
-		break;
-	case NIF:{
-		evaltree(n->nif.test, EV_TESTED);
-		if (evalskip)
-			goto out;
-		if (exitstatus == 0)
-			evaltree(n->nif.ifpart, flags);
-		else if (n->nif.elsepart)
-			evaltree(n->nif.elsepart, flags);
-		else
-			exitstatus = 0;
-		break;
-	}
-	case NWHILE:
-	case NUNTIL:
-		evalloop(n, flags);
-		break;
-	case NFOR:
-		evalfor(n, flags);
-		break;
-	case NCASE:
-		evalcase(n, flags);
-		break;
-	case NDEFUN:{
-		struct builtincmd *bcmd;
-		struct cmdentry entry;
-
-		if ((bcmd = find_builtin(n->narg.text)) && IS_BUILTIN_SPECIAL(bcmd)
-			) {
-			out2fmt("%s is a special built-in\n", n->narg.text);
-			exitstatus = 1;
-			break;
-		}
-		entry.cmdtype = CMDFUNCTION;
-		entry.u.func = copyfunc(n->narg.next);
-		addcmdentry(n->narg.text, &entry);
-		exitstatus = 0;
-		break;
-	}
-	case NNOT:
-		evaltree(n->nnot.com, EV_TESTED);
-		exitstatus = !exitstatus;
-		break;
-
-	case NPIPE:
-		evalpipe(n, flags);
-		checkexit = 1;
-		break;
-	case NCMD:
-		evalcommand(n, flags);
-		checkexit = 1;
-		break;
-#ifdef DEBUG
-	default:
-		printf("Node type = %d\n", n->type);
-		break;
-#endif
-	}
-  out:
-	if (pendingsigs)
-		dotrap();
-	if (flags & EV_EXIT ||
-		(checkexit && eflag && exitstatus && !(flags & EV_TESTED))
-		)
-		exitshell(exitstatus);
-}
-
-/*
- * Kick off a subshell to evaluate a tree.
- */
-
-static void evalsubshell(const union node *n, int flags)
-{
-	struct job *jp = 0;
-	int backgnd = (n->type == NBACKGND);
-
-	expredir(n->nredir.redirect);
-	if (!backgnd && flags & EV_EXIT && !trap[0])
-		goto nofork;
-	INTOFF;
-	jp = makejob(n, 1);
-	if (forkshell(jp, n, backgnd) == 0) {
-		INTON;
-		flags |= EV_EXIT;
-		if (backgnd)
-			flags &= ~EV_TESTED;
-	  nofork:
-		redirect(n->nredir.redirect, 0);
-		evaltree(n->nredir.n, flags);	/* never returns */
-	}
-	if (!backgnd) {
-		exitstatus = waitforjob(jp);
-	}
-	INTON;
-}
-
-/*
- * Compute the names of the files in a redirection list.
- */
-
-static void fixredir(union node *n, const char *text, int err);
-
-static void expredir(union node *n)
-{
-	union node *redir;
-
-	for (redir = n; redir; redir = redir->nfile.next) {
-		struct arglist fn;
-
-		fn.lastp = &fn.list;
-		oexitstatus = exitstatus;
-		switch (redir->type) {
-		case NFROMTO:
-		case NFROM:
-		case NTO:
-		case NAPPEND:
-		case NTOOV:
-			expandarg(redir->nfile.fname, &fn, EXP_TILDE | EXP_REDIR);
-			redir->nfile.expfname = fn.list->text;
-			break;
-		case NFROMFD:
-		case NTOFD:
-			if (redir->ndup.vname) {
-				expandarg(redir->ndup.vname, &fn, EXP_FULL | EXP_TILDE);
-				fixredir(redir, fn.list->text, 1);
-			}
-			break;
-		}
-	}
-}
 
 
 /*
@@ -2869,84 +3108,405 @@
  * Should be called with interrupts off.
  */
 
-static void evalbackcmd(union node *n, struct backcmd *result)
+static void
+evalbackcmd(union node *n, struct backcmd *result)
 {
-	int pip[2];
-	struct job *jp;
-	struct stackmark smark;	/* unnecessary */
+	int saveherefd;
 
-	setstackmark(&smark);
 	result->fd = -1;
 	result->buf = NULL;
 	result->nleft = 0;
 	result->jp = NULL;
 	if (n == NULL) {
-		exitstatus = 0;
 		goto out;
 	}
-	exitstatus = 0;
-	if (pipe(pip) < 0)
-		error("Pipe call failed");
-	jp = makejob(n, 1);
-	if (forkshell(jp, n, FORK_NOJOB) == 0) {
-		FORCEINTON;
-		close(pip[0]);
-		if (pip[1] != 1) {
-			close(1);
-			dup_as_newfd(pip[1], 1);
-			close(pip[1]);
+
+	saveherefd = herefd;
+	herefd = -1;
+
+	{
+		int pip[2];
+		struct job *jp;
+
+		if (pipe(pip) < 0)
+			error("Pipe call failed");
+		jp = makejob(n, 1);
+		if (forkshell(jp, n, FORK_NOJOB) == 0) {
+			FORCEINTON;
+			close(pip[0]);
+			if (pip[1] != 1) {
+				close(1);
+				copyfd(pip[1], 1);
+				close(pip[1]);
+			}
+			eflag = 0;
+			evaltreenr(n, EV_EXIT);
+			/* NOTREACHED */
 		}
-		eflag = 0;
-		evaltree(n, EV_EXIT);
+		close(pip[1]);
+		result->fd = pip[0];
+		result->jp = jp;
 	}
-	close(pip[1]);
-	result->fd = pip[0];
-	result->jp = jp;
-  out:
-	popstackmark(&smark);
+	herefd = saveherefd;
+out:
 	TRACE(("evalbackcmd done: fd=%d buf=0x%x nleft=%d jp=0x%x\n",
-		   result->fd, result->buf, result->nleft, result->jp));
+		result->fd, result->buf, result->nleft, result->jp));
 }
 
+#ifdef CONFIG_ASH_CMDCMD
+static inline char **
+parse_command_args(char **argv, const char **path)
+{
+	char *cp, c;
+
+	for (;;) {
+		cp = *++argv;
+		if (!cp)
+			return 0;
+		if (*cp++ != '-')
+			break;
+		if (!(c = *cp++))
+			break;
+		if (c == '-' && !*cp) {
+			argv++;
+			break;
+		}
+		do {
+			switch (c) {
+			case 'p':
+				*path = defpath;
+				break;
+			default:
+				/* run 'typecmd' for other options */
+				return 0;
+			}
+		} while ((c = *cp++));
+	}
+	return argv;
+}
+#endif
+
+
 
 /*
  * Execute a simple command.
  */
 
+static void
+evalcommand(union node *cmd, int flags)
+{
+	struct stackmark smark;
+	union node *argp;
+	struct arglist arglist;
+	struct arglist varlist;
+	char **argv;
+	int argc;
+	struct strlist *sp;
+	struct cmdentry cmdentry;
+	struct job *jp;
+	char *lastarg;
+	const char *path;
+	int spclbltin;
+	int cmd_is_exec;
+	int status;
+	char **nargv;
+
+	/* First expand the arguments. */
+	TRACE(("evalcommand(0x%lx, %d) called\n", (long)cmd, flags));
+	setstackmark(&smark);
+	back_exitstatus = 0;
+
+	cmdentry.cmdtype = CMDBUILTIN;
+	cmdentry.u.cmd = &bltin;
+	varlist.lastp = &varlist.list;
+	*varlist.lastp = NULL;
+	arglist.lastp = &arglist.list;
+	*arglist.lastp = NULL;
+
+	argc = 0;
+	for (argp = cmd->ncmd.args; argp; argp = argp->narg.next) {
+		struct strlist **spp;
+
+		spp = arglist.lastp;
+		expandarg(argp, &arglist, EXP_FULL | EXP_TILDE);
+		for (sp = *spp; sp; sp = sp->next)
+			argc++;
+	}
+
+	argv = nargv = stalloc(sizeof (char *) * (argc + 1));
+	for (sp = arglist.list ; sp ; sp = sp->next) {
+		TRACE(("evalcommand arg: %s\n", sp->text));
+		*nargv++ = sp->text;
+	}
+	*nargv = NULL;
+
+	lastarg = NULL;
+	if (iflag && funcnest == 0 && argc > 0)
+		lastarg = nargv[-1];
+
+	expredir(cmd->ncmd.redirect);
+	status = redirectsafe(cmd->ncmd.redirect, REDIR_PUSH);
+
+	path = vpath.text;
+	for (argp = cmd->ncmd.assign; argp; argp = argp->narg.next) {
+		struct strlist **spp;
+		char *p;
+
+		spp = varlist.lastp;
+		expandarg(argp, &varlist, EXP_VARTILDE);
+
+		/*
+		 * Modify the command lookup path, if a PATH= assignment
+		 * is present
+		 */
+		p = (*spp)->text;
+		if (varequal(p, path))
+			path = p;
+	}
+
+	/* Print the command if xflag is set. */
+	if (xflag) {
+		int sep;
+
+		out2str(ps4val());
+		sep = 0;
+		sep = eprintlist(varlist.list, sep);
+		eprintlist(arglist.list, sep);
+		out2c('\n');
+		flushall();
+	}
+
+	cmd_is_exec = 0;
+	spclbltin = -1;
+
+	/* Now locate the command. */
+	if (argc) {
+		const char *oldpath;
+		int cmd_flag = DO_ERR;
+
+		path += 5;
+		oldpath = path;
+		for (;;) {
+			find_command(argv[0], &cmdentry, cmd_flag, path);
+			if (cmdentry.cmdtype == CMDUNKNOWN) {
+				status = 127;
+				flushout(stderr);
+				goto bail;
+			}
+
+			/* implement bltin and command here */
+			if (cmdentry.cmdtype != CMDBUILTIN)
+				break;
+			if (spclbltin < 0)
+				spclbltin = IS_BUILTIN_SPECIAL(cmdentry.u.cmd);
+			if (cmdentry.u.cmd == EXECCMD)
+				cmd_is_exec++;
+#ifdef CONFIG_ASH_CMDCMD
+			if (cmdentry.u.cmd == COMMANDCMD) {
+
+				path = oldpath;
+				nargv = parse_command_args(argv, &path);
+				if (!nargv)
+					break;
+				argc -= nargv - argv;
+				argv = nargv;
+				cmd_flag |= DO_NOFUNC;
+			} else
+#endif
+				break;
+		}
+	}
+
+	if (status) {
+		/* We have a redirection error. */
+		if (spclbltin > 0)
+			exraise(EXERROR);
+bail:
+		exitstatus = status;
+		goto out;
+	}
+
+	/* Execute the command. */
+	switch (cmdentry.cmdtype) {
+	default:
+		/* Fork off a child process if necessary. */
+		if (!(flags & EV_EXIT) || trap[0]) {
+			INTOFF;
+			jp = makejob(cmd, 1);
+			if (forkshell(jp, cmd, FORK_FG) != 0) {
+				exitstatus = waitforjob(jp);
+				INTON;
+				break;
+			}
+			FORCEINTON;
+		}
+		listsetvar(varlist.list, VEXPORT|VSTACK);
+		shellexec(argv, path, cmdentry.u.index);
+		/* NOTREACHED */
+
+	case CMDBUILTIN:
+		cmdenviron = varlist.list;
+		if (cmdenviron) {
+			struct strlist *list = cmdenviron;
+			int i = VNOSET;
+			if (spclbltin > 0 || argc == 0) {
+				i = 0;
+				if (cmd_is_exec && argc > 1)
+					i = VEXPORT;
+			}
+			listsetvar(list, i);
+		}
+		if (evalbltin(cmdentry.u.cmd, argc, argv)) {
+			int exit_status;
+			int i, j;
+
+			i = exception;
+			if (i == EXEXIT)
+				goto raise;
+
+			exit_status = 2;
+			j = 0;
+			if (i == EXINT)
+				j = SIGINT;
+			if (i == EXSIG)
+				j = pendingsigs;
+			if (j)
+				exit_status = j + 128;
+			exitstatus = exit_status;
+
+			if (i == EXINT || spclbltin > 0) {
+raise:
+				longjmp(handler->loc, 1);
+			}
+			FORCEINTON;
+		}
+		break;
+
+	case CMDFUNCTION:
+		listsetvar(varlist.list, 0);
+		if (evalfun(cmdentry.u.func, argc, argv, flags))
+			goto raise;
+		break;
+	}
+
+out:
+	popredir(cmd_is_exec);
+	if (lastarg)
+		/* dsl: I think this is intended to be used to support
+		 * '_' in 'vi' command mode during line editing...
+		 * However I implemented that within libedit itself.
+		 */
+		setvar("_", lastarg, 0);
+	popstackmark(&smark);
+}
+
+static int
+evalbltin(const struct builtincmd *cmd, int argc, char **argv) {
+	char *volatile savecmdname;
+	struct jmploc *volatile savehandler;
+	struct jmploc jmploc;
+	int i;
+
+	savecmdname = commandname;
+	if ((i = setjmp(jmploc.loc)))
+		goto cmddone;
+	savehandler = handler;
+	handler = &jmploc;
+	commandname = argv[0];
+	argptr = argv + 1;
+	optptr = NULL;                  /* initialize nextopt */
+	exitstatus = (*cmd->builtin)(argc, argv);
+	flushall();
+cmddone:
+	exitstatus |= outerr(stdout);
+	commandname = savecmdname;
+	exsig = 0;
+	handler = savehandler;
+
+	return i;
+}
+
+static int
+evalfun(struct funcnode *func, int argc, char **argv, int flags)
+{
+	volatile struct shparam saveparam;
+	struct localvar *volatile savelocalvars;
+	struct jmploc *volatile savehandler;
+	struct jmploc jmploc;
+	int e;
+
+	saveparam = shellparam;
+	savelocalvars = localvars;
+	if ((e = setjmp(jmploc.loc))) {
+		goto funcdone;
+	}
+	INTOFF;
+	savehandler = handler;
+	handler = &jmploc;
+	localvars = NULL;
+	shellparam.malloc = 0;
+	func->count++;
+	INTON;
+	shellparam.nparam = argc - 1;
+	shellparam.p = argv + 1;
+#ifdef CONFIG_ASH_GETOPTS
+	shellparam.optind = 1;
+	shellparam.optoff = -1;
+#endif
+	funcnest++;
+	evaltree(&func->n, flags & EV_TESTED);
+	funcnest--;
+funcdone:
+	INTOFF;
+	freefunc(func);
+	poplocalvars();
+	localvars = savelocalvars;
+	freeparam(&shellparam);
+	shellparam = saveparam;
+	handler = savehandler;
+	INTON;
+	if (evalskip == SKIPFUNC) {
+		evalskip = 0;
+		skipcount = 0;
+	}
+	return e;
+}
+
+
 /*
  * Search for a command.  This is called before we fork so that the
  * location of the command will be available in the parent as well as
- * the child.  The check for "goodname" is an overly conservative
- * check that the name will not be subject to expansion.
+ * the child.
  */
 
-static void prehash(union node *n)
+static void
+prehash(union node *n)
 {
 	struct cmdentry entry;
 
 	if (n->type == NCMD && n->ncmd.args)
-		if (goodname(n->ncmd.args->narg.text))
-			find_command(n->ncmd.args->narg.text, &entry, 0, pathval());
+		find_command(n->ncmd.args->narg.text, &entry, 0, pathval());
 }
 
 
+
 /*
  * Builtin commands.  Builtin commands whose functions are closely
  * tied to evaluation are implemented here.
  */
 
 /*
- * No command given, or a bltin command with no arguments.  Set the
- * specified variables.
+ * No command given.
  */
 
-int bltincmd(int argc, char **argv)
+static int
+bltincmd(int argc, char **argv)
 {
 	/*
 	 * Preserve exitstatus of a previous possible redirection
 	 * as POSIX mandates
 	 */
-	return exitstatus;
+	return back_exitstatus;
 }
 
 
@@ -2961,16 +3521,17 @@
  * in the standard shell so we don't make it one here.
  */
 
-static int breakcmd(int argc, char **argv)
+static int
+breakcmd(int argc, char **argv)
 {
 	int n = argc > 1 ? number(argv[1]) : 1;
 
 	if (n <= 0)
-		error("Illegal number: %s", argv[1]);
+		error(illnum, argv[1]);
 	if (n > loopnest)
 		n = loopnest;
 	if (n > 0) {
-		evalskip = (**argv == 'c') ? SKIPCONT : SKIPBREAK;
+		evalskip = (**argv == 'c')? SKIPCONT : SKIPBREAK;
 		skipcount = n;
 	}
 	return 0;
@@ -2981,15 +3542,17 @@
  * The return command.
  */
 
-static int returncmd(int argc, char **argv)
+static int
+returncmd(int argc, char **argv)
 {
-	int ret = argc > 1 ? number(argv[1]) : oexitstatus;
+	int ret = argc > 1 ? number(argv[1]) : exitstatus;
 
 	if (funcnest) {
 		evalskip = SKIPFUNC;
 		skipcount = 1;
 		return ret;
-	} else {
+	}
+	else {
 		/* Do what ksh does; skip the rest of the file */
 		evalskip = SKIPFILE;
 		skipcount = 1;
@@ -2998,101 +3561,102 @@
 }
 
 
-#ifndef CONFIG_FALSE
-static int false_main(int argc, char **argv)
+static int
+falsecmd(int argc, char **argv)
 {
 	return 1;
 }
-#endif
 
-#ifndef CONFIG_TRUE
-static int true_main(int argc, char **argv)
+
+static int
+truecmd(int argc, char **argv)
 {
 	return 0;
 }
-#endif
-
-/*
- * Controls whether the shell is interactive or not.
- */
-
-static void setsignal(int signo);
-
-#ifdef CONFIG_ASH_MAIL
-static void chkmail(int silent);
-#endif
-
-static void setinteractive(int on)
-{
-	static int is_interactive;
-	static int do_banner = 0;
-
-	if (on == is_interactive)
-		return;
-	setsignal(SIGINT);
-	setsignal(SIGQUIT);
-	setsignal(SIGTERM);
-#ifdef CONFIG_ASH_MAIL
-	chkmail(1);
-#endif
-	is_interactive = on;
-	if (do_banner == 0 && is_interactive) {
-		/* Looks like they want an interactive shell */
-#ifndef CONFIG_FEATURE_SH_EXTRA_QUIET
-		printf("\n\n" BB_BANNER " Built-in shell (ash)\n");
-		printf("Enter 'help' for a list of built-in commands.\n\n");
-#endif
-		do_banner = 1;
-	}
-}
-
-static void optschanged(void)
-{
-	setinteractive(iflag);
-	setjobctl(mflag);
-}
 
 
-static int execcmd(int argc, char **argv)
+static int
+execcmd(int argc, char **argv)
 {
 	if (argc > 1) {
-		struct strlist *sp;
-
-		iflag = 0;		/* exit on error */
+		iflag = 0;              /* exit on error */
 		mflag = 0;
 		optschanged();
-		for (sp = cmdenviron; sp; sp = sp->next)
-			setvareq(sp->text, VEXPORT | VSTACK);
-		shellexec(argv + 1, environment(), pathval(), 0);
+		shellexec(argv + 1, pathval(), 0);
 	}
 	return 0;
 }
 
-static void eprintlist(struct strlist *sp)
+
+static int
+eprintlist(struct strlist *sp, int sep)
 {
-	for (; sp; sp = sp->next) {
-		out2fmt(" %s", sp->text);
+	while (sp) {
+		const char *p;
+
+		p = " %s" + (1 - sep);
+		sep |= 1;
+		fprintf(stderr, p, sp->text);
+		sp = sp->next;
 	}
+
+	return sep;
 }
+/*      $NetBSD: exec.c,v 1.35 2003/01/22 20:36:04 dsl Exp $    */
+
+/*
+ * When commands are first encountered, they are entered in a hash table.
+ * This ensures that a full path search will not have to be done for them
+ * on each invocation.
+ *
+ * We should investigate converting to a linear search, even though that
+ * would make the command name "hash" a misnomer.
+ */
+
+#define CMDTABLESIZE 31         /* should be prime */
+#define ARB 1                   /* actual size determined at run time */
+
+
+
+struct tblentry {
+	struct tblentry *next;  /* next entry in hash chain */
+	union param param;      /* definition of builtin function */
+	short cmdtype;          /* index identifying command */
+	char rehash;            /* if set, cd done since entry created */
+	char cmdname[ARB];      /* name of command */
+};
+
+
+static struct tblentry *cmdtable[CMDTABLESIZE];
+static int builtinloc = -1;             /* index in path of %builtin, or -1 */
+
+
+static void tryexec(char *, char **, char **);
+static void printentry(struct tblentry *);
+static void clearcmdentry(int);
+static struct tblentry *cmdlookup(const char *, int);
+static void delete_cmd_entry(void);
+
 
 /*
  * Exec a program.  Never returns.  If you change this routine, you may
  * have to change the find_command routine as well.
  */
 
-static const char *pathopt;	/* set by padvance */
-
-static void shellexec(char **argv, char **envp, const char *path, int idx)
+static void
+shellexec(char **argv, const char *path, int idx)
 {
 	char *cmdname;
 	int e;
+	char **envp;
 
+	clearredir(1);
+	envp = environment();
 	if (strchr(argv[0], '/') != NULL
 #ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
 		|| find_applet_by_name(argv[0])
-#endif 
-	)
-	{
+#endif
+						) {
 		tryexec(argv[0], argv, envp);
 		e = errno;
 	} else {
@@ -3119,167 +3683,17 @@
 		exerrno = 2;
 		break;
 	}
+	TRACE(("shellexec failed for %s, errno %d, suppressint %d\n",
+		argv[0], e, suppressint ));
 	exerror(EXEXEC, "%s: %s", argv[0], errmsg(e, E_EXEC));
 	/* NOTREACHED */
 }
 
-/*
- * Clear traps on a fork.
- */
-static void clear_traps(void)
-{
-	char **tp;
 
-	for (tp = trap; tp < &trap[NSIG]; tp++) {
-		if (*tp && **tp) {	/* trap not NULL or SIG_IGN */
-			INTOFF;
-			free(*tp);
-			*tp = NULL;
-			if (tp != &trap[0])
-				setsignal(tp - trap);
-			INTON;
-		}
-	}
-}
-
-
-static int preadbuffer(void);
-static void pushfile(void);
-
-/*
- * Read a character from the script, returning PEOF on end of file.
- * Nul characters in the input are silently discarded.
- */
-
-#ifndef CONFIG_ASH_OPTIMIZE_FOR_SIZE
-#define pgetc_macro()   (--parsenleft >= 0? *parsenextc++ : preadbuffer())
-static int pgetc(void)
-{
-	return pgetc_macro();
-}
-#else
-static int pgetc_macro(void)
-{
-	return --parsenleft >= 0 ? *parsenextc++ : preadbuffer();
-}
-
-static inline int pgetc(void)
-{
-	return pgetc_macro();
-}
-#endif
-
-
-/*
- * Undo the last call to pgetc.  Only one character may be pushed back.
- * PEOF may be pushed back.
- */
-
-static void pungetc(void)
-{
-	parsenleft++;
-	parsenextc--;
-}
-
-
-static void popfile(void)
-{
-	struct parsefile *pf = parsefile;
-
-	INTOFF;
-	if (pf->fd >= 0)
-		close(pf->fd);
-	free(pf->buf);
-	while (pf->strpush)
-		popstring();
-	parsefile = pf->prev;
-	free(pf);
-	parsenleft = parsefile->nleft;
-	parselleft = parsefile->lleft;
-	parsenextc = parsefile->nextc;
-	plinno = parsefile->linno;
-	INTON;
-}
-
-
-/*
- * Return to top level.
- */
-
-static void popallfiles(void)
-{
-	while (parsefile != &basepf)
-		popfile();
-}
-
-/*
- * Close the file(s) that the shell is reading commands from.  Called
- * after a fork is done.
- */
-
-static void closescript(void)
-{
-	popallfiles();
-	if (parsefile->fd > 0) {
-		close(parsefile->fd);
-		parsefile->fd = 0;
-	}
-}
-
-
-/*
- * Like setinputfile, but takes an open file descriptor.  Call this with
- * interrupts off.
- */
-
-static void setinputfd(int fd, int push)
-{
-	(void) fcntl(fd, F_SETFD, FD_CLOEXEC);
-	if (push) {
-		pushfile();
-		parsefile->buf = 0;
-	} else {
-		closescript();
-		while (parsefile->strpush)
-			popstring();
-	}
-	parsefile->fd = fd;
-	if (parsefile->buf == NULL)
-		parsefile->buf = xmalloc(BUFSIZ);
-	parselleft = parsenleft = 0;
-	plinno = 1;
-}
-
-
-/*
- * Set the input to take input from a file.  If push is set, push the
- * old input onto the stack first.
- */
-
-static void setinputfile(const char *fname, int push)
-{
-	int fd;
-	int myfileno2;
-
-	INTOFF;
-	if ((fd = open(fname, O_RDONLY)) < 0)
-		error("Can't open %s", fname);
-	if (fd < 10) {
-		myfileno2 = dup_as_newfd(fd, 10);
-		close(fd);
-		if (myfileno2 < 0)
-			error("Out of file descriptors");
-		fd = myfileno2;
-	}
-	setinputfd(fd, push);
-	INTON;
-}
-
-
-static void tryexec(char *cmd, char **argv, char **envp)
+static void
+tryexec(char *cmd, char **argv, char **envp)
 {
 	int repeated = 0;
-
 #ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
 	int flg_bb = 0;
 	char *name = cmd;
@@ -3310,24 +3724,33 @@
 		}
 	}
 #endif
-  repeat:
+
+repeat:
+#ifdef SYSV
+	do {
+		execve(cmd, argv, envp);
+	} while (errno == EINTR);
+#else
 	execve(cmd, argv, envp);
+#endif
 	if (repeated++) {
-		free(argv);
+		ckfree(argv);
 	} else if (errno == ENOEXEC) {
 		char **ap;
 		char **new;
 
-		for (ap = argv; *ap; ap++);
-		ap = new = xmalloc((ap - argv + 2) * sizeof(char *));
+		for (ap = argv; *ap; ap++)
+			;
+		ap = new = ckmalloc((ap - argv + 2) * sizeof(char *));
 		*ap++ = cmd = "/bin/sh";
-		while ((*ap++ = *argv++));
+		while ((*ap++ = *argv++))
+			;
 		argv = new;
 		goto repeat;
 	}
 }
 
-static char *commandtext(const union node *);
+
 
 /*
  * Do a path search.  The variable path (passed by reference) should be
@@ -3339,23 +3762,19 @@
  * NULL.
  */
 
-static const char *pathopt;
-
-static void growstackblock(void);
-
-
-static char *padvance(const char **path, const char *name)
+static char *
+padvance(const char **path, const char *name)
 {
 	const char *p;
 	char *q;
 	const char *start;
-	int len;
+	size_t len;
 
 	if (*path == NULL)
 		return NULL;
 	start = *path;
-	for (p = start; *p && *p != ':' && *p != '%'; p++);
-	len = p - start + strlen(name) + 2;	/* "2" is for '/' and '\0' */
+	for (p = start ; *p && *p != ':' && *p != '%' ; p++);
+	len = p - start + strlen(name) + 2;     /* "2" is for '/' and '\0' */
 	while (stackblocksize() < len)
 		growstackblock();
 	q = stackblock();
@@ -3368,8 +3787,7 @@
 	pathopt = NULL;
 	if (*p == '%') {
 		pathopt = ++p;
-		while (*p && *p != ':')
-			p++;
+		while (*p && *p != ':')  p++;
 	}
 	if (*p == ':')
 		*path = p + 1;
@@ -3378,181 +3796,74 @@
 	return stalloc(len);
 }
 
-/*
- * Wrapper around strcmp for qsort/bsearch/...
- */
-static int pstrcmp(const void *a, const void *b)
-{
-	return strcmp((const char *) a, (*(const char *const *) b) + 1);
-}
-
-/*
- * Find a keyword is in a sorted array.
- */
-
-static const char *const *findkwd(const char *s)
-{
-	return bsearch(s, tokname_array + KWDOFFSET,
-				   (sizeof(tokname_array) / sizeof(const char *)) - KWDOFFSET,
-				   sizeof(const char *), pstrcmp);
-}
 
 
 /*** Command hashing code ***/
 
-static int hashcmd(int argc, char **argv)
+
+static int
+hashcmd(int argc, char **argv)
 {
 	struct tblentry **pp;
 	struct tblentry *cmdp;
 	int c;
-	int verbose;
 	struct cmdentry entry;
 	char *name;
 
-#ifdef CONFIG_ASH_ALIAS
-	const struct alias *ap;
-#endif
-
-	verbose = 0;
-	while ((c = nextopt("rvV")) != '\0') {
-		if (c == 'r') {
-			clearcmdentry(0);
-			return 0;
-		} else if (c == 'v' || c == 'V') {
-			verbose = c;
-		}
+	while ((c = nextopt("r")) != '\0') {
+		clearcmdentry(0);
+		return 0;
 	}
 	if (*argptr == NULL) {
-		for (pp = cmdtable; pp < &cmdtable[CMDTABLESIZE]; pp++) {
-			for (cmdp = *pp; cmdp; cmdp = cmdp->next) {
-				if (cmdp->cmdtype != CMDBUILTIN) {
-					printentry(cmdp, verbose);
-				}
+		for (pp = cmdtable ; pp < &cmdtable[CMDTABLESIZE] ; pp++) {
+			for (cmdp = *pp ; cmdp ; cmdp = cmdp->next) {
+				if (cmdp->cmdtype == CMDNORMAL)
+					printentry(cmdp);
 			}
 		}
 		return 0;
 	}
 	c = 0;
-	while ((name = *argptr++) != NULL) {
+	while ((name = *argptr) != NULL) {
 		if ((cmdp = cmdlookup(name, 0)) != NULL
-			&& (cmdp->cmdtype == CMDNORMAL
-				|| (cmdp->cmdtype == CMDBUILTIN && builtinloc >= 0)))
+		 && (cmdp->cmdtype == CMDNORMAL
+		     || (cmdp->cmdtype == CMDBUILTIN && builtinloc >= 0)))
 			delete_cmd_entry();
-#ifdef CONFIG_ASH_ALIAS
-		/* Then look at the aliases */
-		if ((ap = *__lookupalias(name)) != NULL) {
-			if (verbose == 'v')
-				printf("%s is an alias for %s\n", name, ap->val);
-			else
-				printalias(ap);
-			continue;
-		}
-#endif
-		/* First look at the keywords */
-		if (findkwd(name) != 0) {
-			if (verbose == 'v')
-				printf("%s is a shell keyword\n", name);
-			else
-				puts(name);
-			continue;
-		}
-
 		find_command(name, &entry, DO_ERR, pathval());
 		if (entry.cmdtype == CMDUNKNOWN)
 			c = 1;
-		else if (verbose) {
-			cmdp = cmdlookup(name, 0);
-			if (cmdp)
-				printentry(cmdp, verbose == 'v');
-			flushall();
-		}
+		argptr++;
 	}
 	return c;
 }
 
-static void printentry(struct tblentry *cmdp, int verbose)
+
+static void
+printentry(struct tblentry *cmdp)
 {
 	int idx;
 	const char *path;
 	char *name;
 
-	printf("%s%s", cmdp->cmdname, (verbose ? " is " : ""));
-	if (cmdp->cmdtype == CMDNORMAL) {
-		idx = cmdp->param.index;
-		path = pathval();
-		do {
-			name = padvance(&path, cmdp->cmdname);
-			stunalloc(name);
-		} while (--idx >= 0);
-		if (verbose)
-			out1str(name);
-	} else if (cmdp->cmdtype == CMDBUILTIN) {
-		if (verbose)
-			out1str("a shell builtin");
-	} else if (cmdp->cmdtype == CMDFUNCTION) {
-		if (verbose) {
-			INTOFF;
-			out1str("a function\n");
-			name = commandtext(cmdp->param.func);
-			printf("%s() {\n %s\n}", cmdp->cmdname, name);
-			free(name);
-			INTON;
-		}
-#ifdef DEBUG
-	} else {
-		error("internal error: cmdtype %d", cmdp->cmdtype);
-#endif
-	}
-	puts(cmdp->rehash ? "*" : nullstr);
+	idx = cmdp->param.index;
+	path = pathval();
+	do {
+		name = padvance(&path, cmdp->cmdname);
+		stunalloc(name);
+	} while (--idx >= 0);
+	out1str(name);
+	out1fmt(snlfmt, cmdp->rehash ? "*" : nullstr);
 }
 
 
 
-/*** List the available builtins ***/
-
-
-static int helpcmd(int argc, char **argv)
-{
-	int col, i;
-
-	printf("\nBuilt-in commands:\n-------------------\n");
-	for (col = 0, i = 0; i < NUMBUILTINS; i++) {
-		col += printf("%c%s", ((col == 0) ? '\t' : ' '),
-					  builtincmds[i].name + 1);
-		if (col > 60) {
-			printf("\n");
-			col = 0;
-		}
-	}
-#ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
-	{
-		extern const struct BB_applet applets[];
-		extern const size_t NUM_APPLETS;
-
-		for (i = 0; i < NUM_APPLETS; i++) {
-
-			col += printf("%c%s", ((col == 0) ? '\t' : ' '), applets[i].name);
-			if (col > 60) {
-				printf("\n");
-				col = 0;
-			}
-		}
-	}
-#endif
-	printf("\n\n");
-	return EXIT_SUCCESS;
-}
-
 /*
  * Resolve a command name.  If you change this routine, you may have to
  * change the shellexec routine as well.
  */
 
-static int prefix(const char *, const char *);
-
 static void
-find_command(const char *name, struct cmdentry *entry, int act,
-			 const char *path)
+find_command(char *name, struct cmdentry *entry, int act, const char *path)
 {
 	struct tblentry *cmdp;
 	int idx;
@@ -3560,28 +3871,23 @@
 	char *fullname;
 	struct stat statb;
 	int e;
-	int bltin;
-	int firstchange;
 	int updatetbl;
-	int regular;
 	struct builtincmd *bcmd;
 
-	/* If name contains a slash, don't use the hash table */
+	/* If name contains a slash, don't use PATH or hash table */
 	if (strchr(name, '/') != NULL) {
+		entry->u.index = -1;
 		if (act & DO_ABS) {
 			while (stat(name, &statb) < 0) {
-				if (errno != ENOENT && errno != ENOTDIR)
-					e = errno;
+#ifdef SYSV
+				if (errno == EINTR)
+					continue;
+#endif
 				entry->cmdtype = CMDUNKNOWN;
-				entry->u.index = -1;
 				return;
 			}
-			entry->cmdtype = CMDNORMAL;
-			entry->u.index = -1;
-			return;
 		}
 		entry->cmdtype = CMDNORMAL;
-		entry->u.index = 0;
 		return;
 	}
 
@@ -3593,69 +3899,50 @@
 	}
 #endif
 
-	updatetbl = 1;
-	if (act & DO_BRUTE) {
-		firstchange = path_change(path, &bltin);
-	} else {
-		bltin = builtinloc;
-		firstchange = 9999;
+	updatetbl = (path == pathval());
+	if (!updatetbl) {
+		act |= DO_ALTPATH;
+		if (strstr(path, "%builtin") != NULL)
+			act |= DO_ALTBLTIN;
 	}
 
-	/* If name is in the table, and not invalidated by cd, we're done */
-	if ((cmdp = cmdlookup(name, 0)) != NULL && cmdp->rehash == 0) {
-		if (cmdp->cmdtype == CMDFUNCTION) {
-			if (act & DO_NOFUN) {
-				updatetbl = 0;
-			} else {
-				goto success;
-			}
-		} else if (act & DO_BRUTE) {
-			if ((cmdp->cmdtype == CMDNORMAL &&
-				 cmdp->param.index >= firstchange) ||
-				(cmdp->cmdtype == CMDBUILTIN &&
-				 ((builtinloc < 0 && bltin >= 0) ?
-				  bltin : builtinloc) >= firstchange)) {
-				/* need to recompute the entry */
-			} else {
-				goto success;
-			}
-		} else {
-			goto success;
-		}
-	}
+	/* If name is in the table, check answer will be ok */
+	if ((cmdp = cmdlookup(name, 0)) != NULL) {
+		int bit;
 
-	bcmd = find_builtin(name);
-	regular = bcmd && IS_BUILTIN_REGULAR(bcmd);
-
-	if (regular) {
-		if (cmdp && (cmdp->cmdtype == CMDBUILTIN)) {
-			goto success;
+		switch (cmdp->cmdtype) {
+		default:
+#if DEBUG
+			abort();
+#endif
+		case CMDNORMAL:
+			bit = DO_ALTPATH;
+			break;
+		case CMDFUNCTION:
+			bit = DO_NOFUNC;
+			break;
+		case CMDBUILTIN:
+			bit = DO_ALTBLTIN;
+			break;
 		}
-	} else if (act & DO_BRUTE) {
-		if (firstchange == 0) {
+		if (act & bit) {
 			updatetbl = 0;
-		}
+			cmdp = NULL;
+		} else if (cmdp->rehash == 0)
+			/* if not invalidated by cd, we're done */
+			goto success;
 	}
 
 	/* If %builtin not in path, check for builtin next */
-	if (regular || (bltin < 0 && bcmd)) {
-	  builtin:
-		if (!updatetbl) {
-			entry->cmdtype = CMDBUILTIN;
-			entry->u.cmd = bcmd;
-			return;
-		}
-		INTOFF;
-		cmdp = cmdlookup(name, 1);
-		cmdp->cmdtype = CMDBUILTIN;
-		cmdp->param.cmd = bcmd;
-		INTON;
-		goto success;
-	}
+	bcmd = find_builtin(name);
+	if (bcmd && (IS_BUILTIN_REGULAR(bcmd) || (
+		act & DO_ALTPATH ? !(act & DO_ALTBLTIN) : builtinloc <= 0
+	)))
+		goto builtin_success;
 
 	/* We have to search path. */
-	prev = -1;			/* where to start */
-	if (cmdp && cmdp->rehash) {	/* doing a rehash */
+	prev = -1;              /* where to start */
+	if (cmdp && cmdp->rehash) {     /* doing a rehash */
 		if (cmdp->cmdtype == CMDBUILTIN)
 			prev = builtinloc;
 		else
@@ -3664,52 +3951,52 @@
 
 	e = ENOENT;
 	idx = -1;
-  loop:
+loop:
 	while ((fullname = padvance(&path, name)) != NULL) {
 		stunalloc(fullname);
 		idx++;
-		if (idx >= firstchange) {
-			updatetbl = 0;
-		}
 		if (pathopt) {
-			if (prefix("builtin", pathopt)) {
-				if ((bcmd = find_builtin(name))) {
-					goto builtin;
-				}
+			if (prefix(pathopt, "builtin")) {
+				if (bcmd)
+					goto builtin_success;
 				continue;
-			} else if (!(act & DO_NOFUN) && prefix("func", pathopt)) {
+			} else if (!(act & DO_NOFUNC) &&
+				   prefix(pathopt, "func")) {
 				/* handled below */
 			} else {
-				continue;	/* ignore unimplemented options */
+				/* ignore unimplemented options */
+				continue;
 			}
 		}
 		/* if rehash, don't redo absolute path names */
-		if (fullname[0] == '/' && idx <= prev && idx < firstchange) {
+		if (fullname[0] == '/' && idx <= prev) {
 			if (idx < prev)
 				continue;
 			TRACE(("searchexec \"%s\": no change\n", name));
 			goto success;
 		}
 		while (stat(fullname, &statb) < 0) {
+#ifdef SYSV
+			if (errno == EINTR)
+				continue;
+#endif
 			if (errno != ENOENT && errno != ENOTDIR)
 				e = errno;
 			goto loop;
 		}
-		e = EACCES;		/* if we fail, this will be the error */
+		e = EACCES;     /* if we fail, this will be the error */
 		if (!S_ISREG(statb.st_mode))
 			continue;
-		if (pathopt) {	/* this is a %func directory */
+		if (pathopt) {          /* this is a %func directory */
 			stalloc(strlen(fullname) + 1);
 			readcmdfile(fullname);
-			if ((cmdp = cmdlookup(name, 0)) == NULL
-				|| cmdp->cmdtype != CMDFUNCTION)
+			if ((cmdp = cmdlookup(name, 0)) == NULL ||
+			    cmdp->cmdtype != CMDFUNCTION)
 				error("%s not defined in %s", name, fullname);
 			stunalloc(fullname);
 			goto success;
 		}
 		TRACE(("searchexec \"%s\" returns \"%s\"\n", name, fullname));
-		/* If we aren't called with DO_BRUTE and cmdp is set, it must
-		   be a function and we're being called with DO_NOFUN */
 		if (!updatetbl) {
 			entry->cmdtype = CMDNORMAL;
 			entry->u.index = idx;
@@ -3727,46 +4014,72 @@
 	if (cmdp && updatetbl)
 		delete_cmd_entry();
 	if (act & DO_ERR)
-		out2fmt("%s: %s\n", name, errmsg(e, E_EXEC));
+		sh_warnx("%s: %s", name, errmsg(e, E_EXEC));
 	entry->cmdtype = CMDUNKNOWN;
 	return;
 
-  success:
+builtin_success:
+	if (!updatetbl) {
+		entry->cmdtype = CMDBUILTIN;
+		entry->u.cmd = bcmd;
+		return;
+	}
+	INTOFF;
+	cmdp = cmdlookup(name, 1);
+	cmdp->cmdtype = CMDBUILTIN;
+	cmdp->param.cmd = bcmd;
+	INTON;
+success:
 	cmdp->rehash = 0;
 	entry->cmdtype = cmdp->cmdtype;
 	entry->u = cmdp->param;
 }
 
 
+/*
+ * Wrapper around strcmp for qsort/bsearch/...
+ */
+static int pstrcmp(const void *a, const void *b)
+{
+	return strcmp((const char *) a, (*(const char *const *) b) + 1);
+}
 
 /*
  * Search the table of builtin commands.
  */
 
-static struct builtincmd *find_builtin(const char *name)
+static struct builtincmd *
+find_builtin(const char *name)
 {
 	struct builtincmd *bp;
 
-	bp = bsearch(name, builtincmds, NUMBUILTINS, sizeof(struct builtincmd),
-				 pstrcmp);
+	bp = bsearch(
+		name, builtincmd, NUMBUILTINS, sizeof(struct builtincmd),
+		pstrcmp
+	);
 	return bp;
 }
 
 
+
 /*
  * Called when a cd is done.  Marks all commands so the next time they
  * are executed they will be rehashed.
  */
 
-static void hashcd(void)
+static void
+hashcd(void)
 {
 	struct tblentry **pp;
 	struct tblentry *cmdp;
 
-	for (pp = cmdtable; pp < &cmdtable[CMDTABLESIZE]; pp++) {
-		for (cmdp = *pp; cmdp; cmdp = cmdp->next) {
-			if (cmdp->cmdtype == CMDNORMAL
-				|| (cmdp->cmdtype == CMDBUILTIN && builtinloc >= 0))
+	for (pp = cmdtable ; pp < &cmdtable[CMDTABLESIZE] ; pp++) {
+		for (cmdp = *pp ; cmdp ; cmdp = cmdp->next) {
+			if (cmdp->cmdtype == CMDNORMAL || (
+				cmdp->cmdtype == CMDBUILTIN &&
+				!(IS_BUILTIN_REGULAR(cmdp->param.cmd)) &&
+				builtinloc > 0
+			))
 				cmdp->rehash = 1;
 		}
 	}
@@ -3775,23 +4088,48 @@
 
 
 /*
+ * Fix command hash table when PATH changed.
  * Called before PATH is changed.  The argument is the new value of PATH;
- * pathval() still returns the old value at this point.  Called with
- * interrupts off.
+ * pathval() still returns the old value at this point.
+ * Called with interrupts off.
  */
 
-static void changepath(const char *newval)
+static void
+changepath(const char *newval)
 {
+	const char *old, *new;
+	int idx;
 	int firstchange;
-	int bltin;
+	int idx_bltin;
 
-	firstchange = path_change(newval, &bltin);
-	if (builtinloc < 0 && bltin >= 0)
-		builtinloc = bltin;	/* zap builtins */
+	old = pathval();
+	new = newval;
+	firstchange = 9999;     /* assume no change */
+	idx = 0;
+	idx_bltin = -1;
+	for (;;) {
+		if (*old != *new) {
+			firstchange = idx;
+			if ((*old == '\0' && *new == ':')
+			 || (*old == ':' && *new == '\0'))
+				firstchange++;
+			old = new;      /* ignore subsequent differences */
+		}
+		if (*new == '\0')
+			break;
+		if (*new == '%' && idx_bltin < 0 && prefix(new + 1, "builtin"))
+			idx_bltin = idx;
+		if (*new == ':') {
+			idx++;
+		}
+		new++, old++;
+	}
+	if (builtinloc < 0 && idx_bltin >= 0)
+		builtinloc = idx_bltin;             /* zap builtins */
+	if (builtinloc >= 0 && idx_bltin < 0)
+		firstchange = 0;
 	clearcmdentry(firstchange);
-	builtinloc = bltin;
-	/* Ensure that getenv("PATH") stays current */
-	setenv("PATH", newval, 1);
+	builtinloc = idx_bltin;
 }
 
 
@@ -3800,21 +4138,23 @@
  * PATH which has changed.
  */
 
-static void clearcmdentry(int firstchange)
+static void
+clearcmdentry(int firstchange)
 {
 	struct tblentry **tblp;
 	struct tblentry **pp;
 	struct tblentry *cmdp;
 
 	INTOFF;
-	for (tblp = cmdtable; tblp < &cmdtable[CMDTABLESIZE]; tblp++) {
+	for (tblp = cmdtable ; tblp < &cmdtable[CMDTABLESIZE] ; tblp++) {
 		pp = tblp;
 		while ((cmdp = *pp) != NULL) {
 			if ((cmdp->cmdtype == CMDNORMAL &&
-				 cmdp->param.index >= firstchange)
-				|| (cmdp->cmdtype == CMDBUILTIN && builtinloc >= firstchange)) {
+			     cmdp->param.index >= firstchange)
+			 || (cmdp->cmdtype == CMDBUILTIN &&
+			     builtinloc >= firstchange)) {
 				*pp = cmdp->next;
-				free(cmdp);
+				ckfree(cmdp);
 			} else {
 				pp = &cmdp->next;
 			}
@@ -3824,43 +4164,45 @@
 }
 
 
+
 /*
  * Locate a command in the command hash table.  If "add" is nonzero,
  * add the command to the table if it is not already present.  The
  * variable "lastcmdentry" is set to point to the address of the link
  * pointing to the entry, so that delete_cmd_entry can delete the
  * entry.
+ *
+ * Interrupts must be off if called with add != 0.
  */
 
 static struct tblentry **lastcmdentry;
 
-static struct tblentry *cmdlookup(const char *name, int add)
+
+static struct tblentry *
+cmdlookup(const char *name, int add)
 {
-	int hashval;
+	unsigned int hashval;
 	const char *p;
 	struct tblentry *cmdp;
 	struct tblentry **pp;
 
 	p = name;
-	hashval = *p << 4;
+	hashval = (unsigned char)*p << 4;
 	while (*p)
-		hashval += *p++;
+		hashval += (unsigned char)*p++;
 	hashval &= 0x7FFF;
 	pp = &cmdtable[hashval % CMDTABLESIZE];
-	for (cmdp = *pp; cmdp; cmdp = cmdp->next) {
+	for (cmdp = *pp ; cmdp ; cmdp = cmdp->next) {
 		if (equal(cmdp->cmdname, name))
 			break;
 		pp = &cmdp->next;
 	}
 	if (add && cmdp == NULL) {
-		INTOFF;
-		cmdp = *pp = xmalloc(sizeof(struct tblentry) - ARB
-							 + strlen(name) + 1);
+		cmdp = *pp = ckmalloc(sizeof (struct tblentry) - ARB
+					+ strlen(name) + 1);
 		cmdp->next = NULL;
 		cmdp->cmdtype = CMDUNKNOWN;
-		cmdp->rehash = 0;
 		strcpy(cmdp->cmdname, name);
-		INTON;
 	}
 	lastcmdentry = pp;
 	return cmdp;
@@ -3870,90 +4212,218 @@
  * Delete the command entry returned on the last lookup.
  */
 
-static void delete_cmd_entry(void)
+static void
+delete_cmd_entry(void)
 {
 	struct tblentry *cmdp;
 
 	INTOFF;
 	cmdp = *lastcmdentry;
 	*lastcmdentry = cmdp->next;
-	free(cmdp);
+	if (cmdp->cmdtype == CMDFUNCTION)
+		freefunc(cmdp->param.func);
+	ckfree(cmdp);
 	INTON;
 }
 
 
+/*
+ * Add a new command entry, replacing any existing command entry for
+ * the same name - except special builtins.
+ */
 
+static inline void
+addcmdentry(char *name, struct cmdentry *entry)
+{
+	struct tblentry *cmdp;
 
+	cmdp = cmdlookup(name, 1);
+	if (cmdp->cmdtype == CMDFUNCTION) {
+		freefunc(cmdp->param.func);
+	}
+	cmdp->cmdtype = entry->cmdtype;
+	cmdp->param = entry->u;
+	cmdp->rehash = 0;
+}
 
-static const unsigned char nodesize[26] = {
-	ALIGN(sizeof(struct nbinary)),
-	ALIGN(sizeof(struct ncmd)),
-	ALIGN(sizeof(struct npipe)),
-	ALIGN(sizeof(struct nredir)),
-	ALIGN(sizeof(struct nredir)),
-	ALIGN(sizeof(struct nredir)),
-	ALIGN(sizeof(struct nbinary)),
-	ALIGN(sizeof(struct nbinary)),
-	ALIGN(sizeof(struct nif)),
-	ALIGN(sizeof(struct nbinary)),
-	ALIGN(sizeof(struct nbinary)),
-	ALIGN(sizeof(struct nfor)),
-	ALIGN(sizeof(struct ncase)),
-	ALIGN(sizeof(struct nclist)),
-	ALIGN(sizeof(struct narg)),
-	ALIGN(sizeof(struct narg)),
-	ALIGN(sizeof(struct nfile)),
-	ALIGN(sizeof(struct nfile)),
-	ALIGN(sizeof(struct nfile)),
-	ALIGN(sizeof(struct nfile)),
-	ALIGN(sizeof(struct nfile)),
-	ALIGN(sizeof(struct ndup)),
-	ALIGN(sizeof(struct ndup)),
-	ALIGN(sizeof(struct nhere)),
-	ALIGN(sizeof(struct nhere)),
-	ALIGN(sizeof(struct nnot)),
-};
+/*
+ * Make a copy of a parse tree.
+ */
 
+static inline struct funcnode *
+copyfunc(union node *n)
+{
+	struct funcnode *f;
+	size_t blocksize;
+
+	funcblocksize = offsetof(struct funcnode, n);
+	funcstringsize = 0;
+	calcsize(n);
+	blocksize = funcblocksize;
+	f = ckmalloc(blocksize + funcstringsize);
+	funcblock = (char *) f + offsetof(struct funcnode, n);
+	funcstring = (char *) f + blocksize;
+	copynode(n);
+	f->count = 0;
+	return f;
+}
+
+/*
+ * Define a shell function.
+ */
+
+static void
+defun(char *name, union node *func)
+{
+	struct cmdentry entry;
+
+	INTOFF;
+	entry.cmdtype = CMDFUNCTION;
+	entry.u.func = copyfunc(func);
+	addcmdentry(name, &entry);
+	INTON;
+}
 
 
 /*
  * Delete a function if it exists.
  */
 
-static void unsetfunc(char *name)
+static void
+unsetfunc(const char *name)
 {
 	struct tblentry *cmdp;
 
-	if ((cmdp = cmdlookup(name, 0)) != NULL && cmdp->cmdtype == CMDFUNCTION) {
-		free(cmdp->param.func);
+	if ((cmdp = cmdlookup(name, 0)) != NULL &&
+	    cmdp->cmdtype == CMDFUNCTION)
 		delete_cmd_entry();
-	}
 }
 
-
 /*
  * Locate and print what a word is...
  */
 
-static int typecmd(int argc, char **argv)
+
+#ifdef CONFIG_ASH_CMDCMD
+static int
+describe_command(char *command, int describe_command_verbose)
+#else
+#define describe_command_verbose 1
+static int
+describe_command(char *command)
+#endif
+{
+	struct cmdentry entry;
+	struct tblentry *cmdp;
+#ifdef CONFIG_ASH_ALIAS
+	const struct alias *ap;
+#endif
+	const char *path = pathval();
+
+	if (describe_command_verbose) {
+		out1str(command);
+	}
+
+	/* First look at the keywords */
+	if (findkwd(command)) {
+		out1str(describe_command_verbose ? " is a shell keyword" : command);
+		goto out;
+	}
+
+#ifdef CONFIG_ASH_ALIAS
+	/* Then look at the aliases */
+	if ((ap = lookupalias(command, 0)) != NULL) {
+		if (describe_command_verbose) {
+			out1fmt(" is an alias for %s", ap->val);
+		} else {
+			out1str("alias ");
+			printalias(ap);
+			return 0;
+		}
+		goto out;
+	}
+#endif
+	/* Then check if it is a tracked alias */
+	if ((cmdp = cmdlookup(command, 0)) != NULL) {
+		entry.cmdtype = cmdp->cmdtype;
+		entry.u = cmdp->param;
+	} else {
+		/* Finally use brute force */
+		find_command(command, &entry, DO_ABS, path);
+	}
+
+	switch (entry.cmdtype) {
+	case CMDNORMAL: {
+		int j = entry.u.index;
+		char *p;
+		if (j == -1) {
+			p = command;
+		} else {
+			do {
+				p = padvance(&path, command);
+				stunalloc(p);
+			} while (--j >= 0);
+		}
+		if (describe_command_verbose) {
+			out1fmt(" is%s %s",
+				(cmdp ? " a tracked alias for" : nullstr), p
+			);
+		} else {
+			out1str(p);
+		}
+		break;
+	}
+
+	case CMDFUNCTION:
+		if (describe_command_verbose) {
+			out1str(" is a shell function");
+		} else {
+			out1str(command);
+		}
+		break;
+
+	case CMDBUILTIN:
+		if (describe_command_verbose) {
+			out1fmt(" is a %sshell builtin",
+				IS_BUILTIN_SPECIAL(entry.u.cmd) ?
+					"special " : nullstr
+			);
+		} else {
+			out1str(command);
+		}
+		break;
+
+	default:
+		if (describe_command_verbose) {
+			out1str(": not found\n");
+		}
+		return 127;
+	}
+
+out:
+	out1c('\n');
+	return 0;
+}
+
+static int
+typecmd(int argc, char **argv)
 {
 	int i;
 	int err = 0;
-	char *argv_a[2];
-
-	argv_a[1] = 0;
 
 	for (i = 1; i < argc; i++) {
-		argv_a[0] = argv[i];
-		argptr = argv_a;
-		optptr = "v";
-		err |= hashcmd(2, argv);
+#ifdef CONFIG_ASH_CMDCMD
+		err |= describe_command(argv[i], 1);
+#else
+		err |= describe_command(argv[i]);
+#endif
 	}
 	return err;
 }
 
 #ifdef CONFIG_ASH_CMDCMD
-static int commandcmd(int argc, char **argv)
+static int
+commandcmd(int argc, char **argv)
 {
 	int c;
 	int default_path = 0;
@@ -3962,6 +4432,12 @@
 
 	while ((c = nextopt("pvV")) != '\0')
 		switch (c) {
+		default:
+#ifdef DEBUG
+			fprintf(stderr,
+"command: nextopt returned character code 0%o\n", c);
+			return EX_SOFTWARE;
+#endif
 		case 'p':
 			default_path = 1;
 			break;
@@ -3973,68 +4449,37 @@
 			break;
 		}
 
-	if (default_path + verify_only + verbose_verify_only > 1 || !*argptr) {
-		out2str("command [-p] command [arg ...]\n"
+	if (default_path + verify_only + verbose_verify_only > 1 ||
+	    !*argptr) {
+			fprintf(stderr,
+				"command [-p] command [arg ...]\n"
 				"command {-v|-V} command\n");
-		return EX_USAGE;
+			return EX_USAGE;
 	}
 
 	if (verify_only || verbose_verify_only) {
-		char *argv_a[2];
-
-		argv_a[1] = 0;
-		argv_a[0] = *argptr;
-		argptr = argv_a;
-		optptr = verbose_verify_only ? "v" : "V";	/* reverse special */
-		return hashcmd(argc, argv);
+		return describe_command(*argptr, verbose_verify_only);
 	}
 
 	return 0;
 }
 #endif
 
-static int path_change(const char *newval, int *bltin)
-{
-	const char *old, *new;
-	int idx;
-	int firstchange;
-
-	old = pathval();
-	new = newval;
-	firstchange = 9999;	/* assume no change */
-	idx = 0;
-	*bltin = -1;
-	for (;;) {
-		if (*old != *new) {
-			firstchange = idx;
-			if ((*old == '\0' && *new == ':')
-				|| (*old == ':' && *new == '\0'))
-				firstchange++;
-			old = new;	/* ignore subsequent differences */
-		}
-		if (*new == '\0')
-			break;
-		if (*new == '%' && *bltin < 0 && prefix("builtin", new + 1))
-			*bltin = idx;
-		if (*new == ':') {
-			idx++;
-		}
-		new++, old++;
-	}
-	if (builtinloc >= 0 && *bltin < 0)
-		firstchange = 0;
-	return firstchange;
-}
+/*      $NetBSD: expand.c,v 1.56 2002/11/24 22:35:39 christos Exp $     */
 
 /*
  * Routines to expand arguments to commands.  We have to deal with
  * backquotes, shell variables, and file metacharacters.
  */
+
 /*
  * _rmescape() flags
  */
-#define RMESCAPE_ALLOC  0x1	/* Allocate a new string */
-#define RMESCAPE_GLOB   0x2	/* Add backslashes for glob */
+#define RMESCAPE_ALLOC  0x1     /* Allocate a new string */
+#define RMESCAPE_GLOB   0x2     /* Add backslashes for glob */
+#define RMESCAPE_QUOTED 0x4     /* Remove CTLESC unless in quotes */
+#define RMESCAPE_GROW   0x8     /* Grow strings instead of stalloc */
+#define RMESCAPE_HEAP   0x10    /* Malloc strings instead of stalloc */
 
 /*
  * Structure specifying which parts of the string should be searched
@@ -4042,66 +4487,87 @@
  */
 
 struct ifsregion {
-	struct ifsregion *next;	/* next region in list */
-	int begoff;			/* offset of start of region */
-	int endoff;			/* offset of end of region */
-	int nulonly;		/* search for nul bytes only */
+	struct ifsregion *next; /* next region in list */
+	int begoff;             /* offset of start of region */
+	int endoff;             /* offset of end of region */
+	int nulonly;            /* search for nul bytes only */
 };
 
-
-static char *expdest;	/* output of current string */
-static struct nodelist *argbackq;	/* list of back quote expressions */
-static struct ifsregion ifsfirst;	/* first struct in list of ifs regions */
-static struct ifsregion *ifslastp;	/* last struct in list */
-static struct arglist exparg;	/* holds expanded arg list */
+/* output of current string */
+static char *expdest;
+/* list of back quote expressions */
+static struct nodelist *argbackq;
+/* first struct in list of ifs regions */
+static struct ifsregion ifsfirst;
+/* last struct in list */
+static struct ifsregion *ifslastp;
+/* holds expanded arg list */
+static struct arglist exparg;
 
 static void argstr(char *, int);
-static char *exptilde(char *, int);
+static char *exptilde(char *, char *, int);
 static void expbackq(union node *, int, int);
-static int subevalvar(char *, char *, int, int, int, int, int);
+static const char *subevalvar(char *, char *, int, int, int, int, int);
+static char *evalvar(char *, int);
 static int varisset(char *, int);
 static void strtodest(const char *, int, int);
+static void memtodest(const char *p, size_t len, int syntax, int quotes);
 static void varvalue(char *, int, int);
 static void recordregion(int, int, int);
 static void removerecordregions(int);
 static void ifsbreakup(char *, struct arglist *);
 static void ifsfree(void);
 static void expandmeta(struct strlist *, int);
-
-#if defined(__GLIBC__) && __GLIBC__ >= 2 && !defined(FNMATCH_BROKEN)
-#define preglob(p) _rmescapes((p), RMESCAPE_ALLOC | RMESCAPE_GLOB)
-#if !defined(GLOB_BROKEN)
 static void addglob(const glob_t *);
-#endif
-#endif
-#if !(defined(__GLIBC__) && __GLIBC__ >= 2 && !defined(FNMATCH_BROKEN) && !defined(GLOB_BROKEN))
-static void expmeta(char *, char *);
-#endif
-#if !(defined(__GLIBC__) && __GLIBC__ >= 2 && !defined(FNMATCH_BROKEN) && !defined(GLOB_BROKEN))
-static struct strlist *expsort(struct strlist *);
-static struct strlist *msort(struct strlist *, int);
-#endif
-static int patmatch(char *, char *, int);
+static void addfname(char *);
+static int patmatch(char *, const char *);
 
-#if defined(__GLIBC__) && __GLIBC__ >= 2 && !defined(FNMATCH_BROKEN)
-static int patmatch2(char *, char *, int);
-#else
-static int pmatch(char *, char *, int);
+static int cvtnum(long);
+static size_t esclen(const char *, const char *);
+static char *scanleft(char *, char *, char *, char *, int, int);
+static char *scanright(char *, char *, char *, char *, int, int);
+static void varunset(const char *, const char *, const char *, int)
+	__attribute__((__noreturn__));
 
-#define patmatch2 patmatch
-#endif
-static char *cvtnum(int, char *);
+
+#define pmatch(a, b) !fnmatch((a), (b), 0)
+/*
+ * Prepare a pattern for a glob(3) call.
+ *
+ * Returns an stalloced string.
+ */
+
+static inline char *
+preglob(const char *pattern, int quoted, int flag) {
+	flag |= RMESCAPE_GLOB;
+	if (quoted) {
+		flag |= RMESCAPE_QUOTED;
+	}
+	return _rmescapes((char *)pattern, flag);
+}
+
+
+static size_t
+esclen(const char *start, const char *p) {
+	size_t esc = 0;
+
+	while (p > start && *--p == CTLESC) {
+		esc++;
+	}
+	return esc;
+}
+
 
 /*
  * Expand shell variables and backquotes inside a here document.
  */
 
-/* arg: the document, fd: where to write the expanded version */
-static inline void expandhere(union node *arg, int fd)
+static inline void
+expandhere(union node *arg, int fd)
 {
 	herefd = fd;
-	expandarg(arg, (struct arglist *) NULL, 0);
-	xwrite(fd, stackblock(), expdest - stackblock());
+	expandarg(arg, (struct arglist *)NULL, 0);
+	xwrite(fd, stackblock(), expdest - (char *)stackblock());
 }
 
 
@@ -4112,7 +4578,8 @@
  * here document expansion.
  */
 
-static void expandarg(union node *arg, struct arglist *arglist, int flag)
+void
+expandarg(union node *arg, struct arglist *arglist, int flag)
 {
 	struct strlist *sp;
 	char *p;
@@ -4123,7 +4590,7 @@
 	ifslastp = NULL;
 	argstr(arg->narg.text, flag);
 	if (arglist == NULL) {
-		return;			/* here document expanded */
+		return;                 /* here document expanded */
 	}
 	STPUTC('\0', expdest);
 	p = grabstackstr(expdest);
@@ -4137,14 +4604,15 @@
 		exparg.lastp = &exparg.list;
 		expandmeta(exparg.list, flag);
 	} else {
-		if (flag & EXP_REDIR)	/*XXX - for now, just remove escapes */
+		if (flag & EXP_REDIR) /*XXX - for now, just remove escapes */
 			rmescapes(p);
-		sp = (struct strlist *) stalloc(sizeof(struct strlist));
+		sp = (struct strlist *)stalloc(sizeof (struct strlist));
 		sp->text = p;
 		*exparg.lastp = sp;
 		exparg.lastp = &sp->next;
 	}
-	ifsfree();
+	if (ifsfirst.next)
+		ifsfree();
 	*exparg.lastp = NULL;
 	if (exparg.list) {
 		*arglist->lastp = exparg.list;
@@ -4153,120 +4621,585 @@
 }
 
 
+
+/*
+ * Perform variable and command substitution.  If EXP_FULL is set, output CTLESC
+ * characters to allow for further processing.  Otherwise treat
+ * $@ like $* since no splitting will be performed.
+ */
+
+static void
+argstr(char *p, int flag)
+{
+	static const char spclchars[] = {
+		'=',
+		':',
+		CTLQUOTEMARK,
+		CTLENDVAR,
+		CTLESC,
+		CTLVAR,
+		CTLBACKQ,
+		CTLBACKQ | CTLQUOTE,
+#ifdef CONFIG_ASH_MATH_SUPPORT
+		CTLENDARI,
+#endif
+		0
+	};
+	const char *reject = spclchars;
+	int c;
+	int quotes = flag & (EXP_FULL | EXP_CASE);      /* do CTLESC */
+	int breakall = flag & EXP_WORD;
+	int inquotes;
+	size_t length;
+	int startloc;
+
+	if (!(flag & EXP_VARTILDE)) {
+		reject += 2;
+	} else if (flag & EXP_VARTILDE2) {
+		reject++;
+	}
+	inquotes = 0;
+	length = 0;
+	if (flag & EXP_TILDE) {
+		char *q;
+
+		flag &= ~EXP_TILDE;
+tilde:
+		q = p;
+		if (*q == CTLESC && (flag & EXP_QWORD))
+			q++;
+		if (*q == '~')
+			p = exptilde(p, q, flag);
+	}
+start:
+	startloc = expdest - (char *)stackblock();
+	for (;;) {
+		length += strcspn(p + length, reject);
+		c = p[length];
+		if (c && (!(c & 0x80)
+#ifdef CONFIG_ASH_MATH_SUPPORT
+					|| c == CTLENDARI
+#endif
+		   )) {
+			/* c == '=' || c == ':' || c == CTLENDARI */
+			length++;
+		}
+		if (length > 0) {
+			int newloc;
+			expdest = stnputs(p, length, expdest);
+			newloc = expdest - (char *)stackblock();
+			if (breakall && !inquotes && newloc > startloc) {
+				recordregion(startloc, newloc, 0);
+			}
+			startloc = newloc;
+		}
+		p += length + 1;
+		length = 0;
+
+		switch (c) {
+		case '\0':
+			goto breakloop;
+		case '=':
+			if (flag & EXP_VARTILDE2) {
+				p--;
+				continue;
+			}
+			flag |= EXP_VARTILDE2;
+			reject++;
+			/* fall through */
+		case ':':
+			/*
+			 * sort of a hack - expand tildes in variable
+			 * assignments (after the first '=' and after ':'s).
+			 */
+			if (*--p == '~') {
+				goto tilde;
+			}
+			continue;
+		}
+
+		switch (c) {
+		case CTLENDVAR: /* ??? */
+			goto breakloop;
+		case CTLQUOTEMARK:
+			/* "$@" syntax adherence hack */
+			if (
+				!inquotes &&
+				!memcmp(p, dolatstr, DOLATSTRLEN) &&
+				(p[4] == CTLQUOTEMARK || (
+					p[4] == CTLENDVAR &&
+					p[5] == CTLQUOTEMARK
+				))
+			) {
+				p = evalvar(p + 1, flag) + 1;
+				goto start;
+			}
+			inquotes = !inquotes;
+addquote:
+			if (quotes) {
+				p--;
+				length++;
+				startloc++;
+			}
+			break;
+		case CTLESC:
+			startloc++;
+			length++;
+			goto addquote;
+		case CTLVAR:
+			p = evalvar(p, flag);
+			goto start;
+		case CTLBACKQ:
+			c = 0;
+		case CTLBACKQ|CTLQUOTE:
+			expbackq(argbackq->n, c, quotes);
+			argbackq = argbackq->next;
+			goto start;
+#ifdef CONFIG_ASH_MATH_SUPPORT
+		case CTLENDARI:
+			p--;
+			expari(quotes);
+			goto start;
+#endif
+		}
+	}
+breakloop:
+	;
+}
+
+static char *
+exptilde(char *startp, char *p, int flag)
+{
+	char c;
+	char *name;
+	struct passwd *pw;
+	const char *home;
+	int quotes = flag & (EXP_FULL | EXP_CASE);
+	int startloc;
+
+	name = p + 1;
+
+	while ((c = *++p) != '\0') {
+		switch(c) {
+		case CTLESC:
+			return (startp);
+		case CTLQUOTEMARK:
+			return (startp);
+		case ':':
+			if (flag & EXP_VARTILDE)
+				goto done;
+			break;
+		case '/':
+		case CTLENDVAR:
+			goto done;
+		}
+	}
+done:
+	*p = '\0';
+	if (*name == '\0') {
+		if ((home = lookupvar(homestr)) == NULL)
+			goto lose;
+	} else {
+		if ((pw = getpwnam(name)) == NULL)
+			goto lose;
+		home = pw->pw_dir;
+	}
+	if (*home == '\0')
+		goto lose;
+	*p = c;
+	startloc = expdest - (char *)stackblock();
+	strtodest(home, SQSYNTAX, quotes);
+	recordregion(startloc, expdest - (char *)stackblock(), 0);
+	return (p);
+lose:
+	*p = c;
+	return (startp);
+}
+
+
+static void
+removerecordregions(int endoff)
+{
+	if (ifslastp == NULL)
+		return;
+
+	if (ifsfirst.endoff > endoff) {
+		while (ifsfirst.next != NULL) {
+			struct ifsregion *ifsp;
+			INTOFF;
+			ifsp = ifsfirst.next->next;
+			ckfree(ifsfirst.next);
+			ifsfirst.next = ifsp;
+			INTON;
+		}
+		if (ifsfirst.begoff > endoff)
+			ifslastp = NULL;
+		else {
+			ifslastp = &ifsfirst;
+			ifsfirst.endoff = endoff;
+		}
+		return;
+	}
+
+	ifslastp = &ifsfirst;
+	while (ifslastp->next && ifslastp->next->begoff < endoff)
+		ifslastp=ifslastp->next;
+	while (ifslastp->next != NULL) {
+		struct ifsregion *ifsp;
+		INTOFF;
+		ifsp = ifslastp->next->next;
+		ckfree(ifslastp->next);
+		ifslastp->next = ifsp;
+		INTON;
+	}
+	if (ifslastp->endoff > endoff)
+		ifslastp->endoff = endoff;
+}
+
+
+#ifdef CONFIG_ASH_MATH_SUPPORT
+/*
+ * Expand arithmetic expression.  Backup to start of expression,
+ * evaluate, place result in (backed up) result, adjust string position.
+ */
+void
+expari(int quotes)
+{
+	char *p, *start;
+	int begoff;
+	int flag;
+	int len;
+
+	/*      ifsfree(); */
+
+	/*
+	 * This routine is slightly over-complicated for
+	 * efficiency.  Next we scan backwards looking for the
+	 * start of arithmetic.
+	 */
+	start = stackblock();
+	p = expdest - 1;
+	*p = '\0';
+	p--;
+	do {
+		int esc;
+
+		while (*p != CTLARI) {
+			p--;
+#ifdef DEBUG
+			if (p < start) {
+				error("missing CTLARI (shouldn't happen)");
+			}
+#endif
+		}
+
+		esc = esclen(start, p);
+		if (!(esc % 2)) {
+			break;
+		}
+
+		p -= esc + 1;
+	} while (1);
+
+	begoff = p - start;
+
+	removerecordregions(begoff);
+
+	flag = p[1];
+
+	expdest = p;
+
+	if (quotes)
+		rmescapes(p + 2);
+
+	len = cvtnum(dash_arith(p + 2));
+
+	if (flag != '"')
+		recordregion(begoff, begoff + len, 0);
+}
+#endif
+
+/*
+ * Expand stuff in backwards quotes.
+ */
+
+static void
+expbackq(union node *cmd, int quoted, int quotes)
+{
+	struct backcmd in;
+	int i;
+	char buf[128];
+	char *p;
+	char *dest;
+	int startloc;
+	int syntax = quoted? DQSYNTAX : BASESYNTAX;
+	struct stackmark smark;
+
+	INTOFF;
+	setstackmark(&smark);
+	dest = expdest;
+	startloc = dest - (char *)stackblock();
+	grabstackstr(dest);
+	evalbackcmd(cmd, (struct backcmd *) &in);
+	popstackmark(&smark);
+
+	p = in.buf;
+	i = in.nleft;
+	if (i == 0)
+		goto read;
+	for (;;) {
+		memtodest(p, i, syntax, quotes);
+read:
+		if (in.fd < 0)
+			break;
+		i = safe_read(in.fd, buf, sizeof buf);
+		TRACE(("expbackq: read returns %d\n", i));
+		if (i <= 0)
+			break;
+		p = buf;
+	}
+
+	if (in.buf)
+		ckfree(in.buf);
+	if (in.fd >= 0) {
+		close(in.fd);
+		back_exitstatus = waitforjob(in.jp);
+	}
+	INTON;
+
+	/* Eat all trailing newlines */
+	dest = expdest;
+	for (; dest > (char *)stackblock() && dest[-1] == '\n';)
+		STUNPUTC(dest);
+	expdest = dest;
+
+	if (quoted == 0)
+		recordregion(startloc, dest - (char *)stackblock(), 0);
+	TRACE(("evalbackq: size=%d: \"%.*s\"\n",
+		(dest - (char *)stackblock()) - startloc,
+		(dest - (char *)stackblock()) - startloc,
+		stackblock() + startloc));
+}
+
+
+static char *
+scanleft(
+	char *startp, char *rmesc, char *rmescend, char *str, int quotes,
+	int zero
+) {
+	char *loc;
+	char *loc2;
+	char c;
+
+	loc = startp;
+	loc2 = rmesc;
+	do {
+		int match;
+		const char *s = loc2;
+		c = *loc2;
+		if (zero) {
+			*loc2 = '\0';
+			s = rmesc;
+		}
+		match = pmatch(str, s);
+		*loc2 = c;
+		if (match)
+			return loc;
+		if (quotes && *loc == CTLESC)
+			loc++;
+		loc++;
+		loc2++;
+	} while (c);
+	return 0;
+}
+
+
+static char *
+scanright(
+	char *startp, char *rmesc, char *rmescend, char *str, int quotes,
+	int zero
+) {
+	int esc = 0;
+	char *loc;
+	char *loc2;
+
+	for (loc = str - 1, loc2 = rmescend; loc >= startp; loc2--) {
+		int match;
+		char c = *loc2;
+		const char *s = loc2;
+		if (zero) {
+			*loc2 = '\0';
+			s = rmesc;
+		}
+		match = pmatch(str, s);
+		*loc2 = c;
+		if (match)
+			return loc;
+		loc--;
+		if (quotes) {
+			if (--esc < 0) {
+				esc = esclen(startp, loc);
+			}
+			if (esc % 2) {
+				esc--;
+				loc--;
+			}
+		}
+	}
+	return 0;
+}
+
+static const char *
+subevalvar(char *p, char *str, int strloc, int subtype, int startloc, int varflags, int quotes)
+{
+	char *startp;
+	char *loc;
+	int saveherefd = herefd;
+	struct nodelist *saveargbackq = argbackq;
+	int amount;
+	char *rmesc, *rmescend;
+	int zero;
+	char *(*scan)(char *, char *, char *, char *, int , int);
+
+	herefd = -1;
+	argstr(p, subtype != VSASSIGN && subtype != VSQUESTION ? EXP_CASE : 0);
+	STPUTC('\0', expdest);
+	herefd = saveherefd;
+	argbackq = saveargbackq;
+	startp = stackblock() + startloc;
+
+	switch (subtype) {
+	case VSASSIGN:
+		setvar(str, startp, 0);
+		amount = startp - expdest;
+		STADJUST(amount, expdest);
+		return startp;
+
+	case VSQUESTION:
+		varunset(p, str, startp, varflags);
+		/* NOTREACHED */
+	}
+
+	subtype -= VSTRIMRIGHT;
+#ifdef DEBUG
+	if (subtype < 0 || subtype > 3)
+		abort();
+#endif
+
+	rmesc = startp;
+	rmescend = stackblock() + strloc;
+	if (quotes) {
+		rmesc = _rmescapes(startp, RMESCAPE_ALLOC | RMESCAPE_GROW);
+		if (rmesc != startp) {
+			rmescend = expdest;
+			startp = stackblock() + startloc;
+		}
+	}
+	rmescend--;
+	str = stackblock() + strloc;
+	preglob(str, varflags & VSQUOTE, 0);
+
+	/* zero = subtype == VSTRIMLEFT || subtype == VSTRIMLEFTMAX */
+	zero = subtype >> 1;
+	/* VSTRIMLEFT/VSTRIMRIGHTMAX -> scanleft */
+	scan = (subtype & 1) ^ zero ? scanleft : scanright;
+
+	loc = scan(startp, rmesc, rmescend, str, quotes, zero);
+	if (loc) {
+		if (zero) {
+			memmove(startp, loc, str - loc);
+			loc = startp + (str - loc) - 1;
+		}
+		*loc = '\0';
+		amount = loc - expdest;
+		STADJUST(amount, expdest);
+	}
+	return loc;
+}
+
+
 /*
  * Expand a variable, and return a pointer to the next character in the
  * input string.
  */
-
-static inline char *evalvar(char *p, int flag)
+static char *
+evalvar(char *p, int flag)
 {
 	int subtype;
 	int varflags;
 	char *var;
-	const char *val;
 	int patloc;
 	int c;
 	int set;
-	int special;
 	int startloc;
-	int varlen;
+	size_t varlen;
 	int easy;
-	int quotes = flag & (EXP_FULL | EXP_CASE);
+	int quotes;
+	int quoted;
 
+	quotes = flag & (EXP_FULL | EXP_CASE);
 	varflags = *p++;
 	subtype = varflags & VSTYPE;
+	quoted = varflags & VSQUOTE;
 	var = p;
-	special = 0;
-	if (!is_name(*p))
-		special = 1;
-	p = strchr(p, '=') + 1;
-  again:				/* jump here after setting a variable with ${var=text} */
-	if (special) {
-		set = varisset(var, varflags & VSNUL);
-		val = NULL;
-	} else {
-		val = lookupvar(var);
-		if (val == NULL || ((varflags & VSNUL) && val[0] == '\0')) {
-			val = NULL;
-			set = 0;
-		} else
-			set = 1;
-	}
+	easy = (!quoted || (*var == '@' && shellparam.nparam));
 	varlen = 0;
-	startloc = expdest - stackblock();
-	if (set && subtype != VSPLUS) {
-		/* insert the value of the variable */
-		if (special) {
-			varvalue(var, varflags & VSQUOTE, flag);
+	startloc = expdest - (char *)stackblock();
+	p = strchr(p, '=') + 1;
+
+	if (!is_name(*var)) {
+		set = varisset(var, varflags & VSNUL);
+		set--;
+		if (subtype == VSPLUS)
+			goto vsplus;
+		if (++set) {
+			varvalue(var, quoted, flag);
 			if (subtype == VSLENGTH) {
-				varlen = expdest - stackblock() - startloc;
+				varlen =
+					expdest - (char *)stackblock() -
+					startloc;
 				STADJUST(-varlen, expdest);
+				goto vslen;
 			}
-		} else {
-			if (subtype == VSLENGTH) {
-				varlen = strlen(val);
-			} else {
-				strtodest(val,
-						  varflags & VSQUOTE ? DQSYNTAX : BASESYNTAX, quotes);
-			}
+		}
+	} else {
+		const char *val;
+again:
+		/* jump here after setting a variable with ${var=text} */
+		val = lookupvar(var);
+		set = !val || ((varflags & VSNUL) && !*val);
+		if (subtype == VSPLUS)
+			goto vsplus;
+		if (--set) {
+			varlen = strlen(val);
+			if (subtype == VSLENGTH)
+				goto vslen;
+			memtodest(
+				val, varlen, quoted ? DQSYNTAX : BASESYNTAX,
+				quotes
+			);
 		}
 	}
 
-	if (subtype == VSPLUS)
-		set = !set;
 
-	easy = ((varflags & VSQUOTE) == 0 ||
-			(*var == '@' && shellparam.nparam != 1));
-
-
-	switch (subtype) {
-	case VSLENGTH:
-		expdest = cvtnum(varlen, expdest);
-		goto record;
-
-	case VSNORMAL:
-		if (!easy)
-			break;
-	  record:
-		recordregion(startloc, expdest - stackblock(), varflags & VSQUOTE);
-		break;
-
-	case VSPLUS:
-	case VSMINUS:
+	if (subtype == VSMINUS) {
+vsplus:
 		if (!set) {
-			argstr(p, flag);
-			break;
+			argstr(
+				p, flag | EXP_TILDE |
+					(quoted ?  EXP_QWORD : EXP_WORD)
+			);
+			goto end;
 		}
 		if (easy)
 			goto record;
-		break;
+		goto end;
+	}
 
-	case VSTRIMLEFT:
-	case VSTRIMLEFTMAX:
-	case VSTRIMRIGHT:
-	case VSTRIMRIGHTMAX:
-		if (!set)
-			break;
-		/*
-		 * Terminate the string and start recording the pattern
-		 * right after it
-		 */
-		STPUTC('\0', expdest);
-		patloc = expdest - stackblock();
-		if (subevalvar(p, NULL, patloc, subtype,
-					   startloc, varflags, quotes) == 0) {
-			int amount = (expdest - stackblock() - patloc) + 1;
-
-			STADJUST(-amount, expdest);
-		}
-		/* Remove any recorded regions beyond start of variable */
-		removerecordregions(startloc);
-		goto record;
-
-	case VSASSIGN:
-	case VSQUESTION:
+	if (subtype == VSASSIGN || subtype == VSQUESTION) {
 		if (!set) {
-			if (subevalvar(p, var, 0, subtype, startloc, varflags, quotes)) {
+			if (subevalvar(p, var, 0, subtype, startloc,
+				       varflags, 0)) {
 				varflags &= ~VSNUL;
 				/*
 				 * Remove any recorded regions beyond
@@ -4275,25 +5208,68 @@
 				removerecordregions(startloc);
 				goto again;
 			}
-			break;
+			goto end;
 		}
 		if (easy)
 			goto record;
-		break;
-
-#ifdef DEBUG
-	default:
-		abort();
-#endif
+		goto end;
 	}
 
-	if (subtype != VSNORMAL) {	/* skip to end of alternative */
-		int nesting = 1;
+	if (!set && uflag)
+		varunset(p, var, 0, 0);
 
+	if (subtype == VSLENGTH) {
+vslen:
+		cvtnum(varlen);
+		goto record;
+	}
+
+	if (subtype == VSNORMAL) {
+		if (!easy)
+			goto end;
+record:
+		recordregion(startloc, expdest - (char *)stackblock(), quoted);
+		goto end;
+	}
+
+#ifdef DEBUG
+	switch (subtype) {
+	case VSTRIMLEFT:
+	case VSTRIMLEFTMAX:
+	case VSTRIMRIGHT:
+	case VSTRIMRIGHTMAX:
+		break;
+	default:
+		abort();
+	}
+#endif
+
+	if (set) {
+		/*
+		 * Terminate the string and start recording the pattern
+		 * right after it
+		 */
+		STPUTC('\0', expdest);
+		patloc = expdest - (char *)stackblock();
+		if (subevalvar(p, NULL, patloc, subtype,
+			       startloc, varflags, quotes) == 0) {
+			int amount = expdest - (
+				(char *)stackblock() + patloc - 1
+			);
+			STADJUST(-amount, expdest);
+		}
+		/* Remove any recorded regions beyond start of variable */
+		removerecordregions(startloc);
+		goto record;
+	}
+
+end:
+	if (subtype != VSNORMAL) {      /* skip to end of alternative */
+		int nesting = 1;
 		for (;;) {
 			if ((c = *p++) == CTLESC)
 				p++;
-			else if (c == CTLBACKQ || c == (CTLBACKQ | CTLQUOTE)) {
+			else if (c == CTLBACKQ || c == (CTLBACKQ|CTLQUOTE)) {
 				if (set)
 					argbackq = argbackq->next;
 			} else if (c == CTLVAR) {
@@ -4309,449 +5285,16 @@
 }
 
 
-/*
- * Perform variable and command substitution.  If EXP_FULL is set, output CTLESC
- * characters to allow for further processing.  Otherwise treat
- * $@ like $* since no splitting will be performed.
- */
-
-static void argstr(char *p, int flag)
-{
-	char c;
-	int quotes = flag & (EXP_FULL | EXP_CASE);	/* do CTLESC */
-	int firsteq = 1;
-
-	if (*p == '~' && (flag & (EXP_TILDE | EXP_VARTILDE)))
-		p = exptilde(p, flag);
-	for (;;) {
-		switch (c = *p++) {
-		case '\0':
-		case CTLENDVAR:	/* ??? */
-			return;
-		case CTLQUOTEMARK:
-			/* "$@" syntax adherence hack */
-			if (p[0] == CTLVAR && p[2] == '@' && p[3] == '=')
-				break;
-			if ((flag & EXP_FULL) != 0)
-				STPUTC(c, expdest);
-			break;
-		case CTLESC:
-			if (quotes)
-				STPUTC(c, expdest);
-			c = *p++;
-			STPUTC(c, expdest);
-			break;
-		case CTLVAR:
-			p = evalvar(p, flag);
-			break;
-		case CTLBACKQ:
-		case CTLBACKQ | CTLQUOTE:
-			expbackq(argbackq->n, c & CTLQUOTE, flag);
-			argbackq = argbackq->next;
-			break;
-#ifdef CONFIG_ASH_MATH_SUPPORT
-		case CTLENDARI:
-			expari(flag);
-			break;
-#endif
-		case ':':
-		case '=':
-			/*
-			 * sort of a hack - expand tildes in variable
-			 * assignments (after the first '=' and after ':'s).
-			 */
-			STPUTC(c, expdest);
-			if (flag & EXP_VARTILDE && *p == '~') {
-				if (c == '=') {
-					if (firsteq)
-						firsteq = 0;
-					else
-						break;
-				}
-				p = exptilde(p, flag);
-			}
-			break;
-		default:
-			STPUTC(c, expdest);
-		}
-	}
-}
-
-static char *exptilde(char *p, int flag)
-{
-	char c, *startp = p;
-	struct passwd *pw;
-	const char *home;
-	int quotes = flag & (EXP_FULL | EXP_CASE);
-
-	while ((c = *p) != '\0') {
-		switch (c) {
-		case CTLESC:
-			return (startp);
-		case CTLQUOTEMARK:
-			return (startp);
-		case ':':
-			if (flag & EXP_VARTILDE)
-				goto done;
-			break;
-		case '/':
-			goto done;
-		}
-		p++;
-	}
-  done:
-	*p = '\0';
-	if (*(startp + 1) == '\0') {
-		if ((home = lookupvar("HOME")) == NULL)
-			goto lose;
-	} else {
-		if ((pw = getpwnam(startp + 1)) == NULL)
-			goto lose;
-		home = pw->pw_dir;
-	}
-	if (*home == '\0')
-		goto lose;
-	*p = c;
-	strtodest(home, SQSYNTAX, quotes);
-	return (p);
-  lose:
-	*p = c;
-	return (startp);
-}
-
-
-static void removerecordregions(int endoff)
-{
-	if (ifslastp == NULL)
-		return;
-
-	if (ifsfirst.endoff > endoff) {
-		while (ifsfirst.next != NULL) {
-			struct ifsregion *ifsp;
-
-			INTOFF;
-			ifsp = ifsfirst.next->next;
-			free(ifsfirst.next);
-			ifsfirst.next = ifsp;
-			INTON;
-		}
-		if (ifsfirst.begoff > endoff)
-			ifslastp = NULL;
-		else {
-			ifslastp = &ifsfirst;
-			ifsfirst.endoff = endoff;
-		}
-		return;
-	}
-
-	ifslastp = &ifsfirst;
-	while (ifslastp->next && ifslastp->next->begoff < endoff)
-		ifslastp = ifslastp->next;
-	while (ifslastp->next != NULL) {
-		struct ifsregion *ifsp;
-
-		INTOFF;
-		ifsp = ifslastp->next->next;
-		free(ifslastp->next);
-		ifslastp->next = ifsp;
-		INTON;
-	}
-	if (ifslastp->endoff > endoff)
-		ifslastp->endoff = endoff;
-}
-
-
-#ifdef CONFIG_ASH_MATH_SUPPORT
-/*
- * Expand arithmetic expression.  Backup to start of expression,
- * evaluate, place result in (backed up) result, adjust string position.
- */
-static void expari(int flag)
-{
-	char *p, *start;
-	int errcode;
-	int result;
-	int begoff;
-	int quotes = flag & (EXP_FULL | EXP_CASE);
-	int quoted;
-
-	/*      ifsfree(); */
-
-	/*
-	 * This routine is slightly over-complicated for
-	 * efficiency.  First we make sure there is
-	 * enough space for the result, which may be bigger
-	 * than the expression if we add exponentation.  Next we
-	 * scan backwards looking for the start of arithmetic.  If the
-	 * next previous character is a CTLESC character, then we
-	 * have to rescan starting from the beginning since CTLESC
-	 * characters have to be processed left to right.
-	 */
-	CHECKSTRSPACE(10, expdest);
-	USTPUTC('\0', expdest);
-	start = stackblock();
-	p = expdest - 1;
-	while (*p != CTLARI && p >= start)
-		--p;
-	if (*p != CTLARI)
-		error("missing CTLARI (shouldn't happen)");
-	if (p > start && *(p - 1) == CTLESC)
-		for (p = start; *p != CTLARI; p++)
-			if (*p == CTLESC)
-				p++;
-
-	if (p[1] == '"')
-		quoted = 1;
-	else
-		quoted = 0;
-	begoff = p - start;
-	removerecordregions(begoff);
-	if (quotes)
-		rmescapes(p + 2);
-	result = arith(p + 2, &errcode);
-	if (errcode < 0) {
-		if (errcode == -2)
-			error("divide by zero");
-		else
-			error("syntax error: \"%s\"\n", p + 2);
-	}
-	snprintf(p, 12, "%d", result);
-	while (*p++);
-
-	if (quoted == 0)
-		recordregion(begoff, p - 1 - start, 0);
-	result = expdest - p + 1;
-	STADJUST(-result, expdest);
-}
-#endif
-
-/*
- * Expand stuff in backwards quotes.
- */
-
-static void expbackq(union node *cmd, int quoted, int flag)
-{
-	volatile struct backcmd in;
-	int i;
-	char buf[128];
-	char *p;
-	char *dest = expdest;
-	volatile struct ifsregion saveifs;
-	struct ifsregion *volatile savelastp;
-	struct nodelist *volatile saveargbackq;
-	char lastc;
-	int startloc = dest - stackblock();
-	int syntax = quoted ? DQSYNTAX : BASESYNTAX;
-	volatile int saveherefd;
-	int quotes = flag & (EXP_FULL | EXP_CASE);
-	struct jmploc jmploc;
-	struct jmploc *volatile savehandler;
-	int ex;
-
-#if __GNUC__
-	/* Avoid longjmp clobbering */
-	(void) &dest;
-	(void) &syntax;
-#endif
-
-	in.fd = -1;
-	in.buf = 0;
-	in.jp = 0;
-
-	INTOFF;
-	saveifs = ifsfirst;
-	savelastp = ifslastp;
-	saveargbackq = argbackq;
-	saveherefd = herefd;
-	herefd = -1;
-	if ((ex = setjmp(jmploc.loc))) {
-		goto err1;
-	}
-	savehandler = handler;
-	handler = &jmploc;
-	INTON;
-	p = grabstackstr(dest);
-	evalbackcmd(cmd, (struct backcmd *) &in);
-	ungrabstackstr(p, dest);
-  err1:
-	INTOFF;
-	ifsfirst = saveifs;
-	ifslastp = savelastp;
-	argbackq = saveargbackq;
-	herefd = saveherefd;
-	if (ex) {
-		goto err2;
-	}
-
-	p = in.buf;
-	lastc = '\0';
-	for (;;) {
-		if (--in.nleft < 0) {
-			if (in.fd < 0)
-				break;
-			i = safe_read(in.fd, buf, sizeof buf);
-			TRACE(("expbackq: read returns %d\n", i));
-			if (i <= 0)
-				break;
-			p = buf;
-			in.nleft = i - 1;
-		}
-		lastc = *p++;
-		if (lastc != '\0') {
-			if (quotes && SIT(lastc, syntax) == CCTL)
-				STPUTC(CTLESC, dest);
-			STPUTC(lastc, dest);
-		}
-	}
-
-	/* Eat all trailing newlines */
-	for (; dest > stackblock() && dest[-1] == '\n';)
-		STUNPUTC(dest);
-
-  err2:
-	if (in.fd >= 0)
-		close(in.fd);
-	free(in.buf);
-	if (in.jp)
-		exitstatus = waitforjob(in.jp);
-	handler = savehandler;
-	if (ex) {
-		longjmp(handler->loc, 1);
-	}
-	if (quoted == 0)
-		recordregion(startloc, dest - stackblock(), 0);
-	TRACE(("evalbackq: size=%d: \"%.*s\"\n",
-		   (dest - stackblock()) - startloc,
-		   (dest - stackblock()) - startloc, stackblock() + startloc));
-	expdest = dest;
-	INTON;
-}
-
-static int
-subevalvar(char *p, char *str, int strloc, int subtype, int startloc,
-		   int varflags, int quotes)
-{
-	char *startp;
-	char *loc = NULL;
-	char *q;
-	int c = 0;
-	int saveherefd = herefd;
-	struct nodelist *saveargbackq = argbackq;
-	int amount;
-
-	herefd = -1;
-	argstr(p, subtype != VSASSIGN && subtype != VSQUESTION ? EXP_CASE : 0);
-	STACKSTRNUL(expdest);
-	herefd = saveherefd;
-	argbackq = saveargbackq;
-	startp = stackblock() + startloc;
-	if (str == NULL)
-		str = stackblock() + strloc;
-
-	switch (subtype) {
-	case VSASSIGN:
-		setvar(str, startp, 0);
-		amount = startp - expdest;
-		STADJUST(amount, expdest);
-		varflags &= ~VSNUL;
-		if (c != 0)
-			*loc = c;
-		return 1;
-
-	case VSQUESTION:
-		if (*p != CTLENDVAR) {
-			out2fmt(snlfmt, startp);
-			error((char *) NULL);
-		}
-		error("%.*s: parameter %snot set", p - str - 1,
-			  str, (varflags & VSNUL) ? "null or " : nullstr);
-		/* NOTREACHED */
-
-	case VSTRIMLEFT:
-		for (loc = startp; loc < str; loc++) {
-			c = *loc;
-			*loc = '\0';
-			if (patmatch2(str, startp, quotes))
-				goto recordleft;
-			*loc = c;
-			if (quotes && *loc == CTLESC)
-				loc++;
-		}
-		return 0;
-
-	case VSTRIMLEFTMAX:
-		for (loc = str - 1; loc >= startp;) {
-			c = *loc;
-			*loc = '\0';
-			if (patmatch2(str, startp, quotes))
-				goto recordleft;
-			*loc = c;
-			loc--;
-			if (quotes && loc > startp && *(loc - 1) == CTLESC) {
-				for (q = startp; q < loc; q++)
-					if (*q == CTLESC)
-						q++;
-				if (q > loc)
-					loc--;
-			}
-		}
-		return 0;
-
-	case VSTRIMRIGHT:
-		for (loc = str - 1; loc >= startp;) {
-			if (patmatch2(str, loc, quotes))
-				goto recordright;
-			loc--;
-			if (quotes && loc > startp && *(loc - 1) == CTLESC) {
-				for (q = startp; q < loc; q++)
-					if (*q == CTLESC)
-						q++;
-				if (q > loc)
-					loc--;
-			}
-		}
-		return 0;
-
-	case VSTRIMRIGHTMAX:
-		for (loc = startp; loc < str - 1; loc++) {
-			if (patmatch2(str, loc, quotes))
-				goto recordright;
-			if (quotes && *loc == CTLESC)
-				loc++;
-		}
-		return 0;
-
-#ifdef DEBUG
-	default:
-		abort();
-#endif
-	}
-
-  recordleft:
-	*loc = c;
-	amount = ((str - 1) - (loc - startp)) - expdest;
-	STADJUST(amount, expdest);
-	while (loc != str - 1)
-		*startp++ = *loc++;
-	return 1;
-
-  recordright:
-	amount = loc - expdest;
-	STADJUST(amount, expdest);
-	STPUTC('\0', expdest);
-	STADJUST(-1, expdest);
-	return 1;
-}
-
 
 /*
  * Test whether a specialized variable is set.
  */
 
-static int varisset(char *name, int nulok)
+static int
+varisset(char *name, int nulok)
 {
 	if (*name == '!')
-		return backgndpid != -1;
+		return backgndpid != 0;
 	else if (*name == '@' || *name == '*') {
 		if (*shellparam.p == NULL)
 			return 0;
@@ -4782,24 +5325,45 @@
 	return 1;
 }
 
+
+
 /*
  * Put a string on the stack.
  */
 
-static void strtodest(const char *p, int syntax, int quotes)
-{
-	while (*p) {
-		if (quotes && SIT(*p, syntax) == CCTL)
-			STPUTC(CTLESC, expdest);
-		STPUTC(*p++, expdest);
+static void
+memtodest(const char *p, size_t len, int syntax, int quotes) {
+	char *q = expdest;
+
+	q = makestrspace(len * 2, q);
+
+	while (len--) {
+		int c = *p++;
+		if (!c)
+			continue;
+		if (quotes && (SIT(c, syntax) == CCTL || SIT(c, syntax) == CBACK))
+			USTPUTC(CTLESC, q);
+		USTPUTC(c, q);
 	}
+
+	expdest = q;
 }
 
+
+static void
+strtodest(const char *p, int syntax, int quotes)
+{
+	memtodest(p, strlen(p), syntax, quotes);
+}
+
+
+
 /*
  * Add the value of a specialized variable to the stack string.
  */
 
-static void varvalue(char *name, int quoted, int flags)
+static void
+varvalue(char *name, int quoted, int flags)
 {
 	int num;
 	char *p;
@@ -4817,20 +5381,20 @@
 		num = rootpid;
 		goto numvar;
 	case '?':
-		num = oexitstatus;
+		num = exitstatus;
 		goto numvar;
 	case '#':
 		num = shellparam.nparam;
 		goto numvar;
 	case '!':
 		num = backgndpid;
-	  numvar:
-		expdest = cvtnum(num, expdest);
+numvar:
+		cvtnum(num);
 		break;
 	case '-':
-		for (i = 0; i < NOPTS; i++) {
-			if (optent_val(i))
-				STPUTC(optent_letter(optlist[i]), expdest);
+		for (i = 0 ; i < NOPTS ; i++) {
+			if (optlist[i])
+				STPUTC(optletters(i), expdest);
 		}
 		break;
 	case '@':
@@ -4840,17 +5404,19 @@
 		}
 		/* fall through */
 	case '*':
-		sep = ifsset()? ifsval()[0] : ' ';
+		sep = ifsset() ? ifsval()[0] : ' ';
 		if (quotes) {
-			sepq = SIT(sep, syntax) == CCTL;
+			sepq = (SIT(sep, syntax) == CCTL) || (SIT(sep, syntax) == CBACK);
 		}
-	  param:
-		for (ap = shellparam.p; (p = *ap++) != NULL;) {
+param:
+		for (ap = shellparam.p ; (p = *ap++) != NULL ; ) {
 			strtodest(p, syntax, quotes);
 			if (*ap && sep) {
+				p = expdest;
 				if (sepq)
-					STPUTC(CTLESC, expdest);
-				STPUTC(sep, expdest);
+					STPUTC(CTLESC, p);
+				STPUTC(sep, p);
+				expdest = p;
 			}
 		}
 		break;
@@ -4867,12 +5433,14 @@
 }
 
 
+
 /*
  * Record the fact that we have to scan this region of the
  * string for IFS characters.
  */
 
-static void recordregion(int start, int end, int nulonly)
+static void
+recordregion(int start, int end, int nulonly)
 {
 	struct ifsregion *ifsp;
 
@@ -4880,7 +5448,7 @@
 		ifsp = &ifsfirst;
 	} else {
 		INTOFF;
-		ifsp = (struct ifsregion *) xmalloc(sizeof(struct ifsregion));
+		ifsp = (struct ifsregion *)ckmalloc(sizeof (struct ifsregion));
 		ifsp->next = NULL;
 		ifslastp->next = ifsp;
 		INTON;
@@ -4898,7 +5466,8 @@
  * strings to the argument list.  The regions of the string to be
  * searched for IFS characters have been stored by recordregion.
  */
-static void ifsbreakup(char *string, struct arglist *arglist)
+static void
+ifsbreakup(char *string, struct arglist *arglist)
 {
 	struct ifsregion *ifsp;
 	struct strlist *sp;
@@ -4911,10 +5480,10 @@
 
 
 	start = string;
-	ifsspc = 0;
-	nulonly = 0;
-	realifs = ifsset()? ifsval() : defifs;
 	if (ifslastp != NULL) {
+		ifsspc = 0;
+		nulonly = 0;
+		realifs = ifsset() ? ifsval() : defifs;
 		ifsp = &ifsfirst;
 		do {
 			p = string + ifsp->begoff;
@@ -4935,7 +5504,7 @@
 						continue;
 					}
 					*q = '\0';
-					sp = (struct strlist *) stalloc(sizeof *sp);
+					sp = (struct strlist *)stalloc(sizeof *sp);
 					sp->text = start;
 					*arglist->lastp = sp;
 					arglist->lastp = &sp->next;
@@ -4948,7 +5517,7 @@
 							q = p;
 							if (*p == CTLESC)
 								p++;
-							if (strchr(ifs, *p) == NULL) {
+							if (strchr(ifs, *p) == NULL ) {
 								p = q;
 								break;
 							} else if (strchr(defifs, *p) == NULL) {
@@ -4968,84 +5537,83 @@
 					p++;
 			}
 		} while ((ifsp = ifsp->next) != NULL);
-		if (!(*start || (!ifsspc && start > string && nulonly))) {
-			return;
-		}
+		if (nulonly)
+			goto add;
 	}
 
-	sp = (struct strlist *) stalloc(sizeof *sp);
+	if (!*start)
+		return;
+
+add:
+	sp = (struct strlist *)stalloc(sizeof *sp);
 	sp->text = start;
 	*arglist->lastp = sp;
 	arglist->lastp = &sp->next;
 }
 
-static void ifsfree(void)
+static void
+ifsfree(void)
 {
-	while (ifsfirst.next != NULL) {
-		struct ifsregion *ifsp;
+	struct ifsregion *p;
 
-		INTOFF;
-		ifsp = ifsfirst.next->next;
-		free(ifsfirst.next);
-		ifsfirst.next = ifsp;
-		INTON;
-	}
+	INTOFF;
+	p = ifsfirst.next;
+	do {
+		struct ifsregion *ifsp;
+		ifsp = p->next;
+		ckfree(p);
+		p = ifsp;
+	} while (p);
 	ifslastp = NULL;
 	ifsfirst.next = NULL;
+	INTON;
 }
 
-/*
- * Add a file name to the list.
- */
 
-static void addfname(const char *name)
-{
-	struct strlist *sp;
-	size_t len = strlen(name) + 1;
-
-	sp = (struct strlist *) stalloc(sizeof *sp);
-	sp->text = memcpy(stalloc(len), name, len);
-	*exparg.lastp = sp;
-	exparg.lastp = &sp->next;
-}
 
 /*
  * Expand shell metacharacters.  At this point, the only control characters
  * should be escapes.  The results are stored in the list exparg.
  */
 
-#if defined(__GLIBC__) && __GLIBC__ >= 2 && !defined(FNMATCH_BROKEN) && !defined(GLOB_BROKEN)
-static void expandmeta(struct strlist *str, int flag)
+static void
+expandmeta(str, flag)
+	struct strlist *str;
+	int flag;
 {
-	const char *p;
-	glob_t pglob;
-
 	/* TODO - EXP_REDIR */
 
 	while (str) {
+		const char *p;
+		glob_t pglob;
+		int i;
+
 		if (fflag)
 			goto nometa;
-		p = preglob(str->text);
 		INTOFF;
-		switch (glob(p, 0, 0, &pglob)) {
+		p = preglob(str->text, 0, RMESCAPE_ALLOC | RMESCAPE_HEAP);
+		i = glob(p, GLOB_NOMAGIC, 0, &pglob);
+		if (p != str->text)
+			ckfree(p);
+		switch (i) {
 		case 0:
-			if (pglob.gl_pathv[1] == 0 && !strcmp(p, pglob.gl_pathv[0]))
+			if (!(pglob.gl_flags & GLOB_MAGCHAR))
 				goto nometa2;
 			addglob(&pglob);
 			globfree(&pglob);
 			INTON;
 			break;
 		case GLOB_NOMATCH:
-		  nometa2:
+nometa2:
 			globfree(&pglob);
 			INTON;
-		  nometa:
+nometa:
 			*exparg.lastp = str;
 			rmescapes(str->text);
 			exparg.lastp = &str->next;
 			break;
-		default:		/* GLOB_NOSPACE */
-			error("Out of space");
+		default:        /* GLOB_NOSPACE */
+			error(bb_msg_memory_exhausted);
 		}
 		str = str->next;
 	}
@@ -5056,7 +5624,9 @@
  * Add the result of glob(3) to the list.
  */
 
-static void addglob(const glob_t * pglob)
+static void
+addglob(pglob)
+	const glob_t *pglob;
 {
 	char **p = pglob->gl_pathv;
 
@@ -5066,414 +5636,45 @@
 }
 
 
-#else							/* defined(__GLIBC__) && !defined(FNMATCH_BROKEN) && !defined(GLOB_BROKEN) */
-static char *expdir;
-
-
-static void expandmeta(struct strlist *str, int flag)
-{
-	char *p;
-	struct strlist **savelastp;
-	struct strlist *sp;
-	char c;
-
-	/* TODO - EXP_REDIR */
-
-	while (str) {
-		if (fflag)
-			goto nometa;
-		p = str->text;
-		for (;;) {		/* fast check for meta chars */
-			if ((c = *p++) == '\0')
-				goto nometa;
-			if (c == '*' || c == '?' || c == '[' || c == '!')
-				break;
-		}
-		savelastp = exparg.lastp;
-		INTOFF;
-		if (expdir == NULL) {
-			int i = strlen(str->text);
-
-			expdir = xmalloc(i < 2048 ? 2048 : i);	/* XXX */
-		}
-
-		expmeta(expdir, str->text);
-		free(expdir);
-		expdir = NULL;
-		INTON;
-		if (exparg.lastp == savelastp) {
-			/*
-			 * no matches
-			 */
-		  nometa:
-			*exparg.lastp = str;
-			rmescapes(str->text);
-			exparg.lastp = &str->next;
-		} else {
-			*exparg.lastp = NULL;
-			*savelastp = sp = expsort(*savelastp);
-			while (sp->next != NULL)
-				sp = sp->next;
-			exparg.lastp = &sp->next;
-		}
-		str = str->next;
-	}
-}
-
-
 /*
- * Do metacharacter (i.e. *, ?, [...]) expansion.
+ * Add a file name to the list.
  */
 
-static void expmeta(char *enddir, char *name)
+static void
+addfname(char *name)
 {
-	char *p;
-	const char *cp;
-	char *q;
-	char *start;
-	char *endname;
-	int metaflag;
-	struct stat statb;
-	DIR *dirp;
-	struct dirent *dp;
-	int atend;
-	int matchdot;
-
-	metaflag = 0;
-	start = name;
-	for (p = name;; p++) {
-		if (*p == '*' || *p == '?')
-			metaflag = 1;
-		else if (*p == '[') {
-			q = p + 1;
-			if (*q == '!')
-				q++;
-			for (;;) {
-				while (*q == CTLQUOTEMARK)
-					q++;
-				if (*q == CTLESC)
-					q++;
-				if (*q == '/' || *q == '\0')
-					break;
-				if (*++q == ']') {
-					metaflag = 1;
-					break;
-				}
-			}
-		} else if (*p == '!' && p[1] == '!' && (p == name || p[-1] == '/')) {
-			metaflag = 1;
-		} else if (*p == '\0')
-			break;
-		else if (*p == CTLQUOTEMARK)
-			continue;
-		else if (*p == CTLESC)
-			p++;
-		if (*p == '/') {
-			if (metaflag)
-				break;
-			start = p + 1;
-		}
-	}
-	if (metaflag == 0) {	/* we've reached the end of the file name */
-		if (enddir != expdir)
-			metaflag++;
-		for (p = name;; p++) {
-			if (*p == CTLQUOTEMARK)
-				continue;
-			if (*p == CTLESC)
-				p++;
-			*enddir++ = *p;
-			if (*p == '\0')
-				break;
-		}
-		if (metaflag == 0 || lstat(expdir, &statb) >= 0)
-			addfname(expdir);
-		return;
-	}
-	endname = p;
-	if (start != name) {
-		p = name;
-		while (p < start) {
-			while (*p == CTLQUOTEMARK)
-				p++;
-			if (*p == CTLESC)
-				p++;
-			*enddir++ = *p++;
-		}
-	}
-	if (enddir == expdir) {
-		cp = ".";
-	} else if (enddir == expdir + 1 && *expdir == '/') {
-		cp = "/";
-	} else {
-		cp = expdir;
-		enddir[-1] = '\0';
-	}
-	if ((dirp = opendir(cp)) == NULL)
-		return;
-	if (enddir != expdir)
-		enddir[-1] = '/';
-	if (*endname == 0) {
-		atend = 1;
-	} else {
-		atend = 0;
-		*endname++ = '\0';
-	}
-	matchdot = 0;
-	p = start;
-	while (*p == CTLQUOTEMARK)
-		p++;
-	if (*p == CTLESC)
-		p++;
-	if (*p == '.')
-		matchdot++;
-	while (!int_pending() && (dp = readdir(dirp)) != NULL) {
-		if (dp->d_name[0] == '.' && !matchdot)
-			continue;
-		if (patmatch(start, dp->d_name, 0)) {
-			if (atend) {
-				strcpy(enddir, dp->d_name);
-				addfname(expdir);
-			} else {
-				for (p = enddir, cp = dp->d_name; (*p++ = *cp++) != '\0';)
-					continue;
-				p[-1] = '/';
-				expmeta(p, endname);
-			}
-		}
-	}
-	closedir(dirp);
-	if (!atend)
-		endname[-1] = '/';
-}
-#endif							/* defined(__GLIBC__) && !defined(FNMATCH_BROKEN) && !defined(GLOB_BROKEN) */
-
-
-
-#if !(defined(__GLIBC__) && __GLIBC__ >= 2 && !defined(FNMATCH_BROKEN) && !defined(GLOB_BROKEN))
-/*
- * Sort the results of file name expansion.  It calculates the number of
- * strings to sort and then calls msort (short for merge sort) to do the
- * work.
- */
-
-static struct strlist *expsort(struct strlist *str)
-{
-	int len;
 	struct strlist *sp;
 
-	len = 0;
-	for (sp = str; sp; sp = sp->next)
-		len++;
-	return msort(str, len);
+	sp = (struct strlist *)stalloc(sizeof *sp);
+	sp->text = sstrdup(name);
+	*exparg.lastp = sp;
+	exparg.lastp = &sp->next;
 }
 
 
-static struct strlist *msort(struct strlist *list, int len)
-{
-	struct strlist *p, *q = NULL;
-	struct strlist **lpp;
-	int half;
-	int n;
-
-	if (len <= 1)
-		return list;
-	half = len >> 1;
-	p = list;
-	for (n = half; --n >= 0;) {
-		q = p;
-		p = p->next;
-	}
-	q->next = NULL;		/* terminate first half of list */
-	q = msort(list, half);	/* sort first half of list */
-	p = msort(p, len - half);	/* sort second half */
-	lpp = &list;
-	for (;;) {
-		if (strcmp(p->text, q->text) < 0) {
-			*lpp = p;
-			lpp = &p->next;
-			if ((p = *lpp) == NULL) {
-				*lpp = q;
-				break;
-			}
-		} else {
-			*lpp = q;
-			lpp = &q->next;
-			if ((q = *lpp) == NULL) {
-				*lpp = p;
-				break;
-			}
-		}
-	}
-	return list;
-}
-#endif
-
-
-
 /*
  * Returns true if the pattern matches the string.
  */
 
-#if defined(__GLIBC__) && __GLIBC__ >= 2 && !defined(FNMATCH_BROKEN)
-/* squoted: string might have quote chars */
-static int patmatch(char *pattern, char *string, int squoted)
+static inline int
+patmatch(char *pattern, const char *string)
 {
-	const char *p;
-	char *q;
-
-	p = preglob(pattern);
-	q = squoted ? _rmescapes(string, RMESCAPE_ALLOC) : string;
-
-	return !fnmatch(p, q, 0);
+	return pmatch(preglob(pattern, 0, 0), string);
 }
 
 
-static int patmatch2(char *pattern, char *string, int squoted)
-{
-	char *p;
-	int res;
-
-	sstrnleft--;
-	p = grabstackstr(expdest);
-	res = patmatch(pattern, string, squoted);
-	ungrabstackstr(p, expdest);
-	return res;
-}
-#else
-static int patmatch(char *pattern, char *string, int squoted)
-{
-	return pmatch(pattern, string, squoted);
-}
-
-
-static int pmatch(char *pattern, char *string, int squoted)
-{
-	char *p, *q;
-	char c;
-
-	p = pattern;
-	q = string;
-	for (;;) {
-		switch (c = *p++) {
-		case '\0':
-			goto breakloop;
-		case CTLESC:
-			if (squoted && *q == CTLESC)
-				q++;
-			if (*q++ != *p++)
-				return 0;
-			break;
-		case CTLQUOTEMARK:
-			continue;
-		case '?':
-			if (squoted && *q == CTLESC)
-				q++;
-			if (*q++ == '\0')
-				return 0;
-			break;
-		case '*':
-			c = *p;
-			while (c == CTLQUOTEMARK || c == '*')
-				c = *++p;
-			if (c != CTLESC && c != CTLQUOTEMARK &&
-				c != '?' && c != '*' && c != '[') {
-				while (*q != c) {
-					if (squoted && *q == CTLESC && q[1] == c)
-						break;
-					if (*q == '\0')
-						return 0;
-					if (squoted && *q == CTLESC)
-						q++;
-					q++;
-				}
-			}
-			do {
-				if (pmatch(p, q, squoted))
-					return 1;
-				if (squoted && *q == CTLESC)
-					q++;
-			} while (*q++ != '\0');
-			return 0;
-		case '[':{
-			char *endp;
-			int invert, found;
-			char chr;
-
-			endp = p;
-			if (*endp == '!')
-				endp++;
-			for (;;) {
-				while (*endp == CTLQUOTEMARK)
-					endp++;
-				if (*endp == '\0')
-					goto dft;	/* no matching ] */
-				if (*endp == CTLESC)
-					endp++;
-				if (*++endp == ']')
-					break;
-			}
-			invert = 0;
-			if (*p == '!') {
-				invert++;
-				p++;
-			}
-			found = 0;
-			chr = *q++;
-			if (squoted && chr == CTLESC)
-				chr = *q++;
-			if (chr == '\0')
-				return 0;
-			c = *p++;
-			do {
-				if (c == CTLQUOTEMARK)
-					continue;
-				if (c == CTLESC)
-					c = *p++;
-				if (*p == '-' && p[1] != ']') {
-					p++;
-					while (*p == CTLQUOTEMARK)
-						p++;
-					if (*p == CTLESC)
-						p++;
-					if (chr >= c && chr <= *p)
-						found = 1;
-					p++;
-				} else {
-					if (chr == c)
-						found = 1;
-				}
-			} while ((c = *p++) != ']');
-			if (found == invert)
-				return 0;
-			break;
-		}
-		dft: default:
-			if (squoted && *q == CTLESC)
-				q++;
-			if (*q++ != c)
-				return 0;
-			break;
-		}
-	}
-  breakloop:
-	if (*q != '\0')
-		return 0;
-	return 1;
-}
-#endif
-
-
-
 /*
  * Remove any CTLESC characters from a string.
  */
 
-#if defined(__GLIBC__) && __GLIBC__ >= 2 && !defined(FNMATCH_BROKEN)
-static char *_rmescapes(char *str, int flag)
+static char *
+_rmescapes(char *str, int flag)
 {
 	char *p, *q, *r;
 	static const char qchars[] = { CTLESC, CTLQUOTEMARK, 0 };
+	unsigned inquotes;
+	int notescaped;
+	int globbing;
 
 	p = strpbrk(str, qchars);
 	if (!p) {
@@ -5483,52 +5684,52 @@
 	r = str;
 	if (flag & RMESCAPE_ALLOC) {
 		size_t len = p - str;
+		size_t fulllen = len + strlen(p) + 1;
 
-		q = r = stalloc(strlen(p) + len + 1);
+		if (flag & RMESCAPE_GROW) {
+			r = makestrspace(fulllen, expdest);
+		} else if (flag & RMESCAPE_HEAP) {
+			r = ckmalloc(fulllen);
+		} else {
+			r = stalloc(fulllen);
+		}
+		q = r;
 		if (len > 0) {
-			memcpy(q, str, len);
-			q += len;
+			q = mempcpy(q, str, len);
 		}
 	}
+	inquotes = (flag & RMESCAPE_QUOTED) ^ RMESCAPE_QUOTED;
+	globbing = flag & RMESCAPE_GLOB;
+	notescaped = globbing;
 	while (*p) {
 		if (*p == CTLQUOTEMARK) {
+			inquotes = ~inquotes;
 			p++;
+			notescaped = globbing;
 			continue;
 		}
+		if (*p == '\\') {
+			/* naked back slash */
+			notescaped = 0;
+			goto copy;
+		}
 		if (*p == CTLESC) {
 			p++;
-			if (flag & RMESCAPE_GLOB && *p != '/') {
+			if (notescaped && inquotes && *p != '/') {
 				*q++ = '\\';
 			}
 		}
+		notescaped = globbing;
+copy:
 		*q++ = *p++;
 	}
 	*q = '\0';
+	if (flag & RMESCAPE_GROW) {
+		expdest = r;
+		STADJUST(q - r + 1, expdest);
+	}
 	return r;
 }
-#else
-static void rmescapes(char *str)
-{
-	char *p, *q;
-
-	p = str;
-	while (*p != CTLESC && *p != CTLQUOTEMARK) {
-		if (*p++ == '\0')
-			return;
-	}
-	q = p;
-	while (*p) {
-		if (*p == CTLQUOTEMARK) {
-			p++;
-			continue;
-		}
-		if (*p == CTLESC)
-			p++;
-		*q++ = *p++;
-	}
-	*q = '\0';
-}
-#endif
 
 
 
@@ -5536,20 +5737,19 @@
  * See if a pattern matches in a case statement.
  */
 
-static int casematch(union node *pattern, const char *val)
+int
+casematch(union node *pattern, char *val)
 {
 	struct stackmark smark;
 	int result;
-	char *p;
 
 	setstackmark(&smark);
 	argbackq = pattern->narg.backquote;
 	STARTSTACKSTR(expdest);
 	ifslastp = NULL;
 	argstr(pattern->narg.text, EXP_TILDE | EXP_CASE);
-	STPUTC('\0', expdest);
-	p = grabstackstr(expdest);
-	result = patmatch(p, (char *) val, 0);
+	STACKSTRNUL(expdest);
+	result = patmatch(stackblock(), val);
 	popstackmark(&smark);
 	return result;
 }
@@ -5558,113 +5758,35 @@
  * Our own itoa().
  */
 
-static char *cvtnum(int num, char *buf)
+static int
+cvtnum(long num)
 {
 	int len;
 
-	CHECKSTRSPACE(32, buf);
-	len = sprintf(buf, "%d", num);
-	STADJUST(len, buf);
-	return buf;
+	expdest = makestrspace(32, expdest);
+	len = fmtstr(expdest, 32, "%ld", num);
+	STADJUST(len, expdest);
+	return len;
 }
 
-/*
- * Editline and history functions (and glue).
- */
-static int histcmd(int argc, char **argv)
+static void
+varunset(const char *end, const char *var, const char *umsg, int varflags)
 {
-	error("not compiled with history support");
-	/* NOTREACHED */
+	const char *msg;
+	const char *tail;
+
+	tail = nullstr;
+	msg = "parameter not set";
+	if (umsg) {
+		if (*end == CTLENDVAR) {
+			if (varflags & VSNUL)
+				tail = " or null";
+		} else
+			msg = umsg;
+	}
+	error("%.*s: %s%s", end - var - 1, var, msg, tail);
 }
-
-
-struct redirtab {
-	struct redirtab *next;
-	short renamed[10];	/* Current ash support only 0-9 descriptors */
-	/* char on arm (and others) can't be negative */
-};
-
-static struct redirtab *redirlist;
-
-extern char **environ;
-
-
-
-/*
- * Initialization code.
- */
-
-static void init(void)
-{
-
-	/* from cd.c: */
-	{
-		curdir = nullstr;
-		setpwd(0, 0);
-	}
-
-	/* from input.c: */
-	{
-		basepf.nextc = basepf.buf = basebuf;
-	}
-
-	/* from var.c: */
-	{
-		char **envp;
-		char ppid[32];
-
-		initvar();
-		for (envp = environ; *envp; envp++) {
-			if (strchr(*envp, '=')) {
-				setvareq(*envp, VEXPORT | VTEXTFIXED);
-			}
-		}
-
-		snprintf(ppid, sizeof(ppid), "%d", (int) getppid());
-		setvar("PPID", ppid, 0);
-	}
-}
-
-
-
-/*
- * This routine is called when an error or an interrupt occurs in an
- * interactive shell and control is returned to the main command loop.
- */
-
-/* 1 == check for aliases, 2 == also check for assignments */
-static int checkalias;	/* also used in no alias mode for check assignments */
-
-static void reset(void)
-{
-
-	/* from eval.c: */
-	{
-		evalskip = 0;
-		loopnest = 0;
-		funcnest = 0;
-	}
-
-	/* from input.c: */
-	{
-		parselleft = parsenleft = 0;	/* clear input buffer */
-		popallfiles();
-	}
-
-	/* from parser.c: */
-	{
-		tokpushback = 0;
-		checkkwd = 0;
-		checkalias = 0;
-	}
-
-	/* from redir.c: */
-	{
-		while (redirlist)
-			popredir();
-	}
-
-}
+/*      $NetBSD: input.c,v 1.37 2002/11/24 22:35:40 christos Exp $      */
 
 
 
@@ -5672,49 +5794,17 @@
  * This file implements the input routines used by the parser.
  */
 
-#ifdef CONFIG_FEATURE_COMMAND_EDITING
-static const char *cmdedit_prompt;
-static inline void putprompt(const char *s)
-{
-	cmdedit_prompt = s;
-}
-#else
-static inline void putprompt(const char *s)
-{
-	out2str(s);
-}
-#endif
+#define EOF_NLEFT -99           /* value of parsenleft when EOF pushed back */
+#define IBUFSIZ (BUFSIZ + 1)
 
-#define EOF_NLEFT -99	/* value of parsenleft when EOF pushed back */
-
-
-
-/*
- * Same as pgetc(), but ignores PEOA.
- */
-
-#ifdef CONFIG_ASH_ALIAS
-static int pgetc2(void)
-{
-	int c;
-
-	do {
-		c = pgetc_macro();
-	} while (c == PEOA);
-	return c;
-}
-#else
-static inline int pgetc2(void)
-{
-	return pgetc_macro();
-}
-#endif
+static void pushfile(void);
 
 /*
  * Read a line from the script.
  */
 
-static inline char *pfgets(char *line, int len)
+static inline char *
+pfgets(char *line, int len)
 {
 	char *p = line;
 	int nleft = len;
@@ -5735,20 +5825,86 @@
 	return line;
 }
 
-static inline int preadfd(void)
+
+/*
+ * Read a character from the script, returning PEOF on end of file.
+ * Nul characters in the input are silently discarded.
+ */
+
+#define pgetc_as_macro()   (--parsenleft >= 0? *parsenextc++ : preadbuffer())
+
+#ifdef CONFIG_ASH_OPTIMIZE_FOR_SIZE
+#define pgetc_macro() pgetc()
+static int
+pgetc(void)
+{
+	return pgetc_as_macro();
+}
+#else
+#define pgetc_macro()   pgetc_as_macro()
+static int
+pgetc(void)
+{
+	return pgetc_macro();
+}
+#endif
+
+
+/*
+ * Same as pgetc(), but ignores PEOA.
+ */
+#ifdef CONFIG_ASH_ALIAS
+static int pgetc2(void)
+{
+	int c;
+
+	do {
+		c = pgetc_macro();
+	} while (c == PEOA);
+	return c;
+}
+#else
+static inline int pgetc2(void)
+{
+	return pgetc_macro();
+}
+#endif
+
+
+#ifdef CONFIG_FEATURE_COMMAND_EDITING
+static const char *cmdedit_prompt;
+static inline void putprompt(const char *s)
+{
+	cmdedit_prompt = s;
+}
+#else
+static inline void putprompt(const char *s)
+{
+	out2str(s);
+}
+#endif
+
+static inline int
+preadfd(void)
 {
 	int nr;
-	char *buf = parsefile->buf;
-
+	char *buf =  parsefile->buf;
 	parsenextc = buf;
 
-  retry:
+retry:
 #ifdef CONFIG_FEATURE_COMMAND_EDITING
-	{
-		if (!iflag || parsefile->fd)
-			nr = safe_read(parsefile->fd, buf, BUFSIZ - 1);
-		else {
-			nr = cmdedit_read_input((char *) cmdedit_prompt, buf);
+	if (!iflag || parsefile->fd)
+		nr = safe_read(parsefile->fd, buf, BUFSIZ - 1);
+	else {
+		nr = cmdedit_read_input((char *) cmdedit_prompt, buf);
+		if(nr == 0) {
+			/* Ctrl+C presend */
+			raise(SIGINT);
+			goto retry;
+		}
+		if(nr < 0) {
+			/* Ctrl+D presend */
+			nr = 0;
 		}
 	}
 #else
@@ -5758,9 +5914,8 @@
 	if (nr < 0) {
 		if (parsefile->fd == 0 && errno == EWOULDBLOCK) {
 			int flags = fcntl(0, F_GETFL, 0);
-
 			if (flags >= 0 && flags & O_NONBLOCK) {
-				flags &= ~O_NONBLOCK;
+				flags &=~ O_NONBLOCK;
 				if (fcntl(0, F_SETFL, flags) >= 0) {
 					out2str("sh: turning off NDELAY mode\n");
 					goto retry;
@@ -5771,38 +5926,6 @@
 	return nr;
 }
 
-static void popstring(void)
-{
-	struct strpush *sp = parsefile->strpush;
-
-	INTOFF;
-#ifdef CONFIG_ASH_ALIAS
-	if (sp->ap) {
-		if (parsenextc[-1] == ' ' || parsenextc[-1] == '\t') {
-			if (!checkalias) {
-				checkalias = 1;
-			}
-		}
-		if (sp->string != sp->ap->val) {
-			free(sp->string);
-		}
-
-		sp->ap->flag &= ~ALIASINUSE;
-		if (sp->ap->flag & ALIASDEAD) {
-			unalias(sp->ap->name);
-		}
-	}
-#endif
-	parsenextc = sp->prevstring;
-	parsenleft = sp->prevnleft;
-/*dprintf("*** calling popstring: restoring to '%s'\n", parsenextc);*/
-	parsefile->strpush = sp->prev;
-	if (sp != &(parsefile->basestrpush))
-		free(sp);
-	INTON;
-}
-
-
 /*
  * Refill the input buffer and return the next input character:
  *
@@ -5813,7 +5936,8 @@
  * 4) Process input up to the next newline, deleting nul characters.
  */
 
-static int preadbuffer(void)
+int
+preadbuffer(void)
 {
 	char *p, *q;
 	int more;
@@ -5834,7 +5958,7 @@
 		return PEOF;
 	flushall();
 
-  again:
+again:
 	if (parselleft <= 0) {
 		if ((parselleft = preadfd()) <= 0) {
 			parselleft = parsenleft = EOF_NLEFT;
@@ -5848,18 +5972,18 @@
 	for (more = 1; more;) {
 		switch (*p) {
 		case '\0':
-			p++;		/* Skip nul */
+			p++;    /* Skip nul */
 			goto check;
 
-
 		case '\n':
 			parsenleft = q - parsenextc;
-			more = 0;	/* Stop processing here */
+			more = 0; /* Stop processing here */
 			break;
+
 		}
 
 		*q++ = *p++;
-	  check:
+check:
 		if (--parselleft <= 0 && more) {
 			parsenleft = q - parsenextc - 1;
 			if (parsenleft < 0)
@@ -5873,6 +5997,7 @@
 
 	if (vflag) {
 		out2str(parsenextc);
+		flushout(stderr);
 	}
 
 	*q = savec;
@@ -5880,19 +6005,33 @@
 	return *parsenextc++;
 }
 
+/*
+ * Undo the last call to pgetc.  Only one character may be pushed back.
+ * PEOF may be pushed back.
+ */
+
+void
+pungetc(void)
+{
+	parsenleft++;
+	parsenextc--;
+}
 
 /*
  * Push a string back onto the input at this current parsefile level.
  * We handle aliases this way.
  */
-static void pushstring(char *s, int len, void *ap)
+void
+pushstring(char *s, void *ap)
 {
 	struct strpush *sp;
+	size_t len;
 
+	len = strlen(s);
 	INTOFF;
 /*dprintf("*** calling pushstring: %s, %d\n", s, len);*/
 	if (parsefile->strpush) {
-		sp = xmalloc(sizeof(struct strpush));
+		sp = ckmalloc(sizeof (struct strpush));
 		sp->prev = parsefile->strpush;
 		parsefile->strpush = sp;
 	} else
@@ -5900,9 +6039,9 @@
 	sp->prevstring = parsenextc;
 	sp->prevnleft = parsenleft;
 #ifdef CONFIG_ASH_ALIAS
-	sp->ap = (struct alias *) ap;
+	sp->ap = (struct alias *)ap;
 	if (ap) {
-		((struct alias *) ap)->flag |= ALIASINUSE;
+		((struct alias *)ap)->flag |= ALIASINUSE;
 		sp->string = s;
 	}
 #endif
@@ -5911,12 +6050,88 @@
 	INTON;
 }
 
+void
+popstring(void)
+{
+	struct strpush *sp = parsefile->strpush;
+
+	INTOFF;
+#ifdef CONFIG_ASH_ALIAS
+	if (sp->ap) {
+		if (parsenextc[-1] == ' ' || parsenextc[-1] == '\t') {
+			checkkwd |= CHKALIAS;
+		}
+		if (sp->string != sp->ap->val) {
+			ckfree(sp->string);
+		}
+		sp->ap->flag &= ~ALIASINUSE;
+		if (sp->ap->flag & ALIASDEAD) {
+			unalias(sp->ap->name);
+		}
+	}
+#endif
+	parsenextc = sp->prevstring;
+	parsenleft = sp->prevnleft;
+/*dprintf("*** calling popstring: restoring to '%s'\n", parsenextc);*/
+	parsefile->strpush = sp->prev;
+	if (sp != &(parsefile->basestrpush))
+		ckfree(sp);
+	INTON;
+}
+
+/*
+ * Set the input to take input from a file.  If push is set, push the
+ * old input onto the stack first.
+ */
+
+void
+setinputfile(const char *fname, int push)
+{
+	int fd;
+	int fd2;
+
+	INTOFF;
+	if ((fd = open(fname, O_RDONLY)) < 0)
+		error("Can't open %s", fname);
+	if (fd < 10) {
+		fd2 = copyfd(fd, 10);
+		close(fd);
+		if (fd2 < 0)
+			error("Out of file descriptors");
+		fd = fd2;
+	}
+	setinputfd(fd, push);
+	INTON;
+}
+
+
+/*
+ * Like setinputfile, but takes an open file descriptor.  Call this with
+ * interrupts off.
+ */
+
+static void
+setinputfd(int fd, int push)
+{
+	(void) fcntl(fd, F_SETFD, FD_CLOEXEC);
+	if (push) {
+		pushfile();
+		parsefile->buf = 0;
+	}
+	parsefile->fd = fd;
+	if (parsefile->buf == NULL)
+		parsefile->buf = ckmalloc(IBUFSIZ);
+	parselleft = parsenleft = 0;
+	plinno = 1;
+}
+
 
 /*
  * Like setinputfile, but takes input from a string.
  */
 
-static void setinputstring(char *string)
+static void
+setinputstring(char *string)
 {
 	INTOFF;
 	pushfile();
@@ -5934,7 +6149,8 @@
  * adds a new entry to the stack and popfile restores the previous level.
  */
 
-static void pushfile(void)
+static void
+pushfile(void)
 {
 	struct parsefile *pf;
 
@@ -5942,7 +6158,7 @@
 	parsefile->lleft = parselleft;
 	parsefile->nextc = parsenextc;
 	parsefile->linno = plinno;
-	pf = (struct parsefile *) xmalloc(sizeof(struct parsefile));
+	pf = (struct parsefile *)ckmalloc(sizeof (struct parsefile));
 	pf->prev = parsefile;
 	pf->fd = -1;
 	pf->strpush = NULL;
@@ -5950,75 +6166,221 @@
 	parsefile = pf;
 }
 
-#ifdef CONFIG_ASH_JOB_CONTROL
-static void restartjob(struct job *);
-#endif
-static void freejob(struct job *);
-static struct job *getjob(const char *);
-static int dowait(int, struct job *);
+
+static void
+popfile(void)
+{
+	struct parsefile *pf = parsefile;
+
+	INTOFF;
+	if (pf->fd >= 0)
+		close(pf->fd);
+	if (pf->buf)
+		ckfree(pf->buf);
+	while (pf->strpush)
+		popstring();
+	parsefile = pf->prev;
+	ckfree(pf);
+	parsenleft = parsefile->nleft;
+	parselleft = parsefile->lleft;
+	parsenextc = parsefile->nextc;
+	plinno = parsefile->linno;
+	INTON;
+}
 
 
 /*
- * We keep track of whether or not fd0 has been redirected.  This is for
- * background commands, where we want to redirect fd0 to /dev/null only
- * if it hasn't already been redirected.
-*/
-static int fd0_redirected = 0;
+ * Return to top level.
+ */
 
-/* Return true if fd 0 has already been redirected at least once.  */
-static inline int fd0_redirected_p(void)
+static void
+popallfiles(void)
 {
-	return fd0_redirected != 0;
+	while (parsefile != &basepf)
+		popfile();
 }
 
-static void dupredirect(const union node *, int, int fd1dup);
 
-#ifdef CONFIG_ASH_JOB_CONTROL
+
+/*
+ * Close the file(s) that the shell is reading commands from.  Called
+ * after a fork is done.
+ */
+
+static void
+closescript(void)
+{
+	popallfiles();
+	if (parsefile->fd > 0) {
+		close(parsefile->fd);
+		parsefile->fd = 0;
+	}
+}
+/*      $NetBSD: jobs.c,v 1.56 2002/11/25 12:13:03 agc Exp $    */
+
+
+/* mode flags for set_curjob */
+#define CUR_DELETE 2
+#define CUR_RUNNING 1
+#define CUR_STOPPED 0
+
+/* mode flags for dowait */
+#define DOWAIT_NORMAL 0
+#define DOWAIT_BLOCK 1
+
+/* array of jobs */
+static struct job *jobtab;
+/* size of array */
+static unsigned njobs;
+#if JOBS
+/* pgrp of shell on invocation */
+static int initialpgrp;
+static int ttyfd = -1;
+#endif
+/* current job */
+static struct job *curjob;
+/* number of presumed living untracked jobs */
+static int jobless;
+
+static void set_curjob(struct job *, unsigned);
+#if JOBS
+static int restartjob(struct job *, int);
+static void xtcsetpgrp(int, pid_t);
+static char *commandtext(union node *);
+static void cmdlist(union node *, int);
+static void cmdtxt(union node *);
+static void cmdputs(const char *);
+static void showpipe(struct job *, FILE *);
+#endif
+static int sprint_status(char *, int, int);
+static void freejob(struct job *);
+static struct job *getjob(const char *, int);
+static struct job *growjobtab(void);
+static void forkchild(struct job *, union node *, int);
+static void forkparent(struct job *, union node *, int, pid_t);
+static int dowait(int, struct job *);
+static int getstatus(struct job *);
+
+static void
+set_curjob(struct job *jp, unsigned mode)
+{
+	struct job *jp1;
+	struct job **jpp, **curp;
+
+	/* first remove from list */
+	jpp = curp = &curjob;
+	do {
+		jp1 = *jpp;
+		if (jp1 == jp)
+			break;
+		jpp = &jp1->prev_job;
+	} while (1);
+	*jpp = jp1->prev_job;
+
+	/* Then re-insert in correct position */
+	jpp = curp;
+	switch (mode) {
+	default:
+#ifdef DEBUG
+		abort();
+#endif
+	case CUR_DELETE:
+		/* job being deleted */
+		break;
+	case CUR_RUNNING:
+		/* newly created job or backgrounded job,
+		   put after all stopped jobs. */
+		do {
+			jp1 = *jpp;
+#ifdef JOBS
+			if (!jp1 || jp1->state != JOBSTOPPED)
+#endif
+				break;
+			jpp = &jp1->prev_job;
+		} while (1);
+		/* FALLTHROUGH */
+#ifdef JOBS
+	case CUR_STOPPED:
+#endif
+		/* newly stopped job - becomes curjob */
+		jp->prev_job = *jpp;
+		*jpp = jp;
+		break;
+	}
+}
+
+#if JOBS
 /*
  * Turn job control on and off.
  *
  * Note:  This code assumes that the third arg to ioctl is a character
  * pointer, which is true on Berkeley systems but not System V.  Since
  * System V doesn't have job control yet, this isn't a problem now.
+ *
+ * Called with interrupts off.
  */
 
-
-
-static void setjobctl(int enable)
+void
+setjobctl(int on)
 {
-	if (enable == jobctl || rootshell == 0)
+	int fd;
+	int pgrp;
+
+	if (on == jobctl || rootshell == 0)
 		return;
-	if (enable) {
-		do {			/* while we are in the background */
-			initialpgrp = tcgetpgrp(2);
-			if (initialpgrp < 0) {
-				out2str("sh: can't access tty; job control turned off\n");
-				mflag = 0;
-				return;
+	if (on) {
+		int ofd;
+		ofd = fd = open(_PATH_TTY, O_RDWR);
+		if (fd < 0) {
+			fd += 3;
+			while (!isatty(fd) && --fd >= 0)
+				;
+		}
+		fd = fcntl(fd, F_DUPFD, 10);
+		close(ofd);
+		if (fd < 0)
+			goto out;
+		fcntl(fd, F_SETFD, FD_CLOEXEC);
+		do { /* while we are in the background */
+			if ((pgrp = tcgetpgrp(fd)) < 0) {
+out:
+				sh_warnx("can't access tty; job control turned off");
+				mflag = on = 0;
+				goto close;
 			}
-			if (initialpgrp == getpgrp())
+			if (pgrp == getpgrp())
 				break;
 			killpg(0, SIGTTIN);
 		} while (1);
+		initialpgrp = pgrp;
+
 		setsignal(SIGTSTP);
 		setsignal(SIGTTOU);
 		setsignal(SIGTTIN);
-		setpgid(0, rootpid);
-		tcsetpgrp(2, rootpid);
-	} else {			/* turning job control off */
-		setpgid(0, initialpgrp);
-		tcsetpgrp(2, initialpgrp);
+		pgrp = rootpid;
+		setpgid(0, pgrp);
+		xtcsetpgrp(fd, pgrp);
+	} else {
+		/* turning job control off */
+		fd = ttyfd;
+		pgrp = initialpgrp;
+		xtcsetpgrp(fd, pgrp);
+		setpgid(0, pgrp);
 		setsignal(SIGTSTP);
 		setsignal(SIGTTOU);
 		setsignal(SIGTTIN);
+close:
+		close(fd);
+		fd = -1;
 	}
-	jobctl = enable;
+	ttyfd = fd;
+	jobctl = on;
 }
-#endif
 
-
-#ifdef CONFIG_ASH_JOB_CONTROL
-static int killcmd(int argc, char **argv)
+static int
+killcmd(argc, argv)
+	int argc;
+	char **argv;
 {
 	int signo = -1;
 	int list = 0;
@@ -6027,135 +6389,283 @@
 	struct job *jp;
 
 	if (argc <= 1) {
-	  usage:
-		error
-			("Usage: kill [-s sigspec | -signum | -sigspec] [pid | job]... or\n"
-			 "kill -l [exitstatus]");
+usage:
+		error(
+"Usage: kill [-s sigspec | -signum | -sigspec] [pid | job]... or\n"
+"kill -l [exitstatus]"
+		);
 	}
 
-	if (*argv[1] == '-') {
-		signo = decode_signal(argv[1] + 1, 1);
+	if (**++argv == '-') {
+		signo = decode_signal(*argv + 1, 1);
 		if (signo < 0) {
 			int c;
 
 			while ((c = nextopt("ls:")) != '\0')
 				switch (c) {
+				default:
+#ifdef DEBUG
+					abort();
+#endif
 				case 'l':
 					list = 1;
 					break;
 				case 's':
 					signo = decode_signal(optionarg, 1);
 					if (signo < 0) {
-						error("invalid signal number or name: %s", optionarg);
+						error(
+							"invalid signal number or name: %s",
+							optionarg
+						);
 					}
 					break;
-#ifdef DEBUG
-				default:
-					error("nextopt returned character code 0%o", c);
-#endif
 				}
+			argv = argptr;
 		} else
-			argptr++;
+			argv++;
 	}
 
 	if (!list && signo < 0)
 		signo = SIGTERM;
 
-	if ((signo < 0 || !*argptr) ^ list) {
+	if ((signo < 0 || !*argv) ^ list) {
 		goto usage;
 	}
 
 	if (list) {
 		const char *name;
 
-		if (!*argptr) {
-			out1str("0\n");
+		if (!*argv) {
 			for (i = 1; i < NSIG; i++) {
 				name = u_signal_names(0, &i, 1);
 				if (name)
-					puts(name);
+					out1fmt(snlfmt, name);
 			}
 			return 0;
 		}
 		name = u_signal_names(*argptr, &signo, -1);
 		if (name)
-			puts(name);
+			out1fmt(snlfmt, name);
 		else
 			error("invalid signal number or exit status: %s", *argptr);
 		return 0;
 	}
 
+	i = 0;
 	do {
-		if (**argptr == '%') {
-			jp = getjob(*argptr);
-			if (jp->jobctl == 0)
-				error("job %s not created under job control", *argptr);
+		if (**argv == '%') {
+			jp = getjob(*argv, 0);
 			pid = -jp->ps[0].pid;
 		} else
-			pid = atoi(*argptr);
-		if (kill(pid, signo) != 0)
-			error("%s: %m", *argptr);
-	} while (*++argptr);
-
-	return 0;
-}
-
-static int fgcmd(int argc, char **argv)
-{
-	struct job *jp;
-	int pgrp;
-	int status;
-
-	jp = getjob(argv[1]);
-	if (jp->jobctl == 0)
-		error("job not created under job control");
-	pgrp = jp->ps[0].pid;
-	ioctl(2, TIOCSPGRP, (char *) &pgrp);
-	restartjob(jp);
-	status = waitforjob(jp);
-	return status;
-}
-
-
-static int bgcmd(int argc, char **argv)
-{
-	struct job *jp;
-
-	do {
-		jp = getjob(*++argv);
-		if (jp->jobctl == 0)
-			error("job not created under job control");
-		restartjob(jp);
-	} while (--argc > 1);
-	return 0;
-}
-
-
-static void restartjob(struct job *jp)
-{
-	struct procstat *ps;
-	int i;
-
-	if (jp->state == JOBDONE)
-		return;
-	INTOFF;
-	killpg(jp->ps[0].pid, SIGCONT);
-	for (ps = jp->ps, i = jp->nprocs; --i >= 0; ps++) {
-		if (WIFSTOPPED(ps->status)) {
-			ps->status = -1;
-			jp->state = 0;
+			pid = number(*argv);
+		if (kill(pid, signo) != 0) {
+			sh_warnx("%m\n");
+			i = 1;
 		}
-	}
-	INTON;
+	} while (*++argv);
+
+	return i;
+}
+#endif /* JOBS */
+
+#if defined(JOBS) || defined(DEBUG)
+static int
+jobno(const struct job *jp)
+{
+	return jp - jobtab + 1;
 }
 #endif
 
-static void showjobs(int change);
-
-
-static int jobscmd(int argc, char **argv)
+#ifdef JOBS
+static int
+fgcmd(int argc, char **argv)
 {
-	showjobs(0);
+	struct job *jp;
+	FILE *out;
+	int mode;
+	int retval;
+
+	mode = (**argv == 'f') ? FORK_FG : FORK_BG;
+	nextopt(nullstr);
+	argv = argptr;
+	out = stdout;
+	do {
+		jp = getjob(*argv, 1);
+		if (mode == FORK_BG) {
+			set_curjob(jp, CUR_RUNNING);
+			fprintf(out, "[%d] ", jobno(jp));
+		}
+		outstr(jp->ps->cmd, out);
+		showpipe(jp, out);
+		retval = restartjob(jp, mode);
+	} while (*argv && *++argv);
+	return retval;
+}
+
+static int bgcmd(int, char **) __attribute__((__alias__("fgcmd")));
+
+
+static int
+restartjob(struct job *jp, int mode)
+{
+	struct procstat *ps;
+	int i;
+	int status;
+	pid_t pgid;
+
+	INTOFF;
+	if (jp->state == JOBDONE)
+		goto out;
+	jp->state = JOBRUNNING;
+	pgid = jp->ps->pid;
+	if (mode == FORK_FG)
+		xtcsetpgrp(ttyfd, pgid);
+	killpg(pgid, SIGCONT);
+	ps = jp->ps;
+	i = jp->nprocs;
+	do {
+		if (WIFSTOPPED(ps->status)) {
+			ps->status = -1;
+		}
+	} while (ps++, --i);
+out:
+	status = (mode == FORK_FG) ? waitforjob(jp) : 0;
+	INTON;
+	return status;
+}
+#endif
+
+static int
+sprint_status(char *s, int status, int sigonly)
+{
+	int col;
+	int st;
+
+	col = 0;
+	st = WEXITSTATUS(status);
+	if (!WIFEXITED(status)) {
+		st = WSTOPSIG(status);
+#if JOBS
+		if (!WIFSTOPPED(status))
+			st = WTERMSIG(status);
+#endif
+		if (sigonly) {
+			if (st == SIGINT || st == SIGPIPE)
+				goto out;
+			if (WIFSTOPPED(status))
+				goto out;
+		}
+		st &= 0x7f;
+		col = fmtstr(s, 32, u_signal_names(NULL, &st, 0));
+		if (WCOREDUMP(status)) {
+			col += fmtstr(s + col, 16, " (core dumped)");
+		}
+	} else if (!sigonly) {
+		if (st)
+			col = fmtstr(s, 16, "Done(%d)", st);
+		else
+			col = fmtstr(s, 16, "Done");
+	}
+
+out:
+	return col;
+}
+
+#if JOBS
+static void
+showjob(FILE *out, struct job *jp, int mode)
+{
+	struct procstat *ps;
+	struct procstat *psend;
+	int col;
+	int indent;
+	char s[80];
+
+	ps = jp->ps;
+
+	if (mode & SHOW_PGID) {
+		/* just output process (group) id of pipeline */
+		fprintf(out, "%d\n", ps->pid);
+		return;
+	}
+
+	col = fmtstr(s, 16, "[%d]   ", jobno(jp));
+	indent = col;
+
+	if (jp == curjob)
+		s[col - 2] = '+';
+	else if (curjob && jp == curjob->prev_job)
+		s[col - 2] = '-';
+
+	if (mode & SHOW_PID)
+		col += fmtstr(s + col, 16, "%d ", ps->pid);
+
+	psend = ps + jp->nprocs;
+
+	if (jp->state == JOBRUNNING) {
+		scopy("Running", s + col);
+		col += strlen("Running");
+	} else {
+		int status = psend[-1].status;
+#if JOBS
+		if (jp->state == JOBSTOPPED)
+			status = jp->stopstatus;
+#endif
+		col += sprint_status(s + col, status, 0);
+	}
+
+	goto start;
+
+	do {
+		/* for each process */
+		col = fmtstr(s, 48, " |\n%*c%d ", indent, ' ', ps->pid) - 3;
+
+start:
+		fprintf(
+			out, "%s%*c%s",
+			s, 33 - col >= 0 ? 33 - col : 0, ' ', ps->cmd
+		);
+		if (!(mode & SHOW_PID)) {
+			showpipe(jp, out);
+			break;
+		}
+		if (++ps == psend) {
+			outcslow('\n', out);
+			break;
+		}
+	} while (1);
+
+	jp->changed = 0;
+
+	if (jp->state == JOBDONE) {
+		TRACE(("showjob: freeing job %d\n", jobno(jp)));
+		freejob(jp);
+	}
+}
+
+
+static int
+jobscmd(int argc, char **argv)
+{
+	int mode, m;
+	FILE *out;
+
+	mode = 0;
+	while ((m = nextopt("lp")))
+		if (m == 'l')
+			mode = SHOW_PID;
+		else
+			mode = SHOW_PGID;
+
+	out = stdout;
+	argv = argptr;
+	if (*argv)
+		do
+			showjob(out, getjob(*argv,0), mode);
+		while (*++argv);
+	else
+		showjobs(out, mode);
+
 	return 0;
 }
 
@@ -6163,146 +6673,107 @@
 /*
  * Print a list of jobs.  If "change" is nonzero, only print jobs whose
  * statuses have changed since the last call to showjobs.
- *
- * If the shell is interrupted in the process of creating a job, the
- * result may be a job structure containing zero processes.  Such structures
- * will be freed here.
  */
 
-static void showjobs(int change)
+static void
+showjobs(FILE *out, int mode)
 {
-	int jobno;
-	int procno;
-	int i;
 	struct job *jp;
-	struct procstat *ps;
-	int col;
-	char s[64];
 
-	TRACE(("showjobs(%d) called\n", change));
-	while (dowait(0, (struct job *) NULL) > 0);
-	for (jobno = 1, jp = jobtab; jobno <= njobs; jobno++, jp++) {
-		if (!jp->used)
-			continue;
-		if (jp->nprocs == 0) {
-			freejob(jp);
-			continue;
-		}
-		if (change && !jp->changed)
-			continue;
-		procno = jp->nprocs;
-		for (ps = jp->ps;; ps++) {	/* for each process */
-			if (ps == jp->ps)
-				snprintf(s, 64, "[%d] %ld ", jobno, (long) ps->pid);
-			else
-				snprintf(s, 64, "    %ld ", (long) ps->pid);
-			out1str(s);
-			col = strlen(s);
-			s[0] = '\0';
-			if (ps->status == -1) {
-				/* don't print anything */
-			} else if (WIFEXITED(ps->status)) {
-				snprintf(s, 64, "Exit %d", WEXITSTATUS(ps->status));
-			} else {
-#ifdef CONFIG_ASH_JOB_CONTROL
-				if (WIFSTOPPED(ps->status))
-					i = WSTOPSIG(ps->status);
-				else	/* WIFSIGNALED(ps->status) */
-#endif
-					i = WTERMSIG(ps->status);
-				if ((i & 0x7F) < NSIG && sys_siglist[i & 0x7F])
-					strcpy(s, sys_siglist[i & 0x7F]);
-				else
-					snprintf(s, 64, "Signal %d", i & 0x7F);
-				if (WCOREDUMP(ps->status))
-					strcat(s, " (core dumped)");
-			}
-			out1str(s);
-			col += strlen(s);
-			printf("%*c%s\n", 30 - col >= 0 ? 30 - col : 0, ' ', ps->cmd);
-			if (--procno <= 0)
-				break;
-		}
-		jp->changed = 0;
-		if (jp->state == JOBDONE) {
-			freejob(jp);
-		}
+	TRACE(("showjobs(%x) called\n", mode));
+
+	/* If not even one one job changed, there is nothing to do */
+	while (dowait(DOWAIT_NORMAL, NULL) > 0)
+		continue;
+
+	for (jp = curjob; jp; jp = jp->prev_job) {
+		if (!(mode & SHOW_CHANGED) || jp->changed)
+			showjob(out, jp, mode);
 	}
 }
-
+#endif /* JOBS */
 
 /*
  * Mark a job structure as unused.
  */
 
-static void freejob(struct job *jp)
+static void
+freejob(struct job *jp)
 {
-	const struct procstat *ps;
+	struct procstat *ps;
 	int i;
 
 	INTOFF;
-	for (i = jp->nprocs, ps = jp->ps; --i >= 0; ps++) {
+	for (i = jp->nprocs, ps = jp->ps ; --i >= 0 ; ps++) {
 		if (ps->cmd != nullstr)
-			free(ps->cmd);
+			ckfree(ps->cmd);
 	}
 	if (jp->ps != &jp->ps0)
-		free(jp->ps);
+		ckfree(jp->ps);
 	jp->used = 0;
-#ifdef CONFIG_ASH_JOB_CONTROL
-	if (curjob == jp - jobtab + 1)
-		curjob = 0;
-#endif
+	set_curjob(jp, CUR_DELETE);
 	INTON;
 }
 
 
-
-static int waitcmd(int argc, char **argv)
+static int
+waitcmd(int argc, char **argv)
 {
 	struct job *job;
-	int status, retval;
+	int retval;
 	struct job *jp;
 
-	if (--argc > 0) {
-	  start:
-		job = getjob(*++argv);
-	} else {
-		job = NULL;
-	}
-	for (;;) {			/* loop until process terminated or stopped */
-		if (job != NULL) {
-			if (job->state) {
-				status = job->ps[job->nprocs - 1].status;
-				if (!iflag)
-					freejob(job);
-				if (--argc) {
-					goto start;
+	EXSIGON();
+
+	nextopt(nullstr);
+	retval = 0;
+
+	argv = argptr;
+	if (!*argv) {
+		/* wait for all jobs */
+		for (;;) {
+			jp = curjob;
+			while (1) {
+				if (!jp) {
+					/* no running procs */
+					goto out;
 				}
-				if (WIFEXITED(status))
-					retval = WEXITSTATUS(status);
-#ifdef CONFIG_ASH_JOB_CONTROL
-				else if (WIFSTOPPED(status))
-					retval = WSTOPSIG(status) + 128;
-#endif
-				else {
-					/* XXX: limits number of signals */
-					retval = WTERMSIG(status) + 128;
-				}
-				return retval;
-			}
-		} else {
-			for (jp = jobtab;; jp++) {
-				if (jp >= jobtab + njobs) {	/* no running procs */
-					return 0;
-				}
-				if (jp->used && jp->state == 0)
+				if (jp->state == JOBRUNNING)
 					break;
+				jp->waited = 1;
+				jp = jp->prev_job;
 			}
-		}
-		if (dowait(2, 0) < 0 && errno == EINTR) {
-			return 129;
+			dowait(DOWAIT_BLOCK, 0);
 		}
 	}
+
+	retval = 127;
+	do {
+		if (**argv != '%') {
+			pid_t pid = number(*argv);
+			job = curjob;
+			goto start;
+			do {
+				if (job->ps[job->nprocs - 1].pid == pid)
+					break;
+				job = job->prev_job;
+start:
+				if (!job)
+					goto repeat;
+			} while (1);
+		} else
+			job = getjob(*argv, 0);
+		/* loop until process terminated or stopped */
+		while (job->state == JOBRUNNING)
+			dowait(DOWAIT_BLOCK, 0);
+		job->waited = 1;
+		retval = getstatus(job);
+repeat:
+		;
+	} while (*++argv);
+
+out:
+	return retval;
 }
 
 
@@ -6311,112 +6782,177 @@
  * Convert a job name to a job structure.
  */
 
-static struct job *getjob(const char *name)
+static struct job *
+getjob(const char *name, int getctl)
 {
-	int jobno;
 	struct job *jp;
-	int pid;
-	int i;
+	struct job *found;
+	const char *err_msg = "No such job: %s";
+	unsigned num;
+	int c;
+	const char *p;
+	char *(*match)(const char *, const char *);
 
-	if (name == NULL) {
-#ifdef CONFIG_ASH_JOB_CONTROL
-	  currentjob:
-		if ((jobno = curjob) == 0 || jobtab[jobno - 1].used == 0)
-			error("No current job");
-		return &jobtab[jobno - 1];
-#else
-		error("No current job");
-#endif
-	} else if (name[0] == '%') {
-		if (is_digit(name[1])) {
-			jobno = number(name + 1);
-			if (jobno > 0 && jobno <= njobs && jobtab[jobno - 1].used != 0)
-				return &jobtab[jobno - 1];
-#ifdef CONFIG_ASH_JOB_CONTROL
-		} else if (name[1] == '%' && name[2] == '\0') {
-			goto currentjob;
-#endif
-		} else {
-			struct job *found = NULL;
+	jp = curjob;
+	p = name;
+	if (!p)
+		goto currentjob;
 
-			for (jp = jobtab, i = njobs; --i >= 0; jp++) {
-				if (jp->used && jp->nprocs > 0
-					&& prefix(name + 1, jp->ps[0].cmd)) {
-					if (found)
-						error("%s: ambiguous", name);
-					found = jp;
-				}
-			}
-			if (found)
-				return found;
-		}
-	} else if (is_number(name, &pid)) {
-		for (jp = jobtab, i = njobs; --i >= 0; jp++) {
-			if (jp->used && jp->nprocs > 0
-				&& jp->ps[jp->nprocs - 1].pid == pid)
-				return jp;
+	if (*p != '%')
+		goto err;
+
+	c = *++p;
+	if (!c)
+		goto currentjob;
+
+	if (!p[1]) {
+		if (c == '+' || c == '%') {
+currentjob:
+			err_msg = "No current job";
+			goto check;
+		} else if (c == '-') {
+			if (jp)
+				jp = jp->prev_job;
+			err_msg = "No previous job";
+check:
+			if (!jp)
+				goto err;
+			goto gotit;
 		}
 	}
-	error("No such job: %s", name);
-	/* NOTREACHED */
+
+	if (is_number(p)) {
+		num = atoi(p);
+		if (num < njobs) {
+			jp = jobtab + num - 1;
+			if (jp->used)
+				goto gotit;
+			goto err;
+		}
+	}
+
+	match = prefix;
+	if (*p == '?') {
+		match = strstr;
+		p++;
+	}
+
+	found = 0;
+	while (1) {
+		if (!jp)
+			goto err;
+		if (match(jp->ps[0].cmd, p)) {
+			if (found)
+				goto err;
+			found = jp;
+			err_msg = "%s: ambiguous";
+		}
+		jp = jp->prev_job;
+	}
+
+gotit:
+#if JOBS
+	err_msg = "job %s not created under job control";
+	if (getctl && jp->jobctl == 0)
+		goto err;
+#endif
+	return jp;
+err:
+	error(err_msg, name);
 }
 
 
 
 /*
- * Return a new job structure,
+ * Return a new job structure.
+ * Called with interrupts off.
  */
 
-static struct job *makejob(const union node *node, int nprocs)
+static struct job *
+makejob(union node *node, int nprocs)
 {
 	int i;
 	struct job *jp;
 
-	for (i = njobs, jp = jobtab;; jp++) {
+	for (i = njobs, jp = jobtab ; ; jp++) {
 		if (--i < 0) {
-			INTOFF;
-			if (njobs == 0) {
-				jobtab = xmalloc(4 * sizeof jobtab[0]);
-			} else {
-				jp = xmalloc((njobs + 4) * sizeof jobtab[0]);
-				memcpy(jp, jobtab, njobs * sizeof jp[0]);
-				/* Relocate `ps' pointers */
-				for (i = 0; i < njobs; i++)
-					if (jp[i].ps == &jobtab[i].ps0)
-						jp[i].ps = &jp[i].ps0;
-				free(jobtab);
-				jobtab = jp;
-			}
-			jp = jobtab + njobs;
-			for (i = 4; --i >= 0; jobtab[njobs++].used = 0);
-			INTON;
+			jp = growjobtab();
 			break;
 		}
 		if (jp->used == 0)
 			break;
-	}
-	INTOFF;
-	jp->state = 0;
-	jp->used = 1;
-	jp->changed = 0;
-	jp->nprocs = 0;
-#ifdef CONFIG_ASH_JOB_CONTROL
-	jp->jobctl = jobctl;
+		if (jp->state != JOBDONE || !jp->waited)
+			continue;
+#if JOBS
+		if (jobctl)
+			continue;
 #endif
-	if (nprocs > 1) {
-		jp->ps = xmalloc(nprocs * sizeof(struct procstat));
-	} else {
-		jp->ps = &jp->ps0;
+		freejob(jp);
+		break;
 	}
-	INTON;
-	TRACE(("makejob(0x%lx, %d) returns %%%d\n", (long) node, nprocs,
-		   jp - jobtab + 1));
+	memset(jp, 0, sizeof(*jp));
+#if JOBS
+	if (jobctl)
+		jp->jobctl = 1;
+#endif
+	jp->prev_job = curjob;
+	curjob = jp;
+	jp->used = 1;
+	jp->ps = &jp->ps0;
+	if (nprocs > 1) {
+		jp->ps = ckmalloc(nprocs * sizeof (struct procstat));
+	}
+	TRACE(("makejob(0x%lx, %d) returns %%%d\n", (long)node, nprocs,
+	    jobno(jp)));
+	return jp;
+}
+
+static struct job *
+growjobtab(void)
+{
+	size_t len;
+	ptrdiff_t offset;
+	struct job *jp, *jq;
+
+	len = njobs * sizeof(*jp);
+	jq = jobtab;
+	jp = ckrealloc(jq, len + 4 * sizeof(*jp));
+
+	offset = (char *)jp - (char *)jq;
+	if (offset) {
+		/* Relocate pointers */
+		size_t l = len;
+
+		jq = (struct job *)((char *)jq + l);
+		while (l) {
+			l -= sizeof(*jp);
+			jq--;
+#define joff(p) ((struct job *)((char *)(p) + l))
+#define jmove(p) (p) = (void *)((char *)(p) + offset)
+			if (likely(joff(jp)->ps == &jq->ps0))
+				jmove(joff(jp)->ps);
+			if (joff(jp)->prev_job)
+				jmove(joff(jp)->prev_job);
+		}
+		if (curjob)
+			jmove(curjob);
+#undef joff
+#undef jmove
+	}
+
+	njobs += 4;
+	jobtab = jp;
+	jp = (struct job *)((char *)jp + len);
+	jq = jp + 3;
+	do {
+		jq->used = 0;
+	} while (--jq >= jp);
 	return jp;
 }
 
 
 /*
- * Fork of a subshell.  If we are doing job control, give the subshell its
+ * Fork off a subshell.  If we are doing job control, give the subshell its
  * own process group.  Jp is a job structure that the job is to be added to.
  * N is the command that will be evaluated by the child.  Both jp and n may
  * be NULL.  The mode parameter can be one of the following:
@@ -6428,103 +6964,114 @@
  * When job control is turned off, background processes have their standard
  * input redirected to /dev/null (except for the second and later processes
  * in a pipeline).
+ *
+ * Called with interrupts off.
  */
 
-
-
-static int forkshell(struct job *jp, const union node *n, int mode)
+static inline void
+forkchild(struct job *jp, union node *n, int mode)
 {
-	int pid;
+	int wasroot;
 
-#ifdef CONFIG_ASH_JOB_CONTROL
-	int pgrp;
+	TRACE(("Child shell %d\n", getpid()));
+	wasroot = rootshell;
+	rootshell = 0;
+
+	closescript();
+	clear_traps();
+#if JOBS
+	/* do job control only in root shell */
+	jobctl = 0;
+	if (mode != FORK_NOJOB && jp->jobctl && wasroot) {
+		pid_t pgrp;
+
+		if (jp->nprocs == 0)
+			pgrp = getpid();
+		else
+			pgrp = jp->ps[0].pid;
+		/* This can fail because we are doing it in the parent also */
+		(void)setpgid(0, pgrp);
+		if (mode == FORK_FG)
+			xtcsetpgrp(ttyfd, pgrp);
+		setsignal(SIGTSTP);
+		setsignal(SIGTTOU);
+	} else
 #endif
-	const char *devnull = _PATH_DEVNULL;
-	const char *nullerr = "Can't open %s";
-
-	TRACE(("forkshell(%%%d, 0x%lx, %d) called\n", jp - jobtab, (long) n,
-		   mode));
-	INTOFF;
-	pid = fork();
-	if (pid == -1) {
-		TRACE(("Fork failed, errno=%d\n", errno));
-		INTON;
-		error("Cannot fork");
-	}
-	if (pid == 0) {
-		struct job *p;
-		int wasroot;
-		int i;
-
-		TRACE(("Child shell %d\n", getpid()));
-		wasroot = rootshell;
-		rootshell = 0;
-		closescript();
-		INTON;
-		clear_traps();
-#ifdef CONFIG_ASH_JOB_CONTROL
-		jobctl = 0;		/* do job control only in root shell */
-		if (wasroot && mode != FORK_NOJOB && mflag) {
-			if (jp == NULL || jp->nprocs == 0)
-				pgrp = getpid();
-			else
-				pgrp = jp->ps[0].pid;
-			setpgid(0, pgrp);
-			if (mode == FORK_FG) {
-				/*** this causes superfluous TIOCSPGRPS ***/
-				if (tcsetpgrp(2, pgrp) < 0)
-					error("tcsetpgrp failed, errno=%d", errno);
-			}
-			setsignal(SIGTSTP);
-			setsignal(SIGTTOU);
-		} else if (mode == FORK_BG) {
-#else
-		if (mode == FORK_BG) {
-#endif
-			ignoresig(SIGINT);
-			ignoresig(SIGQUIT);
-			if ((jp == NULL || jp->nprocs == 0) && !fd0_redirected_p()) {
-				close(0);
-				if (open(devnull, O_RDONLY) != 0)
-					error(nullerr, devnull);
-			}
+	if (mode == FORK_BG) {
+		ignoresig(SIGINT);
+		ignoresig(SIGQUIT);
+		if (jp->nprocs == 0) {
+			close(0);
+			if (open(_PATH_DEVNULL, O_RDONLY) != 0)
+				error("Can't open %s", _PATH_DEVNULL);
 		}
-		for (i = njobs, p = jobtab; --i >= 0; p++)
-			if (p->used)
-				freejob(p);
-		if (wasroot && iflag) {
-			setsignal(SIGINT);
-			setsignal(SIGQUIT);
-			setsignal(SIGTERM);
-		}
-		return pid;
 	}
-#ifdef CONFIG_ASH_JOB_CONTROL
-	if (rootshell && mode != FORK_NOJOB && mflag) {
-		if (jp == NULL || jp->nprocs == 0)
+	if (wasroot && iflag) {
+		setsignal(SIGINT);
+		setsignal(SIGQUIT);
+		setsignal(SIGTERM);
+	}
+	for (jp = curjob; jp; jp = jp->prev_job)
+		freejob(jp);
+	jobless = 0;
+}
+
+static inline void
+forkparent(struct job *jp, union node *n, int mode, pid_t pid)
+{
+	TRACE(("In parent shell:  child = %d\n", pid));
+	if (!jp) {
+		while (jobless && dowait(DOWAIT_NORMAL, 0) > 0);
+		jobless++;
+		return;
+	}
+#if JOBS
+	if (mode != FORK_NOJOB && jp->jobctl) {
+		int pgrp;
+
+		if (jp->nprocs == 0)
 			pgrp = pid;
 		else
 			pgrp = jp->ps[0].pid;
-		setpgid(pid, pgrp);
+		/* This can fail because we are doing it in the child also */
+		(void)setpgid(pid, pgrp);
 	}
 #endif
-	if (mode == FORK_BG)
-		backgndpid = pid;	/* set $! */
+	if (mode == FORK_BG) {
+		backgndpid = pid;               /* set $! */
+		set_curjob(jp, CUR_RUNNING);
+	}
 	if (jp) {
 		struct procstat *ps = &jp->ps[jp->nprocs++];
-
 		ps->pid = pid;
 		ps->status = -1;
 		ps->cmd = nullstr;
-		if (iflag && rootshell && n)
+#if JOBS
+		if (jobctl && n)
 			ps->cmd = commandtext(n);
+#endif
 	}
-	INTON;
-	TRACE(("In parent shell:  child = %d\n", pid));
-	return pid;
 }
 
+static int
+forkshell(struct job *jp, union node *n, int mode)
+{
+	int pid;
 
+	TRACE(("forkshell(%%%d, %p, %d) called\n", jobno(jp), n, mode));
+	pid = fork();
+	if (pid < 0) {
+		TRACE(("Fork failed, errno=%d", errno));
+		if (jp)
+			freejob(jp);
+		error("Cannot fork");
+	}
+	if (pid == 0)
+		forkchild(jp, n, mode);
+	else
+		forkparent(jp, n, mode, pid);
+	return pid;
+}
 
 /*
  * Wait for job to finish.
@@ -6543,65 +7090,41 @@
  * exit on interrupt; unless these processes terminate themselves by
  * sending a signal to themselves (instead of calling exit) they will
  * confuse this approach.
+ *
+ * Called with interrupts off.
  */
 
-static int waitforjob(struct job *jp)
+int
+waitforjob(struct job *jp)
 {
-#ifdef CONFIG_ASH_JOB_CONTROL
-	int mypgrp = getpgrp();
-#endif
-	int status;
 	int st;
 
-	INTOFF;
-	TRACE(("waitforjob(%%%d) called\n", jp - jobtab + 1));
-	while (jp->state == 0) {
-		dowait(1, jp);
+	TRACE(("waitforjob(%%%d) called\n", jobno(jp)));
+	while (jp->state == JOBRUNNING) {
+		dowait(DOWAIT_BLOCK, jp);
 	}
-#ifdef CONFIG_ASH_JOB_CONTROL
+	st = getstatus(jp);
+#if JOBS
 	if (jp->jobctl) {
-		if (tcsetpgrp(2, mypgrp) < 0)
-			error("tcsetpgrp failed, errno=%d\n", errno);
-	}
-	if (jp->state == JOBSTOPPED)
-		curjob = jp - jobtab + 1;
-#endif
-	status = jp->ps[jp->nprocs - 1].status;
-	/* convert to 8 bits */
-	if (WIFEXITED(status))
-		st = WEXITSTATUS(status);
-#ifdef CONFIG_ASH_JOB_CONTROL
-	else if (WIFSTOPPED(status))
-		st = WSTOPSIG(status) + 128;
-#endif
-	else
-		st = WTERMSIG(status) + 128;
-#ifdef CONFIG_ASH_JOB_CONTROL
-	if (jp->jobctl) {
+		xtcsetpgrp(ttyfd, rootpid);
 		/*
 		 * This is truly gross.
 		 * If we're doing job control, then we did a TIOCSPGRP which
 		 * caused us (the shell) to no longer be in the controlling
 		 * session -- so we wouldn't have seen any ^C/SIGINT.  So, we
 		 * intuit from the subprocess exit status whether a SIGINT
-		 * occured, and if so interrupt ourselves.  Yuck.  - mycroft
+		 * occurred, and if so interrupt ourselves.  Yuck.  - mycroft
 		 */
-		if (WIFSIGNALED(status) && WTERMSIG(status) == SIGINT)
+		if (jp->sigint)
 			raise(SIGINT);
 	}
 	if (jp->state == JOBDONE)
 #endif
 		freejob(jp);
-	INTON;
 	return st;
 }
 
 
-
-/*
- * Wait for a process to terminate.
- */
-
 /*
  * Do a wait system call.  If job control is compiled in, we accept
  * stopped processes.  If block is zero, we return a value of zero
@@ -6624,635 +7147,554 @@
  * then checking to see whether it was called.  If there are any
  * children to be waited for, it will be.
  *
+ * If neither SYSV nor BSD is defined, we don't implement nonblocking
+ * waits at all.  In this case, the user will not be informed when
+ * a background process until the next time she runs a real program
+ * (as opposed to running a builtin command or just typing return),
+ * and the jobs command may give out of date information.
  */
 
-static inline int waitproc(int block, int *status)
+static inline int
+waitproc(int block, int *status)
 {
-	int flags;
+	int flags = 0;
 
-	flags = 0;
-#ifdef CONFIG_ASH_JOB_CONTROL
+#if JOBS
 	if (jobctl)
 		flags |= WUNTRACED;
 #endif
 	if (block == 0)
 		flags |= WNOHANG;
-	return wait3(status, flags, (struct rusage *) NULL);
+	return wait3(status, flags, (struct rusage *)NULL);
 }
 
-static int dowait(int block, struct job *job)
+/*
+ * Wait for a process to terminate.
+ */
+
+static int
+dowait(int block, struct job *job)
 {
 	int pid;
 	int status;
-	struct procstat *sp;
 	struct job *jp;
 	struct job *thisjob;
-	int done;
-	int stopped;
-	int core;
-	int sig;
+	int state;
 
 	TRACE(("dowait(%d) called\n", block));
-	do {
-		pid = waitproc(block, &status);
-		TRACE(("wait returns %d, status=%d\n", pid, status));
-	} while (!(block & 2) && pid == -1 && errno == EINTR);
+	pid = waitproc(block, &status);
+	TRACE(("wait returns pid %d, status=%d\n", pid, status));
 	if (pid <= 0)
 		return pid;
 	INTOFF;
 	thisjob = NULL;
-	for (jp = jobtab; jp < jobtab + njobs; jp++) {
-		if (jp->used) {
-			done = 1;
-			stopped = 1;
-			for (sp = jp->ps; sp < jp->ps + jp->nprocs; sp++) {
-				if (sp->pid == -1)
-					continue;
-				if (sp->pid == pid) {
-					TRACE(("Changing status of proc %d from 0x%x to 0x%x\n",
-						   pid, sp->status, status));
-					sp->status = status;
-					thisjob = jp;
-				}
-				if (sp->status == -1)
-					stopped = 0;
-				else if (WIFSTOPPED(sp->status))
-					done = 0;
+	for (jp = curjob; jp; jp = jp->prev_job) {
+		struct procstat *sp;
+		struct procstat *spend;
+		if (jp->state == JOBDONE)
+			continue;
+		state = JOBDONE;
+		spend = jp->ps + jp->nprocs;
+		sp = jp->ps;
+		do {
+			if (sp->pid == pid) {
+				TRACE(("Job %d: changing status of proc %d from 0x%x to 0x%x\n", jobno(jp), pid, sp->status, status));
+				sp->status = status;
+				thisjob = jp;
 			}
-			if (stopped) {	/* stopped or done */
-				int state = done ? JOBDONE : JOBSTOPPED;
-
-				if (jp->state != state) {
-					TRACE(("Job %d: changing state from %d to %d\n",
-						   jp - jobtab + 1, jp->state, state));
-					jp->state = state;
-#ifdef CONFIG_ASH_JOB_CONTROL
-					if (done && curjob == jp - jobtab + 1)
-						curjob = 0;	/* no current job */
+			if (sp->status == -1)
+				state = JOBRUNNING;
+#ifdef JOBS
+			if (state == JOBRUNNING)
+				continue;
+			if (WIFSTOPPED(sp->status)) {
+				jp->stopstatus = sp->status;
+				state = JOBSTOPPED;
+			}
 #endif
-				}
+		} while (++sp < spend);
+		if (thisjob)
+			goto gotjob;
+	}
+#ifdef JOBS
+	if (!WIFSTOPPED(status))
+#endif
+
+		jobless--;
+	goto out;
+
+gotjob:
+	if (state != JOBRUNNING) {
+		thisjob->changed = 1;
+
+		if (thisjob->state != state) {
+			TRACE(("Job %d: changing state from %d to %d\n", jobno(thisjob), thisjob->state, state));
+			thisjob->state = state;
+#ifdef JOBS
+			if (state == JOBSTOPPED) {
+				set_curjob(thisjob, CUR_STOPPED);
 			}
+#endif
 		}
 	}
-	INTON;
-	if (!rootshell || !iflag || (job && thisjob == job)) {
-		core = WCOREDUMP(status);
-#ifdef CONFIG_ASH_JOB_CONTROL
-		if (WIFSTOPPED(status))
-			sig = WSTOPSIG(status);
-		else
-#endif
-		if (WIFEXITED(status))
-			sig = 0;
-		else
-			sig = WTERMSIG(status);
 
-		if (sig != 0 && sig != SIGINT && sig != SIGPIPE) {
-			if (thisjob != job)
-				out2fmt("%d: ", pid);
-#ifdef CONFIG_ASH_JOB_CONTROL
-			if (sig == SIGTSTP && rootshell && iflag)
-				out2fmt("%%%ld ", (long) (job - jobtab + 1));
-#endif
-			if (sig < NSIG && sys_siglist[sig])
-				out2str(sys_siglist[sig]);
-			else
-				out2fmt("Signal %d", sig);
-			if (core)
-				out2str(" - core dumped");
-			out2c('\n');
-		} else {
-			TRACE(("Not printing status: status=%d, sig=%d\n", status, sig));
+out:
+	INTON;
+
+	if (thisjob && thisjob == job) {
+		char s[48 + 1];
+		int len;
+
+		len = sprint_status(s, status, 1);
+		if (len) {
+			s[len] = '\n';
+			s[len + 1] = 0;
+			out2str(s);
 		}
-	} else {
-		TRACE(("Not printing status, rootshell=%d, job=0x%x\n", rootshell,
-			   job));
-		if (thisjob)
-			thisjob->changed = 1;
 	}
 	return pid;
 }
 
 
 
-
 /*
  * return 1 if there are stopped jobs, otherwise 0
  */
-static int stoppedjobs(void)
+int
+stoppedjobs(void)
 {
-	int jobno;
 	struct job *jp;
+	int retval;
 
+	retval = 0;
 	if (job_warning)
-		return (0);
-	for (jobno = 1, jp = jobtab; jobno <= njobs; jobno++, jp++) {
-		if (jp->used == 0)
-			continue;
-		if (jp->state == JOBSTOPPED) {
-			out2str("You have stopped jobs.\n");
-			job_warning = 2;
-			return (1);
-		}
+		goto out;
+	jp = curjob;
+	if (jp && jp->state == JOBSTOPPED) {
+		out2str("You have stopped jobs.\n");
+		job_warning = 2;
+		retval++;
 	}
 
-	return (0);
+out:
+	return retval;
 }
 
 /*
  * Return a string identifying a command (to be printed by the
- * jobs command.
+ * jobs command).
  */
 
+#if JOBS
 static char *cmdnextc;
-static int cmdnleft;
 
-#define MAXCMDTEXT      200
-
-static void cmdputs(const char *s)
+static char *
+commandtext(union node *n)
 {
-	const char *p;
-	char *q;
-	char c;
-	int subtype = 0;
+	char *name;
 
-	if (cmdnleft <= 0)
-		return;
-	p = s;
-	q = cmdnextc;
-	while ((c = *p++) != '\0') {
-		if (c == CTLESC)
-			*q++ = *p++;
-		else if (c == CTLVAR) {
-			*q++ = '$';
-			if (--cmdnleft > 0)
-				*q++ = '{';
-			subtype = *p++;
-		} else if (c == '=' && subtype != 0) {
-			*q++ = "}-+?="[(subtype & VSTYPE) - VSNORMAL];
-			subtype = 0;
-		} else if (c == CTLENDVAR) {
-			*q++ = '}';
-		} else if (c == CTLBACKQ || c == CTLBACKQ + CTLQUOTE)
-			cmdnleft++;	/* ignore it */
-		else
-			*q++ = c;
-		if (--cmdnleft <= 0) {
-			*q++ = '.';
-			*q++ = '.';
-			*q++ = '.';
-			break;
-		}
-	}
-	cmdnextc = q;
+	STARTSTACKSTR(cmdnextc);
+	cmdtxt(n);
+	name = stackblock();
+	TRACE(("commandtext: name %p, end %p\n\t\"%s\"\n",
+		name, cmdnextc, cmdnextc));
+	return savestr(name);
 }
 
-#define CMDTXT_TABLE
-#ifdef CMDTXT_TABLE
-/*
- * To collect a lot of redundant code in cmdtxt() case statements, we
- * implement a mini language here.  Each type of node struct has an
- * associated instruction sequence that operates on its members via
- * their offsets.  The instruction are pack in unsigned chars with
- * format   IIDDDDDE   where the bits are
- *   I : part of the instruction opcode, which are
- *       00 : member is a pointer to another node -- process it recursively
- *       40 : member is a pointer to a char string -- output it
- *       80 : output the string whose index is stored in the data field
- *       CC : flag signaling that this case needs external processing
- *   D : data - either the (shifted) index of a fixed string to output or
- *              the actual offset of the member to operate on in the struct
- *              (since we assume bit 0 is set, the offset is not shifted)
- *   E : flag signaling end of instruction sequence
- *
- * WARNING: In order to handle larger offsets for 64bit archs, this code
- *          assumes that no offset can be an odd number and stores the
- *          end-of-instructions flag in bit 0.
- */
-
-#define CMDTXT_NOMORE      0x01	/* NOTE: no offset should be odd */
-#define CMDTXT_CHARPTR     0x40
-#define CMDTXT_STRING      0x80
-#define CMDTXT_SPECIAL     0xC0
-#define CMDTXT_OFFSETMASK  0x3E
-
-static const char *const cmdtxt_strings[] = {
-	/* 0     1    2    3       4       5      6          7     */
-	"; ", "(", ")", " && ", " || ", "if ", "; then ", "...",
-	/* 8         9        10       11        12      13       */
-	"while ", "; do ", "; done", "until ", "for ", " in ...",
-	/* 14       15     16        17     */
-	"case ", "???", "() ...", "<<..."
-};
-
-static const char *const redir_strings[] = {
-	">", "<", "<>", ">>", ">|", ">&", "<&"
-};
-
-static const unsigned char cmdtxt_ops[] = {
-#define CMDTXT_NSEMI    0
-	offsetof(union node, nbinary.ch1),
-	0 | CMDTXT_STRING,
-	offsetof(union node, nbinary.ch2) | CMDTXT_NOMORE,
-#define CMDTXT_NCMD     (CMDTXT_NSEMI + 3)
-#define CMDTXT_NPIPE    (CMDTXT_NCMD)
-#define  CMDTXT_NCASE    (CMDTXT_NCMD)
-#define  CMDTXT_NTO      (CMDTXT_NCMD)
-#define  CMDTXT_NFROM    (CMDTXT_NCMD)
-#define  CMDTXT_NFROMTO  (CMDTXT_NCMD)
-#define  CMDTXT_NAPPEND  (CMDTXT_NCMD)
-#define  CMDTXT_NTOOV    (CMDTXT_NCMD)
-#define  CMDTXT_NTOFD    (CMDTXT_NCMD)
-#define  CMDTXT_NFROMFD  (CMDTXT_NCMD)
-	CMDTXT_SPECIAL,
-#define CMDTXT_NREDIR   (CMDTXT_NPIPE + 1)
-#define CMDTXT_NBACKGND (CMDTXT_NREDIR)
-	offsetof(union node, nredir.n) | CMDTXT_NOMORE,
-#define CMDTXT_NSUBSHELL (CMDTXT_NBACKGND + 1)
-	(1 * 2) | CMDTXT_STRING,
-	offsetof(union node, nredir.n),
-	(2 * 2) | CMDTXT_STRING | CMDTXT_NOMORE,
-#define CMDTXT_NAND     (CMDTXT_NSUBSHELL + 3)
-	offsetof(union node, nbinary.ch1),
-	(3 * 2) | CMDTXT_STRING,
-	offsetof(union node, nbinary.ch2) | CMDTXT_NOMORE,
-#define CMDTXT_NOR      (CMDTXT_NAND + 3)
-	offsetof(union node, nbinary.ch1),
-	(4 * 2) | CMDTXT_STRING,
-	offsetof(union node, nbinary.ch2) | CMDTXT_NOMORE,
-#define CMDTXT_NIF      (CMDTXT_NOR + 3)
-	(5 * 2) | CMDTXT_STRING,
-	offsetof(union node, nif.test),
-	(6 * 2) | CMDTXT_STRING,
-	offsetof(union node, nif.ifpart),
-	(7 * 2) | CMDTXT_STRING | CMDTXT_NOMORE,
-#define CMDTXT_NWHILE   (CMDTXT_NIF + 5)
-	(8 * 2) | CMDTXT_STRING,
-	offsetof(union node, nbinary.ch1),
-	(9 * 2) | CMDTXT_STRING,
-	offsetof(union node, nbinary.ch2),
-	(10 * 2) | CMDTXT_STRING | CMDTXT_NOMORE,
-#define CMDTXT_NUNTIL   (CMDTXT_NWHILE + 5)
-	(11 * 2) | CMDTXT_STRING,
-	offsetof(union node, nbinary.ch1),
-	(9 * 2) | CMDTXT_STRING,
-	offsetof(union node, nbinary.ch2),
-	(10 * 2) | CMDTXT_STRING | CMDTXT_NOMORE,
-#define CMDTXT_NFOR     (CMDTXT_NUNTIL + 5)
-	(12 * 2) | CMDTXT_STRING,
-	offsetof(union node, nfor.var) | CMDTXT_CHARPTR,
-	(13 * 2) | CMDTXT_STRING | CMDTXT_NOMORE,
-#define CMDTXT_NCLIST   (CMDTXT_NFOR + 3)	/* TODO: IS THIS CORRECT??? */
-#define  CMDTXT_NNOT     (CMDTXT_NCLIST)	/* TODO: IS THIS CORRECT??? */
-	(15 * 2) | CMDTXT_STRING | CMDTXT_NOMORE,
-#define CMDTXT_NDEFUN   (CMDTXT_NCLIST + 1)
-	offsetof(union node, narg.text) | CMDTXT_CHARPTR,
-	(16 * 2) | CMDTXT_STRING | CMDTXT_NOMORE,
-#define CMDTXT_NARG     (CMDTXT_NDEFUN + 2)
-	offsetof(union node, narg.text) | CMDTXT_CHARPTR | CMDTXT_NOMORE,
-#define CMDTXT_NHERE    (CMDTXT_NARG + 1)
-#define CMDTXT_NXHERE   (CMDTXT_NHERE)
-	(17 * 2) | CMDTXT_STRING | CMDTXT_NOMORE,
-};
-
-#if CMDTXT_NXHERE != 36
-#error CMDTXT_NXHERE
-#endif
-
-static const unsigned char cmdtxt_ops_index[26] = {
-	CMDTXT_NSEMI,
-	CMDTXT_NCMD,
-	CMDTXT_NPIPE,
-	CMDTXT_NREDIR,
-	CMDTXT_NBACKGND,
-	CMDTXT_NSUBSHELL,
-	CMDTXT_NAND,
-	CMDTXT_NOR,
-	CMDTXT_NIF,
-	CMDTXT_NWHILE,
-	CMDTXT_NUNTIL,
-	CMDTXT_NFOR,
-	CMDTXT_NCASE,
-	CMDTXT_NCLIST,
-	CMDTXT_NDEFUN,
-	CMDTXT_NARG,
-	CMDTXT_NTO,
-	CMDTXT_NFROM,
-	CMDTXT_NFROMTO,
-	CMDTXT_NAPPEND,
-	CMDTXT_NTOOV,
-	CMDTXT_NTOFD,
-	CMDTXT_NFROMFD,
-	CMDTXT_NHERE,
-	CMDTXT_NXHERE,
-	CMDTXT_NNOT,
-};
-
-static void cmdtxt(const union node *n)
-{
-	const char *p;
-
-	if (n == NULL)
-		return;
-
-	p = cmdtxt_ops + (int) cmdtxt_ops_index[n->type];
-	if ((*p & CMDTXT_SPECIAL) != CMDTXT_SPECIAL) {	/* normal case */
-		do {
-			if (*p & CMDTXT_STRING) {	/* output fixed string */
-				cmdputs(cmdtxt_strings
-						[((int) (*p & CMDTXT_OFFSETMASK) >> 1)]);
-			} else {
-				const char *pf = ((const char *) n)
-					+ ((int) (*p & CMDTXT_OFFSETMASK));
-
-				if (*p & CMDTXT_CHARPTR) {	/* output dynamic string */
-					cmdputs(*((const char **) pf));
-				} else {	/* output field */
-					cmdtxt(*((const union node **) pf));
-				}
-			}
-		} while (!(*p++ & CMDTXT_NOMORE));
-	} else if (n->type == NCMD) {
-		union node *np;
-
-		for (np = n->ncmd.args; np; np = np->narg.next) {
-			cmdtxt(np);
-			if (np->narg.next)
-				cmdputs(spcstr);
-		}
-		for (np = n->ncmd.redirect; np; np = np->nfile.next) {
-			cmdputs(spcstr);
-			cmdtxt(np);
-		}
-	} else if (n->type == NPIPE) {
-		struct nodelist *lp;
-
-		for (lp = n->npipe.cmdlist; lp; lp = lp->next) {
-			cmdtxt(lp->n);
-			if (lp->next)
-				cmdputs(" | ");
-		}
-	} else if (n->type == NCASE) {
-		cmdputs(cmdtxt_strings[14]);
-		cmdputs(n->ncase.expr->narg.text);
-		cmdputs(cmdtxt_strings[13]);
-	} else {
-#if (NTO != 16) || (NFROM != 17) || (NFROMTO != 18) || (NAPPEND != 19) || (NTOOV != 20) || (NTOFD != 21) || (NFROMFD != 22)
-#error Assumption violated regarding range and ordering of NTO ... NFROMFD!
-#endif
-		char s[2];
-
-#ifdef DEBUG
-		assert((n->type >= NTO) && (n->type <= NFROMFD));
-#endif
-
-		p = redir_strings[n->type - NTO];
-		if (n->nfile.fd != ('>' == *p)) {
-			s[0] = n->nfile.fd + '0';
-			s[1] = '\0';
-			cmdputs(s);
-		}
-		cmdputs(p);
-		if (n->type >= NTOFD) {
-			s[0] = n->ndup.dupfd + '0';
-			s[1] = '\0';
-			cmdputs(s);
-		} else {
-			cmdtxt(n->nfile.fname);
-		}
-	}
-}
-#else							/* CMDTXT_TABLE */
-static void cmdtxt(const union node *n)
+static void
+cmdtxt(union node *n)
 {
 	union node *np;
 	struct nodelist *lp;
 	const char *p;
-	int i;
 	char s[2];
 
-	if (n == NULL)
-		return;
 	switch (n->type) {
-	case NSEMI:
-		cmdtxt(n->nbinary.ch1);
-		cmdputs("; ");
-		cmdtxt(n->nbinary.ch2);
-		break;
-	case NAND:
-		cmdtxt(n->nbinary.ch1);
-		cmdputs(" && ");
-		cmdtxt(n->nbinary.ch2);
-		break;
-	case NOR:
-		cmdtxt(n->nbinary.ch1);
-		cmdputs(" || ");
-		cmdtxt(n->nbinary.ch2);
-		break;
+	default:
+#if DEBUG
+		abort();
+#endif
 	case NPIPE:
-		for (lp = n->npipe.cmdlist; lp; lp = lp->next) {
+		lp = n->npipe.cmdlist;
+		for (;;) {
 			cmdtxt(lp->n);
-			if (lp->next)
-				cmdputs(" | ");
+			lp = lp->next;
+			if (!lp)
+				break;
+			cmdputs(" | ");
 		}
 		break;
-	case NSUBSHELL:
-		cmdputs("(");
-		cmdtxt(n->nredir.n);
-		cmdputs(")");
-		break;
+	case NSEMI:
+		p = "; ";
+		goto binop;
+	case NAND:
+		p = " && ";
+		goto binop;
+	case NOR:
+		p = " || ";
+binop:
+		cmdtxt(n->nbinary.ch1);
+		cmdputs(p);
+		n = n->nbinary.ch2;
+		goto donode;
 	case NREDIR:
 	case NBACKGND:
-		cmdtxt(n->nredir.n);
+		n = n->nredir.n;
+		goto donode;
+	case NNOT:
+		cmdputs("!");
+		n = n->nnot.com;
+donode:
+		cmdtxt(n);
 		break;
 	case NIF:
 		cmdputs("if ");
 		cmdtxt(n->nif.test);
 		cmdputs("; then ");
-		cmdtxt(n->nif.ifpart);
-		cmdputs("...");
-		break;
+		n = n->nif.ifpart;
+		if (n->nif.elsepart) {
+			cmdtxt(n);
+			cmdputs("; else ");
+			n = n->nif.elsepart;
+		}
+		p = "; fi";
+		goto dotail;
+	case NSUBSHELL:
+		cmdputs("(");
+		n = n->nredir.n;
+		p = ")";
+		goto dotail;
 	case NWHILE:
-		cmdputs("while ");
+		p = "while ";
 		goto until;
 	case NUNTIL:
-		cmdputs("until ");
-	  until:
+		p = "until ";
+until:
+		cmdputs(p);
 		cmdtxt(n->nbinary.ch1);
+		n = n->nbinary.ch2;
+		p = "; done";
+dodo:
 		cmdputs("; do ");
-		cmdtxt(n->nbinary.ch2);
-		cmdputs("; done");
-		break;
+dotail:
+		cmdtxt(n);
+		goto dotail2;
 	case NFOR:
 		cmdputs("for ");
 		cmdputs(n->nfor.var);
-		cmdputs(" in ...");
-		break;
-	case NCASE:
-		cmdputs("case ");
-		cmdputs(n->ncase.expr->narg.text);
-		cmdputs(" in ...");
-		break;
+		cmdputs(" in ");
+		cmdlist(n->nfor.args, 1);
+		n = n->nfor.body;
+		p = "; done";
+		goto dodo;
 	case NDEFUN:
 		cmdputs(n->narg.text);
-		cmdputs("() ...");
-		break;
+		p = "() { ... }";
+		goto dotail2;
 	case NCMD:
-		for (np = n->ncmd.args; np; np = np->narg.next) {
-			cmdtxt(np);
-			if (np->narg.next)
-				cmdputs(spcstr);
-		}
-		for (np = n->ncmd.redirect; np; np = np->nfile.next) {
-			cmdputs(spcstr);
-			cmdtxt(np);
-		}
+		cmdlist(n->ncmd.args, 1);
+		cmdlist(n->ncmd.redirect, 0);
 		break;
 	case NARG:
-		cmdputs(n->narg.text);
-		break;
-	case NTO:
-		p = ">";
-		i = 1;
-		goto redir;
-	case NAPPEND:
-		p = ">>";
-		i = 1;
-		goto redir;
-	case NTOFD:
-		p = ">&";
-		i = 1;
-		goto redir;
-	case NTOOV:
-		p = ">|";
-		i = 1;
-		goto redir;
-	case NFROM:
-		p = "<";
-		i = 0;
-		goto redir;
-	case NFROMFD:
-		p = "<&";
-		i = 0;
-		goto redir;
-	case NFROMTO:
-		p = "<>";
-		i = 0;
-		goto redir;
-	  redir:
-		if (n->nfile.fd != i) {
-			s[0] = n->nfile.fd + '0';
-			s[1] = '\0';
-			cmdputs(s);
-		}
+		p = n->narg.text;
+dotail2:
 		cmdputs(p);
-		if (n->type == NTOFD || n->type == NFROMFD) {
-			s[0] = n->ndup.dupfd + '0';
-			s[1] = '\0';
-			cmdputs(s);
-		} else {
-			cmdtxt(n->nfile.fname);
-		}
 		break;
 	case NHERE:
 	case NXHERE:
-		cmdputs("<<...");
-		break;
-	default:
-		cmdputs("???");
-		break;
+		p = "<<...";
+		goto dotail2;
+	case NCASE:
+		cmdputs("case ");
+		cmdputs(n->ncase.expr->narg.text);
+		cmdputs(" in ");
+		for (np = n->ncase.cases; np; np = np->nclist.next) {
+			cmdtxt(np->nclist.pattern);
+			cmdputs(") ");
+			cmdtxt(np->nclist.body);
+			cmdputs(";; ");
+		}
+		p = "esac";
+		goto dotail2;
+	case NTO:
+		p = ">";
+		goto redir;
+	case NCLOBBER:
+		p = ">|";
+		goto redir;
+	case NAPPEND:
+		p = ">>";
+		goto redir;
+	case NTOFD:
+		p = ">&";
+		goto redir;
+	case NFROM:
+		p = "<";
+		goto redir;
+	case NFROMFD:
+		p = "<&";
+		goto redir;
+	case NFROMTO:
+		p = "<>";
+redir:
+		s[0] = n->nfile.fd + '0';
+		s[1] = '\0';
+		cmdputs(s);
+		cmdputs(p);
+		if (n->type == NTOFD || n->type == NFROMFD) {
+			s[0] = n->ndup.dupfd + '0';
+			p = s;
+			goto dotail2;
+		} else {
+			n = n->nfile.fname;
+			goto donode;
+		}
 	}
 }
-#endif							/* CMDTXT_TABLE */
 
-static char *commandtext(const union node *n)
+static void
+cmdlist(union node *np, int sep)
 {
-	char *name;
-
-	cmdnextc = name = xmalloc(MAXCMDTEXT);
-	cmdnleft = MAXCMDTEXT - 4;
-	cmdtxt(n);
-	*cmdnextc = '\0';
-	return name;
+	for (; np; np = np->narg.next) {
+		if (!sep)
+			cmdputs(spcstr);
+		cmdtxt(np);
+		if (sep && np->narg.next)
+			cmdputs(spcstr);
+	}
 }
 
 
+static void
+cmdputs(const char *s)
+{
+	const char *p, *str;
+	char c, cc[2] = " ";
+	char *nextc;
+	int subtype = 0;
+	int quoted = 0;
+	static const char *const vstype[16] = {
+		nullstr, "}", "-", "+", "?", "=",
+		"#", "##", "%", "%%"
+	};
+
+	nextc = makestrspace((strlen(s) + 1) * 8, cmdnextc);
+	p = s;
+	while ((c = *p++) != 0) {
+		str = 0;
+		switch (c) {
+		case CTLESC:
+			c = *p++;
+			break;
+		case CTLVAR:
+			subtype = *p++;
+			if ((subtype & VSTYPE) == VSLENGTH)
+				str = "${#";
+			else
+				str = "${";
+			if (!(subtype & VSQUOTE) != !(quoted & 1)) {
+				quoted ^= 1;
+				c = '"';
+			} else
+				goto dostr;
+			break;
+		case CTLENDVAR:
+			quoted >>= 1;
+			subtype = 0;
+			if (quoted & 1) {
+				str = "\"}";
+				goto dostr;
+			}
+			c = '}';
+			break;
+		case CTLBACKQ:
+			str = "$(...)";
+			goto dostr;
+		case CTLBACKQ+CTLQUOTE:
+			str = "\"$(...)\"";
+			goto dostr;
+#ifdef CONFIG_ASH_MATH_SUPPORT
+		case CTLARI:
+			str = "$((";
+			goto dostr;
+		case CTLENDARI:
+			str = "))";
+			goto dostr;
+#endif
+		case CTLQUOTEMARK:
+			quoted ^= 1;
+			c = '"';
+			break;
+		case '=':
+			if (subtype == 0)
+				break;
+			str = vstype[subtype & VSTYPE];
+			if (subtype & VSNUL)
+				c = ':';
+			else
+				c = *str++;
+			if (c != '}')
+				quoted <<= 1;
+			break;
+		case '\'':
+		case '\\':
+		case '"':
+		case '$':
+			/* These can only happen inside quotes */
+			cc[0] = c;
+			str = cc;
+			c = '\\';
+			break;
+		default:
+			break;
+		}
+		USTPUTC(c, nextc);
+		if (!str)
+			continue;
+dostr:
+		while ((c = *str++)) {
+			USTPUTC(c, nextc);
+		}
+	}
+	if (quoted & 1) {
+		USTPUTC('"', nextc);
+	}
+	*nextc = 0;
+	cmdnextc = nextc;
+}
+
+
+static void
+showpipe(struct job *jp, FILE *out)
+{
+	struct procstat *sp;
+	struct procstat *spend;
+
+	spend = jp->ps + jp->nprocs;
+	for (sp = jp->ps + 1; sp < spend; sp++)
+		fprintf(out, " | %s", sp->cmd);
+	outcslow('\n', out);
+	flushall();
+}
+
+static void
+xtcsetpgrp(int fd, pid_t pgrp)
+{
+	if (tcsetpgrp(fd, pgrp))
+		error("Cannot set tty process group (%m)");
+}
+#endif /* JOBS */
+
+static int
+getstatus(struct job *job) {
+	int status;
+	int retval;
+
+	status = job->ps[job->nprocs - 1].status;
+	retval = WEXITSTATUS(status);
+	if (!WIFEXITED(status)) {
+#if JOBS
+		retval = WSTOPSIG(status);
+		if (!WIFSTOPPED(status))
+#endif
+		{
+			/* XXX: limits number of signals */
+			retval = WTERMSIG(status);
+#if JOBS
+			if (retval == SIGINT)
+				job->sigint = 1;
+#endif
+		}
+		retval += 128;
+	}
+	TRACE(("getstatus: job %d, nproc %d, status %x, retval %x\n",
+		jobno(job), job->nprocs, status, retval));
+	return retval;
+}
+
 #ifdef CONFIG_ASH_MAIL
+/*      $NetBSD: mail.c,v 1.15 2002/11/24 22:35:40 christos Exp $       */
 
 /*
- * Routines to check for mail.
+ * Routines to check for mail.  (Perhaps make part of main.c?)
  */
 
-
 #define MAXMBOXES 10
 
-
-static int nmboxes;		/* number of mailboxes */
-static time_t mailtime[MAXMBOXES];	/* times of mailboxes */
+/* times of mailboxes */
+static time_t mailtime[MAXMBOXES];
+/* Set if MAIL or MAILPATH is changed. */
+static int mail_var_path_changed;
 
 
 
 /*
- * Print appropriate message(s) if mail has arrived.  If the argument is
- * nozero, then the value of MAIL has changed, so we just update the
- * values.
+ * Print appropriate message(s) if mail has arrived.
+ * If mail_var_path_changed is set,
+ * then the value of MAIL has mail_var_path_changed,
+ * so we just update the values.
  */
 
-static void chkmail(int silent)
+static void
+chkmail(void)
 {
-	int i;
 	const char *mpath;
 	char *p;
 	char *q;
+	time_t *mtp;
 	struct stackmark smark;
 	struct stat statb;
 
-	if (silent)
-		nmboxes = 10;
-	if (nmboxes == 0)
-		return;
 	setstackmark(&smark);
-	mpath = mpathset()? mpathval() : mailval();
-	for (i = 0; i < nmboxes; i++) {
+	mpath = mpathset() ? mpathval() : mailval();
+	for (mtp = mailtime; mtp < mailtime + MAXMBOXES; mtp++) {
 		p = padvance(&mpath, nullstr);
 		if (p == NULL)
 			break;
 		if (*p == '\0')
 			continue;
-		for (q = p; *q; q++);
+		for (q = p ; *q ; q++);
 #ifdef DEBUG
 		if (q[-1] != '/')
 			abort();
 #endif
-		q[-1] = '\0';	/* delete trailing '/' */
-		if (stat(p, &statb) < 0)
-			statb.st_size = 0;
-		if (statb.st_size > mailtime[i] && !silent) {
-			out2fmt(snlfmt, pathopt ? pathopt : "you have mail");
+		q[-1] = '\0';                   /* delete trailing '/' */
+		if (stat(p, &statb) < 0) {
+			*mtp = 0;
+			continue;
 		}
-		mailtime[i] = statb.st_size;
+		if (!mail_var_path_changed && statb.st_mtime != *mtp) {
+			fprintf(
+				stderr, snlfmt,
+				pathopt ? pathopt : "you have mail"
+			);
+		}
+		*mtp = statb.st_mtime;
 	}
-	nmboxes = i;
+	mail_var_path_changed = 0;
 	popstackmark(&smark);
 }
 
-#endif							/* CONFIG_ASH_MAIL */
 
-#define PROFILE 0
+static void
+changemail(const char *val)
+{
+	mail_var_path_changed++;
+}
+
+#endif /* CONFIG_ASH_MAIL */
+
+/*      $NetBSD: main.c,v 1.46 2002/12/11 19:12:18 christos Exp $       */
+
 
 #if PROFILE
 static short profile_buf[16384];
 extern int etext();
 #endif
 
-static int isloginsh = 0;
+static int isloginsh;
 
 static void read_profile(const char *);
-static void cmdloop(int);
-static void options(int);
-static void setoption(int, int);
-static void procargs(int, char **);
-
 
 /*
  * Main routine.  We initialize things, parse the arguments, execute
@@ -7262,56 +7704,52 @@
  * is used to figure out how far we had gotten.
  */
 
-int ash_main(int argc, char **argv)
+int
+ash_main(int argc, char **argv)
 {
+	char *shinit;
+	volatile int state;
 	struct jmploc jmploc;
 	struct stackmark smark;
-	volatile int state;
-	const char *shinit;
 
-	BLTINCMD = find_builtin("builtin");
-	EXECCMD = find_builtin("exec");
-	EVALCMD = find_builtin("eval");
-
-#ifndef CONFIG_FEATURE_SH_FANCY_PROMPT
-	unsetenv("PS1");
-	unsetenv("PS2");
+#ifdef __GLIBC__
+	dash_errno = __errno_location();
 #endif
 
 #if PROFILE
 	monitor(4, etext, profile_buf, sizeof profile_buf, 50);
 #endif
-#if defined(linux) || defined(__GNU__)
-	signal(SIGCHLD, SIG_DFL);
-#endif
 	state = 0;
 	if (setjmp(jmploc.loc)) {
-		INTOFF;
-		/*
-		 * When a shell procedure is executed, we raise the
-		 * exception EXSHELLPROC to clean up before executing
-		 * the shell procedure.
-		 */
-		if (exception == EXSHELLPROC) {
-			rootpid = getpid();
-			rootshell = 1;
-			minusc = NULL;
-			state = 3;
-		} else {
-			if (exception == EXEXEC) {
-				exitstatus = exerrno;
-			} else if (exception == EXERROR) {
-				exitstatus = 2;
-			}
-			if (state == 0 || iflag == 0 || !rootshell)
-				exitshell(exitstatus);
-		}
+		int status;
+		int e;
+
 		reset();
-		if (exception == EXINT) {
-			out2c('\n');
+
+		e = exception;
+		switch (exception) {
+		case EXEXEC:
+			status = exerrno;
+			break;
+
+		case EXERROR:
+			status = 2;
+			break;
+
+		default:
+			status = exitstatus;
+			break;
+		}
+		exitstatus = status;
+
+		if (e == EXEXIT || state == 0 || iflag == 0 || ! rootshell)
+			exitshell();
+
+		if (e == EXINT ) {
+			outcslow('\n', stderr);
 		}
 		popstackmark(&smark);
-		FORCEINTON;		/* enable interrupts */
+		FORCEINTON;                             /* enable interrupts */
 		if (state == 1)
 			goto state1;
 		else if (state == 2)
@@ -7324,8 +7762,7 @@
 	handler = &jmploc;
 #ifdef DEBUG
 	opentrace();
-	trputs("Shell args:  ");
-	trargs(argv);
+	trputs("Shell args:  ");  trargs(argv);
 #endif
 	rootpid = getpid();
 	rootshell = 1;
@@ -7351,45 +7788,29 @@
 	if (isloginsh) {
 		state = 1;
 		read_profile("/etc/profile");
-	  state1:
+state1:
 		state = 2;
 		read_profile(".profile");
 	}
-  state2:
+state2:
 	state = 3;
+	if (
 #ifndef linux
-	if (getuid() == geteuid() && getgid() == getegid()) {
+		getuid() == geteuid() && getgid() == getegid() &&
 #endif
+		iflag
+	) {
 		if ((shinit = lookupvar("ENV")) != NULL && *shinit != '\0') {
-			state = 3;
 			read_profile(shinit);
 		}
-#ifndef linux
 	}
-#endif
-  state3:
+state3:
 	state = 4;
-	if (sflag == 0 || minusc) {
-		static const char sigs[] = {
-			SIGINT, SIGQUIT, SIGHUP,
-#ifdef SIGTSTP
-			SIGTSTP,
-#endif
-			SIGPIPE
-		};
-
-#define SIGSSIZE ((sizeof(sigs)/sizeof(sigs[0])))
-		int i;
-
-		for (i = 0; i < SIGSSIZE; i++)
-			setsignal(sigs[i]);
-	}
-
 	if (minusc)
 		evalstring(minusc, 0);
 
 	if (sflag || minusc == NULL) {
-	  state4:			/* XXX ??? - why isn't this before the "if" statement */
+state4: /* XXX ??? - why isn't this before the "if" statement */
 #ifdef CONFIG_FEATURE_COMMAND_SAVEHISTORY
 	    if ( iflag ) {
 		const char *hp = lookupvar("HISTFILE");
@@ -7403,7 +7824,13 @@
 #if PROFILE
 	monitor(0);
 #endif
-	exitshell(exitstatus);
+#if GPROF
+	{
+		extern void _mcleanup(void);
+		_mcleanup();
+	}
+#endif
+	exitshell();
 	/* NOTREACHED */
 }
 
@@ -7413,7 +7840,8 @@
  * loop; it turns on prompting if the shell is interactive.
  */
 
-static void cmdloop(int top)
+static void
+cmdloop(int top)
 {
 	union node *n;
 	struct stackmark smark;
@@ -7425,14 +7853,16 @@
 	for (;;) {
 		if (pendingsigs)
 			dotrap();
+#if JOBS
+		if (jobctl)
+			showjobs(stderr, SHOW_CHANGED);
+#endif
 		inter = 0;
 		if (iflag && top) {
 			inter++;
-			showjobs(1);
 #ifdef CONFIG_ASH_MAIL
-			chkmail(0);
+			chkmail();
 #endif
-			flushall();
 		}
 		n = parsecmd(inter);
 		/* showtree(n); DEBUG */
@@ -7466,11 +7896,12 @@
  * Read /etc/profile or .profile.  Return on error.
  */
 
-static void read_profile(const char *name)
+static void
+read_profile(const char *name)
 {
 	int fd;
-	int xflag_save;
-	int vflag_save;
+	int xflag_set = 0;
+	int vflag_set = 0;
 
 	INTOFF;
 	if ((fd = open(name, O_RDONLY)) >= 0)
@@ -7479,15 +7910,19 @@
 	if (fd < 0)
 		return;
 	/* -q turns off -x and -v just when executing init files */
-	/* Note: Might do a little redundant work, but reduces code size. */
-	xflag_save = xflag;
-	vflag_save = vflag;
-	if (qflag) {
-		vflag = xflag = 0;
+	if (qflag)  {
+	    if (xflag)
+		    xflag = 0, xflag_set = 1;
+	    if (vflag)
+		    vflag = 0, vflag_set = 1;
 	}
 	cmdloop(0);
-	xflag = xflag_save;
-	vflag = vflag_save;
+	if (qflag)  {
+	    if (xflag_set)
+		    xflag = 1;
+	    if (vflag_set)
+		    vflag = 1;
+	}
 	popfile();
 }
 
@@ -7497,7 +7932,8 @@
  * Read a file containing shell functions.
  */
 
-static void readcmdfile(const char *name)
+static void
+readcmdfile(char *name)
 {
 	int fd;
 
@@ -7512,23 +7948,23 @@
 }
 
 
-
 /*
- * Take commands from a file.  To be compatable we should do a path
+ * Take commands from a file.  To be compatible we should do a path
  * search for the file, which is necessary to find sub-commands.
  */
 
-static inline char *find_dot_file(char *mybasename)
+static inline char *
+find_dot_file(char *name)
 {
 	char *fullname;
 	const char *path = pathval();
 	struct stat statb;
 
 	/* don't try this for absolute or relative paths */
-	if (strchr(mybasename, '/'))
-		return mybasename;
+	if (strchr(name, '/'))
+		return name;
 
-	while ((fullname = padvance(&path, mybasename)) != NULL) {
+	while ((fullname = padvance(&path, name)) != NULL) {
 		if ((stat(fullname, &statb) == 0) && S_ISREG(statb.st_mode)) {
 			/*
 			 * Don't bother freeing here, since it will
@@ -7540,107 +7976,149 @@
 	}
 
 	/* not found in the PATH */
-	error("%s: not found", mybasename);
+	error(not_found_msg, name);
 	/* NOTREACHED */
 }
 
-static int dotcmd(int argc, char **argv)
+int
+dotcmd(int argc, char **argv)
 {
-	struct strlist *sp;
-	volatile struct shparam saveparam;
-
 	exitstatus = 0;
 
-	for (sp = cmdenviron; sp; sp = sp->next)
-		setvareq(bb_xstrdup(sp->text), VSTRFIXED | VTEXTFIXED);
-
-	if (argc >= 2) {	/* That's what SVR2 does */
+	if (argc >= 2) {                /* That's what SVR2 does */
 		char *fullname;
 		struct stackmark smark;
 
 		setstackmark(&smark);
 		fullname = find_dot_file(argv[1]);
-
-		if (argc > 2) {
-			saveparam = shellparam;
-			shellparam.malloc = 0;
-			shellparam.nparam = argc - 2;
-			shellparam.p = argv + 2;
-		};
-
 		setinputfile(fullname, 1);
 		commandname = fullname;
 		cmdloop(0);
 		popfile();
-
-		if (argc > 2) {
-			freeparam(&shellparam);
-			shellparam = saveparam;
-		};
-
 		popstackmark(&smark);
 	}
 	return exitstatus;
 }
 
 
-static int exitcmd(int argc, char **argv)
+static int
+exitcmd(int argc, char **argv)
 {
 	if (stoppedjobs())
 		return 0;
-		
 	if (argc > 1)
 		exitstatus = number(argv[1]);
-	else
-		exitstatus = oexitstatus;
-	exitshell(exitstatus);
+	exraise(EXEXIT);
 	/* NOTREACHED */
 }
 
-static pointer stalloc(int nbytes)
+/*      $NetBSD: memalloc.c,v 1.27 2003/01/22 20:36:04 dsl Exp $        */
+
+/*
+ * Like malloc, but returns an error when out of space.
+ */
+
+static pointer
+ckmalloc(size_t nbytes)
 {
-	char *p;
+	pointer p;
 
-	nbytes = ALIGN(nbytes);
-	if (nbytes > stacknleft) {
-		int blocksize;
-		struct stack_block *sp;
-
-		blocksize = nbytes;
-		if (blocksize < MINSIZE)
-			blocksize = MINSIZE;
-		INTOFF;
-		sp = xmalloc(sizeof(struct stack_block) - MINSIZE + blocksize);
-		sp->prev = stackp;
-		stacknxt = sp->space;
-		stacknleft = blocksize;
-		stackp = sp;
-		INTON;
-	}
-	p = stacknxt;
-	stacknxt += nbytes;
-	stacknleft -= nbytes;
+	p = malloc(nbytes);
+	if (p == NULL)
+		error(bb_msg_memory_exhausted);
 	return p;
 }
 
 
-static void stunalloc(pointer p)
+/*
+ * Same for realloc.
+ */
+
+static pointer
+ckrealloc(pointer p, size_t nbytes)
+{
+	p = realloc(p, nbytes);
+	if (p == NULL)
+		error(bb_msg_memory_exhausted);
+	return p;
+}
+
+
+/*
+ * Make a copy of a string in safe storage.
+ */
+
+static char *
+savestr(const char *s)
+{
+	char *p = strdup(s);
+	if (!p)
+		error(bb_msg_memory_exhausted);
+	return p;
+}
+
+
+/*
+ * Parse trees for commands are allocated in lifo order, so we use a stack
+ * to make this more efficient, and also to avoid all sorts of exception
+ * handling code to handle interrupts in the middle of a parse.
+ *
+ * The size 504 was chosen because the Ultrix malloc handles that size
+ * well.
+ */
+
+
+static pointer
+stalloc(size_t nbytes)
+{
+	char *p;
+	size_t aligned;
+
+	aligned = SHELL_ALIGN(nbytes);
+	if (aligned > stacknleft) {
+		size_t len;
+		size_t blocksize;
+		struct stack_block *sp;
+
+		blocksize = aligned;
+		if (blocksize < MINSIZE)
+			blocksize = MINSIZE;
+		len = sizeof(struct stack_block) - MINSIZE + blocksize;
+		if (len < blocksize)
+			error(bb_msg_memory_exhausted);
+		INTOFF;
+		sp = ckmalloc(len);
+		sp->prev = stackp;
+		stacknxt = sp->space;
+		stacknleft = blocksize;
+		sstrend = stacknxt + blocksize;
+		stackp = sp;
+		INTON;
+	}
+	p = stacknxt;
+	stacknxt += aligned;
+	stacknleft -= aligned;
+	return p;
+}
+
+
+void
+stunalloc(pointer p)
 {
 #ifdef DEBUG
-	if (p == NULL) {	/*DEBUG */
+	if (!p || (stacknxt < (char *)p) || ((char *)p < stackp->space)) {
 		write(2, "stunalloc\n", 10);
 		abort();
 	}
 #endif
-	if (!(stacknxt >= (char *) p && (char *) p >= stackp->space)) {
-		p = stackp->space;
-	}
-	stacknleft += stacknxt - (char *) p;
+	stacknleft += stacknxt - (char *)p;
 	stacknxt = p;
 }
 
 
-static void setstackmark(struct stackmark *mark)
+
+void
+setstackmark(struct stackmark *mark)
 {
 	mark->stackp = stackp;
 	mark->stacknxt = stacknxt;
@@ -7650,7 +8128,8 @@
 }
 
 
-static void popstackmark(struct stackmark *mark)
+void
+popstackmark(struct stackmark *mark)
 {
 	struct stack_block *sp;
 
@@ -7659,10 +8138,11 @@
 	while (stackp != mark->stackp) {
 		sp = stackp;
 		stackp = sp->prev;
-		free(sp);
+		ckfree(sp);
 	}
 	stacknxt = mark->stacknxt;
 	stacknleft = mark->stacknleft;
+	sstrend = mark->stacknxt + mark->stacknleft;
 	INTON;
 }
 
@@ -7677,62 +8157,69 @@
  * part of the block that has been used.
  */
 
-static void growstackblock(void)
+void
+growstackblock(void)
 {
-	char *p;
-	int newlen = ALIGN(stacknleft * 2 + 100);
-	char *oldspace = stacknxt;
-	int oldlen = stacknleft;
-	struct stack_block *sp;
-	struct stack_block *oldstackp;
+	size_t newlen;
+
+	newlen = stacknleft * 2;
+	if (newlen < stacknleft)
+		error(bb_msg_memory_exhausted);
+	if (newlen < 128)
+		newlen += 128;
 
 	if (stacknxt == stackp->space && stackp != &stackbase) {
+		struct stack_block *oldstackp;
+		struct stackmark *xmark;
+		struct stack_block *sp;
+		struct stack_block *prevstackp;
+		size_t grosslen;
+
 		INTOFF;
 		oldstackp = stackp;
 		sp = stackp;
-		stackp = sp->prev;
-		sp = xrealloc((pointer) sp,
-					  sizeof(struct stack_block) - MINSIZE + newlen);
-		sp->prev = stackp;
+		prevstackp = sp->prev;
+		grosslen = newlen + sizeof(struct stack_block) - MINSIZE;
+		sp = ckrealloc((pointer)sp, grosslen);
+		sp->prev = prevstackp;
 		stackp = sp;
 		stacknxt = sp->space;
 		stacknleft = newlen;
-		{
-			/* Stack marks pointing to the start of the old block
-			 * must be relocated to point to the new block
-			 */
-			struct stackmark *xmark;
+		sstrend = sp->space + newlen;
 
-			xmark = markp;
-			while (xmark != NULL && xmark->stackp == oldstackp) {
-				xmark->stackp = stackp;
-				xmark->stacknxt = stacknxt;
-				xmark->stacknleft = stacknleft;
-				xmark = xmark->marknext;
-			}
+		/*
+		 * Stack marks pointing to the start of the old block
+		 * must be relocated to point to the new block
+		 */
+		xmark = markp;
+		while (xmark != NULL && xmark->stackp == oldstackp) {
+			xmark->stackp = stackp;
+			xmark->stacknxt = stacknxt;
+			xmark->stacknleft = stacknleft;
+			xmark = xmark->marknext;
 		}
 		INTON;
 	} else {
-		p = stalloc(newlen);
-		memcpy(p, oldspace, oldlen);
-		stacknxt = p;	/* free the space */
-		stacknleft += newlen;	/* we just allocated */
+		char *oldspace = stacknxt;
+		int oldlen = stacknleft;
+		char *p = stalloc(newlen);
+
+		/* free the space we just allocated */
+		stacknxt = memcpy(p, oldspace, oldlen);
+		stacknleft += newlen;
 	}
 }
 
-
-
-static inline void grabstackblock(int len)
+static inline void
+grabstackblock(size_t len)
 {
-	len = ALIGN(len);
+	len = SHELL_ALIGN(len);
 	stacknxt += len;
 	stacknleft -= len;
 }
 
-
-
 /*
- * The following routines are somewhat easier to use that the above.
+ * The following routines are somewhat easier to use than the above.
  * The user declares a variable of type STACKSTR, which may be declared
  * to be a register.  The macro STARTSTACKSTR initializes things.  Then
  * the user uses the macro STPUTC to add characters to the string.  In
@@ -7749,853 +8236,349 @@
  * is space for at least one character.
  */
 
-
-static char *growstackstr(void)
+void *
+growstackstr(void)
 {
-	int len = stackblocksize();
-
+	size_t len = stackblocksize();
 	if (herefd >= 0 && len >= 1024) {
 		xwrite(herefd, stackblock(), len);
-		sstrnleft = len - 1;
 		return stackblock();
 	}
 	growstackblock();
-	sstrnleft = stackblocksize() - len - 1;
 	return stackblock() + len;
 }
 
-
 /*
  * Called from CHECKSTRSPACE.
  */
 
-static char *makestrspace(size_t newlen)
+char *
+makestrspace(size_t newlen, char *p)
 {
-	int len = stackblocksize() - sstrnleft;
+	size_t len = p - stacknxt;
+	size_t size = stackblocksize();
 
-	do {
+	for (;;) {
+		size_t nleft;
+
+		size = stackblocksize();
+		nleft = size - len;
+		if (nleft >= newlen)
+			break;
 		growstackblock();
-		sstrnleft = stackblocksize() - len;
-	} while (sstrnleft < newlen);
+	}
 	return stackblock() + len;
 }
 
-
-
-static void ungrabstackstr(char *s, char *p)
+char *
+stnputs(const char *s, size_t n, char *p)
 {
-	stacknleft += stacknxt - s;
-	stacknxt = s;
-	sstrnleft = stacknleft - (p - s);
+	p = makestrspace(n, p);
+	p = mempcpy(p, s, n);
+	return p;
 }
 
+char *
+stputs(const char *s, char *p)
+{
+	return stnputs(s, strlen(s), p);
+}
+
+/*      $NetBSD: mystring.c,v 1.15 2002/11/24 22:35:42 christos Exp $   */
+
 /*
- * Miscelaneous builtins.
- */
-
-
-#undef rflag
-
-#if !defined(__GLIBC__) || __GLIBC__ == 2 && __GLIBC_MINOR__ < 1
-typedef long rlim_t;
-#endif
-
-
-
-/*
- * The read builtin.  The -e option causes backslashes to escape the
- * following character.
+ * String functions.
  *
- * This uses unbuffered input, which may be avoidable in some cases.
+ *      number(s)               Convert a string of digits to an integer.
+ *      is_number(s)            Return true if s is a string of digits.
  */
 
-static int readcmd(int argc, char **argv)
-{
-	char **ap;
-	int backslash;
-	char c;
-	int rflag;
-	char *prompt;
-	const char *ifs;
-	char *p;
-	int startword;
-	int status;
-	int i;
-
-	rflag = 0;
-	prompt = NULL;
-	while ((i = nextopt("p:r")) != '\0') {
-		if (i == 'p')
-			prompt = optionarg;
-		else
-			rflag = 1;
-	}
-	if (prompt && isatty(0)) {
-		out2str(prompt);	/* read without cmdedit */
-		flushall();
-	}
-	if (*(ap = argptr) == NULL)
-		error("arg count");
-	if ((ifs = bltinlookup("IFS")) == NULL)
-		ifs = defifs;
-	status = 0;
-	startword = 1;
-	backslash = 0;
-	STARTSTACKSTR(p);
-	for (;;) {
-		if (read(0, &c, 1) != 1) {
-			status = 1;
-			break;
-		}
-		if (c == '\0')
-			continue;
-		if (backslash) {
-			backslash = 0;
-			if (c != '\n')
-				STPUTC(c, p);
-			continue;
-		}
-		if (!rflag && c == '\\') {
-			backslash++;
-			continue;
-		}
-		if (c == '\n')
-			break;
-		if (startword && *ifs == ' ' && strchr(ifs, c)) {
-			continue;
-		}
-		startword = 0;
-		if (backslash && c == '\\') {
-			if (read(0, &c, 1) != 1) {
-				status = 1;
-				break;
-			}
-			STPUTC(c, p);
-		} else if (ap[1] != NULL && strchr(ifs, c) != NULL) {
-			STACKSTRNUL(p);
-			setvar(*ap, stackblock(), 0);
-			ap++;
-			startword = 1;
-			STARTSTACKSTR(p);
-		} else {
-			STPUTC(c, p);
-		}
-	}
-	STACKSTRNUL(p);
-	/* Remove trailing blanks */
-	while (stackblock() <= --p && strchr(ifs, *p) != NULL)
-		*p = '\0';
-	setvar(*ap, stackblock(), 0);
-	while (*++ap != NULL)
-		setvar(*ap, nullstr, 0);
-	return status;
-}
-
-
-
-static int umaskcmd(int argc, char **argv)
-{
-	static const char permuser[3] = "ugo";
-	static const char permmode[3] = "rwx";
-	static const short int permmask[] = {
-		S_IRUSR, S_IWUSR, S_IXUSR,
-		S_IRGRP, S_IWGRP, S_IXGRP,
-		S_IROTH, S_IWOTH, S_IXOTH
-	};
-
-	char *ap;
-	mode_t mask;
-	int i;
-	int symbolic_mode = 0;
-
-	while (nextopt("S") != '\0') {
-		symbolic_mode = 1;
-	}
-
-	INTOFF;
-	mask = umask(0);
-	umask(mask);
-	INTON;
-
-	if ((ap = *argptr) == NULL) {
-		if (symbolic_mode) {
-			char buf[18];
-			char *p = buf;
-
-			for (i = 0; i < 3; i++) {
-				int j;
-
-				*p++ = permuser[i];
-				*p++ = '=';
-				for (j = 0; j < 3; j++) {
-					if ((mask & permmask[3 * i + j]) == 0) {
-						*p++ = permmode[j];
-					}
-				}
-				*p++ = ',';
-			}
-			*--p = 0;
-			puts(buf);
-		} else {
-			printf("%.4o\n", mask);
-		}
-	} else {
-		if (is_digit((unsigned char) *ap)) {
-			mask = 0;
-			do {
-				if (*ap >= '8' || *ap < '0')
-					error("Illegal number: %s", argv[1]);
-				mask = (mask << 3) + (*ap - '0');
-			} while (*++ap != '\0');
-			umask(mask);
-		} else {
-			mask = ~mask & 0777;
-			if (!bb_parse_mode(ap, &mask)) {
-				error("Illegal mode: %s", ap);
-			}
-			umask(~mask & 0777);
-		}
-	}
-	return 0;
-}
-
-/*
- * ulimit builtin
- *
- * This code, originally by Doug Gwyn, Doug Kingston, Eric Gisin, and
- * Michael Rendell was ripped from pdksh 5.0.8 and hacked for use with
- * ash by J.T. Conklin.
- *
- * Public domain.
- */
-
-struct limits {
-	const char *name;
-	short cmd;
-	short factor;		/* multiply by to get rlim_{cur,max} values */
-};
-
-static const struct limits limits[] = {
-#ifdef RLIMIT_CPU
-	{"time(seconds)", RLIMIT_CPU, 1},
-#endif
-#ifdef RLIMIT_FSIZE
-	{"file(blocks)", RLIMIT_FSIZE, 512},
-#endif
-#ifdef RLIMIT_DATA
-	{"data(kbytes)", RLIMIT_DATA, 1024},
-#endif
-#ifdef RLIMIT_STACK
-	{"stack(kbytes)", RLIMIT_STACK, 1024},
-#endif
-#ifdef  RLIMIT_CORE
-	{"coredump(blocks)", RLIMIT_CORE, 512},
-#endif
-#ifdef RLIMIT_RSS
-	{"memory(kbytes)", RLIMIT_RSS, 1024},
-#endif
-#ifdef RLIMIT_MEMLOCK
-	{"locked memory(kbytes)", RLIMIT_MEMLOCK, 1024},
-#endif
-#ifdef RLIMIT_NPROC
-	{"process(processes)", RLIMIT_NPROC, 1},
-#endif
-#ifdef RLIMIT_NOFILE
-	{"nofiles(descriptors)", RLIMIT_NOFILE, 1},
-#endif
-#ifdef RLIMIT_VMEM
-	{"vmemory(kbytes)", RLIMIT_VMEM, 1024},
-#endif
-#ifdef RLIMIT_SWAP
-	{"swap(kbytes)", RLIMIT_SWAP, 1024},
-#endif
-	{NULL, 0, 0}
-};
-
-static int ulimitcmd(int argc, char **argv)
-{
-	static const char unlimited_string[] = "unlimited";
-	int c;
-	rlim_t val = 0;
-	enum { SOFT = 0x1, HARD = 0x2 } how = SOFT | HARD;
-	const struct limits *l;
-	int set, all = 0;
-	int optc, what;
-	struct rlimit limit;
-
-	what = 'f';
-
-	while ((optc = nextopt("HSa"
-#ifdef RLIMIT_CPU
-						   "t"
-#endif
-#ifdef RLIMIT_FSIZE
-						   "f"
-#endif
-#ifdef RLIMIT_DATA
-						   "d"
-#endif
-#ifdef RLIMIT_STACK
-						   "s"
-#endif
-#ifdef  RLIMIT_CORE
-						   "c"
-#endif
-#ifdef RLIMIT_RSS
-						   "m"
-#endif
-#ifdef RLIMIT_MEMLOCK
-						   "l"
-#endif
-#ifdef RLIMIT_NPROC
-						   "p"
-#endif
-#ifdef RLIMIT_NOFILE
-						   "n"
-#endif
-#ifdef RLIMIT_VMEM
-						   "v"
-#endif
-#ifdef RLIMIT_SWAP
-						   "w"
-#endif
-			)) != '\0') {
-		if (optc == 'H') {
-			how = HARD;
-		} else if (optc == 'S') {
-			how = SOFT;
-		} else if (optc == 'a') {
-			all = 1;
-		} else {
-			what = optc;
-		}
-	}
-
-	for (l = limits; l->name; l++) {
-		if (l->name[0] == what)
-			break;
-		if (l->name[1] == 'w' && what == 'w')
-			break;
-	}
-
-	set = *argptr ? 1 : 0;
-	if (set) {
-		char *p = *argptr;
-
-		if (all || argptr[1])
-			error("too many arguments");
-		if (strcmp(p, unlimited_string) == 0)
-			val = RLIM_INFINITY;
-		else {
-			val = (rlim_t) 0;
-
-			while ((c = *p++) >= '0' && c <= '9') {
-				val = (val * 10) + (long) (c - '0');
-				if (val < (rlim_t) 0)
-					break;
-			}
-			if (c)
-				error("bad number");
-			val *= l->factor;
-		}
-	}
-
-	if (all) {
-		for (l = limits; l->name; l++) {
-			printf("%-20s ", l->name);
-			getrlimit(l->cmd, &limit);
-		  OUTPUT_LIMIT:
-			if (how & SOFT)
-				val = limit.rlim_cur;
-			else if (how & HARD)
-				val = limit.rlim_max;
-
-			if (val == RLIM_INFINITY)
-				puts(unlimited_string);
-			else {
-				val /= l->factor;
-				printf("%lld\n", (long long) val);
-			}
-			if (!all) {
-				break;
-			}
-		}
-		return 0;
-	}
-
-	if (!set) {
-		goto OUTPUT_LIMIT;
-	}
-
-	getrlimit(l->cmd, &limit);
-	if (how & HARD)
-		limit.rlim_max = val;
-	if (how & SOFT)
-		limit.rlim_cur = val;
-	if (setrlimit(l->cmd, &limit) < 0)
-		error("error setting limit (%m)");
-	return 0;
-}
-
 /*
  * prefix -- see if pfx is a prefix of string.
  */
 
-static int prefix(char const *pfx, char const *string)
+char *
+prefix(const char *string, const char *pfx)
 {
 	while (*pfx) {
 		if (*pfx++ != *string++)
 			return 0;
 	}
-	return 1;
+	return (char *) string;
 }
 
-/*
- * Return true if s is a string of digits, and save munber in intptr
- * nagative is bad
- */
-
-static int is_number(const char *p, int *intptr)
-{
-	int ret = 0;
-
-	do {
-		if (!is_digit(*p))
-			return 0;
-		ret *= 10;
-		ret += digit_val(*p);
-		p++;
-	} while (*p != '\0');
-
-	*intptr = ret;
-	return 1;
-}
 
 /*
  * Convert a string of digits to an integer, printing an error message on
  * failure.
  */
 
-static int number(const char *s)
+int
+number(const char *s)
 {
-	int i;
 
-	if (!is_number(s, &i))
-		error("Illegal number: %s", s);
-	return i;
+	if (! is_number(s))
+		error(illnum, s);
+	return atoi(s);
 }
 
+
+
+/*
+ * Check for a valid number.  This should be elsewhere.
+ */
+
+int
+is_number(const char *p)
+{
+	do {
+		if (! is_digit(*p))
+			return 0;
+	} while (*++p != '\0');
+	return 1;
+}
+
+
 /*
  * Produce a possibly single quoted string suitable as input to the shell.
  * The return string is allocated on the stack.
  */
 
-static char *single_quote(const char *s)
-{
+char *
+single_quote(const char *s) {
 	char *p;
 
 	STARTSTACKSTR(p);
 
 	do {
-		char *q = p;
-		size_t len1, len1p, len2, len2p;
+		char *q;
+		size_t len;
 
-		len1 = strcspn(s, "'");
-		len2 = strspn(s + len1, "'");
+		len = strchrnul(s, '\'') - s;
 
-		len1p = len1 ? len1 + 2 : len1;
-		len2p = len2 + ((len2 < 2) ? len2 : 2);
+		q = p = makestrspace(len + 3, p);
 
-		CHECKSTRSPACE(len1p + len2p + 1, p);
+		*q++ = '\'';
+		q = mempcpy(q, s, len);
+		*q++ = '\'';
+		s += len;
 
-		if (len1) {
-			*p = '\'';
-			q = p + 1 + len1;
-			memcpy(p + 1, s, len1);
-			*q++ = '\'';
-			s += len1;
-		}
+		STADJUST(q - p, p);
 
-		if (len2 > 1) {
-			*q = '"';
-			q += 1 + len2;
-			memcpy(q + 1, s, len2);
-			*q = '"';
-			s += len2;
-		} else if (len2 == 1) {
-			*q++ = '\\';
-			*q = '\'';
-			s++;
-		}
+		len = strspn(s, "'");
+		if (!len)
+			break;
 
-		STADJUST(len1p + len2p, p);
+		q = p = makestrspace(len + 3, p);
+
+		*q++ = '"';
+		q = mempcpy(q, s, len);
+		*q++ = '"';
+		s += len;
+
+		STADJUST(q - p, p);
 	} while (*s);
 
 	USTPUTC(0, p);
 
-	return grabstackstr(p);
+	return stackblock();
 }
 
 /*
- * Routine for dealing with parsed shell commands.
+ * Like strdup but works with the ash stack.
  */
 
-
-static void sizenodelist(const struct nodelist *);
-static struct nodelist *copynodelist(const struct nodelist *);
-static char *nodesavestr(const char *);
-
-#define CALCSIZE_TABLE
-#define COPYNODE_TABLE
-#if defined(CALCSIZE_TABLE) || defined(COPYNODE_TABLE)
-/*
- * To collect a lot of redundant code in case statements for copynode()
- * and calcsize(), we implement a mini language here.  Each type of node
- * struct has an associated instruction sequence that operates on its
- * members via their offsets.  The instruction are pack in unsigned chars
- * with format   IIDDDDDE   where the bits are
- *   I : part of the instruction opcode, which are
- *       00 : member is a pointer to another node
- *       40 : member is an integer
- *       80 : member is a pointer to a nodelist
- *       CC : member is a pointer to a char string
- *   D : data - the actual offset of the member to operate on in the struct
- *              (since we assume bit 0 is set, it is not shifted)
- *   E : flag signaling end of instruction sequence
- *
- * WARNING: In order to handle larger offsets for 64bit archs, this code
- *          assumes that no offset can be an odd number and stores the
- *          end-of-instructions flag in bit 0.
- */
-
-#define NODE_INTEGER    0x40
-#define NODE_NODELIST   0x80
-#define NODE_CHARPTR    0xC0
-#define NODE_NOMORE             0x01	/* Note: no offset should be odd (aligned) */
-#define NODE_MBRMASK    0xC0
-#define NODE_OFFSETMASK 0x3E
-
-static const unsigned char copynode_ops[35] = {
-#define COPYNODE_OPS0   0
-	offsetof(union node, nbinary.ch2),
-	offsetof(union node, nbinary.ch1) | NODE_NOMORE,
-#define COPYNODE_OPS1   (COPYNODE_OPS0 + 2)
-	offsetof(union node, ncmd.redirect),
-	offsetof(union node, ncmd.args),
-	offsetof(union node, ncmd.assign),
-	offsetof(union node, ncmd.backgnd) | NODE_INTEGER | NODE_NOMORE,
-#define COPYNODE_OPS2   (COPYNODE_OPS1 + 4)
-	offsetof(union node, npipe.cmdlist) | NODE_NODELIST,
-	offsetof(union node, npipe.backgnd) | NODE_INTEGER | NODE_NOMORE,
-#define COPYNODE_OPS3   (COPYNODE_OPS2 + 2)
-	offsetof(union node, nredir.redirect),
-	offsetof(union node, nredir.n) | NODE_NOMORE,
-#define COPYNODE_OPS4   (COPYNODE_OPS3 + 2)
-	offsetof(union node, nif.elsepart),
-	offsetof(union node, nif.ifpart),
-	offsetof(union node, nif.test) | NODE_NOMORE,
-#define COPYNODE_OPS5   (COPYNODE_OPS4 + 3)
-	offsetof(union node, nfor.var) | NODE_CHARPTR,
-	offsetof(union node, nfor.body),
-	offsetof(union node, nfor.args) | NODE_NOMORE,
-#define COPYNODE_OPS6   (COPYNODE_OPS5 + 3)
-	offsetof(union node, ncase.cases),
-	offsetof(union node, ncase.expr) | NODE_NOMORE,
-#define COPYNODE_OPS7   (COPYNODE_OPS6 + 2)
-	offsetof(union node, nclist.body),
-	offsetof(union node, nclist.pattern),
-	offsetof(union node, nclist.next) | NODE_NOMORE,
-#define COPYNODE_OPS8   (COPYNODE_OPS7 + 3)
-	offsetof(union node, narg.backquote) | NODE_NODELIST,
-	offsetof(union node, narg.text) | NODE_CHARPTR,
-	offsetof(union node, narg.next) | NODE_NOMORE,
-#define COPYNODE_OPS9   (COPYNODE_OPS8 + 3)
-	offsetof(union node, nfile.fname),
-	offsetof(union node, nfile.fd) | NODE_INTEGER,
-	offsetof(union node, nfile.next) | NODE_NOMORE,
-#define COPYNODE_OPS10   (COPYNODE_OPS9 + 3)
-	offsetof(union node, ndup.vname),
-	offsetof(union node, ndup.dupfd) | NODE_INTEGER,
-	offsetof(union node, ndup.fd) | NODE_INTEGER,
-	offsetof(union node, ndup.next) | NODE_NOMORE,
-#define COPYNODE_OPS11   (COPYNODE_OPS10 + 4)
-	offsetof(union node, nhere.doc),
-	offsetof(union node, nhere.fd) | NODE_INTEGER,
-	offsetof(union node, nhere.next) | NODE_NOMORE,
-#define COPYNODE_OPS12   (COPYNODE_OPS11 + 3)
-	offsetof(union node, nnot.com) | NODE_NOMORE,
-};
-
-#if COPYNODE_OPS12 != 34
-#error COPYNODE_OPS12 is incorrect
-#endif
-
-static const unsigned char copynode_ops_index[26] = {
-	COPYNODE_OPS0,		/* NSEMI */
-	COPYNODE_OPS1,		/* NCMD */
-	COPYNODE_OPS2,		/* NPIPE */
-	COPYNODE_OPS3,		/* NREDIR */
-	COPYNODE_OPS3,		/* NBACKGND */
-	COPYNODE_OPS3,		/* NSUBSHELL */
-	COPYNODE_OPS0,		/* NAND */
-	COPYNODE_OPS0,		/* NOR */
-	COPYNODE_OPS4,		/* NIF */
-	COPYNODE_OPS0,		/* NWHILE */
-	COPYNODE_OPS0,		/* NUNTIL */
-	COPYNODE_OPS5,		/* NFOR */
-	COPYNODE_OPS6,		/* NCASE */
-	COPYNODE_OPS7,		/* NCLIST */
-	COPYNODE_OPS8,		/* NDEFUN */
-	COPYNODE_OPS8,		/* NARG */
-	COPYNODE_OPS9,		/* NTO */
-	COPYNODE_OPS9,		/* NFROM */
-	COPYNODE_OPS9,		/* NFROMTO */
-	COPYNODE_OPS9,		/* NAPPEND */
-	COPYNODE_OPS9,		/* NTOOV */
-	COPYNODE_OPS10,		/* NTOFD */
-	COPYNODE_OPS10,		/* NFROMFD */
-	COPYNODE_OPS11,		/* NHERE */
-	COPYNODE_OPS11,		/* NXHERE */
-	COPYNODE_OPS12,		/* NNOT */
-};
-
-#if NODE_CHARPTR != NODE_MBRMASK
-#error NODE_CHARPTR != NODE_MBRMASK!!!
-#endif
-#endif							/* defined(CALCSIZE_TABLE) || defined(COPYNODE_TABLE) */
-
-#ifdef COPYNODE_TABLE
-static union node *copynode(const union node *n)
+char *
+sstrdup(const char *p)
 {
-	union node *new;
-	const unsigned char *p;
-
-	if (n == NULL) {
-		return NULL;
-	}
-	new = funcblock;
-	new->type = n->type;
-	funcblock = (char *) funcblock + (int) nodesize[n->type];
-	p = copynode_ops + (int) copynode_ops_index[n->type];
-	do {
-		char *nn = ((char *) new) + ((int) (*p & NODE_OFFSETMASK));
-		const char *no = ((const char *) n) + ((int) (*p & NODE_OFFSETMASK));
-
-		if (!(*p & NODE_MBRMASK)) {	/* standard node */
-			*((union node **) nn) = copynode(*((const union node **) no));
-		} else if ((*p & NODE_MBRMASK) == NODE_CHARPTR) {	/* string */
-			*((const char **) nn) = nodesavestr(*((const char **) no));
-		} else if (*p & NODE_NODELIST) {	/* nodelist */
-			*((struct nodelist **) nn)
-				= copynodelist(*((const struct nodelist **) no));
-		} else {		/* integer */
-			*((int *) nn) = *((int *) no);
-		}
-	} while (!(*p++ & NODE_NOMORE));
-	return new;
+	size_t len = strlen(p) + 1;
+	return memcpy(stalloc(len), p, len);
 }
-#else							/* COPYNODE_TABLE */
-static union node *copynode(const union node *n)
+
+
+static void
+calcsize(union node *n)
 {
-	union node *new;
-
-	if (n == NULL)
-		return NULL;
-	new = funcblock;
-	funcblock = (char *) funcblock + nodesize[n->type];
-	switch (n->type) {
-	case NSEMI:
-	case NAND:
-	case NOR:
-	case NWHILE:
-	case NUNTIL:
-		new->nbinary.ch2 = copynode(n->nbinary.ch2);
-		new->nbinary.ch1 = copynode(n->nbinary.ch1);
-		break;
-	case NCMD:
-		new->ncmd.redirect = copynode(n->ncmd.redirect);
-		new->ncmd.args = copynode(n->ncmd.args);
-		new->ncmd.assign = copynode(n->ncmd.assign);
-		new->ncmd.backgnd = n->ncmd.backgnd;
-		break;
-	case NPIPE:
-		new->npipe.cmdlist = copynodelist(n->npipe.cmdlist);
-		new->npipe.backgnd = n->npipe.backgnd;
-		break;
-	case NREDIR:
-	case NBACKGND:
-	case NSUBSHELL:
-		new->nredir.redirect = copynode(n->nredir.redirect);
-		new->nredir.n = copynode(n->nredir.n);
-		break;
-	case NIF:
-		new->nif.elsepart = copynode(n->nif.elsepart);
-		new->nif.ifpart = copynode(n->nif.ifpart);
-		new->nif.test = copynode(n->nif.test);
-		break;
-	case NFOR:
-		new->nfor.var = nodesavestr(n->nfor.var);
-		new->nfor.body = copynode(n->nfor.body);
-		new->nfor.args = copynode(n->nfor.args);
-		break;
-	case NCASE:
-		new->ncase.cases = copynode(n->ncase.cases);
-		new->ncase.expr = copynode(n->ncase.expr);
-		break;
-	case NCLIST:
-		new->nclist.body = copynode(n->nclist.body);
-		new->nclist.pattern = copynode(n->nclist.pattern);
-		new->nclist.next = copynode(n->nclist.next);
-		break;
-	case NDEFUN:
-	case NARG:
-		new->narg.backquote = copynodelist(n->narg.backquote);
-		new->narg.text = nodesavestr(n->narg.text);
-		new->narg.next = copynode(n->narg.next);
-		break;
-	case NTO:
-	case NFROM:
-	case NFROMTO:
-	case NAPPEND:
-	case NTOOV:
-		new->nfile.fname = copynode(n->nfile.fname);
-		new->nfile.fd = n->nfile.fd;
-		new->nfile.next = copynode(n->nfile.next);
-		break;
-	case NTOFD:
-	case NFROMFD:
-		new->ndup.vname = copynode(n->ndup.vname);
-		new->ndup.dupfd = n->ndup.dupfd;
-		new->ndup.fd = n->ndup.fd;
-		new->ndup.next = copynode(n->ndup.next);
-		break;
-	case NHERE:
-	case NXHERE:
-		new->nhere.doc = copynode(n->nhere.doc);
-		new->nhere.fd = n->nhere.fd;
-		new->nhere.next = copynode(n->nhere.next);
-		break;
-	case NNOT:
-		new->nnot.com = copynode(n->nnot.com);
-		break;
-	};
-	new->type = n->type;
-	return new;
+      if (n == NULL)
+	    return;
+      funcblocksize += nodesize[n->type];
+      switch (n->type) {
+      case NCMD:
+	    calcsize(n->ncmd.redirect);
+	    calcsize(n->ncmd.args);
+	    calcsize(n->ncmd.assign);
+	    break;
+      case NPIPE:
+	    sizenodelist(n->npipe.cmdlist);
+	    break;
+      case NREDIR:
+      case NBACKGND:
+      case NSUBSHELL:
+	    calcsize(n->nredir.redirect);
+	    calcsize(n->nredir.n);
+	    break;
+      case NAND:
+      case NOR:
+      case NSEMI:
+      case NWHILE:
+      case NUNTIL:
+	    calcsize(n->nbinary.ch2);
+	    calcsize(n->nbinary.ch1);
+	    break;
+      case NIF:
+	    calcsize(n->nif.elsepart);
+	    calcsize(n->nif.ifpart);
+	    calcsize(n->nif.test);
+	    break;
+      case NFOR:
+	    funcstringsize += strlen(n->nfor.var) + 1;
+	    calcsize(n->nfor.body);
+	    calcsize(n->nfor.args);
+	    break;
+      case NCASE:
+	    calcsize(n->ncase.cases);
+	    calcsize(n->ncase.expr);
+	    break;
+      case NCLIST:
+	    calcsize(n->nclist.body);
+	    calcsize(n->nclist.pattern);
+	    calcsize(n->nclist.next);
+	    break;
+      case NDEFUN:
+      case NARG:
+	    sizenodelist(n->narg.backquote);
+	    funcstringsize += strlen(n->narg.text) + 1;
+	    calcsize(n->narg.next);
+	    break;
+      case NTO:
+      case NCLOBBER:
+      case NFROM:
+      case NFROMTO:
+      case NAPPEND:
+	    calcsize(n->nfile.fname);
+	    calcsize(n->nfile.next);
+	    break;
+      case NTOFD:
+      case NFROMFD:
+	    calcsize(n->ndup.vname);
+	    calcsize(n->ndup.next);
+	    break;
+      case NHERE:
+      case NXHERE:
+	    calcsize(n->nhere.doc);
+	    calcsize(n->nhere.next);
+	    break;
+      case NNOT:
+	    calcsize(n->nnot.com);
+	    break;
+      };
 }
-#endif							/* COPYNODE_TABLE */
 
-#ifdef CALCSIZE_TABLE
-static void calcsize(const union node *n)
-{
-	const unsigned char *p;
 
-	if (n == NULL)
-		return;
-	funcblocksize += (int) nodesize[n->type];
 
-	p = copynode_ops + (int) copynode_ops_index[n->type];
-	do {
-		const char *no = ((const char *) n) + ((int) (*p & NODE_OFFSETMASK));
-
-		if (!(*p & NODE_MBRMASK)) {	/* standard node */
-			calcsize(*((const union node **) no));
-		} else if ((*p & NODE_MBRMASK) == NODE_CHARPTR) {	/* string */
-			funcstringsize += strlen(*((const char **) no)) + 1;
-		} else if (*p & NODE_NODELIST) {	/* nodelist */
-			sizenodelist(*((const struct nodelist **) no));
-		}				/* else integer -- ignore */
-	} while (!(*p++ & NODE_NOMORE));
-}
-#else							/* CALCSIZE_TABLE */
-static void calcsize(const union node *n)
-{
-	if (n == NULL)
-		return;
-	funcblocksize += nodesize[n->type];
-	switch (n->type) {
-	case NSEMI:
-	case NAND:
-	case NOR:
-	case NWHILE:
-	case NUNTIL:
-		calcsize(n->nbinary.ch2);
-		calcsize(n->nbinary.ch1);
-		break;
-	case NCMD:
-		calcsize(n->ncmd.redirect);
-		calcsize(n->ncmd.args);
-		calcsize(n->ncmd.assign);
-		break;
-	case NPIPE:
-		sizenodelist(n->npipe.cmdlist);
-		break;
-	case NREDIR:
-	case NBACKGND:
-	case NSUBSHELL:
-		calcsize(n->nredir.redirect);
-		calcsize(n->nredir.n);
-		break;
-	case NIF:
-		calcsize(n->nif.elsepart);
-		calcsize(n->nif.ifpart);
-		calcsize(n->nif.test);
-		break;
-	case NFOR:
-		funcstringsize += strlen(n->nfor.var) + 1;
-		calcsize(n->nfor.body);
-		calcsize(n->nfor.args);
-		break;
-	case NCASE:
-		calcsize(n->ncase.cases);
-		calcsize(n->ncase.expr);
-		break;
-	case NCLIST:
-		calcsize(n->nclist.body);
-		calcsize(n->nclist.pattern);
-		calcsize(n->nclist.next);
-		break;
-	case NDEFUN:
-	case NARG:
-		sizenodelist(n->narg.backquote);
-		funcstringsize += strlen(n->narg.text) + 1;
-		calcsize(n->narg.next);
-		break;
-	case NTO:
-	case NFROM:
-	case NFROMTO:
-	case NAPPEND:
-	case NTOOV:
-		calcsize(n->nfile.fname);
-		calcsize(n->nfile.next);
-		break;
-	case NTOFD:
-	case NFROMFD:
-		calcsize(n->ndup.vname);
-		calcsize(n->ndup.next);
-		break;
-	case NHERE:
-	case NXHERE:
-		calcsize(n->nhere.doc);
-		calcsize(n->nhere.next);
-		break;
-	case NNOT:
-		calcsize(n->nnot.com);
-		break;
-	};
-}
-#endif							/* CALCSIZE_TABLE */
-
-static void sizenodelist(const struct nodelist *lp)
+static void
+sizenodelist(struct nodelist *lp)
 {
 	while (lp) {
-		funcblocksize += ALIGN(sizeof(struct nodelist));
+		funcblocksize += SHELL_ALIGN(sizeof(struct nodelist));
 		calcsize(lp->n);
 		lp = lp->next;
 	}
 }
 
 
-static struct nodelist *copynodelist(const struct nodelist *lp)
+
+static union node *
+copynode(union node *n)
+{
+      union node *new;
+
+      if (n == NULL)
+	    return NULL;
+      new = funcblock;
+      funcblock = (char *) funcblock + nodesize[n->type];
+      switch (n->type) {
+      case NCMD:
+	    new->ncmd.redirect = copynode(n->ncmd.redirect);
+	    new->ncmd.args = copynode(n->ncmd.args);
+	    new->ncmd.assign = copynode(n->ncmd.assign);
+	    break;
+      case NPIPE:
+	    new->npipe.cmdlist = copynodelist(n->npipe.cmdlist);
+	    new->npipe.backgnd = n->npipe.backgnd;
+	    break;
+      case NREDIR:
+      case NBACKGND:
+      case NSUBSHELL:
+	    new->nredir.redirect = copynode(n->nredir.redirect);
+	    new->nredir.n = copynode(n->nredir.n);
+	    break;
+      case NAND:
+      case NOR:
+      case NSEMI:
+      case NWHILE:
+      case NUNTIL:
+	    new->nbinary.ch2 = copynode(n->nbinary.ch2);
+	    new->nbinary.ch1 = copynode(n->nbinary.ch1);
+	    break;
+      case NIF:
+	    new->nif.elsepart = copynode(n->nif.elsepart);
+	    new->nif.ifpart = copynode(n->nif.ifpart);
+	    new->nif.test = copynode(n->nif.test);
+	    break;
+      case NFOR:
+	    new->nfor.var = nodesavestr(n->nfor.var);
+	    new->nfor.body = copynode(n->nfor.body);
+	    new->nfor.args = copynode(n->nfor.args);
+	    break;
+      case NCASE:
+	    new->ncase.cases = copynode(n->ncase.cases);
+	    new->ncase.expr = copynode(n->ncase.expr);
+	    break;
+      case NCLIST:
+	    new->nclist.body = copynode(n->nclist.body);
+	    new->nclist.pattern = copynode(n->nclist.pattern);
+	    new->nclist.next = copynode(n->nclist.next);
+	    break;
+      case NDEFUN:
+      case NARG:
+	    new->narg.backquote = copynodelist(n->narg.backquote);
+	    new->narg.text = nodesavestr(n->narg.text);
+	    new->narg.next = copynode(n->narg.next);
+	    break;
+      case NTO:
+      case NCLOBBER:
+      case NFROM:
+      case NFROMTO:
+      case NAPPEND:
+	    new->nfile.fname = copynode(n->nfile.fname);
+	    new->nfile.fd = n->nfile.fd;
+	    new->nfile.next = copynode(n->nfile.next);
+	    break;
+      case NTOFD:
+      case NFROMFD:
+	    new->ndup.vname = copynode(n->ndup.vname);
+	    new->ndup.dupfd = n->ndup.dupfd;
+	    new->ndup.fd = n->ndup.fd;
+	    new->ndup.next = copynode(n->ndup.next);
+	    break;
+      case NHERE:
+      case NXHERE:
+	    new->nhere.doc = copynode(n->nhere.doc);
+	    new->nhere.fd = n->nhere.fd;
+	    new->nhere.next = copynode(n->nhere.next);
+	    break;
+      case NNOT:
+	    new->nnot.com = copynode(n->nnot.com);
+	    break;
+      };
+      new->type = n->type;
+	return new;
+}
+
+
+static struct nodelist *
+copynodelist(struct nodelist *lp)
 {
 	struct nodelist *start;
 	struct nodelist **lpp;
@@ -8603,7 +8586,8 @@
 	lpp = &start;
 	while (lp) {
 		*lpp = funcblock;
-		funcblock = (char *) funcblock + ALIGN(sizeof(struct nodelist));
+		funcblock = (char *) funcblock +
+		    SHELL_ALIGN(sizeof(struct nodelist));
 		(*lpp)->n = copynode(lp->n);
 		lp = lp->next;
 		lpp = &(*lpp)->next;
@@ -8613,95 +8597,133 @@
 }
 
 
-static char *nodesavestr(const char *s)
-{
-	const char *p = s;
-	char *q = funcstring;
-	char *rtn = funcstring;
 
-	while ((*q++ = *p++) != '\0')
-		continue;
-	funcstring = q;
+static char *
+nodesavestr(char   *s)
+{
+	char   *rtn = funcstring;
+
+	funcstring = stpcpy(funcstring, s) + 1;
 	return rtn;
 }
 
-#ifdef CONFIG_ASH_GETOPTS
-static int getopts(char *, char *, char **, int *, int *);
-#endif
+
+
+/*
+ * Free a parse tree.
+ */
+
+static void
+freefunc(struct funcnode *f)
+{
+	if (f && --f->count < 0)
+		ckfree(f);
+}
+
+
+static void options(int);
+static void setoption(int, int);
+
 
 /*
  * Process the shell command line arguments.
  */
 
-static void procargs(int argc, char **argv)
+void
+procargs(int argc, char **argv)
 {
 	int i;
+	const char *xminusc;
+	char **xargv;
 
-	argptr = argv;
+	xargv = argv;
+	arg0 = xargv[0];
 	if (argc > 0)
-		argptr++;
+		xargv++;
 	for (i = 0; i < NOPTS; i++)
-		optent_val(i) = 2;
+		optlist[i] = 2;
+	argptr = xargv;
 	options(1);
-	if (*argptr == NULL && minusc == NULL)
+	xargv = argptr;
+	xminusc = minusc;
+	if (*xargv == NULL) {
+		if (xminusc)
+			error("-c requires an argument");
 		sflag = 1;
+	}
 	if (iflag == 2 && sflag == 1 && isatty(0) && isatty(1))
 		iflag = 1;
 	if (mflag == 2)
 		mflag = iflag;
 	for (i = 0; i < NOPTS; i++)
-		if (optent_val(i) == 2)
-			optent_val(i) = 0;
-	arg0 = argv[0];
-	if (sflag == 0 && minusc == NULL) {
-		commandname = argv[0];
-		arg0 = *argptr++;
-		setinputfile(arg0, 0);
+		if (optlist[i] == 2)
+			optlist[i] = 0;
+#if DEBUG == 2
+	debug = 1;
+#endif
+	/* POSIX 1003.2: first arg after -c cmd is $0, remainder $1... */
+	if (xminusc) {
+		minusc = *xargv++;
+		if (*xargv)
+			goto setarg0;
+	} else if (!sflag) {
+		setinputfile(*xargv, 0);
+setarg0:
+		arg0 = *xargv++;
 		commandname = arg0;
 	}
-	/* POSIX 1003.2: first arg after -c cmd is $0, remainder $1... */
-	if (argptr && minusc && *argptr)
-		arg0 = *argptr++;
 
-	shellparam.p = argptr;
+	shellparam.p = xargv;
+#ifdef CONFIG_ASH_GETOPTS
 	shellparam.optind = 1;
 	shellparam.optoff = -1;
+#endif
 	/* assert(shellparam.malloc == 0 && shellparam.nparam == 0); */
-	while (*argptr) {
+	while (*xargv) {
 		shellparam.nparam++;
-		argptr++;
+		xargv++;
 	}
 	optschanged();
 }
 
 
+void
+optschanged(void)
+{
+#ifdef DEBUG
+	opentrace();
+#endif
+	setinteractive(iflag);
+	setjobctl(mflag);
+}
 
-/*
- * Process shell options.  The global variable argptr contains a pointer
- * to the argument list; we advance it past the options.
- */
-
-static inline void minus_o(const char *name, int val)
+static inline void
+minus_o(char *name, int val)
 {
 	int i;
 
 	if (name == NULL) {
 		out1str("Current option settings\n");
 		for (i = 0; i < NOPTS; i++)
-			printf("%-16s%s\n", optent_name(optlist[i]),
-				   optent_val(i) ? "on" : "off");
+			out1fmt("%-16s%s\n", optnames(i),
+				optlist[i] ? "on" : "off");
 	} else {
 		for (i = 0; i < NOPTS; i++)
-			if (equal(name, optent_name(optlist[i]))) {
-				setoption(optent_letter(optlist[i]), val);
+			if (equal(name, optnames(i))) {
+				optlist[i] = val;
 				return;
 			}
 		error("Illegal option -o %s", name);
 	}
 }
 
+/*
+ * Process shell options.  The global variable argptr contains a pointer
+ * to the argument list; we advance it past the options.
+ */
 
-static void options(int cmdline)
+static void
+options(int cmdline)
 {
 	char *p;
 	int val;
@@ -8722,7 +8744,7 @@
 					else if (*argptr == NULL)
 						setparam(argptr);
 				}
-				break;	/* "-" or  "--" terminates options */
+				break;    /* "-" or  "--" terminates options */
 			}
 		} else if (c == '+') {
 			val = 0;
@@ -8732,23 +8754,12 @@
 		}
 		while ((c = *p++) != '\0') {
 			if (c == 'c' && cmdline) {
-				char *q;
-
-#ifdef NOHACK			/* removing this code allows sh -ce 'foo' for compat */
-				if (*p == '\0')
-#endif
-					q = *argptr++;
-				if (q == NULL || minusc != NULL)
-					error("Bad -c option");
-				minusc = q;
-#ifdef NOHACK
-				break;
-#endif
+				minusc = p;     /* command is after shell args*/
 			} else if (c == 'o') {
 				minus_o(*argptr, val);
 				if (*argptr)
 					argptr++;
-			} else if (cmdline && (c == '-')) {	// long options
+			} else if (cmdline && (c == '-')) {     // long options
 				if (strcmp(p, "login") == 0)
 					isloginsh = 1;
 				break;
@@ -8760,20 +8771,15 @@
 }
 
 
-static void setoption(int flag, int val)
+
+static void
+setoption(int flag, int val)
 {
 	int i;
 
 	for (i = 0; i < NOPTS; i++)
-		if (optent_letter(optlist[i]) == flag) {
-			optent_val(i) = val;
-			if (val) {
-				/* #%$ hack for ksh semantics */
-				if (flag == 'V')
-					Eflag = 0;
-				else if (flag == 'E')
-					Vflag = 0;
-			}
+		if (optletters(i) == flag) {
+			optlist[i] = val;
 			return;
 		}
 	error("Illegal option -%c", flag);
@@ -8786,24 +8792,27 @@
  * Set the shell parameters.
  */
 
-static void setparam(char **argv)
+void
+setparam(char **argv)
 {
 	char **newparam;
 	char **ap;
 	int nparam;
 
-	for (nparam = 0; argv[nparam]; nparam++);
-	ap = newparam = xmalloc((nparam + 1) * sizeof *ap);
+	for (nparam = 0 ; argv[nparam] ; nparam++);
+	ap = newparam = ckmalloc((nparam + 1) * sizeof *ap);
 	while (*argv) {
-		*ap++ = bb_xstrdup(*argv++);
+		*ap++ = savestr(*argv++);
 	}
 	*ap = NULL;
 	freeparam(&shellparam);
 	shellparam.malloc = 1;
 	shellparam.nparam = nparam;
 	shellparam.p = newparam;
+#ifdef CONFIG_ASH_GETOPTS
 	shellparam.optind = 1;
 	shellparam.optoff = -1;
+#endif
 }
 
 
@@ -8811,14 +8820,15 @@
  * Free the list of positional parameters.
  */
 
-static void freeparam(volatile struct shparam *param)
+void
+freeparam(volatile struct shparam *param)
 {
 	char **ap;
 
 	if (param->malloc) {
-		for (ap = param->p; *ap; ap++)
-			free(*ap);
-		free(param->p);
+		for (ap = param->p ; *ap ; ap++)
+			ckfree(*ap);
+		ckfree(param->p);
 	}
 }
 
@@ -8828,7 +8838,8 @@
  * The shift builtin command.
  */
 
-static int shiftcmd(int argc, char **argv)
+int
+shiftcmd(int argc, char **argv)
 {
 	int n;
 	char **ap1, **ap2;
@@ -8840,14 +8851,16 @@
 		error("can't shift that many");
 	INTOFF;
 	shellparam.nparam -= n;
-	for (ap1 = shellparam.p; --n >= 0; ap1++) {
+	for (ap1 = shellparam.p ; --n >= 0 ; ap1++) {
 		if (shellparam.malloc)
-			free(*ap1);
+			ckfree(*ap1);
 	}
 	ap2 = shellparam.p;
 	while ((*ap2++ = *ap1++) != NULL);
+#ifdef CONFIG_ASH_GETOPTS
 	shellparam.optind = 1;
 	shellparam.optoff = -1;
+#endif
 	INTON;
 	return 0;
 }
@@ -8858,10 +8871,11 @@
  * The set command builtin.
  */
 
-static int setcmd(int argc, char **argv)
+int
+setcmd(int argc, char **argv)
 {
 	if (argc == 1)
-		return showvarscmd(argc, argv);
+		return showvars(nullstr, 0, VUNSET);
 	INTOFF;
 	options(0);
 	optschanged();
@@ -8873,11 +8887,15 @@
 }
 
 
-static void getoptsreset(const char *value)
+#ifdef CONFIG_ASH_GETOPTS
+static void
+getoptsreset(value)
+	const char *value;
 {
 	shellparam.optind = number(value);
 	shellparam.optoff = -1;
 }
+#endif
 
 #ifdef CONFIG_LOCALE_SUPPORT
 static void change_lc_all(const char *value)
@@ -8895,74 +8913,18 @@
 #endif
 
 #ifdef CONFIG_ASH_GETOPTS
-/*
- * The getopts builtin.  Shellparam.optnext points to the next argument
- * to be processed.  Shellparam.optptr points to the next character to
- * be processed in the current argument.  If shellparam.optnext is NULL,
- * then it's the first time getopts has been called.
- */
-
-static int getoptscmd(int argc, char **argv)
-{
-	char **optbase;
-
-	if (argc < 3)
-		error("Usage: getopts optstring var [arg]");
-	else if (argc == 3) {
-		optbase = shellparam.p;
-		if (shellparam.optind > shellparam.nparam + 1) {
-			shellparam.optind = 1;
-			shellparam.optoff = -1;
-		}
-	} else {
-		optbase = &argv[3];
-		if (shellparam.optind > argc - 2) {
-			shellparam.optind = 1;
-			shellparam.optoff = -1;
-		}
-	}
-
-	return getopts(argv[1], argv[2], optbase, &shellparam.optind,
-				   &shellparam.optoff);
-}
-
-/*
- * Safe version of setvar, returns 1 on success 0 on failure.
- */
-
-static int setvarsafe(const char *name, const char *val, int flags)
-{
-	struct jmploc jmploc;
-	struct jmploc *volatile savehandler = handler;
-	int err = 0;
-
-#ifdef __GNUC__
-	(void) &err;
-#endif
-
-	if (setjmp(jmploc.loc))
-		err = 1;
-	else {
-		handler = &jmploc;
-		setvar(name, val, flags);
-	}
-	handler = savehandler;
-	return err;
-}
-
 static int
-getopts(char *optstr, char *optvar, char **optfirst, int *myoptind,
-		int *optoff)
+getopts(char *optstr, char *optvar, char **optfirst, int *param_optind, int *optoff)
 {
 	char *p, *q;
 	char c = '?';
 	int done = 0;
 	int err = 0;
 	char s[10];
-	char **optnext = optfirst + *myoptind - 1;
+	char **optnext = optfirst + *param_optind - 1;
 
-	if (*myoptind <= 1 || *optoff < 0 || !(*(optnext - 1)) ||
-		strlen(*(optnext - 1)) < *optoff)
+	if (*param_optind <= 1 || *optoff < 0 || !(*(optnext - 1)) ||
+	    strlen(*(optnext - 1)) < *optoff)
 		p = NULL;
 	else
 		p = *(optnext - 1) + *optoff;
@@ -8972,30 +8934,29 @@
 			return 1;
 		p = *optnext;
 		if (p == NULL || *p != '-' || *++p == '\0') {
-		  atend:
-			*myoptind = optnext - optfirst + 1;
+atend:
 			p = NULL;
 			done = 1;
 			goto out;
 		}
 		optnext++;
-		if (p[0] == '-' && p[1] == '\0')	/* check for "--" */
+		if (p[0] == '-' && p[1] == '\0')        /* check for "--" */
 			goto atend;
 	}
 
 	c = *p++;
-	for (q = optstr; *q != c;) {
+	for (q = optstr; *q != c; ) {
 		if (*q == '\0') {
 			if (optstr[0] == ':') {
 				s[0] = c;
 				s[1] = '\0';
 				err |= setvarsafe("OPTARG", s, 0);
 			} else {
-				out2fmt("Illegal option -%c\n", c);
+				fprintf(stderr, "Illegal option -%c\n", c);
 				(void) unsetvar("OPTARG");
 			}
 			c = '?';
-			goto bad;
+			goto out;
 		}
 		if (*++q == ':')
 			q++;
@@ -9009,40 +8970,70 @@
 				err |= setvarsafe("OPTARG", s, 0);
 				c = ':';
 			} else {
-				out2fmt("No arg for -%c option\n", c);
+				fprintf(stderr, "No arg for -%c option\n", c);
 				(void) unsetvar("OPTARG");
 				c = '?';
 			}
-			goto bad;
+			goto out;
 		}
 
 		if (p == *optnext)
 			optnext++;
-		setvarsafe("OPTARG", p, 0);
+		err |= setvarsafe("OPTARG", p, 0);
 		p = NULL;
 	} else
-		setvarsafe("OPTARG", "", 0);
-	*myoptind = optnext - optfirst + 1;
-	goto out;
+		err |= setvarsafe("OPTARG", nullstr, 0);
 
-  bad:
-	*myoptind = 1;
-	p = NULL;
-  out:
+out:
 	*optoff = p ? p - *(optnext - 1) : -1;
-	snprintf(s, sizeof(s), "%d", *myoptind);
+	*param_optind = optnext - optfirst + 1;
+	fmtstr(s, sizeof(s), "%d", *param_optind);
 	err |= setvarsafe("OPTIND", s, VNOFUNC);
 	s[0] = c;
 	s[1] = '\0';
 	err |= setvarsafe(optvar, s, 0);
 	if (err) {
-		*myoptind = 1;
+		*param_optind = 1;
 		*optoff = -1;
+		flushall();
 		exraise(EXERROR);
 	}
 	return done;
 }
-#endif
+
+/*
+ * The getopts builtin.  Shellparam.optnext points to the next argument
+ * to be processed.  Shellparam.optptr points to the next character to
+ * be processed in the current argument.  If shellparam.optnext is NULL,
+ * then it's the first time getopts has been called.
+ */
+
+int
+getoptscmd(int argc, char **argv)
+{
+	char **optbase;
+
+	if (argc < 3)
+		error("Usage: getopts optstring var [arg]");
+	else if (argc == 3) {
+		optbase = shellparam.p;
+		if (shellparam.optind > shellparam.nparam + 1) {
+			shellparam.optind = 1;
+			shellparam.optoff = -1;
+		}
+	}
+	else {
+		optbase = &argv[3];
+		if (shellparam.optind > argc - 2) {
+			shellparam.optind = 1;
+			shellparam.optoff = -1;
+		}
+	}
+
+	return getopts(argv[1], argv[2], optbase, &shellparam.optind,
+		       &shellparam.optoff);
+}
+#endif /* CONFIG_ASH_GETOPTS */
 
 /*
  * XXX - should get rid of.  have all builtins use getopt(3).  the
@@ -9055,7 +9046,8 @@
  * end of input.
  */
 
-static int nextopt(const char *optstring)
+static int
+nextopt(const char *optstring)
 {
 	char *p;
 	const char *q;
@@ -9066,11 +9058,11 @@
 		if (p == NULL || *p != '-' || *++p == '\0')
 			return '\0';
 		argptr++;
-		if (p[0] == '-' && p[1] == '\0')	/* check for "--" */
+		if (p[0] == '-' && p[1] == '\0')        /* check for "--" */
 			return '\0';
 	}
 	c = *p++;
-	for (q = optstring; *q != c;) {
+	for (q = optstring ; *q != c ; ) {
 		if (*q == '\0')
 			error("Illegal option -%c", c);
 		if (*++q == ':')
@@ -9086,52 +9078,94 @@
 	return c;
 }
 
-static void flushall()
+/*      $NetBSD: output.c,v 1.27 2002/11/24 22:35:42 christos Exp $     */
+
+
+
+void
+outstr(const char *p, FILE *file)
+{
+	INTOFF;
+	fputs(p, file);
+	INTON;
+}
+
+void
+flushall(void)
 {
 	INTOFF;
 	fflush(stdout);
+	fflush(stderr);
 	INTON;
 }
 
 
-static void out2fmt(const char *fmt, ...)
+void
+flushout(FILE *dest)
+{
+	INTOFF;
+	fflush(dest);
+	INTON;
+}
+
+static void
+outcslow(int c, FILE *dest)
+{
+	INTOFF;
+	putc(c, dest);
+	fflush(dest);
+	INTON;
+}
+
+
+static int
+out1fmt(const char *fmt, ...)
 {
 	va_list ap;
+	int r;
+
+	INTOFF;
+	va_start(ap, fmt);
+	r = vprintf(fmt, ap);
+	va_end(ap);
+	INTON;
+	return r;
+}
+
+
+int
+fmtstr(char *outbuf, size_t length, const char *fmt, ...)
+{
+	va_list ap;
+	int ret;
 
 	va_start(ap, fmt);
-	vfprintf(stderr, fmt, ap);
+	INTOFF;
+	ret = vsnprintf(outbuf, length, fmt, ap);
 	va_end(ap);
+	INTON;
+	return ret;
 }
 
+
 /*
  * Version of write which resumes after a signal is caught.
  */
 
-static int xwrite(int fd, const char *buf, int nbytes)
+static void
+xwrite(int fd, const void *p, size_t n)
 {
-	int ntry;
-	int i;
-	int n;
+	ssize_t i;
 
-	n = nbytes;
-	ntry = 0;
-	for (;;) {
-		i = write(fd, buf, n);
-		if (i > 0) {
-			if ((n -= i) <= 0)
-				return nbytes;
-			buf += i;
-			ntry = 0;
-		} else if (i == 0) {
-			if (++ntry > 10)
-				return nbytes - n;
-		} else if (errno != EINTR) {
-			return -1;
-		}
-	}
+	do {
+		i = bb_full_write(fd, p, n);
+	} while (i < 0 && errno == EINTR);
 }
 
 
+/*      $NetBSD: parser.c,v 1.54 2002/11/24 22:35:42 christos Exp $     */
+
+
 /*
  * Shell command parser.
  */
@@ -9139,61 +9173,66 @@
 #define EOFMARKLEN 79
 
 
-
 struct heredoc {
-	struct heredoc *next;	/* next here document in list */
-	union node *here;	/* redirection node */
-	char *eofmark;		/* string indicating end of input */
-	int striptabs;		/* if set, strip leading tabs */
+	struct heredoc *next;   /* next here document in list */
+	union node *here;               /* redirection node */
+	char *eofmark;          /* string indicating end of input */
+	int striptabs;          /* if set, strip leading tabs */
 };
 
-static struct heredoc *heredoclist;	/* list of here documents to read */
-static int parsebackquote;	/* nonzero if we are inside backquotes */
-static int doprompt;	/* if set, prompt the user */
-static int needprompt;	/* true if interactive and at start of line */
-static int lasttoken;	/* last token read */
 
-static char *wordtext;	/* text of last word returned by readtoken */
 
-static struct nodelist *backquotelist;
-static union node *redirnode;
-static struct heredoc *heredoc;
-static int quoteflag;	/* set if (part of) last token was quoted */
-static int startlinno;	/* line # where last token started */
+static struct heredoc *heredoclist;    /* list of here documents to read */
 
 
 static union node *list(int);
 static union node *andor(void);
 static union node *pipeline(void);
 static union node *command(void);
-static union node *simplecmd(union node **rpp, union node *redir);
+static union node *simplecmd(void);
+static union node *makename(void);
 static void parsefname(void);
 static void parseheredoc(void);
 static char peektoken(void);
 static int readtoken(void);
 static int xxreadtoken(void);
-static int readtoken1(int, int, const char *, int);
+static int readtoken1(int firstc, int syntax, char *eofmark, int striptabs);
 static int noexpand(char *);
-static void synexpect(int) __attribute__ ((noreturn));
-static void synerror(const char *) __attribute__ ((noreturn));
+static void synexpect(int) __attribute__((__noreturn__));
+static void synerror(const char *) __attribute__((__noreturn__));
 static void setprompt(int);
 
 
+static inline int
+goodname(const char *p)
+{
+	return !*endofname(p);
+}
+
+static inline int
+isassignment(const char *p)
+{
+	const char *q = endofname(p);
+	if (p == q)
+		return 0;
+	return *q == '=';
+}
+
+
 /*
  * Read and parse a command.  Returns NEOF on end of file.  (NULL is a
  * valid parse tree indicating a blank line.)
  */
 
-static union node *parsecmd(int interact)
+union node *
+parsecmd(int interact)
 {
 	int t;
 
 	tokpushback = 0;
 	doprompt = interact;
 	if (doprompt)
-		setprompt(1);
-	else
-		setprompt(0);
+		setprompt(doprompt);
 	needprompt = 0;
 	t = readtoken();
 	if (t == TEOF)
@@ -9205,35 +9244,37 @@
 }
 
 
-static union node *list(int nlflag)
+static union node *
+list(int nlflag)
 {
 	union node *n1, *n2, *n3;
 	int tok;
 
-	checkkwd = 2;
-	if (nlflag == 0 && peektoken())
+	checkkwd = CHKNL | CHKKWD | CHKALIAS;
+	if (nlflag == 2 && peektoken())
 		return NULL;
 	n1 = NULL;
 	for (;;) {
 		n2 = andor();
 		tok = readtoken();
 		if (tok == TBACKGND) {
-			if (n2->type == NCMD || n2->type == NPIPE) {
-				n2->ncmd.backgnd = 1;
-			} else if (n2->type == NREDIR) {
-				n2->type = NBACKGND;
+			if (n2->type == NPIPE) {
+				n2->npipe.backgnd = 1;
 			} else {
-				n3 = (union node *) stalloc(sizeof(struct nredir));
-				n3->type = NBACKGND;
-				n3->nredir.n = n2;
-				n3->nredir.redirect = NULL;
-				n2 = n3;
+				if (n2->type != NREDIR) {
+					n3 = stalloc(sizeof(struct nredir));
+					n3->nredir.n = n2;
+					n3->nredir.redirect = NULL;
+					n2 = n3;
+				}
+				n2->type = NBACKGND;
 			}
 		}
 		if (n1 == NULL) {
 			n1 = n2;
-		} else {
-			n3 = (union node *) stalloc(sizeof(struct nbinary));
+		}
+		else {
+			n3 = (union node *)stalloc(sizeof (struct nbinary));
 			n3->type = NSEMI;
 			n3->nbinary.ch1 = n1;
 			n3->nbinary.ch2 = n2;
@@ -9247,12 +9288,12 @@
 		case TNL:
 			if (tok == TNL) {
 				parseheredoc();
-				if (nlflag)
+				if (nlflag == 1)
 					return n1;
 			} else {
 				tokpushback++;
 			}
-			checkkwd = 2;
+			checkkwd = CHKNL | CHKKWD | CHKALIAS;
 			if (peektoken())
 				return n1;
 			break;
@@ -9260,10 +9301,10 @@
 			if (heredoclist)
 				parseheredoc();
 			else
-				pungetc();	/* push back EOF on input */
+				pungetc();              /* push back EOF on input */
 			return n1;
 		default:
-			if (nlflag)
+			if (nlflag == 1)
 				synexpect(-1);
 			tokpushback++;
 			return n1;
@@ -9273,12 +9314,12 @@
 
 
 
-static union node *andor()
+static union node *
+andor(void)
 {
 	union node *n1, *n2, *n3;
 	int t;
 
-	checkkwd = 1;
 	n1 = pipeline();
 	for (;;) {
 		if ((t = readtoken()) == TAND) {
@@ -9289,9 +9330,9 @@
 			tokpushback++;
 			return n1;
 		}
-		checkkwd = 2;
+		checkkwd = CHKNL | CHKKWD | CHKALIAS;
 		n2 = pipeline();
-		n3 = (union node *) stalloc(sizeof(struct nbinary));
+		n3 = (union node *)stalloc(sizeof (struct nbinary));
 		n3->type = t;
 		n3->nbinary.ch1 = n1;
 		n3->nbinary.ch2 = n2;
@@ -9301,7 +9342,8 @@
 
 
 
-static union node *pipeline()
+static union node *
+pipeline(void)
 {
 	union node *n1, *n2, *pipenode;
 	struct nodelist *lp, *prev;
@@ -9311,21 +9353,21 @@
 	TRACE(("pipeline: entered\n"));
 	if (readtoken() == TNOT) {
 		negate = !negate;
-		checkkwd = 1;
+		checkkwd = CHKKWD | CHKALIAS;
 	} else
 		tokpushback++;
 	n1 = command();
 	if (readtoken() == TPIPE) {
-		pipenode = (union node *) stalloc(sizeof(struct npipe));
+		pipenode = (union node *)stalloc(sizeof (struct npipe));
 		pipenode->type = NPIPE;
 		pipenode->npipe.backgnd = 0;
-		lp = (struct nodelist *) stalloc(sizeof(struct nodelist));
+		lp = (struct nodelist *)stalloc(sizeof (struct nodelist));
 		pipenode->npipe.cmdlist = lp;
 		lp->n = n1;
 		do {
 			prev = lp;
-			lp = (struct nodelist *) stalloc(sizeof(struct nodelist));
-			checkkwd = 2;
+			lp = (struct nodelist *)stalloc(sizeof (struct nodelist));
+			checkkwd = CHKNL | CHKKWD | CHKALIAS;
 			lp->n = command();
 			prev->next = lp;
 		} while (readtoken() == TPIPE);
@@ -9334,7 +9376,7 @@
 	}
 	tokpushback++;
 	if (negate) {
-		n2 = (union node *) stalloc(sizeof(struct nnot));
+		n2 = (union node *)stalloc(sizeof (struct nnot));
 		n2->type = NNOT;
 		n2->nnot.com = n1;
 		return n2;
@@ -9344,29 +9386,25 @@
 
 
 
-static union node *command(void)
+static union node *
+command(void)
 {
 	union node *n1, *n2;
 	union node *ap, **app;
 	union node *cp, **cpp;
 	union node *redir, **rpp;
+	union node **rpp2;
 	int t;
 
 	redir = NULL;
-	n1 = NULL;
-	rpp = &redir;
-
-	/* Check for redirection which may precede command */
-	while (readtoken() == TREDIR) {
-		*rpp = n2 = redirnode;
-		rpp = &n2->nfile.next;
-		parsefname();
-	}
-	tokpushback++;
+	rpp2 = &redir;
 
 	switch (readtoken()) {
+	default:
+		synexpect(-1);
+		/* NOTREACHED */
 	case TIF:
-		n1 = (union node *) stalloc(sizeof(struct nif));
+		n1 = (union node *)stalloc(sizeof (struct nif));
 		n1->type = NIF;
 		n1->nif.test = list(0);
 		if (readtoken() != TTHEN)
@@ -9374,7 +9412,7 @@
 		n1->nif.ifpart = list(0);
 		n2 = n1;
 		while (readtoken() == TELIF) {
-			n2->nif.elsepart = (union node *) stalloc(sizeof(struct nif));
+			n2->nif.elsepart = (union node *)stalloc(sizeof (struct nif));
 			n2 = n2->nif.elsepart;
 			n2->type = NIF;
 			n2->nif.test = list(0);
@@ -9388,38 +9426,33 @@
 			n2->nif.elsepart = NULL;
 			tokpushback++;
 		}
-		if (readtoken() != TFI)
-			synexpect(TFI);
-		checkkwd = 1;
+		t = TFI;
 		break;
 	case TWHILE:
-	case TUNTIL:{
+	case TUNTIL: {
 		int got;
-		n1 = (union node *) stalloc(sizeof(struct nbinary));
-		n1->type = (lasttoken == TWHILE) ? NWHILE : NUNTIL;
+		n1 = (union node *)stalloc(sizeof (struct nbinary));
+		n1->type = (lasttoken == TWHILE)? NWHILE : NUNTIL;
 		n1->nbinary.ch1 = list(0);
-		if ((got = readtoken()) != TDO) {
-			TRACE(("expecting DO got %s %s\n", tokname(got),
-				   got == TWORD ? wordtext : ""));
+		if ((got=readtoken()) != TDO) {
+TRACE(("expecting DO got %s %s\n", tokname(got), got == TWORD ? wordtext : ""));
 			synexpect(TDO);
 		}
 		n1->nbinary.ch2 = list(0);
-		if (readtoken() != TDONE)
-			synexpect(TDONE);
-		checkkwd = 1;
+		t = TDONE;
 		break;
 	}
 	case TFOR:
-		if (readtoken() != TWORD || quoteflag || !goodname(wordtext))
+		if (readtoken() != TWORD || quoteflag || ! goodname(wordtext))
 			synerror("Bad for loop variable");
-		n1 = (union node *) stalloc(sizeof(struct nfor));
+		n1 = (union node *)stalloc(sizeof (struct nfor));
 		n1->type = NFOR;
 		n1->nfor.var = wordtext;
-		checkkwd = 1;
+		checkkwd = CHKKWD | CHKALIAS;
 		if (readtoken() == TIN) {
 			app = &ap;
 			while (readtoken() == TWORD) {
-				n2 = (union node *) stalloc(sizeof(struct narg));
+				n2 = (union node *)stalloc(sizeof (struct narg));
 				n2->type = NARG;
 				n2->narg.text = wordtext;
 				n2->narg.backquote = backquotelist;
@@ -9431,12 +9464,9 @@
 			if (lasttoken != TNL && lasttoken != TSEMI)
 				synexpect(-1);
 		} else {
-			static char argvars[5] = { CTLVAR, VSNORMAL | VSQUOTE,
-				'@', '=', '\0'
-			};
-			n2 = (union node *) stalloc(sizeof(struct narg));
+			n2 = (union node *)stalloc(sizeof (struct narg));
 			n2->type = NARG;
-			n2->narg.text = argvars;
+			n2->narg.text = (char *)dolatstr;
 			n2->narg.backquote = NULL;
 			n2->narg.next = NULL;
 			n1->nfor.args = n2;
@@ -9447,43 +9477,43 @@
 			if (lasttoken != TNL && lasttoken != TSEMI)
 				tokpushback++;
 		}
-		checkkwd = 2;
+		checkkwd = CHKNL | CHKKWD | CHKALIAS;
 		if (readtoken() != TDO)
 			synexpect(TDO);
 		n1->nfor.body = list(0);
-		if (readtoken() != TDONE)
-			synexpect(TDONE);
-		checkkwd = 1;
+		t = TDONE;
 		break;
 	case TCASE:
-		n1 = (union node *) stalloc(sizeof(struct ncase));
+		n1 = (union node *)stalloc(sizeof (struct ncase));
 		n1->type = NCASE;
 		if (readtoken() != TWORD)
 			synexpect(TWORD);
-		n1->ncase.expr = n2 = (union node *) stalloc(sizeof(struct narg));
+		n1->ncase.expr = n2 = (union node *)stalloc(sizeof (struct narg));
 		n2->type = NARG;
 		n2->narg.text = wordtext;
 		n2->narg.backquote = backquotelist;
 		n2->narg.next = NULL;
 		do {
-			checkkwd = 1;
+			checkkwd = CHKKWD | CHKALIAS;
 		} while (readtoken() == TNL);
 		if (lasttoken != TIN)
-			synerror("expecting \"in\"");
+			synexpect(TIN);
 		cpp = &n1->ncase.cases;
-		checkkwd = 2, readtoken();
-		do {
+next_case:
+		checkkwd = CHKNL | CHKKWD;
+		t = readtoken();
+		while(t != TESAC) {
 			if (lasttoken == TLP)
 				readtoken();
-			*cpp = cp = (union node *) stalloc(sizeof(struct nclist));
+			*cpp = cp = (union node *)stalloc(sizeof (struct nclist));
 			cp->type = NCLIST;
 			app = &cp->nclist.pattern;
 			for (;;) {
-				*app = ap = (union node *) stalloc(sizeof(struct narg));
+				*app = ap = (union node *)stalloc(sizeof (struct narg));
 				ap->type = NARG;
 				ap->narg.text = wordtext;
 				ap->narg.backquote = backquotelist;
-				if (checkkwd = 2, readtoken() != TPIPE)
+				if (readtoken() != TPIPE)
 					break;
 				app = &ap->narg.next;
 				readtoken();
@@ -9491,59 +9521,44 @@
 			ap->narg.next = NULL;
 			if (lasttoken != TRP)
 				synexpect(TRP);
-			cp->nclist.body = list(0);
+			cp->nclist.body = list(2);
 
-			checkkwd = 2;
+			cpp = &cp->nclist.next;
+
+			checkkwd = CHKNL | CHKKWD;
 			if ((t = readtoken()) != TESAC) {
 				if (t != TENDCASE)
 					synexpect(TENDCASE);
 				else
-					checkkwd = 2, readtoken();
+					goto next_case;
 			}
-			cpp = &cp->nclist.next;
-		} while (lasttoken != TESAC);
+		}
 		*cpp = NULL;
-		checkkwd = 1;
-		break;
+		goto redir;
 	case TLP:
-		n1 = (union node *) stalloc(sizeof(struct nredir));
+		n1 = (union node *)stalloc(sizeof (struct nredir));
 		n1->type = NSUBSHELL;
 		n1->nredir.n = list(0);
 		n1->nredir.redirect = NULL;
-		if (readtoken() != TRP)
-			synexpect(TRP);
-		checkkwd = 1;
+		t = TRP;
 		break;
 	case TBEGIN:
 		n1 = list(0);
-		if (readtoken() != TEND)
-			synexpect(TEND);
-		checkkwd = 1;
+		t = TEND;
 		break;
-		/* Handle an empty command like other simple commands.  */
-	case TSEMI:
-	case TAND:
-	case TOR:
-	case TNL:
-	case TEOF:
-	case TRP:
-	case TBACKGND:
-		/*
-		 * An empty command before a ; doesn't make much sense, and
-		 * should certainly be disallowed in the case of `if ;'.
-		 */
-		if (!redir)
-			synexpect(-1);
 	case TWORD:
+	case TREDIR:
 		tokpushback++;
-		n1 = simplecmd(rpp, redir);
-		return n1;
-	default:
-		synexpect(-1);
-		/* NOTREACHED */
+		return simplecmd();
 	}
 
+	if (readtoken() != t)
+		synexpect(t);
+
+redir:
 	/* Now check for redirection which may follow command */
+	checkkwd = CHKKWD | CHKALIAS;
+	rpp = rpp2;
 	while (readtoken() == TREDIR) {
 		*rpp = n2 = redirnode;
 		rpp = &n2->nfile.next;
@@ -9553,7 +9568,7 @@
 	*rpp = NULL;
 	if (redir) {
 		if (n1->type != NSUBSHELL) {
-			n2 = (union node *) stalloc(sizeof(struct nredir));
+			n2 = (union node *)stalloc(sizeof (struct nredir));
 			n2->type = NREDIR;
 			n2->nredir.n = n1;
 			n1 = n2;
@@ -9565,56 +9580,65 @@
 }
 
 
-static union node *simplecmd(union node **rpp, union node *redir)
-{
+static union node *
+simplecmd(void) {
 	union node *args, **app;
 	union node *n = NULL;
 	union node *vars, **vpp;
-	union node **orig_rpp;
+	union node **rpp, *redir;
+	int savecheckkwd;
 
 	args = NULL;
 	app = &args;
 	vars = NULL;
 	vpp = &vars;
+	redir = NULL;
+	rpp = &redir;
 
-	/* If we don't have any redirections already, then we must reset
-	   rpp to be the address of the local redir variable.  */
-	if (redir == 0)
-		rpp = &redir;
-	/* We save the incoming value, because we need this for shell
-	   functions.  There can not be a redirect or an argument between
-	   the function name and the open parenthesis.  */
-	orig_rpp = rpp;
-
-	checkalias = 2;
+	savecheckkwd = CHKALIAS;
 	for (;;) {
+		checkkwd = savecheckkwd;
 		switch (readtoken()) {
 		case TWORD:
-		case TASSIGN:
-			n = (union node *) stalloc(sizeof(struct narg));
+			n = (union node *)stalloc(sizeof (struct narg));
 			n->type = NARG;
 			n->narg.text = wordtext;
 			n->narg.backquote = backquotelist;
-			if (lasttoken == TWORD) {
-				*app = n;
-				app = &n->narg.next;
-			} else {
+			if (savecheckkwd && isassignment(wordtext)) {
 				*vpp = n;
 				vpp = &n->narg.next;
+			} else {
+				*app = n;
+				app = &n->narg.next;
+				savecheckkwd = 0;
 			}
 			break;
 		case TREDIR:
 			*rpp = n = redirnode;
 			rpp = &n->nfile.next;
-			parsefname();	/* read name of redirection file */
+			parsefname();   /* read name of redirection file */
 			break;
 		case TLP:
-			if (args && app == &args->narg.next && !vars && rpp == orig_rpp) {
+			if (
+				args && app == &args->narg.next &&
+				!vars && !redir
+			) {
+				struct builtincmd *bcmd;
+				const char *name;
+
 				/* We have a function */
 				if (readtoken() != TRP)
 					synexpect(TRP);
+				name = n->narg.text;
+				if (
+					!goodname(name) || (
+						(bcmd = find_builtin(name)) &&
+						IS_BUILTIN_SPECIAL(bcmd)
+					)
+				)
+					synerror("Bad function name");
 				n->type = NDEFUN;
-				checkkwd = 2;
+				checkkwd = CHKNL | CHKKWD | CHKALIAS;
 				n->narg.next = command();
 				return n;
 			}
@@ -9624,24 +9648,24 @@
 			goto out;
 		}
 	}
-  out:
+out:
 	*app = NULL;
 	*vpp = NULL;
 	*rpp = NULL;
-	n = (union node *) stalloc(sizeof(struct ncmd));
+	n = (union node *)stalloc(sizeof (struct ncmd));
 	n->type = NCMD;
-	n->ncmd.backgnd = 0;
 	n->ncmd.args = args;
 	n->ncmd.assign = vars;
 	n->ncmd.redirect = redir;
 	return n;
 }
 
-static union node *makename(void)
+static union node *
+makename(void)
 {
 	union node *n;
 
-	n = (union node *) stalloc(sizeof(struct narg));
+	n = (union node *)stalloc(sizeof (struct narg));
 	n->type = NARG;
 	n->narg.next = NULL;
 	n->narg.text = wordtext;
@@ -9649,7 +9673,7 @@
 	return n;
 }
 
-static void fixredir(union node *n, const char *text, int err)
+void fixredir(union node *n, const char *text, int err)
 {
 	TRACE(("Fix redir %s %d\n", text, err));
 	if (!err)
@@ -9669,7 +9693,8 @@
 }
 
 
-static void parsefname(void)
+static void
+parsefname(void)
 {
 	union node *n = redirnode;
 
@@ -9683,12 +9708,7 @@
 		if (quoteflag == 0)
 			n->type = NXHERE;
 		TRACE(("Here document %d\n", n->type));
-		if (here->striptabs) {
-			while (*wordtext == '\t')
-				wordtext++;
-		}
-		if (!noexpand(wordtext) || (i = strlen(wordtext)) == 0
-			|| i > EOFMARKLEN)
+		if (! noexpand(wordtext) || (i = strlen(wordtext)) == 0 || i > EOFMARKLEN)
 			synerror("Illegal eof marker for << redirection");
 		rmescapes(wordtext);
 		here->eofmark = wordtext;
@@ -9696,7 +9716,7 @@
 		if (heredoclist == NULL)
 			heredoclist = here;
 		else {
-			for (p = heredoclist; p->next; p = p->next);
+			for (p = heredoclist ; p->next ; p = p->next);
 			p->next = here;
 		}
 	} else if (n->type == NTOFD || n->type == NFROMFD) {
@@ -9711,30 +9731,33 @@
  * Input any here documents.
  */
 
-static void parseheredoc()
+static void
+parseheredoc(void)
 {
 	struct heredoc *here;
 	union node *n;
 
-	while (heredoclist) {
-		here = heredoclist;
-		heredoclist = here->next;
+	here = heredoclist;
+	heredoclist = 0;
+
+	while (here) {
 		if (needprompt) {
 			setprompt(2);
 			needprompt = 0;
 		}
-		readtoken1(pgetc(), here->here->type == NHERE ? SQSYNTAX : DQSYNTAX,
-				   here->eofmark, here->striptabs);
-		n = (union node *) stalloc(sizeof(struct narg));
+		readtoken1(pgetc(), here->here->type == NHERE? SQSYNTAX : DQSYNTAX,
+				here->eofmark, here->striptabs);
+		n = (union node *)stalloc(sizeof (struct narg));
 		n->narg.type = NARG;
 		n->narg.next = NULL;
 		n->narg.text = wordtext;
 		n->narg.backquote = backquotelist;
 		here->here->nhere.doc = n;
+		here = here->next;
 	}
 }
 
-static char peektoken()
+static char peektoken(void)
 {
 	int t;
 
@@ -9743,83 +9766,65 @@
 	return tokname_array[t][0];
 }
 
-static int readtoken()
+static int
+readtoken(void)
 {
 	int t;
-
-	int savecheckalias = checkalias;
-
-#ifdef CONFIG_ASH_ALIAS
-	int savecheckkwd = checkkwd;
-	struct alias *ap;
-#endif
-
 #ifdef DEBUG
 	int alreadyseen = tokpushback;
 #endif
 
 #ifdef CONFIG_ASH_ALIAS
-  top:
+top:
 #endif
 
 	t = xxreadtoken();
 
-	checkalias = savecheckalias;
-
-	if (checkkwd) {
-		/*
-		 * eat newlines
-		 */
-		if (checkkwd == 2) {
-			checkkwd = 0;
-			while (t == TNL) {
-				parseheredoc();
-				t = xxreadtoken();
-			}
-		}
-		checkkwd = 0;
-		/*
-		 * check for keywords
-		 */
-		if (t == TWORD && !quoteflag) {
-			const char *const *pp;
-
-			if ((pp = findkwd(wordtext))) {
-				lasttoken = t = pp - tokname_array;
-				TRACE(("keyword %s recognized\n", tokname(t)));
-				goto out;
-			}
+	/*
+	 * eat newlines
+	 */
+	if (checkkwd & CHKNL) {
+		while (t == TNL) {
+			parseheredoc();
+			t = xxreadtoken();
 		}
 	}
 
+	if (t != TWORD || quoteflag) {
+		goto out;
+	}
 
-	if (t != TWORD) {
-		if (t != TREDIR) {
-			checkalias = 0;
+	/*
+	 * check for keywords
+	 */
+	if (checkkwd & CHKKWD) {
+		const char *const *pp;
+
+		if ((pp = findkwd(wordtext))) {
+			lasttoken = t = pp - tokname_array;
+			TRACE(("keyword %s recognized\n", tokname(t)));
+			goto out;
 		}
-	} else if (checkalias == 2 && isassignment(wordtext)) {
-		lasttoken = t = TASSIGN;
-	} else if (checkalias) {
+	}
+
+	if (checkkwd & CHKALIAS) {
 #ifdef CONFIG_ASH_ALIAS
-		if (!quoteflag && (ap = *__lookupalias(wordtext)) != NULL
-			&& !(ap->flag & ALIASINUSE)) {
+		struct alias *ap;
+		if ((ap = lookupalias(wordtext, 1)) != NULL) {
 			if (*ap->val) {
-				pushstring(ap->val, strlen(ap->val), ap);
+				pushstring(ap->val, ap);
 			}
-			checkkwd = savecheckkwd;
 			goto top;
 		}
 #endif
-		checkalias = 0;
 	}
-  out:
+out:
+	checkkwd = 0;
 #ifdef DEBUG
 	if (!alreadyseen)
-		TRACE(("token %s %s\n", tokname(t), t == TWORD
-			   || t == TASSIGN ? wordtext : ""));
+	    TRACE(("token %s %s\n", tokname(t), t == TWORD ? wordtext : ""));
 	else
-		TRACE(("reread token %s %s\n", tokname(t), t == TWORD
-			   || t == TASSIGN ? wordtext : ""));
+	    TRACE(("reread token %s %s\n", tokname(t), t == TWORD ? wordtext : ""));
 #endif
 	return (t);
 }
@@ -9843,89 +9848,10 @@
  *  have parseword (readtoken1?) handle both words and redirection.]
  */
 
-#define NEW_xxreadtoken
-#ifdef NEW_xxreadtoken
-
-static const char xxreadtoken_chars[] = "\n()&|;";	/* singles must be first! */
-static const char xxreadtoken_tokens[] = {
-	TNL, TLP, TRP,		/* only single occurrence allowed */
-	TBACKGND, TPIPE, TSEMI,	/* if single occurrence */
-	TEOF,				/* corresponds to trailing nul */
-	TAND, TOR, TENDCASE,	/* if double occurrence */
-};
-
-#define xxreadtoken_doubles \
-	(sizeof(xxreadtoken_tokens) - sizeof(xxreadtoken_chars))
-#define xxreadtoken_singles \
-	(sizeof(xxreadtoken_chars) - xxreadtoken_doubles - 1)
-
-static int xxreadtoken()
-{
-	int c;
-
-	if (tokpushback) {
-		tokpushback = 0;
-		return lasttoken;
-	}
-	if (needprompt) {
-		setprompt(2);
-		needprompt = 0;
-	}
-	startlinno = plinno;
-	for (;;) {			/* until token or start of word found */
-		c = pgetc_macro();
-
-		if ((c != ' ') && (c != '\t')
-#ifdef CONFIG_ASH_ALIAS
-			&& (c != PEOA)
-#endif
-			) {
-			if (c == '#') {
-				while ((c = pgetc()) != '\n' && c != PEOF);
-				pungetc();
-			} else if (c == '\\') {
-				if (pgetc() != '\n') {
-					pungetc();
-					goto READTOKEN1;
-				}
-				startlinno = ++plinno;
-				setprompt(doprompt ? 2 : 0);
-			} else {
-				const char *p
-					= xxreadtoken_chars + sizeof(xxreadtoken_chars) - 1;
-
-				if (c != PEOF) {
-					if (c == '\n') {
-						plinno++;
-						needprompt = doprompt;
-					}
-
-					p = strchr(xxreadtoken_chars, c);
-					if (p == NULL) {
-					  READTOKEN1:
-						return readtoken1(c, BASESYNTAX, (char *) NULL, 0);
-					}
-
-					if (p - xxreadtoken_chars >= xxreadtoken_singles) {
-						if (pgetc() == *p) {	/* double occurrence? */
-							p += xxreadtoken_doubles + 1;
-						} else {
-							pungetc();
-						}
-					}
-				}
-
-				return lasttoken = xxreadtoken_tokens[p - xxreadtoken_chars];
-			}
-		}
-	}
-}
-
-
-#else
 #define RETURN(token)   return lasttoken = token
 
-static int xxreadtoken()
+static int
+xxreadtoken(void)
 {
 	int c;
 
@@ -9938,11 +9864,10 @@
 		needprompt = 0;
 	}
 	startlinno = plinno;
-	for (;;) {			/* until token or start of word found */
+	for (;;) {      /* until token or start of word found */
 		c = pgetc_macro();
 		switch (c) {
-		case ' ':
-		case '\t':
+		case ' ': case '\t':
 #ifdef CONFIG_ASH_ALIAS
 		case PEOA:
 #endif
@@ -9956,8 +9881,6 @@
 				startlinno = ++plinno;
 				if (doprompt)
 					setprompt(2);
-				else
-					setprompt(0);
 				continue;
 			}
 			pungetc();
@@ -9991,11 +9914,12 @@
 			goto breakloop;
 		}
 	}
-  breakloop:
-	return readtoken1(c, BASESYNTAX, (char *) NULL, 0);
+breakloop:
+	return readtoken1(c, BASESYNTAX, (char *)NULL, 0);
 #undef RETURN
 }
-#endif
+
+
 
 /*
  * If eofmark is NULL, read a word or a redirection symbol.  If eofmark
@@ -10017,7 +9941,7 @@
 #define PARSEARITH()    {goto parsearith; parsearith_return:;}
 
 static int
-readtoken1(int firstc, int syntax, const char *eofmark, int striptabs)
+readtoken1(int firstc, int syntax, char *eofmark, int striptabs)
 {
 	int c = firstc;
 	char *out;
@@ -10026,13 +9950,12 @@
 	struct nodelist *bqlist;
 	int quotef;
 	int dblquote;
-	int varnest;		/* levels of variables expansion */
-	int arinest;		/* levels of arithmetic expansion */
-	int parenlevel;		/* levels of parens in arithmetic */
-	int dqvarnest;		/* levels of variables expansion within double quotes */
+	int varnest;    /* levels of variables expansion */
+	int arinest;    /* levels of arithmetic expansion */
+	int parenlevel; /* levels of parens in arithmetic */
+	int dqvarnest;  /* levels of variables expansion within double quotes */
 	int oldstyle;
-	int prevsyntax;		/* syntax before arithmetic */
-
+	int prevsyntax; /* syntax before arithmetic */
 #if __GNUC__
 	/* Avoid longjmp clobbering */
 	(void) &out;
@@ -10059,81 +9982,83 @@
 	dqvarnest = 0;
 
 	STARTSTACKSTR(out);
-  loop:{				/* for each line, until end of word */
-		CHECKEND();		/* set c to PEOF if at end of here document */
-		for (;;) {		/* until end of line or end of word */
-			CHECKSTRSPACE(3, out);	/* permit 3 calls to USTPUTC */
-			switch (SIT(c, syntax)) {
-			case CNL:	/* '\n' */
+	loop: { /* for each line, until end of word */
+		CHECKEND();     /* set c to PEOF if at end of here document */
+		for (;;) {      /* until end of line or end of word */
+			CHECKSTRSPACE(4, out);  /* permit 4 calls to USTPUTC */
+			switch(SIT(c, syntax)) {
+			case CNL:       /* '\n' */
 				if (syntax == BASESYNTAX)
-					goto endword;	/* exit outer loop */
+					goto endword;   /* exit outer loop */
 				USTPUTC(c, out);
 				plinno++;
 				if (doprompt)
 					setprompt(2);
-				else
-					setprompt(0);
 				c = pgetc();
-				goto loop;	/* continue outer loop */
+				goto loop;              /* continue outer loop */
 			case CWORD:
 				USTPUTC(c, out);
 				break;
 			case CCTL:
-				if ((eofmark == NULL || dblquote) && dqvarnest == 0)
+				if (eofmark == NULL || dblquote)
 					USTPUTC(CTLESC, out);
 				USTPUTC(c, out);
 				break;
-			case CBACK:	/* backslash */
+			case CBACK:     /* backslash */
 				c = pgetc2();
 				if (c == PEOF) {
+					USTPUTC(CTLESC, out);
 					USTPUTC('\\', out);
 					pungetc();
 				} else if (c == '\n') {
 					if (doprompt)
 						setprompt(2);
-					else
-						setprompt(0);
 				} else {
-					if (dblquote && c != '\\' && c != '`' && c != '$'
-						&& (c != '"' || eofmark != NULL))
+					if (
+						dblquote &&
+						c != '\\' && c != '`' &&
+						c != '$' && (
+							c != '"' ||
+							eofmark != NULL
+						)
+					) {
+						USTPUTC(CTLESC, out);
 						USTPUTC('\\', out);
+					}
 					if (SIT(c, SQSYNTAX) == CCTL)
 						USTPUTC(CTLESC, out);
-					else if (eofmark == NULL)
-						USTPUTC(CTLQUOTEMARK, out);
 					USTPUTC(c, out);
 					quotef++;
 				}
 				break;
 			case CSQUOTE:
-				if (eofmark == NULL)
-					USTPUTC(CTLQUOTEMARK, out);
 				syntax = SQSYNTAX;
+quotemark:
+				if (eofmark == NULL) {
+					USTPUTC(CTLQUOTEMARK, out);
+				}
 				break;
 			case CDQUOTE:
-				if (eofmark == NULL)
-					USTPUTC(CTLQUOTEMARK, out);
 				syntax = DQSYNTAX;
 				dblquote = 1;
-				break;
+				goto quotemark;
 			case CENDQUOTE:
-				if (eofmark != NULL && arinest == 0 && varnest == 0) {
+				if (eofmark != NULL && arinest == 0 &&
+				    varnest == 0) {
 					USTPUTC(c, out);
 				} else {
-					if (arinest) {
-						syntax = ARISYNTAX;
-						dblquote = 0;
-					} else if (eofmark == NULL && dqvarnest == 0) {
+					if (dqvarnest == 0) {
 						syntax = BASESYNTAX;
 						dblquote = 0;
 					}
 					quotef++;
+					goto quotemark;
 				}
 				break;
-			case CVAR:	/* '$' */
-				PARSESUB();	/* parse substitution */
+			case CVAR:      /* '$' */
+				PARSESUB();             /* parse substitution */
 				break;
-			case CENDVAR:	/* '}' */
+			case CENDVAR:   /* '}' */
 				if (varnest > 0) {
 					varnest--;
 					if (dqvarnest > 0) {
@@ -10145,11 +10070,11 @@
 				}
 				break;
 #ifdef CONFIG_ASH_MATH_SUPPORT
-			case CLP:	/* '(' in arithmetic */
+			case CLP:       /* '(' in arithmetic */
 				parenlevel++;
 				USTPUTC(c, out);
 				break;
-			case CRP:	/* ')' in arithmetic */
+			case CRP:       /* ')' in arithmetic */
 				if (parenlevel > 0) {
 					USTPUTC(c, out);
 					--parenlevel;
@@ -10175,16 +10100,16 @@
 				}
 				break;
 #endif
-			case CBQUOTE:	/* '`' */
+			case CBQUOTE:   /* '`' */
 				PARSEBACKQOLD();
 				break;
 			case CENDFILE:
-				goto endword;	/* exit outer loop */
+				goto endword;           /* exit outer loop */
 			case CIGN:
 				break;
 			default:
 				if (varnest == 0)
-					goto endword;	/* exit outer loop */
+					goto endword;   /* exit outer loop */
 #ifdef CONFIG_ASH_ALIAS
 				if (c != PEOA)
 #endif
@@ -10194,21 +10119,26 @@
 			c = pgetc_macro();
 		}
 	}
-  endword:
+endword:
+#ifdef CONFIG_ASH_MATH_SUPPORT
 	if (syntax == ARISYNTAX)
 		synerror("Missing '))'");
-	if (syntax != BASESYNTAX && !parsebackquote && eofmark == NULL)
+#endif
+	if (syntax != BASESYNTAX && ! parsebackquote && eofmark == NULL)
 		synerror("Unterminated quoted string");
 	if (varnest != 0) {
 		startlinno = plinno;
+		/* { */
 		synerror("Missing '}'");
 	}
 	USTPUTC('\0', out);
-	len = out - stackblock();
+	len = out - (char *)stackblock();
 	out = stackblock();
 	if (eofmark == NULL) {
 		if ((c == '>' || c == '<')
-			&& quotef == 0 && len <= 2 && (*out == '\0' || is_digit(*out))) {
+		 && quotef == 0
+		 && len <= 2
+		 && (*out == '\0' || is_digit(*out))) {
 			PARSEREDIR();
 			return lasttoken = TREDIR;
 		} else {
@@ -10230,36 +10160,36 @@
  * we are at the end of the here document, this routine sets the c to PEOF.
  */
 
-  checkend:{
-		if (eofmark) {
+checkend: {
+	if (eofmark) {
 #ifdef CONFIG_ASH_ALIAS
-			if (c == PEOA) {
+		if (c == PEOA) {
+			c = pgetc2();
+		}
+#endif
+		if (striptabs) {
+			while (c == '\t') {
 				c = pgetc2();
 			}
-#endif
-			if (striptabs) {
-				while (c == '\t') {
-					c = pgetc2();
-				}
-			}
-			if (c == *eofmark) {
-				if (pfgets(line, sizeof line) != NULL) {
-					const char *p, *q;
+		}
+		if (c == *eofmark) {
+			if (pfgets(line, sizeof line) != NULL) {
+				char *p, *q;
 
-					p = line;
-					for (q = eofmark + 1; *q && *p == *q; p++, q++);
-					if (*p == '\n' && *q == '\0') {
-						c = PEOF;
-						plinno++;
-						needprompt = doprompt;
-					} else {
-						pushstring(line, strlen(line), NULL);
-					}
+				p = line;
+				for (q = eofmark + 1 ; *q && *p == *q ; p++, q++);
+				if (*p == '\n' && *q == '\0') {
+					c = PEOF;
+					plinno++;
+					needprompt = doprompt;
+				} else {
+					pushstring(line, NULL);
 				}
 			}
 		}
-		goto checkend_return;
 	}
+	goto checkend_return;
+}
 
 
 /*
@@ -10268,62 +10198,62 @@
  * first character of the redirection operator.
  */
 
-  parseredir:{
-		char fd = *out;
-		union node *np;
+parseredir: {
+	char fd = *out;
+	union node *np;
 
-		np = (union node *) stalloc(sizeof(struct nfile));
-		if (c == '>') {
-			np->nfile.fd = 1;
-			c = pgetc();
-			if (c == '>')
-				np->type = NAPPEND;
-			else if (c == '&')
-				np->type = NTOFD;
-			else if (c == '|')
-				np->type = NTOOV;
-			else {
-				np->type = NTO;
-				pungetc();
-			}
-		} else {		/* c == '<' */
-			np->nfile.fd = 0;
-			switch (c = pgetc()) {
-			case '<':
-				if (sizeof(struct nfile) != sizeof(struct nhere)) {
-					np = (union node *) stalloc(sizeof(struct nhere));
-					np->nfile.fd = 0;
-				}
-				np->type = NHERE;
-				heredoc = (struct heredoc *) stalloc(sizeof(struct heredoc));
-				heredoc->here = np;
-				if ((c = pgetc()) == '-') {
-					heredoc->striptabs = 1;
-				} else {
-					heredoc->striptabs = 0;
-					pungetc();
-				}
-				break;
-
-			case '&':
-				np->type = NFROMFD;
-				break;
-
-			case '>':
-				np->type = NFROMTO;
-				break;
-
-			default:
-				np->type = NFROM;
-				pungetc();
-				break;
-			}
+	np = (union node *)stalloc(sizeof (struct nfile));
+	if (c == '>') {
+		np->nfile.fd = 1;
+		c = pgetc();
+		if (c == '>')
+			np->type = NAPPEND;
+		else if (c == '|')
+			np->type = NCLOBBER;
+		else if (c == '&')
+			np->type = NTOFD;
+		else {
+			np->type = NTO;
+			pungetc();
 		}
-		if (fd != '\0')
-			np->nfile.fd = digit_val(fd);
-		redirnode = np;
-		goto parseredir_return;
+	} else {        /* c == '<' */
+		np->nfile.fd = 0;
+		switch (c = pgetc()) {
+		case '<':
+			if (sizeof (struct nfile) != sizeof (struct nhere)) {
+				np = (union node *)stalloc(sizeof (struct nhere));
+				np->nfile.fd = 0;
+			}
+			np->type = NHERE;
+			heredoc = (struct heredoc *)stalloc(sizeof (struct heredoc));
+			heredoc->here = np;
+			if ((c = pgetc()) == '-') {
+				heredoc->striptabs = 1;
+			} else {
+				heredoc->striptabs = 0;
+				pungetc();
+			}
+			break;
+
+		case '&':
+			np->type = NFROMFD;
+			break;
+
+		case '>':
+			np->type = NFROMTO;
+			break;
+
+		default:
+			np->type = NFROM;
+			pungetc();
+			break;
+		}
 	}
+	if (fd != '\0')
+		np->nfile.fd = digit_val(fd);
+	redirnode = np;
+	goto parseredir_return;
+}
 
 
 /*
@@ -10331,76 +10261,85 @@
  * and nothing else.
  */
 
-  parsesub:{
-		int subtype;
-		int typeloc;
-		int flags;
-		char *p;
-		static const char types[] = "}-+?=";
+parsesub: {
+	int subtype;
+	int typeloc;
+	int flags;
+	char *p;
+	static const char types[] = "}-+?=";
 
-		c = pgetc();
-		if (c <= PEOA ||
-			(c != '(' && c != '{' && !is_name(c) && !is_special(c))
-			) {
-			USTPUTC('$', out);
-			pungetc();
-		} else if (c == '(') {	/* $(command) or $((arith)) */
-			if (pgetc() == '(') {
-				PARSEARITH();
-			} else {
-				pungetc();
-				PARSEBACKQNEW();
-			}
+	c = pgetc();
+	if (
+		c <= PEOA_OR_PEOF  ||
+		(c != '(' && c != '{' && !is_name(c) && !is_special(c))
+	) {
+		USTPUTC('$', out);
+		pungetc();
+	} else if (c == '(') {  /* $(command) or $((arith)) */
+		if (pgetc() == '(') {
+#ifdef CONFIG_ASH_MATH_SUPPORT
+			PARSEARITH();
+#else
+			synerror("We unsupport $((arith))");
+#endif
 		} else {
-			USTPUTC(CTLVAR, out);
-			typeloc = out - stackblock();
-			USTPUTC(VSNORMAL, out);
-			subtype = VSNORMAL;
-			if (c == '{') {
-				c = pgetc();
-				if (c == '#') {
-					if ((c = pgetc()) == '}')
-						c = '#';
-					else
-						subtype = VSLENGTH;
-				} else
-					subtype = 0;
+			pungetc();
+			PARSEBACKQNEW();
+		}
+	} else {
+		USTPUTC(CTLVAR, out);
+		typeloc = out - (char *)stackblock();
+		USTPUTC(VSNORMAL, out);
+		subtype = VSNORMAL;
+		if (c == '{') {
+			c = pgetc();
+			if (c == '#') {
+				if ((c = pgetc()) == '}')
+					c = '#';
+				else
+					subtype = VSLENGTH;
 			}
-			if (c > PEOA && is_name(c)) {
-				do {
-					STPUTC(c, out);
-					c = pgetc();
-				} while (c > PEOA && is_in_name(c));
-			} else if (is_digit(c)) {
-				do {
-					USTPUTC(c, out);
-					c = pgetc();
-				} while (is_digit(c));
-			} else if (is_special(c)) {
-				USTPUTC(c, out);
+			else
+				subtype = 0;
+		}
+		if (c > PEOA_OR_PEOF && is_name(c)) {
+			do {
+				STPUTC(c, out);
 				c = pgetc();
-			} else
-			  badsub:synerror("Bad substitution");
+			} while (c > PEOA_OR_PEOF && is_in_name(c));
+		} else if (is_digit(c)) {
+			do {
+				STPUTC(c, out);
+				c = pgetc();
+			} while (is_digit(c));
+		}
+		else if (is_special(c)) {
+			USTPUTC(c, out);
+			c = pgetc();
+		}
+		else
+badsub:                 synerror("Bad substitution");
 
-			STPUTC('=', out);
-			flags = 0;
-			if (subtype == 0) {
-				switch (c) {
-				case ':':
-					flags = VSNUL;
-					c = pgetc();
-				 /*FALLTHROUGH*/ default:
-					p = strchr(types, c);
-					if (p == NULL)
-						goto badsub;
-					subtype = p - types + VSNORMAL;
-					break;
-				case '%':
-				case '#':
+		STPUTC('=', out);
+		flags = 0;
+		if (subtype == 0) {
+			switch (c) {
+			case ':':
+				flags = VSNUL;
+				c = pgetc();
+				/*FALLTHROUGH*/
+			default:
+				p = strchr(types, c);
+				if (p == NULL)
+					goto badsub;
+				subtype = p - types + VSNORMAL;
+				break;
+			case '%':
+			case '#':
 				{
 					int cc = c;
-
-					subtype = c == '#' ? VSTRIMLEFT : VSTRIMRIGHT;
+					subtype = c == '#' ? VSTRIMLEFT :
+							     VSTRIMRIGHT;
 					c = pgetc();
 					if (c == cc)
 						subtype++;
@@ -10408,22 +10347,22 @@
 						pungetc();
 					break;
 				}
-				}
-			} else {
-				pungetc();
 			}
-			if (dblquote || arinest)
-				flags |= VSQUOTE;
-			*(stackblock() + typeloc) = subtype | flags;
-			if (subtype != VSNORMAL) {
-				varnest++;
-				if (dblquote) {
-					dqvarnest++;
-				}
+		} else {
+			pungetc();
+		}
+		if (dblquote || arinest)
+			flags |= VSQUOTE;
+		*((char *)stackblock() + typeloc) = subtype | flags;
+		if (subtype != VSNORMAL) {
+			varnest++;
+			if (dblquote || arinest) {
+				dqvarnest++;
 			}
 		}
-		goto parsesub_return;
 	}
+	goto parsesub_return;
+}
 
 
 /*
@@ -10433,182 +10372,183 @@
  * characters on the top of the stack which must be preserved.
  */
 
-  parsebackq:{
-		struct nodelist **nlpp;
-		int savepbq;
-		union node *n;
-		char *volatile str;
-		struct jmploc jmploc;
-		struct jmploc *volatile savehandler;
-		int savelen;
-		int saveprompt;
-
+parsebackq: {
+	struct nodelist **nlpp;
+	int savepbq;
+	union node *n;
+	char *volatile str;
+	struct jmploc jmploc;
+	struct jmploc *volatile savehandler;
+	size_t savelen;
+	int saveprompt;
 #ifdef __GNUC__
-		(void) &saveprompt;
+	(void) &saveprompt;
 #endif
 
-		savepbq = parsebackquote;
-		if (setjmp(jmploc.loc)) {
-			free(str);
-			parsebackquote = 0;
-			handler = savehandler;
-			longjmp(handler->loc, 1);
-		}
-		INTOFF;
-		str = NULL;
-		savelen = out - stackblock();
-		if (savelen > 0) {
-			str = xmalloc(savelen);
-			memcpy(str, stackblock(), savelen);
-		}
-		savehandler = handler;
-		handler = &jmploc;
-		INTON;
-		if (oldstyle) {
-			/* We must read until the closing backquote, giving special
-			   treatment to some slashes, and then push the string and
-			   reread it as input, interpreting it normally.  */
-			char *pout;
-			int pc;
-			int psavelen;
-			char *pstr;
-
-
-			STARTSTACKSTR(pout);
-			for (;;) {
-				if (needprompt) {
-					setprompt(2);
-					needprompt = 0;
-				}
-				switch (pc = pgetc()) {
-				case '`':
-					goto done;
-
-				case '\\':
-					if ((pc = pgetc()) == '\n') {
-						plinno++;
-						if (doprompt)
-							setprompt(2);
-						else
-							setprompt(0);
-						/*
-						 * If eating a newline, avoid putting
-						 * the newline into the new character
-						 * stream (via the STPUTC after the
-						 * switch).
-						 */
-						continue;
-					}
-					if (pc != '\\' && pc != '`' && pc != '$'
-						&& (!dblquote || pc != '"'))
-						STPUTC('\\', pout);
-					if (pc > PEOA) {
-						break;
-					}
-					/* fall through */
-
-				case PEOF:
-#ifdef CONFIG_ASH_ALIAS
-				case PEOA:
-#endif
-					startlinno = plinno;
-					synerror("EOF in backquote substitution");
-
-				case '\n':
-					plinno++;
-					needprompt = doprompt;
-					break;
-
-				default:
-					break;
-				}
-				STPUTC(pc, pout);
-			}
-		  done:
-			STPUTC('\0', pout);
-			psavelen = pout - stackblock();
-			if (psavelen > 0) {
-				pstr = grabstackstr(pout);
-				setinputstring(pstr);
-			}
-		}
-		nlpp = &bqlist;
-		while (*nlpp)
-			nlpp = &(*nlpp)->next;
-		*nlpp = (struct nodelist *) stalloc(sizeof(struct nodelist));
-		(*nlpp)->next = NULL;
-		parsebackquote = oldstyle;
-
-		if (oldstyle) {
-			saveprompt = doprompt;
-			doprompt = 0;
-		}
-
-		n = list(0);
-
-		if (oldstyle)
-			doprompt = saveprompt;
-		else {
-			if (readtoken() != TRP)
-				synexpect(TRP);
-		}
-
-		(*nlpp)->n = n;
-		if (oldstyle) {
-			/*
-			 * Start reading from old file again, ignoring any pushed back
-			 * tokens left from the backquote parsing
-			 */
-			popfile();
-			tokpushback = 0;
-		}
-		while (stackblocksize() <= savelen)
-			growstackblock();
-		STARTSTACKSTR(out);
-		if (str) {
-			memcpy(out, str, savelen);
-			STADJUST(savelen, out);
-			INTOFF;
-			free(str);
-			str = NULL;
-			INTON;
-		}
-		parsebackquote = savepbq;
+	savepbq = parsebackquote;
+	if (setjmp(jmploc.loc)) {
+		if (str)
+			ckfree(str);
+		parsebackquote = 0;
 		handler = savehandler;
-		if (arinest || dblquote)
-			USTPUTC(CTLBACKQ | CTLQUOTE, out);
-		else
-			USTPUTC(CTLBACKQ, out);
-		if (oldstyle)
-			goto parsebackq_oldreturn;
-		else
-			goto parsebackq_newreturn;
+		longjmp(handler->loc, 1);
+	}
+	INTOFF;
+	str = NULL;
+	savelen = out - (char *)stackblock();
+	if (savelen > 0) {
+		str = ckmalloc(savelen);
+		memcpy(str, stackblock(), savelen);
+	}
+	savehandler = handler;
+	handler = &jmploc;
+	INTON;
+	if (oldstyle) {
+		/* We must read until the closing backquote, giving special
+		   treatment to some slashes, and then push the string and
+		   reread it as input, interpreting it normally.  */
+		char *pout;
+		int pc;
+		size_t psavelen;
+		char *pstr;
+
+
+		STARTSTACKSTR(pout);
+		for (;;) {
+			if (needprompt) {
+				setprompt(2);
+				needprompt = 0;
+			}
+			switch (pc = pgetc()) {
+			case '`':
+				goto done;
+
+			case '\\':
+				if ((pc = pgetc()) == '\n') {
+					plinno++;
+					if (doprompt)
+						setprompt(2);
+					/*
+					 * If eating a newline, avoid putting
+					 * the newline into the new character
+					 * stream (via the STPUTC after the
+					 * switch).
+					 */
+					continue;
+				}
+				if (pc != '\\' && pc != '`' && pc != '$'
+				    && (!dblquote || pc != '"'))
+					STPUTC('\\', pout);
+				if (pc > PEOA_OR_PEOF) {
+					break;
+				}
+				/* fall through */
+
+			case PEOF:
+#ifdef CONFIG_ASH_ALIAS
+			case PEOA:
+#endif
+				startlinno = plinno;
+				synerror("EOF in backquote substitution");
+
+			case '\n':
+				plinno++;
+				needprompt = doprompt;
+				break;
+
+			default:
+				break;
+			}
+			STPUTC(pc, pout);
+		}
+done:
+		STPUTC('\0', pout);
+		psavelen = pout - (char *)stackblock();
+		if (psavelen > 0) {
+			pstr = grabstackstr(pout);
+			setinputstring(pstr);
+		}
+	}
+	nlpp = &bqlist;
+	while (*nlpp)
+		nlpp = &(*nlpp)->next;
+	*nlpp = (struct nodelist *)stalloc(sizeof (struct nodelist));
+	(*nlpp)->next = NULL;
+	parsebackquote = oldstyle;
+
+	if (oldstyle) {
+		saveprompt = doprompt;
+		doprompt = 0;
 	}
 
+	n = list(2);
+
+	if (oldstyle)
+		doprompt = saveprompt;
+	else {
+		if (readtoken() != TRP)
+			synexpect(TRP);
+	}
+
+	(*nlpp)->n = n;
+	if (oldstyle) {
+		/*
+		 * Start reading from old file again, ignoring any pushed back
+		 * tokens left from the backquote parsing
+		 */
+		popfile();
+		tokpushback = 0;
+	}
+	while (stackblocksize() <= savelen)
+		growstackblock();
+	STARTSTACKSTR(out);
+	if (str) {
+		memcpy(out, str, savelen);
+		STADJUST(savelen, out);
+		INTOFF;
+		ckfree(str);
+		str = NULL;
+		INTON;
+	}
+	parsebackquote = savepbq;
+	handler = savehandler;
+	if (arinest || dblquote)
+		USTPUTC(CTLBACKQ | CTLQUOTE, out);
+	else
+		USTPUTC(CTLBACKQ, out);
+	if (oldstyle)
+		goto parsebackq_oldreturn;
+	else
+		goto parsebackq_newreturn;
+}
+
+#ifdef CONFIG_ASH_MATH_SUPPORT
 /*
  * Parse an arithmetic expansion (indicate start of one and set state)
  */
-  parsearith:{
+parsearith: {
 
-		if (++arinest == 1) {
-			prevsyntax = syntax;
-			syntax = ARISYNTAX;
-			USTPUTC(CTLARI, out);
-			if (dblquote)
-				USTPUTC('"', out);
-			else
-				USTPUTC(' ', out);
-		} else {
-			/*
-			 * we collapse embedded arithmetic expansion to
-			 * parenthesis, which should be equivalent
-			 */
-			USTPUTC('(', out);
-		}
-		goto parsearith_return;
+	if (++arinest == 1) {
+		prevsyntax = syntax;
+		syntax = ARISYNTAX;
+		USTPUTC(CTLARI, out);
+		if (dblquote)
+			USTPUTC('"',out);
+		else
+			USTPUTC(' ',out);
+	} else {
+		/*
+		 * we collapse embedded arithmetic expansion to
+		 * parenthesis, which should be equivalent
+		 */
+		USTPUTC('(', out);
 	}
+	goto parsearith_return;
+}
+#endif
 
-}						/* end of readtoken */
+} /* end of readtoken */
+
 
 
 /*
@@ -10616,7 +10556,8 @@
  * or backquotes).
  */
 
-static int noexpand(char *text)
+static int
+noexpand(char *text)
 {
 	char *p;
 	char c;
@@ -10635,22 +10576,23 @@
 
 
 /*
- * Return true if the argument is a legal variable name (a letter or
- * underscore followed by zero or more letters, underscores, and digits).
+ * Return of a legal variable name (a letter or underscore followed by zero or
+ * more letters, underscores, and digits).
  */
 
-static int goodname(const char *name)
-{
-	const char *p;
+char *
+endofname(const char *name)
+	{
+	char *p;
 
-	p = name;
-	if (!is_name(*p))
-		return 0;
+	p = (char *) name;
+	if (! is_name(*p))
+		return p;
 	while (*++p) {
-		if (!is_in_name(*p))
-			return 0;
+		if (! is_in_name(*p))
+			break;
 	}
-	return 1;
+	return p;
 }
 
 
@@ -10672,13 +10614,10 @@
 	/* NOTREACHED */
 }
 
-
-static void synerror(const char *msg)
+static void
+synerror(const char *msg)
 {
-	if (commandname)
-		out2fmt("%s: %d: ", commandname, startlinno);
-	out2fmt("Syntax error: %s\n", msg);
-	error((char *) NULL);
+	error("Syntax error: %s", msg);
 	/* NOTREACHED */
 }
 
@@ -10687,9 +10626,10 @@
  * called by editline -- any expansions to the prompt
  *    should be added here.
  */
+
 static void setprompt(int whichprompt)
 {
-	char *prompt;
+	const char *prompt;
 
 	switch (whichprompt) {
 	case 1:
@@ -10698,30 +10638,39 @@
 	case 2:
 		prompt = ps2val();
 		break;
-	default:			/* 0 */
-		prompt = "";
+	default:                        /* 0 */
+		prompt = nullstr;
 	}
 	putprompt(prompt);
 }
 
 
+static const char *const *findkwd(const char *s)
+{
+	return bsearch(s, tokname_array + KWDOFFSET,
+				   (sizeof(tokname_array) / sizeof(const char *)) - KWDOFFSET,
+				   sizeof(const char *), pstrcmp);
+}
+
+/*      $NetBSD: redir.c,v 1.27 2002/11/24 22:35:42 christos Exp $      */
+
 /*
  * Code for dealing with input/output redirection.
  */
 
-#define EMPTY -2		/* marks an unused slot in redirtab */
+#define EMPTY -2                /* marks an unused slot in redirtab */
 #ifndef PIPE_BUF
-# define PIPESIZE 4096	/* amount of buffering in a pipe */
+# define PIPESIZE 4096          /* amount of buffering in a pipe */
 #else
 # define PIPESIZE PIPE_BUF
 #endif
 
-
 /*
  * Open a file in noclobber mode.
  * The code was copied from bash.
  */
-static inline int noclobberopen(const char *fname)
+static inline int
+noclobberopen(const char *fname)
 {
 	int r, fd;
 	struct stat finfo, finfo2;
@@ -10744,8 +10693,8 @@
 	 * file was not a regular file, we leave O_EXCL off.
 	 */
 	if (r != 0)
-		return open(fname, O_WRONLY | O_CREAT | O_EXCL, 0666);
-	fd = open(fname, O_WRONLY | O_CREAT, 0666);
+		return open(fname, O_WRONLY|O_CREAT|O_EXCL, 0666);
+	fd = open(fname, O_WRONLY|O_CREAT, 0666);
 
 	/* If the open failed, return the file descriptor right away. */
 	if (fd < 0)
@@ -10764,8 +10713,8 @@
 	 * revealed that it was a regular file, and the file has not been
 	 * replaced, return the file descriptor.
 	 */
-	if (fstat(fd, &finfo2) == 0 && !S_ISREG(finfo2.st_mode) &&
-		finfo.st_dev == finfo2.st_dev && finfo.st_ino == finfo2.st_ino)
+	 if (fstat(fd, &finfo2) == 0 && !S_ISREG(finfo2.st_mode) &&
+	     finfo.st_dev == finfo2.st_dev && finfo.st_ino == finfo2.st_ino)
 		return fd;
 
 	/* The file has been replaced.  badness. */
@@ -10780,10 +10729,11 @@
  * the pipe without forking.
  */
 
-static inline int openhere(const union node *redir)
+static inline int
+openhere(union node *redir)
 {
 	int pip[2];
-	int len = 0;
+	size_t len = 0;
 
 	if (pipe(pip) < 0)
 		error("Pipe call failed");
@@ -10794,7 +10744,7 @@
 			goto out;
 		}
 	}
-	if (forkshell((struct job *) NULL, (union node *) NULL, FORK_NOJOB) == 0) {
+	if (forkshell((struct job *)NULL, (union node *)NULL, FORK_NOJOB) == 0) {
 		close(pip[0]);
 		signal(SIGINT, SIG_IGN);
 		signal(SIGQUIT, SIG_IGN);
@@ -10809,13 +10759,13 @@
 			expandhere(redir->nhere.doc, pip[1]);
 		_exit(0);
 	}
-  out:
+out:
 	close(pip[1]);
 	return pip[0];
 }
 
-
-static inline int openredirect(const union node *redir)
+static int
+openredirect(union node *redir)
 {
 	char *fname;
 	int f;
@@ -10828,7 +10778,7 @@
 		break;
 	case NFROMTO:
 		fname = redir->nfile.expfname;
-		if ((f = open(fname, O_RDWR | O_CREAT | O_TRUNC, 0666)) < 0)
+		if ((f = open(fname, O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0)
 			goto ecreate;
 		break;
 	case NTO:
@@ -10839,26 +10789,16 @@
 				goto ecreate;
 			break;
 		}
-	case NTOOV:
+		/* FALLTHROUGH */
+	case NCLOBBER:
 		fname = redir->nfile.expfname;
-#ifdef O_CREAT
-		if ((f = open(fname, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0)
+		if ((f = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0)
 			goto ecreate;
-#else
-		if ((f = creat(fname, 0666)) < 0)
-			goto ecreate;
-#endif
 		break;
 	case NAPPEND:
 		fname = redir->nfile.expfname;
-#ifdef O_APPEND
-		if ((f = open(fname, O_WRONLY | O_CREAT | O_APPEND, 0666)) < 0)
+		if ((f = open(fname, O_WRONLY|O_CREAT|O_APPEND, 0666)) < 0)
 			goto ecreate;
-#else
-		if ((f = open(fname, O_WRONLY)) < 0 && (f = creat(fname, 0666)) < 0)
-			goto ecreate;
-		lseek(f, (off_t) 0, 2);
-#endif
 		break;
 	default:
 #ifdef DEBUG
@@ -10876,109 +10816,100 @@
 	}
 
 	return f;
-  ecreate:
+ecreate:
 	error("cannot create %s: %s", fname, errmsg(errno, E_CREAT));
-  eopen:
+eopen:
 	error("cannot open %s: %s", fname, errmsg(errno, E_OPEN));
 }
 
+static inline void
+dupredirect(union node *redir, int f)
+{
+	int fd = redir->nfile.fd;
+
+	if (redir->nfile.type == NTOFD || redir->nfile.type == NFROMFD) {
+		if (redir->ndup.dupfd >= 0) {   /* if not ">&-" */
+				copyfd(redir->ndup.dupfd, fd);
+		}
+		return;
+	}
+
+	if (f != fd) {
+		copyfd(f, fd);
+		close(f);
+	}
+	return;
+}
 
 /*
  * Process a list of redirection commands.  If the REDIR_PUSH flag is set,
  * old file descriptors are stashed away so that the redirection can be
  * undone by calling popredir.  If the REDIR_BACKQ flag is set, then the
  * standard output, and the standard error if it becomes a duplicate of
- * stdout.
+ * stdout, is saved in memory.
  */
 
-static void redirect(union node *redir, int flags)
+static void
+redirect(union node *redir, int flags)
 {
 	union node *n;
-	struct redirtab *sv = NULL;
+	struct redirtab *sv;
 	int i;
 	int fd;
 	int newfd;
-	int try;
-	int fd1dup = flags & REDIR_BACKQ;;	/* stdout `cmd` redir to pipe */
-
-	TRACE(("redirect(%s) called\n",
-		   flags & REDIR_PUSH ? "REDIR_PUSH" : "NO_REDIR_PUSH"));
-	if (flags & REDIR_PUSH) {
-		sv = xmalloc(sizeof(struct redirtab));
-		for (i = 0; i < 10; i++)
-			sv->renamed[i] = EMPTY;
-		sv->next = redirlist;
-		redirlist = sv;
+	int *p;
+	nullredirs++;
+	if (!redir) {
+		return;
 	}
-	for (n = redir; n; n = n->nfile.next) {
+	sv = NULL;
+	INTOFF;
+	if (flags & REDIR_PUSH) {
+		struct redirtab *q;
+		q = ckmalloc(sizeof (struct redirtab));
+		q->next = redirlist;
+		redirlist = q;
+		q->nullredirs = nullredirs - 1;
+		for (i = 0 ; i < 10 ; i++)
+			q->renamed[i] = EMPTY;
+		nullredirs = 0;
+		sv = q;
+	}
+	n = redir;
+	do {
 		fd = n->nfile.fd;
-		try = 0;
 		if ((n->nfile.type == NTOFD || n->nfile.type == NFROMFD) &&
-			n->ndup.dupfd == fd)
-			continue;	/* redirect from/to same file descriptor */
+		    n->ndup.dupfd == fd)
+			continue; /* redirect from/to same file descriptor */
 
-		INTOFF;
 		newfd = openredirect(n);
-		if ((flags & REDIR_PUSH) && sv->renamed[fd] == EMPTY) {
-			i = fd;
-			if (newfd == fd) {
-				try++;
-			} else if ((i = fcntl(fd, F_DUPFD, 10)) == -1) {
-				switch (errno) {
-				case EBADF:
-					if (!try) {
-						dupredirect(n, newfd, fd1dup);
-						try++;
-						break;
-					}
-					/* FALLTHROUGH */
-				default:
-					if (newfd >= 0) {
-						close(newfd);
-					}
-					INTON;
+		if (fd == newfd)
+			continue;
+		if (sv && *(p = &sv->renamed[fd]) == EMPTY) {
+			i = fcntl(fd, F_DUPFD, 10);
+
+			if (i == -1) {
+				i = errno;
+				if (i != EBADF) {
+					close(newfd);
+					errno = i;
 					error("%d: %m", fd);
 					/* NOTREACHED */
 				}
-			}
-			if (!try) {
+			} else {
+				*p = i;
 				close(fd);
-				if (flags & REDIR_PUSH) {
-					sv->renamed[fd] = i;
-				}
 			}
-		} else if (fd != newfd) {
+		} else {
 			close(fd);
 		}
-		if (fd == 0)
-			fd0_redirected++;
-		if (!try)
-			dupredirect(n, newfd, fd1dup);
-		INTON;
-	}
+		dupredirect(n, newfd);
+	} while ((n = n->nfile.next));
+	INTON;
 }
 
 
-static void dupredirect(const union node *redir, int f, int fd1dup)
-{
-	int fd = redir->nfile.fd;
 
-	if (fd == 1)
-		fd1dup = 0;
-	if (redir->nfile.type == NTOFD || redir->nfile.type == NFROMFD) {
-		if (redir->ndup.dupfd >= 0) {	/* if not ">&-" */
-			if (redir->ndup.dupfd != 1 || fd1dup != 1)
-				dup_as_newfd(redir->ndup.dupfd, fd);
-		}
-		return;
-	}
-
-	if (f != fd) {
-		dup_as_newfd(f, fd);
-		close(f);
-	}
-	return;
-}
 
 
 
@@ -10986,55 +10917,60 @@
  * Undo the effects of the last redirection.
  */
 
-static void popredir(void)
+void
+popredir(int drop)
 {
-	struct redirtab *rp = redirlist;
+	struct redirtab *rp;
 	int i;
 
+	if (--nullredirs >= 0)
+		return;
 	INTOFF;
-	for (i = 0; i < 10; i++) {
+	rp = redirlist;
+	for (i = 0 ; i < 10 ; i++) {
 		if (rp->renamed[i] != EMPTY) {
-			if (i == 0)
-				fd0_redirected--;
-			close(i);
-			if (rp->renamed[i] >= 0) {
-				dup_as_newfd(rp->renamed[i], i);
-				close(rp->renamed[i]);
+			if (!drop) {
+				close(i);
+				copyfd(rp->renamed[i], i);
 			}
+			close(rp->renamed[i]);
 		}
 	}
 	redirlist = rp->next;
-	free(rp);
+	nullredirs = rp->nullredirs;
+	ckfree(rp);
 	INTON;
 }
 
 /*
+ * Undo all redirections.  Called on error or interrupt.
+ */
+
+/*
  * Discard all saved file descriptors.
  */
 
-static void clearredir(void)
+void
+clearredir(int drop)
 {
-	struct redirtab *rp;
-	int i;
-
-	for (rp = redirlist; rp; rp = rp->next) {
-		for (i = 0; i < 10; i++) {
-			if (rp->renamed[i] >= 0) {
-				close(rp->renamed[i]);
-			}
-			rp->renamed[i] = EMPTY;
-		}
+	for (;;) {
+		nullredirs = 0;
+		if (!redirlist)
+			break;
+		popredir(drop);
 	}
 }
 
 
+
 /*
  * Copy a file descriptor to be >= to.  Returns -1
  * if the source file descriptor is closed, EMPTY if there are no unused
  * file descriptors left.
  */
 
-static int dup_as_newfd(int from, int to)
+int
+copyfd(int from, int to)
 {
 	int newfd;
 
@@ -11048,27 +10984,47 @@
 	return newfd;
 }
 
-#ifdef DEBUG
-/*
- * Debugging stuff.
- */
 
-static void shtree(union node *, int, char *, FILE *);
+int
+redirectsafe(union node *redir, int flags)
+{
+	int err;
+	volatile int saveint;
+	struct jmploc *volatile savehandler = handler;
+	struct jmploc jmploc;
+
+	SAVEINT(saveint);
+	if (!(err = setjmp(jmploc.loc) * 2)) {
+		handler = &jmploc;
+		redirect(redir, flags);
+	}
+	handler = savehandler;
+	if (err && exception != EXERROR)
+		longjmp(handler->loc, 1);
+	RESTOREINT(saveint);
+	return err;
+}
+
+/*      $NetBSD: show.c,v 1.24 2003/01/22 20:36:04 dsl Exp $    */
+
+#ifdef DEBUG
+static void shtree(union node *, int, char *, FILE*);
 static void shcmd(union node *, FILE *);
 static void sharg(union node *, FILE *);
 static void indent(int, char *, FILE *);
 static void trstring(char *);
 
 
-#if 0
-static void showtree(node * n)
+void
+showtree(union node *n)
 {
 	trputs("showtree called\n");
 	shtree(n, 1, NULL, stdout);
 }
-#endif
 
-static void shtree(union node *n, int ind, char *pfx, FILE * fp)
+
+static void
+shtree(union node *n, int ind, char *pfx, FILE *fp)
 {
 	struct nodelist *lp;
 	const char *s;
@@ -11077,7 +11033,7 @@
 		return;
 
 	indent(ind, pfx, fp);
-	switch (n->type) {
+	switch(n->type) {
 	case NSEMI:
 		s = "; ";
 		goto binop;
@@ -11086,10 +11042,10 @@
 		goto binop;
 	case NOR:
 		s = " || ";
-	  binop:
+binop:
 		shtree(n->nbinary.ch1, ind, NULL, fp);
-		/*    if (ind < 0) */
-		fputs(s, fp);
+	   /*    if (ind < 0) */
+			fputs(s, fp);
 		shtree(n->nbinary.ch2, ind, NULL, fp);
 		break;
 	case NCMD:
@@ -11098,7 +11054,7 @@
 			putc('\n', fp);
 		break;
 	case NPIPE:
-		for (lp = n->npipe.cmdlist; lp; lp = lp->next) {
+		for (lp = n->npipe.cmdlist ; lp ; lp = lp->next) {
 			shcmd(lp->n, fp);
 			if (lp->next)
 				fputs(" | ", fp);
@@ -11117,7 +11073,9 @@
 }
 
 
-static void shcmd(union node *cmd, FILE * fp)
+
+static void
+shcmd(union node *cmd, FILE *fp)
 {
 	union node *np;
 	int first;
@@ -11125,60 +11083,25 @@
 	int dftfd;
 
 	first = 1;
-	for (np = cmd->ncmd.args; np; np = np->narg.next) {
-		if (!first)
+	for (np = cmd->ncmd.args ; np ; np = np->narg.next) {
+		if (! first)
 			putchar(' ');
 		sharg(np, fp);
 		first = 0;
 	}
-	for (np = cmd->ncmd.redirect; np; np = np->nfile.next) {
-		if (!first)
+	for (np = cmd->ncmd.redirect ; np ; np = np->nfile.next) {
+		if (! first)
 			putchar(' ');
-#if 1
-		s = "*error*";
-		dftfd = 0;
-		if ((np->nfile.type <= NFROMFD) && (np->nfile.type >= NTO)) {
-			s = redir_strings[np->nfile.type - NTO];
-			if (*s == '>') {
-				dftfd = 1;
-			}
-		}
-#else
 		switch (np->nfile.type) {
-		case NTO:
-			s = ">";
-			dftfd = 1;
-			break;
-		case NAPPEND:
-			s = ">>";
-			dftfd = 1;
-			break;
-		case NTOFD:
-			s = ">&";
-			dftfd = 1;
-			break;
-		case NTOOV:
-			s = ">|";
-			dftfd = 1;
-			break;
-		case NFROM:
-			s = "<";
-			dftfd = 0;
-			break;
-		case NFROMFD:
-			s = "<&";
-			dftfd = 0;
-			break;
-		case NFROMTO:
-			s = "<>";
-			dftfd = 0;
-			break;
-		default:
-			s = "*error*";
-			dftfd = 0;
-			break;
+			case NTO:       s = ">";  dftfd = 1; break;
+			case NCLOBBER:  s = ">|"; dftfd = 1; break;
+			case NAPPEND:   s = ">>"; dftfd = 1; break;
+			case NTOFD:     s = ">&"; dftfd = 1; break;
+			case NFROM:     s = "<";  dftfd = 0; break;
+			case NFROMFD:   s = "<&"; dftfd = 0; break;
+			case NFROMTO:   s = "<>"; dftfd = 0; break;
+			default:        s = "*error*"; dftfd = 0; break;
 		}
-#endif
 		if (np->nfile.fd != dftfd)
 			fprintf(fp, "%d", np->nfile.fd);
 		fputs(s, fp);
@@ -11192,19 +11115,20 @@
 }
 
 
-static void sharg(union node *arg, FILE * fp)
+
+static void
+sharg(union node *arg, FILE *fp)
 {
 	char *p;
 	struct nodelist *bqlist;
 	int subtype;
 
 	if (arg->type != NARG) {
-		printf("<node type %d>\n", arg->type);
-		fflush(stdout);
+		out1fmt("<node type %d>\n", arg->type);
 		abort();
 	}
 	bqlist = arg->narg.backquote;
-	for (p = arg->narg.text; *p; p++) {
+	for (p = arg->narg.text ; *p ; p++) {
 		switch (*p) {
 		case CTLESC:
 			putc(*++p, fp);
@@ -11255,14 +11179,14 @@
 			case VSLENGTH:
 				break;
 			default:
-				printf("<subtype %d>", subtype);
+				out1fmt("<subtype %d>", subtype);
 			}
 			break;
 		case CTLENDVAR:
-			putc('}', fp);
-			break;
+		     putc('}', fp);
+		     break;
 		case CTLBACKQ:
-		case CTLBACKQ | CTLQUOTE:
+		case CTLBACKQ|CTLQUOTE:
 			putc('$', fp);
 			putc('(', fp);
 			shtree(bqlist->n, -1, NULL, fp);
@@ -11276,100 +11200,88 @@
 }
 
 
-static void indent(int amount, char *pfx, FILE * fp)
+static void
+indent(int amount, char *pfx, FILE *fp)
 {
 	int i;
 
-	for (i = 0; i < amount; i++) {
+	for (i = 0 ; i < amount ; i++) {
 		if (pfx && i == amount - 1)
 			fputs(pfx, fp);
 		putc('\t', fp);
 	}
 }
 
+
+
+/*
+ * Debugging stuff.
+ */
+
+
 FILE *tracefile;
 
-#if DEBUG == 2
-static int debug = 1;
-#else
-static int debug = 0;
-#endif
 
-
-static void trputc(int c)
+void
+trputc(int c)
 {
-	if (tracefile == NULL)
+	if (debug != 1)
 		return;
 	putc(c, tracefile);
-	if (c == '\n')
-		fflush(tracefile);
 }
 
-static void trace(const char *fmt, ...)
+void
+trace(const char *fmt, ...)
 {
 	va_list va;
 
+	if (debug != 1)
+		return;
 	va_start(va, fmt);
-	if (tracefile != NULL) {
-		(void) vfprintf(tracefile, fmt, va);
-		if (strchr(fmt, '\n'))
-			(void) fflush(tracefile);
-	}
+	(void) vfprintf(tracefile, fmt, va);
 	va_end(va);
 }
 
-
-static void trputs(const char *s)
+void
+tracev(const char *fmt, va_list va)
 {
-	if (tracefile == NULL)
+	if (debug != 1)
 		return;
-	fputs(s, tracefile);
-	if (strchr(s, '\n'))
-		fflush(tracefile);
+	(void) vfprintf(tracefile, fmt, va);
 }
 
 
-static void trstring(char *s)
+void
+trputs(const char *s)
+{
+	if (debug != 1)
+		return;
+	fputs(s, tracefile);
+}
+
+
+static void
+trstring(char *s)
 {
 	char *p;
 	char c;
 
-	if (tracefile == NULL)
+	if (debug != 1)
 		return;
 	putc('"', tracefile);
-	for (p = s; *p; p++) {
+	for (p = s ; *p ; p++) {
 		switch (*p) {
-		case '\n':
-			c = 'n';
-			goto backslash;
-		case '\t':
-			c = 't';
-			goto backslash;
-		case '\r':
-			c = 'r';
-			goto backslash;
-		case '"':
-			c = '"';
-			goto backslash;
-		case '\\':
-			c = '\\';
-			goto backslash;
-		case CTLESC:
-			c = 'e';
-			goto backslash;
-		case CTLVAR:
-			c = 'v';
-			goto backslash;
-		case CTLVAR + CTLQUOTE:
-			c = 'V';
-			goto backslash;
-		case CTLBACKQ:
-			c = 'q';
-			goto backslash;
-		case CTLBACKQ + CTLQUOTE:
-			c = 'Q';
-			goto backslash;
-		  backslash:putc('\\', tracefile);
+		case '\n':  c = 'n';  goto backslash;
+		case '\t':  c = 't';  goto backslash;
+		case '\r':  c = 'r';  goto backslash;
+		case '"':  c = '"';  goto backslash;
+		case '\\':  c = '\\';  goto backslash;
+		case CTLESC:  c = 'e';  goto backslash;
+		case CTLVAR:  c = 'v';  goto backslash;
+		case CTLVAR+CTLQUOTE:  c = 'V';  goto backslash;
+		case CTLBACKQ:  c = 'q';  goto backslash;
+		case CTLBACKQ+CTLQUOTE:  c = 'Q';  goto backslash;
+backslash:        putc('\\', tracefile);
 			putc(c, tracefile);
 			break;
 		default:
@@ -11388,9 +11300,10 @@
 }
 
 
-static void trargs(char **ap)
+void
+trargs(char **ap)
 {
-	if (tracefile == NULL)
+	if (debug != 1)
 		return;
 	while (*ap) {
 		trstring(*ap++);
@@ -11399,78 +11312,91 @@
 		else
 			putc('\n', tracefile);
 	}
-	fflush(tracefile);
 }
 
 
-static void opentrace()
+void
+opentrace(void)
 {
 	char s[100];
-
 #ifdef O_APPEND
 	int flags;
 #endif
 
-	if (!debug)
+	if (debug != 1) {
+		if (tracefile)
+			fflush(tracefile);
+		/* leave open because libedit might be using it */
 		return;
-#ifdef not_this_way
-	{
-		char *p;
-
-		if ((p = getenv("HOME")) == NULL) {
-			if (geteuid() == 0)
-				p = "/";
-			else
-				p = "/tmp";
-		}
-		strcpy(s, p);
-		strcat(s, "/trace");
 	}
-#else
-	strcpy(s, "./trace");
-#endif							/* not_this_way */
-	if ((tracefile = bb_wfopen(s, "a")) == NULL)
-		return;
+	scopy("./trace", s);
+	if (tracefile) {
+		if (!freopen(s, "a", tracefile)) {
+			fprintf(stderr, "Can't re-open %s\n", s);
+			debug = 0;
+			return;
+		}
+	} else {
+		if ((tracefile = fopen(s, "a")) == NULL) {
+			fprintf(stderr, "Can't open %s\n", s);
+			debug = 0;
+			return;
+		}
+	}
 #ifdef O_APPEND
 	if ((flags = fcntl(fileno(tracefile), F_GETFL, 0)) >= 0)
 		fcntl(fileno(tracefile), F_SETFL, flags | O_APPEND);
 #endif
+	setlinebuf(tracefile);
 	fputs("\nTracing started.\n", tracefile);
-	fflush(tracefile);
 }
-#endif							/* DEBUG */
+#endif /* DEBUG */
+
+
+/*      $NetBSD: trap.c,v 1.28 2002/11/24 22:35:43 christos Exp $       */
+
+/*
+ * Sigmode records the current value of the signal handlers for the various
+ * modes.  A value of zero means that the current handler is not known.
+ * S_HARD_IGN indicates that the signal was ignored on entry to the shell,
+ */
+
+#define S_DFL 1                 /* default signal handling (SIG_DFL) */
+#define S_CATCH 2               /* signal is caught */
+#define S_IGN 3                 /* signal is ignored (SIG_IGN) */
+#define S_HARD_IGN 4            /* signal is ignored permenantly */
+#define S_RESET 5               /* temporary - to reset a hard ignored sig */
+
 
 
 /*
  * The trap builtin.
  */
 
-static int trapcmd(int argc, char **argv)
+int
+trapcmd(int argc, char **argv)
 {
 	char *action;
 	char **ap;
 	int signo;
 
-	if (argc <= 1) {
-		for (signo = 0; signo < NSIG; signo++) {
+	nextopt(nullstr);
+	ap = argptr;
+	if (!*ap) {
+		for (signo = 0 ; signo < NSIG ; signo++) {
 			if (trap[signo] != NULL) {
-				char *p;
 				const char *sn;
 
-				p = single_quote(trap[signo]);
-				sn = sys_siglist[signo];
-				if (sn == NULL)
-					sn = u_signal_names(0, &signo, 0);
+				sn = u_signal_names(0, &signo, 0);
 				if (sn == NULL)
 					sn = "???";
-				printf("trap -- %s %s\n", p, sn);
-				stunalloc(p);
+				out1fmt("trap -- %s %s\n",
+					single_quote(trap[signo]), sn);
 			}
 		}
 		return 0;
 	}
-	ap = argv + 1;
-	if (argc == 2)
+	if (!ap[1])
 		action = NULL;
 	else
 		action = *ap++;
@@ -11482,9 +11408,10 @@
 			if (action[0] == '-' && action[1] == '\0')
 				action = NULL;
 			else
-				action = bb_xstrdup(action);
+				action = savestr(action);
 		}
-		free(trap[signo]);
+		if (trap[signo])
+			ckfree(trap[signo]);
 		trap[signo] = action;
 		if (signo != 0)
 			setsignal(signo);
@@ -11495,15 +11422,40 @@
 }
 
 
+
+/*
+ * Clear traps on a fork.
+ */
+
+void
+clear_traps(void)
+{
+	char **tp;
+
+	for (tp = trap ; tp < &trap[NSIG] ; tp++) {
+		if (*tp && **tp) {      /* trap not NULL or SIG_IGN */
+			INTOFF;
+			ckfree(*tp);
+			*tp = NULL;
+			if (tp != &trap[0])
+				setsignal(tp - trap);
+			INTON;
+		}
+	}
+}
+
+
+
 /*
  * Set the signal handler for the specified signal.  The routine figures
  * out what it should be set to.
  */
 
-static void setsignal(int signo)
+void
+setsignal(int signo)
 {
 	int action;
-	char *t;
+	char *t, tsig;
 	struct sigaction act;
 
 	if ((t = trap[signo]) == NULL)
@@ -11520,18 +11472,15 @@
 			break;
 		case SIGQUIT:
 #ifdef DEBUG
-		{
-
 			if (debug)
 				break;
-		}
 #endif
 			/* FALLTHROUGH */
 		case SIGTERM:
 			if (iflag)
 				action = S_IGN;
 			break;
-#ifdef CONFIG_ASH_JOB_CONTROL
+#if JOBS
 		case SIGTSTP:
 		case SIGTTOU:
 			if (mflag)
@@ -11542,7 +11491,8 @@
 	}
 
 	t = &sigmode[signo - 1];
-	if (*t == 0) {
+	tsig = *t;
+	if (tsig == 0) {
 		/*
 		 * current setting unknown
 		 */
@@ -11556,21 +11506,29 @@
 		}
 		if (act.sa_handler == SIG_IGN) {
 			if (mflag && (signo == SIGTSTP ||
-						  signo == SIGTTIN || signo == SIGTTOU)) {
-				*t = S_IGN;	/* don't hard ignore these */
+			     signo == SIGTTIN || signo == SIGTTOU)) {
+				tsig = S_IGN;   /* don't hard ignore these */
 			} else
-				*t = S_HARD_IGN;
+				tsig = S_HARD_IGN;
 		} else {
-			*t = S_RESET;	/* force to be set */
+			tsig = S_RESET; /* force to be set */
 		}
 	}
-	if (*t == S_HARD_IGN || *t == action)
+	if (tsig == S_HARD_IGN || tsig == action)
 		return;
-	act.sa_handler = ((action == S_CATCH) ? onsig
-					  : ((action == S_IGN) ? SIG_IGN : SIG_DFL));
+	switch (action) {
+	case S_CATCH:
+		act.sa_handler = onsig;
+		break;
+	case S_IGN:
+		act.sa_handler = SIG_IGN;
+		break;
+	default:
+		act.sa_handler = SIG_DFL;
+	}
 	*t = action;
 	act.sa_flags = 0;
-	sigemptyset(&act.sa_mask);
+	sigfillset(&act.sa_mask);
 	sigaction(signo, &act, 0);
 }
 
@@ -11578,7 +11536,8 @@
  * Ignore a signal.
  */
 
-static void ignoresig(int signo)
+void
+ignoresig(int signo)
 {
 	if (sigmode[signo - 1] != S_IGN && sigmode[signo - 1] != S_HARD_IGN) {
 		signal(signo, SIG_IGN);
@@ -11587,74 +11546,142 @@
 }
 
 
+
 /*
  * Signal handler.
  */
 
-static void onsig(int signo)
+void
+onsig(int signo)
 {
-	if (signo == SIGINT && trap[SIGINT] == NULL) {
-		onint();
-		return;
-	}
 	gotsig[signo - 1] = 1;
-	pendingsigs++;
+	pendingsigs = signo;
+
+	if (exsig || (signo == SIGINT && !trap[SIGINT])) {
+		if (!suppressint)
+			onint();
+		intpending = 1;
+	}
 }
 
 
+
 /*
  * Called to execute a trap.  Perhaps we should avoid entering new trap
  * handlers while we are executing a trap handler.
  */
 
-static void dotrap(void)
+void
+dotrap(void)
 {
-	int i;
+	char *p;
+	char *q;
 	int savestatus;
 
-	for (;;) {
-		for (i = 1;; i++) {
-			if (gotsig[i - 1])
-				break;
-			if (i >= NSIG - 1)
-				goto done;
-		}
-		gotsig[i - 1] = 0;
-		savestatus = exitstatus;
-		evalstring(trap[i], 0);
+	savestatus = exitstatus;
+	q = gotsig;
+	while (pendingsigs = 0, barrier(), (p = memchr(q, 1, NSIG - 1))) {
+		*p = 0;
+		p = trap[p - q + 1];
+		if (!p)
+			continue;
+		evalstring(p, 0);
 		exitstatus = savestatus;
 	}
-  done:
-	pendingsigs = 0;
 }
 
+
+
+/*
+ * Controls whether the shell is interactive or not.
+ */
+
+
+void
+setinteractive(int on)
+{
+	static int is_interactive;
+
+	if (++on == is_interactive)
+		return;
+	is_interactive = on;
+	setsignal(SIGINT);
+	setsignal(SIGQUIT);
+	setsignal(SIGTERM);
+#ifndef CONFIG_FEATURE_SH_EXTRA_QUIET
+		if(is_interactive > 1) {
+			/* Looks like they want an interactive shell */
+			static int do_banner;
+
+				if(!do_banner) {
+					out1fmt(
+			"\n\n" BB_BANNER " Built-in shell (ash)\n"
+			"Enter 'help' for a list of built-in commands.\n\n");
+					do_banner++;
+				}
+		}
+#endif
+}
+
+
+#ifndef CONFIG_FEATURE_SH_EXTRA_QUIET
+/*** List the available builtins ***/
+
+static int helpcmd(int argc, char **argv)
+{
+	int col, i;
+
+	out1fmt("\nBuilt-in commands:\n-------------------\n");
+	for (col = 0, i = 0; i < NUMBUILTINS; i++) {
+		col += out1fmt("%c%s", ((col == 0) ? '\t' : ' '),
+					  builtincmd[i].name + 1);
+		if (col > 60) {
+			out1fmt("\n");
+			col = 0;
+		}
+	}
+#ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
+	{
+		extern const struct BB_applet applets[];
+		extern const size_t NUM_APPLETS;
+
+		for (i = 0; i < NUM_APPLETS; i++) {
+
+			col += out1fmt("%c%s", ((col == 0) ? '\t' : ' '), applets[i].name);
+			if (col > 60) {
+				out1fmt("\n");
+				col = 0;
+			}
+		}
+	}
+#endif
+	out1fmt("\n\n");
+	return EXIT_SUCCESS;
+}
+#endif /* CONFIG_FEATURE_SH_EXTRA_QUIET */
+
 /*
  * Called to exit the shell.
  */
 
-static void exitshell(int status)
+void
+exitshell(void)
 {
-	struct jmploc loc1, loc2;
+	struct jmploc loc;
 	char *p;
+	int status;
 
-	TRACE(("exitshell(%d) pid=%d\n", status, getpid()));
-	if (setjmp(loc1.loc)) {
-		goto l1;
+	status = exitstatus;
+	TRACE(("pid %d, exitshell(%d)\n", getpid(), status));
+	if (setjmp(loc.loc)) {
+		goto out;
 	}
-	if (setjmp(loc2.loc)) {
-		goto l2;
-	}
-	handler = &loc1;
+	handler = &loc;
 	if ((p = trap[0]) != NULL && *p != '\0') {
 		trap[0] = NULL;
 		evalstring(p, 0);
 	}
-l1:
-	handler = &loc2;   /* probably unnecessary */
 	flushall();
-#ifdef CONFIG_ASH_JOB_CONTROL
-	setjobctl(0);
-#endif
 #ifdef CONFIG_FEATURE_COMMAND_SAVEHISTORY
 	if (iflag && rootshell) {
 		const char *hp = lookupvar("HISTFILE");
@@ -11663,7 +11690,8 @@
 			save_history ( hp );
 	}
 #endif
-l2:
+out:
+	out1c('\n');
 	_exit(status);
 	/* NOTREACHED */
 }
@@ -11676,95 +11704,78 @@
 	return name ? signo : -1;
 }
 
-static struct var **hashvar(const char *);
-static void showvars(const char *, int, int);
+/*      $NetBSD: var.c,v 1.32 2003/01/22 20:36:04 dsl Exp $     */
+
+static struct var *vartab[VTABSIZE];
+
+static int vpcmp(const void *, const void *);
 static struct var **findvar(struct var **, const char *);
 
 /*
  * Initialize the varable symbol tables and import the environment
  */
 
+
+#ifdef CONFIG_ASH_GETOPTS
 /*
- * This routine initializes the builtin variables.  It is called when the
- * shell is initialized and again when a shell procedure is spawned.
+ * Safe version of setvar, returns 1 on success 0 on failure.
  */
 
-static void initvar()
+int
+setvarsafe(const char *name, const char *val, int flags)
 {
-	const struct varinit *ip;
-	struct var *vp;
-	struct var **vpp;
+	int err;
+	volatile int saveint;
+	struct jmploc *volatile savehandler = handler;
+	struct jmploc jmploc;
 
-	for (ip = varinit; (vp = ip->var) != NULL; ip++) {
-		if ((vp->flags & VEXPORT) == 0) {
-			vpp = hashvar(ip->text);
-			vp->next = *vpp;
-			*vpp = vp;
-			vp->text = bb_xstrdup(ip->text);
-			vp->flags = ip->flags;
-			vp->func = ip->func;
-		}
+	SAVEINT(saveint);
+	if (setjmp(jmploc.loc))
+		err = 1;
+	else {
+		handler = &jmploc;
+		setvar(name, val, flags);
+		err = 0;
 	}
-#if !defined(CONFIG_FEATURE_COMMAND_EDITING) || !defined(CONFIG_FEATURE_SH_FANCY_PROMPT)
-	/*
-	 * PS1 depends on uid
-	 */
-	if ((vps1.flags & VEXPORT) == 0) {
-		vpp = hashvar("PS1=$ ");
-		vps1.next = *vpp;
-		*vpp = &vps1;
-		vps1.text = bb_xstrdup(geteuid()? "PS1=$ " : "PS1=# ");
-		vps1.flags = VSTRFIXED | VTEXTFIXED;
-	}
-#endif
+	handler = savehandler;
+	RESTOREINT(saveint);
+	return err;
 }
+#endif
 
 /*
  * Set the value of a variable.  The flags argument is ored with the
  * flags of the variable.  If val is NULL, the variable is unset.
  */
 
-static void setvar(const char *name, const char *val, int flags)
+static void
+setvar(const char *name, const char *val, int flags)
 {
-	const char *p;
-	int len;
-	int namelen;
+	char *p, *q;
+	size_t namelen;
 	char *nameeq;
-	int isbad;
-	int vallen = 0;
+	size_t vallen;
 
-	isbad = 0;
-	p = name;
-	if (!is_name(*p))
-		isbad = 1;
-	p++;
-	for (;;) {
-		if (!is_in_name(*p)) {
-			if (*p == '\0' || *p == '=')
-				break;
-			isbad = 1;
-		}
-		p++;
-	}
+	q = endofname(name);
+	p = strchrnul(q, '=');
 	namelen = p - name;
-	if (isbad)
+	if (!namelen || p != q)
 		error("%.*s: bad variable name", namelen, name);
-	len = namelen + 2;	/* 2 is space for '=' and '\0' */
+	vallen = 0;
 	if (val == NULL) {
 		flags |= VUNSET;
 	} else {
-		len += vallen = strlen(val);
+		vallen = strlen(val);
 	}
 	INTOFF;
-	nameeq = xmalloc(len);
-	memcpy(nameeq, name, namelen);
-	nameeq[namelen] = '=';
-	if (val) {
-		memcpy(nameeq + namelen + 1, val, vallen + 1);
-	} else {
-		nameeq[namelen + 1] = '\0';
+	p = mempcpy(nameeq = ckmalloc(namelen + vallen + 2), name, namelen);
+	*p++ = '\0';
+	if (vallen) {
+		p[-1] = '=';
+		p = mempcpy(p, val, vallen);
 	}
-	setvareq(nameeq, flags);
+	*p = '\0';
+	setvareq(nameeq, flags | VNOSAVE);
 	INTON;
 }
 
@@ -11775,50 +11786,47 @@
  * the first argument as name=value.  Since the first argument will
  * be actually stored in the table, it should not be a string that
  * will go away.
+ * Called with interrupts off.
  */
 
-static void setvareq(char *s, int flags)
+void
+setvareq(char *s, int flags)
 {
 	struct var *vp, **vpp;
 
 	vpp = hashvar(s);
 	flags |= (VEXPORT & (((unsigned) (1 - aflag)) - 1));
-	if ((vp = *findvar(vpp, s))) {
+	vp = *findvar(vpp, s);
+	if (vp) {
 		if (vp->flags & VREADONLY) {
-			size_t len = strchr(s, '=') - s;
-
-			error("%.*s: is read only", len, s);
+			if (flags & VNOSAVE)
+				free(s);
+			error("%.*s: is read only", strchrnul(s, '=') - s, s);
 		}
-		INTOFF;
+
+		if (flags & VNOSET)
+			return;
 
 		if (vp->func && (flags & VNOFUNC) == 0)
-			(*vp->func) (strchr(s, '=') + 1);
+			(*vp->func)(strchrnul(s, '=') + 1);
 
-		if ((vp->flags & (VTEXTFIXED | VSTACK)) == 0)
-			free(vp->text);
+		if ((vp->flags & (VTEXTFIXED|VSTACK)) == 0)
+			ckfree(vp->text);
 
-		vp->flags &= ~(VTEXTFIXED | VSTACK | VUNSET);
-		vp->flags |= flags;
-		vp->text = s;
-
-#ifdef CONFIG_ASH_MAIL
-		/*
-		 * We could roll this to a function, to handle it as
-		 * a regular variable function callback, but why bother?
-		 */
-		if (iflag && (vp == &vmpath || (vp == &vmail && !mpathset())))
-			chkmail(1);
-#endif
-		INTON;
-		return;
+		flags |= vp->flags & ~(VTEXTFIXED|VSTACK|VNOSAVE|VUNSET);
+	} else {
+		if (flags & VNOSET)
+			return;
+		/* not found */
+		vp = ckmalloc(sizeof (*vp));
+		vp->next = *vpp;
+		vp->func = NULL;
+		*vpp = vp;
 	}
-	/* not found */
-	vp = xmalloc(sizeof(*vp));
-	vp->flags = flags;
+	if (!(flags & (VTEXTFIXED|VSTACK|VNOSAVE)))
+		s = savestr(s);
 	vp->text = s;
-	vp->next = *vpp;
-	vp->func = NULL;
-	*vpp = vp;
+	vp->flags = flags;
 }
 
 
@@ -11827,29 +11835,32 @@
  * Process a linked list of variable assignments.
  */
 
-static void listsetvar(struct strlist *mylist)
+static void
+listsetvar(struct strlist *list_set_var, int flags)
 {
-	struct strlist *lp;
+	struct strlist *lp = list_set_var;
 
+	if (!lp)
+		return;
 	INTOFF;
-	for (lp = mylist; lp; lp = lp->next) {
-		setvareq(bb_xstrdup(lp->text), 0);
-	}
+	do {
+		setvareq(lp->text, flags);
+	} while ((lp = lp->next));
 	INTON;
 }
 
 
-
 /*
  * Find the value of a variable.  Returns NULL if not set.
  */
 
-static const char *lookupvar(const char *name)
+static char *
+lookupvar(const char *name)
 {
 	struct var *v;
 
 	if ((v = *findvar(hashvar(name), name)) && !(v->flags & VUNSET)) {
-		return strchr(v->text, '=') + 1;
+		return strchrnul(v->text, '=') + 1;
 	}
 	return NULL;
 }
@@ -11860,13 +11871,14 @@
  * Search the environment of a builtin command.
  */
 
-static const char *bltinlookup(const char *name)
+static char *
+bltinlookup(const char *name)
 {
-	const struct strlist *sp;
+	struct strlist *sp;
 
-	for (sp = cmdenviron; sp; sp = sp->next) {
+	for (sp = cmdenviron ; sp ; sp = sp->next) {
 		if (varequal(sp->text, name))
-			return strchr(sp->text, '=') + 1;
+			return strchrnul(sp->text, '=') + 1;
 	}
 	return lookupvar(name);
 }
@@ -11874,44 +11886,69 @@
 
 
 /*
- * Generate a list of exported variables.  This routine is used to construct
- * the third argument to execve when executing a program.
+ * Generate a list of variables satisfying the given conditions.
  */
 
-static char **environment()
+static char **
+listvars(int on, int off, char ***end)
 {
-	int nenv;
 	struct var **vpp;
 	struct var *vp;
-	char **env;
 	char **ep;
+	int mask;
 
-	nenv = 0;
-	for (vpp = vartab; vpp < vartab + VTABSIZE; vpp++) {
-		for (vp = *vpp; vp; vp = vp->next)
-			if (vp->flags & VEXPORT)
-				nenv++;
-	}
-	ep = env = stalloc((nenv + 1) * sizeof *env);
-	for (vpp = vartab; vpp < vartab + VTABSIZE; vpp++) {
-		for (vp = *vpp; vp; vp = vp->next)
-			if (vp->flags & VEXPORT)
-				*ep++ = vp->text;
-	}
-	*ep = NULL;
-	return env;
+	STARTSTACKSTR(ep);
+	vpp = vartab;
+	mask = on | off;
+	do {
+		for (vp = *vpp ; vp ; vp = vp->next)
+			if ((vp->flags & mask) == on) {
+				if (ep == stackstrend())
+					ep = growstackstr();
+				*ep++ = (char *) vp->text;
+			}
+	} while (++vpp < vartab + VTABSIZE);
+	if (ep == stackstrend())
+		ep = growstackstr();
+	if (end)
+		*end = ep;
+	*ep++ = NULL;
+	return grabstackstr(ep);
 }
 
 
+
 /*
- * Command to list all variables which are set.  Currently this command
- * is invoked from the set command when the set command is called without
- * any variables.
+ * POSIX requires that 'set' (but not export or readonly) output the
+ * variables in lexicographic order - by the locale's collating order (sigh).
+ * Maybe we could keep them in an ordered balanced binary tree
+ * instead of hashed lists.
+ * For now just roll 'em through qsort for printing...
  */
 
-static int showvarscmd(int argc, char **argv)
+static int
+showvars(const char *sep_prefix, int on, int off)
 {
-	showvars(nullstr, VUNSET, VUNSET);
+	const char *sep;
+	char **ep, **epend;
+
+	ep = listvars(on, off, &epend);
+	qsort(ep, epend - ep, sizeof(char *), vpcmp);
+
+	sep = *sep_prefix ? spcstr : sep_prefix;
+
+	for (; ep < epend; ep++) {
+		const char *p;
+		const char *q;
+
+		p = strchrnul(*ep, '=');
+		q = nullstr;
+		if (*p)
+			q = single_quote(++p);
+
+		out1fmt("%s%s%.*s%s\n", sep_prefix, sep, (int)(p - *ep), *ep, q);
+	}
+
 	return 0;
 }
 
@@ -11921,29 +11958,29 @@
  * The export and readonly commands.
  */
 
-static int exportcmd(int argc, char **argv)
+static int
+exportcmd(int argc, char **argv)
 {
 	struct var *vp;
 	char *name;
 	const char *p;
-	int flag = argv[0][0] == 'r' ? VREADONLY : VEXPORT;
-	int pflag;
+	char **aptr;
+	int flag = argv[0][0] == 'r'? VREADONLY : VEXPORT;
+	int notp;
 
-	listsetvar(cmdenviron);
-	pflag = (nextopt("p") == 'p');
-	if (argc > 1 && !pflag) {
-		while ((name = *argptr++) != NULL) {
+	notp = nextopt("p") - 'p';
+	if (notp && ((name = *(aptr = argptr)))) {
+		do {
 			if ((p = strchr(name, '=')) != NULL) {
 				p++;
 			} else {
 				if ((vp = *findvar(hashvar(name), name))) {
 					vp->flags |= flag;
-					goto found;
+					continue;
 				}
 			}
 			setvar(name, p, flag);
-		  found:;
-		}
+		} while ((name = *++aptr) != NULL);
 	} else {
 		showvars(argv[0], flag, 0);
 	}
@@ -11952,62 +11989,45 @@
 
 
 /*
- * The "local" command.
- */
-
-/* funcnest nonzero if we are currently evaluating a function */
-
-static int localcmd(int argc, char **argv)
-{
-	char *name;
-
-	if (!funcnest)
-		error("Not in a function");
-	while ((name = *argptr++) != NULL) {
-		mklocal(name);
-	}
-	return 0;
-}
-
-
-/*
  * Make a variable a local variable.  When a variable is made local, it's
  * value and flags are saved in a localvar structure.  The saved values
  * will be restored when the shell function returns.  We handle the name
  * "-" as a special case.
  */
 
-static void mklocal(char *name)
+static inline void
+mklocal(char *name)
 {
 	struct localvar *lvp;
 	struct var **vpp;
 	struct var *vp;
 
 	INTOFF;
-	lvp = xmalloc(sizeof(struct localvar));
+	lvp = ckmalloc(sizeof (struct localvar));
 	if (name[0] == '-' && name[1] == '\0') {
 		char *p;
-
-		p = xmalloc(sizeof optet_vals);
-		lvp->text = memcpy(p, optet_vals, sizeof optet_vals);
+		p = ckmalloc(sizeof(optlist));
+		lvp->text = memcpy(p, optlist, sizeof(optlist));
 		vp = NULL;
 	} else {
+		char *eq;
+
 		vpp = hashvar(name);
 		vp = *findvar(vpp, name);
+		eq = strchr(name, '=');
 		if (vp == NULL) {
-			if (strchr(name, '='))
-				setvareq(bb_xstrdup(name), VSTRFIXED);
+			if (eq)
+				setvareq(name, VSTRFIXED);
 			else
 				setvar(name, NULL, VSTRFIXED);
-			vp = *vpp;	/* the new variable */
-			lvp->text = NULL;
+			vp = *vpp;      /* the new variable */
 			lvp->flags = VUNSET;
 		} else {
 			lvp->text = vp->text;
 			lvp->flags = vp->flags;
-			vp->flags |= VSTRFIXED | VTEXTFIXED;
-			if (strchr(name, '='))
-				setvareq(bb_xstrdup(name), 0);
+			vp->flags |= VSTRFIXED|VTEXTFIXED;
+			if (eq)
+				setvareq(name, 0);
 		}
 	}
 	lvp->vp = vp;
@@ -12016,12 +12036,32 @@
 	INTON;
 }
 
+/*
+ * The "local" command.
+ */
+
+static int
+localcmd(int argc, char **argv)
+{
+	char *name;
+
+	argv = argptr;
+	while ((name = *argv++) != NULL) {
+		mklocal(name);
+	}
+	return 0;
+}
+
+
+
 
 /*
  * Called after a function returns.
+ * Interrupts must be off.
  */
 
-static void poplocalvars()
+static void
+poplocalvars(void)
 {
 	struct localvar *lvp;
 	struct var *vp;
@@ -12029,64 +12069,55 @@
 	while ((lvp = localvars) != NULL) {
 		localvars = lvp->next;
 		vp = lvp->vp;
-		if (vp == NULL) {	/* $- saved */
-			memcpy(optet_vals, lvp->text, sizeof optet_vals);
-			free(lvp->text);
-		} else if ((lvp->flags & (VUNSET | VSTRFIXED)) == VUNSET) {
-			(void) unsetvar(vp->text);
+		TRACE(("poplocalvar %s", vp ? vp->text : "-"));
+		if (vp == NULL) {       /* $- saved */
+			memcpy(optlist, lvp->text, sizeof(optlist));
+			ckfree(lvp->text);
+			optschanged();
+		} else if ((lvp->flags & (VUNSET|VSTRFIXED)) == VUNSET) {
+			unsetvar(vp->text);
 		} else {
-			if ((vp->flags & VTEXTFIXED) == 0)
-				free(vp->text);
+			if (vp->func)
+				(*vp->func)(strchrnul(lvp->text, '=') + 1);
+			if ((vp->flags & (VTEXTFIXED|VSTACK)) == 0)
+				ckfree(vp->text);
 			vp->flags = lvp->flags;
 			vp->text = lvp->text;
 		}
-		free(lvp);
+		ckfree(lvp);
 	}
 }
 
 
-static int setvarcmd(int argc, char **argv)
-{
-	if (argc <= 2)
-		return unsetcmd(argc, argv);
-	else if (argc == 3)
-		setvar(argv[1], argv[2], 0);
-	else
-		error("List assignment not implemented");
-	return 0;
-}
-
-
 /*
  * The unset builtin command.  We unset the function before we unset the
  * variable to allow a function to be unset when there is a readonly variable
  * with the same name.
  */
 
-static int unsetcmd(int argc, char **argv)
+int
+unsetcmd(int argc, char **argv)
 {
 	char **ap;
 	int i;
-	int flg_func = 0;
-	int flg_var = 0;
+	int flag = 0;
 	int ret = 0;
 
 	while ((i = nextopt("vf")) != '\0') {
-		if (i == 'f')
-			flg_func = 1;
-		else
-			flg_var = 1;
+		flag = i;
 	}
-	if (flg_func == 0 && flg_var == 0)
-		flg_var = 1;
 
-	for (ap = argptr; *ap; ap++) {
-		if (flg_func)
+	for (ap = argptr; *ap ; ap++) {
+		if (flag != 'f') {
+			i = unsetvar(*ap);
+			ret |= i;
+			if (!(i & 2))
+				continue;
+		}
+		if (flag != 'v')
 			unsetfunc(*ap);
-		if (flg_var)
-			ret |= unsetvar(*ap);
 	}
-	return ret;
+	return ret & 1;
 }
 
 
@@ -12094,32 +12125,41 @@
  * Unset the specified variable.
  */
 
-static int unsetvar(const char *s)
+int
+unsetvar(const char *s)
 {
 	struct var **vpp;
 	struct var *vp;
+	int retval;
 
 	vpp = findvar(hashvar(s), s);
 	vp = *vpp;
+	retval = 2;
 	if (vp) {
-		if (vp->flags & VREADONLY)
-			return (1);
-		INTOFF;
-		if (*(strchr(vp->text, '=') + 1) != '\0')
-			setvar(s, nullstr, 0);
-		vp->flags &= ~VEXPORT;
-		vp->flags |= VUNSET;
-		if ((vp->flags & VSTRFIXED) == 0) {
-			if ((vp->flags & VTEXTFIXED) == 0)
-				free(vp->text);
+		int flags = vp->flags;
+
+		retval = 1;
+		if (flags & VREADONLY)
+			goto out;
+		if (flags & VUNSET)
+			goto ok;
+		if ((flags & VSTRFIXED) == 0) {
+			INTOFF;
+			if ((flags & (VTEXTFIXED|VSTACK)) == 0)
+				ckfree(vp->text);
 			*vpp = vp->next;
-			free(vp);
+			ckfree(vp);
+			INTON;
+		} else {
+			setvar(s, 0, 0);
+			vp->flags &= ~VEXPORT;
 		}
-		INTON;
-		return (0);
+ok:
+		retval = 0;
 	}
 
-	return (0);
+out:
+	return retval;
 }
 
 
@@ -12128,7 +12168,8 @@
  * Find the appropriate entry in the hash table from the name.
  */
 
-static struct var **hashvar(const char *p)
+static struct var **
+hashvar(const char *p)
 {
 	unsigned int hashval;
 
@@ -12141,46 +12182,38 @@
 
 
 /*
- * Returns true if the two strings specify the same varable.  The first
- * variable name is terminated by '='; the second may be terminated by
+ * Compares two strings up to the first = or '\0'.  The first
+ * string must be terminated by '='; the second may be terminated by
  * either '=' or '\0'.
  */
 
-static int varequal(const char *p, const char *q)
+int
+varcmp(const char *p, const char *q)
 {
-	while (*p == *q++) {
-		if (*p++ == '=')
-			return 1;
+	int c, d;
+
+	while ((c = *p) == (d = *q)) {
+		if (!c || c == '=')
+			goto out;
+		p++;
+		q++;
 	}
-	if (*p == '=' && *(q - 1) == '\0')
-		return 1;
-	return 0;
+	if (c == '=')
+		c = 0;
+	if (d == '=')
+		d = 0;
+out:
+	return c - d;
 }
 
-static void showvars(const char *myprefix, int mask, int xor)
+static int
+vpcmp(const void *a, const void *b)
 {
-	struct var **vpp;
-	struct var *vp;
-	const char *sep = myprefix == nullstr ? myprefix : spcstr;
-
-	for (vpp = vartab; vpp < vartab + VTABSIZE; vpp++) {
-		for (vp = *vpp; vp; vp = vp->next) {
-			if ((vp->flags & mask) ^ xor) {
-				char *p;
-				int len;
-
-				p = strchr(vp->text, '=') + 1;
-				len = p - vp->text;
-				p = single_quote(p);
-
-				printf("%s%s%.*s%s\n", myprefix, sep, len, vp->text, p);
-				stunalloc(p);
-			}
-		}
-	}
+	return varcmp(*(const char **)a, *(const char **)b);
 }
 
-static struct var **findvar(struct var **vpp, const char *name)
+static struct var **
+findvar(struct var **vpp, const char *name)
 {
 	for (; *vpp; vpp = &(*vpp)->next) {
 		if (varequal((*vpp)->text, name)) {
@@ -12189,68 +12222,420 @@
 	}
 	return vpp;
 }
+/*      $NetBSD: setmode.c,v 1.29 2003/01/15 23:58:03 kleink Exp $      */
 
 /*
  * Copyright (c) 1999 Herbert Xu <herbert@debian.org>
- * This file contains code for the times builtin.
+ * This code for the times builtin.
  */
-static int timescmd(int argc, char **argv)
-{
+
+#include <sys/times.h>
+
+int timescmd(int ac, char **av) {
 	struct tms buf;
 	long int clk_tck = sysconf(_SC_CLK_TCK);
 
 	times(&buf);
-	printf("%dm%fs %dm%fs\n%dm%fs %dm%fs\n",
-		   (int) (buf.tms_utime / clk_tck / 60),
-		   ((double) buf.tms_utime) / clk_tck,
-		   (int) (buf.tms_stime / clk_tck / 60),
-		   ((double) buf.tms_stime) / clk_tck,
-		   (int) (buf.tms_cutime / clk_tck / 60),
-		   ((double) buf.tms_cutime) / clk_tck,
-		   (int) (buf.tms_cstime / clk_tck / 60),
-		   ((double) buf.tms_cstime) / clk_tck);
+	out1fmt("%dm%fs %dm%fs\n%dm%fs %dm%fs\n",
+	       (int) (buf.tms_utime / clk_tck / 60),
+	       ((double) buf.tms_utime) / clk_tck,
+	       (int) (buf.tms_stime / clk_tck / 60),
+	       ((double) buf.tms_stime) / clk_tck,
+	       (int) (buf.tms_cutime / clk_tck / 60),
+	       ((double) buf.tms_cutime) / clk_tck,
+	       (int) (buf.tms_cstime / clk_tck / 60),
+	       ((double) buf.tms_cstime) / clk_tck);
 	return 0;
 }
 
 #ifdef CONFIG_ASH_MATH_SUPPORT
-/* The let builtin.  */
-int letcmd(int argc, char **argv)
+static int
+dash_arith(const char *s)
 {
-	int errcode;
 	long result = 0;
+	int errcode = 0;
 
-	if (argc == 2) {
-		char *tmp, *expression, p[13];
+	INTOFF;
+	result = arith(s, &errcode);
+	if (errcode < 0) {
+		if (errcode == -2)
+			error("divide by zero");
+		else
+			synerror(s);
+	}
+	INTON;
 
-		expression = strchr(argv[1], '=');
-		if (!expression) {
-			/* Cannot use 'error()' here, or the return code
-			 * will be incorrect */
-			out2fmt("sh: let: syntax error: \"%s\"\n", argv[1]);
-			return 0;
-		}
-		*expression = '\0';
-		tmp = ++expression;
-		result = arith(tmp, &errcode);
-		if (errcode < 0) {
-			/* Cannot use 'error()' here, or the return code
-			 * will be incorrect */
-			out2fmt("sh: let: ");
-			if (errcode == -2)
-				out2fmt("divide by zero");
-			else
-				out2fmt("syntax error: \"%s=%s\"\n", argv[1], expression);
-			return 0;
-		}
-		snprintf(p, 12, "%ld", result);
-		setvar(argv[1], bb_xstrdup(p), 0);
-	} else if (argc >= 3)
-		synerror("invalid operand");
-	return !result;
+	return (result);
 }
+
+
+/*
+ *  The exp(1) builtin.
+ */
+static int
+expcmd(int argc, char **argv)
+{
+	const char *p;
+	char *concat;
+	char **ap;
+	long i;
+
+	if (argc > 1) {
+		p = argv[1];
+		if (argc > 2) {
+			/*
+			 * concatenate arguments
+			 */
+			STARTSTACKSTR(concat);
+			ap = argv + 2;
+			for (;;) {
+				while (*p)
+					STPUTC(*p++, concat);
+				if ((p = *ap++) == NULL)
+					break;
+				STPUTC(' ', concat);
+			}
+			STPUTC('\0', concat);
+			p = grabstackstr(concat);
+		}
+	} else
+		p = nullstr;
+
+	i = dash_arith(p);
+
+	out1fmt("%ld\n", i);
+	return (! i);
+}
+#endif /* CONFIG_ASH_MATH_SUPPORT */
+
+/*      $NetBSD: miscbltin.c,v 1.31 2002/11/24 22:35:41 christos Exp $  */
+
+/*
+ * Miscelaneous builtins.
+ */
+
+#undef rflag
+
+#ifdef __GLIBC__
+#if !defined(__GLIBC__) || __GLIBC__ == 2 && __GLIBC_MINOR__ < 1
+typedef enum __rlimit_resource rlim_t;
+#endif
 #endif
 
 
+/*
+ * The read builtin.  The -e option causes backslashes to escape the
+ * following character.
+ *
+ * This uses unbuffered input, which may be avoidable in some cases.
+ */
+
+static int
+readcmd(int argc, char **argv)
+{
+	char **ap;
+	int backslash;
+	char c;
+	int rflag;
+	char *prompt;
+	const char *ifs;
+	char *p;
+	int startword;
+	int status;
+	int i;
+
+	rflag = 0;
+	prompt = NULL;
+	while ((i = nextopt("p:r")) != '\0') {
+		if (i == 'p')
+			prompt = optionarg;
+		else
+			rflag = 1;
+	}
+	if (prompt && isatty(0)) {
+		out2str(prompt);
+		flushall();
+	}
+	if (*(ap = argptr) == NULL)
+		error("arg count");
+	if ((ifs = bltinlookup("IFS")) == NULL)
+		ifs = defifs;
+	status = 0;
+	startword = 1;
+	backslash = 0;
+	STARTSTACKSTR(p);
+	for (;;) {
+		if (read(0, &c, 1) != 1) {
+			status = 1;
+			break;
+		}
+		if (c == '\0')
+			continue;
+		if (backslash) {
+			backslash = 0;
+			if (c != '\n')
+				goto put;
+			continue;
+		}
+		if (!rflag && c == '\\') {
+			backslash++;
+			continue;
+		}
+		if (c == '\n')
+			break;
+		if (startword && *ifs == ' ' && strchr(ifs, c)) {
+			continue;
+		}
+		startword = 0;
+		if (ap[1] != NULL && strchr(ifs, c) != NULL) {
+			STACKSTRNUL(p);
+			setvar(*ap, stackblock(), 0);
+			ap++;
+			startword = 1;
+			STARTSTACKSTR(p);
+		} else {
+put:
+			STPUTC(c, p);
+		}
+	}
+	STACKSTRNUL(p);
+	/* Remove trailing blanks */
+	while ((char *)stackblock() <= --p && strchr(ifs, *p) != NULL)
+		*p = '\0';
+	setvar(*ap, stackblock(), 0);
+	while (*++ap != NULL)
+		setvar(*ap, nullstr, 0);
+	return status;
+}
+
+
+static int umaskcmd(int argc, char **argv)
+{
+	static const char permuser[3] = "ugo";
+	static const char permmode[3] = "rwx";
+	static const short int permmask[] = {
+		S_IRUSR, S_IWUSR, S_IXUSR,
+		S_IRGRP, S_IWGRP, S_IXGRP,
+		S_IROTH, S_IWOTH, S_IXOTH
+	};
+
+	char *ap;
+	mode_t mask;
+	int i;
+	int symbolic_mode = 0;
+
+	while (nextopt("S") != '\0') {
+		symbolic_mode = 1;
+	}
+
+	INTOFF;
+	mask = umask(0);
+	umask(mask);
+	INTON;
+
+	if ((ap = *argptr) == NULL) {
+		if (symbolic_mode) {
+			char buf[18];
+			char *p = buf;
+
+			for (i = 0; i < 3; i++) {
+				int j;
+
+				*p++ = permuser[i];
+				*p++ = '=';
+				for (j = 0; j < 3; j++) {
+					if ((mask & permmask[3 * i + j]) == 0) {
+						*p++ = permmode[j];
+					}
+				}
+				*p++ = ',';
+			}
+			*--p = 0;
+			puts(buf);
+		} else {
+			out1fmt("%.4o\n", mask);
+		}
+	} else {
+		if (is_digit((unsigned char) *ap)) {
+			mask = 0;
+			do {
+				if (*ap >= '8' || *ap < '0')
+					error(illnum, argv[1]);
+				mask = (mask << 3) + (*ap - '0');
+			} while (*++ap != '\0');
+			umask(mask);
+		} else {
+			mask = ~mask & 0777;
+			if (!bb_parse_mode(ap, &mask)) {
+				error("Illegal mode: %s", ap);
+			}
+			umask(~mask & 0777);
+		}
+	}
+	return 0;
+}
+
+/*
+ * ulimit builtin
+ *
+ * This code, originally by Doug Gwyn, Doug Kingston, Eric Gisin, and
+ * Michael Rendell was ripped from pdksh 5.0.8 and hacked for use with
+ * ash by J.T. Conklin.
+ *
+ * Public domain.
+ */
+
+struct limits {
+	const char *name;
+	int     cmd;
+	int     factor; /* multiply by to get rlim_{cur,max} values */
+	char    option;
+};
+
+static const struct limits limits[] = {
+#ifdef RLIMIT_CPU
+	{ "time(seconds)",              RLIMIT_CPU,        1, 't' },
+#endif
+#ifdef RLIMIT_FSIZE
+	{ "file(blocks)",               RLIMIT_FSIZE,    512, 'f' },
+#endif
+#ifdef RLIMIT_DATA
+	{ "data(kbytes)",               RLIMIT_DATA,    1024, 'd' },
+#endif
+#ifdef RLIMIT_STACK
+	{ "stack(kbytes)",              RLIMIT_STACK,   1024, 's' },
+#endif
+#ifdef  RLIMIT_CORE
+	{ "coredump(blocks)",           RLIMIT_CORE,     512, 'c' },
+#endif
+#ifdef RLIMIT_RSS
+	{ "memory(kbytes)",             RLIMIT_RSS,     1024, 'm' },
+#endif
+#ifdef RLIMIT_MEMLOCK
+	{ "locked memory(kbytes)",      RLIMIT_MEMLOCK, 1024, 'l' },
+#endif
+#ifdef RLIMIT_NPROC
+	{ "process(processes)",         RLIMIT_NPROC,      1, 'p' },
+#endif
+#ifdef RLIMIT_NOFILE
+	{ "nofiles(descriptors)",       RLIMIT_NOFILE,     1, 'n' },
+#endif
+#ifdef RLIMIT_VMEM
+	{ "vmemory(kbytes)",            RLIMIT_VMEM,    1024, 'v' },
+#endif
+#ifdef RLIMIT_SWAP
+	{ "swap(kbytes)",               RLIMIT_SWAP,    1024, 'w' },
+#endif
+	{ (char *) 0,                   0,                 0,  '\0' }
+};
+
+int
+ulimitcmd(int argc, char **argv)
+{
+	int     c;
+	rlim_t val = 0;
+	enum { SOFT = 0x1, HARD = 0x2 }
+			how = SOFT | HARD;
+	const struct limits     *l;
+	int             set, all = 0;
+	int             optc, what;
+	struct rlimit   limit;
+
+	what = 'f';
+	while ((optc = nextopt("HSatfdsmcnpl")) != '\0')
+		switch (optc) {
+		case 'H':
+			how = HARD;
+			break;
+		case 'S':
+			how = SOFT;
+			break;
+		case 'a':
+			all = 1;
+			break;
+		default:
+			what = optc;
+		}
+
+	for (l = limits; l->name && l->option != what; l++)
+		;
+	if (!l->name)
+		error("internal error (%c)", what);
+
+	set = *argptr ? 1 : 0;
+	if (set) {
+		char *p = *argptr;
+
+		if (all || argptr[1])
+			error("too many arguments");
+		if (strcmp(p, "unlimited") == 0)
+			val = RLIM_INFINITY;
+		else {
+			val = (rlim_t) 0;
+
+			while ((c = *p++) >= '0' && c <= '9')
+			{
+				val = (val * 10) + (long)(c - '0');
+				if (val < (rlim_t) 0)
+					break;
+			}
+			if (c)
+				error("bad number");
+			val *= l->factor;
+		}
+	}
+	if (all) {
+		for (l = limits; l->name; l++) {
+			getrlimit(l->cmd, &limit);
+			if (how & SOFT)
+				val = limit.rlim_cur;
+			else if (how & HARD)
+				val = limit.rlim_max;
+
+			out1fmt("%-20s ", l->name);
+			if (val == RLIM_INFINITY)
+				out1fmt("unlimited\n");
+			else
+			{
+				val /= l->factor;
+				out1fmt("%lld\n", (long long) val);
+			}
+		}
+		return 0;
+	}
+
+	getrlimit(l->cmd, &limit);
+	if (set) {
+		if (how & HARD)
+			limit.rlim_max = val;
+		if (how & SOFT)
+			limit.rlim_cur = val;
+		if (setrlimit(l->cmd, &limit) < 0)
+			error("error setting limit (%m)");
+	} else {
+		if (how & SOFT)
+			val = limit.rlim_cur;
+		else if (how & HARD)
+			val = limit.rlim_max;
+
+		if (val == RLIM_INFINITY)
+			out1fmt("unlimited\n");
+		else
+		{
+			val /= l->factor;
+			out1fmt("%lld\n", (long long) val);
+		}
+	}
+	return 0;
+}
+
+#ifdef DEBUG
+const char *bb_applet_name = "debug stuff usage";
+int main(int argc, char **argv)
+{
+	return ash_main(argc, argv);
+}
+#endif
 
 /*-
  * Copyright (c) 1989, 1991, 1993, 1994
diff --git a/shell/cmdedit.c b/shell/cmdedit.c
index 843f73f..7170672 100644
--- a/shell/cmdedit.c
+++ b/shell/cmdedit.c
@@ -9,7 +9,7 @@
  *      Adam Rogoyski    <rogoyski@cs.utexas.edu>
  *      Dave Cinege      <dcinege@psychosis.com>
  *      Jakub Jelinek (c) 1995
- *      Erik Andersen    <andersen@codepoet.org> (Majorly adjusted for busybox)
+ *      Erik Andersen    <andersee@debian.org> (Majorly adjusted for busybox)
  *
  * This code is 'as is' with no warranty.
  *
@@ -63,7 +63,7 @@
 
 #define D(x)  x
 
-#endif							/* TEST */
+#endif                                                  /* TEST */
 
 #ifdef CONFIG_FEATURE_COMMAND_TAB_COMPLETION
 #include <dirent.h>
@@ -86,7 +86,7 @@
 #       else
 #               include <pwd.h>
 #       endif  /* TEST */
-#endif							/* advanced FEATURES */
+#endif                                                  /* advanced FEATURES */
 
 
 /* Maximum length of the linked list for the command line history */
@@ -115,30 +115,30 @@
 
 
 static
-volatile int cmdedit_termw = 80;	/* actual terminal width */
+volatile int cmdedit_termw = 80;        /* actual terminal width */
 static
-volatile int handlers_sets = 0;	/* Set next bites: */
+volatile int handlers_sets = 0; /* Set next bites: */
 
 enum {
-	SET_ATEXIT = 1,		/* when atexit() has been called 
+	SET_ATEXIT = 1,         /* when atexit() has been called
 				   and get euid,uid,gid to fast compare */
 	SET_WCHG_HANDLERS = 2,  /* winchg signal handler */
 	SET_RESET_TERM = 4,     /* if the terminal needs to be reset upon exit */
 };
 
 
-static int cmdedit_x;		/* real x terminal position */
-static int cmdedit_y;		/* pseudoreal y terminal position */
-static int cmdedit_prmt_len;	/* lenght prompt without colores string */
+static int cmdedit_x;           /* real x terminal position */
+static int cmdedit_y;           /* pseudoreal y terminal position */
+static int cmdedit_prmt_len;    /* lenght prompt without colores string */
 
-static int cursor;		/* required global for signal handler */
-static int len;			/* --- "" - - "" - -"- --""-- --""--- */
-static char *command_ps;	/* --- "" - - "" - -"- --""-- --""--- */
+static int cursor;              /* required global for signal handler */
+static int len;                 /* --- "" - - "" - -"- --""-- --""--- */
+static char *command_ps;        /* --- "" - - "" - -"- --""-- --""--- */
 static
 #ifndef CONFIG_FEATURE_SH_FANCY_PROMPT
 	const
 #endif
-char *cmdedit_prompt;		/* --- "" - - "" - -"- --""-- --""--- */
+char *cmdedit_prompt;           /* --- "" - - "" - -"- --""-- --""--- */
 
 #ifdef CONFIG_FEATURE_GETUSERNAME_AND_HOMEDIR
 static char *user_buf = "";
@@ -161,31 +161,36 @@
 static int my_uid;
 static int my_gid;
 
-#endif	/* CONFIG_FEATURE_COMMAND_TAB_COMPLETION */
+#endif  /* CONFIG_FEATURE_COMMAND_TAB_COMPLETION */
+
+/* It seems that libc5 doesn't know what a sighandler_t is... */
+#if (__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1)
+typedef void (*sighandler_t) (int);
+#endif
 
 static void cmdedit_setwidth(int w, int redraw_flg);
 
 static void win_changed(int nsig)
 {
 	struct winsize win = { 0, 0, 0, 0 };
-	static sighandler_t previous_SIGWINCH_handler;	/* for reset */
+	static sighandler_t previous_SIGWINCH_handler;  /* for reset */
 
 	/*   emulate      || signal call */
 	if (nsig == -SIGWINCH || nsig == SIGWINCH) {
 		ioctl(0, TIOCGWINSZ, &win);
 		if (win.ws_col > 0) {
 			cmdedit_setwidth(win.ws_col, nsig == SIGWINCH);
-		} 
+		}
 	}
 	/* Unix not all standart in recall signal */
 
-	if (nsig == -SIGWINCH)		/* save previous handler   */
+	if (nsig == -SIGWINCH)          /* save previous handler   */
 		previous_SIGWINCH_handler = signal(SIGWINCH, win_changed);
-	else if (nsig == SIGWINCH)	/* signaled called handler */
-		signal(SIGWINCH, win_changed);	/* set for next call       */
-	else						/* nsig == 0 */
+	else if (nsig == SIGWINCH)      /* signaled called handler */
+		signal(SIGWINCH, win_changed);  /* set for next call       */
+	else                                            /* nsig == 0 */
 		/* set previous handler    */
-		signal(SIGWINCH, previous_SIGWINCH_handler);	/* reset    */
+		signal(SIGWINCH, previous_SIGWINCH_handler);    /* reset    */
 }
 
 static void cmdedit_reset_term(void)
@@ -211,9 +216,9 @@
 	int c = (int)((unsigned char) command_ps[cursor]);
 
 	if (c == 0)
-		c = ' ';	/* destroy end char? */
+		c = ' ';        /* destroy end char? */
 #ifdef CONFIG_FEATURE_NONPRINTABLE_INVERSE_PUT
-	if (!Isprint(c)) {	/* Inverse put non-printable characters */
+	if (!Isprint(c)) {      /* Inverse put non-printable characters */
 		if (c >= 128)
 			c -= 128;
 		if (c < ' ')
@@ -270,9 +275,9 @@
 {
 	if (num > cursor)
 		num = cursor;
-	cursor -= num;		/* new cursor (in command, not terminal) */
+	cursor -= num;          /* new cursor (in command, not terminal) */
 
-	if (cmdedit_x >= num) {		/* no to up line */
+	if (cmdedit_x >= num) {         /* no to up line */
 		cmdedit_x -= num;
 		if (num < 4)
 			while (num-- > 0)
@@ -284,22 +289,22 @@
 		int count_y;
 
 		if (cmdedit_x) {
-			putchar('\r');		/* back to first terminal pos.  */
-			num -= cmdedit_x;	/* set previous backward        */
+			putchar('\r');          /* back to first terminal pos.  */
+			num -= cmdedit_x;       /* set previous backward        */
 		}
 		count_y = 1 + num / cmdedit_termw;
 		printf("\033[%dA", count_y);
 		cmdedit_y -= count_y;
 		/*  require  forward  after  uping   */
 		cmdedit_x = cmdedit_termw * count_y - num;
-		printf("\033[%dC", cmdedit_x);	/* set term cursor   */
+		printf("\033[%dC", cmdedit_x);  /* set term cursor   */
 	}
 }
 
 static void put_prompt(void)
 {
 	out1str(cmdedit_prompt);
-	cmdedit_x = cmdedit_prmt_len;	/* count real x terminal position */
+	cmdedit_x = cmdedit_prmt_len;   /* count real x terminal position */
 	cursor = 0;
 	cmdedit_y = 0;                  /* new quasireal y */
 }
@@ -335,7 +340,7 @@
 		if (c == '\\') {
 			const char *cp = prmt_ptr;
 			int l;
-			
+
 			c = bb_process_escape_sequence(&prmt_ptr);
 			if(prmt_ptr==cp) {
 			  if (*cp == 0)
@@ -346,7 +351,7 @@
 			  case 'u':
 				pbuf = user_buf;
 				break;
-#endif	
+#endif
 			  case 'h':
 				pbuf = hostname_buf;
 				if (pbuf == 0) {
@@ -378,7 +383,7 @@
 					strcpy(pbuf+1, pwd_buf+l);
 					}
 				break;
-#endif	
+#endif
 			  case 'W':
 				pbuf = pwd_buf;
 				cp = strrchr(pbuf,'/');
@@ -391,7 +396,7 @@
 			  case 'e': case 'E':     /* \e \E = \033 */
 				c = '\033';
 				break;
-			  case 'x': case 'X': 
+			  case 'x': case 'X':
 				for (l = 0; l < 3;) {
 					int h;
 					buf2[l++] = *prmt_ptr;
@@ -416,7 +421,7 @@
 				}
 				break;
 			  }
-			} 
+			}
 		}
 		if(pbuf == buf)
 			*pbuf = c;
@@ -437,12 +442,12 @@
 /* draw promt, editor line, and clear tail */
 static void redraw(int y, int back_cursor)
 {
-	if (y > 0)				/* up to start y */
+	if (y > 0)                              /* up to start y */
 		printf("\033[%dA", y);
 	putchar('\r');
 	put_prompt();
-	input_end();				/* rewrite */
-	printf("\033[J");			/* destroy tail after cursor */
+	input_end();                            /* rewrite */
+	printf("\033[J");                       /* destroy tail after cursor */
 	input_backward(back_cursor);
 }
 
@@ -456,9 +461,9 @@
 
 	strcpy(command_ps + j, command_ps + j + 1);
 	len--;
-	input_end();			/* rewtite new line */
-	cmdedit_set_out_char(0);	/* destroy end char */
-	input_backward(cursor - j);	/* back to old pos cursor */
+	input_end();                    /* rewtite new line */
+	cmdedit_set_out_char(0);        /* destroy end char */
+	input_backward(cursor - j);     /* back to old pos cursor */
 }
 
 /* Delete the char in back of the cursor */
@@ -496,7 +501,7 @@
 			redraw((new_y >= cmdedit_y ? new_y : cmdedit_y), len - cursor);
 			fflush(stdout);
 		}
-	} 
+	}
 }
 
 static void cmdedit_init(void)
@@ -527,9 +532,9 @@
 #endif
 		my_uid = getuid();
 		my_gid = getgid();
-#endif	/* CONFIG_FEATURE_COMMAND_TAB_COMPLETION */
+#endif  /* CONFIG_FEATURE_COMMAND_TAB_COMPLETION */
 		handlers_sets |= SET_ATEXIT;
-		atexit(cmdedit_reset_term);	/* be sure to do this only once */
+		atexit(cmdedit_reset_term);     /* be sure to do this only once */
 	}
 }
 
@@ -553,35 +558,35 @@
 	char *temp;
 
 
-	ud++;				/* ~user/... to user/... */
+	ud++;                           /* ~user/... to user/... */
 	userlen = strlen(ud);
 
-	if (num_matches == 0) {		/* "~/..." or "~user/..." */
+	if (num_matches == 0) {         /* "~/..." or "~user/..." */
 		char *sav_ud = ud - 1;
 		char *home = 0;
 
-		if (*ud == '/') {	/* "~/..."     */
+		if (*ud == '/') {       /* "~/..."     */
 			home = home_pwd_buf;
 		} else {
 			/* "~user/..." */
 			temp = strchr(ud, '/');
-			*temp = 0;		/* ~user\0 */
+			*temp = 0;              /* ~user\0 */
 			entry = getpwnam(ud);
-			*temp = '/';		/* restore ~user/... */
+			*temp = '/';            /* restore ~user/... */
 			ud = temp;
 			if (entry)
 				home = entry->pw_dir;
 		}
 		if (home) {
 			if ((userlen + strlen(home) + 1) < BUFSIZ) {
-				char temp2[BUFSIZ];	/* argument size */
+				char temp2[BUFSIZ];     /* argument size */
 
 				/* /home/user/... */
 				sprintf(temp2, "%s%s", home, ud);
 				strcpy(sav_ud, temp2);
 			}
 		}
-		return 0;	/* void, result save to argument :-) */
+		return 0;       /* void, result save to argument :-) */
 	} else {
 		/* "~[^/]*" */
 		char **matches = (char **) NULL;
@@ -593,7 +598,7 @@
 			/* Null usernames should result in all users as possible completions. */
 			if ( /*!userlen || */ !strncmp(ud, entry->pw_name, userlen)) {
 
-                               bb_xasprintf(&temp, "~%s/", entry->pw_name);
+			       bb_xasprintf(&temp, "~%s/", entry->pw_name);
 				matches = xrealloc(matches, (nm + 1) * sizeof(char *));
 
 				matches[nm++] = temp;
@@ -605,7 +610,7 @@
 		return (matches);
 	}
 }
-#endif	/* CONFIG_FEATURE_COMMAND_USERNAME_COMPLETION */
+#endif  /* CONFIG_FEATURE_COMMAND_USERNAME_COMPLETION */
 
 enum {
 	FIND_EXE_ONLY = 0,
@@ -630,11 +635,11 @@
 	npth = 0;
 
 	for (;;) {
-		npth++;			/* count words is + 1 count ':' */
+		npth++;                 /* count words is + 1 count ':' */
 		tmp = strchr(tmp, ':');
 		if (tmp) {
 			if (*++tmp == 0)
-				break;	/* :<empty> */
+				break;  /* :<empty> */
 		} else
 			break;
 	}
@@ -643,17 +648,17 @@
 
 	tmp = pth;
 	(*p)[0] = bb_xstrdup(tmp);
-	npth = 1;			/* count words is + 1 count ':' */
+	npth = 1;                       /* count words is + 1 count ':' */
 
 	for (;;) {
 		tmp = strchr(tmp, ':');
 		if (tmp) {
-			(*p)[0][(tmp - pth)] = 0;	/* ':' -> '\0' */
+			(*p)[0][(tmp - pth)] = 0;       /* ':' -> '\0' */
 			if (*++tmp == 0)
-				break;			/* :<empty> */
+				break;                  /* :<empty> */
 		} else
 			break;
-		(*p)[npth++] = &(*p)[0][(tmp - pth)];	/* p[next]=p[0][&'\0'+1] */
+		(*p)[npth++] = &(*p)[0][(tmp - pth)];   /* p[next]=p[0][&'\0'+1] */
 	}
 
 	return npth;
@@ -703,20 +708,20 @@
 		/* set dir only */
 		dirbuf[(pfind - command) + 1] = 0;
 #ifdef CONFIG_FEATURE_COMMAND_USERNAME_COMPLETION
-		if (dirbuf[0] == '~')	/* ~/... or ~user/... */
+		if (dirbuf[0] == '~')   /* ~/... or ~user/... */
 			username_tab_completion(dirbuf, 0);
 #endif
 		/* "strip" dirname in command */
 		pfind++;
 
 		paths[0] = dirbuf;
-		npaths = 1;				/* only 1 dir */
+		npaths = 1;                             /* only 1 dir */
 	}
 
 	for (i = 0; i < npaths; i++) {
 
 		dir = opendir(paths[i]);
-		if (!dir)			/* Don't print an error */
+		if (!dir)                       /* Don't print an error */
 			continue;
 
 		while ((next = readdir(dir)) != NULL) {
@@ -728,17 +733,17 @@
 			/* not see .name without .match */
 			if (*str_found == '.' && *pfind == 0) {
 				if (*paths[i] == '/' && paths[i][1] == 0
-					&& str_found[1] == 0) str_found = "";	/* only "/" */
+					&& str_found[1] == 0) str_found = "";   /* only "/" */
 				else
 					continue;
 			}
 			found = concat_path_file(paths[i], str_found);
 			/* hmm, remover in progress? */
-			if (stat(found, &st) < 0) 
+			if (stat(found, &st) < 0)
 				goto cont;
 			/* find with dirs ? */
 			if (paths[i] != dirbuf)
-				strcpy(found, next->d_name);	/* only name */
+				strcpy(found, next->d_name);    /* only name */
 			if (S_ISDIR(st.st_mode)) {
 				/* name is directory      */
 				str_found = found;
@@ -747,7 +752,7 @@
 				str_found = add_quote_for_spec_chars(found);
 			} else {
 				/* not put found file if search only dirs for cd */
-				if (type == FIND_DIR_ONLY) 
+				if (type == FIND_DIR_ONLY)
 					goto cont;
 				str_found = add_quote_for_spec_chars(found);
 				if (type == FIND_FILE_ONLY ||
@@ -764,7 +769,7 @@
 		closedir(dir);
 	}
 	if (paths != path1) {
-		free(paths[0]);			/* allocated memory only in first member */
+		free(paths[0]);                 /* allocated memory only in first member */
 		free(paths);
 	}
 	*num_matches = nm;
@@ -796,7 +801,7 @@
 	for (i = 0;; i++) {
 		int_buf[i] = (int) ((unsigned char) matchBuf[i]);
 		if (int_buf[i] == 0) {
-			pos_buf[i] = -1;	/* indicator end line */
+			pos_buf[i] = -1;        /* indicator end line */
 			break;
 		} else
 			pos_buf[i] = i;
@@ -809,7 +814,7 @@
 			int_buf[j] |= QUOT;
 			i++;
 #ifdef CONFIG_FEATURE_NONPRINTABLE_INVERSE_PUT
-			if (matchBuf[i] == '\t')	/* algorithm equivalent */
+			if (matchBuf[i] == '\t')        /* algorithm equivalent */
 				int_buf[j] = ' ' | QUOT;
 #endif
 		}
@@ -852,7 +857,7 @@
 		}
 		if (command_mode) {
 			collapse_pos(0, i + command_mode);
-			i = -1;				/* hack incremet */
+			i = -1;                         /* hack incremet */
 		}
 	}
 	/* collapse `command...` */
@@ -869,11 +874,11 @@
 				collapse_pos(0, i + 1);
 				break;
 			} else
-				i--;			/* hack incremet */
+				i--;                    /* hack incremet */
 		}
 
 	/* collapse (command...(command...)...) or {command...{command...}...} */
-	c = 0;						/* "recursive" level */
+	c = 0;                                          /* "recursive" level */
 	c2 = 0;
 	for (i = 0; int_buf[i]; i++)
 		if (int_buf[i] == '(' || int_buf[i] == '{') {
@@ -882,7 +887,7 @@
 			else
 				c2++;
 			collapse_pos(0, i + 1);
-			i = -1;				/* hack incremet */
+			i = -1;                         /* hack incremet */
 		}
 	for (i = 0; pos_buf[i] >= 0 && (c > 0 || c2 > 0); i++)
 		if ((int_buf[i] == ')' && c > 0) || (int_buf[i] == '}' && c2 > 0)) {
@@ -891,7 +896,7 @@
 			else
 				c2--;
 			collapse_pos(0, i + 1);
-			i = -1;				/* hack incremet */
+			i = -1;                         /* hack incremet */
 		}
 
 	/* skip first not quote space */
@@ -927,7 +932,7 @@
 	/* skip first not quoted '\'' or '"' */
 	for (i = 0; int_buf[i] == '\'' || int_buf[i] == '"'; i++);
 	/* collapse quote or unquote // or /~ */
-	while ((int_buf[i] & ~QUOT) == '/' && 
+	while ((int_buf[i] & ~QUOT) == '/' &&
 			((int_buf[i + 1] & ~QUOT) == '/'
 			 || (int_buf[i + 1] & ~QUOT) == '~')) {
 		i++;
@@ -991,7 +996,7 @@
 	static int num_matches;
 	static char **matches;
 
-	if (lastWasTab == 0) {		/* free all memory */
+	if (lastWasTab == 0) {          /* free all memory */
 		if (matches) {
 			while (num_matches > 0)
 				free(matches[--num_matches]);
@@ -1008,7 +1013,7 @@
 		int find_type;
 		int recalc_pos;
 
-		*lastWasTab = TRUE;		/* flop trigger */
+		*lastWasTab = TRUE;             /* flop trigger */
 
 		/* Make a local copy of the string -- up
 		 * to the position of the cursor */
@@ -1061,7 +1066,7 @@
 
 			beep();
 			if (!matches)
-				return;		/* not found */
+				return;         /* not found */
 			/* sort */
 			qsort(matches, num_matches, sizeof(char *), match_compare);
 
@@ -1073,11 +1078,11 @@
 						*tmp1 = 0;
 						break;
 					}
-			if (*tmp == 0) {	/* have unique */
+			if (*tmp == 0) {        /* have unique */
 				free(tmp);
 				return;
 			}
-		} else {			/* one match */
+		} else {                        /* one match */
 			tmp = matches[0];
 			/* for next completion current found */
 			*lastWasTab = FALSE;
@@ -1111,7 +1116,7 @@
 		 * just hit TAB again, print a list of all the
 		 * available choices... */
 		if (matches && num_matches > 0) {
-			int sav_cursor = cursor;	/* change goto_new_line() */
+			int sav_cursor = cursor;        /* change goto_new_line() */
 
 			/* Go to the next line */
 			goto_new_line();
@@ -1120,7 +1125,7 @@
 		}
 	}
 }
-#endif	/* CONFIG_FEATURE_COMMAND_TAB_COMPLETION */
+#endif  /* CONFIG_FEATURE_COMMAND_TAB_COMPLETION */
 
 #if MAX_HISTORY >= 1
 static void get_previous_history(void)
@@ -1159,7 +1164,7 @@
 	}
 
 	if (( fp = fopen ( fromfile, "r" ))) {
-	
+
 		for ( hi = 0; hi < MAX_HISTORY; ) {
 			char * hl = bb_get_chomped_line_from_file(fp);
 			int l;
@@ -1183,10 +1188,10 @@
 extern void save_history ( const char *tofile )
 {
 	FILE *fp = fopen ( tofile, "w" );
-	
+
 	if ( fp ) {
 		int i;
-		
+
 		for ( i = 0; i < n_history; i++ ) {
 			fputs ( history [i], fp );
 			fputc ( '\n', fp );
@@ -1220,7 +1225,7 @@
  * Furthermore, the "vi" command editing keys are not implemented.
  *
  */
- 
+
 
 int cmdedit_read_input(char *prompt, char command[BUFSIZ])
 {
@@ -1230,7 +1235,7 @@
 	unsigned char c = 0;
 
 	/* prepare before init handlers */
-	cmdedit_y = 0;	/* quasireal y, not true work if line > xt*yt */
+	cmdedit_y = 0;  /* quasireal y, not true work if line > xt*yt */
 	len = 0;
 	command_ps = command;
 
@@ -1247,7 +1252,7 @@
 #       ifndef _POSIX_VDISABLE
 #               define _POSIX_VDISABLE '\0'
 #       endif
-	new_settings.c_cc[VINTR] = _POSIX_VDISABLE;	
+	new_settings.c_cc[VINTR] = _POSIX_VDISABLE;
 #endif
 	command[0] = 0;
 
@@ -1261,7 +1266,7 @@
 
 	while (1) {
 
-		fflush(stdout);			/* buffered out to fast */
+		fflush(stdout);                 /* buffered out to fast */
 
 		if (safe_read(0, &c, 1) < 1)
 			/* if we can't read input then exit */
@@ -1287,8 +1292,12 @@
 			goto_new_line();
 			command[0] = 0;
 			len = 0;
+#if !defined(CONFIG_ASH)
 			lastWasTab = FALSE;
 			put_prompt();
+#else
+			break_out = 2;
+#endif
 			break;
 		case 4:
 			/* Control-d -- Delete one character, or exit
@@ -1327,14 +1336,14 @@
 #endif
 			break;
 		case 11:
-			/* Control-k -- clear to end of line */  
+			/* Control-k -- clear to end of line */
 			*(command + cursor) = 0;
 			len = cursor;
 			printf("\033[J");
 			break;
-		case 12: 
+		case 12:
 				/* Control-l -- clear screen */
-				printf("\033[H");
+			printf("\033[H");
 			redraw(0, len-cursor);
 			break;
 #if MAX_HISTORY >= 1
@@ -1371,7 +1380,7 @@
 			}
 			switch (c) {
 #ifdef CONFIG_FEATURE_COMMAND_TAB_COMPLETION
-			case '\t':			/* Alt-Tab */
+			case '\t':                      /* Alt-Tab */
 
 				input_tab(&lastWasTab);
 				break;
@@ -1433,7 +1442,7 @@
 			break;
 		}
 
-		default:	/* If it's regular input, do the normal thing */
+		default:        /* If it's regular input, do the normal thing */
 #ifdef CONFIG_FEATURE_NONPRINTABLE_INVERSE_PUT
 			/* Control-V -- Add non-printable symbol */
 			if (c == 22) {
@@ -1445,19 +1454,19 @@
 				}
 			} else
 #endif
-			if (!Isprint(c))	/* Skip non-printable characters */
+			if (!Isprint(c))        /* Skip non-printable characters */
 				break;
 
-			if (len >= (BUFSIZ - 2))	/* Need to leave space for enter */
+			if (len >= (BUFSIZ - 2))        /* Need to leave space for enter */
 				break;
 
 			len++;
 
-			if (cursor == (len - 1)) {	/* Append if at the end of the line */
+			if (cursor == (len - 1)) {      /* Append if at the end of the line */
 				*(command + cursor) = c;
 				*(command + cursor + 1) = 0;
 				cmdedit_set_out_char(0);
-			} else {			/* Insert otherwise */
+			} else {                        /* Insert otherwise */
 				int sc = cursor;
 
 				memmove(command + sc + 1, command + sc, len - sc);
@@ -1471,7 +1480,7 @@
 
 			break;
 		}
-		if (break_out)			/* Enter is the command terminator, no more input. */
+		if (break_out)                  /* Enter is the command terminator, no more input. */
 			break;
 
 		if (c != '\t')
@@ -1486,7 +1495,7 @@
 	/* cleanup may be saved current command line */
 	free(history[MAX_HISTORY]);
 	history[MAX_HISTORY] = 0;
-	if (len) {					/* no put empty line */
+	if (len) {                                      /* no put empty line */
 		int i = n_history;
 			/* After max history, remove the oldest command */
 		if (i >= MAX_HISTORY) {
@@ -1508,23 +1517,27 @@
 	}
 #endif
 #endif  /* MAX_HISTORY >= 1 */
-	if(break_out>0) {
-	command[len++] = '\n';		/* set '\n' */
-	command[len] = 0;
+	if(break_out == 1) {
+		command[len++] = '\n';          /* set '\n' */
+		command[len] = 0;
 	}
 #if defined(CONFIG_FEATURE_CLEAN_UP) && defined(CONFIG_FEATURE_COMMAND_TAB_COMPLETION)
-	input_tab(0);				/* strong free */
+	input_tab(0);                           /* strong free */
 #endif
 #if defined(CONFIG_FEATURE_SH_FANCY_PROMPT)
 	free(cmdedit_prompt);
 #endif
 	cmdedit_reset_term();
+#if !defined(CONFIG_ASH)
 	return len;
+#else
+	return break_out < 0 ? break_out : len;
+#endif
 }
 
 
 
-#endif	/* CONFIG_FEATURE_COMMAND_EDITING */
+#endif  /* CONFIG_FEATURE_COMMAND_EDITING */
 
 
 #ifdef TEST
@@ -1565,4 +1578,4 @@
 	return 0;
 }
 
-#endif	/* TEST */
+#endif  /* TEST */
