-
-
Save kch/960048c72a9b55db40b3 to your computer and use it in GitHub Desktop.
works in macirb, fails in macruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env macruby | |
framework 'Cocoa' | |
path = "#{ENV['HOME']}/Desktop/Y-U-NO-TRASH-ME-MACRUBY.txt" | |
system "touch #{path}" | |
url = NSURL.fileURLWithPath(path) | |
urls = [url] | |
NSWorkspace.sharedWorkspace.recycleURLs(urls, completionHandler:nil) | |
puts "Should be false: #{File.exists?(path)}" |
Author
kch
commented
Aug 2, 2011
I know, right. mv $@ ~/.Trash
$ macirb foo.rb
# … irb output elided
Should be false: false
$ macruby foo.rb
Should be false: true
Fails in nush script, runs in nush interactive:
#!/usr/bin/env nush
((NSWorkspace sharedWorkspace)
recycleURLs:(array (NSURL fileURLWithPath: "/Users/kch/Desktop/a.txt"))
completionHandler:nil)
Fails in ObjC, too:
// clang -o bar bar.m -fobjc-gc-only -framework Cocoa
#import <Cocoa/Cocoa.h>
int main (int argc, const char * argv[]) {
NSString *path = @"/Users/kch/Desktop/a.txt";
NSURL *url = [NSURL fileURLWithPath:path];
NSArray *urls = [NSArray arrayWithObject:url];
[[NSWorkspace sharedWorkspace] recycleURLs:urls completionHandler:nil];
// sleep(1); // <- fails unless sleep is present
return 0;
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment