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