0003-ed.sh - sbase - suckless unix tools
 (HTM) git clone git://git.suckless.org/sbase
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
       0003-ed.sh (520B)
       ---
            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 cat <<EOF >$tmp1
           12 foo
           13 bar
           14 
           15 baz
           16 EOF
           17 
           18 # Unspecified whether quit with a dirty buffer is considered an error, allow both
           19 ../ed $tmp1 <<EOF >$tmp2 || test $? -eq 1
           20 v#^\$#p
           21 p
           22 g/^\$/d
           23 ,p
           24 q
           25 a
           26 fizz
           27 buzz
           28 .
           29 i
           30 foobar
           31 .
           32 w
           33 v!z\$!d
           34 ,p
           35 q
           36 1,2j
           37 1,2j
           38 ,p
           39 q
           40 EOF
           41 
           42 diff -u - $tmp2 <<EOF
           43 13
           44 foo
           45 bar
           46 baz
           47 baz
           48 foo
           49 bar
           50 baz
           51 ?
           52 29
           53 baz
           54 fizz
           55 buzz
           56 ?
           57 bazfizzbuzz
           58 ?
           59 EOF
           60 
           61 diff -u - $tmp1 <<EOF
           62 foo
           63 bar
           64 baz
           65 fizz
           66 foobar
           67 buzz
           68 EOF