From: Sean Middleditch Date: 2002-04-03T06:45:12+09:00 Subject: Re: a note on the . and .. discussion UNIX does not treat . or .. specially. Any entry that begins with a . is ignored by default. (i.e., try running ls, chmod, chgrp, etc. on files in your home directory; then run ls -a and you'll see a bunch of configuration files whose name starts with . that weren't affected by the commands). Also, I don't know how ls is showing . and .. for you, unless you are already giving it -a, because ls should not by default display . and .. entries. ls * will, guaranteed, follow the same rules as chmod * (because the * is expanded by the shell, not the command); I suppose if you just type in ls without any arguments it could do all sorts of weird things depending on your flavour of UNIX. If you want chgrp or chmod to work on the .* entries, you specifically have to specify .*, not just *. (i.e. chown elanthis .*) Root must have . and .., because all directories have . and .., and there are no exceptions to rules in UNIX. In root, .. simply points back to root (i.e. the inode of .. in root is the same as the inode of root). Thus, Ruby should *not* treat them as you say, because that would do the unexpected. However, I *do* like the idea of a "parent" method, simply because it looks cleaner. ^,^ On Tue, 2002-04-02 at 16:13, Patrick May wrote: > I just realized that unix commands do not recognize the "." and ".." > when you execute a command. ls will show "." and ".." as directory > entries, but chmod, chgrp, grep, etc. all ignore "." and ".." when you > do a "chmod 666 *", etc. > > Adding to the apparent inconsistency -- even the root dir has "." and > ".." entries. I would think that if "." and ".." were to provide > information, then root wouldn't have a ".." > > Since these entries are "invisible" to most commands, and since these > entries don't seem to provide consistent information, they smell like > a special case to me. > > The first question I ask is: > > Why are they a special case? > > - to provide a way of navigating the filesystem tree > > This leads to my next (more on topic) question: > > Is there a better way of doing this in Ruby? > > - IMHO, I think that aDir.parent is cleaner than aDir[".."]. I also > think that "." and ".." should continue to be valid "glob" > expressions. > > The point is that unix treats these entries as a special case. If > these entries are special cases in unix, then it makes sense for us to > treat them as special cases in Ruby. > > ~ Patrick