Can't use spoon to call Mac OS `open` or `osascript`
Closed this issue · 2 comments
matschaffer commented
I'm guessing it has something to do with these commands being mac-specific, but I thought I should bring it up since we tripped over it working on redcar.
Here's a sample script that illustrates the issue on rev 560066:
require 'rubygems'
require 'spoon'
open_command = ['open', '-a', 'Finder', '/Applications']
osa_command = ['osascript', '-e', 'tell application "Terminal" to activate']
method = :spoon
if method == :spoon
puts "Using spoon"
Spoon.spawn(*open_command)
Spoon.spawn(*osa_command)
else
puts "Using system"
system(*open_command)
system(*osa_command)
end
evilrich commented
You should specify the path to open or use spawnp.
Spoon.spawn('/usr/bin/open', '-a', 'Finder', '/Applications')
Spoon.spawnp('open', '-a', 'Finder', '/Applications')
I suspect that part of the reason you are having a problem is that Spoon doesn't handle error codes returned by posix_spawn so you can't easily tell when it fails. I have a fix for this here: 9baec25
headius commented
The errno fix was incorporated some time ago, and the remainder of this issue is just misuse.