aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2019-04-20 03:05:07 -0500
committerRob Landley <rob@landley.net>2019-04-20 03:05:07 -0500
commit543b2580c78c0f6ed12630d9e63a0420d37b8348 (patch)
tree50de120e5e4dfdfabbedb046cd633ee323e7c938 /lib
parent71c3f623c6011c923788f0770ad40fe2756893a7 (diff)
downloadtoybox-543b2580c78c0f6ed12630d9e63a0420d37b8348.tar.gz
Add xunsetenv() for the error checking.
Diffstat (limited to 'lib')
-rw-r--r--lib/env.c6
-rw-r--r--lib/lib.h1
2 files changed, 7 insertions, 0 deletions
diff --git a/lib/env.c b/lib/env.c
index 94ea0a4e..35ef688c 100644
--- a/lib/env.c
+++ b/lib/env.c
@@ -80,6 +80,12 @@ void xsetenv(char *name, char *val)
environ[i] = new;
}
+void xunsetenv(char *name)
+{
+ if (strchr(name, '=')) error_exit("xunsetenv %s name has =", name);
+ xsetenv(name, 0);
+}
+
// reset environment for a user, optionally clearing most of it
void reset_env(struct passwd *p, int clear)
{
diff --git a/lib/lib.h b/lib/lib.h
index 82c4c16e..7572a8a3 100644
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -275,6 +275,7 @@ int human_readable(char *buf, unsigned long long num, int style);
long environ_bytes();
void xsetenv(char *name, char *val);
+void xunsetenv(char *name);
void xclearenv(void);
// linestack.c