Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 26 Oct 2018 11:07:47 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 232201] sh(1): Using unset variables in here-doc with set -u does not cause the script to exit
Message-ID:  <bug-232201-227-h4W5xbmFK4@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-232201-227@https.bugs.freebsd.org/bugzilla/>
References:  <bug-232201-227@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D232201

Jilles Tjoelker <jilles@FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|New                         |Open
                 CC|                            |jilles@FreeBSD.org

--- Comment #1 from Jilles Tjoelker <jilles@FreeBSD.org> ---
Although dash is not necessarily a good reference (since it has various bugs
and shortcuts of itself), I checked this against bash --posix and ksh93 and=
 the
common behaviour seems to be that an expansion error in a here-document is
treated as a redirection error (so the redirected command is not executed a=
nd
for some types of command the shell aborts).

When I last changed here-document expansion in SVN r246288, I left the error
and side effect behaviour unchanged from what it was to minimize the risk of
breaking existing scripts.

A related test case:
sh -c 'd=3D/dev/null; : <"${d#$((a=3D1))}"; true <"${d#$((b=3D2))}"; /usr/b=
in/true
<"${d#$((c=3D3))}"; echo "a=3D$a b=3D$b c=3D$c"'

Most shells seem to agree that this should output a=3D1 b=3D2 c=3D3.

Bash (POSIX mode as well as default mode) has different behaviour between t=
rue
(keeps side effects) and /usr/bin/true (discards side effects). This seems
incorrect.

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-232201-227-h4W5xbmFK4>