From 308a14f85158f1545000499a64bc170d688a0db9 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Thu, 10 Jan 2019 18:48:02 -0500 Subject: Import /usr/src/bin/sh from FreeBSD 12.0-RELEASE --- bin/cash/tests/execution/Makefile | 57 +++++++++++++++++++++++++++++ bin/cash/tests/execution/bg1.0 | 3 ++ bin/cash/tests/execution/bg10.0 | 4 ++ bin/cash/tests/execution/bg10.0.stdout | 1 + bin/cash/tests/execution/bg2.0 | 5 +++ bin/cash/tests/execution/bg3.0 | 5 +++ bin/cash/tests/execution/bg4.0 | 6 +++ bin/cash/tests/execution/bg5.0 | 4 ++ bin/cash/tests/execution/bg6.0 | 4 ++ bin/cash/tests/execution/bg6.0.stdout | 1 + bin/cash/tests/execution/bg7.0 | 5 +++ bin/cash/tests/execution/bg8.0 | 5 +++ bin/cash/tests/execution/bg9.0 | 5 +++ bin/cash/tests/execution/fork1.0 | 10 +++++ bin/cash/tests/execution/fork2.0 | 9 +++++ bin/cash/tests/execution/fork3.0 | 4 ++ bin/cash/tests/execution/func1.0 | 4 ++ bin/cash/tests/execution/func2.0 | 12 ++++++ bin/cash/tests/execution/func3.0 | 7 ++++ bin/cash/tests/execution/hash1.0 | 12 ++++++ bin/cash/tests/execution/int-cmd1.0 | 3 ++ bin/cash/tests/execution/killed1.0 | 8 ++++ bin/cash/tests/execution/killed2.0 | 10 +++++ bin/cash/tests/execution/not1.0 | 4 ++ bin/cash/tests/execution/not2.0 | 6 +++ bin/cash/tests/execution/path1.0 | 15 ++++++++ bin/cash/tests/execution/redir1.0 | 27 ++++++++++++++ bin/cash/tests/execution/redir2.0 | 29 +++++++++++++++ bin/cash/tests/execution/redir3.0 | 3 ++ bin/cash/tests/execution/redir4.0 | 4 ++ bin/cash/tests/execution/redir5.0 | 3 ++ bin/cash/tests/execution/redir6.0 | 21 +++++++++++ bin/cash/tests/execution/redir7.0 | 21 +++++++++++ bin/cash/tests/execution/set-C1.0 | 12 ++++++ bin/cash/tests/execution/set-n1.0 | 7 ++++ bin/cash/tests/execution/set-n2.0 | 5 +++ bin/cash/tests/execution/set-n3.0 | 4 ++ bin/cash/tests/execution/set-n4.0 | 3 ++ bin/cash/tests/execution/set-x1.0 | 8 ++++ bin/cash/tests/execution/set-x2.0 | 9 +++++ bin/cash/tests/execution/set-x3.0 | 9 +++++ bin/cash/tests/execution/set-x4.0 | 7 ++++ bin/cash/tests/execution/shellproc1.0 | 11 ++++++ bin/cash/tests/execution/subshell1.0 | 6 +++ bin/cash/tests/execution/subshell1.0.stdout | 2 + bin/cash/tests/execution/subshell2.0 | 10 +++++ bin/cash/tests/execution/subshell3.0 | 4 ++ bin/cash/tests/execution/subshell4.0 | 3 ++ bin/cash/tests/execution/unknown1.0 | 29 +++++++++++++++ bin/cash/tests/execution/var-assign1.0 | 3 ++ 50 files changed, 449 insertions(+) create mode 100644 bin/cash/tests/execution/Makefile create mode 100644 bin/cash/tests/execution/bg1.0 create mode 100644 bin/cash/tests/execution/bg10.0 create mode 100644 bin/cash/tests/execution/bg10.0.stdout create mode 100644 bin/cash/tests/execution/bg2.0 create mode 100644 bin/cash/tests/execution/bg3.0 create mode 100644 bin/cash/tests/execution/bg4.0 create mode 100644 bin/cash/tests/execution/bg5.0 create mode 100644 bin/cash/tests/execution/bg6.0 create mode 100644 bin/cash/tests/execution/bg6.0.stdout create mode 100644 bin/cash/tests/execution/bg7.0 create mode 100644 bin/cash/tests/execution/bg8.0 create mode 100644 bin/cash/tests/execution/bg9.0 create mode 100644 bin/cash/tests/execution/fork1.0 create mode 100644 bin/cash/tests/execution/fork2.0 create mode 100644 bin/cash/tests/execution/fork3.0 create mode 100644 bin/cash/tests/execution/func1.0 create mode 100644 bin/cash/tests/execution/func2.0 create mode 100644 bin/cash/tests/execution/func3.0 create mode 100644 bin/cash/tests/execution/hash1.0 create mode 100644 bin/cash/tests/execution/int-cmd1.0 create mode 100644 bin/cash/tests/execution/killed1.0 create mode 100644 bin/cash/tests/execution/killed2.0 create mode 100644 bin/cash/tests/execution/not1.0 create mode 100644 bin/cash/tests/execution/not2.0 create mode 100644 bin/cash/tests/execution/path1.0 create mode 100644 bin/cash/tests/execution/redir1.0 create mode 100644 bin/cash/tests/execution/redir2.0 create mode 100644 bin/cash/tests/execution/redir3.0 create mode 100644 bin/cash/tests/execution/redir4.0 create mode 100644 bin/cash/tests/execution/redir5.0 create mode 100644 bin/cash/tests/execution/redir6.0 create mode 100644 bin/cash/tests/execution/redir7.0 create mode 100644 bin/cash/tests/execution/set-C1.0 create mode 100644 bin/cash/tests/execution/set-n1.0 create mode 100644 bin/cash/tests/execution/set-n2.0 create mode 100644 bin/cash/tests/execution/set-n3.0 create mode 100644 bin/cash/tests/execution/set-n4.0 create mode 100644 bin/cash/tests/execution/set-x1.0 create mode 100644 bin/cash/tests/execution/set-x2.0 create mode 100644 bin/cash/tests/execution/set-x3.0 create mode 100644 bin/cash/tests/execution/set-x4.0 create mode 100644 bin/cash/tests/execution/shellproc1.0 create mode 100644 bin/cash/tests/execution/subshell1.0 create mode 100644 bin/cash/tests/execution/subshell1.0.stdout create mode 100644 bin/cash/tests/execution/subshell2.0 create mode 100644 bin/cash/tests/execution/subshell3.0 create mode 100644 bin/cash/tests/execution/subshell4.0 create mode 100644 bin/cash/tests/execution/unknown1.0 create mode 100644 bin/cash/tests/execution/var-assign1.0 (limited to 'bin/cash/tests/execution') diff --git a/bin/cash/tests/execution/Makefile b/bin/cash/tests/execution/Makefile new file mode 100644 index 00000000..99963afb --- /dev/null +++ b/bin/cash/tests/execution/Makefile @@ -0,0 +1,57 @@ +# $FreeBSD: releng/12.0/bin/sh/tests/execution/Makefile 308229 2016-11-02 22:33:37Z 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+= 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 diff --git a/bin/cash/tests/execution/bg1.0 b/bin/cash/tests/execution/bg1.0 new file mode 100644 index 00000000..7336ceab --- /dev/null +++ b/bin/cash/tests/execution/bg1.0 @@ -0,0 +1,3 @@ +# $FreeBSD: releng/12.0/bin/sh/tests/execution/bg1.0 221027 2011-04-25 20:54:12Z jilles $ + +: `false` & diff --git a/bin/cash/tests/execution/bg10.0 b/bin/cash/tests/execution/bg10.0 new file mode 100644 index 00000000..33256dc3 --- /dev/null +++ b/bin/cash/tests/execution/bg10.0 @@ -0,0 +1,4 @@ +# $FreeBSD: releng/12.0/bin/sh/tests/execution/bg10.0 258535 2013-11-24 23:12:13Z jilles $ +# The redirection overrides the /dev/null; { cat & wait; }' diff --git a/bin/cash/tests/execution/bg9.0 b/bin/cash/tests/execution/bg9.0 new file mode 100644 index 00000000..a759af7f --- /dev/null +++ b/bin/cash/tests/execution/bg9.0 @@ -0,0 +1,5 @@ +# $FreeBSD: releng/12.0/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; { cat & wait; }' diff --git a/bin/cash/tests/execution/fork1.0 b/bin/cash/tests/execution/fork1.0 new file mode 100644 index 00000000..4713d059 --- /dev/null +++ b/bin/cash/tests/execution/fork1.0 @@ -0,0 +1,10 @@ +# $FreeBSD: releng/12.0/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/cash/tests/execution/fork2.0 b/bin/cash/tests/execution/fork2.0 new file mode 100644 index 00000000..9cd64b61 --- /dev/null +++ b/bin/cash/tests/execution/fork2.0 @@ -0,0 +1,9 @@ +# $FreeBSD: releng/12.0/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/cash/tests/execution/fork3.0 b/bin/cash/tests/execution/fork3.0 new file mode 100644 index 00000000..3ed8cc5e --- /dev/null +++ b/bin/cash/tests/execution/fork3.0 @@ -0,0 +1,4 @@ +# $FreeBSD: releng/12.0/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/cash/tests/execution/func1.0 b/bin/cash/tests/execution/func1.0 new file mode 100644 index 00000000..990507f5 --- /dev/null +++ b/bin/cash/tests/execution/func1.0 @@ -0,0 +1,4 @@ +# $FreeBSD: releng/12.0/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/cash/tests/execution/func2.0 b/bin/cash/tests/execution/func2.0 new file mode 100644 index 00000000..4f00a30c --- /dev/null +++ b/bin/cash/tests/execution/func2.0 @@ -0,0 +1,12 @@ +# $FreeBSD: releng/12.0/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/cash/tests/execution/func3.0 b/bin/cash/tests/execution/func3.0 new file mode 100644 index 00000000..6ccb962e --- /dev/null +++ b/bin/cash/tests/execution/func3.0 @@ -0,0 +1,7 @@ +# $FreeBSD: releng/12.0/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/cash/tests/execution/hash1.0 b/bin/cash/tests/execution/hash1.0 new file mode 100644 index 00000000..dc4b41dd --- /dev/null +++ b/bin/cash/tests/execution/hash1.0 @@ -0,0 +1,12 @@ +# $FreeBSD: releng/12.0/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 <"$T/ls" +: +EOF +chmod 755 "$T/ls" +PATH=$PATH +ls -ld . diff --git a/bin/cash/tests/execution/int-cmd1.0 b/bin/cash/tests/execution/int-cmd1.0 new file mode 100644 index 00000000..517f2291 --- /dev/null +++ b/bin/cash/tests/execution/int-cmd1.0 @@ -0,0 +1,3 @@ +# $FreeBSD: releng/12.0/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/cash/tests/execution/killed1.0 b/bin/cash/tests/execution/killed1.0 new file mode 100644 index 00000000..25bc74a2 --- /dev/null +++ b/bin/cash/tests/execution/killed1.0 @@ -0,0 +1,8 @@ +# $FreeBSD: releng/12.0/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/cash/tests/execution/killed2.0 b/bin/cash/tests/execution/killed2.0 new file mode 100644 index 00000000..f9a67876 --- /dev/null +++ b/bin/cash/tests/execution/killed2.0 @@ -0,0 +1,10 @@ +# $FreeBSD: releng/12.0/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/cash/tests/execution/not1.0 b/bin/cash/tests/execution/not1.0 new file mode 100644 index 00000000..9b726f17 --- /dev/null +++ b/bin/cash/tests/execution/not1.0 @@ -0,0 +1,4 @@ +# $FreeBSD: releng/12.0/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/cash/tests/execution/not2.0 b/bin/cash/tests/execution/not2.0 new file mode 100644 index 00000000..57df141a --- /dev/null +++ b/bin/cash/tests/execution/not2.0 @@ -0,0 +1,6 @@ +# $FreeBSD: releng/12.0/bin/sh/tests/execution/not2.0 249407 2013-04-12 15:19:35Z jilles $ + +while :; do + ! break + exit 3 +done diff --git a/bin/cash/tests/execution/path1.0 b/bin/cash/tests/execution/path1.0 new file mode 100644 index 00000000..49540e0d --- /dev/null +++ b/bin/cash/tests/execution/path1.0 @@ -0,0 +1,15 @@ +# $FreeBSD: releng/12.0/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/cash/tests/execution/redir1.0 b/bin/cash/tests/execution/redir1.0 new file mode 100644 index 00000000..37e20df3 --- /dev/null +++ b/bin/cash/tests/execution/redir1.0 @@ -0,0 +1,27 @@ +# $FreeBSD: releng/12.0/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 fifo2 +} 3fifo1 +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/cash/tests/execution/redir2.0 b/bin/cash/tests/execution/redir2.0 new file mode 100644 index 00000000..af30fb09 --- /dev/null +++ b/bin/cash/tests/execution/redir2.0 @@ -0,0 +1,29 @@ +# $FreeBSD: releng/12.0/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 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/cash/tests/execution/redir3.0 b/bin/cash/tests/execution/redir3.0 new file mode 100644 index 00000000..d85369af --- /dev/null +++ b/bin/cash/tests/execution/redir3.0 @@ -0,0 +1,3 @@ +# $FreeBSD: releng/12.0/bin/sh/tests/execution/redir3.0 214289 2010-10-24 19:56:34Z jilles $ + +3>&- 3>&- diff --git a/bin/cash/tests/execution/redir4.0 b/bin/cash/tests/execution/redir4.0 new file mode 100644 index 00000000..9a41a577 --- /dev/null +++ b/bin/cash/tests/execution/redir4.0 @@ -0,0 +1,4 @@ +# $FreeBSD: releng/12.0/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/cash/tests/execution/redir5.0 b/bin/cash/tests/execution/redir5.0 new file mode 100644 index 00000000..6f316a0f --- /dev/null +++ b/bin/cash/tests/execution/redir5.0 @@ -0,0 +1,3 @@ +# $FreeBSD: releng/12.0/bin/sh/tests/execution/redir5.0 218325 2011-02-05 15:02:19Z jilles $ + +{ (echo bad) >/dev/null; } &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/cash/tests/execution/redir7.0 b/bin/cash/tests/execution/redir7.0 new file mode 100644 index 00000000..0f6671cd --- /dev/null +++ b/bin/cash/tests/execution/redir7.0 @@ -0,0 +1,21 @@ +# $FreeBSD: releng/12.0/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/cash/tests/execution/set-C1.0 b/bin/cash/tests/execution/set-C1.0 new file mode 100644 index 00000000..3aa64f17 --- /dev/null +++ b/bin/cash/tests/execution/set-C1.0 @@ -0,0 +1,12 @@ +# $FreeBSD: releng/12.0/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/cash/tests/execution/set-n1.0 b/bin/cash/tests/execution/set-n1.0 new file mode 100644 index 00000000..c1ee4c50 --- /dev/null +++ b/bin/cash/tests/execution/set-n1.0 @@ -0,0 +1,7 @@ +# $FreeBSD: releng/12.0/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/cash/tests/execution/set-n2.0 b/bin/cash/tests/execution/set-n2.0 new file mode 100644 index 00000000..80514cc9 --- /dev/null +++ b/bin/cash/tests/execution/set-n2.0 @@ -0,0 +1,5 @@ +# $FreeBSD: releng/12.0/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/cash/tests/execution/set-n3.0 b/bin/cash/tests/execution/set-n3.0 new file mode 100644 index 00000000..db9f164c --- /dev/null +++ b/bin/cash/tests/execution/set-n3.0 @@ -0,0 +1,4 @@ +# $FreeBSD: releng/12.0/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/cash/tests/execution/set-n4.0 b/bin/cash/tests/execution/set-n4.0 new file mode 100644 index 00000000..df562c0f --- /dev/null +++ b/bin/cash/tests/execution/set-n4.0 @@ -0,0 +1,3 @@ +# $FreeBSD: releng/12.0/bin/sh/tests/execution/set-n4.0 222676 2011-06-04 11:28:42Z jilles $ + +$SH -nc 'echo bad' diff --git a/bin/cash/tests/execution/set-x1.0 b/bin/cash/tests/execution/set-x1.0 new file mode 100644 index 00000000..65bb127c --- /dev/null +++ b/bin/cash/tests/execution/set-x1.0 @@ -0,0 +1,8 @@ +# $FreeBSD: releng/12.0/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/cash/tests/execution/set-x2.0 b/bin/cash/tests/execution/set-x2.0 new file mode 100644 index 00000000..6e2b939f --- /dev/null +++ b/bin/cash/tests/execution/set-x2.0 @@ -0,0 +1,9 @@ +# $FreeBSD: releng/12.0/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/cash/tests/execution/set-x3.0 b/bin/cash/tests/execution/set-x3.0 new file mode 100644 index 00000000..f10095db --- /dev/null +++ b/bin/cash/tests/execution/set-x3.0 @@ -0,0 +1,9 @@ +# $FreeBSD: releng/12.0/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/cash/tests/execution/set-x4.0 b/bin/cash/tests/execution/set-x4.0 new file mode 100644 index 00000000..98cb1e1b --- /dev/null +++ b/bin/cash/tests/execution/set-x4.0 @@ -0,0 +1,7 @@ +# $FreeBSD: releng/12.0/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/cash/tests/execution/shellproc1.0 b/bin/cash/tests/execution/shellproc1.0 new file mode 100644 index 00000000..f4168fb7 --- /dev/null +++ b/bin/cash/tests/execution/shellproc1.0 @@ -0,0 +1,11 @@ +# $FreeBSD: releng/12.0/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 <"$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/cash/tests/execution/subshell1.0 b/bin/cash/tests/execution/subshell1.0 new file mode 100644 index 00000000..b3e93283 --- /dev/null +++ b/bin/cash/tests/execution/subshell1.0 @@ -0,0 +1,6 @@ +# $FreeBSD: releng/12.0/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/cash/tests/execution/subshell1.0.stdout b/bin/cash/tests/execution/subshell1.0.stdout new file mode 100644 index 00000000..8c71af3c --- /dev/null +++ b/bin/cash/tests/execution/subshell1.0.stdout @@ -0,0 +1,2 @@ +100000 +end diff --git a/bin/cash/tests/execution/subshell2.0 b/bin/cash/tests/execution/subshell2.0 new file mode 100644 index 00000000..c20971d5 --- /dev/null +++ b/bin/cash/tests/execution/subshell2.0 @@ -0,0 +1,10 @@ +# $FreeBSD: releng/12.0/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/cash/tests/execution/subshell3.0 b/bin/cash/tests/execution/subshell3.0 new file mode 100644 index 00000000..31ba849f --- /dev/null +++ b/bin/cash/tests/execution/subshell3.0 @@ -0,0 +1,4 @@ +# $FreeBSD: releng/12.0/bin/sh/tests/execution/subshell3.0 245383 2013-01-13 19:39:13Z jilles $ + +(false; exit) && exit 3 +exit 0 diff --git a/bin/cash/tests/execution/subshell4.0 b/bin/cash/tests/execution/subshell4.0 new file mode 100644 index 00000000..488d6be7 --- /dev/null +++ b/bin/cash/tests/execution/subshell4.0 @@ -0,0 +1,3 @@ +# $FreeBSD: releng/12.0/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/cash/tests/execution/unknown1.0 b/bin/cash/tests/execution/unknown1.0 new file mode 100644 index 00000000..99d8c679 --- /dev/null +++ b/bin/cash/tests/execution/unknown1.0 @@ -0,0 +1,29 @@ +# $FreeBSD: releng/12.0/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/cash/tests/execution/var-assign1.0 b/bin/cash/tests/execution/var-assign1.0 new file mode 100644 index 00000000..1108a071 --- /dev/null +++ b/bin/cash/tests/execution/var-assign1.0 @@ -0,0 +1,3 @@ +# $FreeBSD: releng/12.0/bin/sh/tests/execution/var-assign1.0 212467 2010-09-11 14:15:50Z jilles $ + +[ "$(HOME=/etc HOME=/ cd && pwd)" = / ] -- cgit 1.4.1