我正在寻找一种在 Emacs Lisp 中获取 Linux 版本的方法,无论形式是字符串还是数字。 如果有,请留下您的代码片段。
谢谢。
最佳答案
您只需调用 uname -r
作为 shell 命令即可。
(defun my-linux-version ()
"Return the linux version as a string."
(shell-command-to-string "printf %s $(uname -r)"))
ELISP> (my-linux-version)
"4.4.0-96-generic"
<小时/>
编辑:
trim the part -generic
(defun my-linux-version ()
"Return the linux version as a string."
(let ((version (shell-command-to-string "printf %s $(uname -r)")))
(replace-regexp-in-string "-generic$" "" version)))
关于linux - 如何在 Emacs 中获取 Linux 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46629230/