Last updated 2014-12-16
This is an injection service for F-Script provided as Automator workflow.
The services I found around the web never completely worked well for me, usually I got the Automator workflow icon in menubar running forever. Also I noticed that they left a lldb process running even after the injected program had quit.
I checked and noticed that lldb doesn't cope well with the absence of stdin and that is exactly how it is usually executed when called from a shell script in an Automator workflow. Moreover I didn't quite like the approach with a tempfile that was being used.
I checked lldb's doc and the proper way to run a non-interactive session is via its scripting API, that happens to be in Python.
Since Python is such a joyful language I wrote my own little injection script the way it was meant to be.
Due to an issue with lldb on 10.10 the process running the python interpreter gets stuck, I therefore switched to using a shell script and a temporary file.
I'm updating the following instruction to reflect that, the workflow script is tested and working fine.
In order to create the service follow these steps:
- open Automator
- create a new document of type "Service"
- drag a Run Applescript element to the workflow
- copy the applescript script from this gist into the newly created element
- drag a Run Shell Script element to the workflow
- copy the shell script from this gist into the newly created element
- set the shell to /bin/sh, set "Pass input" setting to "as arguments"
- save the service as "Inject F-Script" or any other name you prefer into ~/Library/services
- Open an application
- go to the application menu > Services
- run the injection service
If you are curious to see the kind of issue lldb gets when called without a proper stdin just run:
lldb </dev/null
This will produce a lot of garbage and either correctly exit with status 0 or get stuck.
When passing commands from a script file with --source flag the outcome is a bit different, resulting in either a stuck process or a memory fault, try:
echo "quit" >/tmp/lldb.tmp; lldb -s /tmp/lldb.tmp </dev/null
These lines are unharmful, to clean the stuck process just kill them. If you didn't have previous running lldb instance you can simply run killall lldb