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