+2013-06-25 Colin Watson <cjwatson@ubuntu.com>
+
+ * util/grub-script-check.c: Fail on scripts containing no
+ commands, to guard against corrupted grub-mkconfig setups that
+ produce no useful output.
+ * tests/grub_script_no_commands.in: New test.
+ * Makefile.util.def (grub_script_no_commands): Add.
+ Reported by Hans Putter. Fixes Debian bug #713886.
+
2013-06-16 Andrey Borzenkov <arvidjaar@gmail.com>
* grub-core/disk/diskfilter.c: Forgot to remove comment
common = tests/grub_script_not.in;
};
+script = {
+ testcase;
+ name = grub_script_no_commands;
+ common = tests/grub_script_no_commands.in;
+};
+
script = {
testcase;
name = partmap_test;
--- /dev/null
+#! /bin/sh
+set -e
+
+# grub-script-check refuses to pass a file with no commands; this usually
+# indicates a bug in the code generating that file.
+
+@builddir@/grub-script-check <<EOF && exit 1
+
+EOF
+
+@builddir@/grub-script-check <<EOF && exit 1
+# comment
+EOF
+
+@builddir@/grub-script-check <<EOF && exit 1
+# comment 1
+# comment 2
+
+EOF
+
+exit 0
.file = 0
};
char *input;
- int found_input = 0;
+ int found_input = 0, found_cmd = 0;
struct grub_script *script = NULL;
set_program_name (argv[0]);
script = grub_script_parse (input, get_config_line, &ctx);
if (script)
{
+ if (script->cmd)
+ found_cmd = 1;
grub_script_execute (script);
grub_script_free (script);
}
fprintf (stderr, _("Syntax error at line %u\n"), ctx.lineno);
return 1;
}
+ if (! found_cmd)
+ {
+ fprintf (stderr, _("Script contains no commands and will do nothing\n"),
+ ctx.arguments.filename);
+ return 1;
+ }
return 0;
}