From 6d2c5e3d731feaf7ce223e361c3642ab11b6c213 Mon Sep 17 00:00:00 2001 From: Radu Date: Mon, 12 Aug 2024 15:39:29 +0300 Subject: [PATCH 1/2] Fix for pwsh users --- src/espIdf/monitor/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/espIdf/monitor/index.ts b/src/espIdf/monitor/index.ts index e803050c0..436fa8967 100644 --- a/src/espIdf/monitor/index.ts +++ b/src/espIdf/monitor/index.ts @@ -72,7 +72,7 @@ export class IDFMonitor { // Function to quote paths for PowerShell and correctly handle spaces for Bash const quotePath = (path) => { - if (shellType.includes("powershell")) { + if (shellType.includes("powershell") || shellType.includes("pwsh")) { return `'${path.replace(/'/g, "''")}'`; } else if (shellType.includes("cmd")) { return `"${path}"`; @@ -121,7 +121,7 @@ export class IDFMonitor { const envSetCmd = process.platform === "win32" ? "set" : "export"; const quotedIdfPath = quotePath(modifiedEnv.IDF_PATH); - if (shellType.includes("powershell")) { + if (shellType.includes("powershell") || shellType.includes("pwsh")) { this.terminal.sendText(`& ${envSetCmd} IDF_PATH=${quotedIdfPath}`); this.terminal.sendText(`& ${args.join(" ")}`); } else if (shellType.includes("cmd")) { From c02fff571c4aacb52411c7101f56f5ae48458b5a Mon Sep 17 00:00:00 2001 From: Radu Date: Mon, 23 Sep 2024 14:59:00 +0300 Subject: [PATCH 2/2] Fix commands execution for pwsh on linux --- src/espIdf/monitor/index.ts | 7 +++++-- src/utils.ts | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/espIdf/monitor/index.ts b/src/espIdf/monitor/index.ts index 436fa8967..91c523533 100644 --- a/src/espIdf/monitor/index.ts +++ b/src/espIdf/monitor/index.ts @@ -46,6 +46,7 @@ export class IDFMonitor { IDFMonitor.config = config; } + static async start() { const modifiedEnv = await appendIdfAndToolsToPath(this.config.workspaceFolder); if (!IDFMonitor.terminal) { @@ -122,8 +123,10 @@ export class IDFMonitor { const quotedIdfPath = quotePath(modifiedEnv.IDF_PATH); if (shellType.includes("powershell") || shellType.includes("pwsh")) { - this.terminal.sendText(`& ${envSetCmd} IDF_PATH=${quotedIdfPath}`); - this.terminal.sendText(`& ${args.join(" ")}`); + this.terminal.sendText(`$env:IDF_PATH = ${quotedIdfPath};`); + // For pwsh users on Linux, we need to add delay between commands + await new Promise((resolve) => setTimeout(resolve, 1000)); + this.terminal.sendText(` & ${args.join(" ")}\r`); } else if (shellType.includes("cmd")) { this.terminal.sendText(`${envSetCmd} IDF_PATH=${modifiedEnv.IDF_PATH}`); this.terminal.sendText(args.join(" ")); diff --git a/src/utils.ts b/src/utils.ts index bd0edf8d4..95b69659d 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1286,7 +1286,7 @@ export function getUserShell() { const shell = vscode.env.shell; // list of shells to check - const shells = ["powershell", "cmd", "bash", "zsh"]; + const shells = ["powershell", "cmd", "bash", "zsh", "pwsh"]; // if user's shell is in the list, return it for (let i = 0; i < shells.length; i++) {