与 MacRuby/XCode 的交互式 shell 机制
我有以下 noobie 类:
class CoreController < NSWindowController
attr_accessor :consoleOutput, :consoleInput, :command, :parsedcommand
def showInConsole_clicked(sender)
x = `"#{@consoleInput.stringValue()}"`
@consoleOutput.stringValue = x
@command.stringValue = @consoleInput.stringValue()
@parsedcommand.stringValue = x
end
end
属于该控制器的接口基本上从输入框读取并将其数据路由到 shell 语句。它有效,但没有我想要的那么酷。
例如,我可以使用“ls”,没有任何问题。但是,当我创建较长的命令(例如“ls -l”或“ruby -v”)时,几乎就像什么都没发生一样。有人有线索吗?
谢谢!
I have the following noobie class:
class CoreController < NSWindowController
attr_accessor :consoleOutput, :consoleInput, :command, :parsedcommand
def showInConsole_clicked(sender)
x = `"#{@consoleInput.stringValue()}"`
@consoleOutput.stringValue = x
@command.stringValue = @consoleInput.stringValue()
@parsedcommand.stringValue = x
end
end
The interface that belongs to this controller basically reads from an inputbox and routes its data to a shell statement. It works, but not as cool as I would want it to be.
I can use 'ls' for example, with no problems. However, when I create longer commands such as 'ls -l' or 'ruby -v', it is almost like nothing really happened. Anyone a clue?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题在于这一行中的双引号:
如果您输入 ruby-v,则会执行,但如果您输入
"ruby -v"
,则会失败因为没有名为“ruby -v”的可执行文件,因为只有ruby而退出。去掉引号就可以了。The problem is with the double-quotes in this line:
If you type ruby-v, that will be executed but if you type
"ruby -v"
, that will fail because no executable called "ruby -v", exits as there is only ruby. Remove the quotes and it will work.