瀏覽代碼

bitwarden--raw-runcmd: capture stderr into its own buffer

Previously, warnings and errors would be mixed with json output. This
resulted in json parsing errors which is not what we want. This commit
changes `call-process' to use a temporary buffer for the stderr
messages.
Sean Farley 2 年之前
父節點
當前提交
072b9e4584
共有 1 個文件被更改,包括 12 次插入7 次删除
  1. 12 7
      bitwarden.el

+ 12 - 7
bitwarden.el

@@ -119,13 +119,18 @@ Returns nil if not unlocked."
   "Run bw command CMD with ARGS.
 Returns a list with the first element being the exit code and the
 second element being the output."
-  (with-temp-buffer
-    (list (apply 'call-process
-                 bitwarden-bw-executable
-                 nil (current-buffer) nil
-                 (cons cmd args))
-          (replace-regexp-in-string "\n$" ""
-                                    (buffer-string)))))
+  (let ((stderr (get-buffer-create " *bitwarden-bw-stderr*")))
+    (with-temp-buffer
+      (list (apply 'call-process
+                   bitwarden-bw-executable
+                   nil               ;; input
+                   (list
+                    (current-buffer) ;; stdout
+                    nil)             ;; TODO capture stderr
+                   nil               ;; re-display buffer
+                   (cons cmd args))
+            (replace-regexp-in-string "\n$" ""
+                                      (buffer-string))))))
 
 (defun bitwarden-runcmd (cmd &rest args)
   "Run bw command CMD with ARGS.