Giles Orr via talk
2018-07-25 16:54:39 UTC
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.
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/
***@gmail.com
Giles
https://www.gilesorr.com/
***@gmail.com