Hi all,

This tiny patch makes exported variables really global. Right now
exported variables are set in the context of a submenu when running it.
But any changes to those vars are lost when leaving the submenu. This
patch sets and exports all vars in the calling context for the submenu
which are exported in the context of the submenu.

This feature is needed in order to have submenus implementing something
like setting boot options like boot params, language setttings and the
like using environment variables.

Any comments? If it's OK any chance to be included?

Andreas
=== modified file 'grub-core/normal/context.c'
--- grub-core/normal/context.c  2012-03-01 21:43:03 +0000
+++ grub-core/normal/context.c  2012-03-04 13:51:28 +0000
@@ -126,6 +126,20 @@
 
       for (p = grub_current_context->vars[i]; p; p = q)
        {
+         if (p->global)
+           {
+             /* Set and export all global variables inside
+                the calling/previous context.  */
+             struct grub_env_context *tmp_context = grub_current_context;
+             grub_current_context = grub_current_context->prev;
+             if (grub_env_set (p->name, p->value) == GRUB_ERR_NONE)
+               {
+                 grub_env_export (p->name);
+                 grub_register_variable_hook (p->name, p->read_hook, 
p->write_hook);
+               }
+             grub_current_context = tmp_context;
+           }
+
          q = p->next;
           grub_free (p->name);
          grub_free (p->value);

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to