For GRUB scripting language, looping in GRUB is very crude and simple. Keep in mind that GRUB does not have arithmetic functionalities. Hence, you can't do something like $((count - 1)) in POSIX shell. It's best to keep it to a Boolean type conditions.
You can use the following to control the loop actions:
continue - skip this loop and proceed to the next onebreak - exit the loop immediatelyYou can use for loop for predictable looping.
The very basic format is similar to POSIX version:
grub> for i in 1 2 3; do> echo "current: $i"> donecurrent 1current 2current 3grub>In script form:
for i in 1 2 3; do echo "current: $i"doneYou can use while loop for unpredictable or conditional looping. Keep in mind that GRUB does not have arithmetic functionalities. Hence, you can't do something like $((count - 1)) in POSIX shell. It's best to keep it to a Boolean type conditions.
while [ controllable Boolean type conditions ]; do ...doneYou can use while loop for unpredictable or conditional looping. Keep in mind that GRUB does not have arithmetic functionalities. Hence, you can't do something like $((count - 1)) in POSIX shell. It's best to keep it to a Boolean type conditions.
until [ controllable Boolean type conditions ]; do ...doneThat's all about looping in GRUB scripting language.