Project

General

Profile

Actions

Bug #13908

closed

Result of Pathname#dirname / File.dirname handling of paths with trailing File::SEPARATOR is surprising

Added by davemyron (Dave Myron) over 6 years ago. Updated over 6 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:82828]

Description

Given File.dirname("/some/folder/") the result of /some is very surprising because the path is "obviously" a directory without a file specified. (I got bit by this today… yes, I needed more tests)

My expectation was that it would return /some/folder. My expectation seems consistent with the method's documentation which states "Returns all components of the filename given in file_name except the last one." – the "last one" should be the item after the last File::SEPARATOR ("/" on my system)

What is the reasoning for the above being the behavior?

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0