Module Name:    src
Committed By:   tls
Date:           Sun Aug 10 06:41:18 UTC 2014

Modified Files:
        src/bin/cat [tls-earlyentropy]: cat.1
        src/bin/csh [tls-earlyentropy]: Makefile
        src/bin/csh/USD.doc [tls-earlyentropy]: Makefile
        src/bin/ls [tls-earlyentropy]: print.c
        src/bin/pax [tls-earlyentropy]: ar_io.c
        src/bin/ps [tls-earlyentropy]: extern.h print.c ps.c ps.h
        src/bin/sh [tls-earlyentropy]: Makefile alias.c alias.h eval.c eval.h
            histedit.c jobs.c main.c sh.1
        src/bin/sh/USD.doc [tls-earlyentropy]: Makefile
Added Files:
        src/bin/sh/USD.doc [tls-earlyentropy]: referargs

Log Message:
Rebase.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.36.8.1 src/bin/cat/cat.1
cvs rdiff -u -r1.39 -r1.39.4.1 src/bin/csh/Makefile
cvs rdiff -u -r1.7 -r1.7.48.1 src/bin/csh/USD.doc/Makefile
cvs rdiff -u -r1.54 -r1.54.2.1 src/bin/ls/print.c
cvs rdiff -u -r1.54 -r1.54.10.1 src/bin/pax/ar_io.c
cvs rdiff -u -r1.34 -r1.34.2.1 src/bin/ps/extern.h
cvs rdiff -u -r1.121 -r1.121.2.1 src/bin/ps/print.c
cvs rdiff -u -r1.80 -r1.80.2.1 src/bin/ps/ps.c
cvs rdiff -u -r1.26 -r1.26.60.1 src/bin/ps/ps.h
cvs rdiff -u -r1.99 -r1.99.8.1 src/bin/sh/Makefile
cvs rdiff -u -r1.14 -r1.14.20.1 src/bin/sh/alias.c
cvs rdiff -u -r1.7 -r1.7.20.1 src/bin/sh/alias.h
cvs rdiff -u -r1.108 -r1.108.2.1 src/bin/sh/eval.c
cvs rdiff -u -r1.15 -r1.15.46.1 src/bin/sh/eval.h
cvs rdiff -u -r1.46 -r1.46.2.1 src/bin/sh/histedit.c
cvs rdiff -u -r1.72 -r1.72.2.1 src/bin/sh/jobs.c
cvs rdiff -u -r1.57 -r1.57.20.1 src/bin/sh/main.c
cvs rdiff -u -r1.112 -r1.112.2.1 src/bin/sh/sh.1
cvs rdiff -u -r1.1 -r1.1.24.1 src/bin/sh/USD.doc/Makefile
cvs rdiff -u -r0 -r1.1.2.2 src/bin/sh/USD.doc/referargs

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/cat/cat.1
diff -u src/bin/cat/cat.1:1.36 src/bin/cat/cat.1:1.36.8.1
--- src/bin/cat/cat.1:1.36	Sat Nov 10 18:41:10 2012
+++ src/bin/cat/cat.1	Sun Aug 10 06:41:18 2014
@@ -1,4 +1,4 @@
-.\"	$NetBSD: cat.1,v 1.36 2012/11/10 18:41:10 wiz Exp $
+.\"	$NetBSD: cat.1,v 1.36.8.1 2014/08/10 06:41:18 tls Exp $
 .\"
 .\" Copyright (c) 1989, 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -32,7 +32,7 @@
 .\"
 .\"     @(#)cat.1	8.3 (Berkeley) 5/2/95
 .\"
-.Dd November 10, 2012
+.Dd June 15, 2014
 .Dt CAT 1
 .Os
 .Sh NAME
@@ -198,7 +198,7 @@ utility is expected to conform to the
 specification.
 .Pp
 The flags
-.Op Fl belnstv
+.Op Fl Bbeflnstv
 are extensions to the specification.
 .Sh HISTORY
 A

Index: src/bin/csh/Makefile
diff -u src/bin/csh/Makefile:1.39 src/bin/csh/Makefile:1.39.4.1
--- src/bin/csh/Makefile:1.39	Tue Jul 16 17:47:43 2013
+++ src/bin/csh/Makefile	Sun Aug 10 06:41:18 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.39 2013/07/16 17:47:43 christos Exp $
+#	$NetBSD: Makefile,v 1.39.4.1 2014/08/10 06:41:18 tls Exp $
 #	@(#)Makefile	8.1 (Berkeley) 5/31/93
 #
 # C Shell with process control; VM/UNIX VAX Makefile
@@ -52,14 +52,8 @@ const.h: const.c
 	    ${TOOL_SED} -e 's/Char \([a-zA-Z0-9_]*\)\(.*\)/extern Char \1[];/' | \
 	    sort >> ${.TARGET}
 
-.if make(install)
 SUBDIR+=USD.doc
-.endif
 
-# XXX Only GCC 4.1 problem
-.if defined(HAVE_GCC) && ${HAVE_GCC} == 4 && ${MACHINE_ARCH} == "vax"
-COPTS.parse.c+=	-O0
-.endif
 COPTS.err.c = -Wno-format-nonliteral
 COPTS.printf.c = -Wno-format-nonliteral
 COPTS.proc.c = -Wno-format-nonliteral

Index: src/bin/csh/USD.doc/Makefile
diff -u src/bin/csh/USD.doc/Makefile:1.7 src/bin/csh/USD.doc/Makefile:1.7.48.1
--- src/bin/csh/USD.doc/Makefile:1.7	Thu Oct 18 18:26:31 2007
+++ src/bin/csh/USD.doc/Makefile	Sun Aug 10 06:41:18 2014
@@ -1,12 +1,12 @@
-#	$NetBSD: Makefile,v 1.7 2007/10/18 18:26:31 tls Exp $
+#	$NetBSD: Makefile,v 1.7.48.1 2014/08/10 06:41:18 tls Exp $
 #	@(#)Makefile	8.1 (Berkeley) 8/14/93
 
-DIR=	usd/04.csh
+SECTION=reference/ref1
+ARTICLE=csh
 SRCS=	tabs csh.1 csh.2 csh.3 csh.4 csh.ap csh.g
 MACROS= -ms
-
-paper.ps: ${SRCS}
-	${TOOL_SOELIM} -I${.CURDIR} ${.ALLSRC} | \
-	    ${TOOL_ROFF_PS} ${MACROS} > ${.TARGET}                  
+EXTRAHTMLFILES=\
+	csh1.png csh2.png csh3.png csh4.png csh5.png csh6.png csh7.png \
+	csh8.png csh9.png
 
 .include <bsd.doc.mk>

Index: src/bin/ls/print.c
diff -u src/bin/ls/print.c:1.54 src/bin/ls/print.c:1.54.2.1
--- src/bin/ls/print.c:1.54	Sat Feb 22 13:11:42 2014
+++ src/bin/ls/print.c	Sun Aug 10 06:41:18 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: print.c,v 1.54 2014/02/22 13:11:42 mlelstv Exp $	*/
+/*	$NetBSD: print.c,v 1.54.2.1 2014/08/10 06:41:18 tls Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993, 1994
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)print.c	8.5 (Berkeley) 7/28/94";
 #else
-__RCSID("$NetBSD: print.c,v 1.54 2014/02/22 13:11:42 mlelstv Exp $");
+__RCSID("$NetBSD: print.c,v 1.54.2.1 2014/08/10 06:41:18 tls Exp $");
 #endif
 #endif /* not lint */
 
@@ -46,6 +46,7 @@ __RCSID("$NetBSD: print.c,v 1.54 2014/02
 
 #include <err.h>
 #include <errno.h>
+#include <inttypes.h>
 #include <fts.h>
 #include <grp.h>
 #include <pwd.h>
@@ -136,8 +137,7 @@ printlong(DISPLAY *dp)
 			continue;
 		sp = p->fts_statp;
 		if (f_inode)
-			(void)printf("%*lu ", dp->s_inode,
-			    (unsigned long)sp->st_ino);
+			(void)printf("%*"PRIu64" ", dp->s_inode, sp->st_ino);
 		if (f_size) {
 			if (f_humanize) {
 				if ((humanize_number(szbuf, sizeof(szbuf),
@@ -365,7 +365,7 @@ printaname(FTSENT *p, int inodefield, in
 	sp = p->fts_statp;
 	chcnt = 0;
 	if (f_inode)
-		chcnt += printf("%*lu ", inodefield, (unsigned long)sp->st_ino);
+		chcnt += printf("%*"PRIu64" ", inodefield, sp->st_ino);
 	if (f_size) {
 		if (f_humanize) {
 			if ((humanize_number(szbuf, sizeof(szbuf), sp->st_size,

Index: src/bin/pax/ar_io.c
diff -u src/bin/pax/ar_io.c:1.54 src/bin/pax/ar_io.c:1.54.10.1
--- src/bin/pax/ar_io.c:1.54	Tue Mar 20 18:42:28 2012
+++ src/bin/pax/ar_io.c	Sun Aug 10 06:41:18 2014
@@ -1,4 +1,4 @@
-/*	$netbsd: ar_io.c,v 1.48 2007/04/23 18:40:22 christos Exp $	*/
+/*	$NetBSD: ar_io.c,v 1.54.10.1 2014/08/10 06:41:18 tls Exp $	*/
 
 /*-
  * Copyright (c) 1992 Keith Muller.
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)ar_io.c	8.2 (Berkeley) 4/18/94";
 #else
-__RCSID("$NetBSD: ar_io.c,v 1.54 2012/03/20 18:42:28 matt Exp $");
+__RCSID("$NetBSD: ar_io.c,v 1.54.10.1 2014/08/10 06:41:18 tls Exp $");
 #endif
 #endif /* not lint */
 

Index: src/bin/ps/extern.h
diff -u src/bin/ps/extern.h:1.34 src/bin/ps/extern.h:1.34.2.1
--- src/bin/ps/extern.h:1.34	Wed Jan 15 08:07:53 2014
+++ src/bin/ps/extern.h	Sun Aug 10 06:41:18 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: extern.h,v 1.34 2014/01/15 08:07:53 mlelstv Exp $	*/
+/*	$NetBSD: extern.h,v 1.34.2.1 2014/08/10 06:41:18 tls Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -46,54 +46,54 @@ extern VAR var[];
 extern VARLIST displaylist;
 extern VARLIST sortlist;
 
-void	 command(void *, VARENT *, int);
-void	 cpuid(void *, VARENT *, int);
-void	 cputime(void *, VARENT *, int);
+void	 command(void *, VARENT *, enum mode);
+void	 cpuid(void *, VARENT *, enum mode);
+void	 cputime(void *, VARENT *, enum mode);
 int	 donlist(void);
 int	 donlist_sysctl(void);
 void	 fmt_puts(char *, int *);
 void	 fmt_putc(int, int *);
-void	 elapsed(void *, VARENT *, int);
+void	 elapsed(void *, VARENT *, enum mode);
 double	 getpcpu(const struct kinfo_proc2 *);
 double	 getpmem(const struct kinfo_proc2 *);
-void	 gname(void *, VARENT *, int);
-void	 groups(void *, VARENT *, int);
-void	 groupnames(void *, VARENT *, int);
-void	 lcputime(void *, VARENT *, int);
-void	 logname(void *, VARENT *, int);
-void	 longtname(void *, VARENT *, int);
-void	 lname(void *, VARENT *, int);
-void	 lstarted(void *, VARENT *, int);
-void	 lstate(void *, VARENT *, int);
-void	 maxrss(void *, VARENT *, int);
+void	 gname(void *, VARENT *, enum mode);
+void	 groups(void *, VARENT *, enum mode);
+void	 groupnames(void *, VARENT *, enum mode);
+void	 lcputime(void *, VARENT *, enum mode);
+void	 logname(void *, VARENT *, enum mode);
+void	 longtname(void *, VARENT *, enum mode);
+void	 lname(void *, VARENT *, enum mode);
+void	 lstarted(void *, VARENT *, enum mode);
+void	 lstate(void *, VARENT *, enum mode);
+void	 maxrss(void *, VARENT *, enum mode);
 void	 nlisterr(struct nlist *);
-void	 p_rssize(void *, VARENT *, int);
-void	 pagein(void *, VARENT *, int);
+void	 p_rssize(void *, VARENT *, enum mode);
+void	 pagein(void *, VARENT *, enum mode);
 void	 parsefmt(const char *);
 void	 parsefmt_insert(const char *, VARENT **);
 void	 parsesort(const char *);
 VARENT * varlist_find(VARLIST *, const char *);
-void	 emul(void *, VARENT *, int);
-void	 pcpu(void *, VARENT *, int);
-void	 pmem(void *, VARENT *, int);
-void	 pnice(void *, VARENT *, int);
-void	 pri(void *, VARENT *, int);
+void	 emul(void *, VARENT *, enum mode);
+void	 pcpu(void *, VARENT *, enum mode);
+void	 pmem(void *, VARENT *, enum mode);
+void	 pnice(void *, VARENT *, enum mode);
+void	 pri(void *, VARENT *, enum mode);
 void	 printheader(void);
-void	 putimeval(void *, VARENT *, int);
-void	 pvar(void *, VARENT *, int);
-void	 rgname(void *, VARENT *, int);
-void	 rssize(void *, VARENT *, int);
-void	 runame(void *, VARENT *, int);
+void	 putimeval(void *, VARENT *, enum mode);
+void	 pvar(void *, VARENT *, enum mode);
+void	 rgname(void *, VARENT *, enum mode);
+void	 rssize(void *, VARENT *, enum mode);
+void	 runame(void *, VARENT *, enum mode);
 void	 showkey(void);
-void	 started(void *, VARENT *, int);
-void	 state(void *, VARENT *, int);
-void	 svgname(void *, VARENT *, int);
-void	 svuname(void *, VARENT *, int);
-void	 tdev(void *, VARENT *, int);
-void	 tname(void *, VARENT *, int);
-void	 tsize(void *, VARENT *, int);
-void	 ucomm(void *, VARENT *, int);
-void	 uname(void *, VARENT *, int);
-void	 uvar(void *, VARENT *, int);
-void	 vsize(void *, VARENT *, int);
-void	 wchan(void *, VARENT *, int);
+void	 started(void *, VARENT *, enum mode);
+void	 state(void *, VARENT *, enum mode);
+void	 svgname(void *, VARENT *, enum mode);
+void	 svuname(void *, VARENT *, enum mode);
+void	 tdev(void *, VARENT *, enum mode);
+void	 tname(void *, VARENT *, enum mode);
+void	 tsize(void *, VARENT *, enum mode);
+void	 ucomm(void *, VARENT *, enum mode);
+void	 uname(void *, VARENT *, enum mode);
+void	 uvar(void *, VARENT *, enum mode);
+void	 vsize(void *, VARENT *, enum mode);
+void	 wchan(void *, VARENT *, enum mode);

Index: src/bin/ps/print.c
diff -u src/bin/ps/print.c:1.121 src/bin/ps/print.c:1.121.2.1
--- src/bin/ps/print.c:1.121	Wed Jan 15 08:07:53 2014
+++ src/bin/ps/print.c	Sun Aug 10 06:41:18 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: print.c,v 1.121 2014/01/15 08:07:53 mlelstv Exp $	*/
+/*	$NetBSD: print.c,v 1.121.2.1 2014/08/10 06:41:18 tls Exp $	*/
 
 /*
  * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 #if 0
 static char sccsid[] = "@(#)print.c	8.6 (Berkeley) 4/16/94";
 #else
-__RCSID("$NetBSD: print.c,v 1.121 2014/01/15 08:07:53 mlelstv Exp $");
+__RCSID("$NetBSD: print.c,v 1.121.2.1 2014/08/10 06:41:18 tls Exp $");
 #endif
 #endif /* not lint */
 
@@ -93,12 +93,12 @@ __RCSID("$NetBSD: print.c,v 1.121 2014/0
 #include "ps.h"
 
 static char *cmdpart(char *);
-static void  printval(void *, VAR *, int);
+static void  printval(void *, VAR *, enum mode);
 static int   titlecmp(char *, char **);
 
-static void  doubleprintorsetwidth(VAR *, double, int, int);
-static void  intprintorsetwidth(VAR *, int, int);
-static void  strprintorsetwidth(VAR *, const char *, int);
+static void  doubleprintorsetwidth(VAR *, double, int, enum mode);
+static void  intprintorsetwidth(VAR *, int, enum mode);
+static void  strprintorsetwidth(VAR *, const char *, enum mode);
 
 static time_t now;
 
@@ -218,7 +218,7 @@ titlecmp(char *name, char **argv)
 }
 
 static void
-doubleprintorsetwidth(VAR *v, double val, int prec, int mode)
+doubleprintorsetwidth(VAR *v, double val, int prec, enum mode mode)
 {
 	int fmtlen;
 
@@ -240,7 +240,7 @@ doubleprintorsetwidth(VAR *v, double val
 }
 
 static void
-intprintorsetwidth(VAR *v, int val, int mode)
+intprintorsetwidth(VAR *v, int val, enum mode mode)
 {
 	int fmtlen;
 
@@ -261,7 +261,7 @@ intprintorsetwidth(VAR *v, int val, int 
 }
 
 static void
-strprintorsetwidth(VAR *v, const char *str, int mode)
+strprintorsetwidth(VAR *v, const char *str, enum mode mode)
 {
 	int len;
 
@@ -278,7 +278,7 @@ strprintorsetwidth(VAR *v, const char *s
 }
 
 void
-command(void *arg, VARENT *ve, int mode)
+command(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_proc2 *ki;
 	VAR *v;
@@ -359,7 +359,7 @@ command(void *arg, VARENT *ve, int mode)
 }
 
 void
-groups(void *arg, VARENT *ve, int mode)
+groups(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_proc2 *ki;
 	VAR *v;
@@ -397,7 +397,7 @@ groups(void *arg, VARENT *ve, int mode)
 }
 
 void
-groupnames(void *arg, VARENT *ve, int mode)
+groupnames(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_proc2 *ki;
 	VAR *v;
@@ -434,7 +434,7 @@ groupnames(void *arg, VARENT *ve, int mo
 }
 
 void
-ucomm(void *arg, VARENT *ve, int mode)
+ucomm(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_proc2 *k;
 	VAR *v;
@@ -445,7 +445,7 @@ ucomm(void *arg, VARENT *ve, int mode)
 }
 
 void
-emul(void *arg, VARENT *ve, int mode)
+emul(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_proc2 *k;
 	VAR *v;
@@ -456,7 +456,7 @@ emul(void *arg, VARENT *ve, int mode)
 }
 
 void
-logname(void *arg, VARENT *ve, int mode)
+logname(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_proc2 *k;
 	VAR *v;
@@ -467,7 +467,7 @@ logname(void *arg, VARENT *ve, int mode)
 }
 
 void
-state(void *arg, VARENT *ve, int mode)
+state(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_proc2 *k;
 	int flag, is_zombie;
@@ -551,7 +551,7 @@ state(void *arg, VARENT *ve, int mode)
 }
 
 void
-lstate(void *arg, VARENT *ve, int mode)
+lstate(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_lwp *k;
 	int flag;
@@ -610,7 +610,7 @@ lstate(void *arg, VARENT *ve, int mode)
 }
 
 void
-pnice(void *arg, VARENT *ve, int mode)
+pnice(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_proc2 *k;
 	VAR *v;
@@ -621,7 +621,7 @@ pnice(void *arg, VARENT *ve, int mode)
 }
 
 void
-pri(void *arg, VARENT *ve, int mode)
+pri(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_lwp *l;
 	VAR *v;
@@ -632,7 +632,7 @@ pri(void *arg, VARENT *ve, int mode)
 }
 
 void
-uname(void *arg, VARENT *ve, int mode)
+uname(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_proc2 *k;
 	VAR *v;
@@ -643,7 +643,7 @@ uname(void *arg, VARENT *ve, int mode)
 }
 
 void
-runame(void *arg, VARENT *ve, int mode)
+runame(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_proc2 *k;
 	VAR *v;
@@ -654,7 +654,7 @@ runame(void *arg, VARENT *ve, int mode)
 }
 
 void
-svuname(void *arg, VARENT *ve, int mode)
+svuname(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_proc2 *k;
 	VAR *v;
@@ -665,7 +665,7 @@ svuname(void *arg, VARENT *ve, int mode)
 }
 
 void
-gname(void *arg, VARENT *ve, int mode)
+gname(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_proc2 *k;
 	VAR *v;
@@ -676,7 +676,7 @@ gname(void *arg, VARENT *ve, int mode)
 }
 
 void
-rgname(void *arg, VARENT *ve, int mode)
+rgname(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_proc2 *k;
 	VAR *v;
@@ -687,7 +687,7 @@ rgname(void *arg, VARENT *ve, int mode)
 }
 
 void
-svgname(void *arg, VARENT *ve, int mode)
+svgname(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_proc2 *k;
 	VAR *v;
@@ -698,7 +698,7 @@ svgname(void *arg, VARENT *ve, int mode)
 }
 
 void
-tdev(void *arg, VARENT *ve, int mode)
+tdev(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_proc2 *k;
 	VAR *v;
@@ -722,7 +722,7 @@ tdev(void *arg, VARENT *ve, int mode)
 }
 
 void
-tname(void *arg, VARENT *ve, int mode)
+tname(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_proc2 *k;
 	VAR *v;
@@ -757,7 +757,7 @@ tname(void *arg, VARENT *ve, int mode)
 }
 
 void
-longtname(void *arg, VARENT *ve, int mode)
+longtname(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_proc2 *k;
 	VAR *v;
@@ -779,7 +779,7 @@ longtname(void *arg, VARENT *ve, int mod
 }
 
 void
-started(void *arg, VARENT *ve, int mode)
+started(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_proc2 *k;
 	VAR *v;
@@ -815,7 +815,7 @@ started(void *arg, VARENT *ve, int mode)
 }
 
 void
-lstarted(void *arg, VARENT *ve, int mode)
+lstarted(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_proc2 *k;
 	VAR *v;
@@ -844,7 +844,7 @@ lstarted(void *arg, VARENT *ve, int mode
 }
 
 void
-elapsed(void *arg, VARENT *ve, int mode)
+elapsed(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_proc2 *k;
 	VAR *v;
@@ -938,7 +938,7 @@ elapsed(void *arg, VARENT *ve, int mode)
 }
 
 void
-wchan(void *arg, VARENT *ve, int mode)
+wchan(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_lwp *l;
 	VAR *v;
@@ -968,7 +968,7 @@ wchan(void *arg, VARENT *ve, int mode)
 #define	pgtok(a)        (((a)*(size_t)getpagesize())/1024)
 
 void
-vsize(void *arg, VARENT *ve, int mode)
+vsize(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_proc2 *k;
 	VAR *v;
@@ -979,7 +979,7 @@ vsize(void *arg, VARENT *ve, int mode)
 }
 
 void
-rssize(void *arg, VARENT *ve, int mode)
+rssize(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_proc2 *k;
 	VAR *v;
@@ -991,7 +991,7 @@ rssize(void *arg, VARENT *ve, int mode)
 }
 
 void
-p_rssize(void *arg, VARENT *ve, int mode)	/* doesn't account for text */
+p_rssize(void *arg, VARENT *ve, enum mode mode)	/* doesn't account for text */
 {
 	struct kinfo_proc2 *k;
 	VAR *v;
@@ -1002,7 +1002,7 @@ p_rssize(void *arg, VARENT *ve, int mode
 }
 
 void
-cpuid(void *arg, VARENT *ve, int mode)
+cpuid(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_lwp *l;
 	VAR *v;
@@ -1013,7 +1013,7 @@ cpuid(void *arg, VARENT *ve, int mode)
 }
 
 static void
-cputime1(int32_t secs, int32_t psecs, VAR *v, int mode)
+cputime1(int32_t secs, int32_t psecs, VAR *v, enum mode mode)
 {
 	int fmtlen;
 
@@ -1049,7 +1049,7 @@ cputime1(int32_t secs, int32_t psecs, VA
 }
 
 void
-cputime(void *arg, VARENT *ve, int mode)
+cputime(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_proc2 *k;
 	VAR *v;
@@ -1075,7 +1075,7 @@ cputime(void *arg, VARENT *ve, int mode)
 }
 
 void
-lcputime(void *arg, VARENT *ve, int mode)
+lcputime(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_lwp *l;
 	VAR *v;
@@ -1112,7 +1112,7 @@ getpcpu(const struct kinfo_proc2 *k)
 }
 
 void
-pcpu(void *arg, VARENT *ve, int mode)
+pcpu(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_proc2 *k;
 	VAR *v;
@@ -1144,7 +1144,7 @@ getpmem(const struct kinfo_proc2 *k)
 }
 
 void
-pmem(void *arg, VARENT *ve, int mode)
+pmem(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_proc2 *k;
 	VAR *v;
@@ -1155,7 +1155,7 @@ pmem(void *arg, VARENT *ve, int mode)
 }
 
 void
-pagein(void *arg, VARENT *ve, int mode)
+pagein(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_proc2 *k;
 	VAR *v;
@@ -1166,7 +1166,7 @@ pagein(void *arg, VARENT *ve, int mode)
 }
 
 void
-maxrss(void *arg, VARENT *ve, int mode)
+maxrss(void *arg, VARENT *ve, enum mode mode)
 {
 	VAR *v;
 
@@ -1177,7 +1177,7 @@ maxrss(void *arg, VARENT *ve, int mode)
 }
 
 void
-tsize(void *arg, VARENT *ve, int mode)
+tsize(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_proc2 *k;
 	VAR *v;
@@ -1192,7 +1192,7 @@ tsize(void *arg, VARENT *ve, int mode)
  * structures.
  */
 static void
-printval(void *bp, VAR *v, int mode)
+printval(void *bp, VAR *v, enum mode mode)
 {
 	static char ofmt[32] = "%";
 	int width, vok, fmtlen;
@@ -1390,7 +1390,7 @@ printval(void *bp, VAR *v, int mode)
 }
 
 void
-pvar(void *arg, VARENT *ve, int mode)
+pvar(void *arg, VARENT *ve, enum mode mode)
 {
 	VAR *v;
 
@@ -1405,7 +1405,7 @@ pvar(void *arg, VARENT *ve, int mode)
 }
 
 void
-putimeval(void *arg, VARENT *ve, int mode)
+putimeval(void *arg, VARENT *ve, enum mode mode)
 {
 	VAR *v = ve->var;
 	struct kinfo_proc2 *k = arg;
@@ -1457,7 +1457,7 @@ putimeval(void *arg, VARENT *ve, int mod
 }
 
 void
-lname(void *arg, VARENT *ve, int mode)
+lname(void *arg, VARENT *ve, enum mode mode)
 {
 	struct kinfo_lwp *l;
 	VAR *v;

Index: src/bin/ps/ps.c
diff -u src/bin/ps/ps.c:1.80 src/bin/ps/ps.c:1.80.2.1
--- src/bin/ps/ps.c:1.80	Wed Feb 19 20:42:14 2014
+++ src/bin/ps/ps.c	Sun Aug 10 06:41:18 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ps.c,v 1.80 2014/02/19 20:42:14 dsl Exp $	*/
+/*	$NetBSD: ps.c,v 1.80.2.1 2014/08/10 06:41:18 tls Exp $	*/
 
 /*
  * Copyright (c) 2000-2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 19
 #if 0
 static char sccsid[] = "@(#)ps.c	8.4 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: ps.c,v 1.80 2014/02/19 20:42:14 dsl Exp $");
+__RCSID("$NetBSD: ps.c,v 1.80.2.1 2014/08/10 06:41:18 tls Exp $");
 #endif
 #endif /* not lint */
 
@@ -175,8 +175,11 @@ ttyname2dev(const char *ttname, int *xfl
 		ttypath = ttname;
 	*what = KERN_PROC_TTY;
 	if (stat(ttypath, &sb) == -1) {
-		devmajor_t pts = getdevmajor("pts", S_IFCHR);
+		devmajor_t pts;
+		int serrno;
 
+		serrno = errno;
+		pts = getdevmajor("pts", S_IFCHR);
 		if (pts != NODEVMAJOR && strncmp(ttname, "pts/", 4) == 0) {
 			int ptsminor = atoi(ttname + 4);
 
@@ -184,6 +187,7 @@ ttyname2dev(const char *ttname, int *xfl
 			if (strcmp(pathbuf, ttname) == 0 && ptsminor >= 0)
 				return makedev(pts, ptsminor);
 		}
+		errno = serrno;
 		err(1, "%s", ttypath);
 	}
 	if (!S_ISCHR(sb.st_mode))
@@ -199,7 +203,7 @@ main(int argc, char *argv[])
 	struct kinfo_lwp *kl, *l;
 	int ch, i, j, fmt, lineno, nentries, nlwps;
 	long long flag;
-	int prtheader, wflag, what, xflg, mode, showlwps;
+	int prtheader, wflag, what, xflg, showlwps;
 	char *nlistf, *memf, *swapf, errbuf[_POSIX2_LINE_MAX];
 	char *ttname;
 
@@ -221,7 +225,7 @@ main(int argc, char *argv[])
 	what = KERN_PROC_UID;
 	flag = myuid = getuid();
 	memf = nlistf = swapf = NULL;
-	mode = PRINTMODE;
+
 	while ((ch = getopt(argc, argv, GETOPTSTR)) != -1)
 		switch((char)ch) {
 		case 'A':
@@ -421,33 +425,32 @@ main(int argc, char *argv[])
 	 * "setwidth" mode to determine the widest element of
 	 * the column.
 	 */
-	if (mode == PRINTMODE)
-		for (i = 0; i < nentries; i++) {
-			struct kinfo_proc2 *ki = &kinfo[i];
-
-			if (xflg == 0 && (ki->p_tdev == (uint32_t)NODEV ||
-			    (ki->p_flag & P_CONTROLT) == 0))
-				continue;
-
-			kl = kvm_getlwps(kd, ki->p_pid, ki->p_paddr,
-			    sizeof(struct kinfo_lwp), &nlwps);
-			if (kl == 0)
-				nlwps = 0;
-			if (showlwps == 0) {
-				l = pick_representative_lwp(ki, kl, nlwps);
-				SIMPLEQ_FOREACH(vent, &displaylist, next)
-					OUTPUT(vent, ki, l, WIDTHMODE);
-			} else {
-				/* The printing is done with the loops
-				 * reversed, but here we don't need that,
-				 * and this improves the code locality a bit.
-				 */
-				SIMPLEQ_FOREACH(vent, &displaylist, next)
-					for (j = 0; j < nlwps; j++)
-						OUTPUT(vent, ki, &kl[j],
-						    WIDTHMODE);
-			}
+
+	for (i = 0; i < nentries; i++) {
+		struct kinfo_proc2 *ki = &kinfo[i];
+
+		if (xflg == 0 && (ki->p_tdev == (uint32_t)NODEV ||
+		    (ki->p_flag & P_CONTROLT) == 0))
+			continue;
+
+		kl = kvm_getlwps(kd, ki->p_pid, ki->p_paddr,
+		    sizeof(struct kinfo_lwp), &nlwps);
+		if (kl == 0)
+			nlwps = 0;
+		if (showlwps == 0) {
+			l = pick_representative_lwp(ki, kl, nlwps);
+			SIMPLEQ_FOREACH(vent, &displaylist, next)
+				OUTPUT(vent, ki, l, WIDTHMODE);
+		} else {
+			/* The printing is done with the loops
+			 * reversed, but here we don't need that,
+			 * and this improves the code locality a bit.
+			 */
+			SIMPLEQ_FOREACH(vent, &displaylist, next)
+				for (j = 0; j < nlwps; j++)
+					OUTPUT(vent, ki, &kl[j], WIDTHMODE);
 		}
+	}
 	/*
 	 * Print header - AFTER determining process field widths.
 	 * printheader() also adds up the total width of all
@@ -471,7 +474,7 @@ main(int argc, char *argv[])
 		if (showlwps == 0) {
 			l = pick_representative_lwp(ki, kl, nlwps);
 			SIMPLEQ_FOREACH(vent, &displaylist, next) {
-				OUTPUT(vent, ki, l, mode);
+				OUTPUT(vent, ki, l, PRINTMODE);
 				if (SIMPLEQ_NEXT(vent, next) != NULL)
 					(void)putchar(' ');
 			}
@@ -484,7 +487,7 @@ main(int argc, char *argv[])
 		} else {
 			for (j = 0; j < nlwps; j++) {
 				SIMPLEQ_FOREACH(vent, &displaylist, next) {
-					OUTPUT(vent, ki, &kl[j], mode);
+					OUTPUT(vent, ki, &kl[j], PRINTMODE);
 					if (SIMPLEQ_NEXT(vent, next) != NULL)
 						(void)putchar(' ');
 				}

Index: src/bin/ps/ps.h
diff -u src/bin/ps/ps.h:1.26 src/bin/ps/ps.h:1.26.60.1
--- src/bin/ps/ps.h:1.26	Mon Oct  2 17:54:35 2006
+++ src/bin/ps/ps.h	Sun Aug 10 06:41:18 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ps.h,v 1.26 2006/10/02 17:54:35 apb Exp $	*/
+/*	$NetBSD: ps.h,v 1.26.60.1 2014/08/10 06:41:18 tls Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -35,8 +35,10 @@
 
 #define	UNLIMITED	0	/* unlimited terminal width */
 
-#define	PRINTMODE	0	/* print values */
-#define	WIDTHMODE	1	/* determine width of column */
+enum mode {
+	PRINTMODE = 0,		/* print values */
+	WIDTHMODE = 1		/* determine width of column */
+};
 
 enum type {
 	UNSPECIFIED,
@@ -65,7 +67,7 @@ typedef struct var {
 #define	ALIAS	0x40		/* entry is alias for 'header' */
 	u_int	flag;
 				/* output routine */
-	void	(*oproc)(void *, struct varent *, int);
+	void	(*oproc)(void *, struct varent *, enum mode);
 	/*
 	 * The following (optional) elements are hooks for passing information
 	 * to the generic output routine: pvar (that which prints simple

Index: src/bin/sh/Makefile
diff -u src/bin/sh/Makefile:1.99 src/bin/sh/Makefile:1.99.8.1
--- src/bin/sh/Makefile:1.99	Sun Dec  2 12:55:27 2012
+++ src/bin/sh/Makefile	Sun Aug 10 06:41:18 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.99 2012/12/02 12:55:27 apb Exp $
+#	$NetBSD: Makefile,v 1.99.8.1 2014/08/10 06:41:18 tls Exp $
 #	@(#)Makefile	8.4 (Berkeley) 5/5/95
 
 .include <bsd.own.mk>
@@ -77,9 +77,7 @@ nodes.c nodes.h: mknodes.sh nodetypes no
 NBCOMPATLIB=   -L${TOOLDIR}/lib -lnbcompat
 .endif
 
-.if make(install)
 SUBDIR+=USD.doc
-.endif
 
 COPTS.printf.c = -Wno-format-nonliteral
 COPTS.jobs.c = -Wno-format-nonliteral

Index: src/bin/sh/alias.c
diff -u src/bin/sh/alias.c:1.14 src/bin/sh/alias.c:1.14.20.1
--- src/bin/sh/alias.c:1.14	Sat Jun 18 21:18:46 2011
+++ src/bin/sh/alias.c	Sun Aug 10 06:41:18 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: alias.c,v 1.14 2011/06/18 21:18:46 christos Exp $	*/
+/*	$NetBSD: alias.c,v 1.14.20.1 2014/08/10 06:41:18 tls 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.14 2011/06/18 21:18:46 christos Exp $");
+__RCSID("$NetBSD: alias.c,v 1.14.20.1 2014/08/10 06:41:18 tls Exp $");
 #endif
 #endif /* not lint */
 
@@ -59,7 +59,7 @@ struct alias *atab[ATABSIZE];
 
 STATIC void setalias(char *, char *);
 STATIC int unalias(char *);
-STATIC struct alias **hashalias(char *);
+STATIC struct alias **hashalias(const char *);
 
 STATIC
 void
@@ -178,7 +178,7 @@ rmaliases(void)
 }
 
 struct alias *
-lookupalias(char *name, int check)
+lookupalias(const char *name, int check)
 {
 	struct alias *ap = *hashalias(name);
 
@@ -193,8 +193,8 @@ lookupalias(char *name, int check)
 	return (NULL);
 }
 
-char *
-get_alias_text(char *name)
+const char *
+alias_text(void *dummy __unused, const char *name)
 {
 	struct alias *ap;
 
@@ -264,7 +264,7 @@ unaliascmd(int argc, char **argv)
 }
 
 STATIC struct alias **
-hashalias(char *p)
+hashalias(const char *p)
 {
 	unsigned int hashval;
 

Index: src/bin/sh/alias.h
diff -u src/bin/sh/alias.h:1.7 src/bin/sh/alias.h:1.7.20.1
--- src/bin/sh/alias.h:1.7	Sat Jun 18 21:18:46 2011
+++ src/bin/sh/alias.h	Sun Aug 10 06:41:18 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: alias.h,v 1.7 2011/06/18 21:18:46 christos Exp $	*/
+/*	$NetBSD: alias.h,v 1.7.20.1 2014/08/10 06:41:18 tls Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -43,6 +43,6 @@ struct alias {
 	int flag;
 };
 
-struct alias *lookupalias(char *, int);
-char *get_alias_text(char *);
+struct alias *lookupalias(const char *, int);
+const char *alias_text(void *, const char *);
 void rmaliases(void);

Index: src/bin/sh/eval.c
diff -u src/bin/sh/eval.c:1.108 src/bin/sh/eval.c:1.108.2.1
--- src/bin/sh/eval.c:1.108	Sun Jan 26 22:38:20 2014
+++ src/bin/sh/eval.c	Sun Aug 10 06:41:18 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: eval.c,v 1.108 2014/01/26 22:38:20 christos Exp $	*/
+/*	$NetBSD: eval.c,v 1.108.2.1 2014/08/10 06:41:18 tls 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.108 2014/01/26 22:38:20 christos Exp $");
+__RCSID("$NetBSD: eval.c,v 1.108.2.1 2014/08/10 06:41:18 tls Exp $");
 #endif
 #endif /* not lint */
 
@@ -89,11 +89,20 @@ __RCSID("$NetBSD: eval.c,v 1.108 2014/01
 #define EV_TESTED 02		/* exit status is checked; ignore -e flag */
 #define EV_BACKCMD 04		/* command executing within back quotes */
 
-int evalskip;			/* set if we are skipping commands */
+STATIC enum skipstate evalskip;	/* != SKIPNONE if we are skipping commands */
 STATIC int skipcount;		/* number of levels to skip */
-MKINIT int loopnest;		/* current loop nesting level */
-int funcnest;			/* depth of function calls */
+STATIC int loopnest;		/* current loop nesting level */
+STATIC int funcnest;		/* depth of function calls */
 STATIC int builtin_flags;	/* evalcommand flags for builtins */
+/*
+ * Base function nesting level inside a dot command.  Set to 0 initially
+ * and to (funcnest + 1) before every dot command to enable 
+ *   1) detection of being in a file sourced by a dot command and
+ *   2) counting of function nesting in that file for the implementation
+ *      of the return command.
+ * The value is reset to its previous value after the dot command.
+ */
+STATIC int dot_funcnest;
 
 
 const char *commandname;
@@ -111,6 +120,7 @@ STATIC void evalpipe(union node *);
 STATIC void evalcommand(union node *, int, struct backcmd *);
 STATIC void prehash(union node *);
 
+STATIC char *find_dot_file(char *);
 
 /*
  * Called to reset things after an exception.
@@ -120,9 +130,7 @@ STATIC void prehash(union node *);
 INCLUDE "eval.h"
 
 RESET {
-	evalskip = 0;
-	loopnest = 0;
-	funcnest = 0;
+	reset_eval();
 }
 
 SHELLPROC {
@@ -130,6 +138,15 @@ SHELLPROC {
 }
 #endif
 
+void
+reset_eval(void)
+{
+	evalskip = SKIPNONE;
+	dot_funcnest = 0;
+	loopnest = 0;
+	funcnest = 0;
+}
+
 static int
 sh_pipe(int fds[2])
 {
@@ -327,11 +344,11 @@ evalloop(union node *n, int flags)
 		evaltree(n->nbinary.ch1, EV_TESTED);
 		if (evalskip) {
 skipping:	  if (evalskip == SKIPCONT && --skipcount <= 0) {
-				evalskip = 0;
+				evalskip = SKIPNONE;
 				continue;
 			}
 			if (evalskip == SKIPBREAK && --skipcount <= 0)
-				evalskip = 0;
+				evalskip = SKIPNONE;
 			break;
 		}
 		if (n->type == NWHILE) {
@@ -377,11 +394,11 @@ evalfor(union node *n, int flags)
 		status = exitstatus;
 		if (evalskip) {
 			if (evalskip == SKIPCONT && --skipcount <= 0) {
-				evalskip = 0;
+				evalskip = SKIPNONE;
 				continue;
 			}
 			if (evalskip == SKIPBREAK && --skipcount <= 0)
-				evalskip = 0;
+				evalskip = SKIPNONE;
 			break;
 		}
 	}
@@ -964,7 +981,7 @@ normal_fork:
 		popredir();
 		INTON;
 		if (evalskip == SKIPFUNC) {
-			evalskip = 0;
+			evalskip = SKIPNONE;
 			skipcount = 0;
 		}
 		if (flags & EV_EXIT)
@@ -1104,7 +1121,24 @@ prehash(union node *n)
 				     pathval());
 }
 
+STATIC int
+in_function(void)
+{
+	return funcnest;
+}
 
+STATIC enum skipstate
+current_skipstate(void)
+{
+	return evalskip;
+}
+
+STATIC void
+stop_skipping(void)
+{
+	evalskip = SKIPNONE;
+	skipcount = 0;
+}
 
 /*
  * Builtin commands.  Builtin commands whose functions are closely
@@ -1151,9 +1185,84 @@ breakcmd(int argc, char **argv)
 	return 0;
 }
 
+int
+dotcmd(int argc, char **argv)
+{
+	exitstatus = 0;
+
+	if (argc >= 2) {		/* That's what SVR2 does */
+		char *fullname;
+		/*
+		 * dot_funcnest needs to be 0 when not in a dotcmd, so it
+		 * cannot be restored with (funcnest + 1).
+		 */
+		int dot_funcnest_old;
+		struct stackmark smark;
+
+		setstackmark(&smark);
+		fullname = find_dot_file(argv[1]);
+		setinputfile(fullname, 1);
+		commandname = fullname;
+		dot_funcnest_old = dot_funcnest;
+		dot_funcnest = funcnest + 1;
+		cmdloop(0);
+		dot_funcnest = dot_funcnest_old;
+		popfile();
+		popstackmark(&smark);
+	}
+	return exitstatus;
+}
+
+/*
+ * 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 char *
+find_dot_file(char *basename)
+{
+	char *fullname;
+	const char *path = pathval();
+	struct stat statb;
+
+	/* don't try this for absolute or relative paths */
+	if (strchr(basename, '/'))
+		return basename;
+
+	while ((fullname = padvance(&path, basename)) != NULL) {
+		if ((stat(fullname, &statb) == 0) && S_ISREG(statb.st_mode)) {
+			/*
+			 * Don't bother freeing here, since it will
+			 * be freed by the caller.
+			 */
+			return fullname;
+		}
+		stunalloc(fullname);
+	}
+
+	/* not found in the PATH */
+	error("%s: not found", basename);
+	/* NOTREACHED */
+}
+
+
 
 /*
  * The return command.
+ *
+ * Quoth the POSIX standard:
+ *   The return utility shall cause the shell to stop executing the current
+ *   function or dot script. If the shell is not currently executing
+ *   a function or dot script, the results are unspecified.
+ *
+ * As for the unspecified part, there seems to be no de-facto standard: bash
+ * ignores the return with a warning, zsh ignores the return in interactive
+ * mode but seems to liken it to exit in a script.  (checked May 2014)
+ *
+ * We choose to silently ignore the return.  Older versions of this shell
+ * set evalskip to SKIPFILE causing the shell to (indirectly) exit.  This
+ * had at least the problem of circumventing the check for stopped jobs,
+ * which would occur for exit or ^D.
  */
 
 int
@@ -1161,17 +1270,19 @@ returncmd(int argc, char **argv)
 {
 	int ret = argc > 1 ? number(argv[1]) : exitstatus;
 
-	if (funcnest) {
+	if ((dot_funcnest == 0 && funcnest)
+	    || (dot_funcnest > 0 && funcnest - (dot_funcnest - 1) > 0)) {
 		evalskip = SKIPFUNC;
 		skipcount = 1;
-		return ret;
-	}
-	else {
-		/* Do what ksh does; skip the rest of the file */
+	} else if (dot_funcnest > 0) {
 		evalskip = SKIPFILE;
 		skipcount = 1;
-		return ret;
+	} else {
+		/* XXX: should a warning be issued? */
+		ret = 0;
 	}
+
+	return ret;
 }
 
 

Index: src/bin/sh/eval.h
diff -u src/bin/sh/eval.h:1.15 src/bin/sh/eval.h:1.15.46.1
--- src/bin/sh/eval.h:1.15	Fri Feb 15 17:26:06 2008
+++ src/bin/sh/eval.h	Sun Aug 10 06:41:18 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: eval.h,v 1.15 2008/02/15 17:26:06 matt Exp $	*/
+/*	$NetBSD: eval.h,v 1.15.46.1 2014/08/10 06:41:18 tls Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -53,12 +53,21 @@ void evaltree(union node *, int);
 void evalbackcmd(union node *, struct backcmd *);
 
 /* in_function returns nonzero if we are currently evaluating a function */
-#define in_function()	funcnest
-extern int funcnest;
-extern int evalskip;
+int in_function(void);		/* return non-zero, if evaluating a function */
 
 /* reasons for skipping commands (see comment on breakcmd routine) */
-#define SKIPBREAK	1
-#define SKIPCONT	2
-#define SKIPFUNC	3
-#define SKIPFILE	4
+enum skipstate {
+      SKIPNONE  = 0,	/* not skipping */
+      SKIPBREAK,	/* break */
+      SKIPCONT,		/* continue */
+      SKIPFUNC,		/* return in a function */
+      SKIPFILE		/* return in a dot command */
+};
+
+enum skipstate current_skipstate(void);
+void stop_skipping(void);	/* reset internal skipping state to SKIPNONE */
+
+/*
+ * Only for use by reset() in init.c!
+ */
+void reset_eval(void);

Index: src/bin/sh/histedit.c
diff -u src/bin/sh/histedit.c:1.46 src/bin/sh/histedit.c:1.46.2.1
--- src/bin/sh/histedit.c:1.46	Sun Mar 23 05:07:59 2014
+++ src/bin/sh/histedit.c	Sun Aug 10 06:41:18 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: histedit.c,v 1.46 2014/03/23 05:07:59 dholland Exp $	*/
+/*	$NetBSD: histedit.c,v 1.46.2.1 2014/08/10 06:41:18 tls 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.46 2014/03/23 05:07:59 dholland Exp $");
+__RCSID("$NetBSD: histedit.c,v 1.46.2.1 2014/08/10 06:41:18 tls Exp $");
 #endif
 #endif /* not lint */
 
@@ -59,6 +59,7 @@ __RCSID("$NetBSD: histedit.c,v 1.46 2014
 #include "mystring.h"
 #include "myhistedit.h"
 #include "error.h"
+#include "alias.h"
 #ifndef SMALL
 #include "eval.h"
 #include "memalloc.h"
@@ -135,6 +136,7 @@ histedit(void)
 					el_set(el, EL_HIST, history, hist);
 				el_set(el, EL_PROMPT, getprompt);
 				el_set(el, EL_SIGNAL, 1);
+				el_set(el, EL_ALIAS_TEXT, alias_text, NULL);
 				el_set(el, EL_ADDFN, "rl-complete",
 				    "ReadLine compatible completion function",
 				    _el_fn_complete);

Index: src/bin/sh/jobs.c
diff -u src/bin/sh/jobs.c:1.72 src/bin/sh/jobs.c:1.72.2.1
--- src/bin/sh/jobs.c:1.72	Sun Jan 26 22:38:20 2014
+++ src/bin/sh/jobs.c	Sun Aug 10 06:41:18 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: jobs.c,v 1.72 2014/01/26 22:38:20 christos Exp $	*/
+/*	$NetBSD: jobs.c,v 1.72.2.1 2014/08/10 06:41:18 tls 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.72 2014/01/26 22:38:20 christos Exp $");
+__RCSID("$NetBSD: jobs.c,v 1.72.2.1 2014/08/10 06:41:18 tls Exp $");
 #endif
 #endif /* not lint */
 
@@ -649,7 +649,7 @@ waitcmd(int argc, char **argv)
 			if (dowait(WBLOCK|WNOFREE, job) == -1)
 			       return 128 + SIGINT;
 		}
-		status = job->ps[job->nprocs - 1].status;
+		status = job->ps[job->nprocs ? job->nprocs - 1 : 0].status;
 		if (WIFEXITED(status))
 			retval = WEXITSTATUS(status);
 #if JOBS

Index: src/bin/sh/main.c
diff -u src/bin/sh/main.c:1.57 src/bin/sh/main.c:1.57.20.1
--- src/bin/sh/main.c:1.57	Sat Jun 18 21:18:46 2011
+++ src/bin/sh/main.c	Sun Aug 10 06:41:18 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.57 2011/06/18 21:18:46 christos Exp $	*/
+/*	$NetBSD: main.c,v 1.57.20.1 2014/08/10 06:41:18 tls 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.57 2011/06/18 21:18:46 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.57.20.1 2014/08/10 06:41:18 tls Exp $");
 #endif
 #endif /* not lint */
 
@@ -89,7 +89,6 @@ extern int etext();
 #endif
 
 STATIC void read_profile(const char *);
-STATIC char *find_dot_file(char *);
 int main(int, char **);
 
 /*
@@ -239,6 +238,7 @@ cmdloop(int top)
 	struct stackmark smark;
 	int inter;
 	int numeof = 0;
+	enum skipstate skip;
 
 	TRACE(("cmdloop(%d) called\n", top));
 	setstackmark(&smark);
@@ -270,8 +270,18 @@ cmdloop(int top)
 		}
 		popstackmark(&smark);
 		setstackmark(&smark);
-		if (evalskip == SKIPFILE) {
-			evalskip = 0;
+
+		/*
+		 * Any SKIP* can occur here!  SKIP(FUNC|BREAK|CONT) occur when
+		 * a dotcmd is in a loop or a function body and appropriate
+		 * built-ins occurs in file scope in the sourced file.  Values
+		 * other than SKIPFILE are reset by the appropriate eval*()
+		 * that contained the dotcmd() call.
+		 */
+		skip = current_skipstate();
+		if (skip != SKIPNONE) {
+			if (skip == SKIPFILE)
+				stop_skipping();
 			break;
 		}
 	}
@@ -337,60 +347,6 @@ readcmdfile(char *name)
 
 
 
-/*
- * 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 char *
-find_dot_file(char *basename)
-{
-	char *fullname;
-	const char *path = pathval();
-	struct stat statb;
-
-	/* don't try this for absolute or relative paths */
-	if (strchr(basename, '/'))
-		return basename;
-
-	while ((fullname = padvance(&path, basename)) != NULL) {
-		if ((stat(fullname, &statb) == 0) && S_ISREG(statb.st_mode)) {
-			/*
-			 * Don't bother freeing here, since it will
-			 * be freed by the caller.
-			 */
-			return fullname;
-		}
-		stunalloc(fullname);
-	}
-
-	/* not found in the PATH */
-	error("%s: not found", basename);
-	/* NOTREACHED */
-}
-
-int
-dotcmd(int argc, char **argv)
-{
-	exitstatus = 0;
-
-	if (argc >= 2) {		/* That's what SVR2 does */
-		char *fullname;
-		struct stackmark smark;
-
-		setstackmark(&smark);
-		fullname = find_dot_file(argv[1]);
-		setinputfile(fullname, 1);
-		commandname = fullname;
-		cmdloop(0);
-		popfile();
-		popstackmark(&smark);
-	}
-	return exitstatus;
-}
-
-
 int
 exitcmd(int argc, char **argv)
 {

Index: src/bin/sh/sh.1
diff -u src/bin/sh/sh.1:1.112 src/bin/sh/sh.1:1.112.2.1
--- src/bin/sh/sh.1:1.112	Mon Jan 20 14:05:51 2014
+++ src/bin/sh/sh.1	Sun Aug 10 06:41:18 2014
@@ -1,4 +1,4 @@
-.\"	$NetBSD: sh.1,v 1.112 2014/01/20 14:05:51 roy Exp $
+.\"	$NetBSD: sh.1,v 1.112.2.1 2014/08/10 06:41:18 tls Exp $
 .\" Copyright (c) 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
 .\"
@@ -31,7 +31,7 @@
 .\"
 .\"	@(#)sh.1	8.6 (Berkeley) 5/4/95
 .\"
-.Dd January 20, 2014
+.Dd June 1, 2014
 .Dt SH 1
 .Os
 .Sh NAME
@@ -1192,10 +1192,24 @@ be built in for efficiency (e.g.
 .Xr test 1 ,
 etc).
 .Bl -tag -width 5n
-.It :
+.It : [ Ar arg ... ]
 A null command that returns a 0 (true) exit value.
+Any arguments are ignored.
 .It \&. file
-The commands in the specified file are read and executed by the shell.
+The dot command reads and executes the commands from the specified
+.Ar file
+in the current shell environment.
+The file does not need to be executable and is looked up from the directories
+listed in the
+.Ev PATH
+variable if it does not contain a directory separator
+.Pq Sq / .
+The return command can be used for a premature return from the sourced file.
+.Pp
+The POSIX standard is unclear on how loop control keywords (break
+and continue) behave across a dot command boundary.
+This implementation allows them to control loops surrounding the dot command,
+but obviously such behavior should not be relied on.
 .It alias Op Ar name Ns Op Ar "=string ..."
 If
 .Ar name=string
@@ -1632,6 +1646,21 @@ With the
 .Fl p
 option specified the output will be formatted suitably for non-interactive use.
 .Pp
+.It return [ Ar n ]
+Stop executing the current function or a dot command with return value of
+.Ar n
+or the value of the last executed command, if not specified.
+For portability,
+.Ar n
+should be in the range from 0 to 255.
+.Pp
+The POSIX standard says that the results of
+.Sq return
+outside a function or a dot command are unspecified.
+This implementation treats such a return as a no-op with a return value of 0
+(success, true).
+Use the exit command instead, if you want to return from a script or exit
+your shell.
 .It set Oo { Fl options | Cm +options | Cm \-- } Oc Ar arg ...
 The
 .Ic set

Index: src/bin/sh/USD.doc/Makefile
diff -u src/bin/sh/USD.doc/Makefile:1.1 src/bin/sh/USD.doc/Makefile:1.1.24.1
--- src/bin/sh/USD.doc/Makefile:1.1	Sun Aug 22 01:58:16 2010
+++ src/bin/sh/USD.doc/Makefile	Sun Aug 10 06:41:18 2014
@@ -1,12 +1,12 @@
-#	$NetBSD: Makefile,v 1.1 2010/08/22 01:58:16 perry Exp $
+#	$NetBSD: Makefile,v 1.1.24.1 2014/08/10 06:41:18 tls Exp $
 #	@(#)Makefile	8.1 (Berkeley) 8/14/93
 
-DIR=	usd/03.shell
-SRCS=	Rv7man t.mac t1 t2 t3 t4
-MACROS= -ms
-
-paper.ps: ${SRCS}
-	${TOOL_REFER} -e -p ${SRCS} | \
-	    ${TOOL_ROFF_PS} ${MACROS} > ${.TARGET}
+SECTION=reference/ref1
+ARTICLE=sh
+SRCS=	referargs t.mac t1 t2 t3 t4
+MACROS=-ms
+ROFF_REFER=yes
+#REFER_ARGS=-e -p Rv7man
+EXTRAHTMLFILES=sh1.png sh2.png sh3.png sh4.png sh5.png
 
 .include <bsd.doc.mk>

Added files:

Index: src/bin/sh/USD.doc/referargs
diff -u /dev/null src/bin/sh/USD.doc/referargs:1.1.2.2
--- /dev/null	Sun Aug 10 06:41:19 2014
+++ src/bin/sh/USD.doc/referargs	Sun Aug 10 06:41:18 2014
@@ -0,0 +1,8 @@
+.\" $NetBSD: referargs,v 1.1.2.2 2014/08/10 06:41:18 tls Exp $
+.\"
+.\" Arguments for refer; these were previously passed on the refer(1)
+.\" command line: -e -p Rv7man
+.R1
+accumulate
+database Rv7man
+.R2

Reply via email to