cksum again diagnoses read errors in its default CRC32 mode.
[bug introduced in coreutils-9.0]
+ 'cksum --check' now ensures filenames with a leading backslash character
+ are escaped appropriately in the status output.
+ This also applies to the standalone checksumming utilities.
+ [bug introduced in coreutils-8.25]
+
dd again supports more than two multipliers for numbers.
Previously numbers of the form '1024x1024x32' gave "invalid number" errors.
[bug introduced in coreutils-9.1]
or carriage return, the line is started with a backslash, and each
problematic character in the file name is escaped with a backslash,
making the output unambiguous even in the presence of arbitrary file names.
+Since the backslash character itself is escaped, any other backslash
+escape sequences are reserved for future use.
If @var{file} is omitted or specified as @samp{-}, standard input is read.
@cindex BSD output
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
-@samp{\} at the start of the line, being used.
+characters are escaped as described above, using the same escaping indicator of
+@samp{\} at the start of the line, as used with the other output format.
The @option{--tag} option implies binary mode, and is disallowed with
@option{--text} mode as supporting that would unnecessarily complicate
the output format, while providing little benefit.
exit (status);
}
+/* Given a string S, return TRUE if it contains problematic characters
+ that need escaping. Note we escape '\' itself to provide some forward
+ compat to introduce escaping of other characters. */
+
+static bool
+problematic_chars (char const *s)
+{
+ return strchr (s, '\\') || strchr (s, '\n') || strchr (s, '\r');
+}
+
#define ISWHITE(c) ((c) == ' ' || (c) == '\t')
/* Given a file name, S of length S_LEN, that is not NUL-terminated,
unsigned char const *bin_buffer = digest;
- /* Output a leading backslash if the file name contains problematic chars.
- Note we escape '\' itself to provide some forward compat to introduce
- escaping of other characters. */
- bool needs_escape = delim == '\n' && (strchr (file, '\\')
- || strchr (file, '\n')
- || strchr (file, '\r'));
+ /* Output a leading backslash if the file name contains problematic chars. */
+ bool needs_escape = delim == '\n' && problematic_chars (file);
+
if (needs_escape)
putchar ('\\');
{
bool ok;
bool missing;
- /* Only escape in the edge case producing multiple lines,
- to ease automatic processing of status output. */
- bool needs_escape = ! status_only && strchr (filename, '\n');
+ bool needs_escape = ! status_only && problematic_chars (filename);
properly_formatted_lines = true;
# with the GNU extension of escaped newlines
nl='
'
-tab=' '
+t=' '
rm check.md5
-for i in 'a\b' 'a\' "a${nl}b" "a${tab}b"; do
+for i in 'a\b' 'a\' '\a' "a${nl}b" "a${t}b"; do
: > "$i"
md5sum --tag "$i" >> check.md5 || fail=1
done
-md5sum --strict -c check.md5 || fail=1
+md5sum --strict -c check.md5 > out || fail=1
+printf '%s: OK\n' '\a\\b' '\a\\' '\\\a' '\a\nb' "a${t}b" > exp ||
+ framework_failure_
+compare exp out || fail=1
+
# Ensure BSD traditional format with GNU extension escapes
# is in the expected format