This unifies the three separate copies of the AppleScript used to query the system’s mode.
Each of the three approaches has some changes
ns-do-applescript uses AppleScript’s built-in boolean coercion to integer, since it doesn’t support AppleScript booleans;
mac-do-applescriptseems to return the command output as a string, so this avoids the extra conversion to an AppleScript string and returns the boolean directly; and
osascript now uses process-lines instead of shell-command-to-string which avoids shell invocation, the need to handle any shell escaping in the arguments, and the need to trim the result (which is now a list of output lines).
I tested both the ns-do-applescript and osascript approaches, but I’m not sure where mac-do-applescript comes from. If you let me know, I will mention it in the doc/comments and test that approach as well.
This unifies the three separate copies of the AppleScript used to query the system’s mode.
Each of the three approaches has some changes
ns-do-applescript
uses AppleScript’s built-in boolean coercion to integer, since it doesn’t support AppleScript booleans;mac-do-applescript
seems to return the command output as a string, so this avoids the extra conversion to an AppleScript string and returns the boolean directly; andosascript
now usesprocess-lines
instead ofshell-command-to-string
which avoids shell invocation, the need to handle any shell escaping in the arguments, and the need to trim the result (which is now a list of output lines).