mkscripts.sh revision 1057
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 ] && { echo "$ED: cannot execute"; exit 1; }
7
8for i in *.t; do
9#	base=${i%.*}
10#	base=`echo $i | sed 's/\..*//'`
11#	base=`expr $i : '\([^.]*\)'`
12#	(
13#	echo "#!/bin/sh -"
14#	echo "$ED - <<\EOT"
15#	echo "r $base.d"
16#	cat $i
17#	echo "w $base.o"
18#	echo EOT
19#	) >$base.ed
20#	chmod +x $base.ed
21# The following is pretty ugly way of doing the above, and not appropriate 
22# use of ed  but the point is that it can be done...
23	base=`$ED - \!"echo $i" <<-EOF
24		s/\..*
25	EOF`
26	$ED - <<-EOF
27		a
28		#!/bin/sh -
29		$ED - <<\EOT
30		H
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# The following is pretty ugly way of doing the above, and not appropriate 
56# use of ed  but the point is that it can be done...
57	base=`$ED - \!"echo $i" <<-EOF
58		s/\..*
59	EOF`
60	$ED - <<-EOF
61		a
62		#!/bin/sh -
63		$ED - <<\EOT
64		H
65		r $base.err
66		w $base.o
67		EOT
68		.
69		-2r $i
70		w ${base}.red
71		!chmod +x ${base}.red
72	EOF
73done
74