changelog shortlog tags branches changeset files revisions annotate raw help

Mercurial > hg > plan9front / rc/bin/src

changeset 7243: 34f64dcbbc25
parent: efddda59690a
author: cinap_lenrek@felloff.net
date: Fri, 17 May 2019 18:14:10 +0200
permissions: -rwxr-xr-x
description: 7l: don't hardcode 4k pagesize, use INITRND
1 #!/bin/rc
2 
3 rfork e
4 path=(/bin/)
5 
6 sym = 'threadmain?z
7  main?z'
8 
9 fn dbsrc{
10  echo $sym | db $1 | sed '1d;/symbol not found/d;s/.*\(\) //'
11 }
12 
13 fn go{
14  type=`{file <$1 | sed 's/stdin: //'}
15  switch($type){
16  case 'rc executable file'
17  plumbit $1 '(rc executable)'
18  case *executable* *'plan 9 boot image'*
19  plumbit `{dbsrc $1} '(executable)'
20  case *
21  echo 'src: can''t find source for '$1 - unrecognized type $type >[1=2]
22  }
23 }
24 
25 fn plumbit{B $1}
26 
27 fn usage{
28  echo usage: 'src [-n] [-s symbol] executable ...'>[1=2]
29  exit usage
30 }
31 
32 while(~ $1 -*)
33  switch($1){
34  case -n
35  shift
36  fn plumbit {echo $1}
37  case -s
38  shift
39  # add main in case symbol is undefined
40  sym=$1'?z
41  main?z'
42  shift
43  case -*
44  usage
45  }
46 
47 if(~ $#* 0) usage
48 
49 for(i){
50  if(test -f $i) go $i
51  if not if(test -f /bin/$i) go /bin/$i
52  if not if(test -f /bin/*/$i) go /bin/*/$i
53  if not if(test -f /bin/*/*/$i) go /bin/*/*/$i
54  if not echo 'src: can''t find '$i
55 }