GNU bug report logs - #8766
Bug in sha1sum?

Previous Next

Package: coreutils;

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 #8 received at 8766 <at> debbugs.gnu.org (full text, mbox):

From: "Alan Curry" <pacman-cu <at> kosh.dhis.org>
To: theo.band <at> greenpeak.com (Theo Band)
Cc: 8766 <at> debbugs.gnu.org
Subject: Re: 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




This bug report was last modified 14 years and 55 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.