MacOS – How to invoke osascript ‘Generic Scripting System’

applescriptmacosscript

The terminal command osalang list the following installed OSA languages supported by osascript.

AppleScript
JavaScript
Generic Scripting System

Using AppleScript or JavaScript works. For example:

osascript -l JavaScript \
    -e 'Application("iTunes").currentTrack.name()'

However, something like to following returns a "found unknown token" error.

osascript -l 'Generic Scripting System' \
    -e '#!/bin/bash' \
    -e 'echo $HOME'

How does one invoke osascript for 'Generic Scripting System' from the command line for some non-AppleScript, non-JavaScript scripting … without using any (intermediate) AppleScript or JavaScript? Is this even possible?

Best Answer

According to OS X system internals, the "Generic Scripting System" is a generic class to contain the two flavors of scripting supported:

  • AppleScript
  • JavaScript

It's not some third option that adds one or more new dialects, but a container to hold the existing ones. This is indirectly explained in Apple's documentation - they list the two languages and don't mention the wrapper class (or whatever it's proper name is):

If you needed other languages, I would call AppleScript "do shell script..." to then call whatever shell executable that ships by Apple or you have installed (bash, sh, python, swift, perl, ...).