GNU bug report logs -
#8766
Bug in sha1sum?
Previous Next
Reported by: Theo Band <theo.band <at> greenpeak.com>
Date: Mon, 30 May 2011 17:54:02 UTC
Severity: normal
Tags: notabug
Done: Jim Meyering <jim <at> meyering.net>
Bug is archived. No further changes may be made.
Full log
Message #19 received at 8766-done <at> debbugs.gnu.org (full text, mbox):
tags 8766 notabug
On 30/05/11 11:51, Theo Band wrote:
> 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).
>
> sha1sum --version
> sha1sum (GNU coreutils) 5.97
> coreutils-5.97-23.el5_6.4
This is expected.
Here is a shell function I use in FSlint to
clean the output from these utilities
when we know we'll not have files with \n chars.
cleanup_sum() {
sed '
# md5sum and sha1sum et. al. from coreutils at least,
# to deal with \n in filenames, convert any \ and \n chars
# to \\ and \\n respectively. Currently we ignore files with \n
# so just undo this problematic escaping
/^\\/{s/^\\//; s/\\\\/\\/g};
# These utils also add a "*" flag character for normal files
# on platforms where O_BINARY is significant (like CYGWIN).
# We always process in binary mode and so remove that flag here
s/^\([^ ]*\) \*/\1 /;
'
}
So you can just:
sha1sum test | cleanup_sum
cheers,
Pádraig.
This bug report was last modified 14 years and 54 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.