1
0

undo 565 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/rc
  2. rfork e
  3. if(! ~ $#* 1){
  4. echo 'usage: patch/undo patch-name' >[1=2]
  5. exit usage
  6. }
  7. if(! test -d /n/sources/patch){
  8. rfork n
  9. 9fs sources
  10. }
  11. if(! test -d /n/sources/patch/$1){
  12. echo 'no such patch' /n/sources/patch/$1 >[1=2]
  13. exit nopatch
  14. }
  15. d=$1
  16. builtin cd /n/sources/patch/$1 || exit nopatch
  17. if(! patch/okay .){
  18. echo 'bad patch: '$status >[1=2]
  19. exit badpatch
  20. }
  21. fn xxx {
  22. if(cmp $2.new $1){
  23. echo cp /n/sources/patch/$d/$2.backup $1
  24. cp $2.backup $1
  25. }
  26. if not
  27. echo $1 has changed since patch was applied! >[2=1]
  28. }
  29. cat files | sed 's/^/xxx /' |rc