From: merch-redmine@... Date: 2021-06-24T20:19:36+00:00 Subject: [ruby-core:104397] [Ruby master Bug#12261] Windows: File.dirname with 2+ / or 2+ \\ will return // or \\\\ Issue #12261 has been updated by jeremyevans0 (Jeremy Evans). Assignee set to usa (Usaku NAKAMURA) Status changed from Open to Assigned I'm not sure whether this behavior was originally expected, but I think changing it at this point isn't worth the backwards compatibility breakage. For example, consider the following: ```ruby dir = File.dirname(string) # string could be '/////' File.read(File.join(dir, 'server', 'share')) ``` If you change the behavior of `File.dirname` from returning `//` to returning `/`, you change which file is read. In general, that's probably going to result an an Errno::ENOENT exception, but in the pathological case, it results in an unintended file being read. @usa Can you please determine whether this is a bug? ---------------------------------------- Bug #12261: Windows: File.dirname with 2+ / or 2+ \\ will return // or \\\\ https://bugs.ruby-lang.org/issues/12261#change-92638 * Author: enebo (Thomas Enebo) * Status: Assigned * Priority: Normal * Assignee: usa (Usaku NAKAMURA) * Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- I am working through some File.dirname issues on JRuby and I saw a ruby/spec covering this behavior on windows: `File.dirname('/////').should == '//'` Same result if backslashes are used. Is there a reason for this result? It does not seem useful to me but I am not much of a windows user. I would think in this case it would be '/' since I don't see how this is useful for UNC paths in Ruby? If someone could explain it then I will document this at least in JRuby source code :) So far all versions of MRI seem to have this behavior. -- https://bugs.ruby-lang.org/ Unsubscribe: