]> git.lizzy.rs Git - plan9front.git/blob - rc/bin/patch/diff
inst: get rid of ppp configuration
[plan9front.git] / rc / bin / patch / diff
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
9 dopts=(-c)
10 while (! ~ $#* 0 && ~ $1 -*) {
11         switch ($1) {
12         case -[bmnw]
13                 dopts=($dopts $1)
14         case -z
15                 dopts=()
16         case *
17                 usage
18         }
19         shift
20 }
21 if(! ~ $#* 1)
22         usage
23
24 if(! test -d /n/sources/patch){
25         rfork n
26         9fs sources
27 }
28
29 if(! test -d /n/sources/patch/$1){
30         echo 'no such patch' /n/sources/patch/$1 >[1=2]
31         exit nopatch
32 }
33
34 builtin cd /n/sources/patch/$1 || exit nopatch
35 if(! patch/okay .){
36         echo 'bad patch: '$status >[1=2]
37         exit badpatch
38 }
39
40 d=/n/sources/patch/$1
41 fn xxx {
42         echo $1
43         diff $dopts $2.orig $d/$2 | sed 's/^/   /'
44 }
45 cat files | sed 's/^/xxx /' | rc