Add safety checks to pkg_tools cache clearing

I made this a new pull request for the sake of not committing too much in one request. These were the cache safety checks I talked about, but I apparently forgot to push them.

Anyway, this adds some simple checks. If `$PKG_CACHE` is set, but it's value is not actually a directory, it will tell you to make it, and then exits. Otherwise, it will continue trying to `cd` into it, failing and exiting with a non-zero code if it can not change to it's directory. There is not much else that can be done in terms of safety checks, since the guidelines for what constitutes a valid `$PKG_CACHE` in pkg_tools is fairly liberal.