aboutsummaryrefslogtreecommitdiff
path: root/lib/envop.c
diff options
context:
space:
mode:
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/envop.c
parent8004bbaa1b31b14dd4c4d3886b5f57b103bf7405 (diff)
downloadpies-f50a208f9df348cede2ba50b4f435351d8d3f19e.tar.gz
pies-f50a208f9df348cede2ba50b4f435351d8d3f19e.tar.bz2
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/envop.c')
-rw-r--r--lib/envop.c14
1 files changed, 10 insertions, 4 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)
}
int
-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)
break;
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);
break;
case envop_keep:

Return to:

Send suggestions and report system problems to the System administrator.