while [ ! -e *.cabal ] ; do OLDDIR=$PWD; cd ..; if [ $OLDDIR == $PWD ] ; then exit 1 ; # reached root node fi done echo $PWD