sbase/tests/0003-ed.sh
Roberto E. Vargas Caballero c02bf1a70d tests: USE $EXEC and fix ed path
Using an EXEC variable for every test make easy to run tools to
debug issues like for example using EXEC=valgrind ./0025-ed.sh.
Some tests for ed had a wrong path to the ed binary and they
were not testing the actual ed but the system one.
2026-01-13 12:11:16 +01:00

69 lines
501 B
Bash
Executable File

#!/bin/sh
set -e
tmp1=tmp1.$$
tmp2=tmp2.$$
trap 'rm -f $tmp1 $tmp2' EXIT
trap 'exit $?' HUP INT TERM
cat <<EOF >$tmp1
foo
bar
baz
EOF
# Unspecified whether quit with a dirty buffer is considered an error, allow both
$EXEC ../ed $tmp1 <<EOF >$tmp2 || test $? -eq 1
v#^\$#p
p
g/^\$/d
,p
q
a
fizz
buzz
.
i
foobar
.
w
v!z\$!d
,p
q
1,2j
1,2j
,p
q
EOF
diff -u - $tmp2 <<EOF
13
foo
bar
baz
baz
foo
bar
baz
?
29
baz
fizz
buzz
?
bazfizzbuzz
?
EOF
diff -u - $tmp1 <<EOF
foo
bar
baz
fizz
foobar
buzz
EOF