views:

2384

answers:

4

In Cygwin a space in a path has to be escaped with a backslash Not true in Windows, put the whole path in a quote

Is there a way to convert to this automatically in Ruby?

Otherwise, how in Ruby do I detect if I am running with Windows or Cygwin?

+1  A: 

Quoting paths in Cygwin ought to work fine.

Andrew Medico
A: 

I found how to detect the platform at least - the RUBY_PLATFORM constant defines that.

theschmitzer
A: 

Yes... RUBY_PLATFORM will report mswin on windows. Also within ruby on windows you can use

'C:/windows/Documents\ and\ Settings/'

or

'C:\\windows\\Documents\ and\ Settings\\'
anshul
+1  A: 

http://rant.rubyforge.org/

sys.escape("foo bar")
# gives on Windows: '"foo bar"'
# other systems: 'foo\ bar'
knoopx