Blob
1 #!/usr/local/plan9/bin/rc3 . 9.rc4 sym = 'threadmain?z5 p9main?z6 main?z'8 fn dbsrc{9 echo $sym | db $1 | 9 sed '1d;/symbol not found/d;s/.*\(\) //'10 }12 fn go{13 type=`{file $1}14 switch($type){15 case *'script text'*16 plumbit $1 '(script)'17 case *executable* *'plan 9 boot image'* *'shared object'*18 plumbit `{dbsrc $1} '(executable)'19 case *20 echo 'src: can''t find source for '$1 - unrecognized type $type >[1=2]21 }22 }24 fn plumbit{B $1}26 fn usage{27 echo usage: 'src [-n] [-s symbol] executable ...'>[1=2]28 exit usage29 }31 while(~ $1 -*)32 switch($1){33 case -n34 shift35 fn plumbit {echo $1}36 case -s37 shift38 # add main in case symbol is undefined39 sym=$1'?z40 threadmain?z41 p9main?z42 main?z'43 shift44 case -*45 usage46 }48 if(~ $#* 0) usage49 ifs='50 '51 for(i){52 wi=`{which $i >[2]/dev/null}53 if(test -f $i) go $i54 if not if(~ $#wi 1 && test -f $wi) go $wi55 if not echo 'src: can''t find '$i56 }