`s3' applies the last substitution to the 3rd (or nth) match.
Split up the code to several files.
This commit is contained in:
parent
d2656eedba
commit
59ddb06db0
|
@ -1,18 +1,23 @@
|
|||
ED!=cd $(.CURDIR)/..; \
|
||||
printf "xxx:\n\techo \$${.OBJDIR}/ed\n" | make -r -s -f - xxx
|
||||
SHELL= /bin/sh
|
||||
ED= ../obj/ed
|
||||
|
||||
all: build test
|
||||
@echo done
|
||||
all: check
|
||||
@:
|
||||
|
||||
check: build test
|
||||
@if grep -h '\*\*\*' errs.o scripts.o; then :; else \
|
||||
echo "tests completed successfully."; \
|
||||
fi
|
||||
|
||||
build: mkscripts.sh
|
||||
@echo building test scripts...
|
||||
@chmod +x mkscripts.sh
|
||||
@./mkscripts.sh ${ED}
|
||||
@if [ -f errs.o ]; then :; else \
|
||||
echo "building test scripts for $(ED) ..."; \
|
||||
$(SHELL) mkscripts.sh $(ED); \
|
||||
fi
|
||||
|
||||
test: build ckscripts.sh
|
||||
@echo running test scripts...
|
||||
@chmod +x ckscripts.sh
|
||||
@./ckscripts.sh ${ED}
|
||||
@echo testing $(ED) ...
|
||||
@$(SHELL) ckscripts.sh $(ED)
|
||||
|
||||
clean:
|
||||
rm -f *.ed *.[oz] *~
|
||||
rm -f *.ed *.red *.[oz] *~
|
||||
|
|
|
@ -19,14 +19,6 @@ which look like:
|
|||
or:
|
||||
*** Output u.o of script u.ed is incorrect ***
|
||||
|
||||
It is assumed that the ed being tested processes escapes (\) in file names.
|
||||
This is so that a name starting with bang (!) can be read, via:
|
||||
r \!file
|
||||
Without the escape, a POSIX ed would attempt to read the output of
|
||||
the shell command `file'. If the ed being tested does not support escape
|
||||
processing on file names, then the script `mkscripts.sh' should be modified
|
||||
accordingly.
|
||||
|
||||
The POSIX requirement that an address range not be used where at most
|
||||
a single address is expected has been relaxed in this version of ed.
|
||||
Therefore, the following scripts which test for compliance with this
|
||||
|
@ -36,6 +28,3 @@ a1-err.ed
|
|||
i1-err.ed
|
||||
k1-err.ed
|
||||
r1-err.ed
|
||||
|
||||
In addition, one of bang1-err.ed or bang2.ed will fail, depending on
|
||||
whether or not ed was compiled with the EX_BANG directive.
|
||||
|
|
|
@ -5,26 +5,24 @@
|
|||
|
||||
PATH="/bin:/usr/bin:/usr/local/bin/:."
|
||||
ED=$1
|
||||
[ X"$ED" = X -o ! -x $ED ] && ED="../ed"
|
||||
[ ! -x $ED ] && { echo "$ED: cannot execute"; exit 1; }
|
||||
|
||||
# Run the *-err.ed scripts first, since these don't generate output;
|
||||
# rename then to *-err.ed~; they exit with non-zero status
|
||||
for i in *-err.ed; do
|
||||
echo $i~
|
||||
# Run the *.red scripts first, since these don't generate output;
|
||||
# they exit with non-zero status
|
||||
for i in *.red; do
|
||||
echo $i
|
||||
if $i; then
|
||||
echo "*** The script $i~ exited abnormally ***"
|
||||
echo "*** The script $i exited abnormally ***"
|
||||
fi
|
||||
mv $i $i~
|
||||
done >errs.o 2>&1
|
||||
|
||||
# Run the remainding scripts; they exit with zero status
|
||||
for i in *.ed; do
|
||||
base=`expr $i : '\([^.]*\)'`
|
||||
# base=`expr $i : '\([^.]*\)'`
|
||||
# base=`echo $i | sed 's/\..*//'`
|
||||
# base=`$ED - \!"echo \\\\$i" <<-EOF
|
||||
# s/\..*
|
||||
# EOF`
|
||||
base=`$ED - \!"echo $i" <<-EOF
|
||||
s/\..*
|
||||
EOF`
|
||||
if $base.ed; then
|
||||
if cmp -s $base.o $base.r; then :; else
|
||||
echo "*** Output $base.o of script $i is incorrect ***"
|
||||
|
|
|
@ -3,69 +3,71 @@
|
|||
|
||||
PATH="/bin:/usr/bin:/usr/local/bin/:."
|
||||
ED=$1
|
||||
[ X"$ED" = X -o ! -x $ED ] && ED="../ed"
|
||||
[ ! -x $ED ] && { echo "$ED: cannot execute"; exit 1; }
|
||||
|
||||
for i in *.t; do
|
||||
# base=${i%.*}
|
||||
# base=`echo $i | sed 's/\..*//'`
|
||||
base=`expr $i : '\([^.]*\)'`
|
||||
(
|
||||
echo "#!/bin/sh -"
|
||||
echo "$ED - <<\EOT"
|
||||
echo "r \\$base.d"
|
||||
cat $i
|
||||
echo "w \\$base.o"
|
||||
echo EOT
|
||||
) >$base.ed
|
||||
chmod +x $base.ed
|
||||
# The following is pretty ugly and not appropriate use of ed
|
||||
# but the point is that it can be done...
|
||||
# base=`$ED - \!"echo \\\\$i" <<-EOF
|
||||
# s/\..*
|
||||
# EOF`
|
||||
# $ED - <<-EOF
|
||||
# a
|
||||
# #!/bin/sh -
|
||||
# $ED - <<\EOT
|
||||
# r \\$base.d
|
||||
# w \\$base.o
|
||||
# EOT
|
||||
# .
|
||||
# -2r \\$i
|
||||
# w \\$base.ed
|
||||
# !chmod +x \\$base.ed
|
||||
# EOF
|
||||
# base=`expr $i : '\([^.]*\)'`
|
||||
# (
|
||||
# echo "#!/bin/sh -"
|
||||
# echo "$ED - <<\EOT"
|
||||
# echo "r $base.d"
|
||||
# cat $i
|
||||
# echo "w $base.o"
|
||||
# echo EOT
|
||||
# ) >$base.ed
|
||||
# chmod +x $base.ed
|
||||
# The following is pretty ugly way of doing the above, and not appropriate
|
||||
# use of ed but the point is that it can be done...
|
||||
base=`$ED - \!"echo $i" <<-EOF
|
||||
s/\..*
|
||||
EOF`
|
||||
$ED - <<-EOF
|
||||
a
|
||||
#!/bin/sh -
|
||||
$ED - <<\EOT
|
||||
H
|
||||
r $base.d
|
||||
w $base.o
|
||||
EOT
|
||||
.
|
||||
-2r $i
|
||||
w $base.ed
|
||||
!chmod +x $base.ed
|
||||
EOF
|
||||
done
|
||||
|
||||
for i in *.err; do
|
||||
# base=${i%.*}
|
||||
# base=`echo $i | sed 's/\..*//'`
|
||||
base=`expr $i : '\([^.]*\)'`
|
||||
(
|
||||
echo "#!/bin/sh -"
|
||||
echo "$ED - <<\EOT"
|
||||
echo H
|
||||
echo "r \\$base.err"
|
||||
cat $i
|
||||
echo "w \\$base.o"
|
||||
echo EOT
|
||||
) >$base-err.ed
|
||||
chmod +x $base-err.ed
|
||||
# base=`$ED - \!"echo \\\\$i" <<-EOF
|
||||
# s/\..*
|
||||
# EOF`
|
||||
# $ED - <<-EOF
|
||||
# a
|
||||
# #!/bin/sh -
|
||||
# $ED - <<\EOT
|
||||
# H
|
||||
# r \\$base.err
|
||||
# w \\$base.o
|
||||
# EOT
|
||||
# .
|
||||
# -2r \\$i
|
||||
# w \\${base}-err.ed
|
||||
# !chmod +x ${base}-err.ed
|
||||
# EOF
|
||||
# base=`expr $i : '\([^.]*\)'`
|
||||
# (
|
||||
# echo "#!/bin/sh -"
|
||||
# echo "$ED - <<\EOT"
|
||||
# echo H
|
||||
# echo "r $base.err"
|
||||
# cat $i
|
||||
# echo "w $base.o"
|
||||
# echo EOT
|
||||
# ) >$base-err.ed
|
||||
# chmod +x $base-err.ed
|
||||
# The following is pretty ugly way of doing the above, and not appropriate
|
||||
# use of ed but the point is that it can be done...
|
||||
base=`$ED - \!"echo $i" <<-EOF
|
||||
s/\..*
|
||||
EOF`
|
||||
$ED - <<-EOF
|
||||
a
|
||||
#!/bin/sh -
|
||||
$ED - <<\EOT
|
||||
H
|
||||
r $base.err
|
||||
w $base.o
|
||||
EOT
|
||||
.
|
||||
-2r $i
|
||||
w ${base}.red
|
||||
!chmod +x ${base}.red
|
||||
EOF
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue