@item --debug
@opindex --debug
Output extra information to stderr, like the checksum implementation being used.
+
+@item --untagged
+@opindex --untagged
+Output using the original coreutils format used by the other
+standalone checksum utilities like @command{md5sum} for example.
+This format has the checksum at the start of the line, and may be
+more amenable to further processing by other utilities,
+especially in combination with the @option{--zero} option.
+Note this does not identify the digest algorithm used for the checksum.
+@xref{md5sum invocation} for details of this format.
@end table
@item --tag
@opindex --tag
@cindex BSD output
+Note this option is not supported by the @command{cksum} command,
+as this is the default output format that it uses.
Output BSD style checksums, which indicate the checksum algorithm used.
As a GNU extension, if @option{--zero} is not used, file names with problematic
characters are escaped as described above, with the same escaping indicator of
QUIET_OPTION,
STRICT_OPTION,
TAG_OPTION,
+ UNTAG_OPTION,
DEBUG_PROGRAM_OPTION,
};
{ "text", no_argument, NULL, 't' },
{ "warn", no_argument, NULL, 'w' },
{ "strict", no_argument, NULL, STRICT_OPTION },
+# if HASH_ALGO_CKSUM
+ { "untagged", no_argument, NULL, UNTAG_OPTION },
+# else
{ "tag", no_argument, NULL, TAG_OPTION },
+# endif
{ "zero", no_argument, NULL, 'z' },
#endif
#if HASH_ALGO_CKSUM
the blake2 algorithm and must be a multiple of 8\n\
"), stdout);
# endif
+# if HASH_ALGO_CKSUM
+ fputs (_("\
+ --untagged create a reversed style checksum, without digest type\n\
+"), stdout);
+# else
fputs (_("\
--tag create a BSD-style checksum\n\
"), stdout);
+# endif
if (O_BINARY)
fputs (_("\
-t, --text read in text mode (default if reading tty stdin)\n\
int opt;
bool ok = true;
int binary = -1;
+#if HASH_ALGO_CKSUM
+ bool prefix_tag = true;
+#else
bool prefix_tag = false;
+#endif
/* Setting values of global variables. */
initialize_main (&argc, &argv);
case STRICT_OPTION:
strict = true;
break;
+# if HASH_ALGO_CKSUM
+ case UNTAG_OPTION:
+ prefix_tag = false;
+ break;
+# else
case TAG_OPTION:
prefix_tag = true;
binary = 1;
break;
+# endif
case 'z':
digest_delim = '\0';
break;
case bsd:
case sysv:
case crc:
- if (prefix_tag)
- die (EXIT_FAILURE, 0,
- _("--tag is not supported with --algorithm={bsd,sysv,crc}"));
if (do_check && algorithm_specified)
die (EXIT_FAILURE, 0,
_("--check is not supported with --algorithm={bsd,sysv,crc}"));
"verifying checksums"));
usage (EXIT_FAILURE);
}
-
+#if HASH_ALGO_CKSUM
+ if (!prefix_tag && do_check)
+ {
+ error (0, 0, _("the --untagged option is meaningless when "
+ "verifying checksums"));
+ usage (EXIT_FAILURE);
+ }
+#else
if (prefix_tag && do_check)
{
error (0, 0, _("the --tag option is meaningless when "
"verifying checksums"));
usage (EXIT_FAILURE);
}
+#endif
if (0 <= binary && do_check)
{
# Ensure we can --check the --tag format we produce
rm -f check.b2sum || framework_failure_
+[ "$prog" = 'b2sum' ] && tag_opt='--tag' || tag_opt=''
for i in 'a' ' b' '*c' '44' ' '; do
echo "$i" > "$i"
for l in 0 128; do
- $prog -l $l --tag "$i" >> check.b2sum
+ $prog -l $l $tag_opt "$i" >> check.b2sum
done
done
# Note -l is inferred from the tags in the mixed format file
rm -f check.vals || framework_failure_
# Ensure we can check non tagged format
+[ "$prog" != 'b2sum' ] && tag_opt='--untagged' || tag_opt=''
for l in 0 128; do
- $prog -l $l /dev/null | tee -a check.vals > check.b2sum
+ $prog $tag_opt -l $l /dev/null | tee -a check.vals > check.b2sum
$prog -l $l --strict -c check.b2sum || fail=1
$prog --strict -c check.b2sum || fail=1
done
# Ensure the checksum values are correct. The reference
# check.vals was created with the upstream SSE reference implementation.
-$prog --length=128 check.vals > out || fail=1
+[ "$prog" != 'b2sum' ] && tag_opt='--untagged' || tag_opt=''
+$prog $tag_opt --length=128 check.vals > out || fail=1
printf '%s\n' '796485dd32fe9b754ea5fd6c721271d9 check.vals' > exp
compare exp out || fail=1
blake2b b2sum -t
" | while read algo prog; do
$prog < /dev/null >> out || continue
- cksum --algorithm=$algo < /dev/null >> out-a || fail=1
+ cksum --untagged --algorithm=$algo < /dev/null >> out-a || fail=1
done
compare out out-a || fail=1
shuf -i 1-10 > input || framework_failure_
for args in '-a sha384' '-a blake2b' '-a blake2b -l 384' '-a sm3'; do
- cksum $args --tag 'input' >> CHECKSUMS || fail=1
+ cksum $args 'input' >> CHECKSUMS || fail=1
done
cksum --strict --check CHECKSUMS || fail=1
foreach $t (@Tests)
{
splice @$t, 1, 0, '--text' unless @$t[1] =~ /--check/;
- splice @$t, 1, 0, '-a sm3'
+ splice @$t, 1, 0, '--untagged -a sm3'
}
my $save_temps = $ENV{DEBUG};