mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Shell: don't detect user shell
This commit is contained in:
@@ -20,10 +20,6 @@ typedef struct FFTerminalShellResult
|
||||
const char* terminalExeName; //pointer to a char in terminalExe
|
||||
FFstrbuf terminalVersion;
|
||||
uint32_t terminalPid;
|
||||
|
||||
FFstrbuf userShellExe;
|
||||
const char* userShellExeName; //pointer to a char in userShellExe
|
||||
FFstrbuf userShellVersion;
|
||||
} FFTerminalShellResult;
|
||||
|
||||
const FFTerminalShellResult* ffDetectTerminalShell();
|
||||
|
||||
@@ -269,18 +269,12 @@ static void getTerminalFromEnv(FFTerminalShellResult* result)
|
||||
|
||||
static void getUserShellFromEnv(FFTerminalShellResult* result)
|
||||
{
|
||||
ffStrbufSet(&result->userShellExe, &instance.state.platform.userShell);
|
||||
if(result->userShellExe.length == 0)
|
||||
return;
|
||||
|
||||
setExeName(&result->userShellExe, &result->userShellExeName);
|
||||
|
||||
//If shell detection via processes failed
|
||||
if(result->shellProcessName.length == 0 && result->userShellExe.length > 0)
|
||||
if(result->shellProcessName.length == 0 && instance.state.platform.userShell.length > 0)
|
||||
{
|
||||
ffStrbufAppendS(&result->shellProcessName, result->userShellExeName);
|
||||
ffStrbufSet(&result->shellExe, &result->userShellExe);
|
||||
ffStrbufSet(&result->shellExe, &instance.state.platform.userShell);
|
||||
setExeName(&result->shellExe, &result->shellExeName);
|
||||
ffStrbufAppendS(&result->shellProcessName, result->shellExeName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -348,10 +342,6 @@ const FFTerminalShellResult* ffDetectTerminalShell()
|
||||
result.terminalExeName = result.terminalExe.chars;
|
||||
result.terminalPid = 0;
|
||||
|
||||
ffStrbufInit(&result.userShellExe);
|
||||
result.userShellExeName = result.userShellExe.chars;
|
||||
ffStrbufInit(&result.userShellVersion);
|
||||
|
||||
getTerminalShell(&result, getppid());
|
||||
|
||||
getTerminalFromEnv(&result);
|
||||
@@ -360,11 +350,6 @@ const FFTerminalShellResult* ffDetectTerminalShell()
|
||||
ffStrbufClear(&result.shellVersion);
|
||||
getShellVersion(&result.shellExe, result.shellExeName, &result.shellVersion);
|
||||
|
||||
if(strcasecmp(result.shellExeName, result.userShellExeName) != 0)
|
||||
getShellVersion(&result.userShellExe, result.userShellExeName, &result.userShellVersion);
|
||||
else
|
||||
ffStrbufSet(&result.userShellVersion, &result.shellVersion);
|
||||
|
||||
if(ffStrbufEqualS(&result.shellProcessName, "pwsh"))
|
||||
ffStrbufInitStatic(&result.shellPrettyName, "PowerShell");
|
||||
else if(ffStrbufEqualS(&result.shellProcessName, "nu"))
|
||||
|
||||
@@ -379,10 +379,6 @@ const FFTerminalShellResult* ffDetectTerminalShell(void)
|
||||
ffStrbufInit(&result.terminalPrettyName);
|
||||
result.terminalPid = 0;
|
||||
|
||||
ffStrbufInit(&result.userShellExe);
|
||||
result.userShellExeName = "";
|
||||
ffStrbufInit(&result.userShellVersion);
|
||||
|
||||
uint32_t ppid;
|
||||
if(!getProcessInfo(0, &ppid, NULL, NULL, NULL))
|
||||
goto exit;
|
||||
|
||||
+3
-4
@@ -158,14 +158,13 @@ static inline void printCommandHelp(const char* command)
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(command, "shell-format"))
|
||||
{
|
||||
constructAndPrintCommandHelpFormat("shell", "{3} {4}", 7,
|
||||
constructAndPrintCommandHelpFormat("shell", "{3} {4}", 6,
|
||||
"Shell process name",
|
||||
"Shell path with exe name",
|
||||
"Shell exe name",
|
||||
"Shell version",
|
||||
"User shell path with exe name",
|
||||
"User shell exe name",
|
||||
"User shell version"
|
||||
"Shell pid",
|
||||
"Shell pretty name"
|
||||
);
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(command, "display-format"))
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "modules/shell/shell.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_SHELL_NUM_FORMAT_ARGS 7
|
||||
#define FF_SHELL_NUM_FORMAT_ARGS 6
|
||||
|
||||
void ffPrintShell(FFShellOptions* options)
|
||||
{
|
||||
@@ -36,9 +36,8 @@ void ffPrintShell(FFShellOptions* options)
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->shellExe},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, result->shellExeName},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->shellVersion},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->userShellExe},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, result->userShellExeName},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->userShellVersion}
|
||||
{FF_FORMAT_ARG_TYPE_UINT, &result->shellPid},
|
||||
{FF_FORMAT_ARG_TYPE_STRBUF, &result->shellPrettyName},
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -97,7 +96,4 @@ void ffGenerateShellJson(FF_MAYBE_UNUSED FFShellOptions* options, yyjson_mut_doc
|
||||
yyjson_mut_obj_add_uint(doc, obj, "pid", result->shellPid);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "processName", &result->shellProcessName);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "version", &result->shellVersion);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "userShellExe", &result->userShellExe);
|
||||
yyjson_mut_obj_add_strcpy(doc, obj, "userShellExeName", result->userShellExeName);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "userShellVersion", &result->userShellVersion);
|
||||
}
|
||||
|
||||
@@ -149,4 +149,5 @@ void ffGenerateTitleJson(FF_MAYBE_UNUSED FFTitleOptions* options, yyjson_mut_doc
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "hostName", &instance.state.platform.hostName);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "domainName", &instance.state.platform.domainName);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "exePath", &instance.state.platform.exePath);
|
||||
yyjson_mut_obj_add_strbuf(doc, obj, "userShell", &instance.state.platform.userShell);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user