diff --git a/src/detection/terminalshell/terminalshell.c b/src/detection/terminalshell/terminalshell.c index 822812882..99224718e 100644 --- a/src/detection/terminalshell/terminalshell.c +++ b/src/detection/terminalshell/terminalshell.c @@ -284,6 +284,22 @@ FF_MAYBE_UNUSED static bool getTerminalVersionXterm(FFstrbuf* exe, FFstrbuf* ver return version->length > 0; } +FF_MAYBE_UNUSED static bool getTerminalVersionUrxvt(FF_MAYBE_UNUSED FFstrbuf* exe, FFstrbuf* version) +{ + if(ffProcessAppendStdErr(version, (char* const[]){ + "urxvt", // Don't use exe because of urxvtd + "-invalid", + NULL + })) return false; + + //urxvt: "invalid": unknown or malformed option. + //rxvt-unicode (urxvt) v9.31 - released: 2023-01-02 + ffStrbufSubstrAfterFirstS(version, "(urxvt) v"); + ffStrbufSubstrBeforeFirstC(version, ' '); + + return version->length > 0; +} + static bool getTerminalVersionContour(FFstrbuf* exe, FFstrbuf* version) { const char* env = getenv("TERMINAL_VERSION_STRING"); @@ -371,6 +387,13 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe if(ffStrbufIgnCaseEqualS(processName, "xterm")) return getTerminalVersionXterm(exe, version); + if(ffStrbufIgnCaseEqualS(processName, "urxvt") || + ffStrbufIgnCaseEqualS(processName, "urxvtd") || + ffStrbufIgnCaseEqualS(processName, "rxvt") || + ffStrbufIgnCaseEqualS(processName, "rxvt-unicode") + ) + return getTerminalVersionUrxvt(exe, version); + #endif #ifdef _WIN32 diff --git a/src/detection/terminalshell/terminalshell_linux.c b/src/detection/terminalshell/terminalshell_linux.c index 7b72f8618..38d83e800 100644 --- a/src/detection/terminalshell/terminalshell_linux.c +++ b/src/detection/terminalshell/terminalshell_linux.c @@ -388,6 +388,11 @@ const FFTerminalShellResult* ffDetectTerminalShell() ffStrbufInitStatic(&result.terminalPrettyName, "GNOME Terminal"); else if(ffStrbufStartsWithS(&result.terminalProcessName, "kgx")) ffStrbufInitStatic(&result.terminalPrettyName, "GNOME Console"); + else if(ffStrbufEqualS(&result.terminalProcessName, "urxvt") || + ffStrbufEqualS(&result.terminalProcessName, "urxvtd") || + ffStrbufEqualS(&result.terminalProcessName, "rxvt") + ) + ffStrbufInitStatic(&result.terminalPrettyName, "rxvt-unicode"); #elif defined(__APPLE__)