[GTALUG] Bash does-directory-exist question

John Sellens jsellens at syonex.com
Fri Jul 10 11:01:26 EDT 2020


On Fri, 2020/07/10 09:38:48AM -0400, Giles Orr via talk <talk at gtalug.org> wrote:
| This gives immediate visual feedback on the write-status of the
| current directory.  But test's '-w' and '-d' both claim that you're
| still in a valid directory under the above circumstances.  Does anyone
| know of a simple way to find out if the directory you're currently in
| actually exists?

The directory "." will still exist while you have it open (your current
directory), but will be unreachable, as you observed with stat(1) and
the number of links.

Would checking for "test -d $PWD" work?  I think $PWD is the full path
and so if it's no longer reachable, the test should fail?

Hope that helps

John


More information about the talk mailing list