@@ -37,6 +37,15 @@ const char* ffDetectInitSystem(FFInitSystemResult* result)
37
37
ffProcessGetInfoLinux ((int ) result -> pid , & result -> name , & result -> exe , & _ , NULL );
38
38
if (result -> exe .chars [0 ] == '/' )
39
39
{
40
+ if (ffStrbufEqualS (& result -> name , "shepherd" ) ||
41
+ ffStrbufEqualS (& result -> name , "guile" ))
42
+ {
43
+ // guile --no-auto-compile shepherd
44
+ // skip first 2 \0 characters to the shepherd path
45
+ const char * tmp = result -> exe .chars + result -> exe .length + 1 ;
46
+ ffStrbufSetS (& result -> exe , tmp + strlen (tmp ) + 1 );
47
+ }
48
+
40
49
// In some old system, /sbin/init is a symlink
41
50
char buf [PATH_MAX ];
42
51
if (realpath (result -> exe .chars , buf ))
@@ -84,16 +93,19 @@ const char* ffDetectInitSystem(FFInitSystemResult* result)
84
93
ffStrbufSubstrAfterLastC (& result -> version , ' ' );
85
94
}
86
95
}
87
- else if (ffStrbufEqualS (& result -> name , "guile " ))
96
+ else if (ffStrbufEqualS (& result -> name , "shepherd " ))
88
97
{
89
- // TODO: guile is actually shepherd
90
- if (ffProcessAppendStdOut (& result -> version , (char * const []) {
91
- ffStrbufEndsWithS (& result -> exe , "/guile" ) ? result -> exe .chars : "guile" ,
92
- "--version" ,
98
+ if (ffProcessAppendStdOut (& result -> version , (char * const []) {
99
+ ffStrbufEndsWithS (& result -> exe , "/shepherd" ) ? result -> exe .chars : "shepherd" ,
100
+ "--version" ,
93
101
NULL ,
94
102
}) == NULL && result -> version .length )
95
103
{
96
- // guile (GNU Guile) 3.0.9
104
+ // shepherd (GNU Shepherd) 1.0.6
105
+ // The first line in the output might not contain the version
106
+ if (!ffStrbufStartsWithS (& result -> version , "shepherd" ))
107
+ ffStrbufSubstrAfterFirstC (& result -> version , '\n' );
108
+
97
109
ffStrbufSubstrBeforeFirstC (& result -> version , '\n' );
98
110
ffStrbufSubstrAfterLastC (& result -> version , ' ' );
99
111
}
0 commit comments