1#!/bin/bash
2
3if [[ -z "$AWK" || -z "$WORKDIR" ]]; then
4    printf '$AWK and $WORKDIR must be set\n' >&2
5    exit 1
6fi
7
8TEMP0=$WORKDIR/test.temp.0
9TEMP1=$WORKDIR/test.temp.1
10TEMP2=$WORKDIR/test.temp.2
11TEMP3=$WORKDIR/test.temp.3
12
13RESULT=0
14
15fail() {
16	echo "$1" >&2
17	RESULT=1
18}
19
20echo T.lilly: miscellaneous RE tests from Bruce Lilly
21
22cat > $TEMP0 <<EOF
23foo=bar
24foo==bar
25foo+bar
26foo+=bar
27foo-=bar
28foo*=bar
29foo/=bar
30foo^=bar
31foo%=bar
32foo!=bar
33foo<=bar
34foo>=bar
35foo bar
36foo/bar
37foo=bar=fribble
38=foo=bar
39EOF
40
41rm -f $TEMP2
42$AWK '
43/./ {
44	print $0 >"'$TEMP2'"
45	print "###", NR, $0
46	system(ENVIRON["AWK"] " -f '$TEMP2' <\"'$TEMP0'\" ")
47	close "'$TEMP2'"
48}' < lilly.progs > $TEMP1 2>&1
49
50echo `wc -l lilly.progs` tests
51
52diff $TEMP1 lilly.ok > $WORKDIR/lilly.diff || fail 'bad: T.lilly is different'
53
54exit $RESULT
55