From: Andreas Vogel <Andreas.Vogel@anvo-it.de>
To: The development of GNU GRUB <grub-devel@gnu.org>
Subject: [PATCH] Making exported variables really global
Date: Sun, 04 Mar 2012 14:08:17 +0100 [thread overview]
Message-ID: <4F536941.8070805@anvo-it.de> (raw)
[-- 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);
next reply other threads:[~2012-03-04 13:08 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-04 13:08 Andreas Vogel [this message]
2012-03-04 13:18 ` [PATCH] Making exported variables really global 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F536941.8070805@anvo-it.de \
--to=andreas.vogel@anvo-it.de \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.