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