NetBSD Problem Report #55585

From silas_netbsd_gnats@nocafe.net  Wed Aug 19 00:25:15 2020
Return-Path: <silas_netbsd_gnats@nocafe.net>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 2E3FD1A9239
	for <gnats-bugs@gnats.NetBSD.org>; Wed, 19 Aug 2020 00:25:15 +0000 (UTC)
Message-Id: <20200819002502.6C4C721C5E@hope.nocafe.net>
Date: Tue, 18 Aug 2020 21:25:02 -0300 (-03)
From: silas_netbsd_gnats@nocafe.net
Reply-To: silas_netbsd_gnats@nocafe.net
To: gnats-bugs@NetBSD.org
Subject: /bin/sh -eu and unset parameters in heredocs
X-Send-Pr-Version: 3.95

>Number:         55585
>Category:       bin
>Synopsis:       /bin/sh -eu and unset parameters in heredocs
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kre
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Aug 19 00:30:00 +0000 2020
>Closed-Date:    Sat Jul 09 10:19:37 +0000 2022
>Last-Modified:  Sat Jul 09 10:19:37 +0000 2022
>Originator:     silas_netbsd_gnats@nocafe.net
>Release:        NetBSD 9.0
>Organization:

>Environment:
System: NetBSD hope 9.0 NetBSD 9.0 (GENERIC) #0: Fri Feb 14 00:06:28 UTC 2020 mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
I'm testing it on NetBSD 9.0, but the same happens for /bin/sh compiled from
HEAD as of 2020-08-17.

If /bin/sh has set -eu, it should fail when finding an unset variable inside a
heredoc that is treated like a double quoted string.  It warns about the unset
variable but it doesn't exit.

For future reference, kre's email to tech-userlevel@ on 2020-08-18:

> I think this is essentially the same issue as (the lowest
> possible priority) shell PR bin/53550, which has been waiting
> until some time when I am extremely bored and desperately
> seeking something to do ...
> 
> The issue isn't related to -e (as surprising as that may be, given
> that almost every time someone uses it, yet another issue is found)
> but that status from heredoc expansions gets lost.
> (...)
>How-To-Repeat:
$ cat /tmp/x.txt
set -eu
echo 1
cat <<EOF
$unset
EOF
echo 2

$ /bin/sh
1
/tmp/x.txt: unset: parameter not set
2

>Fix:


>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: bin-bug-people->kre
Responsible-Changed-By: kre@NetBSD.org
Responsible-Changed-When: Wed, 19 Aug 2020 15:48:20 +0000
Responsible-Changed-Why:
Mine.


State-Changed-From-To: open->closed
State-Changed-By: kre@NetBSD.org
State-Changed-When: Sat, 09 Jul 2022 10:19:37 +0000
State-Changed-Why:
This was fixed when PR bin/53550 was fixed, last November
(I just forgot that this PR meeded closing along with that one).


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.