From ec0af17fb579a0b7c7b1eff80cb55f855e94b81d Mon Sep 17 00:00:00 2001 From: Souma <101255979+5ouma@users.noreply.github.com> Date: Thu, 9 May 2024 20:39:17 +0900 Subject: [PATCH] Terminal (macOS): fix compatibility with `(*term)` (#909) Ignore (term). This is because Fig( (figterm)) migrated to CodeWhisperer( (cwterm)) and CodeWhisperer renamed to Q( (qterm)). Future changes will all be ignored by this change. Related: #676 --- src/detection/terminalshell/terminalshell_linux.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/detection/terminalshell/terminalshell_linux.c b/src/detection/terminalshell/terminalshell_linux.c index dbdc08900..006f40a37 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -307,10 +307,19 @@ static pid_t getTerminalInfo(FFTerminalResult* result, pid_t pid) #ifdef __APPLE__ // https://github.com/fastfetch-cli/fastfetch/discussions/501 - if (ffStrEndsWith(name, " (figterm)") || ffStrEndsWith(name, " (cwterm)")) + const char* pLeft = strstr(name, " ("); + if (pLeft) { - if (__builtin_expect(getProcessNameAndPpid(ppid, name, &ppid, NULL) != NULL, false)) - return 0; + pLeft += 2; + const char* pRight = strstr(pLeft, "term)"); + if (pRight && pRight[5] == '\0') + { + for (; pLeft < pRight; ++pLeft) + if (*pLeft < 'a' || *pLeft > 'z') + break; + if (pLeft == pRight && getProcessNameAndPpid(ppid, name, &ppid, NULL) != NULL) + return 0; + } } #endif