Problem with /FileUtils.chmod Ruby

I ran into a rather complicated problem with Ruby and File.chmod (the same problem exists with FileUtils.chmod.

Here is what I am doing for a test case:

File.chmod(1777, "testfile") 

But as soon as I did this, I get this as a set of permissions:

 --wxrwS--t 

This problem only exists when using * nix 4 bit permission sets. I googled it, but got nothing of value. When permission set 0777 is installed, it assigns correctly, but something greater than 0 for the first digit will spoil the permissions pretty badly.

Does anyone have any clues?

I know that I can make a system call to do what I want, but I'm sure it is something simple that I am missing.

+4
source share
1 answer

01777 will work. In ruby, a leading zero in an integer literal indicates that it is written in octal notation and file permissions are usually written as octal numbers.

+12
source

Source: https://habr.com/ru/post/1301266/


All Articles