TerminalShell: clears version buffer if detection failed

This commit is contained in:
Carter Li
2026-09-25 10:58:27 +08:00
parent 537635cd9c
commit 93175aea1d
2 changed files with 12 additions and 4 deletions
@@ -429,7 +429,9 @@ const FFShellResult* ffDetectShell() {
if (result->processName.length > 0) { if (result->processName.length > 0) {
setShellInfoDetails(result); setShellInfoDetails(result);
if (instance.config.general.detectVersion) { if (instance.config.general.detectVersion) {
fftsGetShellVersion(result->exePath.length > 0 ? &result->exePath : &result->exe, result->exeName, &result->version); if (!fftsGetShellVersion(result->exePath.length > 0 ? &result->exePath : &result->exe, result->exeName, &result->version)) {
ffStrbufClear(&result->version);
}
} }
} }
@@ -484,7 +486,9 @@ const FFTerminalResult* ffDetectTerminal() {
if (result->processName.length > 0) { if (result->processName.length > 0) {
setTerminalInfoDetails(result); setTerminalInfoDetails(result);
if (instance.config.general.detectVersion) { if (instance.config.general.detectVersion) {
fftsGetTerminalVersion(&result->processName, result->exePath.length > 0 ? &result->exePath : &result->exe, &result->version); if (!fftsGetTerminalVersion(&result->processName, result->exePath.length > 0 ? &result->exePath : &result->exe, &result->version)) {
ffStrbufClear(&result->version);
}
} }
} }
@@ -354,7 +354,9 @@ const FFShellResult* ffDetectShell(void) {
*ext = '\0'; *ext = '\0';
} }
if (instance.config.general.detectVersion) { if (instance.config.general.detectVersion) {
fftsGetShellVersion(result->exePath.length > 0 ? &result->exePath : &result->exe, tmp, &result->version); if (!fftsGetShellVersion(result->exePath.length > 0 ? &result->exePath : &result->exe, tmp, &result->version)) {
ffStrbufClear(&result->version);
}
} }
} }
@@ -415,7 +417,9 @@ const FFTerminalResult* ffDetectTerminal(void) {
if (result->processName.length > 0) { if (result->processName.length > 0) {
setTerminalInfoDetails(result); setTerminalInfoDetails(result);
if (instance.config.general.detectVersion) { if (instance.config.general.detectVersion) {
fftsGetTerminalVersion(&result->processName, result->exePath.length > 0 ? &result->exePath : &result->exe, &result->version); if (!fftsGetTerminalVersion(&result->processName, result->exePath.length > 0 ? &result->exePath : &result->exe, &result->version)) {
ffStrbufClear(&result->version);
}
} }
} }