summary refs log tree commit diff
path: root/bin/1sh/tests/execution
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-03-09 04:00:31 -0400
committerJune McEnroe <june@causal.agency>2020-03-09 04:00:31 -0400
commitbb6d30656efa59e16d9abc20146accb24de17090 (patch)
treee6e0a2f16e0900f29260d4198b5e530be87372f5 /bin/1sh/tests/execution
parentRemove 1sh sources (diff)
downloadsrc-bb6d30656efa59e16d9abc20146accb24de17090.tar.gz
src-bb6d30656efa59e16d9abc20146accb24de17090.zip
Import /usr/src/bin/sh from FreeBSD 12.1-RELEASE
Diffstat (limited to 'bin/1sh/tests/execution')
-rw-r--r--bin/1sh/tests/execution/Makefile64
-rw-r--r--bin/1sh/tests/execution/Makefile.depend11
-rw-r--r--bin/1sh/tests/execution/bg1.03
-rw-r--r--bin/1sh/tests/execution/bg10.04
-rw-r--r--bin/1sh/tests/execution/bg10.0.stdout1
-rw-r--r--bin/1sh/tests/execution/bg2.05
-rw-r--r--bin/1sh/tests/execution/bg3.05
-rw-r--r--bin/1sh/tests/execution/bg4.06
-rw-r--r--bin/1sh/tests/execution/bg5.04
-rw-r--r--bin/1sh/tests/execution/bg6.04
-rw-r--r--bin/1sh/tests/execution/bg6.0.stdout1
-rw-r--r--bin/1sh/tests/execution/bg7.05
-rw-r--r--bin/1sh/tests/execution/bg8.05
-rw-r--r--bin/1sh/tests/execution/bg9.05
-rw-r--r--bin/1sh/tests/execution/fork1.010
-rw-r--r--bin/1sh/tests/execution/fork2.09
-rw-r--r--bin/1sh/tests/execution/fork3.04
-rw-r--r--bin/1sh/tests/execution/func1.04
-rw-r--r--bin/1sh/tests/execution/func2.012
-rw-r--r--bin/1sh/tests/execution/func3.07
-rw-r--r--bin/1sh/tests/execution/hash1.012
-rw-r--r--bin/1sh/tests/execution/int-cmd1.03
-rw-r--r--bin/1sh/tests/execution/killed1.08
-rw-r--r--bin/1sh/tests/execution/killed2.010
-rw-r--r--bin/1sh/tests/execution/not1.04
-rw-r--r--bin/1sh/tests/execution/not2.06
-rw-r--r--bin/1sh/tests/execution/path1.015
-rw-r--r--bin/1sh/tests/execution/pipefail1.04
-rw-r--r--bin/1sh/tests/execution/pipefail2.424
-rw-r--r--bin/1sh/tests/execution/pipefail3.424
-rw-r--r--bin/1sh/tests/execution/pipefail4.424
-rw-r--r--bin/1sh/tests/execution/pipefail5.425
-rw-r--r--bin/1sh/tests/execution/pipefail6.426
-rw-r--r--bin/1sh/tests/execution/pipefail7.05
-rw-r--r--bin/1sh/tests/execution/redir1.027
-rw-r--r--bin/1sh/tests/execution/redir2.029
-rw-r--r--bin/1sh/tests/execution/redir3.03
-rw-r--r--bin/1sh/tests/execution/redir4.04
-rw-r--r--bin/1sh/tests/execution/redir5.03
-rw-r--r--bin/1sh/tests/execution/redir6.021
-rw-r--r--bin/1sh/tests/execution/redir7.021
-rw-r--r--bin/1sh/tests/execution/set-C1.012
-rw-r--r--bin/1sh/tests/execution/set-n1.07
-rw-r--r--bin/1sh/tests/execution/set-n2.05
-rw-r--r--bin/1sh/tests/execution/set-n3.04
-rw-r--r--bin/1sh/tests/execution/set-n4.03
-rw-r--r--bin/1sh/tests/execution/set-x1.08
-rw-r--r--bin/1sh/tests/execution/set-x2.09
-rw-r--r--bin/1sh/tests/execution/set-x3.09
-rw-r--r--bin/1sh/tests/execution/set-x4.07
-rw-r--r--bin/1sh/tests/execution/shellproc1.011
-rw-r--r--bin/1sh/tests/execution/subshell1.06
-rw-r--r--bin/1sh/tests/execution/subshell1.0.stdout2
-rw-r--r--bin/1sh/tests/execution/subshell2.010
-rw-r--r--bin/1sh/tests/execution/subshell3.04
-rw-r--r--bin/1sh/tests/execution/subshell4.03
-rw-r--r--bin/1sh/tests/execution/unknown1.029
-rw-r--r--bin/1sh/tests/execution/var-assign1.03
58 files changed, 499 insertions, 0 deletions
diff --git a/bin/1sh/tests/execution/Makefile b/bin/1sh/tests/execution/Makefile
new file mode 100644
index 00000000..966bc93c
--- /dev/null
+++ b/bin/1sh/tests/execution/Makefile
@@ -0,0 +1,64 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/Makefile 345487 2019-03-24 22:10:26Z jilles $
+
+PACKAGE=	tests
+
+TESTSDIR=	${TESTSBASE}/bin/sh/${.CURDIR:T}
+
+.PATH: ${.CURDIR:H}
+ATF_TESTS_SH=	functional_test
+
+${PACKAGE}FILES+=		bg1.0
+${PACKAGE}FILES+=		bg2.0
+${PACKAGE}FILES+=		bg3.0
+${PACKAGE}FILES+=		bg4.0
+${PACKAGE}FILES+=		bg5.0
+${PACKAGE}FILES+=		bg6.0 bg6.0.stdout
+${PACKAGE}FILES+=		bg7.0
+${PACKAGE}FILES+=		bg8.0
+${PACKAGE}FILES+=		bg9.0
+${PACKAGE}FILES+=		bg10.0 bg10.0.stdout
+${PACKAGE}FILES+=		fork1.0
+${PACKAGE}FILES+=		fork2.0
+${PACKAGE}FILES+=		fork3.0
+${PACKAGE}FILES+=		func1.0
+${PACKAGE}FILES+=		func2.0
+${PACKAGE}FILES+=		func3.0
+${PACKAGE}FILES+=		hash1.0
+${PACKAGE}FILES+=		int-cmd1.0
+${PACKAGE}FILES+=		killed1.0
+${PACKAGE}FILES+=		killed2.0
+${PACKAGE}FILES+=		not1.0
+${PACKAGE}FILES+=		not2.0
+${PACKAGE}FILES+=		path1.0
+${PACKAGE}FILES+=		pipefail1.0
+${PACKAGE}FILES+=		pipefail2.42
+${PACKAGE}FILES+=		pipefail3.42
+${PACKAGE}FILES+=		pipefail4.42
+${PACKAGE}FILES+=		pipefail5.42
+${PACKAGE}FILES+=		pipefail6.42
+${PACKAGE}FILES+=		pipefail7.0
+${PACKAGE}FILES+=		redir1.0
+${PACKAGE}FILES+=		redir2.0
+${PACKAGE}FILES+=		redir3.0
+${PACKAGE}FILES+=		redir4.0
+${PACKAGE}FILES+=		redir5.0
+${PACKAGE}FILES+=		redir6.0
+${PACKAGE}FILES+=		redir7.0
+${PACKAGE}FILES+=		set-C1.0
+${PACKAGE}FILES+=		set-n1.0
+${PACKAGE}FILES+=		set-n2.0
+${PACKAGE}FILES+=		set-n3.0
+${PACKAGE}FILES+=		set-n4.0
+${PACKAGE}FILES+=		set-x1.0
+${PACKAGE}FILES+=		set-x2.0
+${PACKAGE}FILES+=		set-x3.0
+${PACKAGE}FILES+=		set-x4.0
+${PACKAGE}FILES+=		shellproc1.0
+${PACKAGE}FILES+=		subshell1.0 subshell1.0.stdout
+${PACKAGE}FILES+=		subshell2.0
+${PACKAGE}FILES+=		subshell3.0
+${PACKAGE}FILES+=		subshell4.0
+${PACKAGE}FILES+=		unknown1.0
+${PACKAGE}FILES+=		var-assign1.0
+
+.include <bsd.test.mk>
diff --git a/bin/1sh/tests/execution/Makefile.depend b/bin/1sh/tests/execution/Makefile.depend
new file mode 100644
index 00000000..746c07a0
--- /dev/null
+++ b/bin/1sh/tests/execution/Makefile.depend
@@ -0,0 +1,11 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/Makefile.depend 296587 2016-03-09 22:46:01Z bdrewery $
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/bin/1sh/tests/execution/bg1.0 b/bin/1sh/tests/execution/bg1.0
new file mode 100644
index 00000000..b7277fa8
--- /dev/null
+++ b/bin/1sh/tests/execution/bg1.0
@@ -0,0 +1,3 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/bg1.0 221027 2011-04-25 20:54:12Z jilles $
+
+: `false` &
diff --git a/bin/1sh/tests/execution/bg10.0 b/bin/1sh/tests/execution/bg10.0
new file mode 100644
index 00000000..9eb15ed2
--- /dev/null
+++ b/bin/1sh/tests/execution/bg10.0
@@ -0,0 +1,4 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/bg10.0 258535 2013-11-24 23:12:13Z jilles $
+# The redirection overrides the </dev/null implicit in a background command.
+
+echo yes | ${SH} -c '{ cat & wait; } <&0'
diff --git a/bin/1sh/tests/execution/bg10.0.stdout b/bin/1sh/tests/execution/bg10.0.stdout
new file mode 100644
index 00000000..7cfab5b0
--- /dev/null
+++ b/bin/1sh/tests/execution/bg10.0.stdout
@@ -0,0 +1 @@
+yes
diff --git a/bin/1sh/tests/execution/bg2.0 b/bin/1sh/tests/execution/bg2.0
new file mode 100644
index 00000000..d0593687
--- /dev/null
+++ b/bin/1sh/tests/execution/bg2.0
@@ -0,0 +1,5 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/bg2.0 221027 2011-04-25 20:54:12Z jilles $
+
+f() { return 42; }
+f
+: | : &
diff --git a/bin/1sh/tests/execution/bg3.0 b/bin/1sh/tests/execution/bg3.0
new file mode 100644
index 00000000..e218ecd0
--- /dev/null
+++ b/bin/1sh/tests/execution/bg3.0
@@ -0,0 +1,5 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/bg3.0 221027 2011-04-25 20:54:12Z jilles $
+
+f() { return 42; }
+f
+(:) &
diff --git a/bin/1sh/tests/execution/bg4.0 b/bin/1sh/tests/execution/bg4.0
new file mode 100644
index 00000000..ddb5891f
--- /dev/null
+++ b/bin/1sh/tests/execution/bg4.0
@@ -0,0 +1,6 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/bg4.0 223283 2011-06-19 00:00:36Z jilles $
+
+x=''
+: ${x:=1} &
+wait
+exit ${x:-0}
diff --git a/bin/1sh/tests/execution/bg5.0 b/bin/1sh/tests/execution/bg5.0
new file mode 100644
index 00000000..cb9883ad
--- /dev/null
+++ b/bin/1sh/tests/execution/bg5.0
@@ -0,0 +1,4 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/bg5.0 258489 2013-11-22 21:50:13Z jilles $
+# A background command has an implicit </dev/null redirection.
+
+echo bad | ${SH} -c '{ cat & wait; }'
diff --git a/bin/1sh/tests/execution/bg6.0 b/bin/1sh/tests/execution/bg6.0
new file mode 100644
index 00000000..2883d2d4
--- /dev/null
+++ b/bin/1sh/tests/execution/bg6.0
@@ -0,0 +1,4 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/bg6.0 258489 2013-11-22 21:50:13Z jilles $
+# The redirection overrides the </dev/null implicit in a background command.
+
+echo yes | ${SH} -c '{ cat & wait; } </dev/stdin'
diff --git a/bin/1sh/tests/execution/bg6.0.stdout b/bin/1sh/tests/execution/bg6.0.stdout
new file mode 100644
index 00000000..7cfab5b0
--- /dev/null
+++ b/bin/1sh/tests/execution/bg6.0.stdout
@@ -0,0 +1 @@
+yes
diff --git a/bin/1sh/tests/execution/bg7.0 b/bin/1sh/tests/execution/bg7.0
new file mode 100644
index 00000000..f15c3c21
--- /dev/null
+++ b/bin/1sh/tests/execution/bg7.0
@@ -0,0 +1,5 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/bg7.0 258533 2013-11-24 22:45:49Z jilles $
+# The redirection does not apply to the background command, and therefore
+# does not override the implicit </dev/null.
+
+echo bad | ${SH} -c '</dev/null; { cat & wait; }'
diff --git a/bin/1sh/tests/execution/bg8.0 b/bin/1sh/tests/execution/bg8.0
new file mode 100644
index 00000000..43c1e3f0
--- /dev/null
+++ b/bin/1sh/tests/execution/bg8.0
@@ -0,0 +1,5 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/bg8.0 258533 2013-11-24 22:45:49Z jilles $
+# The redirection does not apply to the background command, and therefore
+# does not override the implicit </dev/null.
+
+echo bad | ${SH} -c 'command eval \) </dev/null 2>/dev/null; { cat & wait; }'
diff --git a/bin/1sh/tests/execution/bg9.0 b/bin/1sh/tests/execution/bg9.0
new file mode 100644
index 00000000..4fee9946
--- /dev/null
+++ b/bin/1sh/tests/execution/bg9.0
@@ -0,0 +1,5 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/bg9.0 258533 2013-11-24 22:45:49Z jilles $
+# The redirection does not apply to the background command, and therefore
+# does not override the implicit </dev/null.
+
+echo bad | ${SH} -c 'command eval eval \\\) \</dev/null 2>/dev/null; { cat & wait; }'
diff --git a/bin/1sh/tests/execution/fork1.0 b/bin/1sh/tests/execution/fork1.0
new file mode 100644
index 00000000..edd8f6ad
--- /dev/null
+++ b/bin/1sh/tests/execution/fork1.0
@@ -0,0 +1,10 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/fork1.0 218850 2011-02-19 13:22:18Z jilles $
+
+shname=${SH%% *}
+shname=${shname##*/}
+
+result=$(${SH} -c 'ps -p $$ -o comm=')
+test "$result" = "ps" || exit 1
+
+result=$(${SH} -c 'ps -p $$ -o comm=; :')
+test "$result" = "$shname" || exit 1
diff --git a/bin/1sh/tests/execution/fork2.0 b/bin/1sh/tests/execution/fork2.0
new file mode 100644
index 00000000..f85f7e0a
--- /dev/null
+++ b/bin/1sh/tests/execution/fork2.0
@@ -0,0 +1,9 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/fork2.0 213738 2010-10-12 18:20:38Z obrien $
+
+result=$(${SH} -c '(/bin/sleep 1)& sleep 0.1; ps -p $! -o comm=; kill $!')
+test "$result" = sleep || exit 1
+
+result=$(${SH} -c '{ trap "echo trapped" EXIT; (/usr/bin/true); } & wait')
+test "$result" = trapped || exit 1
+
+exit 0
diff --git a/bin/1sh/tests/execution/fork3.0 b/bin/1sh/tests/execution/fork3.0
new file mode 100644
index 00000000..101a16c6
--- /dev/null
+++ b/bin/1sh/tests/execution/fork3.0
@@ -0,0 +1,4 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/fork3.0 220978 2011-04-23 22:28:56Z jilles $
+
+result=$(${SH} -c 'f() { ps -p $$ -o comm=; }; f')
+test "$result" = "ps"
diff --git a/bin/1sh/tests/execution/func1.0 b/bin/1sh/tests/execution/func1.0
new file mode 100644
index 00000000..25b4781f
--- /dev/null
+++ b/bin/1sh/tests/execution/func1.0
@@ -0,0 +1,4 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/func1.0 213738 2010-10-12 18:20:38Z obrien $
+
+MALLOC_OPTIONS=J ${SH} -c 'g() { g() { :; }; :; }; g' &&
+MALLOC_OPTIONS=J ${SH} -c 'g() { unset -f g; :; }; g'
diff --git a/bin/1sh/tests/execution/func2.0 b/bin/1sh/tests/execution/func2.0
new file mode 100644
index 00000000..a1f3e0cc
--- /dev/null
+++ b/bin/1sh/tests/execution/func2.0
@@ -0,0 +1,12 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/func2.0 211399 2010-08-16 17:18:08Z jilles $
+# The empty pairs of braces here are to test that this does not cause a crash.
+
+f() { }
+f
+hash -v f >/dev/null
+f() { { }; }
+f
+hash -v f >/dev/null
+f() { { } }
+f
+hash -v f >/dev/null
diff --git a/bin/1sh/tests/execution/func3.0 b/bin/1sh/tests/execution/func3.0
new file mode 100644
index 00000000..a92c12f6
--- /dev/null
+++ b/bin/1sh/tests/execution/func3.0
@@ -0,0 +1,7 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/func3.0 216398 2010-12-12 21:18:16Z jilles $
+
+# This may fail when parsing or when defining the function, or the definition
+# may silently do nothing. In no event may the function be executed.
+
+${SH} -c 'unset() { echo overriding function executed, bad; }; v=1; unset v; exit "${v-0}"' 2>/dev/null
+:
diff --git a/bin/1sh/tests/execution/hash1.0 b/bin/1sh/tests/execution/hash1.0
new file mode 100644
index 00000000..e47b86c8
--- /dev/null
+++ b/bin/1sh/tests/execution/hash1.0
@@ -0,0 +1,12 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/hash1.0 218323 2011-02-05 14:01:46Z jilles $
+
+T=`mktemp -d "${TMPDIR:-/tmp}/sh-test.XXXXXXXX"` || exit
+trap 'rm -rf "${T}"' 0
+PATH=$T:$PATH
+ls -ld . >/dev/null
+cat <<EOF >"$T/ls"
+:
+EOF
+chmod 755 "$T/ls"
+PATH=$PATH
+ls -ld .
diff --git a/bin/1sh/tests/execution/int-cmd1.0 b/bin/1sh/tests/execution/int-cmd1.0
new file mode 100644
index 00000000..6c415646
--- /dev/null
+++ b/bin/1sh/tests/execution/int-cmd1.0
@@ -0,0 +1,3 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/int-cmd1.0 253271 2013-07-12 15:29:41Z jilles $
+
+! echo echo bad | $SH -ic 'fi' 2>/dev/null
diff --git a/bin/1sh/tests/execution/killed1.0 b/bin/1sh/tests/execution/killed1.0
new file mode 100644
index 00000000..c5b36ab6
--- /dev/null
+++ b/bin/1sh/tests/execution/killed1.0
@@ -0,0 +1,8 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/killed1.0 217557 2011-01-18 21:18:31Z jilles $
+# Sometimes the "Killed" message is not flushed soon enough and it
+# is redirected along with the output of a builtin.
+# Do not change the semicolon to a newline as it would hide the bug.
+
+exec 3>&1
+exec >/dev/null 2>&1
+${SH} -c 'kill -9 $$'; : >&3 2>&3
diff --git a/bin/1sh/tests/execution/killed2.0 b/bin/1sh/tests/execution/killed2.0
new file mode 100644
index 00000000..6d7a40e6
--- /dev/null
+++ b/bin/1sh/tests/execution/killed2.0
@@ -0,0 +1,10 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/killed2.0 218105 2011-01-30 22:57:52Z jilles $
+# Most shells print a message when a foreground job is killed by a signal.
+# POSIX allows this, provided the message is sent to stderr, not stdout.
+# Some trickery is needed to capture the message as redirecting stderr of
+# the command itself does not affect it. The colon command ensures that
+# the subshell forks for ${SH}.
+
+exec 3>&1
+r=`(${SH} -c 'kill $$'; :) 2>&1 >&3`
+[ -n "$r" ]
diff --git a/bin/1sh/tests/execution/not1.0 b/bin/1sh/tests/execution/not1.0
new file mode 100644
index 00000000..8e329c9b
--- /dev/null
+++ b/bin/1sh/tests/execution/not1.0
@@ -0,0 +1,4 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/not1.0 249407 2013-04-12 15:19:35Z jilles $
+
+f() { ! return $1; }
+f 0 && ! f 1
diff --git a/bin/1sh/tests/execution/not2.0 b/bin/1sh/tests/execution/not2.0
new file mode 100644
index 00000000..0930f243
--- /dev/null
+++ b/bin/1sh/tests/execution/not2.0
@@ -0,0 +1,6 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/not2.0 249407 2013-04-12 15:19:35Z jilles $
+
+while :; do
+	! break
+	exit 3
+done
diff --git a/bin/1sh/tests/execution/path1.0 b/bin/1sh/tests/execution/path1.0
new file mode 100644
index 00000000..63ab97a1
--- /dev/null
+++ b/bin/1sh/tests/execution/path1.0
@@ -0,0 +1,15 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/path1.0 217206 2011-01-09 21:07:30Z jilles $
+# Some builtins should not be overridable via PATH.
+
+set -e
+T=$(mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXX)
+trap 'rm -rf ${T}' 0
+echo '#!/bin/sh
+echo bad' >"$T/cd"
+chmod 755 "$T/cd"
+cd /bin
+oPATH=$PATH
+PATH=$T:$PATH:%builtin
+cd /
+PATH=$oPATH
+[ "$(pwd)" = / ]
diff --git a/bin/1sh/tests/execution/pipefail1.0 b/bin/1sh/tests/execution/pipefail1.0
new file mode 100644
index 00000000..4835d8c0
--- /dev/null
+++ b/bin/1sh/tests/execution/pipefail1.0
@@ -0,0 +1,4 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/pipefail1.0 345487 2019-03-24 22:10:26Z jilles $
+
+set -o pipefail
+: && : | : && : | : | : && : | : | : | :
diff --git a/bin/1sh/tests/execution/pipefail2.42 b/bin/1sh/tests/execution/pipefail2.42
new file mode 100644
index 00000000..1d9d2759
--- /dev/null
+++ b/bin/1sh/tests/execution/pipefail2.42
@@ -0,0 +1,4 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/pipefail2.42 345487 2019-03-24 22:10:26Z jilles $
+
+set -o pipefail
+(exit 42) | :
diff --git a/bin/1sh/tests/execution/pipefail3.42 b/bin/1sh/tests/execution/pipefail3.42
new file mode 100644
index 00000000..17f49894
--- /dev/null
+++ b/bin/1sh/tests/execution/pipefail3.42
@@ -0,0 +1,4 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/pipefail3.42 345487 2019-03-24 22:10:26Z jilles $
+
+set -o pipefail
+: | (exit 42)
diff --git a/bin/1sh/tests/execution/pipefail4.42 b/bin/1sh/tests/execution/pipefail4.42
new file mode 100644
index 00000000..a7c9b4ad
--- /dev/null
+++ b/bin/1sh/tests/execution/pipefail4.42
@@ -0,0 +1,4 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/pipefail4.42 345487 2019-03-24 22:10:26Z jilles $
+
+set -o pipefail
+(exit 43) | (exit 42)
diff --git a/bin/1sh/tests/execution/pipefail5.42 b/bin/1sh/tests/execution/pipefail5.42
new file mode 100644
index 00000000..7882d8a5
--- /dev/null
+++ b/bin/1sh/tests/execution/pipefail5.42
@@ -0,0 +1,5 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/pipefail5.42 345487 2019-03-24 22:10:26Z jilles $
+
+set -o pipefail
+(exit 42) | : &
+wait %+
diff --git a/bin/1sh/tests/execution/pipefail6.42 b/bin/1sh/tests/execution/pipefail6.42
new file mode 100644
index 00000000..70d84d72
--- /dev/null
+++ b/bin/1sh/tests/execution/pipefail6.42
@@ -0,0 +1,6 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/pipefail6.42 345487 2019-03-24 22:10:26Z jilles $
+
+set -o pipefail
+(exit 42) | : &
+set +o pipefail
+wait %+
diff --git a/bin/1sh/tests/execution/pipefail7.0 b/bin/1sh/tests/execution/pipefail7.0
new file mode 100644
index 00000000..1a23e90d
--- /dev/null
+++ b/bin/1sh/tests/execution/pipefail7.0
@@ -0,0 +1,5 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/pipefail7.0 345487 2019-03-24 22:10:26Z jilles $
+
+(exit 42) | : &
+set -o pipefail
+wait %+
diff --git a/bin/1sh/tests/execution/redir1.0 b/bin/1sh/tests/execution/redir1.0
new file mode 100644
index 00000000..797e42b2
--- /dev/null
+++ b/bin/1sh/tests/execution/redir1.0
@@ -0,0 +1,27 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/redir1.0 211408 2010-08-16 22:23:19Z jilles $
+trap ': $((brokenpipe+=1))' PIPE
+
+P=${TMPDIR:-/tmp}
+cd $P
+T=$(mktemp -d sh-test.XXXXXX)
+cd $T
+
+brokenpipe=0
+mkfifo fifo1 fifo2
+read dummy >fifo2 <fifo1 &
+{
+	exec 4>fifo2
+} 3<fifo2 # Formerly, sh would keep fd 3 and a duplicate of it open.
+echo dummy >fifo1
+if [ $brokenpipe -ne 0 ]; then
+	rc=3
+fi
+wait
+echo dummy >&4 2>/dev/null
+if [ $brokenpipe -eq 1 ]; then
+	: ${rc:=0}
+fi
+
+rm fifo1 fifo2
+rmdir ${P}/${T}
+exit ${rc:-3}
diff --git a/bin/1sh/tests/execution/redir2.0 b/bin/1sh/tests/execution/redir2.0
new file mode 100644
index 00000000..1e2a9c16
--- /dev/null
+++ b/bin/1sh/tests/execution/redir2.0
@@ -0,0 +1,29 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/redir2.0 213738 2010-10-12 18:20:38Z obrien $
+trap ': $((brokenpipe+=1))' PIPE
+
+P=${TMPDIR:-/tmp}
+cd $P
+T=$(mktemp -d sh-test.XXXXXX)
+cd $T
+
+brokenpipe=0
+mkfifo fifo1 fifo2
+{
+	{
+		exec ${SH} -c 'exec <fifo1; read dummy'
+	} 7<&- # fifo2 should be kept open, but not passed to programs
+	true
+} 7<fifo2 &
+
+exec 4>fifo2
+exec 3>fifo1
+echo dummy >&4 2>/dev/null
+if [ $brokenpipe -eq 1 ]; then
+	: ${rc:=0}
+fi
+echo dummy >&3
+wait
+
+rm fifo1 fifo2
+rmdir ${P}/${T}
+exit ${rc:-3}
diff --git a/bin/1sh/tests/execution/redir3.0 b/bin/1sh/tests/execution/redir3.0
new file mode 100644
index 00000000..ddd9e1c3
--- /dev/null
+++ b/bin/1sh/tests/execution/redir3.0
@@ -0,0 +1,3 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/redir3.0 214289 2010-10-24 19:56:34Z jilles $
+
+3>&- 3>&-
diff --git a/bin/1sh/tests/execution/redir4.0 b/bin/1sh/tests/execution/redir4.0
new file mode 100644
index 00000000..02cd9a8c
--- /dev/null
+++ b/bin/1sh/tests/execution/redir4.0
@@ -0,0 +1,4 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/redir4.0 214290 2010-10-24 20:09:49Z jilles $
+
+{ echo bad 0>&3; } 2>/dev/null 3>/dev/null 3>&-
+exit 0
diff --git a/bin/1sh/tests/execution/redir5.0 b/bin/1sh/tests/execution/redir5.0
new file mode 100644
index 00000000..f0247102
--- /dev/null
+++ b/bin/1sh/tests/execution/redir5.0
@@ -0,0 +1,3 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/redir5.0 218325 2011-02-05 15:02:19Z jilles $
+
+{ (echo bad) >/dev/null; } </dev/null
diff --git a/bin/1sh/tests/execution/redir6.0 b/bin/1sh/tests/execution/redir6.0
new file mode 100644
index 00000000..846869d4
--- /dev/null
+++ b/bin/1sh/tests/execution/redir6.0
@@ -0,0 +1,21 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/redir6.0 220978 2011-04-23 22:28:56Z jilles $
+
+failures=0
+
+check() {
+	if [ "$2" != "$3" ]; then
+		echo "Failure at $1" >&2
+		failures=$((failures + 1))
+	fi
+}
+
+check $LINENO "$(trap "echo bye" EXIT; : >/dev/null)" bye
+check $LINENO "$(trap "echo bye" EXIT; { :; } >/dev/null)" bye
+check $LINENO "$(trap "echo bye" EXIT; (:) >/dev/null)" bye
+check $LINENO "$(trap "echo bye" EXIT; (: >/dev/null))" bye
+check $LINENO "$(${SH} -c 'trap "echo bye" EXIT; : >/dev/null')" bye
+check $LINENO "$(${SH} -c 'trap "echo bye" EXIT; { :; } >/dev/null')" bye
+check $LINENO "$(${SH} -c 'trap "echo bye" EXIT; (:) >/dev/null')" bye
+check $LINENO "$(${SH} -c 'trap "echo bye" EXIT; (: >/dev/null)')" bye
+
+exit $((failures > 0))
diff --git a/bin/1sh/tests/execution/redir7.0 b/bin/1sh/tests/execution/redir7.0
new file mode 100644
index 00000000..f47c9db8
--- /dev/null
+++ b/bin/1sh/tests/execution/redir7.0
@@ -0,0 +1,21 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/redir7.0 220978 2011-04-23 22:28:56Z jilles $
+
+failures=0
+
+check() {
+	if [ "$2" != "$3" ]; then
+		echo "Failure at $1" >&2
+		failures=$((failures + 1))
+	fi
+}
+
+check $LINENO "$(trap "echo bye" EXIT; f() { :; }; f >/dev/null)" bye
+check $LINENO "$(trap "echo bye" EXIT; f() { :; }; { f; } >/dev/null)" bye
+check $LINENO "$(trap "echo bye" EXIT; f() { :; }; (f) >/dev/null)" bye
+check $LINENO "$(trap "echo bye" EXIT; f() { :; }; (f >/dev/null))" bye
+check $LINENO "$(${SH} -c 'trap "echo bye" EXIT; f() { :; }; f >/dev/null')" bye
+check $LINENO "$(${SH} -c 'trap "echo bye" EXIT; f() { :; }; { f; } >/dev/null')" bye
+check $LINENO "$(${SH} -c 'trap "echo bye" EXIT; f() { :; }; (f) >/dev/null')" bye
+check $LINENO "$(${SH} -c 'trap "echo bye" EXIT; f() { :; }; (f >/dev/null)')" bye
+
+exit $((failures > 0))
diff --git a/bin/1sh/tests/execution/set-C1.0 b/bin/1sh/tests/execution/set-C1.0
new file mode 100644
index 00000000..736eefa6
--- /dev/null
+++ b/bin/1sh/tests/execution/set-C1.0
@@ -0,0 +1,12 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/set-C1.0 308229 2016-11-02 22:33:37Z jilles $
+
+T=$(mktemp -d "${TMPDIR:-/tmp}/sh-test.XXXXXXXX") || exit
+trap 'rm -rf "$T"' 0
+
+set -C
+echo . >"$T/a" &&
+[ -s "$T/a" ] &&
+{ ! true >"$T/a"; } 2>/dev/null &&
+[ -s "$T/a" ] &&
+ln -s /dev/null "$T/b" &&
+true >"$T/b"
diff --git a/bin/1sh/tests/execution/set-n1.0 b/bin/1sh/tests/execution/set-n1.0
new file mode 100644
index 00000000..19afbda3
--- /dev/null
+++ b/bin/1sh/tests/execution/set-n1.0
@@ -0,0 +1,7 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/set-n1.0 222661 2011-06-03 21:17:42Z jilles $
+
+v=$( ($SH -n <<'EOF'
+for
+EOF
+) 2>&1 >/dev/null)
+[ $? -ne 0 ] && [ -n "$v" ]
diff --git a/bin/1sh/tests/execution/set-n2.0 b/bin/1sh/tests/execution/set-n2.0
new file mode 100644
index 00000000..a6d9a1e4
--- /dev/null
+++ b/bin/1sh/tests/execution/set-n2.0
@@ -0,0 +1,5 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/set-n2.0 222661 2011-06-03 21:17:42Z jilles $
+
+$SH -n <<'EOF'
+echo bad
+EOF
diff --git a/bin/1sh/tests/execution/set-n3.0 b/bin/1sh/tests/execution/set-n3.0
new file mode 100644
index 00000000..65214703
--- /dev/null
+++ b/bin/1sh/tests/execution/set-n3.0
@@ -0,0 +1,4 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/set-n3.0 222661 2011-06-03 21:17:42Z jilles $
+
+v=$( ($SH -nc 'for') 2>&1 >/dev/null)
+[ $? -ne 0 ] && [ -n "$v" ]
diff --git a/bin/1sh/tests/execution/set-n4.0 b/bin/1sh/tests/execution/set-n4.0
new file mode 100644
index 00000000..a7584dc3
--- /dev/null
+++ b/bin/1sh/tests/execution/set-n4.0
@@ -0,0 +1,3 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/set-n4.0 222676 2011-06-04 11:28:42Z jilles $
+
+$SH -nc 'echo bad'
diff --git a/bin/1sh/tests/execution/set-x1.0 b/bin/1sh/tests/execution/set-x1.0
new file mode 100644
index 00000000..8c8d11e4
--- /dev/null
+++ b/bin/1sh/tests/execution/set-x1.0
@@ -0,0 +1,8 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/set-x1.0 222882 2011-06-08 21:58:19Z jilles $
+
+key='must_contain_this'
+{ r=`set -x; { : "$key"; } 2>&1 >/dev/null`; } 2>/dev/null
+case $r in
+*"$key"*) true ;;
+*) false ;;
+esac
diff --git a/bin/1sh/tests/execution/set-x2.0 b/bin/1sh/tests/execution/set-x2.0
new file mode 100644
index 00000000..0c5073b5
--- /dev/null
+++ b/bin/1sh/tests/execution/set-x2.0
@@ -0,0 +1,9 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/set-x2.0 222882 2011-06-08 21:58:19Z jilles $
+
+key='must contain this'
+PS4="$key+ "
+{ r=`set -x; { :; } 2>&1 >/dev/null`; } 2>/dev/null
+case $r in
+*"$key"*) true ;;
+*) false ;;
+esac
diff --git a/bin/1sh/tests/execution/set-x3.0 b/bin/1sh/tests/execution/set-x3.0
new file mode 100644
index 00000000..195219b2
--- /dev/null
+++ b/bin/1sh/tests/execution/set-x3.0
@@ -0,0 +1,9 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/set-x3.0 222907 2011-06-09 23:12:23Z jilles $
+
+key='must contain this'
+PS4='$key+ '
+{ r=`set -x; { :; } 2>&1 >/dev/null`; } 2>/dev/null
+case $r in
+*"$key"*) true ;;
+*) false ;;
+esac
diff --git a/bin/1sh/tests/execution/set-x4.0 b/bin/1sh/tests/execution/set-x4.0
new file mode 100644
index 00000000..fcc638ec
--- /dev/null
+++ b/bin/1sh/tests/execution/set-x4.0
@@ -0,0 +1,7 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/set-x4.0 275766 2014-12-14 16:26:19Z jilles $
+
+key=`printf '\r\t\001\200\300'`
+r=`{ set -x; : "$key"; } 2>&1 >/dev/null`
+case $r in
+*[![:print:]]*) echo fail; exit 3
+esac
diff --git a/bin/1sh/tests/execution/shellproc1.0 b/bin/1sh/tests/execution/shellproc1.0
new file mode 100644
index 00000000..2d1fd919
--- /dev/null
+++ b/bin/1sh/tests/execution/shellproc1.0
@@ -0,0 +1,11 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/shellproc1.0 218205 2011-02-02 22:03:18Z jilles $
+
+T=`mktemp -d "${TMPDIR:-/tmp}/sh-test.XXXXXXXX"` || exit
+trap 'rm -rf "${T}"' 0
+cat <<EOF >"$T/testshellproc"
+printf 'this '
+echo is a test
+EOF
+chmod 755 "$T/testshellproc"
+PATH=$T:$PATH
+[ "`testshellproc`" = "this is a test" ]
diff --git a/bin/1sh/tests/execution/subshell1.0 b/bin/1sh/tests/execution/subshell1.0
new file mode 100644
index 00000000..83819cc1
--- /dev/null
+++ b/bin/1sh/tests/execution/subshell1.0
@@ -0,0 +1,6 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/subshell1.0 245383 2013-01-13 19:39:13Z jilles $
+
+(eval "cd /
+v=$(printf %0100000d 1)
+echo \${#v}")
+echo end
diff --git a/bin/1sh/tests/execution/subshell1.0.stdout b/bin/1sh/tests/execution/subshell1.0.stdout
new file mode 100644
index 00000000..8c71af3c
--- /dev/null
+++ b/bin/1sh/tests/execution/subshell1.0.stdout
@@ -0,0 +1,2 @@
+100000
+end
diff --git a/bin/1sh/tests/execution/subshell2.0 b/bin/1sh/tests/execution/subshell2.0
new file mode 100644
index 00000000..e938ff82
--- /dev/null
+++ b/bin/1sh/tests/execution/subshell2.0
@@ -0,0 +1,10 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/subshell2.0 245383 2013-01-13 19:39:13Z jilles $
+
+f() {
+	x=2
+}
+(
+	x=1
+	f
+	[ "$x" = 2 ]
+)
diff --git a/bin/1sh/tests/execution/subshell3.0 b/bin/1sh/tests/execution/subshell3.0
new file mode 100644
index 00000000..f703e9c1
--- /dev/null
+++ b/bin/1sh/tests/execution/subshell3.0
@@ -0,0 +1,4 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/subshell3.0 245383 2013-01-13 19:39:13Z jilles $
+
+(false; exit) && exit 3
+exit 0
diff --git a/bin/1sh/tests/execution/subshell4.0 b/bin/1sh/tests/execution/subshell4.0
new file mode 100644
index 00000000..37ea313e
--- /dev/null
+++ b/bin/1sh/tests/execution/subshell4.0
@@ -0,0 +1,3 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/subshell4.0 245383 2013-01-13 19:39:13Z jilles $
+
+(eval "set v=1"; false) && echo bad; :
diff --git a/bin/1sh/tests/execution/unknown1.0 b/bin/1sh/tests/execution/unknown1.0
new file mode 100644
index 00000000..c4258aa9
--- /dev/null
+++ b/bin/1sh/tests/execution/unknown1.0
@@ -0,0 +1,29 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/unknown1.0 197820 2009-10-06 22:00:14Z jilles $
+
+nosuchtool 2>/dev/null
+[ $? -ne 127 ] && exit 1
+/var/empty/nosuchtool 2>/dev/null
+[ $? -ne 127 ] && exit 1
+(nosuchtool) 2>/dev/null
+[ $? -ne 127 ] && exit 1
+(/var/empty/nosuchtool) 2>/dev/null
+[ $? -ne 127 ] && exit 1
+/ 2>/dev/null
+[ $? -ne 126 ] && exit 1
+PATH=/usr bin 2>/dev/null
+[ $? -ne 126 ] && exit 1
+
+dummy=$(nosuchtool 2>/dev/null)
+[ $? -ne 127 ] && exit 1
+dummy=$(/var/empty/nosuchtool 2>/dev/null)
+[ $? -ne 127 ] && exit 1
+dummy=$( (nosuchtool) 2>/dev/null)
+[ $? -ne 127 ] && exit 1
+dummy=$( (/var/empty/nosuchtool) 2>/dev/null)
+[ $? -ne 127 ] && exit 1
+dummy=$(/ 2>/dev/null)
+[ $? -ne 126 ] && exit 1
+dummy=$(PATH=/usr bin 2>/dev/null)
+[ $? -ne 126 ] && exit 1
+
+exit 0
diff --git a/bin/1sh/tests/execution/var-assign1.0 b/bin/1sh/tests/execution/var-assign1.0
new file mode 100644
index 00000000..6507c487
--- /dev/null
+++ b/bin/1sh/tests/execution/var-assign1.0
@@ -0,0 +1,3 @@
+# $FreeBSD: releng/12.1/bin/sh/tests/execution/var-assign1.0 212467 2010-09-11 14:15:50Z jilles $
+
+[ "$(HOME=/etc HOME=/ cd && pwd)" = / ]