[Bug 293212] bin/sh does not set exitstatus for heredoc expansion errors

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 16 Feb 2026 16:07:28 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=293212

            Bug ID: 293212
           Summary: bin/sh does not set exitstatus for heredoc expansion
                    errors
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: bdrewery@FreeBSD.org
                CC: jilles@FreeBSD.org

```
#! /bin/sh
cat <<EOF
echo "${EMPTY:?}"
EOF
ret=$?
echo $ret
exit $ret
```

Exit statuses:

- sh: 0
- dash: 2
- zsh: 1
- bash: 1

All print `wtf.sh: line 7: EMPTY: parameter null or not set` but /bin/sh does
not set exitstatus to non-0 and does not trigger `set -e`.

-- 
You are receiving this mail because:
You are the assignee for the bug.