[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] save_env variable_name=value
From: |
Colin Watson |
Subject: |
[PATCH] save_env variable_name=value |
Date: |
Wed, 2 Sep 2009 12:01:42 +0100 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
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 <address@hidden>
* 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 address@hidden
- [PATCH] save_env variable_name=value,
Colin Watson <=
- Re: [PATCH] save_env variable_name=value, Robert Millan, 2009/09/03
- Re: [PATCH] save_env variable_name=value, Colin Watson, 2009/09/03
- Re: [PATCH] save_env variable_name=value, Robert Millan, 2009/09/03
- Re: [PATCH] save_env variable_name=value, Pavel Roskin, 2009/09/11
- Re: [PATCH] save_env variable_name=value, Robert Millan, 2009/09/12
- Re: [PATCH] save_env variable_name=value, Colin Watson, 2009/09/12
- Re: [PATCH] save_env variable_name=value, address@hidden, 2009/09/12
- Re: [PATCH] save_env variable_name=value, Pavel Roskin, 2009/09/13