开发者

LoadError: no such file to load — curl

开发者 https://www.devze.com 2023-03-17 06:12 出处:网络
I just have a problem with a ruby script I just want to change the directory 开发者_StackOverflow中文版where the following command would be executed

I just have a problem with a ruby script

I just want to change the directory 开发者_StackOverflow中文版where the following command would be executed

I try this code but it didn't work

  puts "Nom du dossier svn?"
  @dossier = gets.chomp
  system("cd #{@dossier}")

(it's in french because i'm french ^^)

Someone can help me ?

Thank you


Use the Dir.chdir function.

When you do:

system("cd dir")

This in effect starts a shell, that shell changes to the given directory and promptly exits. It has no effect whatsoever on the calling process (your ruby script).


system spawn a subshell, that is this subshell that will change directory, then die.

You want your actual Ruby process to change directory, so use Dir.chdir(@dossier)

0

精彩评论

暂无评论...
验证码 换一张
取 消