On Fri, 10 Jul 2020 at 11:11, David Mason <dma...@ryerson.ca> wrote: > > (base) : ~/foo ; [ -w .. ] && echo true > true > (base) : ~/foo ; /bin/pwd > pwd: .: No such file or directory > (base) : ~/foo ; pwd > /Users/dmason/foo > (base) : ~/foo ; [ -w $PWD ] && echo true > (base) : ~/foo ; > > So, /bin/pwd fails and [ -w $PWD ] also fails, as John hypothesized > > ../Dave > On Jul 10, 2020, 11:01 AM -0400, John Sellens via talk <talk@gtalug.org>, > wrote: > > On Fri, 2020/07/10 09:38:48AM -0400, Giles Orr via talk <talk@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
I love this list! I thought that '[ -w . ]' and '[ -w $PWD ]' were practically equivalent. "Practically" means, in this case, "almost." But not quite - and the difference is the solution to the problem. Thanks everyone, particularly John and Dave. -- Giles https://www.gilesorr.com/ giles...@gmail.com --- Post to this mailing list talk@gtalug.org Unsubscribe from this mailing list https://gtalug.org/mailman/listinfo/talk