# File.extname("foo bar") = " bar" .................?

**URL:** <https://www.ruby-forum.com/t/file-extname-foo-bar-bar/142312>\
**Category:** Ruby\
**Created:** [July 6, 2008, 5:35pm UTC](https://www.ruby-forum.com/t/file-extname-foo-bar-bar/142312 "2008-07-06T17:35:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ThoML](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/d78d45/32.png) [@ThoML](https://www.ruby-forum.com/u/ThoML)\
**Post date:** [July 6, 2008, 5:35pm UTC](https://www.ruby-forum.com/t/file-extname-foo-bar-bar/142312/1 "2008-07-06T17:35:26Z")

</div>

Hi,

I just realized that the result of

File.extname(“foo bar”)

is

=\> " bar"

I have to admit this comes unexpected. In file.c, I found this

#if USE\_NTFS  
#define istrailinggabage(x) ((x) == ‘.’ || (x) == ’ ')  
#else  
#define istrailinggabage(x) 0  
#endif

and

#if defined \_WIN32 || defined **CYGWIN**  
#define USE\_NTFS 1  
#else  
#define USE\_NTFS 0  
#endif

Is this intentional? Could somebody please explain.

This is on  
ruby 1.8.7 (2008-06-20 patchlevel 22) [i386-cygwin]  
and  
ruby 1.9.0 (2008-06-20 revision 17482) [i386-cygwin]

With ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32] the result is  
closer to what I’d expect:  
$ /cygdrive/c/ruby/bin/ruby -e “p File.extname(‘foo bar’)”  
“”

Thanks,  
Thomas.

---

<div class="post-metadata">

**Author:** ![ThoML](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/d78d45/32.png) [@ThoML](https://www.ruby-forum.com/u/ThoML)\
**Post date:** [July 6, 2008, 6:29pm UTC](https://www.ruby-forum.com/t/file-extname-foo-bar-bar/142312/2 "2008-07-06T18:29:56Z")

</div>

Hi,

At Mon, 7 Jul 2008 00:26:39 +0900,  
ThoML wrote in [ruby-talk:307404]:

> I just realized that the result of
> 
> File.extname(“foo bar”)
> 
> is
> 
> =\> " bar"

Thank you, fixed now.
