mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:14:37 +02:00
Shell (Linux): improves performance of busybox (ash) version detection
This commit is contained in:
@@ -168,7 +168,18 @@ static bool getShellVersionNushell(FFstrbuf* exe, FFstrbuf* version) {
|
||||
return getExeVersionRaw(exe, version); // 0.73.0
|
||||
}
|
||||
|
||||
static bool extractBusyboxVersion(const char* line, uint32_t len, void* userdata) {
|
||||
if (!ffStrStartsWith(line, "BusyBox v")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ffStrbufSetNS((FFstrbuf*) userdata, len - strlen("BusyBox v"), line + strlen("BusyBox v"));
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool getShellVersionAsh(FFstrbuf* exe, FFstrbuf* version) {
|
||||
ffBinaryExtractStrings(exe->chars, extractBusyboxVersion, version, (uint32_t) strlen("BusyBox v0.0.0"));
|
||||
|
||||
const char* error = ffStrbufEndsWithS(exe, "busybox")
|
||||
? ffProcessAppendStdErr(version, (char* const[]) { exe->chars, "ash", "--help", NULL })
|
||||
: ffProcessAppendStdErr(version, (char* const[]) { exe->chars, "--help", NULL });
|
||||
|
||||
Reference in New Issue
Block a user