opnsense-src/bin/sh/tests/execution/shellproc4.0
Warner Losh d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00

13 lines
517 B
Text

# This tests a quality of implementation issue.
# Shells are not required to reject executing binary files as shell scripts
# but executing, for example, ELF files for a different architecture as
# shell scripts may have annoying side effects.
T=`mktemp -d "${TMPDIR:-/tmp}/sh-test.XXXXXXXX"` || exit
trap 'rm -rf "${T}"' 0
printf '\211PNG\015\012\032\012\0\0\0\015IHDR' >"$T/testshellproc"
chmod 755 "$T/testshellproc"
PATH=$T:$PATH
errout=`testshellproc 3>&2 2>&1 >&3 3>&-`
r=$?
[ "$r" = 126 ] && [ -n "$errout" ]