]> git.ozlabs.org Git - petitboot/commitdiff
discover/grub2: Support var=value assignments
authorJeremy Kerr <jk@ozlabs.org>
Tue, 24 Sep 2013 06:15:59 +0000 (14:15 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Tue, 24 Sep 2013 08:16:20 +0000 (16:16 +0800)
We want to allow assignments outside of the 'set' builtin.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
discover/grub2/script.c

index 43259aafa304fb973ed0989a10a4ac36dd8b3b00..3f5bc236a66911fb54111a8ec7d3916c68454cca 100644 (file)
@@ -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]);