From 56f33d07ce1976b1565f6680b83eaa9e1bcea9e5 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Thu, 3 Jan 2019 20:22:35 +0000 Subject: [PATCH] sh: Do not place exported but unset variables into the environment PR: 233545 Submitted by: Jan Beich Obtained from: NetBSD --- bin/sh/var.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/sh/var.c b/bin/sh/var.c index 42f9556aad7b..0758289151ba 100644 --- a/bin/sh/var.c +++ b/bin/sh/var.c @@ -558,13 +558,13 @@ environment(void) nenv = 0; for (vpp = vartab ; vpp < vartab + VTABSIZE ; vpp++) { for (vp = *vpp ; vp ; vp = vp->next) - if (vp->flags & VEXPORT) + if ((vp->flags & (VEXPORT|VUNSET)) == VEXPORT) nenv++; } ep = env = stalloc((nenv + 1) * sizeof *env); for (vpp = vartab ; vpp < vartab + VTABSIZE ; vpp++) { for (vp = *vpp ; vp ; vp = vp->next) - if (vp->flags & VEXPORT) + if ((vp->flags & (VEXPORT|VUNSET)) == VEXPORT) *ep++ = vp->text; } *ep = NULL;