I logged the AppleEvents that get sent from a Terminal window. The event that the osascript
command sends to the AppleScript compiler/interpreter wasn't logged. How come?
In greater detail, the following argument consists of three hypotheses followed by their logical conclusion. However, experiment shows that the conclusion is false. Hence the argument is faulty. Unfortunately, I don't know why it is faulty. Where does it break?
Hypotheses
macOS comes with a built-in AppleScript compiler/interpreter that is installed as an OSA component.
The Terminal command
osascript
does not "know" AppleScript. When passed a line of AppleScript code, it passes it on to the AppleScript compiler/interpreter via the OSA architecture by sending out an AppleEvent.The following line of code, when run in the Terminal, will cause all AppleEvents sent by commands that are executed from the same Terminal window afterwards to be printed out in the Terminal:
export AEDebugSends=1
>
export AEDebugSends=1
Conclusion
After running the following two commands in a Terminal window:
>
export AEDebugSends=1
>osascript -e 'tell application "Finder" to activate'
export AEDebugSends=1
osascript -e 'tell application "Finder" to activate'
two AppleEvents should be printed out:
- One directed from
osascript
to the AppleScript compiler/interpreter to compile and run the command 'tell application "Finder" to activate'. - One directed from the AppleScript compiler/interpreter to Finder to activate itself.
Actual output
Only one AppleEvent gets printed out, the one sent to Finder:
AE2000 (4085 ): Sending an event:
------oo start of event oo------
aevt('misc''actv' transactionID=0 sourcePSN=[0x0,e00e "Finder"] timeout=7200 eventSource=3 { &'subj':null(), &'csig':magn(65536) })
------oo end of event oo------