From f8fe92aa77415eb285c5167b30a1701cb8c2c062 Mon Sep 17 00:00:00 2001 From: gazer Date: Wed, 3 Feb 2016 12:50:31 +0300 Subject: [PATCH] run a program with run-script, so terminal will not close immediately after execution --- src/ddebug/common/nodebug.d | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/ddebug/common/nodebug.d b/src/ddebug/common/nodebug.d index 2529718..40919a9 100644 --- a/src/ddebug/common/nodebug.d +++ b/src/ddebug/common/nodebug.d @@ -75,10 +75,22 @@ class ProgramExecutionNoDebug : Thread, ProgramExecution { // external console support if (!_terminalExecutable.empty) { string cmdline = escapeShellCommand(params); - params.length = 0; - params ~= _terminalExecutable; - params ~= "-e"; - params ~= cmdline; + string shellScript = ` +rm $0 +` ~ cmdline ~ ` +exit_code=$? +echo " +----------------------- +(program returned exit code: $exit_code)" +echo "Press any key to continue..." +dummy_var="" +read dummy_var +exit $exit_code +`; + std.file.write(std.path.buildPath(_executableWorkingDir, "dlangide_run_script.sh"), shellScript); + string setExecFlagCommand = escapeShellCommand("chmod", "+x", "dlangide_run_script.sh"); + spawnShell(setExecFlagCommand, stdin, stdout, stderr, null, Config.none, _executableWorkingDir); + params = [_terminalExecutable, "-e", "./dlangide_run_script.sh"]; } File newstdin;