diff -ur bin/sh/Makefile /home/s/reference/FreeBSD/src/bin/sh/Makefile
--- bin/sh/Makefile	2020-09-26 23:21:16.140751000 +0200
+++ /home/s/reference/FreeBSD/src/bin/sh/Makefile	2020-08-21 18:11:22.663124000 +0200
@@ -1,80 +1,74 @@
-# Makefile for /bin/sh
-#
+#	@(#)Makefile	8.4 (Berkeley) 5/5/95
+# $FreeBSD: head/bin/sh/Makefile 359511 2020-04-01 15:12:51Z trasz $
 
+.include <src.opts.mk>
+
+CONFGROUPS=	ETC ROOT
+ETC=	profile
+ROOT=	dot.shrc dot.profile
+ROOTDIR=	/root
+ROOTNAME_dot.shrc=	.shrc
+ROOTNAME_dot.profile=	.profile
+PACKAGE=runtime
 PROG=	sh
 INSTALLFLAGS= -S
 SHSRCS=	alias.c arith_yacc.c arith_yylex.c cd.c echo.c error.c eval.c \
 	exec.c expand.c \
 	histedit.c input.c jobs.c kill.c mail.c main.c memalloc.c miscbltin.c \
-	mystring.c options.c output.c parser.c printf.c redir.c \
+	mystring.c options.c output.c parser.c printf.c redir.c show.c \
 	test.c trap.c var.c
 GENSRCS= builtins.c nodes.c syntax.c
 GENHDRS= builtins.h nodes.h syntax.h token.h
 SRCS= ${SHSRCS} ${GENSRCS} ${GENHDRS}
 
-# would be needed if WARNS upgraded to 3, but lets keep the stderr output
-# clean, so WARNS has been lowered to 2.
-#
-WARNS?= 2
-
 # MLINKS for Shell built in commands for which there are no userland
 # utilities of the same name are handled with the associated manpage,
 # builtin.1 in share/man/man1/.
 
+LIBADD=	edit
+
 CFLAGS+=-DSHELL -I. -I${.CURDIR}
 # for debug:
 # DEBUG_FLAGS+= -g -DDEBUG=2 -fno-inline
-# SHSRCS+=show.c
-
-.if defined(BOOTSTRAPPING)
-CFLAGS+= -DNO_HISTORY
-# LIBEDIT is not needed here
-.else
-CFLAGS+= ${PRIVATELIB_CFLAGS}
-DPADD= ${LIBEDIT} ${LIBNCURSES}
-LDADD= ${LIBEDIT} ${LIBNCURSES}
-.endif
-
 
 .PATH:	${.CURDIR}/bltin \
-	${.CURDIR}/../kill \
-	${.CURDIR}/../test \
-	${.CURDIR}/../../usr.bin/printf
-
-#
-# NOTE: the headers and sources in pregenerated/ must be updated upon any
-# changes to the nodetypes nodes.c.pat mkbuiltins mknodes.c mksyntax.c mktokens
-# files using following scripts and build programs.
-#
-.if 1 # not updating sh(1)
-.PATH: ${.CURDIR}/pregenerated
-CFLAGS+= -I${.CURDIR}/pregenerated
-.else
+	${.CURDIR:H}/kill \
+	${.CURDIR:H}/test \
+	${SRCTOP}/usr.bin/printf
+
+CLEANFILES+= mknodes mksyntax
 CLEANFILES+= ${GENSRCS} ${GENHDRS}
 
+build-tools: mknodes mksyntax
+
 .ORDER: builtins.c builtins.h
+builtins.h: .NOMETA
 builtins.c builtins.h: mkbuiltins builtins.def
 	sh ${.CURDIR}/mkbuiltins ${.CURDIR}
 
-# XXX this is just to stop the default .c rule being used, so that the
-# intermediate object has a fixed name.
-# XXX we have a default .c rule, but no default .o rule.
-.o:
-	${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
+DEPENDOBJS+= mknodes mksyntax
+mknodes mksyntax: ${BUILD_TOOLS_META}
 
 .ORDER: nodes.c nodes.h
-nodes.c nodes.h: nodetypes nodes.c.pat
-	${.OBJDIR}/mknodes/mknodes.nx ${.ALLSRC}
+nodes.h: .NOMETA
+nodes.c nodes.h: mknodes nodetypes nodes.c.pat
+	${BTOOLSPATH:U.}/mknodes ${.CURDIR}/nodetypes ${.CURDIR}/nodes.c.pat
 
 .ORDER: syntax.c syntax.h
-syntax.c syntax.h:
-	${.OBJDIR}/mksyntax/mksyntax.nx
+syntax.h: .NOMETA
+syntax.c syntax.h: mksyntax
+	${BTOOLSPATH:U.}/mksyntax
 
 token.h: mktokens
 	sh ${.CURDIR}/mktokens
-.endif
 
-regress: sh
-	cd ${.CURDIR}/../../tools/regression/bin/sh && ${MAKE} SH=${.OBJDIR}/sh
+HAS_TESTS=
+SUBDIR.${MK_TESTS}+= tests
+
+beforeinstallconfig:
+	rm -f ${DESTDIR}/.profile
+
+afterinstallconfig:
+	${INSTALL_LINK} ${TAG_ARGS} ${DESTDIR}/root/.profile ${DESTDIR}/.profile
 
 .include <bsd.prog.mk>
Only in /home/s/reference/FreeBSD/src/bin/sh: Makefile.depend
diff -ur bin/sh/builtins.def /home/s/reference/FreeBSD/src/bin/sh/builtins.def
--- bin/sh/builtins.def	2020-09-26 20:51:59.499607000 +0200
+++ /home/s/reference/FreeBSD/src/bin/sh/builtins.def	2020-08-21 18:11:22.643126000 +0200
@@ -66,7 +66,7 @@
 #exprcmd		expr
 falsecmd -n	false
 fgcmd -j	fg
-#freebsd_wordexpcmd	freebsd_wordexp
+freebsd_wordexpcmd	freebsd_wordexp
 getoptscmd	getopts
 hashcmd		hash
 histcmd		fc
Only in /home/s/reference/FreeBSD/src/bin/sh: dot.profile
Only in /home/s/reference/FreeBSD/src/bin/sh: dot.shrc
diff -ur bin/sh/expand.c /home/s/reference/FreeBSD/src/bin/sh/expand.c
--- bin/sh/expand.c	2020-09-26 20:54:10.739984000 +0200
+++ /home/s/reference/FreeBSD/src/bin/sh/expand.c	2020-08-21 18:11:22.033147000 +0200
@@ -1171,11 +1171,7 @@
 		if (dp->d_name[0] == '.' && ! matchdot)
 			continue;
 		if (patmatch(start, dp->d_name)) {
-#ifdef _DIRENT_HAVE_D_NAMLEN
 			namlen = dp->d_namlen;
-#else
-			namlen = strlen(dp->d_name);
-#endif
 			if (enddir + namlen + 1 > expdir_end)
 				continue;
 			memcpy(enddir, dp->d_name, namlen + 1);
@@ -1503,7 +1499,6 @@
         return (0);
 }
 
-#if 0
 /*
  * Do most of the work for wordexp(3), new version.
  */
@@ -1556,4 +1551,3 @@
 		outbin(arglist.args[i], strlen(arglist.args[i]) + 1, out1);
 	return (0);
 }
-#endif
diff -ur bin/sh/funcs/suspend /home/s/reference/FreeBSD/src/bin/sh/funcs/suspend
--- bin/sh/funcs/suspend	2020-09-26 20:56:22.520404000 +0200
+++ /home/s/reference/FreeBSD/src/bin/sh/funcs/suspend	2020-08-21 18:11:22.633124000 +0200
@@ -1,5 +1,3 @@
-#!/bin/sh
-
 #-
 # Copyright (c) 1991, 1993
 #	The Regents of the University of California.  All rights reserved.
diff -ur bin/sh/input.c /home/s/reference/FreeBSD/src/bin/sh/input.c
--- bin/sh/input.c	2020-09-26 21:29:35.676169000 +0200
+++ /home/s/reference/FreeBSD/src/bin/sh/input.c	2020-08-21 18:11:22.643126000 +0200
@@ -59,9 +59,7 @@
 #include "error.h"
 #include "alias.h"
 #include "parser.h"
-#ifndef NO_HISTORY
 #include "myhistedit.h"
-#endif
 #include "trap.h"
 
 #define EOF_NLEFT -99		/* value of parsenleft when EOF pushed back */
@@ -364,13 +362,13 @@
 	int fd2;
 
 	INTOFF;
-	if ((fd = open(fname, O_RDONLY | O_CLOEXEC_MAYBE)) < 0) {
+	if ((fd = open(fname, O_RDONLY | O_CLOEXEC)) < 0) {
 		e = errno;
 		errorwithstatus(e == ENOENT || e == ENOTDIR ? 127 : 126,
 		    "cannot open %s: %s", fname, strerror(e));
 	}
 	if (fd < 10) {
-		fd2 = fcntl(fd, F_DUPFD_CLOEXEC_MAYBE, 10);
+		fd2 = fcntl(fd, F_DUPFD_CLOEXEC, 10);
 		close(fd);
 		if (fd2 < 0)
 			error("Out of file descriptors");
@@ -389,9 +387,6 @@
 void
 setinputfd(int fd, int push)
 {
-#if !defined(O_CLOEXEC) || !defined(F_DUPFD_CLOEXEC)
-	fcntl(fd, F_SETFD, FD_CLOEXEC);
-#endif
 	if (push) {
 		pushfile();
 		parsefile->buf = ckmalloc(BUFSIZ + 1);
diff -ur bin/sh/jobs.c /home/s/reference/FreeBSD/src/bin/sh/jobs.c
--- bin/sh/jobs.c	2020-09-26 20:59:26.090960000 +0200
+++ /home/s/reference/FreeBSD/src/bin/sh/jobs.c	2020-08-21 18:11:22.633124000 +0200
@@ -185,12 +185,12 @@
 	if (on) {
 		if (ttyfd != -1)
 			close(ttyfd);
-		if ((ttyfd = open(_PATH_TTY, O_RDWR | O_CLOEXEC_MAYBE)) < 0) {
+		if ((ttyfd = open(_PATH_TTY, O_RDWR | O_CLOEXEC)) < 0) {
 			i = 0;
 			while (i <= 2 && !isatty(i))
 				i++;
 			if (i > 2 ||
-			    (ttyfd = fcntl(i, F_DUPFD_CLOEXEC_MAYBE, 10)) < 0) {
+			    (ttyfd = fcntl(i, F_DUPFD_CLOEXEC, 10)) < 0) {
 				jobctl_notty();
 				return;
 			}
@@ -200,26 +200,16 @@
 			 * Keep our TTY file descriptor out of the way of
 			 * the user's redirections.
 			 */
-			if ((i = fcntl(ttyfd, F_DUPFD_CLOEXEC_MAYBE, 10)) < 0) {
+			if ((i = fcntl(ttyfd, F_DUPFD_CLOEXEC, 10)) < 0) {
 				jobctl_notty();
 				return;
 			}
 			close(ttyfd);
 			ttyfd = i;
 		}
-#if !defined(O_CLOEXEC) || !defined(F_DUPFD_CLOEXEC)
-		if (fcntl(ttyfd, F_SETFD, FD_CLOEXEC) < 0) {
-			close(ttyfd);
-			ttyfd = -1;
-			goto out;
-		}
-#endif
 		do { /* while we are in the background */
 			initialpgrp = tcgetpgrp(ttyfd);
 			if (initialpgrp < 0) {
-#if !defined(O_CLOEXEC) || !defined(F_DUPFD_CLOEXEC)
-out:
-#endif
 				jobctl_notty();
 				return;
 			}
diff -ur bin/sh/main.c /home/s/reference/FreeBSD/src/bin/sh/main.c
--- bin/sh/main.c	2020-09-26 21:01:14.201238000 +0200
+++ /home/s/reference/FreeBSD/src/bin/sh/main.c	2020-09-10 05:46:20.654167000 +0200
@@ -33,6 +33,12 @@
  */
 
 #ifndef lint
+static char const copyright[] =
+"@(#) Copyright (c) 1991, 1993\n\
+	The Regents of the University of California.  All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
 #if 0
 static char sccsid[] = "@(#)main.c	8.6 (Berkeley) 5/28/95";
 #endif
@@ -245,7 +251,7 @@
 	if (expandedname == NULL)
 		return;
 	INTOFF;
-	if ((fd = open(expandedname, O_RDONLY | O_CLOEXEC_MAYBE)) >= 0)
+	if ((fd = open(expandedname, O_RDONLY | O_CLOEXEC)) >= 0)
 		setinputfd(fd, 1);
 	INTON;
 	if (fd < 0)
Only in bin/sh: mknodes
Only in bin/sh: mksyntax
diff -ur bin/sh/parser.c /home/s/reference/FreeBSD/src/bin/sh/parser.c
--- bin/sh/parser.c	2020-09-26 21:05:49.222039000 +0200
+++ /home/s/reference/FreeBSD/src/bin/sh/parser.c	2020-08-21 18:11:22.633124000 +0200
@@ -236,7 +236,6 @@
 }
 
 
-#if 0
 /*
  * Read and parse words for wordexp.
  * Returns a list of NARG nodes; NULL if there are no words.
@@ -268,7 +267,6 @@
 	}
 	return first;
 }
-#endif
 
 
 static union node *
diff -ur bin/sh/parser.h /home/s/reference/FreeBSD/src/bin/sh/parser.h
--- bin/sh/parser.h	2020-09-26 21:06:08.872106000 +0200
+++ /home/s/reference/FreeBSD/src/bin/sh/parser.h	2020-08-21 18:11:22.643126000 +0200
@@ -78,9 +78,7 @@
 
 
 union node *parsecmd(int);
-#if 0
 union node *parsewordexp(void);
-#endif
 void forcealias(void);
 void fixredir(union node *, const char *, int);
 int goodname(const char *);
Only in bin/sh: pregenerated
Only in /home/s/reference/FreeBSD/src/bin/sh: profile
diff -ur bin/sh/redir.c /home/s/reference/FreeBSD/src/bin/sh/redir.c
--- bin/sh/redir.c	2020-09-26 21:06:23.962133000 +0200
+++ /home/s/reference/FreeBSD/src/bin/sh/redir.c	2020-08-21 18:11:22.653124000 +0200
@@ -143,7 +143,7 @@
 
 		if ((flags & REDIR_PUSH) && sv->renamed[fd] == EMPTY) {
 			INTOFF;
-			if ((i = fcntl(fd, F_DUPFD_CLOEXEC_MAYBE, 10)) == -1) {
+			if ((i = fcntl(fd, F_DUPFD_CLOEXEC, 10)) == -1) {
 				switch (errno) {
 				case EBADF:
 					i = CLOSED;
@@ -154,11 +154,6 @@
 					break;
 				}
 			}
-#if !defined(O_CLOEXEC) || !defined(F_DUPFD_CLOEXEC)
-			else {
-				fcntl(i, F_SETFD, FD_CLOEXEC);
-			}
-#endif
 			sv->renamed[fd] = i;
 			INTON;
 		}
diff -ur bin/sh/shell.h /home/s/reference/FreeBSD/src/bin/sh/shell.h
--- bin/sh/shell.h	2020-09-26 21:07:12.202279000 +0200
+++ /home/s/reference/FreeBSD/src/bin/sh/shell.h	2020-08-21 18:11:22.653124000 +0200
@@ -55,22 +55,6 @@
 /* #define DEBUG 1 */
 
 /*
- * Allow compilation with older versions of DragonFly or on
- * systems without these features.
- */
-#ifdef F_DUPFD_CLOEXEC
-#define F_DUPFD_CLOEXEC_MAYBE		F_DUPFD_CLOEXEC
-#else
-#define F_DUPFD_CLOEXEC_MAYBE		F_DUPFD
-#endif
-
-#ifdef O_CLOEXEC
-#define O_CLOEXEC_MAYBE		O_CLOEXEC
-#else
-#define O_CLOEXEC_MAYBE		0
-#endif
-
-/*
  * Type of used arithmetics. SUSv3 requires us to have at least signed long.
  */
 typedef intmax_t arith_t;
Only in /home/s/reference/FreeBSD/src/bin/sh: tests
diff -ur bin/sh/trap.c /home/s/reference/FreeBSD/src/bin/sh/trap.c
--- bin/sh/trap.c	2020-09-26 21:31:15.586432000 +0200
+++ /home/s/reference/FreeBSD/src/bin/sh/trap.c	2020-09-10 05:46:20.654167000 +0200
@@ -58,9 +58,7 @@
 #include "trap.h"
 #include "mystring.h"
 #include "builtins.h"
-#ifndef NO_HISTORY
 #include "myhistedit.h"
-#endif
 
 
 /*
