Created
June 22, 2016 10:54
-
-
Save uchcode/709943a263aca2db68dc9371ddddb039 to your computer and use it in GitHub Desktop.
runScript() のwithParametersバグとその回避・代替案 ref: http://qiita.com/tom-u/items/a9335672f21e91a4a69d
This file contains hidden or 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
function run(argv) { | |
$.NSLog('%@', JSON.stringify(argv)) | |
return argv | |
} |
This file contains hidden or 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
app = Application.currentApplication() | |
app.includeStandardAdditions = true | |
argv = ['hoge', 'fuga'] | |
scpt = '/path/to/script/bar.scpt' | |
// パラメーターを渡すと返値が発生。エラーとなるので例外処理で回避。 | |
// bar.scptからの返値は扱えない。 | |
try { app.runScript(scpt, {withParameters: argv}) } catch(e) {} | |
// パラメーターも意図通りに渡せて返値も取得可能。 | |
app.doShellScript(`osascript "${scpt}" ${argv.join(' ')}`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment