diff --git a/lisp/lib/system.el b/lisp/lib/system.el index 6aad3a5b1..e7961103a 100644 --- a/lisp/lib/system.el +++ b/lisp/lib/system.el @@ -10,7 +10,8 @@ (IS-MAC 'macos) ((and (file-exists-p "/etc/os-release") (with-temp-buffer - (insert-file-contents "/etc/os-release") + (let ((coding-system-for-read 'utf-8-auto)) + (insert-file-contents "/etc/os-release")) (when (re-search-forward "^ID=\"?\\([^\"\n]+\\)\"?" nil t) (intern (downcase (match-string 1))))))) ;; A few redundancies in case os-release fails us @@ -28,7 +29,8 @@ (defun doom-system-distro-version () "Return a distro name and version string." (letf! (defun sh (&rest args) (cdr (apply #'doom-call-process args))) - (let ((distro (doom-system-distro))) + (let ((distro (doom-system-distro)) + (coding-system-for-read 'utf-8-auto)) (cond ((eq distro 'windows) (format "Windows %s" "Unknown")) ; TODO @@ -40,12 +42,17 @@ (format "NixOS %s" (sh "nixos-version"))) ((and (file-exists-p "/etc/os-release") (with-temp-buffer - (insert-file-contents "/etc/os-release") - (when (re-search-forward "^PRETTY_NAME=\"?\\([^\"\n]+\\)\"?" nil t) - (match-string 1))))) + (insert-file-contents "/etc/os-release") + (when (re-search-forward "^PRETTY_NAME=\"?\\([^\"\n]+\\)\"?" nil t) + (match-string 1))))) ((when-let (files (doom-glob "/etc/*-release")) (truncate-string-to-width - (replace-regexp-in-string "\n" " " (cat (car files) 73) nil t) + (replace-regexp-in-string + "\n" " " + (with-temp-buffer + (insert-file-contents (car files) nil nil 73) + (buffer-string)) + nil t) 64 nil nil "..."))) ((concat "Unknown " (sh "uname" "-v")))))))