[bug #58654] -perm -+w does not behave like chmod (POSIX)

Bernhard Voelker <[email protected]>
Newsgroups gmane.comp.gnu.findutils.bugs
Message-ID <[email protected]>
Follow-up Comment #9, bug #58654 (project findutils):

Thanks for the heads-up.

Especially thanks for the additional example.  However, it does
not look very enlightening to me.


find . −perm −+w

prints (−print is assumed) the names of all files in or below the current
directory, with S_IWUSR set if the file creation mask does not have S_IWUSR
set (otherwise the S_IWUSR bit is ignored), S_IWGRP set if the file creation
mask does not have S_IWGRP set (otherwise S_IWGRP is ignored), and S_IWOTH set
if the file creation mask does not have S_IWOTH set (otherwise S_IWOTH is
ignored).


It is not very clear if the 3 conditions are logically OR-ed
or AND-ed.
Furthermore, in practice, `find -perm -+w` will output only
files which have ugo+w permissions, regardless of the current
umask, right?


$ for perm in u ug ugo uo g go o ; do \
    > f-$perm \
    && chmod a-rwx,$perm+w f-$perm; \
  done

$ ls -log f-*
-----w---- 1 0 Feb  2 02:39 f-g
-----w--w- 1 0 Feb  2 02:39 f-go
--------w- 1 0 Feb  2 02:39 f-o
--w------- 1 0 Feb  2 02:39 f-u
--w--w---- 1 0 Feb  2 02:39 f-ug
--w--w--w- 1 0 Feb  2 02:39 f-ugo
--w-----w- 1 0 Feb  2 02:39 f-uo

$ for u in 0000 0002 0022 0020 0222 0202 0220; do ( echo "umask: $u"; umask $u
&& find -perm -+w ); done
umask: 0000
./f-ugo
umask: 0002
./f-ugo
umask: 0022
./f-ugo
umask: 0020
./f-ugo
umask: 0222
./f-ugo
umask: 0202
./f-ugo
umask: 0220
./f-ugo



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?58654>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.