How To Crash Script Editor

OK, first let me say, “Don’t try this at home.” Now that you agree this is a bad idea, here’s what happened: I was playing with various versions of passing an argument from one script to another. My two scripts were simulating a phone call between Bert & Ernie. The goal was to identify as many variations of usefulness as I could from the exercise. Eventually I felt like I understood it and moved on. Later, in a completely different project, it came to me that the way I had used the “me” variable to differentiate between “on run” in an application and “on run” played from the Script Editor (“me” meaning “«script»” and “me” meaning “current application”) might cause Ernie to experience an existential crises. In fact, it was a bad one. So bad, that not only did Ernie handily crash the Script Editor in a mere 7 words, but after rebooting it, Ernie put on a dazzling display of trailing window clones & shadows which I hadn’t seen since PC’s began using mouses that were too fast for the monitor refresh!

So, that said – here’s the punch that knocked out Script Editor version 2.7 (176) with AppleScript 2.4 in Yosemite 10.10.5…


on run "«script»"
	return "«script»"
end run

Please don’t blame me for you trying this. But seriously, was it just me?

I should add that upon rebooting Script Editor, my crashing code had somehow transformed itself into Chinese. Which, when run, still crashes the Script Editor!


on run "꬀猀挀爀椀瀀琀묀"
	return "«script»"
end run

This caused the crash too. Again with conversion to Chinese characters and bizarre video artifacts upon reboot. I guess it wasn’t the “«script»” string.


on run "oops"
   return "oops"
end run

It appears that any quoted text string or number placed after “on run” will cause a crash. Script Editor either ignores or gives proper refusal to reserved words or other predefined strings. Typically indicating that they are illegal as a formal parameter.

All these are fine have no problem…

on run application
on run script
on run file
on run text
on run integer
on run null
on run (grr)
on run {}
on run []

This gets a tidy error…
on run Applescript’s Text Item Delimiters

But these oddities crash it…
on run [grr]
on run 666
on run “”

Oh, well… One more thing for the Applescript “Nope” list!

The thing is, of course, is that ‘on run’ is the first line of a ‘run’ handler. As with any handler, any parameter has to be either a variable to receive a passed value or a list containing a variable or variables, not a value itself.

on run aVariable – Whatever’s passed.
on run {aVariable} – The (first) item in what’s known to be a list.
on run {{a:aVariable}, {a:anotherVariable}} – The values of a in the first two items of a list of records
etc.