From d4fc42052f99c5841b642f552f178320eab2731e Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Tue, 24 Sep 2013 14:15:59 +0800 Subject: discover/grub2: Support var=value assignments We want to allow assignments outside of the 'set' builtin. Signed-off-by: Jeremy Kerr --- discover/grub2/script.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'discover') 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]); -- cgit v1.2.1