summaryrefslogtreecommitdiffstats
path: root/tools/regression/usr.bin/sed
diff options
context:
space:
mode:
authoryar <yar@FreeBSD.org>2007-04-21 01:21:36 +0000
committeryar <yar@FreeBSD.org>2007-04-21 01:21:36 +0000
commit65b331b4a19ecf3dc073e2363cb8294e986ded44 (patch)
treeca61296c60f091c362f574d1212cf29938a3745f /tools/regression/usr.bin/sed
parenta1e73b1eafb356ff4adba96fd8099c15c11471cd (diff)
downloadFreeBSD-src-65b331b4a19ecf3dc073e2363cb8294e986ded44.zip
FreeBSD-src-65b331b4a19ecf3dc073e2363cb8294e986ded44.tar.gz
Change the semantics of -i (in-place editing) so that it treats
each file independently from other files. The new semantics are desired in the most of practical cases, e.g.: delete lines 5-9 from each file. Keep the previous semantics of -i under a new option, -I, which uses a single continuous address space covering all files to edit in-place -- they are too cool to just drop them. Add regression tests for -i and -I. Approved by: dds Compared with: GNU sed Discussed on: -hackers MFC after: 2 weeks
Diffstat (limited to 'tools/regression/usr.bin/sed')
-rw-r--r--tools/regression/usr.bin/sed/regress.sh36
1 files changed, 35 insertions, 1 deletions
diff --git a/tools/regression/usr.bin/sed/regress.sh b/tools/regression/usr.bin/sed/regress.sh
index a99e7ba..2820a25 100644
--- a/tools/regression/usr.bin/sed/regress.sh
+++ b/tools/regression/usr.bin/sed/regress.sh
@@ -2,7 +2,7 @@
REGRESSION_START($1)
-echo '1..16'
+echo '1..20'
REGRESSION_TEST(`G', `sed G < regress.in')
REGRESSION_TEST(`P', `sed P < regress.in')
@@ -28,6 +28,40 @@ foo
REGRESSION_TEST(`b2a', `sed ''`2,3b
1,2d''` < regress.in')
+`
+inplace_test()
+{
+ expr="$1"
+ rc=0
+ ns=$(jot 5)
+ ins= outs= _ins=
+ for n in $ns; do
+ jot -w "l${n}_%d" 9 | tee lines.in.$n lines._in.$n | \
+ sed "$expr" > lines.out.$n
+ ins="$ins lines.in.$n"
+ outs="$outs lines.out.$n"
+ _ins="$_ins lines._in.$n"
+ done
+ sed "$expr" $_ins > lines.out
+
+ sed -i "" "$expr" $ins
+ sed -I "" "$expr" $_ins
+
+ for n in $ns; do
+ diff -u lines.out.$n lines.in.$n || rc=1
+ done
+ cat $_ins | diff -u lines.out - || rc=1
+ rm -f $ins $outs $_ins lines.out
+
+ return $rc
+}
+'
+
+REGRESSION_TEST_FREEFORM(`inplace1', `inplace_test 3,6d')
+REGRESSION_TEST_FREEFORM(`inplace2', `inplace_test 8,30d')
+REGRESSION_TEST_FREEFORM(`inplace3', `inplace_test 20,99d')
+REGRESSION_TEST_FREEFORM(`inplace4', `inplace_test "{;{;8,30d;};}"')
+
REGRESSION_TEST(`hanoi', `echo ":abcd: : :" | sed -f hanoi.sed')
REGRESSION_TEST(`math', `echo "4+7*3+2^7/3" | sed -f math.sed')
OpenPOWER on IntegriCloud