#!/bin/bash

if [ \! -z "$1" -a -f "$1" ]; then

  BN=`basename $1 | cut -d . -f 1`

  GETH="/usr/src/go-ethereum/build/bin/geth --nousb --datadir $HOME/.ethereum -ipcpath $HOME/.ethereum/geth.ipc --preload $HOME/bin/js/gethrc.js,$1"

  $GETH --exec "${BN}Source()" attach | awk 'BEGIN {p=0} /^pragma/ {p=1;print;next} /^undefined/ {p=0;next} {if(p==1)print}'

fi
