Function
Function in GRUB is very slightly different compared to POSIX shell. It doesn't require the function parenthesis ( ()
) and must rely on function
keyword.
Basic
Basic
Here's the an example of basic declaration:
function simple_greeting {
echo "Hello $@"
}
grub> simple_greeting "Michelle"
Hello Michelle
grub>
Parameters
Parameters
Parameters are similar of those in POSIX shell. Example:
$@
- all parameters with positional information$*
- all parameters without positional information$1
,$2
,$3
, ... - parameter value at the specified position.$0
means nothing in this case.return number
- return an exit code aligning to UNIX convention (0 means success)
That's all about creating function in GRUB scripting language.