File permissions w/Dir.mkdir

In OS X 10.4.9, Ruby 1.8.4 when I use:
Dir.mkdir(file_name, 755)

The directories created are drop-box, owner-only.
It seems the Dir class expects the leading bit.
So, it should be 0755 and not 755.

When using:
Dir.mkdir(file_name)

Without permissions, it appears to default to 0755.

Just thought this might be useful for some people.
Seems like I read this in the Pickaxe, but I forgot.
It is interesting, since chmod accepts 755 and assumes you mean 0755
Seems to me that Dir should do the same assuming… but doesn’t

John J.

On Thu, Jun 28, 2007 at 11:24:14AM +0900, John J. wrote:

Without permissions, it appears to default to 0755.

Just thought this might be useful for some people.
Seems like I read this in the Pickaxe, but I forgot.
It is interesting, since chmod accepts 755 and assumes you mean 0755
Seems to me that Dir should do the same assuming… but doesn’t

Dir.mkdir accepts octal numbers, which is standard notation for this
sort of thing. A leading 0 makes Ruby interpret it as octal. You could
say Dir.mkdir(file_name, 493), but that’s sick and twisted.

Also, without the second argument it defaults to 0777, which will get
modified by the umask. cf lines 912-917 of dir.c in the ruby 1.8.6
source.

The reason chmod on the command line accepts 755 is because it can
assume you mean octal digits. Also, I think I’ve come across a few
(weirder) chmods that require the leading 0, but that was a long time
ago.