summaryrefslogtreecommitdiffstats
path: root/discover
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2013-09-24 14:15:59 +0800
committerJeremy Kerr <jk@ozlabs.org>2013-09-24 16:16:20 +0800
commitd4fc42052f99c5841b642f552f178320eab2731e (patch)
tree365103efbdd5aaa44933f3f1741ebed71b2b7273 /discover
parent5b16418b30c17fa8c49d7a606bb8ab4bdec6f1a8 (diff)
downloadtalos-petitboot-d4fc42052f99c5841b642f552f178320eab2731e.tar.gz
talos-petitboot-d4fc42052f99c5841b642f552f178320eab2731e.zip
discover/grub2: Support var=value assignments
We want to allow assignments outside of the 'set' builtin. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'discover')
-rw-r--r--discover/grub2/script.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/discover/grub2/script.c b/discover/grub2/script.c
index 43259aa..3f5bc23 100644
--- a/discover/grub2/script.c
+++ b/discover/grub2/script.c
@@ -235,6 +235,7 @@ int statement_simple_execute(struct grub2_script *script,
{
struct grub2_statement_simple *st = to_stmt_simple(statement);
struct grub2_symtab_entry *entry;
+ char *pos;
int rc;
if (!st->argv)
@@ -245,6 +246,17 @@ int statement_simple_execute(struct grub2_script *script,
if (!st->argv->argc)
return 0;
+ /* is this a var=value assignment? */
+ pos = strchr(st->argv->argv[0], '=');
+ if (pos) {
+ char *name, *value;
+ name = st->argv->argv[0];
+ name = talloc_strndup(st, name, pos - name);
+ value = pos + 1;
+ script_env_set(script, name, value);
+ return 0;
+ }
+
entry = script_lookup_function(script, st->argv->argv[0]);
if (!entry) {
fprintf(stderr, "undefined function '%s'\n", st->argv->argv[0]);
OpenPOWER on IntegriCloud