From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1ETKz8-0002ya-Hq for mharc-grub-devel@gnu.org; Sat, 22 Oct 2005 11:08:38 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ETKz5-0002xo-Lk for grub-devel@gnu.org; Sat, 22 Oct 2005 11:08:36 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ETKz2-0002wd-0v for grub-devel@gnu.org; Sat, 22 Oct 2005 11:08:34 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ETKz1-0002wX-PE for grub-devel@gnu.org; Sat, 22 Oct 2005 11:08:31 -0400 Received: from [145.74.66.11] (helo=mail-cn.han.nl) by monty-python.gnu.org with esmtp (Exim 4.34) id 1ETKz0-0000K6-4j for grub-devel@gnu.org; Sat, 22 Oct 2005 11:08:30 -0400 Received: from vscan-cn.han.nl (venus.han.nl [145.74.65.6]) by mail-cn.han.nl (Postfix) with ESMTP id 0D18786EB for ; Sat, 22 Oct 2005 17:08:28 +0200 (CEST) Received: from mail-cn.han.nl ([145.74.66.11]) by vscan-cn.han.nl (venus.han.nl [145.74.65.6]) (amavisd-new, port 10024) with ESMTP id 30934-05 for ; Sat, 22 Oct 2005 17:08:26 +0200 (CEST) Received: from mail1.han.nl (mail1.han.nl [145.74.103.11]) by mail-cn.han.nl (Postfix) with ESMTP id 20F6F84C8 for ; Sat, 22 Oct 2005 17:08:26 +0200 (CEST) Received: from localhost.localdomain (mgerards.xs4all.nl [82.92.27.129]) by mail1.han.nl (Postfix) with ESMTP id CFB8DC046 for ; Sat, 22 Oct 2005 17:08:25 +0200 (CEST) Mail-Copies-To: metgerards@student.han.nl To: The development of GRUB 2 References: <87pspxtzyu.fsf@student.han.nl> <435A50BE.5030801@gmail.com> From: Marco Gerards Date: Sat, 22 Oct 2005 17:08:26 +0200 In-Reply-To: <435A50BE.5030801@gmail.com> (Vladimir Serbinenko's message of "Sat, 22 Oct 2005 16:46:22 +0200") Message-ID: <87hdb9twr9.fsf@student.han.nl> User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new (2.2.0) at vscan-cn.han.nl Subject: Re: Scripting support 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: Sat, 22 Oct 2005 15:08:36 -0000 Vladimir Serbinenko writes: Hi Vladimir, >>Last days I have been thinking about scripting support. With my last >>patch it should be easy to implement. I hope Vladimir is still >>interested in this. >> >> > Yes. Exactly now I'm on holiday so I have a lot of time. And also I > have some ideas for some new GRUB features but theese features aren't > useful without scripting so I'm interested more than ever. Nice. >>The most important is the general design. I think we shouldn't put >>too much in the core and not even in normal mode. This is the same >>approach bash has taken. I think the core functionality should be: >> >>- variables (we have that) >>- functions >> Functions should work *exactly* like normal GRUB commands. In >> that case we can easily mix GRUB commands and functions. >> >> > In bash when you define a function it appears under environment > variables. IMHO it's useless to store completely the source code as an > environment variables. I propose that the functions will be preparsed > (converted to internal format ready for execution) because it will > gretelya simplify lexer and parser Right. We should discuss the internal format on the list, I think. >>- Return values >> All commands should be able to return a value. That's also what >> bash has. This value can be stored in a variable or simply >> returned, I am not too sure about that. Just check what bash >> does. >> >> > Could it be merged with error variable. It's what bash does Ok. >>- Conditional statements like if and case >>- loops: until, while and for >> >> >> > I propose the following argorithm. Bison parser transforms the > text-form to internal form of a linked list of commands with some > special commands like jump if last value was true, ... . Think about > assembler. Then it's executed by simple engine that works like CPU: it > takes one command from a linked list. Executes it and changes the > pointer so it points to the next command. A command is a structure > containing: > variable showing it's type (normal command, jump, loop, end of > loop, ...) > union of data necessary for necessary commands > pointer to next command. Right. And this can be kept quite simple. The commands itself are just a string of text. The loops just check a variable, no? It can be something like: for foo in 1 2 3 do echo $i done That can be translated into some kind of pseudo language: 1: list = 1 2 3 2: read i, list 3: echo $i 4: check list 5: je 2 I know it's stupid and kind of silly like this. But we have to define a language. It's important to discuss this on the list, IMO. > I made a simple example I posted as preview version of scripting > engine and I also posted on this list simple design doc. > Any ideas are welcome. I think I gave you some ideas. ;) Which mail are you talking about (subject and date)? I must have missed a few the last months. :-( -- Marco