1# $FreeBSD: head/bin/sh/tests/execution/shellproc2.0 356208 2019-12-30 21:32:55Z jilles $
2# This tests a quality of implementation issue.
3# Shells are not required to reject executing binary files as shell scripts
4# but executing, for example, ELF files for a different architecture as
5# shell scripts may have annoying side effects.
6
7T=`mktemp -d "${TMPDIR:-/tmp}/sh-test.XXXXXXXX"` || exit
8trap 'rm -rf "${T}"' 0
9printf '\0' >"$T/testshellproc"
10chmod 755 "$T/testshellproc"
11if [ ! -s "$T/testshellproc" ]; then
12	printf "printf did not write a NUL character\n" >&2
13	exit 2
14fi
15PATH=$T:$PATH
16errout=`testshellproc 3>&2 2>&1 >&3 3>&-`
17r=$?
18[ "$r" = 126 ] && [ -n "$errout" ]
19