This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: "test" producing unexpected results after "chmod"


Greetings, Steven Penny!

> With Linux, these commands produce expected results:

>     $ cd /tmp
>     $ touch alpha.txt
>     $ test -r alpha.txt; echo "$?"
>     0
>     $ chmod -r alpha.txt
>     $ test -r alpha.txt; echo "$?"
>     1
>     $ chmod +r alpha.txt
>     $ test -r alpha.txt; echo "$?"
>     0

> However with Cygwin, unexpected results are produced:

>     $ cd /tmp
>     $ touch alpha.txt
>     $ test -r alpha.txt; echo "$?"
>     0
>     $ chmod -r alpha.txt
>     $ test -r alpha.txt; echo "$?"
>     0

> It seems Cygwin is not able to produce non-readable files.

It's not Cygwin, it's test, like many other programs in this case, make false
assumptions on file readability/writability based on their interpretation of
file permissions.

The only true test for readability is to open file for reading.
The only true test for writability is to open file for writing.
Successfully.

The rest is merely a guesswork.


-- 
With best regards,
Andrey Repin
Monday, December 24, 2018 1:17:48

Sorry for my terrible english...


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]