diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2019-06-03 13:17:13 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2019-06-03 13:41:34 +0300 |
commit | f50a208f9df348cede2ba50b4f435351d8d3f19e (patch) | |
tree | c596fdf237b17713ab56c0269cdb1d339e306941 /src | |
parent | 8004bbaa1b31b14dd4c4d3886b5f57b103bf7405 (diff) | |
download | pies-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.c | 10 | ||||
-rw-r--r-- | src/progman.c | 7 |
2 files changed, 12 insertions, 5 deletions
@@ -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); |