[Zrouter-src-freebsd] ZRouter.org: push to FreeBSD HEAD tree

zrouter-src-freebsd at zrouter.org zrouter-src-freebsd at zrouter.org
Wed Jul 25 14:35:36 UTC 2012


details:   http://zrouter.org/hg/FreeBSD/head//rev/335efb6fcfdd
changeset: 485:335efb6fcfdd
user:      Aleksandr Rybalko <ray at ddteam.net>
date:      Wed Jul 25 16:17:38 2012 +0300
description:
Lazy update

diffstat:

 head/bin/cat/cat.c         |  39 +++++++++++++++++---------------
 head/bin/ed/Makefile       |   8 +++---
 head/bin/expr/expr.1       |   4 +-
 head/bin/expr/expr.y       |   3 +-
 head/bin/kenv/kenv.1       |  20 +++++++++++++---
 head/bin/kenv/kenv.c       |  30 ++++++++++++++++++------
 head/bin/ls/Makefile       |   7 ++++-
 head/bin/ps/keyword.c      |   3 +-
 head/bin/ps/print.c        |  12 +++++----
 head/bin/ps/ps.1           |   6 +++-
 head/bin/rcp/rcp.1         |   8 +-----
 head/bin/rcp/rcp.c         |   3 +-
 head/bin/rm/rm.c           |  25 +++++++++++++++-----
 head/bin/sh/Makefile       |   4 +-
 head/bin/sh/eval.c         |  55 ++++++++++++++++++++++++++++++++++++++++++---
 head/bin/sh/exec.c         |  15 +++++++++++-
 head/bin/sh/exec.h         |   3 +-
 head/bin/sh/input.c        |   4 +-
 head/bin/sh/jobs.c         |   5 +---
 head/bin/sh/jobs.h         |   3 +-
 head/bin/sh/miscbltin.c    |   3 +-
 head/bin/sh/mkbuiltins     |  18 +++++++-------
 head/bin/sh/sh.1           |  22 +++++++++++++++---
 head/bin/sh/trap.c         |   4 +-
 head/bin/stty/extern.h     |   4 +-
 head/bin/test/test.1       |   4 +-
 head/bin/uuidgen/uuidgen.1 |  11 +++++---
 27 files changed, 219 insertions(+), 104 deletions(-)

diffs (970 lines):

diff -r 5ccaa7502b8a -r 335efb6fcfdd head/bin/cat/cat.c
--- a/head/bin/cat/cat.c	Thu May 17 17:13:25 2012 +0300
+++ b/head/bin/cat/cat.c	Wed Jul 25 16:17:38 2012 +0300
@@ -44,7 +44,7 @@
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/bin/cat/cat.c 226961 2011-10-31 08:59:17Z ed $");
+__FBSDID("$FreeBSD: head/bin/cat/cat.c 238653 2012-07-20 08:33:23Z jh $");
 
 #include <sys/param.h>
 #include <sys/stat.h>
@@ -58,11 +58,11 @@
 #include <err.h>
 #include <fcntl.h>
 #include <locale.h>
+#include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <stddef.h>
 
 static int bflag, eflag, nflag, sflag, tflag, vflag;
 static int rval;
@@ -77,16 +77,20 @@
 static int udom_open(const char *path, int flags);
 #endif
 
-/* Memory strategy threshold, in pages: if physmem is larger then this, use a 
- * large buffer */
-#define PHYSPAGES_THRESHOLD (32*1024)
+/*
+ * Memory strategy threshold, in pages: if physmem is larger than this,
+ * use a large buffer.
+ */
+#define	PHYSPAGES_THRESHOLD (32 * 1024)
 
-/* Maximum buffer size in bytes - do not allow it to grow larger than this */
-#define BUFSIZE_MAX (2*1024*1024)
+/* Maximum buffer size in bytes - do not allow it to grow larger than this. */
+#define	BUFSIZE_MAX (2 * 1024 * 1024)
 
-/* Small (default) buffer size in bytes. It's inefficient for this to be
- * smaller than MAXPHYS */
-#define BUFSIZE_SMALL (MAXPHYS)
+/*
+ * Small (default) buffer size in bytes. It's inefficient for this to be
+ * smaller than MAXPHYS.
+ */
+#define	BUFSIZE_SMALL (MAXPHYS)
 
 int
 main(int argc, char *argv[])
@@ -144,13 +148,12 @@
 static void
 scanfiles(char *argv[], int cooked)
 {
-	int i = 0;
+	int fd, i;
 	char *path;
 	FILE *fp;
 
+	i = 0;
 	while ((path = argv[i]) != NULL || i == 0) {
-		int fd;
-
 		if (path == NULL || strcmp(path, "-") == 0) {
 			filename = "stdin";
 			fd = STDIN_FILENO;
@@ -257,16 +260,16 @@
 	wfd = fileno(stdout);
 	if (buf == NULL) {
 		if (fstat(wfd, &sbuf))
-			err(1, "%s", filename);
+			err(1, "stdout");
 		if (S_ISREG(sbuf.st_mode)) {
 			/* If there's plenty of RAM, use a large copy buffer */
 			if (sysconf(_SC_PHYS_PAGES) > PHYSPAGES_THRESHOLD)
-				bsize = MIN(BUFSIZE_MAX, MAXPHYS*8);
+				bsize = MIN(BUFSIZE_MAX, MAXPHYS * 8);
 			else
 				bsize = BUFSIZE_SMALL;
 		} else
-			bsize = MAX(sbuf.st_blksize, 
-					(blksize_t)sysconf(_SC_PAGESIZE));
+			bsize = MAX(sbuf.st_blksize,
+			    (blksize_t)sysconf(_SC_PAGESIZE));
 		if ((buf = malloc(bsize)) == NULL)
 			err(1, "malloc() failure of IO buffer");
 	}
@@ -327,7 +330,7 @@
 			break;
 		}
 	}
-	return(fd);
+	return (fd);
 }
 
 #endif
diff -r 5ccaa7502b8a -r 335efb6fcfdd head/bin/ed/Makefile
--- a/head/bin/ed/Makefile	Thu May 17 17:13:25 2012 +0300
+++ b/head/bin/ed/Makefile	Wed Jul 25 16:17:38 2012 +0300
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: head/bin/ed/Makefile 235654 2012-05-19 17:55:49Z marcel $
 
 .include <bsd.own.mk>
 
@@ -7,12 +7,12 @@
 LINKS=	${BINDIR}/ed ${BINDIR}/red
 MLINKS=	ed.1 red.1
 
-.if !defined(RELEASE_CRUNCH)
-.if ${MK_OPENSSL} != "no"
+.if !defined(RELEASE_CRUNCH) && \
+	${MK_OPENSSL} != "no" && \
+	${MK_ED_CRYPTO} != "no"
 CFLAGS+=-DDES
 DPADD=	${LIBCRYPTO}
 LDADD=	-lcrypto
 .endif
-.endif
 
 .include <bsd.prog.mk>
diff -r 5ccaa7502b8a -r 335efb6fcfdd head/bin/expr/expr.1
--- a/head/bin/expr/expr.1	Thu May 17 17:13:25 2012 +0300
+++ b/head/bin/expr/expr.1	Wed Jul 25 16:17:38 2012 +0300
@@ -28,7 +28,7 @@
 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.\" $FreeBSD: head/bin/expr/expr.1 232158 2012-02-25 15:21:43Z gjb $
+.\" $FreeBSD: head/bin/expr/expr.1 235400 2012-05-13 14:16:04Z joel $
 .\"
 .Dd February 25, 2012
 .Dt EXPR 1
@@ -77,7 +77,7 @@
 and
 .Ql } .
 .Bl -tag -width indent
-.It Ar expr1 Li | Ar expr2
+.It Ar expr1 Li \&| Ar expr2
 Return the evaluation of
 .Ar expr1
 if it is neither an empty string nor zero;
diff -r 5ccaa7502b8a -r 335efb6fcfdd head/bin/expr/expr.y
--- a/head/bin/expr/expr.y	Thu May 17 17:13:25 2012 +0300
+++ b/head/bin/expr/expr.y	Wed Jul 25 16:17:38 2012 +0300
@@ -5,7 +5,7 @@
  *
  * Largely rewritten by J.T. Conklin (jtc at wimsey.com)
  *
- * $FreeBSD: head/bin/expr/expr.y 233137 2012-03-19 00:45:01Z eadler $
+ * $FreeBSD: head/bin/expr/expr.y 235771 2012-05-22 03:01:54Z kevlo $
  */
 
 #include <sys/types.h>
@@ -74,7 +74,6 @@
 void		to_string(struct val *);
 int		yyerror(const char *);
 int		yylex(void);
-int		yyparse(void);
 
 %}
 
diff -r 5ccaa7502b8a -r 335efb6fcfdd head/bin/kenv/kenv.1
--- a/head/bin/kenv/kenv.1	Thu May 17 17:13:25 2012 +0300
+++ b/head/bin/kenv/kenv.1	Wed Jul 25 16:17:38 2012 +0300
@@ -22,9 +22,9 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $FreeBSD: head/bin/kenv/kenv.1 233457 2012-03-25 09:20:14Z joel $
+.\" $FreeBSD: head/bin/kenv/kenv.1 235316 2012-05-12 02:49:40Z mdf $
 .\"
-.Dd January 13, 2009
+.Dd May 11, 2012
 .Dt KENV 1
 .Os
 .Sh NAME
@@ -32,9 +32,9 @@
 .Nd dump or modify the kernel environment
 .Sh SYNOPSIS
 .Nm
-.Op Fl hq
+.Op Fl hNq
 .Nm
-.Op Fl q
+.Op Fl qv
 .Ar variable Ns Op = Ns Ar value
 .Nm
 .Op Fl q
@@ -54,6 +54,11 @@
 .Nm
 will only report that value.
 If the
+.Fl N
+option is specified,
+.Nm
+will only display variable names and not their values.
+If the
 .Fl u
 option is specified,
 .Nm
@@ -68,6 +73,13 @@
 option is set, warnings normally printed as a result of being unable to
 perform the requested operation will be suppressed.
 .Pp
+If the
+.Fl v
+option is set, the variable name will be printed out for the
+environment variable in addition to the value when
+.Nm
+is executed with a variable name.
+.Pp
 Variables can be added to the kernel environment using the
 .Pa /boot/loader.conf
 file, or also statically compiled into the kernel using the statement
diff -r 5ccaa7502b8a -r 335efb6fcfdd head/bin/kenv/kenv.c
--- a/head/bin/kenv/kenv.c	Thu May 17 17:13:25 2012 +0300
+++ b/head/bin/kenv/kenv.c	Wed Jul 25 16:17:38 2012 +0300
@@ -24,7 +24,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/bin/kenv/kenv.c 235297 2012-05-11 23:05:14Z mdf $");
 
 #include <sys/types.h>
 #include <sys/sysctl.h>
@@ -42,15 +42,17 @@
 static int	kunsetenv(char *);
 
 static int hflag = 0;
+static int Nflag = 0;
 static int qflag = 0;
 static int uflag = 0;
+static int vflag = 0;
 
 static void
 usage(void)
 {
 	(void)fprintf(stderr, "%s\n%s\n%s\n",
-	    "usage: kenv [-hq]",
-	    "       kenv [-q] variable[=value]",
+	    "usage: kenv [-hNq]",
+	    "       kenv [-qv] variable[=value]",
 	    "       kenv [-q] -u variable");
 	exit(1);
 }
@@ -64,17 +66,23 @@
 	error = 0;
 	val = NULL;
 	env = NULL;
-	while ((ch = getopt(argc, argv, "hqu")) != -1) {
+	while ((ch = getopt(argc, argv, "hNquv")) != -1) {
 		switch (ch) {
 		case 'h':
 			hflag++;
 			break;
+		case 'N':
+			Nflag++;
+			break;
 		case 'q':
 			qflag++;
 			break;
 		case 'u':
 			uflag++;
 			break;
+		case 'v':
+			vflag++;
+			break;
 		default:
 			usage();
 		}
@@ -91,9 +99,9 @@
 		argv++;
 		argc--;
 	}
-	if (hflag && (env != NULL))
+	if ((hflag || Nflag) && env != NULL)
 		usage();
-	if ((argc > 0) || (uflag && (env == NULL)))
+	if (argc > 0 || ((uflag || vflag) && env == NULL))
 		usage();
 	if (env == NULL) {
 		error = kdumpenv();
@@ -152,7 +160,10 @@
 		if (cp == NULL)
 			continue;
 		*cp++ = '\0';
-		printf("%s=\"%s\"\n", buf, cp);
+		if (Nflag)
+			printf("%s\n", buf);
+		else
+			printf("%s=\"%s\"\n", buf, cp);
 		buf = cp;
 	}
 	return (0);
@@ -167,7 +178,10 @@
 	ret = kenv(KENV_GET, env, buf, sizeof(buf));
 	if (ret == -1)
 		return (ret);
-	printf("%s\n", buf);
+	if (vflag)
+		printf("%s=\"%s\"\n", env, buf);
+	else
+		printf("%s\n", buf);
 	return (0);
 }
 
diff -r 5ccaa7502b8a -r 335efb6fcfdd head/bin/ls/Makefile
--- a/head/bin/ls/Makefile	Thu May 17 17:13:25 2012 +0300
+++ b/head/bin/ls/Makefile	Wed Jul 25 16:17:38 2012 +0300
@@ -1,12 +1,15 @@
 #	@(#)Makefile	8.1 (Berkeley) 6/2/93
-# $FreeBSD$
+# $FreeBSD: head/bin/ls/Makefile 235655 2012-05-19 18:05:00Z marcel $
+
+.include <bsd.own.mk>
 
 PROG=	ls
 SRCS=	cmp.c ls.c print.c util.c
 DPADD=	${LIBUTIL}
 LDADD=	-lutil
 
-.if !defined(RELEASE_CRUNCH)
+.if !defined(RELEASE_CRUNCH) && \
+	${MK_LS_COLORS} != no
 CFLAGS+= -DCOLORLS
 DPADD+=	${LIBTERMCAP}
 LDADD+=	-ltermcap
diff -r 5ccaa7502b8a -r 335efb6fcfdd head/bin/ps/keyword.c
--- a/head/bin/ps/keyword.c	Thu May 17 17:13:25 2012 +0300
+++ b/head/bin/ps/keyword.c	Wed Jul 25 16:17:38 2012 +0300
@@ -33,7 +33,7 @@
 #endif /* not lint */
 #endif
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/bin/ps/keyword.c 225868 2011-09-29 06:31:42Z trasz $");
+__FBSDID("$FreeBSD: head/bin/ps/keyword.c 235851 2012-05-23 18:11:36Z kib $");
 
 #include <sys/param.h>
 #include <sys/time.h>
@@ -76,6 +76,7 @@
 	{"comm", "COMMAND", NULL, LJUST, ucomm, 0, CHAR, NULL, 0},
 	{"command", "COMMAND", NULL, COMM|LJUST|USER, command, 0,
 		CHAR, NULL, 0},
+	{"cow", "COW", NULL, 0, kvar, KOFF(ki_cow), UINT, "u", 0},
 	{"cpu", "CPU", NULL, 0, kvar, KOFF(ki_estcpu), UINT, "d", 0},
 	{"cputime", "", "time", 0, NULL, 0, CHAR, NULL, 0},
 	{"egid", "", "gid", 0, NULL, 0, CHAR, NULL, 0},
diff -r 5ccaa7502b8a -r 335efb6fcfdd head/bin/ps/print.c
--- a/head/bin/ps/print.c	Thu May 17 17:13:25 2012 +0300
+++ b/head/bin/ps/print.c	Wed Jul 25 16:17:38 2012 +0300
@@ -34,7 +34,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/bin/ps/print.c 230287 2012-01-17 22:17:10Z ed $");
+__FBSDID("$FreeBSD: head/bin/ps/print.c 238488 2012-07-15 15:22:13Z jilles $");
 
 #include <sys/param.h>
 #include <sys/time.h>
@@ -387,12 +387,13 @@
 	size_t buflen = 100;
 	char *buf;
 
+	if (!k->ki_valid)
+		return (NULL);
+
 	buf = malloc(buflen);
 	if (buf == NULL)
 		errx(1, "malloc failed");
 
-	if (!k->ki_valid)
-		return (NULL);
 	if (use_ampm < 0)
 		use_ampm = (*nl_langinfo(T_FMT_AMPM) != '\0');
 	then = k->ki_p->ki_start.tv_sec;
@@ -415,12 +416,13 @@
 	char *buf;
 	size_t buflen = 100;
 
+	if (!k->ki_valid)
+		return (NULL);
+
 	buf = malloc(buflen);
 	if (buf == NULL)
 		errx(1, "malloc failed");
 
-	if (!k->ki_valid)
-		return (NULL);
 	then = k->ki_p->ki_start.tv_sec;
 	(void)strftime(buf, buflen, "%c", localtime(&then));
 	return (buf);
diff -r 5ccaa7502b8a -r 335efb6fcfdd head/bin/ps/ps.1
--- a/head/bin/ps/ps.1	Thu May 17 17:13:25 2012 +0300
+++ b/head/bin/ps/ps.1	Wed Jul 25 16:17:38 2012 +0300
@@ -27,9 +27,9 @@
 .\" SUCH DAMAGE.
 .\"
 .\"     @(#)ps.1	8.3 (Berkeley) 4/18/94
-.\" $FreeBSD: head/bin/ps/ps.1 233665 2012-03-29 16:02:40Z joel $
+.\" $FreeBSD: head/bin/ps/ps.1 235851 2012-05-23 18:11:36Z kib $
 .\"
-.Dd March 8, 2012
+.Dd May 20, 2012
 .Dt PS 1
 .Os
 .Sh NAME
@@ -496,6 +496,8 @@
 command
 .It Cm command
 command and arguments
+.It Cm cow
+number of copy-on-write faults
 .It Cm cpu
 short-term CPU usage factor (for scheduling)
 .It Cm emul
diff -r 5ccaa7502b8a -r 335efb6fcfdd head/bin/rcp/rcp.1
--- a/head/bin/rcp/rcp.1	Thu May 17 17:13:25 2012 +0300
+++ b/head/bin/rcp/rcp.1	Wed Jul 25 16:17:38 2012 +0300
@@ -27,7 +27,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"	@(#)rcp.1	8.1 (Berkeley) 5/31/93
-.\" $FreeBSD$
+.\" $FreeBSD: head/bin/rcp/rcp.1 236892 2012-06-11 16:18:39Z des $
 .\"
 .Dd October 16, 2002
 .Dt RCP 1
@@ -116,17 +116,11 @@
 .Nm
 utility handles third party copies, where neither source nor target files
 are on the current machine.
-.Sh FILES
-.Bl -tag -width ".Pa /etc/auth.conf" -compact
-.It Pa /etc/auth.conf
-configure authentication services
-.El
 .Sh SEE ALSO
 .Xr cp 1 ,
 .Xr ftp 1 ,
 .Xr rlogin 1 ,
 .Xr rsh 1 ,
-.Xr auth.conf 5 ,
 .Xr hosts.equiv 5
 .Sh HISTORY
 The
diff -r 5ccaa7502b8a -r 335efb6fcfdd head/bin/rcp/rcp.c
--- a/head/bin/rcp/rcp.c	Thu May 17 17:13:25 2012 +0300
+++ b/head/bin/rcp/rcp.c	Wed Jul 25 16:17:38 2012 +0300
@@ -46,7 +46,7 @@
 #endif /* not lint */
 #endif
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/bin/rcp/rcp.c 223494 2011-06-24 07:29:04Z kevlo $");
+__FBSDID("$FreeBSD: head/bin/rcp/rcp.c 235565 2012-05-17 20:29:15Z marcel $");
 
 #include <sys/param.h>
 #include <sys/stat.h>
@@ -61,7 +61,6 @@
 #include <err.h>
 #include <errno.h>
 #include <fcntl.h>
-#include <libutil.h>
 #include <limits.h>
 #include <netdb.h>
 #include <paths.h>
diff -r 5ccaa7502b8a -r 335efb6fcfdd head/bin/rm/rm.c
--- a/head/bin/rm/rm.c	Thu May 17 17:13:25 2012 +0300
+++ b/head/bin/rm/rm.c	Wed Jul 25 16:17:38 2012 +0300
@@ -39,7 +39,7 @@
 #endif /* not lint */
 #endif
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/bin/rm/rm.c 226961 2011-10-31 08:59:17Z ed $");
+__FBSDID("$FreeBSD: head/bin/rm/rm.c 237339 2012-06-20 21:10:38Z delphij $");
 
 #include <sys/stat.h>
 #include <sys/param.h>
@@ -301,10 +301,16 @@
 				if (fflag)
 					continue;
 				/* FALLTHROUGH */
+
+			case FTS_F:
+			case FTS_NSOK:
+				if (Pflag)
+					if (!rm_overwrite(p->fts_accpath, p->fts_info ==
+					    FTS_NSOK ? NULL : p->fts_statp))
+						continue;
+				/* FALLTHROUGH */
+
 			default:
-				if (Pflag)
-					if (!rm_overwrite(p->fts_accpath, NULL))
-						continue;
 				rval = unlink(p->fts_accpath);
 				if (rval == 0 || (fflag && errno == ENOENT)) {
 					if (rval == 0 && vflag)
@@ -408,7 +414,7 @@
 int
 rm_overwrite(char *file, struct stat *sbp)
 {
-	struct stat sb;
+	struct stat sb, sb2;
 	struct statfs fsb;
 	off_t len;
 	int bsize, fd, wlen;
@@ -427,8 +433,15 @@
 		    file, sbp->st_ino);
 		return (0);
 	}
-	if ((fd = open(file, O_WRONLY, 0)) == -1)
+	if ((fd = open(file, O_WRONLY|O_NONBLOCK|O_NOFOLLOW, 0)) == -1)
 		goto err;
+	if (fstat(fd, &sb2))
+		goto err;
+	if (sb2.st_dev != sbp->st_dev || sb2.st_ino != sbp->st_ino ||
+	    !S_ISREG(sb2.st_mode)) {
+		errno = EPERM;
+		goto err;
+	}
 	if (fstatfs(fd, &fsb) == -1)
 		goto err;
 	bsize = MAX(fsb.f_iosize, 1024);
diff -r 5ccaa7502b8a -r 335efb6fcfdd head/bin/sh/Makefile
--- a/head/bin/sh/Makefile	Thu May 17 17:13:25 2012 +0300
+++ b/head/bin/sh/Makefile	Wed Jul 25 16:17:38 2012 +0300
@@ -1,5 +1,5 @@
 #	@(#)Makefile	8.4 (Berkeley) 5/5/95
-# $FreeBSD$
+# $FreeBSD: head/bin/sh/Makefile 235927 2012-05-24 19:48:15Z marcel $
 
 PROG=	sh
 INSTALLFLAGS= -S
@@ -38,7 +38,7 @@
 
 .ORDER: builtins.c builtins.h
 builtins.c builtins.h: mkbuiltins builtins.def
-	cd ${.CURDIR}; sh mkbuiltins ${.OBJDIR}
+	sh ${.CURDIR}/mkbuiltins ${.CURDIR}
 
 init.c: mkinit alias.c eval.c exec.c input.c jobs.c options.c parser.c \
 	redir.c trap.c var.c
diff -r 5ccaa7502b8a -r 335efb6fcfdd head/bin/sh/eval.c
--- a/head/bin/sh/eval.c	Thu May 17 17:13:25 2012 +0300
+++ b/head/bin/sh/eval.c	Wed Jul 25 16:17:38 2012 +0300
@@ -36,7 +36,7 @@
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/bin/sh/eval.c 230998 2012-02-04 23:12:14Z jilles $");
+__FBSDID("$FreeBSD: head/bin/sh/eval.c 238468 2012-07-15 10:19:43Z jilles $");
 
 #include <paths.h>
 #include <signal.h>
@@ -672,6 +672,52 @@
 		result->fd, result->buf, result->nleft, result->jp));
 }
 
+static int
+mustexpandto(const char *argtext, const char *mask)
+{
+	for (;;) {
+		if (*argtext == CTLQUOTEMARK || *argtext == CTLQUOTEEND) {
+			argtext++;
+			continue;
+		}
+		if (*argtext == CTLESC)
+			argtext++;
+		else if (BASESYNTAX[(int)*argtext] == CCTL)
+			return (0);
+		if (*argtext != *mask)
+			return (0);
+		if (*argtext == '\0')
+			return (1);
+		argtext++;
+		mask++;
+	}
+}
+
+static int
+isdeclarationcmd(struct narg *arg)
+{
+	int have_command = 0;
+
+	if (arg == NULL)
+		return (0);
+	while (mustexpandto(arg->text, "command")) {
+		have_command = 1;
+		arg = &arg->next->narg;
+		if (arg == NULL)
+			return (0);
+		/*
+		 * To also allow "command -p" and "command --" as part of
+		 * a declaration command, add code here.
+		 * We do not do this, as ksh does not do it either and it
+		 * is not required by POSIX.
+		 */
+	}
+	return (mustexpandto(arg->text, "export") ||
+	    mustexpandto(arg->text, "readonly") ||
+	    (mustexpandto(arg->text, "local") &&
+		(have_command || !isfunc("local"))));
+}
+
 /*
  * Check if a builtin can safely be executed in the same process,
  * even though it should be in a subshell (command substitution).
@@ -743,11 +789,12 @@
 	exitstatus = 0;
 	for (argp = cmd->ncmd.args ; argp ; argp = argp->narg.next) {
 		if (varflag && isassignment(argp->narg.text)) {
-			expandarg(argp, &varlist, EXP_VARTILDE);
+			expandarg(argp, varflag == 1 ? &varlist : &arglist,
+			    EXP_VARTILDE);
 			continue;
-		}
+		} else if (varflag == 1)
+			varflag = isdeclarationcmd(&argp->narg) ? 2 : 0;
 		expandarg(argp, &arglist, EXP_FULL | EXP_TILDE);
-		varflag = 0;
 	}
 	*arglist.lastp = NULL;
 	*varlist.lastp = NULL;
diff -r 5ccaa7502b8a -r 335efb6fcfdd head/bin/sh/exec.c
--- a/head/bin/sh/exec.c	Thu May 17 17:13:25 2012 +0300
+++ b/head/bin/sh/exec.c	Wed Jul 25 16:17:38 2012 +0300
@@ -36,7 +36,7 @@
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/bin/sh/exec.c 231535 2012-02-11 21:06:45Z jilles $");
+__FBSDID("$FreeBSD: head/bin/sh/exec.c 238468 2012-07-15 10:19:43Z jilles $");
 
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -648,6 +648,19 @@
 	return (0);
 }
 
+
+/*
+ * Check if a function by a certain name exists.
+ */
+int
+isfunc(const char *name)
+{
+	struct tblentry *cmdp;
+	cmdp = cmdlookup(name, 0);
+	return (cmdp != NULL && cmdp->cmdtype == CMDFUNCTION);
+}
+
+
 /*
  * Shared code for the following builtin commands:
  *    type, command -v, command -V
diff -r 5ccaa7502b8a -r 335efb6fcfdd head/bin/sh/exec.h
--- a/head/bin/sh/exec.h	Thu May 17 17:13:25 2012 +0300
+++ b/head/bin/sh/exec.h	Wed Jul 25 16:17:38 2012 +0300
@@ -30,7 +30,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)exec.h	8.3 (Berkeley) 6/8/95
- * $FreeBSD: head/bin/sh/exec.h 229220 2012-01-01 22:17:12Z jilles $
+ * $FreeBSD: head/bin/sh/exec.h 238468 2012-07-15 10:19:43Z jilles $
  */
 
 /* values of cmdtype */
@@ -72,5 +72,6 @@
 void changepath(const char *);
 void defun(const char *, union node *);
 int unsetfunc(const char *);
+int isfunc(const char *);
 int typecmd_impl(int, char **, int, const char *);
 void clearcmdentry(void);
diff -r 5ccaa7502b8a -r 335efb6fcfdd head/bin/sh/input.c
--- a/head/bin/sh/input.c	Thu May 17 17:13:25 2012 +0300
+++ b/head/bin/sh/input.c	Wed Jul 25 16:17:38 2012 +0300
@@ -36,7 +36,7 @@
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/bin/sh/input.c 230118 2012-01-14 22:46:18Z jilles $");
+__FBSDID("$FreeBSD: head/bin/sh/input.c 238377 2012-07-11 22:17:58Z pfg $");
 
 #include <stdio.h>	/* defines BUFSIZ */
 #include <fcntl.h>
@@ -186,7 +186,7 @@
 		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)
diff -r 5ccaa7502b8a -r 335efb6fcfdd head/bin/sh/jobs.c
--- a/head/bin/sh/jobs.c	Thu May 17 17:13:25 2012 +0300
+++ b/head/bin/sh/jobs.c	Wed Jul 25 16:17:38 2012 +0300
@@ -36,7 +36,7 @@
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/bin/sh/jobs.c 233792 2012-04-02 17:16:24Z jilles $");
+__FBSDID("$FreeBSD: head/bin/sh/jobs.c 238470 2012-07-15 10:49:16Z jilles $");
 
 #include <sys/ioctl.h>
 #include <sys/param.h>
@@ -84,7 +84,6 @@
 static pid_t initialpgrp;	/* pgrp of shell on invocation */
 #endif
 int in_waitcmd = 0;		/* are we in waitcmd()? */
-int in_dowait = 0;		/* are we in dowait()? */
 volatile sig_atomic_t breakwaitcmd = 0;	/* should wait be terminated? */
 static int ttyfd = -1;
 
@@ -1023,14 +1022,12 @@
 	int sig;
 	int coredump;
 
-	in_dowait++;
 	TRACE(("dowait(%d) called\n", block));
 	do {
 		pid = waitproc(block, &status);
 		TRACE(("wait returns %d, status=%d\n", (int)pid, status));
 	} while ((pid == -1 && errno == EINTR && breakwaitcmd == 0) ||
 		 (pid > 0 && WIFSTOPPED(status) && !iflag));
-	in_dowait--;
 	if (pid == -1 && errno == ECHILD && job != NULL)
 		job->state = JOBDONE;
 	if (breakwaitcmd != 0) {
diff -r 5ccaa7502b8a -r 335efb6fcfdd head/bin/sh/jobs.h
--- a/head/bin/sh/jobs.h	Thu May 17 17:13:25 2012 +0300
+++ b/head/bin/sh/jobs.h	Wed Jul 25 16:17:38 2012 +0300
@@ -30,7 +30,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)jobs.h	8.2 (Berkeley) 5/4/95
- * $FreeBSD: head/bin/sh/jobs.h 230998 2012-02-04 23:12:14Z jilles $
+ * $FreeBSD: head/bin/sh/jobs.h 238470 2012-07-15 10:49:16Z jilles $
  */
 
 /* Mode argument to forkshell.  Don't change FORK_FG or FORK_BG. */
@@ -84,7 +84,6 @@
 
 extern int job_warning;		/* user was warned about stopped jobs */
 extern int in_waitcmd;		/* are we in waitcmd()? */
-extern int in_dowait;		/* are we in dowait()? */
 extern volatile sig_atomic_t breakwaitcmd; /* break wait to process traps? */
 
 void setjobctl(int);
diff -r 5ccaa7502b8a -r 335efb6fcfdd head/bin/sh/miscbltin.c
--- a/head/bin/sh/miscbltin.c	Thu May 17 17:13:25 2012 +0300
+++ b/head/bin/sh/miscbltin.c	Wed Jul 25 16:17:38 2012 +0300
@@ -36,7 +36,7 @@
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/bin/sh/miscbltin.c 221975 2011-05-15 22:09:27Z jilles $");
+__FBSDID("$FreeBSD: head/bin/sh/miscbltin.c 235488 2012-05-15 22:50:47Z jilles $");
 
 /*
  * Miscellaneous builtins.
@@ -52,7 +52,6 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <termios.h>
 
 #include "shell.h"
 #include "options.h"
diff -r 5ccaa7502b8a -r 335efb6fcfdd head/bin/sh/mkbuiltins
--- a/head/bin/sh/mkbuiltins	Thu May 17 17:13:25 2012 +0300
+++ b/head/bin/sh/mkbuiltins	Wed Jul 25 16:17:38 2012 +0300
@@ -32,20 +32,20 @@
 # SUCH DAMAGE.
 #
 #	@(#)mkbuiltins	8.2 (Berkeley) 5/4/95
-# $FreeBSD: head/bin/sh/mkbuiltins 223060 2011-06-13 21:03:27Z jilles $
+# $FreeBSD: head/bin/sh/mkbuiltins 235927 2012-05-24 19:48:15Z marcel $
 
 temp=`/usr/bin/mktemp -t ka`
-havejobs=0
-if grep '^#define[	 ]*JOBS[	 ]*1' shell.h > /dev/null
-then	havejobs=1
-fi
 havehist=1
 if [ "X$1" = "X-h" ]; then
 	havehist=0
 	shift
 fi
-objdir=$1
-exec > ${objdir}/builtins.c
+srcdir=$1
+havejobs=0
+if grep '^#define[	 ]*JOBS[	 ]*1' $srcdir/shell.h > /dev/null
+then	havejobs=1
+fi
+exec > builtins.c
 cat <<\!
 /*
  * This file was generated by the mkbuiltins program.
@@ -57,7 +57,7 @@
 
 !
 awk '/^[^#]/ {if(('$havejobs' || $2 != "-j") && ('$havehist' || $2 != "-h")) \
-    print $0}' builtins.def | sed 's/-[hj]//' > $temp
+    print $0}' $srcdir/builtins.def | sed 's/-[hj]//' > $temp
 echo 'int (*const builtinfunc[])(int, char **) = {'
 awk '/^[^#]/ {	printf "\t%s,\n", $1}' $temp
 echo '};
@@ -74,7 +74,7 @@
 echo '	{ NULL, 0, 0 }
 };'
 
-exec > ${objdir}/builtins.h
+exec > builtins.h
 cat <<\!
 /*
  * This file was generated by the mkbuiltins program.
diff -r 5ccaa7502b8a -r 335efb6fcfdd head/bin/sh/sh.1
--- a/head/bin/sh/sh.1	Thu May 17 17:13:25 2012 +0300
+++ b/head/bin/sh/sh.1	Wed Jul 25 16:17:38 2012 +0300
@@ -30,9 +30,9 @@
 .\" SUCH DAMAGE.
 .\"
 .\"	from: @(#)sh.1	8.6 (Berkeley) 5/4/95
-.\" $FreeBSD: head/bin/sh/sh.1 233992 2012-04-07 09:05:30Z joel $
+.\" $FreeBSD: head/bin/sh/sh.1 238468 2012-07-15 10:19:43Z jilles $
 .\"
-.Dd November 5, 2011
+.Dd July 15, 2012
 .Dt SH 1
 .Os
 .Sh NAME
@@ -375,8 +375,8 @@
 .Bl -tag -width indent
 .It Control operators:
 .Bl -column "XXX" "XXX" "XXX" "XXX" "XXX" -offset center -compact
-.It Li & Ta Li && Ta Li ( Ta Li ) Ta Li \en
-.It Li ;; Ta Li ;& Ta Li ; Ta Li | Ta Li ||
+.It Li & Ta Li && Ta Li \&( Ta Li \&) Ta Li \en
+.It Li ;; Ta Li ;& Ta Li \&; Ta Li \&| Ta Li ||
 .El
 .It Redirection operators:
 .Bl -column "XXX" "XXX" "XXX" "XXX" "XXX" -offset center -compact
@@ -1164,6 +1164,20 @@
 tilde expansion is also performed after the equals sign and after any colon
 and usernames are also terminated by colons,
 and field splitting and pathname expansion are not performed.
+.Pp
+This special expansion applies not only to assignments that form a simple
+command by themselves or precede a command word,
+but also to words passed to the
+.Ic export ,
+.Ic local
+or
+.Ic readonly
+built-in commands that have this form.
+For this, the builtin's name must be literal
+(not the result of an expansion)
+and may optionally be preceded by one or more literal instances of
+.Ic command
+without options.
 .Ss Positional Parameters
 A positional parameter is a parameter denoted by a number greater than zero.
 The shell sets these initially to the values of its command line
diff -r 5ccaa7502b8a -r 335efb6fcfdd head/bin/sh/trap.c
--- a/head/bin/sh/trap.c	Thu May 17 17:13:25 2012 +0300
+++ b/head/bin/sh/trap.c	Wed Jul 25 16:17:38 2012 +0300
@@ -36,7 +36,7 @@
 #endif
 #endif /* not lint */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/bin/sh/trap.c 230212 2012-01-16 11:07:46Z dumbbell $");
+__FBSDID("$FreeBSD: head/bin/sh/trap.c 238477 2012-07-15 11:18:52Z jilles $");
 
 #include <signal.h>
 #include <unistd.h>
@@ -416,6 +416,7 @@
 
 	in_dotrap++;
 	for (;;) {
+		pendingsigs = 0;
 		for (i = 1; i < NSIG; i++) {
 			if (gotsig[i]) {
 				gotsig[i] = 0;
@@ -467,7 +468,6 @@
 			break;
 	}
 	in_dotrap--;
-	pendingsigs = 0;
 }
 
 
diff -r 5ccaa7502b8a -r 335efb6fcfdd head/bin/stty/extern.h
--- a/head/bin/stty/extern.h	Thu May 17 17:13:25 2012 +0300
+++ b/head/bin/stty/extern.h	Wed Jul 25 16:17:38 2012 +0300
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)extern.h	8.1 (Berkeley) 5/31/93
- * $FreeBSD$
+ * $FreeBSD: head/bin/stty/extern.h 238508 2012-07-15 21:12:22Z jilles $
  */
 
 int	c_cchars(const void *, const void *);
@@ -40,6 +40,6 @@
 int	msearch(char ***, struct info *);
 void	optlist(void);
 void	print(struct termios *, struct winsize *, int, enum FMT);
-void	usage(void);
+void	usage(void) __dead2;
 
 extern struct cchar cchars1[], cchars2[];
diff -r 5ccaa7502b8a -r 335efb6fcfdd head/bin/test/test.1
--- a/head/bin/test/test.1	Thu May 17 17:13:25 2012 +0300
+++ b/head/bin/test/test.1	Wed Jul 25 16:17:38 2012 +0300
@@ -30,7 +30,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"     @(#)test.1	8.1 (Berkeley) 5/31/93
-.\" $FreeBSD$
+.\" $FreeBSD: head/bin/test/test.1 235400 2012-05-13 14:16:04Z joel $
 .\"
 .Dd September 10, 2010
 .Dt TEST 1
@@ -43,7 +43,7 @@
 .Nm
 .Ar expression
 .Nm \&[
-.Ar expression Cm ]
+.Ar expression Cm \&]
 .Sh DESCRIPTION
 The
 .Nm
diff -r 5ccaa7502b8a -r 335efb6fcfdd head/bin/uuidgen/uuidgen.1
--- a/head/bin/uuidgen/uuidgen.1	Thu May 17 17:13:25 2012 +0300
+++ b/head/bin/uuidgen/uuidgen.1	Wed Jul 25 16:17:38 2012 +0300
@@ -22,9 +22,9 @@
 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.\" $FreeBSD$
+.\" $FreeBSD: head/bin/uuidgen/uuidgen.1 235842 2012-05-23 16:19:19Z wblock $
 .\"
-.Dd September 7, 2005
+.Dd May 23, 2012
 .Dt UUIDGEN 1
 .Os
 .Sh NAME
@@ -52,8 +52,11 @@
 to not generate them in batch, but one at a time.
 .It Fl n
 This option controls the number of identifiers generated.
-By default, multiple
-identifiers are generated in batch.
+By default, multiple identifiers are generated in batch.
+The upper hard limit is 2048
+.Po see
+.Xr uuidgen 2
+.Pc .
 .It Fl o
 Redirect output to
 .Ar filename


More information about the Zrouter-src-freebsd mailing list