From: Austin Ziegler Date: 2005-01-05T00:05:41+09:00 Subject: Re: Error handling in file related methods? On Sat, 11 Dec 2004 01:21:50 +0900, Johan Holmberg wrote: > I wonder what the "philosophy" is regarding error handling in file > related methods in Ruby. Let me give an example. It is the method > Kernel.test(?-, ...), i.e. a test to see if two files are hard links > to the same file: > > $ mkdir subdir > $ touch subdir/aaa > $ ln subdir/aaa subdir/bbb > $ > $ chmod 0755 subdir > $ ruby -e 'p test(?-, *ARGV)' subdir/aaa subdir/bbb > true > $ > $ chmod 0 subdir > $ ruby -e 'p test(?-, *ARGV)' subdir/aaa subdir/bbb > false <--- NOTE THIS !!! > $ > > The "problem" with this behaviour is that the files *are* hard links > but the permissions prevents us from finding that out. I think it > would be better to get an exception indicating that, instead of > "lying" to the script. > > I suspect that Ruby behaves in this way in several similar situations. > > Should this be changed? > If so, what would be the preferred action? I don't know what the preferred action would be on this, Johan -- I don't actually use Kernel#test. However, ?- is doing the same as bash's -ef test: [ subdir/aaa -ef subdir/bbb ] && echo true || echo false -austin -- Austin Ziegler * halostatue@gmail.com * Alternate: austin@halostatue.ca