summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pathname_builtin.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/pathname_builtin.rb b/pathname_builtin.rb
index 4bd8b002f3..84b2bf2848 100644
--- a/pathname_builtin.rb
+++ b/pathname_builtin.rb
@@ -299,9 +299,9 @@ class Pathname
path = @path == '/' ? @path : @path.chomp('/')
stack = []
- until File.directory?(path) || File.dirname(path) == path
+ until File.directory?(path) || (parent = File.dirname(path)) == path
stack.push path
- path = File.dirname(path)
+ path = parent
end
stack.reverse_each do |dir|