diff options
author | 諏訪子 <suwako@076.moe> | 2024-06-20 05:12:08 +0900 |
---|---|---|
committer | 諏訪子 <suwako@076.moe> | 2024-06-20 05:12:08 +0900 |
commit | 662dff2bfa28f523355c69ae83c3f16032e11c3d (patch) | |
tree | 098965f4a6e20868b5bd0c2821cf7a2cf3feafb6 /src/host.c | |
parent | a30c3fda77d8aadfcc388cba4734efedfc79144a (diff) |
「hw.version」が無い可能性があるらしい
Diffstat (limited to 'src/host.c')
-rw-r--r-- | src/host.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -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=//'"); |