path: root/src/comp.c
authorSergey Poznyakoff <>2019-06-02 04:40:11 (GMT)
committer Sergey Poznyakoff <>2019-06-02 05:03:16 (GMT)
commitcc298a11a131b162f291d6ee27ba1d7598a1b6c4 (patch) (side-by-side diff)
tree4d82a9a5da05fbfdce0c9bf03e605ecf00baa07a /src/comp.c
parent1f28935841a69aa8be7eb2e88f580df9c95206d2 (diff)
New configuration statement for manipulating the environment.
The "env" statement is now a compound statement. It can contain four substatements: "clear" to clear the environment, "keep" to retain certain variable while clearing it, "set" to set a variable, and "unset" to unset a variable or variables. Both "keep" and "unset" can take globbing pattern as their argument, in which case they affect all variable matching that pattern. The value part in the "set" statement is subject to variable expansion, e.g. set "MANPATH=$MANPATH${MANPATH:+:}/usr/local/man" The support for the old one-line syntax of "env" is retained for backward compatibility. This commit also fixes redirection to a file: new data are appended to the file, instead of overwriting it. * lib/ Add new files. * lib/envop.c: New file. * lib/envop.h: New file. * lib/wildmatch.c: New file. * src/comp.c (component_free): Update. * src/pies.c (argv_free): New function. (parse_legacy_env): New function. (_cb_env): Remove. (cb_env_section_parser): New function. (cb_env_keywords): New keywords for the "env" block statement: clear, keep, set, unset. (component_keywords): New compount statement: env. Old usage retained for backward compatibility. * src/pies.h: Include "envop.h" (component)<env>: Remove. <envop>: New field. * src/prog.h (prog)<env>: New field. * src/progman.c (redirect_to_file): Position to the end of file. (DEBUG_ENVIRON): Remove macro. (debug_environ): New function. (environ_setup): Remove. (prog_sockenv): Use environ_set to modify local copy of environment. (prog_start_prologue): Use environ_create + envop_exec to create and modify the environment. (prog_execute): Set environment to prog-local copy. * tests/.gitignore: Build envtest * tests/ Add new tests. * tests/ Add environment tests. * tests/ New file. * tests/envtest.c: New file. * tests/ New file. * tests/ Check first two lines of the output file.
Diffstat (limited to 'src/comp.c') (more/less context) (ignore whitespace changes)
1 files changed, 2 insertions, 14 deletions
diff --git a/src/comp.c b/src/comp.c
index 499dfe5..d030979 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -166,24 +166,12 @@ component_create (const char *name)
component_free (struct component *comp)
- size_t i;
component_unlink (comp);
free (comp->tag);
free (comp->program);
free (comp->command);
- if (comp->argv)
- {
- for (i = 0; i < comp->argc; i++)
- free (comp->argv[i]);
- free (comp->argv);
- }
- if (comp->env)
- {
- for (i = 0; comp->env[i]; i++)
- free (comp->env[i]);
- free (comp->env);
- }
+ argv_free (comp->argv);
+ envop_free (comp->envop);
free (comp->dir);
grecs_list_free (comp->prereq);
grecs_list_free (comp->depend);

Return to:

Send suggestions and report system problems to the System administrator.