From b87df82d58f8a91dd497e068e1879291b40eb2f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 19 Dec 2024 11:00:16 +0800 Subject: [PATCH] Shell (Windows): use $POWERSHELL_VERSION if available --- src/detection/terminalshell/terminalshell.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index ebacb444f..a591829a2 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -109,6 +109,15 @@ static bool getShellVersionFish(FFstrbuf* exe, FFstrbuf* version) static bool getShellVersionPwsh(FFstrbuf* exe, FFstrbuf* version) { + // Requires manually setting $POWERSHELL_VERSION + // $env:POWERSHELL_VERSION = $PSVersionTable.PSVersion.ToString(); fastfetch.exe + const char* env = getenv("POWERSHELL_VERSION"); + if (env) + { + ffStrbufSetS(version, env); + return true; + } + #ifdef _WIN32 if(getFileVersion(exe->chars, version)) { @@ -249,6 +258,13 @@ static bool getShellVersionZsh(FFstrbuf* exe, FFstrbuf* exePath, FFstrbuf* versi #ifdef _WIN32 static bool getShellVersionWinPowerShell(FFstrbuf* exe, FFstrbuf* version) { + const char* env = getenv("POWERSHELL_VERSION"); + if (env) + { + ffStrbufSetS(version, env); + return true; + } + return ffProcessAppendStdOut(version, (char* const[]) { exe->chars, "-NoLogo",