Files
qt-creator/share/qtcreator/scripts/openTerminal.command
Fawzi Mohamed 18fa486531 consoleprocess: support Terminal.app on mac
Distinguishes the process that starts the terminal from the stub
process, as on mac to support Terminal.app they are different.

Handle the stub not through the process that starts the terminal,
but through the local socket (on *nix).

Replace the blocking wait(...) in the main thread, with a nonblocking
wait in the signal handler when receiving a SIGCHLD, to leave the
main thread able to handle communication with creator.

This change allows the use of terminal emulator commands
that share a single instance or that fork.
So this is also the real fix for QTCREATORBUG-1633 on linux.

If creator crashes the stub and the debugged program live on.
This was done on purpose, it could be changed if considered better.

Task-number: QTCREATORBUG-6371
Task-number: QTCREATORBUG-1633

Change-Id: I4d4fb3a67b1987f4e46e2c603dcefe8c15152ad2
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
2013-01-29 17:56:59 +01:00

37 lines
1.2 KiB
Bash
Executable File

#! /bin/bash
# ugly escaping: for apple script \ and " need to be escaped, whereas %q takes care of all bash escaping
declare -a args
mydir=`pwd`
mydir=$(printf '%q' "$mydir")
mydir="${mydir//\\/\\\\}"
args[0]="cd ${mydir//\"/\\\"};"
for a in "$@" ; do
x=$(printf '%q ' "$a")
x="${x//\\/\\\\}"
args[${#args[@]}]="${x//\"/\\\"}"
done
mArgs=${args[@]:0}
osascript <<EOF
--Terminal opens a window by default when it is not running, so check
on applicationIsRunning(applicationName)
tell application "System Events" to count (every process whose name is applicationName)
return result is greater than 0
end applicationIsRunning
set terminalWasRunning to applicationIsRunning("Terminal")
set cdScript to "$mArgs"
tell application "Terminal"
--do script will open a new window if none given, but terminal already opens one if not running
if terminalWasRunning then
do script cdScript
else
do script cdScript in first window
end if
set currentTab to the result
set currentWindow to first window whose tabs contains currentTab
activate
end tell
EOF