All of lore.kernel.org
 help / color / mirror / Atom feed
From: Carles Pina i Estany <carles@pina.cat>
To: The development of GNU GRUB <grub-devel@gnu.org>
Subject: Re: var=foo should be valid?
Date: Fri, 4 Dec 2009 21:55:58 +0000	[thread overview]
Message-ID: <20091204215558.GA13421@pina.cat> (raw)
In-Reply-To: <20091204212100.GK1528@thorin>

[-- Attachment #1: Type: text/plain, Size: 999 bytes --]


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

[-- Attachment #2: set_simple.patch --]
[-- Type: text/x-diff, Size: 492 bytes --]

=== 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);
 


[-- Attachment #3: set_refactor.patch --]
[-- Type: text/x-diff, Size: 824 bytes --]

=== 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);
 


  reply	other threads:[~2009-12-04 21:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-29 18:39 var=foo should be valid? Carles Pina i Estany
2009-11-29 18:45 ` Carles Pina i Estany
2009-11-29 18:50   ` Carles Pina i Estany
2009-11-30  9:39   ` Colin Watson
2009-11-30 13:48     ` Carles Pina i Estany
2009-12-04 21:16     ` Robert Millan
2009-12-04 21:21 ` Robert Millan
2009-12-04 21:55   ` Carles Pina i Estany [this message]
2009-12-12  0:04     ` Carles Pina i Estany
2009-12-13 12:45       ` Carles Pina i Estany

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091204215558.GA13421@pina.cat \
    --to=carles@pina.cat \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.