当我从 TextMate 运行时,为什么“gets"在我的 Ruby 脚本中不起作用? [英] Why isn't 'gets' working in my Ruby script when I run from TextMate?
问题描述
运行以下 ruby 脚本时:
When running the following ruby script:
puts gets.inspect
在终端上,我被提示输入,然后显示 inspect
输出,但是如果我使用 CMD+R
快捷方式从 TextMate 内部运行相同的脚本然后它只是输出 nil
就好像没有 gets
方法一样.
On the terminal I am prompted for input and then the inspect
output is shown, but if I run the same script from inside TextMate using the CMD+R
shortcut then it just outputs nil
as if there is no gets
method.
这是为什么?从我读过的内容来看,当脚本请求来自 STDIN 的输入时,TextMate 应该显示一个输入对话框,但在这种情况下不会发生这种情况.
Why is this? From what I've read TextMate is supposed to show an input dialog when input from STDIN is requested by the script, but that isn't happening in this case.
推荐答案
请参阅此博客条目;大概你在雪豹上?
See this blog entry; presumably you're on Snow Leopard?
从评论中,一些用户说这个文件在雪上对他们有用豹.根据@dmarkow 的回答,将此文件复制到:/Applications/TextMate.app/Contents/SharedSupport/Support/lib/
您可能希望保留一份文件副本,因为 TextMate 的更新可能会替换它.
From the comments, some users say that this file has worked for them on Snow Leopard. Per @dmarkow's answer, copy this file to:
/Applications/TextMate.app/Contents/SharedSupport/Support/lib/
You may want to keep a copy of the file around as updates to TextMate may replace it.
这篇关于当我从 TextMate 运行时,为什么“gets"在我的 Ruby 脚本中不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!