How do I delete the newline from a process output?

前端 未结 4 1279
傲寒
傲寒 2021-01-11 09:39

I call git get the toplevel dir (according to Is there a way to get the git root directory in one command? ).

(let ((tmpbuffer (get-buffer-create (make-temp-         


        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-11 09:59

    Assuming it is stored in a variable output-string, the final newline at the end can be removed this way:

    (substring output-string 0 -1)
    

    With the shell-command way, it would look like this:

    (substring
      (shell-command-to-string "git rev-parse --show-toplevel")
      0 -1)
    

提交回复
热议问题