From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1NKc16-0005wK-Ks for mharc-grub-devel@gnu.org; Tue, 15 Dec 2009 13:21:00 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NKc14-0005uO-F5 for grub-devel@gnu.org; Tue, 15 Dec 2009 13:20:58 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NKc0z-0005nv-Hn for grub-devel@gnu.org; Tue, 15 Dec 2009 13:20:57 -0500 Received: from [199.232.76.173] (port=37628 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NKc0z-0005nZ-73 for grub-devel@gnu.org; Tue, 15 Dec 2009 13:20:53 -0500 Received: from mail-fx0-f225.google.com ([209.85.220.225]:52369) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NKc0y-0001MF-OI for grub-devel@gnu.org; Tue, 15 Dec 2009 13:20:53 -0500 Received: by fxm25 with SMTP id 25so159657fxm.26 for ; Tue, 15 Dec 2009 10:20:50 -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=b4rSrMY8wLhBl9M1dsVkyAIsLYCu9zQ9JiV+0jfATZ8=; b=uPJ2xV2IiVuA2efR5ILBDlWMdAyjGTsoeWy0eZ44NGWgV4N3msGvKPFq8T+AzPa854 gxtTecw2AZOVBajzokZdoY9ncLJuFG12Ehvp9qzkS7gtZV+MFOL/FIu1yb2P5XqKuFit kkM8tUlWL/fzRk+f+fBPxsm7MAft92pBsvFRk= 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=HmQtvjPaai/nLQKZw2ByR02avdM8BWFiVU07t66HBCzTfCQFkvtWBSkvTpqGH31Mji bQkIojm+hpr+YU1dA1L4tSk2aNJycsj2Ro8b37gKdWWPy0s40WRS29rmPl7m3UyFNF0Y EYPjLuVQh9kWXw00IGLoe0iW15iEvZ4jAzB+o= Received: by 10.223.94.201 with SMTP id a9mr1935683fan.13.1260901250540; Tue, 15 Dec 2009 10:20:50 -0800 (PST) Received: from ?192.168.178.55? (p5B0CE880.dip.t-dialin.net [91.12.232.128]) by mx.google.com with ESMTPS id 13sm41876fxm.1.2009.12.15.10.20.47 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 15 Dec 2009 10:20:48 -0800 (PST) Message-ID: <4B27D378.1080805@googlemail.com> Date: Tue, 15 Dec 2009 19:20:40 +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> <4B1C36F6.1000504@googlemail.com> In-Reply-To: <4B1C36F6.1000504@googlemail.com> Content-Type: multipart/mixed; boundary="------------000103020500020108000402" 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: Tue, 15 Dec 2009 18:20:58 -0000 This is a multi-part message in MIME format. --------------000103020500020108000402 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit I just noticed that I forgot the header line of the diff. Sorry for that. New double checked version attached. The Changelog is still: 2009-12-15 Andreas Born * kern/env.c (grub_env_export): Create nonexistent variables before exporting. Andreas Born schrieb: > 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); >>> } >> > --------------000103020500020108000402 Content-Type: text/x-patch; name="export-create.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="export-create.diff" === modified file 'kern/env.c' --- kern/env.c 2009-07-16 22:14:09 +0000 +++ kern/env.c 2009-11-29 00:15:05 +0000 @@ -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; } --------------000103020500020108000402--