NetBSD: 起動時間の修正

このコミットが含まれているのは:
守矢諏訪子 2024-06-18 16:42:23 +09:00
コミット 656923fefb
3個のファイルの変更11行の追加0行の削除

2
main.c
ファイルの表示

@ -72,8 +72,10 @@ int main() {
printf("%s ", LOGO[4]);
printf(COLOR"%s%s"RESET, "Uptime", ": ");
#ifndef __NetBSD__
display_days();
printf(", ");
#endif
display_time();
printf("\n");

ファイルの表示

@ -21,11 +21,18 @@ void run_uptime_command(const char *command) {
pclose(p);
}
#ifndef __NetBSD__
void display_days() {
run_uptime_command("uptime | awk '{print $3}' && echo \" days\"");
}
#endif
void display_time() {
#if defined(__NetBSD__)
run_uptime_command("uptime | awk '{print $3}' | sed 's/,//' | "
"sed 's/:/ hours, /' && echo \" mins\"");
#else
run_uptime_command("uptime | awk '{print $5}' | sed 's/,//' | "
"sed 's/:/ hours, /' && echo \" mins\"");
#endif
}

ファイルの表示

@ -1,7 +1,9 @@
#ifndef UPTIME_H
#define UPTIME_H
#ifndef __NetBSD__
void display_days();
#endif
void display_time();
#endif