From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1NGg87-000636-85 for mharc-grub-devel@gnu.org; Fri, 04 Dec 2009 16:55:59 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NGg84-0005zR-VF for grub-devel@gnu.org; Fri, 04 Dec 2009 16:55:57 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NGg80-0005sM-9N for grub-devel@gnu.org; Fri, 04 Dec 2009 16:55:56 -0500 Received: from [199.232.76.173] (port=50124 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NGg80-0005sG-5N for grub-devel@gnu.org; Fri, 04 Dec 2009 16:55:52 -0500 Received: from 197.red-80-32-81.staticip.rima-tde.net ([80.32.81.197]:35108 helo=mail.pina.cat) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NGg7z-0008VH-2J for grub-devel@gnu.org; Fri, 04 Dec 2009 16:55:51 -0500 Received: from pinux (82-45-164-87.cable.ubr06.hari.blueyonder.co.uk [82.45.164.87]) by mail.pina.cat (Postfix) with ESMTP id 45C01288FBA11 for ; Fri, 4 Dec 2009 22:55:49 +0100 (CET) Received: by pinux (Postfix, from userid 1000) id BBA93FC44; Fri, 4 Dec 2009 21:55:58 +0000 (GMT) Date: Fri, 4 Dec 2009 21:55:58 +0000 From: Carles Pina i Estany To: The development of GNU GRUB Message-ID: <20091204215558.GA13421@pina.cat> References: <20091129183936.GB19323@pina.cat> <20091204212100.GK1528@thorin> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="PNTmBPCT7hxwcZjr" Content-Disposition: inline In-Reply-To: <20091204212100.GK1528@thorin> User-Agent: Mutt/1.5.20 (2009-06-14) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: Re: var=foo should be valid? 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: Fri, 04 Dec 2009 21:55:57 -0000 --PNTmBPCT7hxwcZjr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, On Dec/04/2009, Robert Millan wrote: > On Sun, Nov 29, 2009 at 06:39:36PM +0000, Carles Pina i Estany wrote: > > (first one has a bug but very easy to fix, even thought I would maybe > > refactor this code to implement in other way) > > Can you give more details about this bug and the refactor that would be > needed? Find attached the simple patch (without refactoring) (it resets grub_errno _before_ grub_env_set, because grub_env_set calls the hooked functions). The refactoring would be in file script/execute.c, function grub_script_execute_cmdline. See the attached file set_refactor.patch for the idea. It's more work/things in Grub but I think that more robust since now will be the same code using set or without using set. Of course, maybe this extra-complexity is not needed. I have not looked into the Grub parser: maybe the extra-best place to implement it it's there, but I'm not familiar with Lex/Yacc/Bison/... . Cheers, -- Carles Pina i Estany http://pinux.info --PNTmBPCT7hxwcZjr Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="set_simple.patch" === modified file 'script/execute.c' --- script/execute.c 2009-11-23 15:37:33 +0000 +++ script/execute.c 2009-12-04 21:43:28 +0000 @@ -116,10 +116,11 @@ grub_script_execute_cmdline (struct grub /* Create two strings and set the variable. */ *eq = '\0'; eq++; - grub_env_set (assign, eq); /* This was set because the command was not found. */ grub_errno = GRUB_ERR_NONE; + + grub_env_set (assign, eq); } grub_free (assign); --PNTmBPCT7hxwcZjr Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="set_refactor.patch" === modified file 'script/execute.c' --- script/execute.c 2009-11-23 15:37:33 +0000 +++ script/execute.c 2009-12-04 21:51:41 +0000 @@ -113,13 +113,15 @@ grub_script_execute_cmdline (struct grub if (eq) { - /* Create two strings and set the variable. */ - *eq = '\0'; - eq++; - grub_env_set (assign, eq); - - /* This was set because the command was not found. */ - grub_errno = GRUB_ERR_NONE; + // TODO + // New Command Line Function = set + // New arguments = Old Command Line Function concatenate Old arguments + // Call grub_script_execute_cmdline (newCmd) + // + // So if before user typed a=b we call recursively: + // set a=b + // + // Alternatively: Don't need to check for "=" } grub_free (assign); --PNTmBPCT7hxwcZjr--