adiff 541 B

123456789101112131415161718192021222324
  1. #!/bin/rc
  2. if(~ $#* 0 1){
  3. echo >[1=2] usage: adiff file1 file2
  4. echo >[1=2] or adiff file1 file2... dir
  5. exit usage
  6. }
  7. dir = /mnt/wsys
  8. if(! test -f $dir/cons)
  9. dir = /mnt/term/$dir
  10. id=`{cat $dir/new/ctl}
  11. id=$id(1)
  12. l=$1
  13. r=$2
  14. if (test -d $1) l=$1/`{basename $2}
  15. if not if (test -d $2) r=$2/`{basename $1}
  16. echo 'name '^`{pwd}^/-diff-^`{basename $l} > $dir/$id/ctl
  17. diff $* | awk -v 'l='$l -v 'r='^$r '/^diff/ {l=$2; r=$3; next} /^[1-9]/ {sub("[acd]", " & " r ":"); sub("^", l ":", $0)}
  18. {print $0}' > $dir/$id/body
  19. echo clean > $dir/$id/ctl