NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/55585: /bin/sh -eu and unset parameters in heredocs



>Number:         55585
>Category:       bin
>Synopsis:       /bin/sh -eu and unset parameters in heredocs
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Aug 19 00:30:00 +0000 2020
>Originator:     silas_netbsd_gnats%nocafe.net@localhost
>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@localhost:/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:
	



Home | Main Index | Thread Index | Old Index