Ruby即使目录存在,也没有这样的文件或目录@ dir_initialize

时间:2017-12-09 06:15:55

标签: ruby

我有:

ruby -v
=>ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]

puts arg_provide
=>/home/user/Bureau/Clips graver

input_file_or_directory = Shellwords.shellescape(arg_provide).to_s

puts input_file_or_directory
=>/home/user/Bureau/Clips\ graver

我什么时候

Dir.foreach("/home/user/Bureau/Clips\ graver") do |media|
=> IT'S WORKS FINE!

但是当我这样做时

Dir.foreach(input_file_or_directory) do |media|
=>Raise Uncaught exception: No such file or directory @ dir_initialize 
- /home/user/Bureau/Clips\ graver

我无法弄明白 有人帮帮我吗?

1 个答案:

答案 0 :(得分:0)

替换

Dir.foreach(arg_provideinput_file_or_directory)

Dir.foreach(arg_provide.to_s)