From bd7c5c0555477d562bc7a4dab9561017a47b615e Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 2 May 2019 18:41:11 -0700 Subject: env: fix case where a variable is replaced. Found when trying to update the toybox prebuilt used for the Android build. Also add the corresponding test. --- lib/env.c | 4 +--- tests/env.test | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/env.c b/lib/env.c index 35ef688c..bc23b753 100644 --- a/lib/env.c +++ b/lib/env.c @@ -58,11 +58,9 @@ void xsetenv(char *name, char *val) if (!memcmp(name, environ[i], len) && environ[i][len]=='=') { if (i>=envc) free(environ[i]); else { - char **delete = environ+i; - // move old entries down, add at end of old data toys.envc = envc--; - for (i=0; new ? i /dev/null ; echo $?' "125\n" "" "" testcmd "why is this allowed" "=BLAH env | grep '^=BLAH\$'" "=BLAH\n" "" "" + +testcmd "replace" "A=foo PATH= `which printenv` A" "foo\n" "" "" -- cgit v1.2.3