From 662dff2bfa28f523355c69ae83c3f16032e11c3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AB=8F=E8=A8=AA=E5=AD=90?= Date: Thu, 20 Jun 2024 05:12:08 +0900 Subject: =?UTF-8?q?=E3=80=8Chw.version=E3=80=8D=E3=81=8C=E7=84=A1=E3=81=84?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E6=80=A7=E3=81=8C=E3=81=82=E3=82=8B=E3=82=89?= =?UTF-8?q?=E3=81=97=E3=81=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/host.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src') 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=//'"); -- cgit v1.2.3