From 9066003bb2419ef87e6f30eeb89ff7fef9c5c450 Mon Sep 17 00:00:00 2001 From: Andre Weinand Date: Fri, 9 Sep 2016 17:33:52 +0200 Subject: [PATCH] fix external terminal for linux --- .../electron-browser/terminalService.ts | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/vs/workbench/parts/execution/electron-browser/terminalService.ts b/src/vs/workbench/parts/execution/electron-browser/terminalService.ts index 0070014c0be..a9389602319 100644 --- a/src/vs/workbench/parts/execution/electron-browser/terminalService.ts +++ b/src/vs/workbench/parts/execution/electron-browser/terminalService.ts @@ -190,13 +190,20 @@ export class LinuxTerminalService implements ITerminalService { return new TPromise( (c, e) => { - const bashCommand = `${quote(args)}; echo; read -p "${LinuxTerminalService.WAIT_MESSAGE}" -n1;`; - - const termArgs = [ - '--title', `"${TERMINAL_TITLE}"`, - '-x', 'bash', '-c', - `''${bashCommand}''` // wrapping argument in two sets of ' because node is so "friendly" that it removes one set... - ]; + let termArgs: string[]; + + if (exec.indexOf('gnome-terminal') >= 0) { + const bashCommand = `${quote(args)}; echo; read -p "${LinuxTerminalService.WAIT_MESSAGE}" -n1;`; + termArgs = [ + '--title', `"${TERMINAL_TITLE}"`, + '-x', 'bash', '-c', + `''${bashCommand}''` // wrapping argument in two sets of ' because node is so "friendly" that it removes one set... + ]; + } else { + termArgs = [ + '-e', `''${quote(args)}''` // wrapping argument in two sets of ' because node is so "friendly" that it removes one set... + ]; + } // merge environment variables into a copy of the process.env const env = extendObject(extendObject( { }, process.env), envVars); @@ -206,13 +213,22 @@ export class LinuxTerminalService implements ITerminalService { env: env }; + let stderr = ''; const cmd = cp.spawn(exec, termArgs, options); cmd.on('error', e); + cmd.stderr.on('data', (data) => { + stderr += data.toString(); + }); cmd.on('exit', (code: number) => { if (code === 0) { // OK c(null); } else { - e(nls.localize('linux.term.failed', "'{0}' failed with exit code {1}", exec, code)); + if (stderr) { + const lines = stderr.split('\n', 1); + e(new Error(lines[0])); + } else { + e(new Error(nls.localize('linux.term.failed', "'{0}' failed with exit code {1}", exec, code))); + } } }); }); -- GitLab