如何检测如何转义路径中的空格

时间:2021-12-11 05:40:55

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

在Cygwin中,路径中的空格必须使用反斜杠进行转义在Windows中不正确,将整个路径放在引号中

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

有没有办法在Ruby中自动转换为这个?

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

否则,如何在Ruby中检测我是在运行Windows还是Cygwin?

3 个解决方案

#1


1  

http://rant.rubyforge.org/

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

#2


1  

Quoting paths in Cygwin ought to work fine.

Cygwin中的引用路径应该可以正常工作。

#3


0  

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

我发现至少如何检测平台--RUBY_PLATFORM常量定义了这个。

#1


1  

http://rant.rubyforge.org/

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

#2


1  

Quoting paths in Cygwin ought to work fine.

Cygwin中的引用路径应该可以正常工作。

#3


0  

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

我发现至少如何检测平台--RUBY_PLATFORM常量定义了这个。