Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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> 
grub> hello world
hello
grub> # i'd expect to see 'hello world' here
grub> # instead in only get 'hello'
grub> 
grub> # this works however
grub> 1=world
grub> hello
hello world
grub>

Does Grub2 allow passing parameters to user defined functions?

share|improve this question

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.