+static bool option_is_default(struct grub2_script *script,
+ struct discover_boot_option *opt)
+{
+ unsigned int default_idx;
+ const char *var;
+ char *end;
+
+ var = script_env_get(script, "default");
+ if (!var)
+ return false;
+
+ default_idx = strtoul(var, &end, 10);
+ if (end != var && *end == '\0')
+ return default_idx == script->n_options;
+
+ return !strcmp(opt->option->name, var);
+}
+