Quote script path in Apple Script.

This commit is contained in:
Qiu Yuzhou
2017-09-16 17:11:22 +08:00
parent 35c04c7bbb
commit 19c8d047eb

View File

@ -57,7 +57,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
if attrs[FileAttributeKey.ownerAccountName] as! String != NSUserName() { if attrs[FileAttributeKey.ownerAccountName] as! String != NSUserName() {
//try fileMgr.setAttributes([FileAttributeKey.ownerAccountName: NSUserName()], ofItemAtPath: dirPath) //try fileMgr.setAttributes([FileAttributeKey.ownerAccountName: NSUserName()], ofItemAtPath: dirPath)
let bashFilePath = Bundle.main.path(forResource: "fix_dir_owner.sh", ofType: nil)! let bashFilePath = Bundle.main.path(forResource: "fix_dir_owner.sh", ofType: nil)!
let script = "do shell script \"bash \(bashFilePath) \(NSUserName()) \" with administrator privileges" let script = "do shell script \"bash \\\"(bashFilePath)\\\" \(NSUserName()) \" with administrator privileges"
if let appleScript = NSAppleScript(source: script) { if let appleScript = NSAppleScript(source: script) {
var err: NSDictionary? = nil var err: NSDictionary? = nil
appleScript.executeAndReturnError(&err) appleScript.executeAndReturnError(&err)