I want to write an eshell function that sort of wraps an existing command-line script. In order to do this, I want to be able to execute a shell command from an eshell function. My first instinct was to do something like
(defn eshell/myfunc ()
(shell-command "mycommand"))
And this sort of works, except for a few problems. It runs in an inferior shell instead of behaving like a real "exec" command. This means that, among other things, the command "myfunc" in eshell appears to block while the command is running. The output of "mycommand" is collected an appears in a Shell Output buffer at the end, but it doesn't replicate the behavior of a normal shell function, where the standard output appears while it runs.
So, what's the correct way to do this?
Try
(start-process-shell-command "foo" (current-buffer) "mycommand")
If you need more control, see Emacs Lisp Referece Manual, Sectioin 37.4 Creating an Asynchronous Process.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With