public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Andrey Repin <anrdaemon@yandex.ru>
To: Steven Penny <svnpenn@gmail.com>, cygwin@cygwin.com
Subject: Re: "test" producing unexpected results after "chmod"
Date: Sun, 23 Dec 2018 23:05:00 -0000	[thread overview]
Message-ID: <1515955633.20181224012001@yandex.ru> (raw)
In-Reply-To: <5c1f242b.1c69fb81.2721c.076d@mx.google.com>

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

      parent reply	other threads:[~2018-12-23 22:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-23  6:15 Steven Penny
2018-12-23 17:12 ` Marco Atzeri
2018-12-23 23:05 ` Andrey Repin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1515955633.20181224012001@yandex.ru \
    --to=anrdaemon@yandex.ru \
    --cc=cygwin@cygwin.com \
    --cc=svnpenn@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).