Blob
1 #!/usr/local/plan9/bin/rc3 sym = 'threadmain?z4 p9main?z5 main?z'7 fn dbsrc{8 echo $sym | db $1 | 9 sed '1d;/symbol not found/d;s/.*\(\) //'9 }11 fn go{12 type=`{file $1}13 switch($type){14 case *'script text'*15 plumbit $1 '(script)'16 case *executable* *'plan 9 boot image'* *'shared object'*17 plumbit `{dbsrc $1} '(executable)'18 case *19 echo 'src: can''t find source for '$1 - unrecognized type $type >[1=2]20 }21 }23 fn plumbit{B $1}25 fn usage{26 echo usage: 'src [-n] [-s symbol] executable ...'>[1=2]27 exit usage28 }30 while(~ $1 -*)31 switch($1){32 case -n33 shift34 fn plumbit {echo $1}35 case -s36 shift37 # add main in case symbol is undefined38 sym=$1'?z39 threadmain?z40 p9main?z41 main?z'42 shift43 case -*44 usage45 }47 if(~ $#* 0) usage48 ifs='49 '50 for(i){51 wi=`{which $i >[2]/dev/null}52 if(test -f $i) go $i53 if not if(~ $#wi 1 && test -f $wi) go $wi54 if not echo 'src: can''t find '$i55 }