From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1oRNeX-0005iZ-No for mharc-grub-devel@gnu.org; Thu, 25 Aug 2022 20:56:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52120) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRNeU-0005gZ-MK for grub-devel@gnu.org; Thu, 25 Aug 2022 20:56:51 -0400 Received: from mail-qt1-x82a.google.com ([2607:f8b0:4864:20::82a]:45663) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oRNeS-0001su-4x for grub-devel@gnu.org; Thu, 25 Aug 2022 20:56:49 -0400 Received: by mail-qt1-x82a.google.com with SMTP id j17so222661qtp.12 for ; Thu, 25 Aug 2022 17:56:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficientek-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc; bh=y6fTmymucyZWD54xdAl5KWtQVdpBNSTu7/OgKE9nIe0=; b=uqZHKyBar9U50Gl9pUya8byLAbNlnGs8sL4qcvFCa4/7j++80pdia9QavdrD1PEO4U unp+7jzUu/aiuvEd2lI7y4cVJOGzy7i0aCm55biu8UNBCWmvfl+PCHaXutthla02Nlwc WgUEAGZGsh1X6whGuw7b+LnJuLRcT6EKXq6ka37YtUwt8GahfxaYAVoBkapekGzWUojZ aIf9KXveevC05qaHiezRLF3/Wt9mdNcIfkACz0Z6gAIhgaS46H2IpJ1+4uXYgBmDw1gt 85RY6/H4MoWZWZ804SAugvQ2H23/1yHUwb4jaNAYUR4KDz6Cm7JZNyIlcC6HOmp7tZxx TMfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=y6fTmymucyZWD54xdAl5KWtQVdpBNSTu7/OgKE9nIe0=; b=ZDYEnecJVjekCc6nOJIomSyBJy8UPLKdL53/zfQdHC8ytbFGiplfgyTlKYos1F9q8v 50zd/WaULQ4RvjFpThJE6JX5Y5dW8Mr3q+KJNRJ4DqTWEwBA+HK6zaAwEf47CwIspdOr iS4OBW+/BjV0dUiEhnDmOBHosDVMptIZZImq2WjVJlVKb+rPxTVRvWLpoFj/L0lPimJD qYX71HFIIbexvnAxo+wQgD6dZB4T3P4E6EF0liqBVQyYZU0D1fNjIj0vgkMehcF6sggz JJLO5g5iv0CxLB6Czw9b+rURzx5NRIQN0cffDaQindWvJj+nrfPCUBk6SFl/yipl1Zqd irCA== X-Gm-Message-State: ACgBeo2oUkUE1NuoMlQp91jgxIwRye9rN/z5xTyqgBswQtBvixxti8nI 3Tcjkp7b6iKrB+1UwJBt/su0xLs4aIBEFA== X-Google-Smtp-Source: AA6agR5B8T5Odkw6Ts0v05CUy6E4WRAvmdoGnntSTmY4dV/PdolnErP4/Cgx1UtSr/FooYS/9MeyIA== X-Received: by 2002:a05:622a:54a:b0:343:5a1a:9acd with SMTP id m10-20020a05622a054a00b003435a1a9acdmr5938919qtx.194.1661475406996; Thu, 25 Aug 2022 17:56:46 -0700 (PDT) Received: from localhost.localdomain ([37.218.244.249]) by smtp.gmail.com with ESMTPSA id o9-20020ac872c9000000b0034361fb2f75sm325769qtp.22.2022.08.25.17.56.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Aug 2022 17:56:46 -0700 (PDT) From: Glenn Washburn To: grub-devel@gnu.org, Daniel Kiper Cc: Li Gen , Glenn Washburn Subject: [PATCH] cmp: Only return success when both files have the same contents Date: Thu, 25 Aug 2022 19:56:29 -0500 Message-Id: <20220826005629.360450-1-development@efficientek.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::82a; envelope-from=development@efficientek.com; helo=mail-qt1-x82a.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Aug 2022 00:56:51 -0000 From: Li Gen 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 Signed-off-by: Glenn Washburn --- 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