0004-ed.sh - sbase - suckless unix tools
 (HTM) git clone git://git.suckless.org/sbase
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
       0004-ed.sh (405B)
       ---
            1 #!/bin/sh
            2 
            3 set -e
            4 
            5 tmp1=tmp1.$$
            6 tmp2=tmp2.$$
            7 
            8 trap 'rm -f $tmp1 $tmp2' EXIT
            9 trap 'rm -f $tmp1 $tmp2; kill -KILL $$' HUP INT TERM
           10 
           11 printf foo >$tmp1
           12 ../ed $tmp1 <<EOF >$tmp2
           13 ,p
           14 w
           15 EOF
           16 
           17 # This is somewhat opinionated test for files without trailing newline, more
           18 # documenting the current behavior, which differs from BSD and GNU eds.
           19 diff -u - $tmp2 <<EOF || true
           20 3
           21 foo
           22 4
           23 EOF
           24 
           25 diff -u - $tmp1 <<EOF
           26 foo
           27 EOF