Thanks both, I will commit the following once others have reviewed:
http://bogomips.org/ruby.git/patch?id=fbd3769851f
(git://80x24.org/ruby.git bug9581)