From cc298a11a131b162f291d6ee27ba1d7598a1b6c4 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Sun, 2 Jun 2019 07:40:11 +0300 Subject: 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/Makefile.am: 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): Remove. : New field. * src/prog.h (prog): 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/Makefile.am: Add new tests. * tests/testsuite.at: Add environment tests. * tests/envop.at: New file. * tests/envtest.c: New file. * tests/env.at: New file. * tests/redirect.at: Check first two lines of the output file. --- tests/Makefile.am | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests/Makefile.am') diff --git a/tests/Makefile.am b/tests/Makefile.am index 39899c8..419818b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -48,6 +48,8 @@ TESTSUITE_AT = \ testsuite.at\ control.at\ cyclic.at\ + env.at\ + envop.at\ respawn.at\ redirect.at\ ret-exec.at\ @@ -60,6 +62,15 @@ TESTSUITE_AT = \ TESTSUITE = $(srcdir)/testsuite M4=m4 +noinst_PROGRAMS = envtest +AM_CPPFLAGS = \ + -I$(top_srcdir)/lib\ + @GRECS_INCLUDES@ + +LDADD = \ + ../lib/libpies.a\ + @GRECS_LDADD@ + AUTOTEST = $(AUTOM4TE) --language=autotest $(TESTSUITE): package.m4 $(TESTSUITE_AT) $(AM_V_GEN)$(AUTOTEST) -I $(srcdir) testsuite.at -o $@.tmp -- cgit v1.2.1