Not sure whether this is fixed in 10.11, but I think there has already been discussion of osascript's tendency to precede output from command line JXA scripts with
warning: failed to get scripting definition from /usr/bin/osascript; it may not be scriptable.
This has not been a problem in Execute Shell Script actions since Peter very helpfully suggested the:
osascript -l JavaScript <<JXA_END 2>/dev/null
// script
JXA_END
pattern, redirecting the superfluous message off to null
.
It's also no problem with direct use of KM7's new native JXA actions, because we can switch off Include Errors
in the action's settings:
The only place where it might trip users up, is, perhaps, in using Custom Plugin actions which call a compiled JavaScript for Applications .scpt
The UTF-8 and multi-line complexities of reading KMPARAMs, for example, can be overcome by getting the KMPARAM from a JavaScript .scpt with a kind of matrushka pattern:
a = Application.currentApplication();
encodeURIComponent(
(a.includeStandardAdditions = true, a).doShellScript(
[
'LANGSTATE="$(defaults read -g AppleLocale).UTF-8"; ',
'if [[ "$LC_CTYPE" != *"UTF-8"* ]]; ',
'then export LC_ALL="$LANGSTATE" ; fi; ',
'echo "$KMPARAM_Text_to_encode"'
].join('')
)
);
but a user who downloads a custom action of this kind needs to be advised to switch off Include Errors
In order to get:
rather than:
Unless there is, perhaps, any way of specifying an initial default of (IncludeErrors: false)
in the .plist
file for a custom plugin action ?