summaryrefslogtreecommitdiff
path: root/libexec/httpd/testsuite/html_cmp
blob: d5031d657f207b2edc506c60a9cffe020f7d8ab7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#! /bin/sh
#
#	$eterna: html_cmp,v 1.9 2011/11/17 22:18:02 mrg Exp $
#
# like cmp(1)/diff(1) but compares to files after making their
# `Date: ' headers the same, to allow `now' and `then' to work properly.
# it also tries to find servername's that might be the local host and
# converts those as well..
#
# it must be called like `html_cmp cmp|diff file1 file1' *only*.

if [ "cmp" = "$1" ]; then
	cmd="cmp -s"
elif [ "diff" = "$1" ]; then
	cmd="diff -u"
else
	exit 77
fi

h=`hostname || uname -n`

sedcmd="s/^Date: .*/Date: nowish/;
	s/^Last-Modified: .*/Last-Modified: nowish/;
	s/[a-zA-Z0-9-]*\.eterna\.com\.au/$h/g;
	s/[a-zA-Z0-9-]*\.eterna23\.net/$h/g;
	s/^Server: .*/^Server: bozotic HTTP server version 5.08/;
	s/^Content-Length: .*/Content-Length: 223/;"

sed -e "$sedcmd" < "$2" > "f1.tmp.$$"
sed -e "$sedcmd" < "$3" > "f2.tmp.$$"

${cmd} "f1.tmp.$$" "f2.tmp.$$"
rv=$?
rm -f "f1.tmp.$$" "f2.tmp.$$"

exit $rv