If you want the Terminal to close when the program finishes, you can modify the command to read as follows:
osascript -e 'tell app "Terminal"' -e 'activate' -e 'do script (quoted form of "$SCRIPT") & "; exit"' -e 'end tell'
This seems slightly less confusing to students, some of whom will otherwise end up with a BUNCH of Terminal windows open, and sometimes interact with an old instance of the program.
You also have to make sure you go into Terminal / Preferences in the menu, select the Settings icon, Shell tab, and under "When the shell exits:", pick "Close if the shell exited cleanly". This also allows you to change the semicolon (
to the AND operator (&&) and control whether the window closes via the return value from main (return 0; -> Terminal closes, while any non-zero return value keeps the Terminal window open).
Of course, this is slightly inconsistent--it's not the same as the behavior under Windows (and I haven't tested it under Linux, so I don't know how it differs). Since cb_console_runner doesn't seem to exist in the Mac OS X version of C::B, here's an alternative:
osascript -e 'tell app "Terminal"' -e 'activate' -e 'do script (quoted form of "$SCRIPT") & "; echo \'Press any key to continue.\'; read -n 1; exit"' -e 'end tell'
It shows that big "ugly" command in the Terminal window, but at least the behavior is consistent with C::B's behavior under Windows (and what students seem to expect nowadays ... suppressing a rant about "kids" who learn to program only using IDEs and GUIs ... there, I'm all better now). ;-)