File.basename, dirname and split changed in 1.8.0!

Why did the behaviour of File.basename, File.dirname and File.split
change in ruby 1.8.0?

The tests below run on 1.6.8( and 1.7.x, I think), but not on 1.8.0.

Is this intentional and what the rationale?

Cheers,

Thomas

require ‘test/unit’

class BaseFileTest < Test::Unit::TestCase
def test_dirname
assert_equal(“a/b/c”, File.dirname(“a/b/c/d”))
assert_equal(".", File.dirname(“c”))
assert_equal(“a/b”, File.dirname(“a/b/”))
end

def test_basename
assert_equal(“d”, File.basename(“a/b/c/d”))
assert_equal(“c”, File.basename(“c”))
assert_equal("", File.basename(“a/b/”))
end

def test_split
assert_equal([“a/b/c”, “d”], File.split(“a/b/c/d”))
assert_equal([“a/b/c/d”, “”], File.split(“a/b/c/d/”))
assert_equal([".", “a”], File.split(“a”))
end
end

Hi,

···

In message “File.basename, dirname and split changed in 1.8.0!” on 03/08/14, Thomas thomass@deltadata.dk writes:

Why did the behaviour of File.basename, File.dirname and File.split
change in ruby 1.8.0?

To conform POSIX basename and dirname. Blame POSIX.

						matz.

Yukihiro Matsumoto wrote:

Hi,

Why did the behaviour of File.basename, File.dirname and File.split
change in ruby 1.8.0?

To conform POSIX basename and dirname. Blame POSIX.

To summarize the examples, a trailing “/” is ignored. Is that the only
difference?

···

In message “File.basename, dirname and split changed in 1.8.0!” > on 03/08/14, Thomas thomass@deltadata.dk writes:

Hi,

···

In message “Re: File.basename, dirname and split changed in 1.8.0!” on 03/08/14, Joel VanderWerf vjoel@PATH.Berkeley.EDU writes:

To summarize the examples, a trailing “/” is ignored. Is that the only
difference?

I think so.

						matz.