[ruby-core:82828] [Ruby trunk Bug#13908] Result of Pathname#dirname / File.dirname handling of paths with trailing slashes is surprising

From: therealdave.myron@...
Date: 2017-09-16 04:14:55 UTC
List: ruby-core #82828
Issue #13908 has been reported by davemyron (Dave Myron).

----------------------------------------
Bug #13908: Result of Pathname#dirname / File.dirname handling of paths with trailing slashes is surprising
https://bugs.ruby-lang.org/issues/13908

* Author: davemyron (Dave Myron)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 2.4.1p111
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
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)

What is the reasoning for the above being the behavior? 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)



-- 
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>

In This Thread

Prev Next