Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Grub2 allows for powerful scripting capabilities. if, while, function, etc all mean the language is pretty powerful (Turing complete?).

However, I cannot figure out how to pass parameters in grub2.

grub> function hello {
>        echo hello $1
>     }
grub> hello world
grub> # i'd expect to see 'hello world' here
grub> # instead in only get 'hello'
grub> # this works however
grub> 1=world
grub> hello
hello world

Does Grub2 allow passing parameters to user defined functions?

share|improve this question
up vote 1 down vote accepted

Function parameters only appeared in Grub in May 2010. At the moment the last grub release is 1.98 from March 2010, so if you want them, you have to get Grub from the Bazaar repository.

If you hope to do serious programming in Grub, though, you'll have to go all the way to lua support.

share|improve this answer
Thanks. I have been using the Lua. However, I don't think there will ever be a way to pass parameters to Lua from menu entries. The best I can do is set a variable before invoking the script. My idea was to have a grub function forward its parameters to the Lua script. This way my menu entries look like regular function calls, but the guts can still be Lua. – deft_code Sep 9 '10 at 18:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .