0004-ed.sh (391B)
1 #!/bin/sh 2 3 set -e 4 5 tmp1=tmp1.$$ 6 tmp2=tmp2.$$ 7 8 cleanup() 9 { 10 st=$? 11 rm -f $tmp1 $tmp2 12 exit $st 13 } 14 15 trap cleanup EXIT 16 17 printf foo >$tmp1 18 ../ed $tmp1 <<EOF >$tmp2 19 ,p 20 w 21 EOF 22 23 # This is somewhat opinionated test for files without trailing newline, more 24 # documenting the current behavior, which differs from BSD and GNU eds. 25 diff -u - $tmp2 <<EOF || true 26 3 27 foo 28 4 29 EOF 30 31 diff -u - $tmp1 <<EOF 32 foo 33 EOF