Function: report-emacs-bug--os-description

report-emacs-bug--os-description is a byte-compiled function defined in emacsbug.el.gz.

Signature

(report-emacs-bug--os-description)

Documentation

Return a string describing the operating system, or nil.

Source Code

;; Defined in /usr/src/emacs/lisp/mail/emacsbug.el.gz
(defun report-emacs-bug--os-description ()
  "Return a string describing the operating system, or nil."
  (cond ((eq system-type 'darwin)
         (let (os)
           (with-temp-buffer
             (when (eq 0 (ignore-errors
                           (call-process "sw_vers" nil '(t nil) nil)))
               (dolist (s '("ProductName" "ProductVersion"))
                 (goto-char (point-min))
                 (if (re-search-forward (format "^%s\\s-*:\\s-+\\(.*\\)$" s)
                                        nil t)
                     (setq os (concat os " " (match-string 1)))))))
           os))
        ((eq system-type 'windows-nt)
         (or report-emacs-bug--os-description
             (setq report-emacs-bug--os-description (w32--os-description))))
        ((eq system-type 'berkeley-unix)
         (with-temp-buffer
           (when
               (or (eq 0 (ignore-errors (call-process "freebsd-version" nil
                                                      '(t nil) nil "-u")))
                   (progn (erase-buffer)
                          (eq 0 (ignore-errors
                                  (call-process "uname" nil
                                                '(t nil) nil "-a")))))
             (unless (zerop (buffer-size))
               (goto-char (point-min))
               (buffer-substring (line-beginning-position)
                                 (line-end-position))))))
        ;; TODO Cygwin, Solaris (usg-unix-v).
        (t
         (or (let ((file "/etc/os-release"))
               (and (file-readable-p file)
                    (with-temp-buffer
                      (insert-file-contents file)
                      (if (re-search-forward
                           "^\\sw*PRETTY_NAME=\"?\\(.+?\\)\"?$" nil t)
                          (match-string 1)
                        (let (os)
                          (when (re-search-forward
                                 "^\\sw*NAME=\"?\\(.+?\\)\"?$" nil t)
                            (setq os (match-string 1))
                            (if (re-search-forward
                                 "^\\sw*VERSION=\"?\\(.+?\\)\"?$" nil t)
                                (setq os (concat os " " (match-string 1))))
                            os))))))
             (with-temp-buffer
               (when (eq 0 (ignore-errors
                             (call-process "lsb_release" nil '(t nil)
                                           nil "-d")))
                 (goto-char (point-min))
                 (if (looking-at "^\\sw+:\\s-+")
                     (goto-char (match-end 0)))
                 (buffer-substring (point) (line-end-position))))
             (let ((file "/etc/lsb-release"))
               (and (file-readable-p file)
                    (with-temp-buffer
                      (insert-file-contents file)
                      (if (re-search-forward
                           "^\\sw*DISTRIB_DESCRIPTION=\"?\\(.*release.*?\\)\"?$" nil t)
                          (match-string 1)))))
             (catch 'found
               (dolist (f (append (file-expand-wildcards "/etc/*-release")
                                  '("/etc/debian_version")))
                 (and (not (member (file-name-nondirectory f)
                                   '("lsb-release" "os-release")))
                      (file-readable-p f)
                      (with-temp-buffer
                        (insert-file-contents f)
                        (if (not (zerop (buffer-size)))
                            (throw 'found
                                   (format "%s%s"
                                           (if (equal (file-name-nondirectory f)
                                                      "debian_version")
                                               "Debian " "")
                                           (buffer-substring
                                            (line-beginning-position)
                                            (line-end-position)))))))))))))