How to invoke osascript 'Generic Scripting System'?

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):

  • Mac Automation Scripting Guide - part of which is the list of languages

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, ...).


What osalang is actually doing, is talking to the Component Manager and returning all components of type osa (the space at the end is intentional, since this is an OSType aka FourCC). The Component Manager is a software plugin framework which was originally introduced on Classic Mac OS, first for use by QuickTime, and was later heavily used by many Classic Mac OS components, among others Open Scripting Architecture (OSA). In OS X / macOS (and especially so in recent versions), it has been deprecated and is used far less than Classic Mac OS used it, since there are now much better alternatives (such as Objective C classes). The only two things in recent macOS releases that still use Component Manager are OSA and certain audio APIs. (By contrast, in Classic Mac OS it was used for a lot of other stuff, like QuickDraw GX and ColorSync, which have since been replaced by newer technologies.)

So, macOS comes with three osa type components out of the box: ascr (AppleScript), jscr (JavaScript), and scpt (Generic Scripting System). Developers can register additional components to implement further OSA languages, although that is rarely done. What scpt does, is it isn't actually a language, instead it is a programming layer which developers can talk to instead of having to talk directly to the underlying scripting components such as ascr and jscr. Think of it like a middleman, an intermediary. If you look at the macOS SDK, you can find its API declared in OSAGeneric.h which can be found in OpenScripting framework. One of the features it adds to the underlying OSA language components, is routing of .scpt files. Basically, a program (such as osascript or "Script Editor") can call an API (OSALoad) to load a .scpt file. There is a field in the file header or trailer which states which actual scripting language is being used. The Generic Scripting System contains the code to interpret that file header/trailer and then sends the contents of the .scpt file to the appropriate language engine. So, talking to "Generic Scripting System", instead of directly to the underlying language engines, is actually important for developers if they want to support loading .scpt files in any language.