It was my understanding that grub supports a small subset of bash. Their documentation doesn't go into super detail, other than it "supports conditionals", etc.
I am trying to run a simple if.
grub> if [ "${myvar}" = "fred" ]; then
> echo "test"
> fi
error: can't find command `['.
Anybody have an idea? I am using grub2-efi 2.00.
You are missing a grub2 module in order to run
iftests.I'm running Gentoo on a PowerPC system (PPC64 G5 machine) and doing a default
grub-mkconfigthen booting from it gives me the error in your question.Since
bashhas that syntax support, I figured it was simply a grub module that needed to be added (I had been doing work with grub modules recently). tl;dr: You need to load the appropriate grub module and then the error goes away.The first step is to find out what modules you have. For me, it's whatever is available in my
/boot/grub/powerpc-ieee1275/folder. There's also modules in/usr/lib/grub/powerpc-ieee1275/.I wrote up a list of modules I thought I needed:
I then added them to my
/etc/default/grubfile:I did not find an entry for
GRUB_PRELOAD_MODULESin the config file, so I had to do some searching to find out how. I want these modules to be added every time I generate the grub config file, which means putting them in the00_headerportion of grub.Then I recreated the configuration file:
The modules were in the header and things worked perfectly on reboot.
If I had to guess: you probably only need the
testmodule to enableifstatements.