[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Exporting variables in core.img's grub.cfg

From: Mihai Moldovan
Subject: Exporting variables in core.img's grub.cfg
Date: Fri, 5 Oct 2018 10:32:44 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2


I'm trying to make a variable stick around in the general grub environment after
defining it in an embedded grub.cfg file.

E.g., a grub.cfg file baked into core.img like this:

: set important_env_var="1"
: export important_env_var

does seem to define the variable correctly until grub loads the "actual" config
file from the boot partition (otherwise it wouldn't have been able to read that
file in the first place), but it's not defined in the environment past that
point. It doesn't show up in the grub shell and I generally see grub misbehaving
like it would if the env variable is unset. Setting and exporting it manually at
that point makes things work again.

I could naturally define the variable in both places, but that doesn't really
make sense.

I'm unsure if that's a bug or intended behavior, though.

The documentation for "export" says:
> Exported variables are visible to subsidiary configuration files loaded using
> configfile.

which makes me believe that such environment variables should outlive a switch
into normal mode; however, "configfile" explicitly states:
> Any environment variable changes made by the commands in file will not be
> preserved after configfile returns.

That's important, because I would assume that "normal" uses "configfile" to load
the config file.

It sounds like core.img-grub.cfg's scope runs out just before grub calls
"normal" and hence any environment changes made there are lost.

Is there a way to create persistent environment variables in core.img's 

I figure a workaround such as calling "normal" in the embedded grub.cfg might
work because it extends the config file's execution and normal mode would run as
part of the initial environment, but that's hacky.


Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]