Moved DIR inside of if so it will only be set when running bash.