2021-02-18 22:25:36 +01:00
|
|
|
#include "fastfetch.h"
|
|
|
|
|
|
2021-02-27 18:30:05 +01:00
|
|
|
void ffPrintShell(FFinstance* instance)
|
2021-02-18 22:25:36 +01:00
|
|
|
{
|
2021-02-27 18:30:05 +01:00
|
|
|
if(ffPrintCachedValue(instance, "Shell"))
|
2021-02-22 16:52:51 +01:00
|
|
|
return;
|
|
|
|
|
|
2021-02-18 22:25:36 +01:00
|
|
|
char* shellPath = getenv("SHELL");
|
2021-02-19 16:23:41 +01:00
|
|
|
if(shellPath == NULL)
|
|
|
|
|
{
|
2021-02-27 18:30:05 +01:00
|
|
|
ffPrintError(instance, "Shell", "getenv(\"SHELL\") == NULL");
|
2021-02-19 16:23:41 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-05 23:26:05 +01:00
|
|
|
char* value;
|
2021-02-18 22:25:36 +01:00
|
|
|
|
2021-03-05 23:26:05 +01:00
|
|
|
if(!instance->config.shellShowPath)
|
|
|
|
|
{
|
|
|
|
|
char* shellName = strrchr(shellPath, '/');
|
|
|
|
|
if(shellName != NULL)
|
|
|
|
|
value = ++shellName;
|
|
|
|
|
else
|
|
|
|
|
value = shellPath;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
value = shellPath;
|
|
|
|
|
}
|
2021-02-18 22:25:36 +01:00
|
|
|
|
2021-03-05 23:26:05 +01:00
|
|
|
ffPrintAndSaveCachedValue(instance, "Shell", value);
|
2021-02-18 22:25:36 +01:00
|
|
|
}
|