我可以使用反引号(和%x(),系统等)使用Ruby程序或irb运行Bash shell命令。但由于某些原因,这并不符合历史。为什么我不能从Ruby中调用`history`?
例如:
jones$ irb --simple-prompt
>> `whoami`
=> "jones\n"
>> `history`
(irb):2: command not found: history
=> ""
从Ruby程序内它会产生这样的错误:
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31: command not found: history
在bash本身,这些命令做工精细
它不是Ruby的呼叫调用一个新的shell - 它根本找不到那个命令...
Anyo ne知道为什么?我很难...
同样有用的方法可以通过反引号/ etc来调用它:echo“history”| bash -i 2>/dev/null(信用:theosp) – Kevin 2012-08-05 06:07:59