path: root/discover
diff options
authorAlan Dunn <>2016-03-14 17:40:47 -0700
committerSam Mendoza-Jonas <>2016-03-15 14:10:00 +1100
commit6e5cd61065181460be8152a73dfc79f94ecd27fe (patch)
tree62a597293437291e9e495af53d5eaa1714dfcb60 /discover
parentc005b174aa484ecafdbd403af80ea7375b67bc31 (diff)
In GRUB2 parser save_env, treat unset variable value as empty
It seems better to treat unset variable values as empty rather than crashing in save_env. While GRUB's behavior is actually to delete the variable from the environment block, it seems useful to at least not crash while later on someone can do further work to improve GRUB compatibility if desired. Tested: Modified test-grub2-save-env to cover this case. Signed-off-by: Alan Dunn <> Signed-off-by: Sam Mendoza-Jonas <>
Diffstat (limited to 'discover')
1 files changed, 4 insertions, 0 deletions
diff --git a/discover/grub2/env.c b/discover/grub2/env.c
index 3598927..7eda095 100644
--- a/discover/grub2/env.c
+++ b/discover/grub2/env.c
@@ -257,6 +257,10 @@ int builtin_save_env(struct grub2_script *script,
name = argv[i];
value = script_env_get(script, name);
+ if (!value) {
+ pb_log("Saved unset environment variable %s!\n", name);
+ value = "";
+ }
update_env(buf + siglen, len - siglen, name, value);
OpenPOWER on IntegriCloud