diff options
-rw-r--r-- | NEWS | 16 | ||||
-rw-r--r-- | doc/pies.texi | 15 | ||||
-rw-r--r-- | src/comp.c | 2 | ||||
-rw-r--r-- | src/pies.c | 17 | ||||
-rw-r--r-- | src/piesctl.c | 2 | ||||
-rw-r--r-- | tests/env.at | 2 |
6 files changed, 26 insertions, 28 deletions
@@ -1,7 +1,7 @@ -GNU Pies NEWS -- history of user-visible changes. 2019-06-03 +GNU Pies NEWS -- history of user-visible changes. 2019-06-06 See the end of file for copying conditions. Please send Pies bug reports to <bug-pies@gnu.org> or <bug-pies@gnu.org.ua> Version 1.3.91 (git) @@ -40,18 +40,18 @@ contains redirections, pipes, etc. E.g. * New 'env' statement The 'env' statement has been re-implemented as a compound statement. It can contain the following sub-statements: -** clear yes +** clear Clears the environment ** keep NAME Keeps the variable NAME when clearing the environment. Implies -"clear yes". NAME can be a globbing pattern, in which case all +"clear". NAME can be a globbing pattern, in which case all variables matching the pattern are retained. ** set "NAME=VALUE" Sets the environment variable for the component. VALUE is subject to variable expansion. @@ -59,17 +59,17 @@ to variable expansion. Unsets the variable. NAME can be a globbing pattern, in which case all variables matching the pattern are unset. Example: env { - clear yes - keep PATH - keep MANPATH - keep "LC_*" - set "MANPATH=$MANPATH${MANPATH:+:}/usr/local/man" + clear; + keep PATH; + keep MANPATH; + keep "LC_*"; + set "MANPATH=$MANPATH${MANPATH:+:}/usr/local/man"; } * Legacy 'env' statement. Support for the old one-line syntax of "env" is retained for backward compatibility. diff --git a/doc/pies.texi b/doc/pies.texi index ccb9f0e..63064e5 100644 --- a/doc/pies.texi +++ b/doc/pies.texi @@ -1058,13 +1058,13 @@ modern compount syntax. @deffn {Config: component} env @{ ... @} The compound @code{env} statement has the following syntax: @example @group env @{ - clear @var{bool}; + clear; keep @var{pattern}; set "@var{name}=@var{value}"; unset @var{pattern}; @} @end group @end example @@ -1072,17 +1072,16 @@ env @{ Statements inside the @code{env} block define operations that modify the environment. The @code{clear} and @code{keep} statements are executed first. Then, the @code{set} and @code{unset} statements are applied in the order of their appearance in the configuration. -@deffn {env} clear @var{bool} -If @var{bool} is @samp{yes}, all environment variables will be cleared -(unset). The resulting environment will be empty, unless one or more -@code{keep} statements are also given (see below). The @code{clear} -statement is always executed first. +@deffn {env} clear +Clears the environment by removing (unsetting) all variables, except +those listed in @code{keep} statements, if such are given (see below). +The @code{clear} statement is always executed first. @end deffn @deffn {env} keep @var{pattern} Declares variables matching @var{pattern} (a globbing pattern) as exempt from clearing. This statement implies @code{clear}. @@ -1090,13 +1089,13 @@ For example, the following configuration fragment removes from the environment all variables except @samp{HOME}, @samp{USER}, @samp{PATH}, and variables beginning with @samp{LC_}: @example @group env @{ - clear yes; + clear; keep HOME; keep USER; keep PATH; keep "LC_*"; @} @end group @@ -1168,13 +1167,13 @@ word in @var{args}. The modern syntax equivalent is: @example @group env @{ - clear yes; + clear; @} @end group @end example @item -@var{name} Unset the environment variable @var{name}. The modern syntax @@ -739,13 +739,13 @@ component_finish (struct component *comp, grecs_locus_t *locus) if (!comp->command) { grecs_error (locus, 0, "%s", _("no 'command' statement")); component_free (comp); return; } - + if (comp->flags & CF_SHELL) { comp->argc = 3; comp->argv = grecs_calloc (comp->argc + 1, sizeof (comp->argv[0])); comp->argv[0] = grecs_strdup (comp->program ? comp->program : "/bin/sh"); comp->argv[1] = grecs_strdup ("-c"); @@ -727,23 +727,22 @@ _cb_env_clear (enum grecs_callback_command cmd, grecs_node_t *node, void *varptr, void *cb_data) { grecs_locus_t *locus = &node->locus; grecs_value_t *value = node->v.value; struct component *comp = varptr; - int clear; - if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING)) - return 1; - if (grecs_string_convert(&clear, grecs_type_bool, value->v.string, locus)) - return 1; - if (clear) + if (!GRECS_VALUE_EMPTY_P (value)) { - if (envop_entry_add (&comp->envop, envop_clear, NULL, NULL)) - grecs_error (locus, errno, "envop_entry_add"); + grecs_error (&value->locus, 0, "%s", _("unexpected argument")); + return 1; } + + if (envop_entry_add (&comp->envop, envop_clear, NULL, NULL)) + grecs_error (locus, errno, "envop_entry_add"); + return 0; } static int _cb_env_keep (enum grecs_callback_command cmd, grecs_node_t *node, @@ -1028,13 +1027,13 @@ static int _cb_socket_type (enum grecs_callback_command cmd, grecs_node_t *node, void *varptr, void *cb_data) { grecs_locus_t *locus = &node->locus; grecs_value_t *value = node->v.value; - + if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING)) return 1; if (str_to_socket_type (value->v.string, varptr)) grecs_error (locus, 0, _("bad socket type")); return 0; diff --git a/src/piesctl.c b/src/piesctl.c index 390ccfc..2e35aea 100644 --- a/src/piesctl.c +++ b/src/piesctl.c @@ -186,13 +186,13 @@ parse_config (void) node = grecs_find_node (tree, "/control/socket"); if (node) { if (grecs_assert_value_type (node->v.value, GRECS_TYPE_STRING, &node->locus)) exit (EX_CONFIG); - + if (pies_url_create (&client.url, node->v.value->v.string)) { grecs_error (&node->locus, 0, _("%s: cannot create URL: %s"), node->v.value->v.string, strerror (errno)); exit (EX_CONFIG); } diff --git a/tests/env.at b/tests/env.at index 430bf10..1c595de 100644 --- a/tests/env.at +++ b/tests/env.at @@ -33,13 +33,13 @@ AT_CLEANUP]) dnl ############################# dnl Start tests dnl ############################# AT_BANNER([Environment statement]) -ENVTEST([clear],[clear],[clear yes;],[]) +ENVTEST([clear],[clear],[clear;],[]) ENVTEST([keep],[keep],[keep "LC_*";], [LC_ALL="C" LC_CTYPE="C" LC_MESSAGES="C" LC_NUMERIC="C" |