if [ -w branching: how to spot a locked USB stick

Fergus fergus@bonhard.uklinux.net
Thu Sep 20 13:23:00 GMT 2007

A couple of months ago


I wondered whether a user could use "if [ -w " branching in Cygwin to 
distinguish a locked stick from an unlocked stick. Apparently the answer 
was No but Corinna identified an easy fix


I have recently changed to Vista from XP SP2 and amongst other 
annoyances I now find that "if [ -w " branching breaks when the test 
medium is a CD. (It's now reported as "write-able".)

Can anybody confirm this?

The fact that in Vista the directory c:/Windows is not accessible while 
c:/tmp is accessible seems to be correctly reported. The root c:/ is 
inaccessible in a strange new way, to me ("A required privilege is not 
held by the client" instead of "Access is denied") but in fact the 
output from "if -w /c" suggests, wrongly, that it is write-able.

Can anybody confirm this?

I suppose we could all post our individual experiences about how 
disconcertingly horrible Vista is, and how much it has broken or (seems 
to have) got wrong or how much existing established good stuff it has 
merely rendered in need of fixing. I suppose it would soon get wearisome 
for everybody else but I feel, and am, absolutely de-railed by it. 
Currently I am making much use of the command
   export MY_DIR=`cygpath $LOCALAPPDATA`


Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

More information about the Cygwin mailing list