File ash-5.1-current.patch of Package ash

diff -pur ash-5.1/alias.c /home/hare/Devel/ash/alias.c
--- ash-5.1/alias.c	2003-08-07 11:05:29.000000000 +0200
+++ /home/hare/Devel/ash/alias.c	2010-10-30 05:04:37.000000000 +0200
@@ -1,4 +1,4 @@
-/*	$NetBSD: alias.c,v 1.12 2003/08/07 09:05:29 agc Exp $	*/
+/*	$NetBSD: alias.c,v 1.13 2010/10/29 17:04:48 stacktic Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)alias.c	8.3 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: alias.c,v 1.12 2003/08/07 09:05:29 agc Exp $");
+__RCSID("$NetBSD: alias.c,v 1.13 2010/10/29 17:04:48 stacktic Exp $");
 #endif
 #endif /* not lint */
 
@@ -80,6 +80,7 @@ setalias(char *name, char *val)
 	INTOFF;
 	ap = ckmalloc(sizeof (struct alias));
 	ap->name = savestr(name);
+	ap->flag = 0;
 	/*
 	 * XXX - HACK: in order that the parser will not finish reading the
 	 * alias value off the input before processing the next alias, we
diff -pur ash-5.1/arith_lex.l /home/hare/Devel/ash/arith_lex.l
--- ash-5.1/arith_lex.l	2007-03-25 08:29:26.000000000 +0200
+++ /home/hare/Devel/ash/arith_lex.l	2011-03-08 14:13:53.253612872 +0100
@@ -1,5 +1,5 @@
 %{
-/*	$NetBSD: arith_lex.l,v 1.14 2007/03/25 06:29:26 apb Exp $	*/
+/*	$NetBSD: arith_lex.l,v 1.15 2009/10/29 14:21:40 christos Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)arith_lex.l	8.3 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: arith_lex.l,v 1.14 2007/03/25 06:29:26 apb Exp $");
+__RCSID("$NetBSD: arith_lex.l,v 1.15 2009/10/29 14:21:40 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -48,14 +48,14 @@ __RCSID("$NetBSD: arith_lex.l,v 1.14 200
 #include "expand.h"
 #include "var.h"
 
-extern intmax_t yylval;
 extern const char *arith_buf, *arith_startbuf;
 #undef YY_INPUT
 #define YY_INPUT(buf,result,max) \
 	result = (*buf = *arith_buf++) ? 1 : YY_NULL;
-#define YY_NO_UNPUT
 %}
 
+%option nounput noinput noyywrap
+
 %%
 [ \t\n]	{ ; }
 0x[0-9a-fA-F]+	{ yylval = strtoimax(yytext, 0, 0); return(ARITH_NUM); }
diff -pur ash-5.1/arith.y /home/hare/Devel/ash/arith.y
--- ash-5.1/arith.y	2007-03-25 08:29:26.000000000 +0200
+++ /home/hare/Devel/ash/arith.y	2011-03-08 13:52:25.393614485 +0100
@@ -1,5 +1,5 @@
 %{
-/*	$NetBSD: arith.y,v 1.18 2007/03/25 06:29:26 apb Exp $	*/
+/*	$NetBSD: arith.y,v 1.19 2009/11/13 13:49:09 gson Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)arith.y	8.3 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: arith.y,v 1.18 2007/03/25 06:29:26 apb Exp $");
+__RCSID("$NetBSD: arith.y,v 1.19 2009/11/13 13:49:09 gson Exp $");
 #endif
 #endif /* not lint */
 
@@ -83,7 +84,6 @@ exp:	expr {
 			 * the desired result elsewhere.
 			 */
 			arith_result = $1;
-			return 0;
 		}
 	;
 
diff -pur ash-5.1/cd.c /home/hare/Devel/ash/cd.c
--- ash-5.1/cd.c	2010-01-30 20:24:32.000000000 +0100
+++ /home/hare/Devel/ash/cd.c	2011-02-18 05:30:55.000000000 +0100
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd.c,v 1.39.26.1 2010/01/30 19:24:32 snj Exp $	*/
+/*	$NetBSD: cd.c,v 1.41 2011/02/17 15:13:49 pooka Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)cd.c	8.2 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: cd.c,v 1.39.26.1 2010/01/30 19:24:32 snj Exp $");
+__RCSID("$NetBSD: cd.c,v 1.41 2011/02/17 15:13:49 pooka Exp $");
 #endif
 #endif /* not lint */
 
@@ -425,7 +425,7 @@ find_curdir(int noerror)
 			(void) close(pip[0]);
 			if (pip[1] != 1) {
 				close(1);
-				copyfd(pip[1], 1);
+				copyfd(pip[1], 1, 1);
 				close(pip[1]);
 			}
 			(void) execl("/bin/pwd", "pwd", (char *)0);
diff -pur ash-5.1/eval.c /home/hare/Devel/ash/eval.c
--- ash-5.1/eval.c	2008-05-26 16:55:17.000000000 +0200
+++ /home/hare/Devel/ash/eval.c	2011-03-08 14:40:17.230613062 +0100
@@ -1,4 +1,4 @@
-/*	$NetBSD: eval.c,v 1.93 2008/05/26 14:55:17 tron Exp $	*/
+/*	$NetBSD: eval.c,v 1.101 2011/02/17 15:13:49 pooka Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)eval.c	8.9 (Berkeley) 6/8/95";
 #else
-__RCSID("$NetBSD: eval.c,v 1.93 2008/05/26 14:55:17 tron Exp $");
+__RCSID("$NetBSD: eval.c,v 1.101 2011/02/17 15:13:49 pooka Exp $");
 #endif
 #endif /* not lint */
 
@@ -45,6 +45,7 @@ __RCSID("$NetBSD: eval.c,v 1.93 2008/05/
 #include <stdlib.h>
 #include <signal.h>
 #include <stdio.h>
+#include <errno.h>
 #include <unistd.h>
 #include <sys/fcntl.h>
 #include <sys/times.h>
@@ -180,7 +181,7 @@ evalcmd(int argc, char **argv)
                         STPUTC('\0', concat);
                         p = grabstackstr(concat);
                 }
-                evalstring(p, EV_TESTED);
+                evalstring(p, 0);
         }
         return exitstatus;
 }
@@ -519,14 +520,14 @@ evalpipe(union node *n)
 			INTON;
 			if (prevfd > 0) {
 				close(0);
-				copyfd(prevfd, 0);
+				copyfd(prevfd, 0, 1);
 				close(prevfd);
 			}
 			if (pip[1] >= 0) {
 				close(pip[0]);
 				if (pip[1] != 1) {
 					close(1);
-					copyfd(pip[1], 1);
+					copyfd(pip[1], 1, 1);
 					close(pip[1]);
 				}
 			}
@@ -590,7 +591,7 @@ evalbackcmd(union node *n, struct backcm
 			close(pip[0]);
 			if (pip[1] != 1) {
 				close(1);
-				copyfd(pip[1], 1);
+				copyfd(pip[1], 1, 1);
 				close(pip[1]);
 			}
 			eflag = 0;
@@ -665,6 +667,7 @@ parse_command_args(int argc, char **argv
 }
 
 int vforked = 0;
+extern char *trap[];
 
 /*
  * Execute a simple command.
@@ -759,13 +762,13 @@ evalcommand(union node *cmd, int flgs, s
 		for (sp = varlist.list ; sp ; sp = sp->next) {
 			if (sep != 0)
 				outc(sep, &errout);
-			out2str(sp->text);
+			out2shstr(sp->text);
 			sep = ' ';
 		}
 		for (sp = arglist.list ; sp ; sp = sp->next) {
 			if (sep != 0)
 				outc(sep, &errout);
-			out2str(sp->text);
+			out2shstr(sp->text);
 			sep = ' ';
 		}
 		outc('\n', &errout);
@@ -820,7 +823,7 @@ evalcommand(union node *cmd, int flgs, s
 	}
 
 	/* Fork off a child process if necessary. */
-	if (cmd->ncmd.backgnd
+	if (cmd->ncmd.backgnd || (trap[0] && (flags & EV_EXIT) != 0)
 	 || (cmdentry.cmdtype == CMDNORMAL && (flags & EV_EXIT) == 0)
 	 || ((flags & EV_BACKCMD) != 0
 	    && ((cmdentry.cmdtype != CMDBUILTIN && cmdentry.cmdtype != CMDSPLBLTIN)
@@ -903,7 +906,7 @@ normal_fork:
 			close(pip[0]);
 			if (pip[1] != 1) {
 				close(1);
-				copyfd(pip[1], 1);
+				copyfd(pip[1], 1, 1);
 				close(pip[1]);
 			}
 		}
diff -pur ash-5.1/expand.c /home/hare/Devel/ash/expand.c
--- ash-5.1/expand.c	2008-10-16 19:58:29.000000000 +0200
+++ /home/hare/Devel/ash/expand.c	2009-11-28 04:00:43.000000000 +0100
@@ -1,4 +1,4 @@
-/*	$NetBSD: expand.c,v 1.79 2008/10/16 17:58:29 dholland Exp $	*/
+/*	$NetBSD: expand.c,v 1.83 2009/11/27 10:50:04 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)expand.c	8.5 (Berkeley) 5/15/95";
 #else
-__RCSID("$NetBSD: expand.c,v 1.79 2008/10/16 17:58:29 dholland Exp $");
+__RCSID("$NetBSD: expand.c,v 1.83 2009/11/27 10:50:04 tsutsui Exp $");
 #endif
 #endif /* not lint */
 
@@ -372,7 +372,7 @@ expari(int flag)
 	 */
 /* SPACE_NEEDED is enough for all digits, plus possible "-", plus 2 (why?) */
 #define SPACE_NEEDED ((sizeof(intmax_t) * CHAR_BIT + 2) / 3 + 1 + 2)
-	CHECKSTRSPACE(SPACE_NEEDED - 2, expdest);
+	CHECKSTRSPACE((int)(SPACE_NEEDED - 2), expdest);
 	USTPUTC('\0', expdest);
 	start = stackblock();
 	p = expdest - 1;
@@ -493,10 +493,21 @@ subevalvar(char *p, char *str, int strlo
 	int c = 0;
 	int saveherefd = herefd;
 	struct nodelist *saveargbackq = argbackq;
-	int amount;
+	int amount, how;
 
 	herefd = -1;
-	argstr(p, 0);
+	switch (subtype) {
+	case VSTRIMLEFT:
+	case VSTRIMLEFTMAX:
+	case VSTRIMRIGHT:
+	case VSTRIMRIGHTMAX:
+		how = (varflags & VSQUOTE) ? 0 : EXP_CASE;
+		break;
+	default:
+		how = 0;
+		break;
+	}
+	argstr(p, how);
 	STACKSTRNUL(expdest);
 	herefd = saveherefd;
 	argbackq = saveargbackq;
@@ -1554,7 +1565,7 @@ wordexpcmd(int argc, char **argv)
 	out1c('\0');
 	for (i = 1, len = 0; i < argc; i++)
 		len += strlen(argv[i]);
-	out1fmt("%zd", len);
+	out1fmt("%zu", len);
 	out1c('\0');
 	for (i = 1; i < argc; i++) {
 		out1str(argv[i]);
diff -pur ash-5.1/histedit.c /home/hare/Devel/ash/histedit.c
--- ash-5.1/histedit.c	2008-02-13 13:57:16.000000000 +0100
+++ /home/hare/Devel/ash/histedit.c	2011-01-08 04:01:52.000000000 +0100
@@ -1,4 +1,4 @@
-/*	$NetBSD: histedit.c,v 1.41 2008/02/13 12:57:16 joerg Exp $	*/
+/*	$NetBSD: histedit.c,v 1.42 2011/01/07 22:21:56 jmmv Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)histedit.c	8.2 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: histedit.c,v 1.41 2008/02/13 12:57:16 joerg Exp $");
+__RCSID("$NetBSD: histedit.c,v 1.42 2011/01/07 22:21:56 jmmv Exp $");
 #endif
 #endif /* not lint */
 
@@ -149,13 +149,13 @@ bad:
 			INTON;
 		}
 		if (el) {
+			el_source(el, NULL);
 			if (Vflag)
 				el_set(el, EL_EDITOR, "vi");
 			else if (Eflag)
 				el_set(el, EL_EDITOR, "emacs");
 			el_set(el, EL_BIND, "^I", 
 			    tabcomplete ? "rl-complete" : "ed-insert", NULL);
-			el_source(el, NULL);
 		}
 	} else {
 		INTOFF;
diff -pur ash-5.1/input.c /home/hare/Devel/ash/input.c
--- ash-5.1/input.c	2008-10-16 16:36:40.000000000 +0200
+++ /home/hare/Devel/ash/input.c	2011-03-08 12:01:22.771612312 +0100
@@ -1,4 +1,4 @@
-/*	$NetBSD: input.c,v 1.41 2008/10/16 14:36:40 dholland Exp $	*/
+/*	$NetBSD: input.c,v 1.44 2011/02/17 15:13:49 pooka Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)input.c	8.3 (Berkeley) 6/9/95";
 #else
-__RCSID("$NetBSD: input.c,v 1.41 2008/10/16 14:36:40 dholland Exp $");
+__RCSID("$NetBSD: input.c,v 1.44 2011/02/17 15:13:49 pooka Exp $");
 #endif
 #endif /* not lint */
 
@@ -184,7 +186,7 @@ retry:
 		if (rl_cp == NULL)
 			rl_cp = el_gets(el, &el_len);
 		if (rl_cp == NULL)
-			nr = 0;
+			nr = el_len == 0 ? 0 : -1;
 		else {
 			nr = el_len;
 			if (nr > BUFSIZ - 8)
@@ -338,7 +340,7 @@ pushstring(char *s, int len, void *ap)
 	struct strpush *sp;
 
 	INTOFF;
-/*dprintf("*** calling pushstring: %s, %d\n", s, len);*/
+/*debugprintf("*** calling pushstring: %s, %d\n", s, len);*/
 	if (parsefile->strpush) {
 		sp = ckmalloc(sizeof (struct strpush));
 		sp->prev = parsefile->strpush;
@@ -365,7 +367,7 @@ popstring(void)
 	parsenextc = sp->prevstring;
 	parsenleft = sp->prevnleft;
 	parselleft = sp->prevlleft;
-/*dprintf("*** calling popstring: restoring to '%s'\n", parsenextc);*/
+/*debugprintf("*** calling popstring: restoring to '%s'\n", parsenextc);*/
 	if (sp->ap)
 		sp->ap->flag &= ~ALIASINUSE;
 	parsefile->strpush = sp->prev;
@@ -405,7 +407,7 @@ setinputfile(const char *fname, int push
 	}
 
 	if (fd < 10) {
-		fd2 = copyfd(fd, 10);
+		fd2 = copyfd(fd, 10, 0);
 		close(fd);
 		if (fd2 < 0)
 			error("Out of file descriptors");
diff -pur ash-5.1/jobs.c /home/hare/Devel/ash/jobs.c
--- ash-5.1/jobs.c	2008-10-16 17:36:23.000000000 +0200
+++ /home/hare/Devel/ash/jobs.c	2011-03-08 12:02:18.471613870 +0100
@@ -1,4 +1,4 @@
-/*	$NetBSD: jobs.c,v 1.66 2008/10/16 15:36:23 dholland Exp $	*/
+/*	$NetBSD: jobs.c,v 1.68 2008/12/21 17:16:11 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)jobs.c	8.5 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: jobs.c,v 1.66 2008/10/16 15:36:23 dholland Exp $");
+__RCSID("$NetBSD: jobs.c,v 1.68 2008/12/21 17:16:11 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -95,6 +98,8 @@ STATIC void restartjob(struct job *);
 STATIC void freejob(struct job *);
 STATIC struct job *getjob(const char *, int);
 STATIC int dowait(int, struct job *);
+#define WBLOCK	1
+#define WNOFREE 2
 STATIC int waitproc(int, struct job *, int *);
 STATIC void cmdtxt(union node *);
 STATIC void cmdlist(union node *, int);
@@ -615,7 +620,7 @@ waitcmd(int argc, char **argv)
 				jp++;
 				continue;
 			}
-			if (dowait(1, (struct job *)NULL) == -1)
+			if (dowait(WBLOCK, NULL) == -1)
 			       return 128 + SIGINT;
 			jp = jobtab;
 		}
@@ -630,10 +635,10 @@ waitcmd(int argc, char **argv)
 		}
 		/* loop until process terminated or stopped */
 		while (job->state == JOBRUNNING) {
-			if (dowait(1, (struct job *)NULL) == -1)
+			if (dowait(WBLOCK|WNOFREE, job) == -1)
 			       return 128 + SIGINT;
 		}
-		status = job->ps[job->nprocs].status;
+		status = job->ps[job->nprocs - 1].status;
 		if (WIFEXITED(status))
 			retval = WEXITSTATUS(status);
 #if JOBS
@@ -980,7 +985,7 @@ waitforjob(struct job *jp)
 	INTOFF;
 	TRACE(("waitforjob(%%%d) called\n", jp - jobtab + 1));
 	while (jp->state == JOBRUNNING) {
-		dowait(1, jp);
+		dowait(WBLOCK, jp);
 	}
 #if JOBS
 	if (jp->jobctl) {
@@ -1030,7 +1035,7 @@ waitforjob(struct job *jp)
  */
 
 STATIC int
-dowait(int block, struct job *job)
+dowait(int flags, struct job *job)
 {
 	int pid;
 	int status;
@@ -1041,9 +1046,9 @@ dowait(int block, struct job *job)
 	int stopped;
 	extern volatile char gotsig[];
 
-	TRACE(("dowait(%d) called\n", block));
+	TRACE(("dowait(%x) called\n", flags));
 	do {
-		pid = waitproc(block, job, &status);
+		pid = waitproc(flags & WBLOCK, job, &status);
 		TRACE(("wait returns pid %d, status %d\n", pid, status));
 	} while (pid == -1 && errno == EINTR && gotsig[SIGINT - 1] == 0);
 	if (pid <= 0)
@@ -1085,7 +1090,8 @@ dowait(int block, struct job *job)
 		int mode = 0;
 		if (!rootshell || !iflag)
 			mode = SHOW_SIGNALLED;
-		if (job == thisjob)
+		if ((job == thisjob && (flags & WNOFREE) == 0) ||
+		    (job != thisjob && (flags & WNOFREE) != 0))
 			mode = SHOW_SIGNALLED | SHOW_NO_FREE;
 		if (mode)
 			showjob(out2, thisjob, mode);
diff -pur ash-5.1/main.c /home/hare/Devel/ash/main.c
--- ash-5.1/main.c	2008-10-16 16:55:28.000000000 +0200
+++ /home/hare/Devel/ash/main.c	2010-02-22 11:22:52.000000000 +0100
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.52 2008/10/16 14:55:28 dholland Exp $	*/
+/*	$NetBSD: main.c,v 1.56 2010/02/21 09:54:57 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 19
 #if 0
 static char sccsid[] = "@(#)main.c	8.7 (Berkeley) 7/19/95";
 #else
-__RCSID("$NetBSD: main.c,v 1.52 2008/10/16 14:55:28 dholland Exp $");
+__RCSID("$NetBSD: main.c,v 1.56 2010/02/21 09:54:57 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -51,6 +51,7 @@ __RCSID("$NetBSD: main.c,v 1.52 2008/10/
 #include <signal.h>
 #include <sys/stat.h>
 #include <unistd.h>
+#include <stdlib.h>
 #include <locale.h>
 #include <fcntl.h>
 
@@ -80,6 +81,7 @@ __RCSID("$NetBSD: main.c,v 1.52 2008/10/
 
 int rootpid;
 int rootshell;
+int posix;
 #if PROFILE
 short profile_buf[16384];
 extern int etext();
@@ -107,6 +109,7 @@ main(int argc, char **argv)
 
 	setlocale(LC_ALL, "");
 
+	posix = getenv("POSIXLY_CORRECT") != NULL;
 #if PROFILE
 	monitor(4, etext, profile_buf, sizeof profile_buf, 50);
 #endif
@@ -184,7 +187,8 @@ state1:
 	}
 state2:
 	state = 3;
-	if (getuid() == geteuid() && getgid() == getegid()) {
+	if ((iflag || !posix) &&
+	    getuid() == geteuid() && getgid() == getegid()) {
 		if ((shinit = lookupvar("ENV")) != NULL && *shinit != '\0') {
 			state = 3;
 			read_profile(shinit);
@@ -201,7 +205,7 @@ state3:
 		    SIGPIPE
 		};
 #define SIGSSIZE (sizeof(sigs)/sizeof(sigs[0]))
-		int i;
+		size_t i;
 
 		for (i = 0; i < SIGSSIZE; i++)
 		    setsignal(sigs[i], 0);
diff -pur ash-5.1/Makefile /home/hare/Devel/ash/Makefile
--- ash-5.1/Makefile	2008-10-26 00:23:55.000000000 +0200
+++ /home/hare/Devel/ash/Makefile	2010-08-31 05:00:20.000000000 +0200
@@ -1,10 +1,8 @@
-#	$NetBSD: Makefile,v 1.83 2008/10/25 22:23:55 apb Exp $
+#	$NetBSD: Makefile,v 1.94 2010/08/30 06:26:59 christos Exp $
 #	@(#)Makefile	8.4 (Berkeley) 5/5/95
 
 .include <bsd.own.mk>
 
-WARNS=4
-
 YHEADER=1
 PROG=	sh
 SHSRCS=	alias.c cd.c echo.c error.c eval.c exec.c expand.c \
@@ -17,11 +15,10 @@ SRCS=	${SHSRCS} ${GENSRCS}
 
 DPSRCS+=${GENHDRS}
 
-LDADD+=	-ll -ledit -ltermcap
-DPADD+=	${LIBL} ${LIBEDIT} ${LIBTERMCAP}
+LDADD+=	-ll -ledit -lterminfo
+DPADD+=	${LIBL} ${LIBEDIT} ${LIBTERMINFO}
 
 LFLAGS=	-8	# 8-bit lex scanner for arithmetic
-YFLAGS=	-d
 
 # Environment for scripts executed during build.
 SCRIPT_ENV= \
@@ -38,7 +35,8 @@ YFLAGS+=-l
 
 CPPFLAGS+=-DSHELL -I. -I${.CURDIR}
 #XXX: For testing only.
-#CPPFLAGS+=-DDEBUG=1
+#CPPFLAGS+=-DDEBUG=2
+#COPTS+=-g
 #CFLAGS+=-funsigned-char
 #TARGET_CHARFLAG?= -DTARGET_CHAR="unsigned char" -funsigned-char
 
@@ -59,10 +57,8 @@ token.h: mktokens
 	${_MKTARGET_CREATE}
 	${SCRIPT_ENV} ${HOST_SH} ${.ALLSRC}
 
-builtins.h: builtins.c
-	${_MKTARGET_CREATE}
-
-builtins.c: mkbuiltins shell.h builtins.def
+.ORDER: builtins.h builtins.c
+builtins.h builtins.c: mkbuiltins shell.h builtins.def
 	${_MKTARGET_CREATE}
 	${SCRIPT_ENV} ${HOST_SH} ${.ALLSRC} ${.OBJDIR}
 	[ -f builtins.h ]
@@ -71,9 +67,8 @@ init.c: mkinit.sh ${SHSRCS}
 	${_MKTARGET_CREATE}
 	${SCRIPT_ENV} ${HOST_SH} ${.ALLSRC}
 
-nodes.h: nodes.c
-
-nodes.c: mknodes.sh nodetypes nodes.c.pat
+.ORDER: nodes.h nodes.c
+nodes.c nodes.h: mknodes.sh nodetypes nodes.c.pat
 	${_MKTARGET_CREATE}
 	${SCRIPT_ENV} ${HOST_SH} ${.ALLSRC} ${.OBJDIR}
 	[ -f nodes.h ]
@@ -83,4 +78,9 @@ COMPATOBJDIR!=	cd ${NETBSDSRCDIR}/tools/
 NBCOMPATLIB=	-L${COMPATOBJDIR} -lnbcompat
 .endif
 
+.if make(install)
+SUBDIR+=USD.doc
+.endif
+
 .include <bsd.prog.mk>
+.include <bsd.subdir.mk>
diff -pur ash-5.1/miscbltin.c /home/hare/Devel/ash/miscbltin.c
--- ash-5.1/miscbltin.c	2009-04-01 02:25:21.000000000 +0200
+++ /home/hare/Devel/ash/miscbltin.c	2009-03-29 05:04:44.000000000 +0200
@@ -1,4 +1,4 @@
-/*	$NetBSD: miscbltin.c,v 1.36.26.1 2009/04/01 00:25:21 snj Exp $	*/
+/*	$NetBSD: miscbltin.c,v 1.38 2009/03/29 01:02:49 mrg Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)miscbltin.c	8.4 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: miscbltin.c,v 1.36.26.1 2009/04/01 00:25:21 snj Exp $");
+__RCSID("$NetBSD: miscbltin.c,v 1.38 2009/03/29 01:02:49 mrg Exp $");
 #endif
 #endif /* not lint */
 
@@ -392,11 +392,7 @@ ulimitcmd(int argc, char **argv)
 			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;
diff -pur ash-5.1/mkbuiltins /home/hare/Devel/ash/mkbuiltins
--- ash-5.1/mkbuiltins	2004-06-06 09:03:11.000000000 +0200
+++ /home/hare/Devel/ash/mkbuiltins	2009-10-07 05:00:33.000000000 +0200
@@ -1,5 +1,5 @@
 #!/bin/sh -
-#	$NetBSD: mkbuiltins,v 1.21 2004/06/06 07:03:11 christos Exp $
+#	$NetBSD: mkbuiltins,v 1.22 2009/10/06 19:56:58 apb Exp $
 #
 # Copyright (c) 1991, 1993
 #	The Regents of the University of California.  All rights reserved.
@@ -34,7 +34,7 @@
 #	@(#)mkbuiltins	8.2 (Berkeley) 5/4/95
 
 havehist=1
-if [ "X$1" = "X-h" ]; then
+if [ x"$1" = x"-h" ]; then
 	havehist=0
 	shift
 fi
@@ -89,10 +89,10 @@ do
 		echo $line >&4
 		continue
 		;;
+	\#*)
+		continue
+		;;
 	esac
-	l1="${line###}"
-	[ "$l1" != "$line" ] && continue
-
 
 	func=$1
 	shift
@@ -106,14 +106,14 @@ do
 	}
 	echo 'int '"$func"'(int, char **);' >&4
 	while
-		[ $# != 0 -a "$1" != '#' ]
+		[ $# != 0 ] && [ x"$1" != x'#' ]
 	do
-		[ "$1" = '-s' ] && {
+		[ x"$1" = x'-s' ] && {
 			specials="$specials $2 $func"
 			shift 2
 			continue;
 		}
-		[ "$1" = '-u' ] && shift
+		[ x"$1" = x'-u' ] && shift
 		echo '	{ "'$1'",	'"$func"' },' >&3
 		shift
 	done
diff -pur ash-5.1/nodetypes /home/hare/Devel/ash/nodetypes
--- ash-5.1/nodetypes	2003-08-22 13:22:23.000000000 +0200
+++ /home/hare/Devel/ash/nodetypes	2009-05-27 05:05:00.000000000 +0200
@@ -1,4 +1,4 @@
-#	$NetBSD: nodetypes,v 1.12 2003/08/22 11:22:23 agc Exp $
+#	$NetBSD: nodetypes,v 1.13 2009/05/26 07:30:51 joerg Exp $
 # Copyright (c) 1991, 1993
 #	The Regents of the University of California.  All rights reserved.
 #
@@ -139,5 +139,5 @@ NXHERE nhere			# fd<<!
 	doc	  nodeptr		# input to command (NARG node)
 
 NNOT nnot			# ! command  (actually pipeline)
-	type	int
-	com	nodeptr
+	type	  int
+	com	  nodeptr
diff -pur ash-5.1/options.c /home/hare/Devel/ash/options.c
--- ash-5.1/options.c	2005-12-13 18:44:18.000000000 +0100
+++ /home/hare/Devel/ash/options.c	2011-03-08 14:41:57.188614157 +0100
@@ -1,4 +1,4 @@
-/*	$NetBSD: options.c,v 1.40 2005/12/13 17:44:18 dsl Exp $	*/
+/*	$NetBSD: options.c,v 1.41 2009/01/18 00:30:54 lukem Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)options.c	8.2 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: options.c,v 1.40 2005/12/13 17:44:18 dsl Exp $");
+__RCSID("$NetBSD: options.c,v 1.41 2009/01/18 00:30:54 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -86,7 +86,7 @@ STATIC int getopts(char *, char *, char
 void
 procargs(int argc, char **argv)
 {
-	int i;
+	size_t i;
 
 	argptr = argv;
 	if (argc > 0)
@@ -197,9 +197,9 @@ options(int cmdline)
 }
 
 static void
-set_opt_val(int i, int val)
+set_opt_val(size_t i, int val)
 {
-	int j;
+	size_t j;
 	int flag;
 
 	if (val && (flag = optlist[i].opt_set)) {
@@ -218,7 +218,7 @@ set_opt_val(int i, int val)
 STATIC void
 minus_o(char *name, int val)
 {
-	int i;
+	size_t i;
 
 	if (name == NULL) {
 		if (val) {
@@ -249,7 +249,7 @@ minus_o(char *name, int val)
 STATIC void
 setoption(int flag, int val)
 {
-	int i;
+	size_t i;
 
 	for (i = 0; i < NOPTS; i++)
 		if (optlist[i].letter == flag) {
diff -pur ash-5.1/output.c /home/hare/Devel/ash/output.c
--- ash-5.1/output.c	2008-10-12 03:40:37.000000000 +0200
+++ /home/hare/Devel/ash/output.c	2010-08-31 05:00:20.000000000 +0200
@@ -1,4 +1,4 @@
-/*	$NetBSD: output.c,v 1.30 2008/10/12 01:40:37 dholland Exp $	*/
+/*	$NetBSD: output.c,v 1.33 2010/08/30 06:27:14 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)output.c	8.2 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: output.c,v 1.30 2008/10/12 01:40:37 dholland Exp $");
+__RCSID("$NetBSD: output.c,v 1.33 2010/08/30 06:27:14 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -139,6 +139,43 @@ outstr(const char *p, struct output *fil
 }
 
 
+void
+out2shstr(const char *p)
+{
+	outshstr(p, out2);
+}
+
+
+void
+outshstr(const char *p, struct output *file)
+{
+	static const char norm_chars [] \
+		= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/-=";
+	int need_q = p[0] == 0 || p[strspn(p, norm_chars)] != 0;
+	char c;
+
+	if (need_q)
+		outc('\'', file);
+
+	while (c = *p++, c != 0){
+		if (c != '\''){
+			outc(c, file);
+		}else{
+			outc('\'', file);
+			outc('\\', file);
+			outc(c, file);
+			outc('\'', file);
+		}
+	}
+
+	if (need_q)
+		outc('\'', file);
+
+	if (file == out2)
+		flushout(file);
+}
+
+
 char out_junk[16];
 
 
@@ -227,8 +264,9 @@ out1fmt(const char *fmt, ...)
 	va_end(ap);
 }
 
+#ifdef DEBUG
 void
-dprintf(const char *fmt, ...)
+debugprintf(const char *fmt, ...)
 {
 	va_list ap;
 
@@ -237,6 +275,7 @@ dprintf(const char *fmt, ...)
 	va_end(ap);
 	flushout(out2);
 }
+#endif
 
 void
 fmtstr(char *outbuf, size_t length, const char *fmt, ...)
diff -pur ash-5.1/output.h /home/hare/Devel/ash/output.h
--- ash-5.1/output.h	2008-10-12 03:40:37.000000000 +0200
+++ /home/hare/Devel/ash/output.h	2010-10-30 05:04:37.000000000 +0200
@@ -1,4 +1,4 @@
-/*	$NetBSD: output.h,v 1.19 2008/10/12 01:40:37 dholland Exp $	*/
+/*	$NetBSD: output.h,v 1.22 2010/10/29 17:06:53 stacktic Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -60,6 +60,8 @@ void open_mem(char *, int, struct output
 void out1str(const char *);
 void out2str(const char *);
 void outstr(const char *, struct output *);
+void out2shstr(const char *);
+void outshstr(const char *, struct output *);
 void emptyoutbuf(struct output *);
 void flushall(void);
 void flushout(struct output *);
@@ -68,8 +70,10 @@ void outfmt(struct output *, const char
     __attribute__((__format__(__printf__,2,3)));
 void out1fmt(const char *, ...)
     __attribute__((__format__(__printf__,1,2)));
-void dprintf(const char *, ...)
+#ifdef DEBUG
+void debugprintf(const char *, ...)
     __attribute__((__format__(__printf__,1,2)));
+#endif
 void fmtstr(char *, size_t, const char *, ...)
     __attribute__((__format__(__printf__,3,4)));
 void doformat(struct output *, const char *, va_list);
diff -pur ash-5.1/parser.c /home/hare/Devel/ash/parser.c
--- ash-5.1/parser.c	2008-08-23 12:05:52.000000000 +0200
+++ /home/hare/Devel/ash/parser.c	2011-03-08 12:05:23.405613906 +0100
@@ -1,4 +1,4 @@
-/*	$NetBSD: parser.c,v 1.69 2008/08/23 10:05:52 christos Exp $	*/
+/*	$NetBSD: parser.c,v 1.79 2010/12/13 16:54:04 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)parser.c	8.7 (Berkeley) 5/16/95";
 #else
-__RCSID("$NetBSD: parser.c,v 1.69 2008/08/23 10:05:52 christos Exp $");
+__RCSID("$NetBSD: parser.c,v 1.79 2010/12/13 16:54:04 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -101,7 +105,7 @@ int quoteflag;			/* set if (part of) las
 int startlinno;			/* line # where last token started */
 
 
-STATIC union node *list(int);
+STATIC union node *list(int, int);
 STATIC union node *andor(void);
 STATIC union node *pipeline(void);
 STATIC union node *command(void);
@@ -142,12 +146,12 @@ parsecmd(int interact)
 	if (t == TNL)
 		return NULL;
 	tokpushback++;
-	return list(1);
+	return list(1, 0);
 }
 
 
 STATIC union node *
-list(int nlflag)
+list(int nlflag, int erflag)
 {
 	union node *n1, *n2, *n3;
 	int tok;
@@ -207,7 +211,7 @@ list(int nlflag)
 				pungetc();		/* push back EOF on input */
 			return n1;
 		default:
-			if (nlflag)
+			if (nlflag || erflag)
 				synexpect(-1);
 			tokpushback++;
 			return n1;
@@ -325,22 +329,22 @@ command(void)
 	case TIF:
 		n1 = (union node *)stalloc(sizeof (struct nif));
 		n1->type = NIF;
-		n1->nif.test = list(0);
+		n1->nif.test = list(0, 0);
 		if (readtoken() != TTHEN)
 			synexpect(TTHEN);
-		n1->nif.ifpart = list(0);
+		n1->nif.ifpart = list(0, 0);
 		n2 = n1;
 		while (readtoken() == TELIF) {
 			n2->nif.elsepart = (union node *)stalloc(sizeof (struct nif));
 			n2 = n2->nif.elsepart;
 			n2->type = NIF;
-			n2->nif.test = list(0);
+			n2->nif.test = list(0, 0);
 			if (readtoken() != TTHEN)
 				synexpect(TTHEN);
-			n2->nif.ifpart = list(0);
+			n2->nif.ifpart = list(0, 0);
 		}
 		if (lasttoken == TELSE)
-			n2->nif.elsepart = list(0);
+			n2->nif.elsepart = list(0, 0);
 		else {
 			n2->nif.elsepart = NULL;
 			tokpushback++;
@@ -354,12 +358,12 @@ command(void)
 		int got;
 		n1 = (union node *)stalloc(sizeof (struct nbinary));
 		n1->type = (lasttoken == TWHILE)? NWHILE : NUNTIL;
-		n1->nbinary.ch1 = list(0);
+		n1->nbinary.ch1 = list(0, 0);
 		if ((got=readtoken()) != TDO) {
 TRACE(("expecting DO got %s %s\n", tokname[got], got == TWORD ? wordtext : ""));
 			synexpect(TDO);
 		}
-		n1->nbinary.ch2 = list(0);
+		n1->nbinary.ch2 = list(0, 0);
 		if (readtoken() != TDONE)
 			synexpect(TDONE);
 		checkkwd = 1;
@@ -408,7 +412,7 @@ TRACE(("expecting DO got %s %s\n", tokna
 			t = TEND;
 		else
 			synexpect(-1);
-		n1->nfor.body = list(0);
+		n1->nfor.body = list(0, 0);
 		if (readtoken() != t)
 			synexpect(t);
 		checkkwd = 1;
@@ -450,7 +454,7 @@ TRACE(("expecting DO got %s %s\n", tokna
 			if (lasttoken != TRP) {
 				synexpect(TRP);
 			}
-			cp->nclist.body = list(0);
+			cp->nclist.body = list(0, 0);
 
 			checkkwd = 2;
 			if ((t = readtoken()) != TESAC) {
@@ -472,14 +476,14 @@ TRACE(("expecting DO got %s %s\n", tokna
 	case TLP:
 		n1 = (union node *)stalloc(sizeof (struct nredir));
 		n1->type = NSUBSHELL;
-		n1->nredir.n = list(0);
+		n1->nredir.n = list(0, 0);
 		n1->nredir.redirect = NULL;
 		if (readtoken() != TRP)
 			synexpect(TRP);
 		checkkwd = 1;
 		break;
 	case TBEGIN:
-		n1 = list(0);
+		n1 = list(0, 0);
 		if (readtoken() != TEND)
 			synexpect(TEND);
 		checkkwd = 1;
@@ -814,8 +818,6 @@ xxreadtoken(void)
 	startlinno = plinno;
 	for (;;) {	/* until token or start of word found */
 		c = pgetc_macro();
-		if (c == ' ' || c == '\t')
-			continue;		/* quick check for white space first */
 		switch (c) {
 		case ' ': case '\t':
 			continue;
@@ -924,7 +926,7 @@ readtoken1(int firstc, char const *syn,
 	int * volatile dblquotep = NULL;
 	volatile size_t maxnest = 32;
 	volatile int dblquote;
-	volatile int varnest;	/* levels of variables expansion */
+	volatile size_t varnest;	/* levels of variables expansion */
 	volatile int arinest;	/* levels of arithmetic expansion */
 	volatile int parenlevel;	/* levels of parens in arithmetic */
 	volatile int oldstyle;
@@ -1463,7 +1465,7 @@ done:
 	} else
 		saveprompt = 0;
 
-	n = list(0);
+	n = list(0, oldstyle);
 
 	if (oldstyle)
 		doprompt = saveprompt;
diff -pur ash-5.1/redir.c /home/hare/Devel/ash/redir.c
--- ash-5.1/redir.c	2008-01-21 07:43:03.000000000 +0100
+++ /home/hare/Devel/ash/redir.c	2011-02-18 05:30:56.000000000 +0100
@@ -1,4 +1,4 @@
-/*	$NetBSD: redir.c,v 1.30 2008/01/21 06:43:03 msaitoh Exp $	*/
+/*	$NetBSD: redir.c,v 1.31 2011/02/17 15:13:49 pooka Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)redir.c	8.2 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: redir.c,v 1.30 2008/01/21 06:43:03 msaitoh Exp $");
+__RCSID("$NetBSD: redir.c,v 1.31 2011/02/17 15:13:49 pooka Exp $");
 #endif
 #endif /* not lint */
 
@@ -222,7 +222,7 @@ openredirect(union node *redir, char mem
 			if (memory[redir->ndup.dupfd])
 				memory[fd] = 1;
 			else
-				copyfd(redir->ndup.dupfd, fd);
+				copyfd(redir->ndup.dupfd, fd, 1);
 		}
 		INTON;
 		return;
@@ -235,7 +235,7 @@ openredirect(union node *redir, char mem
 	}
 
 	if (f != fd) {
-		copyfd(f, fd);
+		copyfd(f, fd, 1);
 		close(f);
 	}
 	INTON;
@@ -308,7 +308,7 @@ popredir(void)
                                 fd0_redirected--;
 			close(i);
 			if (rp->renamed[i] >= 0) {
-				copyfd(rp->renamed[i], i);
+				copyfd(rp->renamed[i], i, 1);
 				close(rp->renamed[i]);
 			}
 		}
@@ -375,11 +375,14 @@ clearredir(vforked)
  */
 
 int
-copyfd(int from, int to)
+copyfd(int from, int to, int equal)
 {
 	int newfd;
 
-	newfd = fcntl(from, F_DUPFD, to);
+	if (equal)
+		newfd = dup2(from, to);
+	else
+		newfd = fcntl(from, F_DUPFD, to);
 	if (newfd < 0) {
 		if (errno == EMFILE)
 			return EMPTY;
diff -pur ash-5.1/redir.h /home/hare/Devel/ash/redir.h
--- ash-5.1/redir.h	2003-08-07 11:05:37.000000000 +0200
+++ /home/hare/Devel/ash/redir.h	2011-02-18 05:30:56.000000000 +0100
@@ -1,4 +1,4 @@
-/*	$NetBSD: redir.h,v 1.15 2003/08/07 09:05:37 agc Exp $	*/
+/*	$NetBSD: redir.h,v 1.16 2011/02/17 15:13:49 pooka Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -44,5 +44,5 @@ void redirect(union node *, int);
 void popredir(void);
 int fd0_redirected_p(void);
 void clearredir(int);
-int copyfd(int, int);
+int copyfd(int, int, int);
 
diff -pur ash-5.1/sh.1 /home/hare/Devel/ash/sh.1
--- ash-5.1/sh.1	2010-01-30 20:26:39.000000000 +0100
+++ /home/hare/Devel/ash/sh.1	2010-06-03 05:03:15.000000000 +0200
@@ -1,4 +1,4 @@
-.\"	$NetBSD: sh.1,v 1.87.18.3 2010/01/30 19:26:39 snj Exp $
+.\"	$NetBSD: sh.1,v 1.99 2010/06/03 02:05:02 dholland Exp $
 .\" Copyright (c) 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
 .\"
@@ -31,9 +31,9 @@
 .\"
 .\"	@(#)sh.1	8.6 (Berkeley) 5/4/95
 .\"
-.Dd January 1, 2010
-.Os
+.Dd June 2, 2010
 .Dt SH 1
+.Os
 .Sh NAME
 .Nm sh
 .Nd command interpreter (shell)
@@ -310,6 +310,11 @@ Typing a tab character will extend the c
 filename.
 If more than one filename matches it is only extended to be the common prefix.
 Typing a second tab character will list all the matching names.
+One of the editing modes, either
+.Fl E
+or
+.Fl V ,
+must be enabled for this to work.
 .El
 .Ss Lexical Structure
 The shell reads input in terms of lines from a file and breaks it up into
@@ -1197,13 +1202,7 @@ names and values of all defined aliases
 .It bg [ Ar job ] ...
 Continue the specified jobs (or the current job if no
 jobs are given) in the background.
-.It Xo command
-.Op Fl p
-.Op Fl v
-.Op Fl V
-.Ar command
-.Op Ar arg ...
-.Xc
+.It command Oo Fl p Oc Oo Fl v Oc Oo Fl V Oc Ar command Oo Ar arg ... Oc
 Execute the specified command but ignore shell functions when searching
 for it.
 (This is useful when you
@@ -1306,16 +1305,9 @@ With no arguments the export command lis
 With the
 .Fl p
 option specified the output will be formatted suitably for non-interactive use.
-.It Xo fc Op Fl e Ar editor
-.Op Ar first Op Ar last
-.Xc
-.It Xo fc Fl l
-.Op Fl nr
-.Op Ar first Op Ar last
-.Xc
-.It Xo fc Fl s Op Ar old=new
-.Op Ar first
-.Xc
+.It fc Oo Fl e Ar editor Oc Oo Ar first Oo Ar last Oc Oc
+.It fc Fl l Oo Fl nr Oc Oo Ar first Oo Ar last Oc Oc
+.It fc Fl s Oo Ar old=new Oc Oo Ar first Oc
 The
 .Ic fc
 built-in lists, or edits and re-executes, commands previously entered
@@ -1484,7 +1476,7 @@ do
 	case $f in
 	a | b)	flag=$f;;
 	c)	carg=$OPTARG;;
-	\\?)	echo $USAGE; exit 1;;
+	\e?)	echo $USAGE; exit 1;;
 	esac
 done
 shift `expr $OPTIND - 1`
@@ -1534,19 +1526,19 @@ argument is omitted, the current job is
 .It jobs
 This command lists out all the background processes
 which are children of the current shell process.
-.It pwd Op Fl LP
+.It pwd Op Fl \&LP
 Print the current directory.
 If
 .Fl L
 is specified the cached value (initially set from
 .Ev PWD )
-is checked to see if it refers to the current directory, if it does
+is checked to see if it refers to the current directory; if it does
 the value is printed.
 Otherwise the current directory name is found using
 .Xr getcwd 3 .
 The environment variable
 .Ev PWD
-is set to printed value.
+is set to the printed value.
 .Pp
 The default is
 .Ic pwd
@@ -1574,11 +1566,7 @@ The built-in command may differ from the
 the program will use
 .Ev PWD
 and the built-in uses a separately cached value.
-.It Xo read Op Fl p Ar prompt
-.Op Fl r
-.Ar variable
-.Op Ar ...
-.Xc
+.It read Oo Fl p Ar prompt Oc Oo Fl r Oc Ar variable Oo Ar ... Oc
 The prompt is printed if the
 .Fl p
 option is specified and the standard input is a terminal.
@@ -1620,11 +1608,7 @@ With the
 .Fl p
 option specified the output will be formatted suitably for non-interactive use.
 .Pp
-.It Xo set
-.Oo {
-.Fl options | Cm +options | Cm -- }
-.Oc Ar arg ...
-.Xc
+.It set Oo { Fl options | Cm +options | Cm \-- } Oc Ar arg ...
 The
 .Ic set
 command performs three different functions.
@@ -1672,20 +1656,16 @@ by one.
 If there are zero positional parameters,
 .Ic shift
 does nothing.
-.It Xo trap
-.Op Fl l
-.Xc
-.It Xo trap
-.Op Ar action
-.Ar signal ...
-.Xc
+.It trap Oo Fl l Oc
+.It trap Oo Ar action Oc Ar signal ...
 Cause the shell to parse and execute action when any of the specified
 signals are received.
 The signals are specified by signal number or as the name of the signal.
 If
 .Ar signal
 is
-.Li 0 ,
+.Li 0
+or its equivalent, EXIT,
 the action is executed when the shell exits.
 .Ar action
 may be null, which cause the specified signals to be ignored.
@@ -1737,10 +1717,7 @@ command, tracked alias and not found.
 For aliases the alias expansion is
 printed; for commands and tracked aliases the complete pathname of the
 command is printed.
-.It ulimit Xo
-.Op Fl H \*(Ba Fl S
-.Op Fl a \*(Ba Fl tfdscmlpnv Op Ar value
-.Xc
+.It ulimit Oo Fl H \*(Ba Fl S Oc Oo Fl a \*(Ba Fl tfdscmlpnv Oo Ar value Oc Oc
 Inquire about or set the hard or soft limits on processes or set new
 limits.
 The choice between hard limit (which no process is allowed to
@@ -1760,9 +1737,9 @@ is specified, the soft limit is displaye
 If both are specified, the last one wins.
 .El
 .Pp
-.Bl -tag -width Fl
 The limit to be interrogated or set, then, is chosen by specifying
 any one of these flags:
+.Bl -tag -width Fl
 .It Fl a
 show all the current limits
 .It Fl b
@@ -1809,10 +1786,7 @@ Set the value of umask (see
 .Xr umask 2 )
 to the specified octal value.
 If the argument is omitted, the umask value is printed.
-.It unalias Xo
-.Op Fl a
-.Op Ar name
-.Xc
+.It unalias Oo Fl a Oc Oo Ar name Oc
 If
 .Ar name
 is specified, the shell removes that alias.
diff -pur ash-5.1/show.c /home/hare/Devel/ash/show.c
--- ash-5.1/show.c	2003-11-14 11:46:13.000000000 +0100
+++ /home/hare/Devel/ash/show.c	2010-11-15 04:01:24.000000000 +0100
@@ -1,4 +1,4 @@
-/*	$NetBSD: show.c,v 1.26 2003/11/14 10:46:13 dsl Exp $	*/
+/*	$NetBSD: show.c,v 1.27 2010/11/14 19:36:07 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)show.c	8.3 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: show.c,v 1.26 2003/11/14 10:46:13 dsl Exp $");
+__RCSID("$NetBSD: show.c,v 1.27 2010/11/14 19:36:07 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -273,7 +273,7 @@ FILE *tracefile;
 void
 trputc(int c)
 {
-	if (debug != 1)
+	if (debug != 1 || !tracefile)
 		return;
 	putc(c, tracefile);
 }
@@ -285,7 +285,7 @@ trace(const char *fmt, ...)
 #ifdef DEBUG
 	va_list va;
 
-	if (debug != 1)
+	if (debug != 1 || !tracefile)
 		return;
 	va_start(va, fmt);
 	(void) vfprintf(tracefile, fmt, va);
@@ -297,7 +297,7 @@ void
 tracev(const char *fmt, va_list va)
 {
 #ifdef DEBUG
-	if (debug != 1)
+	if (debug != 1 || !tracefile)
 		return;
 	(void) vfprintf(tracefile, fmt, va);
 #endif
@@ -308,7 +308,7 @@ tracev(const char *fmt, va_list va)
 void
 trputs(const char *s)
 {
-	if (debug != 1)
+	if (debug != 1 || !tracefile)
 		return;
 	fputs(s, tracefile);
 }
@@ -320,7 +320,7 @@ trstring(char *s)
 	char *p;
 	char c;
 
-	if (debug != 1)
+	if (debug != 1 || !tracefile)
 		return;
 	putc('"', tracefile);
 	for (p = s ; *p ; p++) {
@@ -359,7 +359,7 @@ void
 trargs(char **ap)
 {
 #ifdef DEBUG
-	if (debug != 1)
+	if (debug != 1 || !tracefile)
 		return;
 	while (*ap) {
 		trstring(*ap++);
@@ -405,6 +405,7 @@ opentrace(void)
 	if (tracefile) {
 		if (!freopen(s, "a", tracefile)) {
 			fprintf(stderr, "Can't re-open %s\n", s);
+			tracefile = NULL;
 			debug = 0;
 			return;
 		}
diff -pur ash-5.1/TOUR /home/hare/Devel/ash/TOUR
--- ash-5.1/TOUR	2006-04-24 20:00:53.000000000 +0200
+++ /home/hare/Devel/ash/TOUR	2008-11-16 04:06:11.000000000 +0100
@@ -1,4 +1,4 @@
-#	$NetBSD: TOUR,v 1.9 2006/04/24 18:00:53 snj Exp $
+#	$NetBSD: TOUR,v 1.10 2008/11/15 17:01:38 snj Exp $
 #	@(#)TOUR	8.1 (Berkeley) 5/31/93
 
 NOTE -- This is the original TOUR paper distributed with ash and
@@ -22,7 +22,7 @@ SOURCE CODE GENERATORS:  Files whose nam
 programs that generate source code.  A complete list of these
 programs is:
 
-        program         intput files        generates
+        program         input files         generates
         -------         ------------        ---------
         mkbuiltins      builtins            builtins.h builtins.c
         mkinit          *.c                 init.c
@@ -91,7 +91,7 @@ INTERRUPTS:  In an interactive shell, an
 EXINT exception to return to the main command loop.  (Exception:
 EXINT is not raised if the user traps interrupts using the trap
 command.)  The INTOFF and INTON macros (defined in exception.h)
-provide uninterruptable critical sections.  Between the execution
+provide uninterruptible critical sections.  Between the execution
 of INTOFF and the execution of INTON, interrupt signals will be
 held for later delivery.  INTOFF and INTON can be nested.
 
@@ -110,7 +110,7 @@ string was going to be:
         p = stackptr;
         *p++ = c;       /* repeated as many times as needed */
         stackptr = p;
-The folloing three macros (defined in memalloc.h) perform these
+The following three macros (defined in memalloc.h) perform these
 operations, but grow the stack if you run off the end:
         STARTSTACKSTR(p);
         STPUTC(c, p);   /* repeated as many times as needed */
@@ -232,7 +232,7 @@ control is defined.
 REDIR.C:  Ash allows file descriptors to be redirected and then
 restored without forking off a child process.  This is accom-
 plished by duplicating the original file descriptors.  The redir-
-tab structure records where the file descriptors have be dupli-
+tab structure records where the file descriptors have been dupli-
 cated to.
 
 EXEC.C:  The routine find_command locates a command, and enters
openSUSE Build Service is sponsored by