I’m writing a script to interact with GDB and need for GDB to think that it’s connected to a terminal. I found some references online to C functions that can be used to do this but my program is written in Groovy (Java) and I want to avoid using the JNI interface. I thought a better way to do this would be to use expect.
As a script:
#!/usr/bin/env expect
eval spawn $argv
interact
When run from my script:
"expect -c 'eval spawn " + cmd + "; interact'".execute()
The problem with these scripts is that expect never seems to terminate. I would like for my expect wrapper to be generic so I don’t want to trap on specific words. I also do not want to use the GDB/MI interface because I would like to generate a log of the GDB session that looks like you would see it from a terminal. How can I get my expect wrapper to terminate properly? Do I need to worry about quotes in the provided command or is spawn smart enough to figure out that an item in the list with spaces is still one argument?
Giving up and just using the MI interface