#!/bin/bash
#
# script to run fable on Linux
#
# some advanced bash and unix tricks to find the fable install directory
## Linux
LSOF=$(lsof -p $$ | grep -E "/"$(basename $0)"$")
FABLE_SCRIPT=$(echo $LSOF | sed -r s/'^([^\/]+)\/'/'\/'/1 2>/dev/null)
if [ $? -ne 0 ]; then
## OSX
  FABLE_SCRIPT=$(echo $LSOF | sed -E s/'^([^\/]+)\/'/'\/'/1 2>/dev/null)
fi
FABLE_HOME=$(dirname $FABLE_SCRIPT)
export PYTHONPATH=$FABLE_HOME/python/linux_x86:$PYTHONPATH
echo "PYTHONPATH = " $PYTHONPATH
export LD_PRELOAD=/usr/lib/libpython2.5.so.1.0
$FABLE_HOME/fable
