[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] cksum: --quiet option to output only the checksum when reading t
From: |
Piotr H. Dabrowski |
Subject: |
[PATCH] cksum: --quiet option to output only the checksum when reading tty stdin |
Date: |
Wed, 17 Apr 2024 19:51:59 +0200 |
* src/digest.c: --quiet option when reading tty stdin
---
src/digest.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/src/digest.c b/src/digest.c
index 1a4cfd1fb..6501f5e9d 100644
--- a/src/digest.c
+++ b/src/digest.c
@@ -195,7 +195,8 @@ static bool warn = false;
/* With --check, ignore missing files. */
static bool ignore_missing = false;
-/* With --check, suppress the "OK" printed for each verified file. */
+/* With --check, suppress the "OK" printed for each verified file.
+ When reading tty stdin output only the checksum. */
static bool quiet = false;
/* With --check, exit with a non-zero return code if any line is
@@ -475,6 +476,9 @@ Print or check %s (%d-bit) checksums.\n\
the blake2 algorithm and must be a multiple of
8\n\
"), stdout);
# endif
+ fputs (_("\
+ --quiet output only the checksum when reading tty stdin\n\
+"), stdout);
# if HASH_ALGO_CKSUM
fputs (_("\
--raw emit a raw binary digest, not hexadecimal\
@@ -1085,7 +1089,7 @@ output_file (char const *file, int binary_file, void
const *digest,
printf ("%02x", bin_buffer[i]);
}
- if (!tagged)
+ if (!tagged && !quiet)
{
putchar (' ');
putchar (binary_file ? '*' : ' ');
@@ -1582,13 +1586,6 @@ main (int argc, char **argv)
usage (EXIT_FAILURE);
}
- if (quiet && !do_check)
- {
- error (0, 0,
- _("the --quiet option is meaningful only when verifying
checksums"));
- usage (EXIT_FAILURE);
- }
-
if (strict & !do_check)
{
error (0, 0,
--
2.40.1
- [PATCH] cksum: --quiet option to output only the checksum when reading tty stdin,
Piotr H. Dabrowski <=