]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - bin/ed/test/mkscripts.sh
zfs: merge openzfs/zfs@a03ebd9be
[FreeBSD/FreeBSD.git] / bin / ed / test / mkscripts.sh
1 #!/bin/sh -
2 # This script generates ed test scripts (.ed) from .t files
3 #       
4
5 PATH="/bin:/usr/bin:/usr/local/bin/:."
6 ED=$1
7 [ ! -x $ED ] && { echo "$ED: cannot execute"; exit 1; }
8
9 for 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 way of doing the above, and not appropriate 
23 # use of ed  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                 H
32                 r $base.d
33                 w $base.o
34                 EOT
35                 .
36                 -2r $i
37                 w $base.ed
38                 !chmod +x $base.ed
39         EOF
40 done
41
42 for i in *.err; do
43 #       base=${i%.*}
44 #       base=`echo $i | sed 's/\..*//'`
45 #       base=`expr $i : '\([^.]*\)'`
46 #       (
47 #       echo "#!/bin/sh -"
48 #       echo "$ED - <<\EOT"
49 #       echo H
50 #       echo "r $base.err"
51 #       cat $i
52 #       echo "w $base.o"
53 #       echo EOT
54 #       ) >$base-err.ed
55 #       chmod +x $base-err.ed
56 # The following is pretty ugly way of doing the above, and not appropriate 
57 # use of ed  but the point is that it can be done...
58         base=`$ED - \!"echo $i" <<-EOF
59                 s/\..*
60         EOF`
61         $ED - <<-EOF
62                 a
63                 #!/bin/sh -
64                 $ED - <<\EOT
65                 H
66                 r $base.err
67                 w $base.o
68                 EOT
69                 .
70                 -2r $i
71                 w ${base}.red
72                 !chmod +x ${base}.red
73         EOF
74 done