From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1MyWMs-0004Xl-R1 for mharc-grub-devel@gnu.org; Thu, 15 Oct 2009 15:52:10 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MyWMp-0004WP-LA for grub-devel@gnu.org; Thu, 15 Oct 2009 15:52:07 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MyWMm-0004V7-CY for grub-devel@gnu.org; Thu, 15 Oct 2009 15:52:05 -0400 Received: from [199.232.76.173] (port=49282 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MyWMm-0004V4-7s for grub-devel@gnu.org; Thu, 15 Oct 2009 15:52:04 -0400 Received: from fg-out-1718.google.com ([72.14.220.153]:65413) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MyWMl-0003Wr-OS for grub-devel@gnu.org; Thu, 15 Oct 2009 15:52:03 -0400 Received: by fg-out-1718.google.com with SMTP id e21so996325fga.12 for ; Thu, 15 Oct 2009 12:52:02 -0700 (PDT) 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=XGUW2r3x/cF4YgIdNtBHIM/AKWpMMpolxdYV+r7nlVs=; b=cwaUSHwKyi4qB0KJkCqVRNbvMJImzn5mTwLl8IBGeWcCBweK7aatFuyBfdTSvFcVqw JrsXfrxHuu5VWqDYnWpBud+7zxzkXgCoF2GRVD/UNcHHtmL+/evErv5Mg23ExbeXeu7+ xcd/2oUimwN0Qpbzt3RT5hCQMWtV7MJsZh7JU= 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=eJFypw9PQjlEMxFIOGKbO9trRnAxlqbSj5lKRPIQLcL3N9k6eEVcK4RZEFJWBnHSBL REh7QIZZH8a3mrFtV1Wo1Lsh5N8J+krWwlG9IXT0GUVum2h5pH30ROuZ00kwMPwCI7Eq cV1LBxI0aJl8tI67GOhV+4nSyOWUB5DHWFuNc= Received: by 10.86.227.13 with SMTP id z13mr564365fgg.72.1255636322802; Thu, 15 Oct 2009 12:52:02 -0700 (PDT) Received: from ?192.168.178.55? (p5B0CEA32.dip.t-dialin.net [91.12.234.50]) by mx.google.com with ESMTPS id l19sm1081138fgb.16.2009.10.15.12.52.01 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 15 Oct 2009 12:52:01 -0700 (PDT) Message-ID: <4AD77D60.6010207@googlemail.com> Date: Thu, 15 Oct 2009 21:52:00 +0200 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> In-Reply-To: <20091015191618.GI28534@riva.ucam.org> Content-Type: multipart/mixed; boundary="------------040804000001040201000700" 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 GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Oct 2009 19:52:08 -0000 This is a multi-part message in MIME format. --------------040804000001040201000700 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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); > } > > --------------040804000001040201000700 Content-Type: text/x-patch; name="export-create.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="export-create.diff" Index: kern/env.c =================================================================== --- kern/env.c (Revision 2631) +++ kern/env.c (Arbeitskopie) @@ -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; } --------------040804000001040201000700--