is reduced in size by 3.2% through the more efficient reuse of the cksum
utility by the md5sum and sha*sum utilities.
+ 'cksum' now validates its options more consistently.
+ E.g., `cksum --text --tag` now fails like `cksum --tag --text` already did.
+
csplit, ls, and sort, now handle a more complete set of terminating signals.
'du' now processes directories with 10,000 or more entries up to 9 times
raw_digest = true;
break;
case UNTAG_OPTION:
- if (prefix_tag == 1)
- binary = -1;
prefix_tag = 0;
break;
# endif
case TAG_OPTION:
prefix_tag = 1;
- binary = 1;
break;
case 'z':
digest_delim = '\0';
}
#endif
- if (prefix_tag == -1)
- prefix_tag = HASH_ALGO_CKSUM;
-
- if (prefix_tag && !binary)
- {
- /* This could be supported in a backwards compatible way
- by prefixing the output line with a space in text mode.
- However that's invasive enough that it was agreed to
- not support this mode with --tag, as --text use cases
- are adequately supported by the default output format. */
-#if !HASH_ALGO_CKSUM
- error (0, 0, _("--tag does not support --text mode"));
-#else
- error (0, 0, _("--text mode is only supported with --untagged"));
-#endif
- usage (EXIT_FAILURE);
- }
-
if (digest_delim != '\n' && do_check)
{
error (0, 0, _("the --zero option is not supported when "
"verifying checksums"));
usage (EXIT_FAILURE);
}
-#if !HASH_ALGO_CKSUM
- if (prefix_tag && do_check)
+ if (1 <= prefix_tag && do_check)
{
+ /* Note we allow --untagged with --check to more
+ seamlessly support --untagged in an emulation wrapper. */
error (0, 0, _("the --tag option is meaningless when "
"verifying checksums"));
usage (EXIT_FAILURE);
}
-#endif
if (0 <= binary && do_check)
{
usage (EXIT_FAILURE);
}
+ if (prefix_tag == -1)
+ prefix_tag = HASH_ALGO_CKSUM;
+
+ if (prefix_tag && !binary)
+ {
+ /* This could be supported in a backwards compatible way
+ by prefixing the output line with a space in text mode.
+ However that's invasive enough that it was agreed to
+ not support this mode with --tag, as --text use cases
+ are adequately supported by the default output format. */
+#if !HASH_ALGO_CKSUM
+ error (0, 0, _("--tag does not support --text mode"));
+#else
+ error (0, 0, _("--text mode is only supported with --untagged"));
+#endif
+ usage (EXIT_FAILURE);
+ }
+
if (!O_BINARY && binary < 0)
binary = 0;
+ else if (prefix_tag)
+ binary = 1;
char **operand_lim = argv + argc;
if (optind == argc)
# Ensure abbreviations not supported for algorithm selection
returns_ 1 cksum -a sha22 </dev/null || fail=1
+# Ensure --text and --tag combo is disallowed
+returns_ 1 cksum --text --tag -a md5 </dev/null || fail=1
+returns_ 1 cksum --tag --text -a md5 </dev/null || fail=1
+
# Ensure --tag -> --untagged transition resets binary indicator
cksum --tag --untagged -a md5 /dev/null >out-1 || fail=1
-# --binary ignored in this edge case
-cksum --binary --tag --untagged -a md5 /dev/null >out-2 || fail=1
# base case for comparison
cksum --untagged -a md5 /dev/null >out || fail=1
compare out out-1 || fail=1
-compare out out-2 || fail=1
# check that the '*' is present
cksum --tag --untagged --binary -a md5 /dev/null >out || fail=1
# Verify that the order does not reset binary indicator
cksum --binary --untagged -a md5 /dev/null >out-1 || fail=1
compare out out-1 || fail=1
+cksum --binary --tag --untagged -a md5 /dev/null >out-2 || fail=1
+compare out out-2 || fail=1
Exit $fail
cksum --check empty-1 empty-2 > out 2>&1 && fail=1
grep 'empty-1: no properly formatted checksum lines found' out || fail=1
grep 'empty-2: no properly formatted checksum lines found' out || fail=1
+
+
+# Disallow --tag --check, with appropriate error
+returns_ 1 cksum --tag --check /dev/null 2> err
+grep 'the --tag option is meaningless when verifying checksums' err || fail=1
+# Allow --untagged --check, to better support
+# an emulation wrapper for legacy *sum utils.
+cksum -a md5 /dev/null | cksum --untagged --check || fail=1
+
Exit $fail