if [ -d $1 ]; then cd $1 else cd `dirname $1` fi