From 6ccc7f78f155b0629b4732257e656e2769217d00 Mon Sep 17 00:00:00 2001 From: Forest Hoffman Date: Thu, 7 Feb 2019 17:56:01 -0600 Subject: [PATCH] Escape "-Command" arguments - Fixes: https://github.com/codercom/bugs/issues/270. On Ubuntu 16.04 containers, the Terminal API fails to start the pwsh executable with any "-Command" arguments. This appears to be due to unescaped single quotes within the argument list. --- src/process.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/process.ts b/src/process.ts index ba0e64c6c9..bbbfb1d567 100644 --- a/src/process.ts +++ b/src/process.ts @@ -69,9 +69,10 @@ export class PowerShellProcess { powerShellArgs.push("-ExecutionPolicy", "Bypass"); } + this.startArgs = this.startArgs.replace(/'/g, '"'); powerShellArgs.push( "-Command", - "& '" + PowerShellProcess.escapeSingleQuotes(startScriptPath) + "' " + this.startArgs); + "'& \"" + PowerShellProcess.escapeSingleQuotes(startScriptPath) + "\" " + this.startArgs + "'"); let powerShellExePath = this.exePath;