[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#8766: Bug in sha1sum?
From: |
Alan Curry |
Subject: |
bug#8766: Bug in sha1sum? |
Date: |
Mon, 30 May 2011 18:03:21 -0500 (GMT+5) |
Theo Band writes:
>
> Hi
>
> I'm not sure, but I think I found a bug in sha1sum. It's easy to
> reproduce with any file that contains a backslash (\) in the name:
> echo test > test
> $ sha1sum test
> 4e1243bd22c66e76c2ba9eddc1f91394e57f9f83 test
> $ mv test 'test\test'
> $ sha1sum 'test\test'
> \4e1243bd22c66e76c2ba9eddc1f91394e57f9f83 test\\test
>
> I expect the file sha1sum to be the same after renaming the file (a
> backslash is prepended to the otherwise correct result).
This result violated my expectations too, but it turns out to be a documented
feature:
For each FILE, `md5sum' outputs the MD5 checksum, a flag indicating
a binary or text input file, and the file name. If FILE contains a
backslash or newline, 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. If FILE is omitted or specified as `-', standard input is read.
(the sha*sum utilities all refer back to md5sum's description)
I better go fix all my scripts that rely on /^[0-9a-f]{32} /
--
Alan Curry