summaryrefslogtreecommitdiff
path: root/src/host.c
diff options
context:
space:
mode:
author諏訪子 <suwako@076.moe>2024-06-20 05:12:08 +0900
committer諏訪子 <suwako@076.moe>2024-06-20 05:12:08 +0900
commit662dff2bfa28f523355c69ae83c3f16032e11c3d (patch)
tree098965f4a6e20868b5bd0c2821cf7a2cf3feafb6 /src/host.c
parenta30c3fda77d8aadfcc388cba4734efedfc79144a (diff)
「hw.version」が無い可能性があるらしい
Diffstat (limited to 'src/host.c')
-rw-r--r--src/host.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/host.c b/src/host.c
index ee88778..72b4cdf 100644
--- a/src/host.c
+++ b/src/host.c
@@ -63,9 +63,13 @@ const char *run_host_command(const char *command) {
void display_host_model() {
#if defined(__OpenBSD__)
- printf("%s", run_host_command("sysctl -n hw.vendor && echo \" \" && "
- "sysctl -n hw.version && echo \" \" &&"
- "sysctl -n hw.product"));
+ const char *cmd = run_host_command("sysctl -n hw.vendor && echo \" \" && "
+ "if [ \"$(sysctl -n hw.version 2>&1)\" != "
+ "\"sysctl: hw.version: value is not available\" ]; then "
+ "sysctl -n hw.version && echo \" \"; fi && "
+ "sysctl -n hw.product");
+ printf("%s", cmd);
+ free((void *)cmd);
#elif defined(__FreeBSD__)
const char *family = run_host_command("kenv | grep smbios.system.family | "
"sed 's/\"//g' | sed 's/smbios.system.family=//'");