path: root/lib
diff options
authorSergey Poznyakoff <gray@gnu.org>2019-06-03 13:17:13 +0300
committerSergey Poznyakoff <gray@gnu.org>2019-06-03 13:41:34 +0300
commitf50a208f9df348cede2ba50b4f435351d8d3f19e (patch)
treec596fdf237b17713ab56c0269cdb1d339e306941 /lib
parent8004bbaa1b31b14dd4c4d3886b5f57b103bf7405 (diff)
Finish the env re-implementation
* NEWS: Document the "env" statement and the PIES_MASTER_PID environment variable. Version 1.3.91 * configure.ac: Version 1.3.91 * doc/pies.texi: Document the new "env" statement syntax. Provide instructions on how to convert legacy "env" statement to the new form. * lib/envop.c (environ_unset): Take reference value as argument. If supplied, unset the variable only if its value matches the reference one. * lib/envop.h (environ_unset): Change proto. * src/pies.c (parse_legacy_env): Minor changes. (_cb_env_unset): Allow to specify value. * src/progman.c (run_command): Define PIES_MASTER_PID. * tests/env.at: Check the legacy env syntax. * tests/envop.at: Additional checks.
Diffstat (limited to 'lib')
2 files changed, 11 insertions, 5 deletions
diff --git a/lib/envop.c b/lib/envop.c
index 79083f7..80a8b6c 100644
--- a/lib/envop.c
+++ b/lib/envop.c
@@ -173,7 +173,7 @@ environ_set (environ_t *env, char const *name, char const *value)
return -1;
if (!value)
- return environ_unset (env, name);
+ return environ_unset (env, name, value);
ws.ws_env = (char const **) env->env_base;
if (wordsplit (value, &ws,
@@ -218,18 +218,21 @@ environ_set (environ_t *env, char const *name, char const *value)
-environ_unset (environ_t *env, char const *name)
+environ_unset (environ_t *env, char const *name, char const *refval)
ssize_t n;
+ char *val;
if (!env || !name)
errno = EINVAL;
return -1;
- n = getenvind (env, name, NULL);
+ n = getenvind (env, name, &val);
if (n == -1)
return ENOENT;
+ if (refval && strcmp (val, refval))
+ return ENOENT;
free (env->env_base[n]);
memmove (env->env_base + n, env->env_base + n + 1,
@@ -457,7 +460,10 @@ envop_exec (struct envop_entry *op, environ_t *env)
case envop_unset:
- environ_unset_glob (env, op->name);
+ if (op->value)
+ environ_unset (env, op->name, op->value);
+ else
+ environ_unset_glob (env, op->name);
case envop_keep:
diff --git a/lib/envop.h b/lib/envop.h
index 054152e..82be3a5 100644
--- a/lib/envop.h
+++ b/lib/envop.h
@@ -27,7 +27,7 @@ environ_t *environ_create (char **);
void environ_free (environ_t *env);
int environ_add (environ_t *env, char const *def);
int environ_set (environ_t *env, char const *name, char const *val);
-int environ_unset (environ_t *env, char const *name);
+int environ_unset (environ_t *env, char const *name, char const *val);
int environ_unset_glob (environ_t *env, const char *pattern);
static inline char **
environ_ptr (environ_t *env)

Return to:

Send suggestions and report system problems to the System administrator.