From e157b9a51fc14f951fd34525c8081e9006f6775e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 27 Apr 2024 16:29:35 +0800 Subject: [PATCH] TerminalShell (Linux): fix nixos wrapped process name Fix #814 --- src/detection/terminalshell/terminalshell_linux.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/detection/terminalshell/terminalshell_linux.c b/src/detection/terminalshell/terminalshell_linux.c index e6e28794..7e747793 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -482,14 +482,12 @@ static void setShellInfoDetails(FFShellResult* result) static void setTerminalInfoDetails(FFTerminalResult* result) { - if(result->exeName[0] == '.' && ffStrEndsWith(result->exeName, "-wrapped")) + if(ffStrbufStartsWithC(&result->processName, '.') && ffStrbufEndsWithS(&result->processName, "-wrapped")) { // For NixOS. Ref: #510 and https://github.com/NixOS/nixpkgs/pull/249428 // We use processName when detecting version and font, overriding it for simplification - ffStrbufSetNS( - &result->processName, - (uint32_t) (strlen(result->exeName) - strlen(".-wrapped")), - result->exeName + 1); + ffStrbufSubstrBefore(&result->processName, result->processName.length - (uint32_t) strlen("-wrapped")); + ffStrbufSubstrAfter(&result->processName, 1); } if(ffStrbufEqualS(&result->processName, "wezterm-gui"))