Fix fatal "guilt graph" error in sha1sum invocation.
PATCH 1/1 Fix fatal "guilt graph" error in sha1sum invocation.
Fix the compatibility function sha1 so that it reads from stdin (and not a file with a zero-length file name) when no argument is supplied.
--- os.Darwin | 7 ++++++- os.Linux | 7 ++++++- os.SunOS | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-)
Note: I have tested both versions of the sha1 function, but only on Linux as I don't have access to a Mac.
/ceder
os.Darwin +6 -1
@@ -27,7 +27,12 @@ head_n() # usage: sha1 [file] sha1() { - openssl dgst -sha1 "$1" | sed "s,SHA1.\(.*\).= \(.*\),\2 \1," + if [ $# = 1 ] + then + openssl dgst -sha1 "$1" | sed "s,SHA1.\(.*\).= \(.*\),\2 \1," + else + openssl dgst -sha1 | sed 's,$, -,' + fi } # usage: cp_a <src> <dst>
os.Linux +6 -1
@@ -30,7 +30,12 @@ head_n() # usage: sha1 [file] sha1() { - sha1sum "$1" + if [ $# = 1 ] + then + sha1sum "$1" + else + sha1sum + fi } # usage: cp_a <src> <dst>
os.SunOS +6 -1
@@ -30,7 +30,12 @@ head_n() # usage: sha1 [file] sha1() { - sha1sum "$1" + if [ $# = 1 ] + then + sha1sum "$1" + else + sha1sum + fi } # usage: cp_a <src> <dst>
Signature · 1 line
1.7.9
Quoted 3 lines · Per Cederqvist
Fix the compatibility function sha1 so that it reads from stdin (and not a file with a zero-length file name) when no argument is supplied.
I just ran into this yesterday. I stupidly changed the caller of sha1 to pass in - for the filename. That worked for me since I ended up using the sha1sum implementations; openssl is not happy about that. So, your patch looks good.
Now, I should actually figure out how to get the git repo out there again.
Thanks,
Jeff.
Quoted 69 lines
Signed-off-by Per Cederqvist <[email protected]>--- os.Darwin | 7 ++++++- os.Linux | 7 ++++++- os.SunOS | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-)Note: I have tested both versions of the sha1 function, but only on Linux as I don't have access to a Mac.
/ceder
os.Darwin +6
-1@@ -27,7 +27,12 @@ head_n() # usage: sha1 [file] sha1() { - openssl dgst -sha1 "$1" | sed "s,SHA1.\(.*\).= \(.*\),\2 \1," + if [ $# = 1 ] + then + openssl dgst -sha1 "$1" | sed "s,SHA1.\(.*\).= \(.*\),\2 \1," + else + openssl dgst -sha1 | sed 's,$, -,' + fi } # usage: cp_a <src> <dst>os.Linux +6
-1@@ -30,7 +30,12 @@ head_n() # usage: sha1 [file] sha1() { - sha1sum "$1" + if [ $# = 1 ] + then + sha1sum "$1" + else + sha1sum + fi } # usage: cp_a <src> <dst>os.SunOS +6
-1@@ -30,7 +30,12 @@ head_n() # usage: sha1 [file] sha1() { - sha1sum "$1" + if [ $# = 1 ] + then + sha1sum "$1" + else + sha1sum + fi } # usage: cp_a <src> <dst>Signature · 1 line
1.7.9
Signature · 3 lines
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. - Albert Einstein
os.Darwin head_n() · line 34
Quoted 6 lines · Per Cederqvist
os.Darwin +5
-1- openssl dgst -sha1 "$1" | sed "s,SHA1.\(.*\).= \(.*\),\2 \1," + if [ $# = 1 ] + then + openssl dgst -sha1 "$1" | sed "s,SHA1.\(.*\).= \(.*\),\2 \1," + else + openssl dgst -sha1 | sed 's,$, -,'
$ openssl dgst -sha1 </dev/null (stdin)= da39a3ee5e6b4b0d3255bfef95601890afd80709
os.Linux head_n() · line 38
Quoted 10 lines
# usage: sha1 [file]
sha1()
{os.Linux +6
-1- sha1sum "$1" + if [ $# = 1 ] + then + sha1sum "$1" + else + sha1sum + fi
sha1sum "$@"
Andreas.
Signature · 3 lines
Andreas Schwab, [email protected] GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Quoted 11 lines · Andreas Schwab
os.Darwin head_n() · line 34
Quoted 6 lines · Per Cederqvist
os.Darwin +5
-1- openssl dgst -sha1 "$1" | sed "s,SHA1.\(.*\).= \(.*\),\2 \1," + if [ $# = 1 ] + then + openssl dgst -sha1 "$1" | sed "s,SHA1.\(.*\).= \(.*\),\2 \1," + else + openssl dgst -sha1 | sed 's,$, -,'$ openssl dgst -sha1</dev/null (stdin)= da39a3ee5e6b4b0d3255bfef95601890afd80709
Was that on a Darwin? If so, my fix obviously needs some work on that platform. I tested openssl-0.9.8o on Ubuntu 11.04, and here it looks like this:
$ openssl dgst -sha1</dev/null da39a3ee5e6b4b0d3255bfef95601890afd80709 $ openssl version OpenSSL 0.9.8o 01 Jun 2010
/ceder
Quoted 15 lines
os.Linux head_n() · line 38
Quoted 10 lines
# usage: sha1 [file] sha1() {os.Linux +6
-1- sha1sum "$1" + if [ $# = 1 ] + then + sha1sum "$1" + else + sha1sum + fisha1sum "$@"Andreas.
Quoted 13 lines · Per Cederqvist
Quoted 11 lines · Andreas Schwab
Quoted 7 lines · Per Cederqvist
- openssl dgst -sha1 "$1" | sed "s,SHA1.\(.*\).= \(.*\),\2 \1,"
+ if [ $# = 1 ]
+ then
+ openssl dgst -sha1 "$1" | sed "s,SHA1.\(.*\).= \(.*\),\2 \1,"
+ else
+ openssl dgst -sha1 | sed 's,$, -,'
Quoted 5 lines
Quoted 2 lines
$ openssl dgst -sha1</dev/null (stdin)= da39a3ee5e6b4b0d3255bfef95601890afd80709Was that on a Darwin?
Here's the output from my Mac (running Snow Leopard):
$ openssl dgst -sha1</dev/null (stdin)= da39a3ee5e6b4b0d3255bfef95601890afd80709 $ openssl version OpenSSL 1.0.0d 8 Feb 2011
-John
Quoted 14 lines · Per Cederqvist
Quoted 11 lines · Andreas Schwab
os.Darwin head_n() · line 34
Quoted 6 lines · Per Cederqvist
os.Darwin +5
-1- openssl dgst -sha1 "$1" | sed "s,SHA1.\(.*\).= \(.*\),\2 \1," + if [ $# = 1 ] + then + openssl dgst -sha1 "$1" | sed "s,SHA1.\(.*\).= \(.*\),\2 \1," + else + openssl dgst -sha1 | sed 's,$, -,'$ openssl dgst -sha1</dev/null (stdin)= da39a3ee5e6b4b0d3255bfef95601890afd80709
Quoted 1 line
Was that on a Darwin?
No.
$ openssl version OpenSSL 1.0.0e 6 Sep 2011
Andreas.
Signature · 3 lines
Andreas Schwab, [email protected] GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."