Function: ghostel--shell-history-run

ghostel--shell-history-run is a natively compiled function defined in ghostel-shell.el.

Signature

(ghostel--shell-history-run COMMAND)

Documentation

Run shell COMMAND via process-file and return its parsed entries.

Splits the output on NUL when present, else on newline; trims each entry and drops blanks. Signals user-error on a non-zero exit, including the command's first stderr line.

Source Code

;; Defined in /nix/store/1252krff0gb2kisjcpp45m50cpdskfrl-emacs-packages-deps/share/emacs/site-lisp/ghostel-shell.el
;;; Shell history

(defun ghostel--shell-history-run (command)
  "Run shell COMMAND via `process-file' and return its parsed entries.
Splits the output on NUL when present, else on newline; trims each
entry and drops blanks.  Signals `user-error' on a non-zero exit,
including the command's first stderr line."
  (let ((stderr-file (make-temp-file "ghostel-history")))
    (unwind-protect
        (with-temp-buffer
          (let ((status (process-file "/bin/sh" nil (list t stderr-file) nil
                                      "-c" command)))
            (unless (eql status 0)
              (user-error "Shell history command failed (%s): %s" status
                          (with-temp-buffer
                            (insert-file-contents stderr-file)
                            (buffer-substring (point-min)
                                              (line-end-position)))))
            (let ((output (buffer-string)))
              (split-string output
                            (if (string-search "\0" output) "\0" "\n")
                            t "[ \t\r\n]+"))))
      (delete-file stderr-file))))