All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] save_env variable_name=value
@ 2009-09-02 11:01 Colin Watson
  2009-09-03 14:33 ` Robert Millan
  0 siblings, 1 reply; 9+ messages in thread
From: Colin Watson @ 2009-09-02 11:01 UTC (permalink / raw)
  To: grub-devel

This implements saving an environment variable with a given value
without having to set that variable first, as suggested by Pavel here:

  http://lists.gnu.org/archive/html/grub-devel/2009-06/msg00190.html

2009-09-02  Colin Watson  <cjwatson@ubuntu.com>

	* commands/loadenv.c (grub_cmd_save_env): Allow an optional
	explicit value (`save_env variable_name=value').
	(GRUB_MOD_INIT (loadenv)): Update save_env summary.

Index: commands/loadenv.c
===================================================================
--- commands/loadenv.c	(revision 2558)
+++ commands/loadenv.c	(working copy)
@@ -351,18 +351,32 @@
 
   while (argc)
     {
-      char *value;
+      char *equals;
+      char *value = NULL;
 
-      value = grub_env_get (args[0]);
+      equals = grub_strchr (args[0], '=');
+      if (equals)
+        {
+          *equals = 0;
+          value = equals + 1;
+        }
+
+      if (! value)
+        value = grub_env_get (args[0]);
       if (value)
         {
           if (! grub_envblk_set (envblk, args[0], value))
             {
               grub_error (GRUB_ERR_BAD_ARGUMENT, "environment block too small");
+              if (equals)
+                *equals = '=';
               goto fail;
             }
         }
 
+      if (equals)
+        *equals = '=';
+
       argc--;
       args++;
     }
@@ -396,7 +410,7 @@
   cmd_save =
     grub_register_extcmd ("save_env", grub_cmd_save_env,
 			  GRUB_COMMAND_FLAG_BOTH,
-			  "save_env [-f FILE] variable_name [...]",
+			  "save_env [-f FILE] variable_name[=value] [...]",
 			  "Save variables to environment block file.",
 			  options);
 }

-- 
Colin Watson                                       [cjwatson@ubuntu.com]



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

end of thread, other threads:[~2009-09-13  5:14 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-02 11:01 [PATCH] save_env variable_name=value Colin Watson
2009-09-03 14:33 ` Robert Millan
2009-09-03 14:52   ` Colin Watson
2009-09-03 15:08     ` Robert Millan
2009-09-11 21:43       ` Pavel Roskin
2009-09-12  8:16         ` Colin Watson
2009-09-12 12:43         ` Robert Millan
2009-09-12 14:54         ` richardvoigt
2009-09-13  5:14           ` Pavel Roskin

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.