summaryrefslogtreecommitdiffhomepage
path: root/lib/eos/jao-shell.el
diff options
context:
space:
mode:
Diffstat (limited to 'lib/eos/jao-shell.el')
-rw-r--r--lib/eos/jao-shell.el31
1 files changed, 20 insertions, 11 deletions
diff --git a/lib/eos/jao-shell.el b/lib/eos/jao-shell.el
index ff1c160..86bf46b 100644
--- a/lib/eos/jao-shell.el
+++ b/lib/eos/jao-shell.el
@@ -24,25 +24,29 @@
;;; Code:
-(defun jao-shell--quote (x) (shell-quote-argument (format "%s" x)))
-
-;;;###autoload
(defun jao-shell-cmd-lines (cmd &rest args)
- (let ((cmd (concat cmd " " (mapconcat #'jao-shell--quote args " "))))
+ (let ((cmd (concat cmd " " (combine-and-quote-strings args))))
(split-string (shell-command-to-string cmd) "\n" t)))
-;;;###autoload
(defun jao-shell-string (cmd &rest args)
(string-trim (or (car (apply #'jao-shell-cmd-lines cmd args)) "")))
-;;;###autoload
-(defun jao-shell-exec (command)
+(defun jao-shell-exec (command &optional wait)
(interactive
(list (read-shell-command "$ "
(if current-prefix-arg
(cons (concat " " (buffer-file-name)) 0)
""))))
- (start-process-shell-command command nil command))
+ (if wait
+ (call-process-shell-command command)
+ (start-process-shell-command command nil command)))
+
+(defun jao-shell-exec* (command-or-wait &rest args)
+ (let ((wait (and (not (stringp command-or-wait)) command-or-wait))
+ (args (if (stringp command-or-wait) (cons command-or-wait args) args)))
+ (jao-shell-exec (combine-and-quote-strings args) wait)))
+
+(defun jao-shell-exec-p (command) (eq 0 (jao-shell-exec command t)))
(defmacro jao-shell-def-exec (name &rest args)
`(defun ,name (&rest other-args)
@@ -52,9 +56,14 @@
"*jao-exec - console*"
(string-join (append (list ,@args) other-args) " "))))
-;;;###autoload
-(defun jao-shell-running-p (pr)
- (not (string-blank-p (shell-command-to-string (concat "pidof " pr)))))
+(defun jao-shell-output (cmd handler)
+ (with-temp-buffer
+ (call-process-shell-command cmd nil (current-buffer))
+ (beginning-of-buffer)
+ (funcall handler)))
+
+(defun jao-shell-running-p (pr) (eq 0 (jao-shell-exec* t "pidof" pr)))
+(defun jao-shell-kill-p (pr) (eq 0 (jao-shell-exec* t "killall" pr)))
(provide 'jao-shell)
;;; jao-shell.el ends here