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