[#77789] [Ruby trunk Feature#12012] Add Boolean method — prodis@...
Issue #12012 has been updated by Fernando Hamasaki de Amorim.
4 messages
2016/10/27
[ruby-core:77504] [Ruby trunk Bug#12814] Pathname#each_child(false) produces unusable file paths
From:
tao@...
Date:
2016-10-06 14:10:56 UTC
List:
ruby-core #77504
Issue #12814 has been updated by Mr. Tao.
Sorry, I over edited my post. Argument to pathname is some existing folder, even `'..'` produces the error.
~~~ ruby
>> Pathname.new('..').each_child(false) { |f| p f.realpath }
~~~
~~~none
Errno::ENOENT: No such file or directory @ realpath_rec - <some_path_here>
from (irb):10:in `realpath'
from (irb):10:in `realpath'
from (irb):10:in `block in irb_binding'
from /usr/local/Cellar/ruby/2.3.1/lib/ruby/2.3.0/pathname.rb:490:in `each'
from /usr/local/Cellar/ruby/2.3.1/lib/ruby/2.3.0/pathname.rb:490:in `each_child'
from (irb):10
from /usr/local/bin/irb:11:in `<main>'
~~~
----------------------------------------
Bug #12814: Pathname#each_child(false) produces unusable file paths
https://bugs.ruby-lang.org/issues/12814#change-60768
* Author: Mr. Tao
* Status: Feedback
* Priority: Normal
* Assignee:
* ruby -v: ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
I tried to iterate over items in a directory with `each_child` testing each item whether it is a directory or not with `directory?`. This was working just fine until I added **`false`** as an argument to `each_child`.
~~~ ruby
Pathname.new('.').each_child { |f| p f.realpath } # works as expected
Pathname.new('.').each_child(false) { |f| p f.realpath } # throws an error
~~~
As per Ruby doc "By default, the yielded pathnames will have enough information to access the files.", however pathnames yielded with `with_directory=false` are completely useless as file paths.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>