Skip to content

Commit b87df82

Browse files
committed
Shell (Windows): use $POWERSHELL_VERSION if available
1 parent c145ce4 commit b87df82

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/detection/terminalshell/terminalshell.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,15 @@ static bool getShellVersionFish(FFstrbuf* exe, FFstrbuf* version)
109109

110110
static bool getShellVersionPwsh(FFstrbuf* exe, FFstrbuf* version)
111111
{
112+
// Requires manually setting $POWERSHELL_VERSION
113+
// $env:POWERSHELL_VERSION = $PSVersionTable.PSVersion.ToString(); fastfetch.exe
114+
const char* env = getenv("POWERSHELL_VERSION");
115+
if (env)
116+
{
117+
ffStrbufSetS(version, env);
118+
return true;
119+
}
120+
112121
#ifdef _WIN32
113122
if(getFileVersion(exe->chars, version))
114123
{
@@ -249,6 +258,13 @@ static bool getShellVersionZsh(FFstrbuf* exe, FFstrbuf* exePath, FFstrbuf* versi
249258
#ifdef _WIN32
250259
static bool getShellVersionWinPowerShell(FFstrbuf* exe, FFstrbuf* version)
251260
{
261+
const char* env = getenv("POWERSHELL_VERSION");
262+
if (env)
263+
{
264+
ffStrbufSetS(version, env);
265+
return true;
266+
}
267+
252268
return ffProcessAppendStdOut(version, (char* const[]) {
253269
exe->chars,
254270
"-NoLogo",

0 commit comments

Comments
 (0)