假设你有一个 bash 脚本 test.sh
#!/bin/sh
echo 'Hello World!'
在 Linux 中,如果你想在 Ruby 中运行它,你只需这样做
irb(main):001:0> `./test.sh`
在 Windows 中你只会得到一个错误
Errno::ENOEXEC: Exec format error - ./test.sh
from (irb):2:in ``'
from (irb):2
from c:/Ruby193/bin/irb:12:in `<main>'
命令工作正常
irb(main):004:0> `grep`
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.
最佳答案
如果您安装了 Bash,请尝试:
irb(main):001:0> `bash ./test.sh`
关于ruby - Windows,从 Ruby 运行 shell 脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9560710/