Hi Clifford, I think you're right about different implementations giving different results.
Unfortunately the C code doesn't really say anything now, because I'd already done "sudo mv /users /Users" and everything is coming back uppercase. But since that renaming brought everything into line, there must have been and uppercase version and a lowercase version stored somewhere, rather than a single true name being differently interpreted by various implementations. Cheers, Chris On Mon, Jan 17, 2011 at 8:22 AM, Clifford Heath <[email protected]> wrote: > Chris, > > I don't think this is a Ruby thing, but comes from the different ways > Ruby gets the information. getpwuid gets your password entry from > the password database. Dir["/"] reads the content of the root directory. > The env, well, you know. > > I'm not sure what the Mac implementation of Dir.pwd does, but it could > not be any of the above. One BSD implementation I knew had a very > clunky method: it would progressively read the entries in .., ../.., > ../../.., > etc, and match the inode numbers with ., .., ../.., etc. I suspect that > Apple > has replaced that, as most unices have, with a kernel implementation, > but I can't see it documented in /usr/share/man/man2. > > https://github.com/ruby/ruby/blob/trunk/dir.c says it's implemented using > my_getcwd, which is probably just a wrapper for getcwd (man 3 getcwd) > from the Apple standard library. Try a little C program and tell us what it > says: > > #include <unistd.h> > void main() > { > char buf[1024]; > getcwd(buf, sizeof(buf)); > puts(buf); > exit(0); > } > > Clifford Heath. > > On 16/01/2011, at 10:59 PM, Chris Berkhout wrote: > >> Hi All, >> >> Today I was surprised to find that the "U" in Users is uppercase >> (which I consider correct) in: >> >> Etc.getpwuid.dir => "/Users/chrisberkhout" >> Dir.entries("/") => [..., "Users", ...] >> ENV['PWD'] => "/Users/chrisberkhout" >> >> But lowercase in: >> >> Dir.pwd => "/users/chrisberkhout" >> File.expand_path('.') => "/users/chrisberkhout" >> >> Also, >> - Manually changing into the uppercase directory doesn't help. >> - Deeper directories with uppercase letters seem fine. >> - Other root-level directories with uppercase letters seem fine. >> >> Anyone else run into this issue? >> >> Cheers, >> Chris >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby or Rails Oceania" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/rails-oceania?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Ruby or Rails Oceania" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rails-oceania?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Ruby or Rails Oceania" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rails-oceania?hl=en.
