diff 681 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/rc
  2. # patch/diff [-w] patch-name
  3. rfork e
  4. fn usage {
  5. echo 'usage: patch/diff [-bmnwz] patch-name' >[1=2]
  6. exit usage
  7. }
  8. dopts=(-c)
  9. while (! ~ $#* 0 && ~ $1 -*) {
  10. switch ($1) {
  11. case -[bmnw]
  12. dopts=($dopts $1)
  13. case -z
  14. dopts=()
  15. case *
  16. usage
  17. }
  18. shift
  19. }
  20. if(! ~ $#* 1)
  21. usage
  22. if(! test -d /n/sources/patch){
  23. rfork n
  24. 9fs sources
  25. }
  26. if(! test -d /n/sources/patch/$1){
  27. echo 'no such patch' /n/sources/patch/$1 >[1=2]
  28. exit nopatch
  29. }
  30. builtin cd /n/sources/patch/$1 || exit nopatch
  31. if(! patch/okay .){
  32. echo 'bad patch: '$status >[1=2]
  33. exit badpatch
  34. }
  35. d=/n/sources/patch/$1
  36. fn xxx {
  37. echo $1
  38. diff $dopts $2.orig $d/$2 | sed 's/^/ /'
  39. }
  40. cat files | sed 's/^/xxx /' | rc