Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1EWK7W-0003Ci-Dv for mharc-grub-devel@gnu.org; Sun, 30 Oct 2005 15:49:38 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EWK7U-0003Bg-W7 for grub-devel@gnu.org; Sun, 30 Oct 2005 15:49:37 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EWK7U-0003B2-5L for grub-devel@gnu.org; Sun, 30 Oct 2005 15:49:36 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EWK7T-0003Aj-Rt for grub-devel@gnu.org; Sun, 30 Oct 2005 15:49:36 -0500 Received: from [209.86.89.61] (helo=smtpauth01.mail.atl.earthlink.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EWK7T-0007D8-Ug for grub-devel@gnu.org; Sun, 30 Oct 2005 15:49:36 -0500 Received: from [63.246.184.80] (helo=[192.168.0.101]) by smtpauth01.mail.atl.earthlink.net with asmtp (Exim 4.34) id 1EWK7R-0002iP-Uq for grub-devel@gnu.org; Sun, 30 Oct 2005 15:49:34 -0500 Mime-Version: 1.0 (Apple Message framework v623) In-Reply-To: <87u0f0t30k.fsf@student.han.nl> References: <87u0f0t30k.fsf@student.han.nl> Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: Content-Transfer-Encoding: 7bit From: Hollis Blanchard Date: Sun, 30 Oct 2005 14:49:31 -0600 To: The development of GRUB 2 X-Mailer: Apple Mail (2.623) X-ELNK-Trace: 77a46389d001b1f223bcf3e39c2f8b5f1aa676d7e74259b7b3291a7d08dfec79089d70ceffe6969105b6090d06d01f8f350badd9bab72f9c350badd9bab72f9c X-Originating-IP: 63.246.184.80 Subject: Re: Scripting support (PATCH) 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: Sun, 30 Oct 2005 20:49:37 -0000 I don't have many comments, since I'm not familiar with lexing and parsing. Just a couple small comments: On Oct 29, 2005, at 4:41 PM, Marco Gerards wrote: > > `if' accepts any command. I showed the example of using the `[' > command. It can be made similar to the `[' command of coreutils. > This command sets the environment variable `RESULT' to either 0 or 1. > After execution `if' checks `RESULT' and either executes the `if' or > the `else' branch. It would also be possible to use a return value > instead of `RESULT', but that was too much trouble for me at first. > But of course this can be changed if someone can convince me of that. You want it to be "$RESULT" instead of "$?" ? I really don't like that each command has to explicitly set RESULT. As you note, it would be better if the return code from the command were automatically placed into the status environment variable. > +#ifdef GRUB_UTIL > +void > +grub_lsb_init (void) > +{ > + grub_register_command ("[", grub_cmd_lsb, GRUB_COMMAND_FLAG_CMDLINE, > + "[ EXPRESSION ]", "Evaluate an expression", 0); > +} > + > +void > +grub_lsb_fini (void) > +{ > + grub_unregister_command ("["); > +} > +#else /* ! GRUB_UTIL */ > +GRUB_MOD_INIT > +{ > + (void)mod; /* To stop warning. */ > + grub_register_command ("[", grub_cmd_lsb, GRUB_COMMAND_FLAG_CMDLINE, > + "[ EXPRESSION ]", "Evaluate an expression", 0); > +} > + > +GRUB_MOD_FINI > +{ > + grub_unregister_command ("["); > +} > +#endif /* ! GRUB_UTIL */ We *really* need to redefine GRUB_MOD_INIT/FINI to remove all this duplicated code. I guess I will add that to my list. > +/* A part of an argument. */ > +struct grub_script_arg > +{ > + /* If this is 0, STR is a string. If it is one, STR is a variable > + name. */ > + int type; This should probably be an enum. Since this code won't break any existing behavior (simple "ls (hd,0)/" will still work, right?), I guess it can be committed as soon as serious issues like the memory leak have been fixed. -Hollis