Hello,

I found a few bugs in the grub-file utility and the corresponding
command.

The first is that "grub-file --version" prints an error message:
grub-file (GRUB) 2.04
error: unknown argument `--version'.

The attached patch fixes this.

Greetings

Lukas Fink


>From b28668524b091fd4a49af2ca47007e420f25dba0 Mon Sep 17 00:00:00 2001
From: Lukas Fink <lukas.fi...@gmail.com>
Date: Sat, 29 Aug 2020 22:34:17 +0200
Subject: [PATCH 1/3] util/grub-file: Fix error message on --version

grub-file now exits after printing its version, therefore avoiding to
print an unknown argument error message.
---
 util/grub-file.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/util/grub-file.c b/util/grub-file.c
index b2e7dd69f..39f972575 100644
--- a/util/grub-file.c
+++ b/util/grub-file.c
@@ -54,13 +54,14 @@ main (int argc, char *argv[])
 
   grub_util_host_init (&argc, &argv);
 
-  argv2 = xcalloc (argc, sizeof (argv2[0]));
-
   if (argc == 2 && strcmp (argv[1], "--version") == 0)
     {
       printf ("%s (%s) %s\n", program_name, PACKAGE_NAME, PACKAGE_VERSION);
+      return 0;
     }
 
+  argv2 = xcalloc (argc, sizeof (argv2[0]));
+
   for (i = 1; i < argc; i++)
     {
       if (argv[i][0] == '-' && argv[i][1] == '-'
-- 
2.28.0



Reply via email to