All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Making exported variables really global
@ 2012-03-04 13:08 Andreas Vogel
  2012-03-04 13:18 ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 1 reply; 9+ messages in thread
From: Andreas Vogel @ 2012-03-04 13:08 UTC (permalink / raw)
  To: The development of GNU GRUB

[-- Attachment #1: Type: text/plain, Size: 578 bytes --]

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

[-- Attachment #2: 08-global_environ_vars.patch --]
[-- Type: text/plain, Size: 800 bytes --]

=== 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);


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-03-04 23:39 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-04 13:08 [PATCH] Making exported variables really global Andreas Vogel
2012-03-04 13:18 ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-03-04 13:47   ` Andreas Vogel
2012-03-04 14:10     ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-03-04 16:16       ` Andreas Vogel
2012-03-04 17:55         ` Andreas Vogel
2012-03-04 21:03           ` Andreas Born
2012-03-04 22:48             ` Andreas Vogel
2012-03-04 23:39               ` Andreas Born

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.