Sometimes you know only know which debug logging conditionals you want to turn off, not necessarily all the ones you want enabled. This patch allows the debug string to contain conditionals in the $debug variable which are prefixed with a "-" to disable debug log messages for that conditional. This is only significant when "all" is a word in the comma-separated list of the $debug variable. Say you want all debug logging on except for btrfs and scripting, then do "set debug=all,-btrfs,-scripting".
Note, only the first occurance of the conditional is searched for to determine if the conditional is enabled. So simply appending ",-conditional" to the $debug variable may not disable that conditional, if, for example, the conditional is already present. To illustrate, the command "set debug=all,btrfs,-scripting,-btrfs" will not disable btrfs. Signed-off-by: Glenn Washburn <developm...@efficientek.com> --- grub-core/kern/misc.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c index 3af336ee2..ecef4839e 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -162,13 +162,28 @@ __attribute__ ((alias("grub_printf"))); int grub_debug_enabled (const char * condition) { - const char *debug; + const char *debug, *found; + char found_end; debug = grub_env_get ("debug"); if (!debug) return 0; - if (grub_strword (debug, "all") || grub_strword (debug, condition)) + if (grub_strword (debug, "all")) + { + if (debug[3] == '\0') + return 1; + found = grub_strstr (debug, condition); + /* If found conditional is preceeded by a '-' and whole, disable debug */ + if (found > debug && *(found-1) == '-') + { + found_end = *(found + grub_strlen (condition)); + if (found_end == '\0' || grub_iswordseparator (found_end)) + return 0; + } + return 1; + } + else if (grub_strword (debug, condition)) return 1; return 0; -- 2.27.0 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel