Commit Diff


commit - 2072343d6ba88a37ede0c4ae2791328880cdfacf
commit + 6e0f14d51ef1971893bb094c873ddde86d0cae61
blob - b38a7290c907f1f1e4b4ee16749d2693b96be851
blob + 6c741ce0faed2c7f2461be79d57ab4ccad67599c
--- regress/lib.sh
+++ regress/lib.sh
@@ -159,23 +159,6 @@ check() {
 	return 1
 }
 
-# usage: sha in out
-# writes the sha256 of `in' to `out'
-sha() {
-	if which sha256 >/dev/null 2>&1; then
-		sha256 < "$1" > "$2"
-		return $?
-	fi
-
-	if which sha256sum >/dev/null 2>&1; then
-		sha256sum "$1" | awk '{print $1}' > "$2"
-		return $?
-	fi
-
-	echo "No sha binary found" >&2
-	exit 1
-}
-
 count() {
 	wc -l | xargs
 }
blob - /dev/null
blob + 02b8eb211eb3c2d1e7d2f072d17e8b98173bacf1 (mode 755)
--- /dev/null
+++ regress/sha
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+# USAGE: ./sha in out
+# writes the sha256 of in to file out
+
+if which sha256 2>/dev/null >/dev/null; then
+	exec sha256 < "$1" > "$2"
+fi
+
+if which sha256sum 2>/dev/null >/dev/null; then
+	sha256sum "$1" | awk '{print $1}' > "$2"
+	exit $?
+fi
+
+echo "No sha binary found"
+exit 1
blob - c01013ee788ada6fd1c527f8d6981607520a8275
blob + ccb7ea7430f25ef9902b5e2ad1796be8ac9be2f7
--- regress/tests.sh
+++ regress/tests.sh
@@ -38,7 +38,7 @@ test_serve_big_files() {
 
 	hdr="$(head /bigfile)"
 	get /bigfile > bigfile
-	sha bigfile bigfile.sha
+	./sha bigfile bigfile.sha
 	body="$(cat bigfile.sha)"
 
 	check_reply "20 application/octet-stream" "$(cat testdata/bigfile.sha)"
@@ -99,7 +99,7 @@ test_cgi_big_replies() {
 
 	hdr="$(head /serve-bigfile)"
 	get /bigfile > bigfile
-	sha bigfile bigfile.sha
+	./sha bigfile bigfile.sha
 	body="$(cat bigfile.sha)"
 	check_reply "20 application/octet-stream" "$(cat testdata/bigfile.sha)"
 }