
There's probably a GRUB-specific mailing list or forum, but I thought I would try here first ... GRUB has a DSL ( https://en.wikipedia.org/wiki/Domain-specific_language ) that looks a lot like shell scripting. Most people never see it as it's used to generate the menus we use at boot-time and they see only the menus, but it can do some interesting things - particularly when you're dealing with multi-boot USB sticks. Here's a simple but slightly useful example: function cpuinfo { # only able to determine: 32/64 bit, and is it PAE echo "GRUB's ability to analyse processors is limited, we can only tell you:" if cpuid -p; then pae_assessment="PAE" else pae_assessment="NO PAE" fi if cpuid -l; then echo "64-bit processor, $pae_assessment" else echo "32-bit processor, $pae_assessment" fi } But it has some nasty limitations that are frustrating me: - no pipes - no command substitution - no file globbing That last in particular is really getting on my nerves. I want to source all the files in one folder, but I can't say 'for file in folder/* ; do' because the '*' is a literal character, no special meaning. Likewise, I can't say 'for file in `ls folder/` ; do' because there's no command substitution. I was wondering if anyone knows of a solution to this problem. Or even if you have ideas from long-gone old shells with similar limitations for which someone worked out a nasty work-around ... What I've been doing is 'for file in name1 name2 name3 ... ; do', but of course this only works if you remember to add new filenames to the list. I've googled quite a bit, but most people only modify GRUB through /etc/default/grub or, if they're really adventurous, through /etc/grub.d/40_custom or similar. What I'm looking for is (mostly) at a lower level than that, and examples are surprisingly hard to come by. And search results are occasionally polluted by GRUB4DOS results ... GRUB4DOS _does_ seem to support file globbing. All very confusing. Thanks. -- Giles https://www.gilesorr.com/ gilesorr@gmail.com

On Wed, Jul 25, 2018 at 12:54:39PM -0400, Giles Orr via talk wrote:
There's probably a GRUB-specific mailing list or forum, but I thought I would try here first ...
GRUB has a DSL ( https://en.wikipedia.org/wiki/Domain-specific_language ) that looks a lot like shell scripting. Most people never see it as it's used to generate the menus we use at boot-time and they see only the menus, but it can do some interesting things - particularly when you're dealing with multi-boot USB sticks. Here's a simple but slightly useful example:
function cpuinfo { # only able to determine: 32/64 bit, and is it PAE echo "GRUB's ability to analyse processors is limited, we can only tell you:" if cpuid -p; then pae_assessment="PAE" else pae_assessment="NO PAE" fi if cpuid -l; then echo "64-bit processor, $pae_assessment" else echo "32-bit processor, $pae_assessment" fi }
But it has some nasty limitations that are frustrating me: - no pipes - no command substitution - no file globbing
Actually it does file globbing if you load the regexp module. Apparently this works: insmod regexp for i in /boot/*; do echo $i; done Or: grub> ls /boot/* error: file `/boot/*' not found. grub> insmod regexp grub> ls /boot/* unicode.pf2 i386-pc/ locale/ fonts/ grubenv grub.cfg config-4.16.0-2-amd64 ... -- Len Sorensen

On 25 July 2018 at 13:45, Lennart Sorensen via talk <talk@gtalug.org> wrote:
There's probably a GRUB-specific mailing list or forum, but I thought I would try here first ...
GRUB has a DSL ( https://en.wikipedia.org/wiki/Domain-specific_language ) that looks a lot like shell scripting. Most people never see it as it's used to generate the menus we use at boot-time and they see only the
On Wed, Jul 25, 2018 at 12:54:39PM -0400, Giles Orr via talk wrote: menus,
but it can do some interesting things - particularly when you're dealing with multi-boot USB sticks. Here's a simple but slightly useful example:
function cpuinfo { # only able to determine: 32/64 bit, and is it PAE echo "GRUB's ability to analyse processors is limited, we can only tell you:" if cpuid -p; then pae_assessment="PAE" else pae_assessment="NO PAE" fi if cpuid -l; then echo "64-bit processor, $pae_assessment" else echo "32-bit processor, $pae_assessment" fi }
But it has some nasty limitations that are frustrating me: - no pipes - no command substitution - no file globbing
Actually it does file globbing if you load the regexp module.
Apparently this works:
insmod regexp for i in /boot/*; do echo $i; done
Or:
grub> ls /boot/* error: file `/boot/*' not found. grub> insmod regexp grub> ls /boot/* unicode.pf2 i386-pc/ locale/ fonts/ grubenv grub.cfg config-4.16.0-2-amd64 ...
Thank you! I don't think that's documented anywhere, and it doesn't strike me as being in any way obvious. -- Giles https://www.gilesorr.com/ gilesorr@gmail.com

On Wed, Jul 25, 2018 at 02:09:00PM -0400, Giles Orr wrote:
I don't think that's documented anywhere, and it doesn't strike me as being in any way obvious.
Well it's vaguely documented in that the module has a description. And it is totally not obvious that a module could change such behaviour in the first place. -- Len Sorensen

On Wed, 25 Jul 2018 at 14:14, Lennart Sorensen via talk <talk@gtalug.org> wrote:
On Wed, Jul 25, 2018 at 02:09:00PM -0400, Giles Orr wrote:
I don't think that's documented anywhere, and it doesn't strike me as being in any way obvious.
Well it's vaguely documented in that the module has a description. And it is totally not obvious that a module could change such behaviour in the first place.
Is there some place to push a documentation patch for that? It's managed at Savannah, so there's a git repo, and it sure seems a neat idea to augment it... git clone git://git.savannah.gnu.org/grub.git -- When confronted by a difficult problem, solve it by reducing it to the question, "How would the Lone Ranger handle this?"
participants (3)
-
Christopher Browne
-
Giles Orr
-
lsorense@csclub.uwaterloo.ca