bashshellbootloadergrubgrub2

grub2 howto increment variable


The grub2 shell aims to be a minimalistic bash like shell.

But how can I increment a variable in grub2?

In bash I would do:

var=$((var+1))

or

((var=var+1))

In grub2 I get a syntax error on these calls. How can I achieve this in the grub2 shell?


Solution

  • Grub2 does not have builtin arithmetic support. You need to add Lua support if you want that, see this answer for details.