Interactive shell mechanism with MacRuby/XCode

288 views Asked by At

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!

1

There are 1 answers

0
Guilherme Bernal On BEST ANSWER

The problem is with the double-quotes in this line:

x = `"#{@consoleInput.stringValue()}"`

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.