2017-10-08 8 views

Répondre

1

Vous pouvez simplement appeler uname -r en tant que commande 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" 

Edit:

la partie -Générique garniture

(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))) 
+0

J'ai essayé de couper la partie -generic xxx avec regex, mais a échoué. Pourriez-vous s'il vous plaît aussi comment le couper? – windrg00