I am writing a script to set environment variables on linux 2.6 using bash. So the script contains commands like:
export SRC_DIR=.. export LIBPATH=${SRC_DIR}/lib
I usually use
SCRIPT_DIR=$(readlink -f ${0%/*})
It should return the full path to the script, and even resolves all the links along the way.