aboutsummaryrefslogtreecommitdiff
path: root/src
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 /src
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 'src')
-rw-r--r--src/pies.c10
-rw-r--r--src/progman.c7
2 files changed, 12 insertions, 5 deletions
diff --git a/src/pies.c b/src/pies.c
index 2387cef..fe8d9b4 100644
--- a/src/pies.c
+++ b/src/pies.c
@@ -615,3 +615,3 @@ parse_legacy_env (char **argv, envop_t **envop)
mem = grecs_malloc (msize);
- snprintf (mem, msize, "${%s:-}${%s+%c}%s",
+ snprintf (mem, msize, "${%s:-}${%s:+%c}%s",
name, name, value[0], value + 1);
@@ -637,3 +637,3 @@ parse_legacy_env (char **argv, envop_t **envop)
mem = grecs_malloc (msize);
- snprintf (mem, msize, "%s${%s+%c}${%s:-}",
+ snprintf (mem, msize, "%s${%s:+%c}${%s:-}",
value, name, c, name);
@@ -787,2 +787,3 @@ _cb_env_unset (enum grecs_callback_command cmd,
struct component *comp = varptr;
+ char *p;
@@ -791,3 +792,6 @@ _cb_env_unset (enum grecs_callback_command cmd,
return 1;
- if (envop_entry_add (&comp->envop, envop_unset, value->v.string, NULL))
+ p = strchr (value->v.string, '=');
+ if (p)
+ *p++ = 0;
+ if (envop_entry_add (&comp->envop, envop_unset, value->v.string, p))
grecs_error (locus, errno, "envop_entry_add");
diff --git a/src/progman.c b/src/progman.c
index b75a2db..a6dc418 100644
--- a/src/progman.c
+++ b/src/progman.c
@@ -823,3 +823,3 @@ prog_start_prologue (struct prog *prog)
for (i = 0; sockenv_var[i]; i++)
- environ_unset (prog->v.p.env, sockenv_var[i]);
+ environ_unset (prog->v.p.env, sockenv_var[i], NULL);
}
@@ -1980,3 +1980,3 @@ run_command (struct action *act, struct prog *prog, unsigned retcode,
{
- pid_t pid;
+ pid_t pid, master_pid;
char *argv[4];
@@ -1984,2 +1984,4 @@ run_command (struct action *act, struct prog *prog, unsigned retcode,
+ master_pid = getpid ();
+
/* FIXME: optionally set output redirectors for this command? */
@@ -2000,2 +2002,3 @@ run_command (struct action *act, struct prog *prog, unsigned retcode,
setenv ("PIES_COMPONENT", prog_tag (prog), 1);
+ setenv ("PIES_MASTER_PID", umaxtostr (master_pid, buf), 1);
setenv ("PIES_PID", umaxtostr (child_pid, buf), 1);

Return to:

Send suggestions and report system problems to the System administrator.