From: Motohiro KOSAKI <kosaki.motohiro@...>
Date: 2012-01-08T02:35:32+09:00
Subject: [ruby-core:41960] [ruby-trunk - Bug #5859] incorrect return value of Pathname.realdirpath of Pathname objects created by Pathname.entries


Issue #5859 has been updated by Motohiro KOSAKI.


A following modified script tell us why the script don't work as you expect. Pathname#entries return directly entrie, not absolute path. then, it forgot /tmp/thing.


% ./ruby--trunk -e "require 'pathname'; p Pathname.new('/tmp/thing').entries.sort[2]"      
#<Pathname:a>

It is not a bug. just misleading spec.

----------------------------------------
Bug #5859: incorrect return value of Pathname.realdirpath of Pathname objects created by Pathname.entries
https://bugs.ruby-lang.org/issues/5859

Author: Thomas Green
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]


It appears when calling realdirpath on a Pathname object returned by Pathname#entries, the returned value is always the current working directory of the ruby process, instead of the location of the file in the filesystem
This disagrees with the rdoc description of Pathname#realdirpath, which does state that realdirpath will return the absolute name of the file.

Tho following code demonstrates the issue:
----
mkdir /tmp/thing
touch /tmp/thing/a
cd ~
ruby-1.9.3-p0 -ve "require 'pathname'; puts Pathname.new('/tmp/thing').entries.sort[2].realdirpath"
----

This is the output from the ruby process:
----
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]
/home/t/a
----

According to my interpretation of the description in rdoc, the correct output should be "/tmp/thing/a"
http://www.ruby-doc.org/stdlib-1.9.3/libdoc/pathname/rdoc/Pathname.html#method-i-realdirpath


-- 
http://redmine.ruby-lang.org