12
我叫git獲取頂層目錄(根據 Is there a way to get the git root directory in one command? )。如何從流程輸出中刪除換行符?
(let ((tmpbuffer (get-buffer-create (make-temp-name "git"))))
(call-process "git" nil tmpbuffer nil "rev-parse" "--show-toplevel")
(with-current-buffer tmpbuffer
(with-output-to-string
(princ (buffer-string))
(kill-buffer))))
但是有返回的字符串的換行符。我不知道如何擺脫它。
這不只是在輸出結束時刪除換行符。我添加了一個替代答案。 –