From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1NHQ3M-0005TX-6O for mharc-grub-devel@gnu.org; Sun, 06 Dec 2009 17:58:08 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NHQ3K-0005S8-66 for grub-devel@gnu.org; Sun, 06 Dec 2009 17:58:06 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NHQ3F-0005Pa-I2 for grub-devel@gnu.org; Sun, 06 Dec 2009 17:58:05 -0500 Received: from [199.232.76.173] (port=37881 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NHQ3F-0005PU-DY for grub-devel@gnu.org; Sun, 06 Dec 2009 17:58:01 -0500 Received: from mail-fx0-f213.google.com ([209.85.220.213]:63936) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NHQ3F-00026a-6E for grub-devel@gnu.org; Sun, 06 Dec 2009 17:58:01 -0500 Received: by mail-fx0-f213.google.com with SMTP id 5so4123401fxm.8 for ; Sun, 06 Dec 2009 14:58:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :content-type; bh=jbMLsffuSsJone6GQ9rP2Eg4eJd6AaQr4sS3ifP/0m8=; b=qQHckDsVhmn0pHIy64HSpP30FEJvu8JZIuuu3sw4qWekuLsP0GfiSZuh66UjZd/bA/ 9Ej0EZhwXeH1U3+pxcTHlghpAPhcwN98tsBB8qkfkBt76QwQbgW1+uSrDrOQpmPB156A fvZY3ARfs0Hi5X0z0+WOqDKysbUF8xHzF0RUQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type; b=GXXZEG+UNYeEFZ3Ni3D7uvj6EzNEKOpupTnyXFthyL+ej8gPOdBPrNUQxGBTCRFmze jIs2r8oP3jMMnFaJBIKCSv5jfZHvbhBxpgB6AfS8C4sMKpLhPd5Ptkdjv2ZjfF0XZ4J1 yv9k3wy4sY9DcU9exLzESHiyLltG7BXWw2i58= Received: by 10.103.78.38 with SMTP id f38mr1888654mul.72.1260140280408; Sun, 06 Dec 2009 14:58:00 -0800 (PST) Received: from ?192.168.178.55? (p5B0CF695.dip.t-dialin.net [91.12.246.149]) by mx.google.com with ESMTPS id b9sm6265592mug.9.2009.12.06.14.57.59 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 06 Dec 2009 14:57:59 -0800 (PST) Message-ID: <4B1C36F6.1000504@googlemail.com> Date: Sun, 06 Dec 2009 23:57:58 +0100 From: Andreas Born User-Agent: Thunderbird 2.0.0.23 (X11/20090827) MIME-Version: 1.0 To: The development of GRUB 2 References: <4AD76CA5.3070102@googlemail.com> <20091015191618.GI28534@riva.ucam.org> <4AD77D60.6010207@googlemail.com> In-Reply-To: <4AD77D60.6010207@googlemail.com> Content-Type: multipart/mixed; boundary="------------070505010209020903020807" X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: Re: [PATCH] create variables when exporting them X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Dec 2009 22:58:06 -0000 This is a multi-part message in MIME format. --------------070505010209020903020807 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Same here. Nothing changed as of r1917 and I didn't get any further feedback either. I've attached a rediffed version, too. Andreas Born schrieb: > Here you go: > ChangeLog: > 2009-10-15 Andreas Born > > * kern/env.c (grub_env_export): Create nonexistent variables > before exporting. > > > The mixed indentation (tabs and spaces) in kern/env.c was a bit > confusing. > > Andreas > > Colin Watson schrieb: >> On Thu, Oct 15, 2009 at 08:40:37PM +0200, Andreas Born wrote: >> >>> This patch changes grub_env_export to create variables with empty >>> value, if necessary. >>> This makes it possible to export variables before actually >>> assigning them any value and is the way bash behaves. >>> >> >> This makes sense to me (although bash is "too big and too slow" and >> we'll never implement anything close to all of it, this is a pretty >> cheap way to reduce confusion due to differences), although probably for >> post-1.97. A couple of nits: >> >> >>> * kern/env.c (grub_env_export): Create inexistent variables >>> before exporting. >>> >> >> "nonexistent" >> >> >>> + if (! var) >>> + { >>> + if (grub_env_set (name, "") != GRUB_ERR_NONE) >>> + return grub_errno; >>> + var = grub_env_find (name); >>> + } >> >> GNU brace style involves indenting the braces as well, thus: >> >> if (! var) >> { >> if (grub_env_set (name, "") != GRUB_ERR_NONE) >> return grub_errno; >> var = grub_env_find (name); >> } >> > --------------070505010209020903020807 Content-Type: text/x-patch; name="export-create.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="export-create.diff" @@ -170,8 +171,13 @@ struct grub_env_var *var; var = grub_env_find (name); - if (var) - var->type = GRUB_ENV_VAR_GLOBAL; + if (! var) + { + if (grub_env_set (name, "") != GRUB_ERR_NONE) + return grub_errno; + var = grub_env_find (name); + } + var->type = GRUB_ENV_VAR_GLOBAL; return GRUB_ERR_NONE; } --------------070505010209020903020807--