All of lore.kernel.org
 help / color / mirror / Atom feed
From: Glenn Washburn <development@efficientek.com>
To: grub-devel@gnu.org, Daniel Kiper <dkiper@net-space.pl>
Cc: Li Gen <ligenlive@gmail.com>,
	Glenn Washburn <development@efficientek.com>
Subject: [PATCH] cmp: Only return success when both files have the same contents
Date: Thu, 25 Aug 2022 19:56:29 -0500	[thread overview]
Message-ID: <20220826005629.360450-1-development@efficientek.com> (raw)

From: Li Gen <ligenlive@gmail.com>

This allows the cmp command to be used in GRUB scripts to conditionally
run commands based on whether two files are the same.

Signed-off-by: Li Gen <ligenlive@gmail.com>
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
 grub-core/commands/cmp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/grub-core/commands/cmp.c b/grub-core/commands/cmp.c
index e9c3b25d34..e1665cf27b 100644
--- a/grub-core/commands/cmp.c
+++ b/grub-core/commands/cmp.c
@@ -38,6 +38,7 @@ grub_cmd_cmp (grub_command_t cmd __attribute__ ((unused)),
   grub_file_t file2 = 0;
   char *buf1 = 0;
   char *buf2 = 0;
+  grub_err_t err = GRUB_ERR_TEST_FAILURE;
 
   if (argc != 2)
     return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("two arguments expected"));
@@ -91,6 +92,7 @@ grub_cmd_cmp (grub_command_t cmd __attribute__ ((unused)),
 
       /* TRANSLATORS: it's always exactly 2 files.  */
       grub_printf_ (N_("The files are identical.\n"));
+      err = GRUB_ERR_NONE;
     }
 
 cleanup:
@@ -102,7 +104,7 @@ cleanup:
   if (file2)
     grub_file_close (file2);
 
-  return grub_errno;
+  return err;
 }
 
 static grub_command_t cmd;
-- 
2.34.1



             reply	other threads:[~2022-08-26  0:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-26  0:56 Glenn Washburn [this message]
2022-09-29 14:00 ` [PATCH] cmp: Only return success when both files have the same contents Daniel Kiper
2022-10-01  5:44   ` Glenn Washburn
2022-10-03 14:56     ` Daniel Kiper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220826005629.360450-1-development@efficientek.com \
    --to=development@efficientek.com \
    --cc=dkiper@net-space.pl \
    --cc=grub-devel@gnu.org \
    --cc=ligenlive@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.