В Tue, 15 Oct 2013 12:20:16 +0200 sas...@freenet.de пишет: > Dear all, > > unfortunately i was not able to find any documentation on usage of > conditional statements in grub configuration files. > > According to the “GNU GRUB Manual 2.00~rc1” found on http://www.gnu.org/ the > words 'if', 'fi', 'case', 'esac', 'in' and so on are reserved. > Furthermore the scripting language is referred to as “Shell-like”. > > Simple “if [ $condition ]; then #dosomething; fi”-statements are not > problematic. > But I wasn't able to find a functional syntax for the case-statements. >
grub does not support "case" statement, at least as of now. > To make it short: I would like to compare strings in the grub cli. > > Is there any more or less exhaustive documentation about the syntax or am I > just too dumb to use google? > What part is unclear? "case" can in almost all cases be replaced with "if". Actually, perl never had "case" too. That said, if someone implements it, I guess it will be accepted. To compare patters you can use regexp command. Current trunk contains a bit more complete list of available commands. > The most recent version I used to test stuff was the 2.00 that comes shipped > with arch linux. > > > What I'm trying to do: > > I want to implement a grub configuration file that automatically generates > menu entries. > > For en example: > The following procedure should create entries for (small) files to be loaded > with memdisk ( from the syslinux project). > /boot/memsik is our kernel. > Our file is the initrd. > We assume that the files can be PREFIX_*.* or just *.* or README*. > (e.g. README || FLOPPY_dellbiosupdate.img || freedos.img) > The README*-files should not be processed. > For files with a prefix, the prefix should be appended as a kernel-parameter. > For files without there are no parameters to append. > > I supposed that this would be “shell-like” (file=$img): > > [code source=”/boot/grub/grub.cfg”] > . .. > insmod ext2 > insmod regexp > . .. > set pathtoimages=”/boot/images” > . .. > for img in ${pathtoimages}/*; do > set appendstr=”” > ... > case ${img} in > */README*) continue ;; > */FLOPPY_*) set appendstr=${appendstr} floppy ;; > … > esac > menuentry “MEMDISK - $img” “$img” “$appendstr” { > linux16 /boot/memdisk ${3} > initrd16 ${2} > } > done > . .. > [/code] > > I also tried to use other quoting notations with no success. > Futhermore I also tried “if [[ ${img} == */FLOPPY_* ]]; ...”. > > > > Thank you very much in advance! > > > > With kind regards, > Sasha B. > > > > P.S.: Sorry if something's misspelled, English isn't my native tongue. > > > > --- > Alle Postfächer an einem Ort. Jetzt wechseln und E-Mail-Adresse mitnehmen! > http://email.freenet.de/basic/Informationen > _______________________________________________ > Help-grub mailing list > Help-grub@gnu.org > https://lists.gnu.org/mailman/listinfo/help-grub _______________________________________________ Help-grub mailing list Help-grub@gnu.org https://lists.gnu.org/mailman/listinfo/help-grub