From c432776b95f4f50c96c451ac43cf7c666bceba81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20K=C3=A4stner?= Date: Sat, 1 May 2021 17:48:15 +0200 Subject: [PATCH] os: Check for programs/files instead of ignoring errors --- eshell-info-banner.el | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/eshell-info-banner.el b/eshell-info-banner.el index 7e8e42e..6d09734 100644 --- a/eshell-info-banner.el +++ b/eshell-info-banner.el @@ -317,10 +317,11 @@ If RELEASE-FILE is nil, use '/etc/os-release'." (defun eshell-info-banner--get-os-information () "Get operating system identifying information." - (or (ignore-errors (eshell-info-banner--get-os-information-from-hostnamectl)) - (ignore-errors (eshell-info-banner--get-os-information-from-lsb-release)) - (ignore-errors (eshell-info-banner--get-os-information-from-release)) - "Unkown")) + (cond + ((executable-find "hostnamectl") (eshell-info-banner--get-os-information-from-hostnamectl)) + ((executable-find "lsb_release") (eshell-info-banner--get-os-information-from-lsb-release)) + ((file-exists-p "/etc/os-release") (eshell-info-banner--get-os-information-from-release-file)) + (t "Unknown"))) ; Public functions ;;;;;;;;;;;;;;;;;;;;