[Bug 232201] sh(1): Using unset variables in here-doc with set -u does not cause the script to exit

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Fri Oct 12 12:49:14 UTC 2018


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=232201

            Bug ID: 232201
           Summary: sh(1): Using unset variables in here-doc with set -u
                    does not cause the script to exit
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs at FreeBSD.org
          Reporter: 0mp at FreeBSD.org

The output of sh(1) from the base and of dash from the ports (shells/dash) is
different.

Here's the script to reproduce this issue:

```
#! /bin/sh -

set -u

# Unset variable.
cat << EOF > /dev/null && echo ok || echo error
$unsetvar
EOF
```

Output of `sh test.sh`:

> testcase-2.sh: unsetvar: parameter not set
> ok

Output of `dash test.sh`:

> testcase-2.sh: 6: testcase-2.sh: unsetvar: parameter not set
> error

I'm running sh(1) from 12.0-ALPHA6 r338797 and dash 0.5.10.2 from ports.

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


More information about the freebsd-bugs mailing list