mkscripts.sh revision 16
1#!/bin/sh -
2# This script generates ed test scripts (.ed) from .t files
3
4PATH="/bin:/usr/bin:/usr/local/bin/:."
5ED=$1
6[ X"$ED" = X -o ! -x $ED ] && ED="../ed"
7[ ! -x $ED ] && { echo "$ED: cannot execute"; exit 1; }
8
9for i in *.t; do
10#	base=${i%.*}
11#	base=`echo $i | sed 's/\..*//'`
12	base=`expr $i : '\([^.]*\)'`
13	(
14	echo "#!/bin/sh -"
15	echo "$ED - <<\EOT"
16	echo "r \\$base.d"
17	cat $i
18	echo "w \\$base.o"
19	echo EOT
20	) >$base.ed
21	chmod +x $base.ed
22# The following is pretty ugly and not appropriate use of ed
23# but the point is that it can be done...
24#	base=`$ED - \!"echo \\\\$i" <<-EOF
25#		s/\..*
26#	EOF`
27#	$ED - <<-EOF
28#		a
29#		#!/bin/sh -
30#		$ED - <<\EOT
31#		r \\$base.d
32#		w \\$base.o
33#		EOT
34#		.
35#		-2r \\$i
36#		w \\$base.ed
37#		!chmod +x \\$base.ed
38#	EOF
39done
40
41for i in *.err; do
42#	base=${i%.*}
43#	base=`echo $i | sed 's/\..*//'`
44	base=`expr $i : '\([^.]*\)'`
45	(
46	echo "#!/bin/sh -"
47	echo "$ED - <<\EOT"
48	echo H
49	echo "r \\$base.err"
50	cat $i
51	echo "w \\$base.o"
52	echo EOT
53	) >$base-err.ed
54	chmod +x $base-err.ed
55#	base=`$ED - \!"echo \\\\$i" <<-EOF
56#		s/\..*
57#	EOF`
58#	$ED - <<-EOF
59#		a
60#		#!/bin/sh -
61#		$ED - <<\EOT
62#		H
63#		r \\$base.err
64#		w \\$base.o
65#		EOT
66#		.
67#		-2r \\$i
68#		w \\${base}-err.ed
69#		!chmod +x ${base}-err.ed
70#	EOF
71done
72