From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Minb6-0005w4-Qv for mharc-grub-devel@gnu.org; Wed, 02 Sep 2009 07:01:52 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Minb4-0005vt-Tj for grub-devel@gnu.org; Wed, 02 Sep 2009 07:01:50 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Minb0-0005v7-DL for grub-devel@gnu.org; Wed, 02 Sep 2009 07:01:50 -0400 Received: from [199.232.76.173] (port=56213 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Minb0-0005v4-9r for grub-devel@gnu.org; Wed, 02 Sep 2009 07:01:46 -0400 Received: from smarthost03.mail.zen.net.uk ([212.23.3.142]:60930) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Minaz-0006jl-PG for grub-devel@gnu.org; Wed, 02 Sep 2009 07:01:45 -0400 Received: from [82.69.40.219] (helo=riva.pelham.vpn.ucam.org) by smarthost03.mail.zen.net.uk with esmtp (Exim 4.63) (envelope-from ) id 1Minay-0007ra-9k for grub-devel@gnu.org; Wed, 02 Sep 2009 11:01:45 +0000 Received: from cjwatson by riva.pelham.vpn.ucam.org with local (Exim 3.36 #1 (Debian)) for grub-devel@gnu.org id 1Minaw-0000V6-00; Wed, 02 Sep 2009 12:01:42 +0100 Date: Wed, 2 Sep 2009 12:01:42 +0100 From: Colin Watson To: grub-devel@gnu.org Message-ID: <20090902110141.GR13423@riva.ucam.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) X-Originating-Smarthost03-IP: [82.69.40.219] X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: [PATCH] save_env variable_name=value X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2009 11:01:51 -0000 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 * 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]