On 7/4/07, Eric Blake <[EMAIL PROTECTED]> wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Geoff Kuenning on 7/3/2007 6:01 PM: > When the *sum family of programs are given a filename that contains > a backslash, a spurious backslash is given at the beginning of the > output line. > > This appears to be a feature, since it's explicitly in the code. > However it isn't documented, which can cause surprises for programs > that expect to parse the output of *sum. This was previously brought up, and a documentation patch was provided in time for coreutils 6.9. http://lists.gnu.org/archive/html/bug-coreutils/2007-03/msg00173.html Sounds like you need to upgrade. [However, this does point out that I have not yet had time to focus on my patch for getting \r to be treated like \\ and \n in the *sum output.] - -- Don't work too hard, make some time for fun as well! Eric Blake [EMAIL PROTECTED] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg<http://home.comcast.net/%7Eericblake/eblake.gpg> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGjBZe84KuGfSFAYARAp1JAJ0cbwfM7rsusC6r6u+D25xkYKkHlwCeIZqb qhl73wJImcTZEe1VRRgd1FU= =HNA4 -----END PGP SIGNATURE----- _______________________________________________ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils
Instead of handling some specific control characters (\n and \r) and the backslash, what about using something like the "quoting-style" functionality used by 'ls'? I think it would be a more general solution. Attached is a little script I made (along with its output). It touches some files with control characters in their names. Then the mechanism of escaping file names in md5sum is shown, followed by each quoting style available in 'ls'. The purpose is to show different ways the *sum programs could handle the display of file names with control characters (or just escapable characters). BTW, I'm not suggesting that there be a "--quoting-style=" command line option in the *sum programs, but rather the style be internal. I personally think the "escape" quoting style would best fit what md5sum already does, but I guess it really depends on who's going to be reading the file names (human, shell, etc.). Steve Ward [EMAIL PROTECTED] ~]$ md5sum --version md5sum (GNU coreutils) 6.9 Copyright (C) 2007 Free Software Foundation, Inc. This is free software. You may redistribute copies of it under the terms of the GNU General Public License <http://www.gnu.org/licenses/gpl.html>. There is NO WARRANTY, to the extent permitted by law. Written by Ulrich Drepper, Scott Miller, and David Madore.
test_md5sum_quoting_style.sh
Description: Bourne shell script
md5sum foo* d41d8cd98f00b204e9800998ecf8427e foo bar d41d8cd98f00b204e9800998ecf8427e foo;bar d41d8cd98f00b204e9800998ecf8427e foo'bar d41d8cd98f00b204e9800998ecf8427e foo"bar d41d8cd98f00b204e9800998ecf8427e foo$bar \d41d8cd98f00b204e9800998ecf8427e foo\\bar d41d8cd98f00b204e9800998ecf8427e foo&bar d41d8cd98f00b204e9800998ecf8427e foo bar \d41d8cd98f00b204e9800998ecf8427e foo\nbar d41d8cd98f00b204e9800998ecf8427e foo bar ls -1 --quoting-style=literal foo* foo bar foo;bar foo'bar foo"bar foo$bar foo\bar foo&bar foo bar foo bar foo bar ls -1 --quoting-style=shell foo* 'foo bar' 'foo;bar' 'foo'\''bar' 'foo"bar' 'foo$bar' 'foo\bar' 'foo&bar' 'foo bar' 'foo bar' 'foo bar' ls -1 --quoting-style=shell-always foo* 'foo bar' 'foo;bar' 'foo'\''bar' 'foo"bar' 'foo$bar' 'foo\bar' 'foo&bar' 'foo bar' 'foo bar' 'foo bar' ls -1 --quoting-style=c foo* "foo bar" "foo;bar" "foo'bar" "foo\"bar" "foo$bar" "foo\\bar" "foo&bar" "foo\tbar" "foo\nbar" "foo\rbar" ls -1 --quoting-style=escape foo* foo\ bar foo;bar foo'bar foo"bar foo$bar foo\\bar foo&bar foo\tbar foo\nbar foo\rbar ls -1 --quoting-style=locale foo* `foo bar' `foo;bar' `foo\'bar' `foo"bar' `foo$bar' `foo\\bar' `foo&bar' `foo\tbar' `foo\nbar' `foo\rbar' ls -1 --quoting-style=clocale foo* "foo bar" "foo;bar" "foo'bar" "foo\"bar" "foo$bar" "foo\\bar" "foo&bar" "foo\tbar" "foo\nbar" "foo\rbar"
_______________________________________________ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils