aboutsummaryrefslogtreecommitdiff
path: root/src/pies.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2019-06-07 08:00:32 +0300
committerSergey Poznyakoff <gray@gnu.org>2019-06-07 08:00:32 +0300
commitc33922f128403f5d05d24f19abeaad2368ce5467 (patch)
tree89ffecf0abbb4fedca962da0b79f0f850179e09f /src/pies.c
parentcc533e2c6b86b62db169f912b4e7891273061c77 (diff)
downloadpies-c33922f128403f5d05d24f19abeaad2368ce5467.tar.gz
pies-c33922f128403f5d05d24f19abeaad2368ce5467.tar.bz2
Implement additional env.eval statement
Diffstat (limited to 'src/pies.c')
-rw-r--r--src/pies.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/pies.c b/src/pies.c
index 1f5fb8f..73d33a0 100644
--- a/src/pies.c
+++ b/src/pies.c
@@ -786,6 +786,22 @@ _cb_env_set (enum grecs_callback_command cmd,
}
static int
+_cb_env_eval (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;
+
+ if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING))
+ return 1;
+ if (envop_entry_add (&comp->envop, envop_set, NULL, value->v.string))
+ grecs_error (locus, errno, "envop_entry_add");
+ return 0;
+}
+
+static int
_cb_env_unset (enum grecs_callback_command cmd,
grecs_node_t *node,
void *varptr, void *cb_data)
@@ -825,6 +841,12 @@ struct grecs_keyword cb_env_keywords[] = {
grecs_type_string, GRECS_DFLT,
NULL, 0,
_cb_env_set },
+ { "eval",
+ N_("string"),
+ N_("Evaluate string. Useful for side-effects, e.g. eval ${X:=2}."),
+ grecs_type_string, GRECS_DFLT,
+ NULL, 0,
+ _cb_env_eval },
{ "unset",
N_("name"),
N_("Unset environment variable. Name can contain wildcards."),

Return to:

Send suggestions and report system problems to the System administrator.