diff --git a/src/modules.go b/src/modules.go index 177dd9f..44b3f37 100644 --- a/src/modules.go +++ b/src/modules.go @@ -130,10 +130,16 @@ func initializeModuleMap() { // Init system module initSystemModule := StormfetchModule{stormfetchModuleConfig: stormfetchModuleConfig{Name: "init_system", Format: "%3Init: %4$INIT"}, Execute: func(sm StormfetchModule) string { + initSystem := GetInitSystem() + + if initSystem == "" { + return "" + } + return os.Expand(sm.Format, func(s string) string { switch s { case "INIT": - return GetInitSystem() + return initSystem default: return "" } diff --git a/src/system.go b/src/system.go index cdb0138..82a0d46 100644 --- a/src/system.go +++ b/src/system.go @@ -138,6 +138,11 @@ func GetInitSystem() string { return "" } + // Return if init system can't be found + if process == nil { + return "" + } + // Special cases // OpenRC check if _, err := os.Stat("/usr/sbin/openrc"); err == nil {